• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

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

Go で書き直した Ikemen


Commit MetaInfo

修订版6c1e69841e14f57b0fdebc368ea727263d822e88 (tree)
时间2016-12-16 00:10:07
作者SUEHIRO <supersuehiro@user...>
CommiterSUEHIRO

Log Message

見直しやミスの修正などをした

更改概述

差异

--- a/src/bytecode.go
+++ b/src/bytecode.go
@@ -458,9 +458,6 @@ func (be BytecodeExp) toI() int32 {
458458 return *(*int32)(unsafe.Pointer(&be[0]))
459459 }
460460 func (be *BytecodeExp) appendValue(bv BytecodeValue) (ok bool) {
461- if bv.IsSF() {
462- return false
463- }
464461 switch bv.t {
465462 case VT_Float:
466463 be.append(OC_float)
@@ -492,16 +489,14 @@ func (_ BytecodeExp) blnot(v *BytecodeValue) {
492489 v.t = VT_Int
493490 }
494491 func (_ BytecodeExp) pow(v1 *BytecodeValue, v2 BytecodeValue, pn int) {
495- t := ValueType(Min(int32(v1.t), int32(v2.t)))
496- if t == VT_Float {
492+ if ValueType(Min(int32(v1.t), int32(v2.t))) == VT_Float {
497493 v1.SetF(float32(math.Pow(float64(v1.ToF()), float64(v2.ToF()))))
498494 } else if v2.ToF() < 0 {
499495 if sys.cgi[pn].ver[0] == 1 {
500496 v1.SetF(float32(math.Pow(float64(v1.ToI()), float64(v2.ToI()))))
501497 } else {
502498 f := float32(math.Pow(float64(v1.ToI()), float64(v2.ToI())))
503- i := *(*int32)(unsafe.Pointer(&f))
504- v1.SetI(i << 29)
499+ v1.SetI(*(*int32)(unsafe.Pointer(&f)) << 29)
505500 }
506501 } else {
507502 i1, i2, hb := v1.ToI(), v2.ToI(), int32(-1)
@@ -524,7 +519,30 @@ func (_ BytecodeExp) pow(v1 *BytecodeValue, v2 BytecodeValue, pn int) {
524519 v1.SetI(i)
525520 }
526521 }
527-func (be BytecodeExp) run(c *Char) BytecodeValue {
522+func (_ BytecodeExp) mul(v1 *BytecodeValue, v2 BytecodeValue) {
523+ if ValueType(Min(int32(v1.t), int32(v2.t))) == VT_Float {
524+ v1.SetF(v1.ToF() * v2.ToF())
525+ } else {
526+ v1.SetI(v1.ToI() * v2.ToI())
527+ }
528+}
529+func (_ BytecodeExp) div(v1 *BytecodeValue, v2 BytecodeValue) {
530+ if ValueType(Min(int32(v1.t), int32(v2.t))) == VT_Float {
531+ v1.SetF(v1.ToF() / v2.ToF())
532+ } else if v2.ToI() == 0 {
533+ *v1 = BytecodeSF()
534+ } else {
535+ v1.SetI(v1.ToI() / v2.ToI())
536+ }
537+}
538+func (_ BytecodeExp) mod(v1 *BytecodeValue, v2 BytecodeValue) {
539+ if v2.ToI() == 0 {
540+ *v1 = BytecodeSF()
541+ } else {
542+ v1.SetI(v1.ToI() % v2.ToI())
543+ }
544+}
545+func (be BytecodeExp) run(c *Char, scpn int) BytecodeValue {
528546 sys.bcStack.Clear()
529547 for i := 1; i <= len(be); i++ {
530548 switch be[i-1] {
@@ -541,17 +559,34 @@ func (be BytecodeExp) run(c *Char) BytecodeValue {
541559 be.blnot(sys.bcStack.Top())
542560 case OC_pow:
543561 v2 := sys.bcStack.Pop()
544- be.pow(sys.bcStack.Top(), v2, c.playerno)
562+ be.pow(sys.bcStack.Top(), v2, scpn)
563+ case OC_mul:
564+ v2 := sys.bcStack.Pop()
565+ be.mul(sys.bcStack.Top(), v2)
566+ case OC_div:
567+ v2 := sys.bcStack.Pop()
568+ be.div(sys.bcStack.Top(), v2)
569+ case OC_mod:
570+ v2 := sys.bcStack.Pop()
571+ be.mod(sys.bcStack.Top(), v2)
545572 default:
546573 unimplemented()
547574 }
548575 }
549576 return sys.bcStack.Pop()
550577 }
551-func (be BytecodeExp) eval(c *Char) float64 { return be.run(c).v }
578+func (be BytecodeExp) evalF(c *Char, scpn int) float32 {
579+ return be.run(c, scpn).ToF()
580+}
581+func (be BytecodeExp) evalI(c *Char, scpn int) int32 {
582+ return be.run(c, scpn).ToI()
583+}
584+func (be BytecodeExp) evalB(c *Char, scpn int) bool {
585+ return be.run(c, scpn).ToB()
586+}
552587
553588 type StateController interface {
554- Run(c *Char) (changeState bool)
589+ Run(c *Char, scpn int) (changeState bool)
555590 }
556591
557592 const (
@@ -559,8 +594,14 @@ const (
559594 SCID_const byte = 128
560595 )
561596
562-type StateControllerBase []byte
597+type StateControllerBase struct {
598+ playerNo int
599+ code []byte
600+}
563601
602+func newStateControllerBase(pn int) *StateControllerBase {
603+ return &StateControllerBase{playerNo: pn}
604+}
564605 func (scb StateControllerBase) beToExp(be ...BytecodeExp) []BytecodeExp {
565606 return be
566607 }
@@ -581,24 +622,24 @@ func (scb StateControllerBase) iToExp(i ...int32) (exp []BytecodeExp) {
581622 return
582623 }
583624 func (scb *StateControllerBase) add(id byte, exp []BytecodeExp) {
584- *scb = append(*scb, id, byte(len(exp)))
625+ scb.code = append(scb.code, id, byte(len(exp)))
585626 for _, e := range exp {
586627 l := int32(len(e))
587- *scb = append(*scb, (*(*[4]byte)(unsafe.Pointer(&l)))[:]...)
588- *scb = append(*scb, (*(*[]byte)(unsafe.Pointer(&e)))...)
628+ scb.code = append(scb.code, (*(*[4]byte)(unsafe.Pointer(&l)))[:]...)
629+ scb.code = append(scb.code, (*(*[]byte)(unsafe.Pointer(&e)))...)
589630 }
590631 }
591632 func (scb StateControllerBase) run(f func(byte, []BytecodeExp) bool) bool {
592- for i := 0; i < len(scb); {
593- id := scb[i]
633+ for i := 0; i < len(scb.code); {
634+ id := scb.code[i]
594635 i++
595- n := scb[i]
636+ n := scb.code[i]
596637 i++
597638 exp := make([]BytecodeExp, n)
598- for m := byte(0); m < n; m++ {
599- l := *(*int32)(unsafe.Pointer(&scb[i]))
639+ for m := 0; m < int(n); m++ {
640+ l := *(*int32)(unsafe.Pointer(&scb.code[i]))
600641 i += 4
601- exp[m] = (*(*BytecodeExp)(unsafe.Pointer(&scb)))[i : i+int(l)]
642+ exp[m] = (*(*BytecodeExp)(unsafe.Pointer(&scb.code)))[i : i+int(l)]
602643 i += int(l)
603644 }
604645 if !f(id, exp) {
@@ -633,39 +674,39 @@ const (
633674 stateDef_poweradd_c = stateDef_poweradd + SCID_const
634675 )
635676
636-func (sd stateDef) Run(c *Char) bool {
677+func (sd stateDef) Run(c *Char, scpn int) bool {
637678 StateControllerBase(sd).run(func(id byte, exp []BytecodeExp) bool {
638679 switch id {
639680 case stateDef_hitcountpersist, stateDef_hitcountpersist_c:
640- if id == stateDef_hitcountpersist_c || exp[0].eval(c) == 0 {
681+ if id == stateDef_hitcountpersist_c || !exp[0].evalB(c, scpn) {
641682 c.clearHitCount()
642683 }
643684 case stateDef_movehitpersist, stateDef_movehitpersist_c:
644- if id == stateDef_movehitpersist_c || exp[0].eval(c) == 0 {
685+ if id == stateDef_movehitpersist_c || !exp[0].evalB(c, scpn) {
645686 c.clearMoveHit()
646687 }
647688 case stateDef_hitdefpersist, stateDef_hitdefpersist_c:
648- if id == stateDef_hitdefpersist_c || exp[0].eval(c) == 0 {
689+ if id == stateDef_hitdefpersist_c || !exp[0].evalB(c, scpn) {
649690 c.clearHitDef()
650691 }
651692 case stateDef_sprpriority:
652- c.setSprPriority(int32(exp[0].eval(c)))
693+ c.setSprPriority(exp[0].evalI(c, scpn))
653694 case stateDef_sprpriority_c:
654695 c.setSprPriority(exp[0].toI())
655696 case stateDef_facep2, stateDef_facep2_c:
656- if id == stateDef_facep2_c || exp[0].eval(c) != 0 {
697+ if id == stateDef_facep2_c || exp[0].evalB(c, scpn) {
657698 c.faceP2()
658699 }
659700 case stateDef_juggle:
660- c.setJuggle(int32(exp[0].eval(c)))
701+ c.setJuggle(exp[0].evalI(c, scpn))
661702 case stateDef_juggle_c:
662703 c.setJuggle(exp[0].toI())
663704 case stateDef_velset:
664- c.setXV(float32(exp[0].eval(c)))
705+ c.setXV(exp[0].evalF(c, scpn))
665706 if len(exp) > 1 {
666- c.setYV(float32(exp[1].eval(c)))
707+ c.setYV(exp[1].evalF(c, scpn))
667708 if len(exp) > 2 {
668- exp[2].run(c)
709+ exp[2].run(c, scpn)
669710 }
670711 }
671712 case stateDef_velset_c:
@@ -674,15 +715,15 @@ func (sd stateDef) Run(c *Char) bool {
674715 c.setYV(exp[1].toF())
675716 }
676717 case stateDef_anim:
677- c.changeAnim(int32(exp[0].eval(c)))
718+ c.changeAnim(exp[0].evalI(c, scpn))
678719 case stateDef_anim_c:
679720 c.changeAnim(exp[0].toI())
680721 case stateDef_ctrl:
681- c.setCtrl(exp[0].eval(c) != 0)
722+ c.setCtrl(exp[0].evalB(c, scpn))
682723 case stateDef_ctrl_c:
683724 c.setCtrl(exp[0].toI() != 0)
684725 case stateDef_poweradd:
685- c.addPower(int32(exp[0].eval(c)))
726+ c.addPower(exp[0].evalI(c, scpn))
686727 case stateDef_poweradd_c:
687728 c.addPower(exp[0].toI())
688729 }
--- a/src/char.go
+++ b/src/char.go
@@ -272,8 +272,8 @@ type Char struct {
272272 name string
273273 cmd []CommandList
274274 key int
275- helperindex int
276- playerno int
275+ helperIndex int
276+ playerNo int
277277 keyctrl bool
278278 player bool
279279 sprpriority int32
@@ -287,8 +287,8 @@ func newChar(n, idx int) (c *Char) {
287287 return c
288288 }
289289 func (c *Char) init(n, idx int) {
290- c.playerno, c.helperindex = n, idx
291- if c.helperindex == 0 {
290+ c.playerNo, c.helperIndex = n, idx
291+ if c.helperIndex == 0 {
292292 c.keyctrl, c.player = true, true
293293 }
294294 c.key = n
@@ -297,7 +297,7 @@ func (c *Char) init(n, idx int) {
297297 }
298298 }
299299 func (c *Char) load(def string) error {
300- gi := &sys.cgi[c.playerno]
300+ gi := &sys.cgi[c.playerNo]
301301 gi.displayname, gi.author, gi.sff, gi.snd = "", "", nil, nil
302302 gi.anim = NewAnimationTable()
303303 for i := range gi.palkeymap {
--- a/src/compiler.go
+++ b/src/compiler.go
@@ -12,12 +12,11 @@ const kuuhaktokigou = " !=<>()|&+-*/%,[]^|:\"\t\r\n"
1212 type ExpFunc func(out *BytecodeExp, in *string) (BytecodeValue, error)
1313 type Compiler struct {
1414 cmdl *CommandList
15- valCnt int
1615 maeOp string
1716 usiroOp bool
1817 norange bool
1918 token string
20- playerno int
19+ playerNo int
2120 }
2221
2322 func newCompiler() *Compiler {
@@ -181,13 +180,13 @@ func (_ *Compiler) isOperator(token string) int {
181180 }
182181 return 0
183182 }
184-func (c *Compiler) operator(in *string) (string, error) {
183+func (c *Compiler) operator(in *string) error {
185184 if len(c.maeOp) > 0 {
186185 if opp := c.isOperator(c.token); opp <= c.isOperator(c.maeOp) {
187186 if opp < 0 || ((!c.usiroOp || c.token[0] != '(') &&
188187 (c.token[0] < 'A' || c.token[0] > 'Z') &&
189188 (c.token[0] < 'a' || c.token[0] > 'z')) {
190- return "", Error(c.maeOp + "が不正です")
189+ return Error(c.maeOp + "が不正です")
191190 }
192191 *in = c.token + " " + *in
193192 c.token = c.maeOp
@@ -195,7 +194,7 @@ func (c *Compiler) operator(in *string) (string, error) {
195194 c.norange = true
196195 }
197196 }
198- return c.token, nil
197+ return nil
199198 }
200199 func (c *Compiler) number(token string) BytecodeValue {
201200 f, err := strconv.ParseFloat(token, 64)
@@ -223,7 +222,6 @@ func (c *Compiler) expValue(out *BytecodeExp, in *string) (BytecodeValue,
223222 c.usiroOp, c.norange = true, false
224223 bv := c.number(c.token)
225224 if !bv.IsSF() {
226- c.valCnt++
227225 c.token = c.tokenizer(in)
228226 return bv, nil
229227 }
@@ -231,11 +229,10 @@ func (c *Compiler) expValue(out *BytecodeExp, in *string) (BytecodeValue,
231229 defer func() { c.usiroOp = false }()
232230 }
233231 unimplemented()
234- c.valCnt++
235232 c.token = c.tokenizer(in)
236233 return bv, nil
237234 }
238-func (c *Compiler) renzikuEnzansihaError(in *string) error {
235+func (c *Compiler) renzokuEnzansihaError(in *string) error {
239236 *in = strings.TrimSpace(*in)
240237 if len(*in) > 0 {
241238 switch (*in)[0] {
@@ -265,14 +262,13 @@ func (c *Compiler) expPostNot(out *BytecodeExp, in *string) (BytecodeValue,
265262 }
266263 c.token = c.tokenizer(in)
267264 }
268-
269265 if len(c.maeOp) == 0 {
270266 opp := c.isOperator(c.token)
271267 if opp == 0 {
272268 if !c.usiroOp && c.token == "(" {
273269 return BytecodeSF(), Error("演算子がありません")
274270 }
275- oldin := *in
271+ oldtoken, oldin := c.token, *in
276272 var dummyout BytecodeExp
277273 if _, err := c.expValue(&dummyout, in); err != nil {
278274 return BytecodeSF(), err
@@ -280,13 +276,14 @@ func (c *Compiler) expPostNot(out *BytecodeExp, in *string) (BytecodeValue,
280276 if c.isOperator(c.token) <= 0 {
281277 return BytecodeSF(), Error("演算子がありません")
282278 }
283- if err := c.renzikuEnzansihaError(in); err != nil {
279+ if err := c.renzokuEnzansihaError(in); err != nil {
284280 return BytecodeSF(), err
285281 }
286282 oldin = oldin[:len(oldin)-len(*in)]
287- *in = "(" + oldin[:strings.LastIndex(oldin, c.token)] + *in
283+ *in = oldtoken + " " + oldin[:strings.LastIndex(oldin, c.token)] + " " +
284+ *in
288285 } else if opp > 0 {
289- if err := c.renzikuEnzansihaError(in); err != nil {
286+ if err := c.renzokuEnzansihaError(in); err != nil {
290287 return BytecodeSF(), err
291288 }
292289 }
@@ -300,31 +297,27 @@ func (c *Compiler) expPow(out *BytecodeExp, in *string) (BytecodeValue,
300297 return BytecodeSF(), err
301298 }
302299 for {
303- op, err := c.operator(in)
304- if err != nil {
300+ if err := c.operator(in); err != nil {
305301 return BytecodeSF(), err
306302 }
307- if op == "**" {
303+ if c.token == "**" {
308304 var be BytecodeExp
309305 bv2, err := c.expPostNot(&be, in)
310306 if err != nil {
311307 return BytecodeSF(), err
312308 }
313- if !bv.IsSF() && !bv.IsSF() {
314- out.pow(&bv, bv, c.playerno)
309+ if !bv.IsSF() && !bv2.IsSF() {
310+ out.pow(&bv, bv2, c.playerNo)
315311 } else {
316- if !bv.IsSF() {
317- out.appendValue(bv)
318- }
312+ out.appendValue(bv)
319313 out.append(be...)
320- if !bv.IsSF() {
321- out.appendValue(bv2)
322- }
314+ out.appendValue(bv2)
323315 out.append(OC_pow)
324316 bv = BytecodeSF()
325317 }
318+ } else {
319+ break
326320 }
327- unimplemented()
328321 }
329322 return bv, nil
330323 }
@@ -334,8 +327,44 @@ func (c *Compiler) expMldv(out *BytecodeExp, in *string) (BytecodeValue,
334327 if err != nil {
335328 return BytecodeSF(), err
336329 }
337- unimplemented()
338- return bv, nil
330+ for {
331+ if err := c.operator(in); err != nil {
332+ return BytecodeSF(), err
333+ }
334+ switch c.token {
335+ case "*", "/", "%":
336+ default:
337+ return bv, nil
338+ }
339+ var be BytecodeExp
340+ bv2, err := c.expPow(&be, in)
341+ if err != nil {
342+ return BytecodeSF(), err
343+ }
344+ if !bv.IsSF() && !bv2.IsSF() {
345+ switch c.token {
346+ case "*":
347+ out.mul(&bv, bv2)
348+ case "/":
349+ out.div(&bv, bv2)
350+ case "%":
351+ out.mod(&bv, bv2)
352+ }
353+ } else {
354+ out.appendValue(bv)
355+ out.append(be...)
356+ out.appendValue(bv2)
357+ switch c.token {
358+ case "*":
359+ out.append(OC_mul)
360+ case "/":
361+ out.append(OC_div)
362+ case "%":
363+ out.append(OC_mod)
364+ }
365+ bv = BytecodeSF()
366+ }
367+ }
339368 }
340369 func (c *Compiler) expAdsb(out *BytecodeExp, in *string) (BytecodeValue,
341370 error) {
@@ -410,9 +439,7 @@ func (c *Compiler) expBoolXor(out *BytecodeExp, in *string) (BytecodeValue,
410439 }
411440 func (c *Compiler) expBoolOr(out *BytecodeExp, in *string) (BytecodeValue,
412441 error) {
413- defer func(ovc int, omp string) {
414- c.valCnt, c.maeOp = ovc, omp
415- }(c.valCnt, c.maeOp)
442+ defer func(omp string) { c.maeOp = omp }(c.maeOp)
416443 bv, err := c.expBoolXor(out, in)
417444 if err != nil {
418445 return BytecodeSF(), err
@@ -430,11 +457,7 @@ func (c *Compiler) typedExp(ef ExpFunc, in *string,
430457 }
431458 if !bv.IsSF() {
432459 if vt == VT_Bool {
433- if bv.v != 0 {
434- bv.v = 1
435- } else {
436- bv.v = 0
437- }
460+ bv.SetB(bv.ToB())
438461 }
439462 return nil, bv, nil
440463 }
@@ -569,9 +592,11 @@ func (c *Compiler) scAdd(sc *StateControllerBase, id byte,
569592 }
570593 }
571594 cns := true
572- for _, v := range vs {
595+ for i, v := range vs {
573596 if v.IsSF() {
574597 cns = false
598+ } else {
599+ bes[i].appendValue(v)
575600 }
576601 }
577602 if cns {
@@ -595,7 +620,7 @@ func (c *Compiler) scAdd(sc *StateControllerBase, id byte,
595620 }
596621 func (c *Compiler) stateDef(is IniSection, sbc *StateBytecode) error {
597622 return c.stateSec(is, func() error {
598- var sc StateControllerBase
623+ sc := newStateControllerBase(c.playerNo)
599624 if err := c.stateParam(is, "type", func(data string) error {
600625 if len(data) == 0 {
601626 return Error("値が指定されていません")
@@ -669,7 +694,7 @@ func (c *Compiler) stateDef(is IniSection, sbc *StateBytecode) error {
669694 }
670695 if v.IsSF() {
671696 sc.add(stateDef_hitcountpersist, sc.beToExp(be))
672- } else if v.v == 0 { // falseのときだけクリアする
697+ } else if !v.ToB() { // falseのときだけクリアする
673698 sc.add(stateDef_hitcountpersist_c, nil)
674699 }
675700 return nil
@@ -688,7 +713,7 @@ func (c *Compiler) stateDef(is IniSection, sbc *StateBytecode) error {
688713 }
689714 if v.IsSF() {
690715 sc.add(stateDef_movehitpersist, sc.beToExp(be))
691- } else if v.v == 0 { // falseのときだけクリアする
716+ } else if !v.ToB() { // falseのときだけクリアする
692717 sc.add(stateDef_movehitpersist_c, nil)
693718 }
694719 return nil
@@ -707,7 +732,7 @@ func (c *Compiler) stateDef(is IniSection, sbc *StateBytecode) error {
707732 }
708733 if v.IsSF() {
709734 sc.add(stateDef_hitdefpersist, sc.beToExp(be))
710- } else if v.v == 0 { // falseのときだけクリアする
735+ } else if !v.ToB() { // falseのときだけクリアする
711736 sc.add(stateDef_hitdefpersist_c, nil)
712737 }
713738 return nil
@@ -718,7 +743,7 @@ func (c *Compiler) stateDef(is IniSection, sbc *StateBytecode) error {
718743 sc.add(stateDef_hitdefpersist_c, nil)
719744 }
720745 if err := c.stateParam(is, "sprpriority", func(data string) error {
721- return c.scAdd(&sc, stateDef_sprpriority, data, VT_Int, 1)
746+ return c.scAdd(sc, stateDef_sprpriority, data, VT_Int, 1)
722747 }); err != nil {
723748 return err
724749 }
@@ -729,7 +754,7 @@ func (c *Compiler) stateDef(is IniSection, sbc *StateBytecode) error {
729754 }
730755 if v.IsSF() {
731756 sc.add(stateDef_facep2, sc.beToExp(be))
732- } else if v.v != 0 {
757+ } else if v.ToB() {
733758 sc.add(stateDef_facep2_c, nil)
734759 }
735760 return nil
@@ -739,7 +764,7 @@ func (c *Compiler) stateDef(is IniSection, sbc *StateBytecode) error {
739764 b = false
740765 if err := c.stateParam(is, "juggle", func(data string) error {
741766 b = true
742- return c.scAdd(&sc, stateDef_juggle, data, VT_Int, 1)
767+ return c.scAdd(sc, stateDef_juggle, data, VT_Int, 1)
743768 }); err != nil {
744769 return err
745770 }
@@ -747,26 +772,26 @@ func (c *Compiler) stateDef(is IniSection, sbc *StateBytecode) error {
747772 sc.add(stateDef_juggle_c, sc.iToExp(0))
748773 }
749774 if err := c.stateParam(is, "velset", func(data string) error {
750- return c.scAdd(&sc, stateDef_velset, data, VT_Float, 3)
775+ return c.scAdd(sc, stateDef_velset, data, VT_Float, 3)
751776 }); err != nil {
752777 return err
753778 }
754779 if err := c.stateParam(is, "anim", func(data string) error {
755- return c.scAdd(&sc, stateDef_anim, data, VT_Int, 1)
780+ return c.scAdd(sc, stateDef_anim, data, VT_Int, 1)
756781 }); err != nil {
757782 return err
758783 }
759784 if err := c.stateParam(is, "ctrl", func(data string) error {
760- return c.scAdd(&sc, stateDef_ctrl, data, VT_Bool, 1)
785+ return c.scAdd(sc, stateDef_ctrl, data, VT_Bool, 1)
761786 }); err != nil {
762787 return err
763788 }
764789 if err := c.stateParam(is, "poweradd", func(data string) error {
765- return c.scAdd(&sc, stateDef_poweradd, data, VT_Int, 1)
790+ return c.scAdd(sc, stateDef_poweradd, data, VT_Int, 1)
766791 }); err != nil {
767792 return err
768793 }
769- sbc.stateDef = stateDef(sc)
794+ sbc.stateDef = stateDef(*sc)
770795 return nil
771796 })
772797 }
@@ -813,7 +838,7 @@ func (c *Compiler) stateCompile(bc *Bytecode, filename, def string) error {
813838 return nil
814839 }
815840 func (c *Compiler) Compile(n int, def string) (*Bytecode, error) {
816- c.playerno = n
841+ c.playerNo = n
817842 bc := newBytecode()
818843 str, err := LoadText(def)
819844 if err != nil {
--- a/src/system.go
+++ b/src/system.go
@@ -437,7 +437,7 @@ func (l *Loader) loadChar(pn int) int {
437437 sys.cgi[pn].palno = pal
438438 }
439439 if sys.cgi[pn].sff == nil {
440- if l.code[pn], l.err = newCompiler().Compile(p.playerno, cdef); l.err != nil {
440+ if l.code[pn], l.err = newCompiler().Compile(p.playerNo, cdef); l.err != nil {
441441 sys.chars[pn] = nil
442442 return -1
443443 }