• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Go で書き直した Ikemen


Commit MetaInfo

Revision3bca299fa04a19c608cc8336daf92693637309b3 (tree)
Zeit2019-07-30 13:09:15
Autorneatunsou <sisiy4excite@gmai...>
Commiterneatunsou

Log Message

sffのコピー画像を読み込む際にパレット情報を必ず上書きしていたのを修正
varの情報を保存して読み込む機能を追加

Ändern Zusammenfassung

Diff

--- a/src/bytecode.go
+++ b/src/bytecode.go
@@ -1,7 +1,9 @@
11 package main
22
33 import (
4+ "encoding/gob"
45 "math"
6+ "os"
57 "path/filepath"
68 "unsafe"
79 )
@@ -5883,6 +5885,110 @@ func (sc matchRestart) Run(c *Char, _ []int32) bool {
58835885 return false
58845886 }
58855887
5888+type saveFile StateControllerBase
5889+
5890+const (
5891+ saveFile_path byte = iota
5892+ saveFile_saveData
5893+ saveFile_redirectid
5894+)
5895+
5896+func (sc saveFile) Run(c *Char, _ []int32) bool {
5897+ crun := c
5898+ var path string
5899+ var data SaveData
5900+ StateControllerBase(sc).run(c, func(id byte, exp []BytecodeExp) bool {
5901+ switch id {
5902+ case saveFile_path:
5903+ path = string(*(*[]byte)(unsafe.Pointer(&exp[0])))
5904+ case saveFile_saveData:
5905+ data = SaveData(exp[0].evalI(c))
5906+ case saveFile_redirectid:
5907+ if rid := sys.playerID(exp[0].evalI(c)); rid != nil {
5908+ crun = rid
5909+ } else {
5910+ return false
5911+ }
5912+ }
5913+ return true
5914+ })
5915+ if path != "" {
5916+ encodeFile, err := os.Create(filepath.Dir(c.gi().def) + "/" + path)
5917+ if err != nil {
5918+ panic(err)
5919+ }
5920+ defer encodeFile.Close()
5921+ encoder := gob.NewEncoder(encodeFile)
5922+ switch data {
5923+ case SaveData_map:
5924+ if err := encoder.Encode(crun.mapArray); err != nil {
5925+ panic(err)
5926+ }
5927+ case SaveData_var:
5928+ if err := encoder.Encode(crun.ivar); err != nil {
5929+ panic(err)
5930+ }
5931+ case SaveData_fvar:
5932+ if err := encoder.Encode(crun.fvar); err != nil {
5933+ panic(err)
5934+ }
5935+ }
5936+ }
5937+ return false
5938+}
5939+
5940+type loadFile StateControllerBase
5941+
5942+const (
5943+ loadFile_path byte = iota
5944+ loadFile_saveData
5945+ loadFile_redirectid
5946+)
5947+
5948+func (sc loadFile) Run(c *Char, _ []int32) bool {
5949+ crun := c
5950+ var path string
5951+ var data SaveData
5952+ StateControllerBase(sc).run(c, func(id byte, exp []BytecodeExp) bool {
5953+ switch id {
5954+ case loadFile_path:
5955+ path = string(*(*[]byte)(unsafe.Pointer(&exp[0])))
5956+ case loadFile_saveData:
5957+ data = SaveData(exp[0].evalI(c))
5958+ case loadFile_redirectid:
5959+ if rid := sys.playerID(exp[0].evalI(c)); rid != nil {
5960+ crun = rid
5961+ } else {
5962+ return false
5963+ }
5964+ }
5965+ return true
5966+ })
5967+ if path != "" {
5968+ decodeFile, err := os.Open(filepath.Dir(c.gi().def) + "/" + path)
5969+ if err != nil {
5970+ panic(err)
5971+ }
5972+ defer decodeFile.Close()
5973+ decoder := gob.NewDecoder(decodeFile)
5974+ switch data {
5975+ case SaveData_map:
5976+ if err := decoder.Decode(&crun.mapArray); err != nil {
5977+ panic(err)
5978+ }
5979+ case SaveData_var:
5980+ if err := decoder.Decode(&crun.ivar); err != nil {
5981+ panic(err)
5982+ }
5983+ case SaveData_fvar:
5984+ if err := decoder.Decode(&crun.fvar); err != nil {
5985+ panic(err)
5986+ }
5987+ }
5988+ }
5989+ return false
5990+}
5991+
58865992 type StateBytecode struct {
58875993 stateType StateType
58885994 moveType MoveType
--- a/src/char.go
+++ b/src/char.go
@@ -90,6 +90,14 @@ const (
9090 Space_screen
9191 )
9292
93+type SaveData int32
94+
95+const (
96+ SaveData_map SaveData = iota
97+ SaveData_var
98+ SaveData_fvar
99+)
100+
93101 type ClsnRect [][4]float32
94102
95103 func (cr *ClsnRect) Add(clsn []float32, x, y, xs, ys float32) {
--- a/src/compiler.go
+++ b/src/compiler.go
@@ -126,6 +126,8 @@ func newCompiler() *Compiler {
126126 "zoom": c.zoom,
127127 "mapset": c.mapSet,
128128 "matchrestart": c.matchRestart,
129+ "savefile": c.saveFile,
130+ "loadfile": c.loadFile,
129131 "forcefeedback": c.null,
130132 "null": c.null,
131133 }
@@ -2808,6 +2810,27 @@ func (c *Compiler) paramSpace(is IniSection, sc *StateControllerBase,
28082810 })
28092811 }
28102812
2813+func (c *Compiler) paramSaveData(is IniSection, sc *StateControllerBase,
2814+ id byte) error {
2815+ return c.stateParam(is, "savedata", func(data string) error {
2816+ if len(data) <= 1 {
2817+ return Error("値が指定されていません")
2818+ }
2819+ var sv SaveData
2820+ if len(data) >= 2 {
2821+ if strings.ToLower(data[:2]) == "ma" {
2822+ sv = SaveData_map
2823+ } else if strings.ToLower(data[:2]) == "va" {
2824+ sv = SaveData_var
2825+ } else if strings.ToLower(data[:2]) == "fv" {
2826+ sv = SaveData_fvar
2827+ }
2828+ }
2829+ sc.add(id, sc.iToExp(int32(sv)))
2830+ return nil
2831+ })
2832+}
2833+
28112834 func (c *Compiler) paramTrans(is IniSection, sc *StateControllerBase,
28122835 prefix string, id byte, afterImage bool) error {
28132836 return c.stateParam(is, prefix+"trans", func(data string) error {
@@ -6381,6 +6404,54 @@ func (c *Compiler) matchRestart(is IniSection, sc *StateControllerBase,
63816404 return *ret, err
63826405 }
63836406
6407+func (c *Compiler) saveFile(is IniSection, sc *StateControllerBase,
6408+ _ int8) (StateController, error) {
6409+ ret, err := (*saveFile)(sc), c.stateSec(is, func() error {
6410+ if err := c.paramValue(is, sc, "redirectid",
6411+ saveFile_redirectid, VT_Int, 1, false); err != nil {
6412+ return err
6413+ }
6414+ if err := c.stateParam(is, "path", func(data string) error {
6415+ if len(data) < 2 || data[0] != '"' || data[len(data)-1] != '"' {
6416+ return Error("\"で囲まれていません")
6417+ }
6418+ sc.add(saveFile_path, sc.beToExp(BytecodeExp(data[1:len(data)-1])))
6419+ return nil
6420+ }); err != nil {
6421+ return err
6422+ }
6423+ if err := c.paramSaveData(is, sc, saveFile_saveData); err != nil {
6424+ return err
6425+ }
6426+ return nil
6427+ })
6428+ return *ret, err
6429+}
6430+
6431+func (c *Compiler) loadFile(is IniSection, sc *StateControllerBase,
6432+ _ int8) (StateController, error) {
6433+ ret, err := (*loadFile)(sc), c.stateSec(is, func() error {
6434+ if err := c.paramValue(is, sc, "redirectid",
6435+ loadFile_redirectid, VT_Int, 1, false); err != nil {
6436+ return err
6437+ }
6438+ if err := c.stateParam(is, "path", func(data string) error {
6439+ if len(data) < 2 || data[0] != '"' || data[len(data)-1] != '"' {
6440+ return Error("\"で囲まれていません")
6441+ }
6442+ sc.add(loadFile_path, sc.beToExp(BytecodeExp(data[1:len(data)-1])))
6443+ return nil
6444+ }); err != nil {
6445+ return err
6446+ }
6447+ if err := c.paramSaveData(is, sc, loadFile_saveData); err != nil {
6448+ return err
6449+ }
6450+ return nil
6451+ })
6452+ return *ret, err
6453+}
6454+
63846455 func (c *Compiler) null(is IniSection, sc *StateControllerBase,
63856456 _ int8) (StateController, error) {
63866457 return nullStateController, nil
--- a/src/image.go
+++ b/src/image.go
@@ -513,7 +513,9 @@ func (s *Sprite) shareCopy(src *Sprite) {
513513 s.Pal = src.Pal
514514 s.Tex = src.Tex
515515 s.Size = src.Size
516- s.palidx = src.palidx
516+ if s.palidx < 0 {
517+ s.palidx = src.palidx
518+ }
517519 }
518520 func (s *Sprite) GetPal(pl *PaletteList) []uint32 {
519521 if s.Pal != nil || s.rle <= -11 {
--- a/src/system.go
+++ b/src/system.go
@@ -64,15 +64,15 @@ var sys = System{
6464 keyInput: glfw.KeyUnknown,
6565 keyString: "",
6666 // Localcoord sceenpack
67- luaSpriteScale: 1,
68- luaSmallPortraitScale: 1,
69- luaBigPortraitScale: 1,
70- luaSpriteOffsetX: 0,
71- lifebarScale: 1,
72- lifebarOffsetX: 0,
67+ luaSpriteScale: 1,
68+ luaSmallPortraitScale: 1,
69+ luaBigPortraitScale: 1,
70+ luaSpriteOffsetX: 0,
71+ lifebarScale: 1,
72+ lifebarOffsetX: 0,
7373 //Shader vars
7474 MultisampleAntialiasing: false,
75- PostProcessingShader: 0,
75+ PostProcessingShader: 0,
7676 }
7777
7878 type TeamMode int32
@@ -256,7 +256,7 @@ type System struct {
256256 lifebarOffsetX float32
257257 LocalcoordScalingType int32
258258
259- PostProcessingShader int32
259+ PostProcessingShader int32
260260 MultisampleAntialiasing bool
261261 }
262262