Go で書き直した Ikemen
修订版 | 9144d50cc5991de50c5fa680345d5ae5a1a98834 (tree) |
---|---|
时间 | 2016-12-19 00:56:20 |
作者 | SUEHIRO <supersuehiro@user...> |
Commiter | SUEHIRO |
ステートコントローラーのところを書いていく
@@ -66,6 +66,7 @@ const ( | ||
66 | 66 | OC_pop |
67 | 67 | OC_dup |
68 | 68 | OC_swap |
69 | + OC_run | |
69 | 70 | OC_jmp8 |
70 | 71 | OC_jz8 |
71 | 72 | OC_jnz8 |
@@ -177,7 +178,6 @@ const ( | ||
177 | 178 | OC_numpartner |
178 | 179 | OC_ailevel |
179 | 180 | OC_palno |
180 | - OC_matchover | |
181 | 181 | OC_hitcount |
182 | 182 | OC_uniqhitcount |
183 | 183 | OC_hitpausetime |
@@ -359,6 +359,7 @@ const ( | ||
359 | 359 | OC_ex_loseko |
360 | 360 | OC_ex_losetime |
361 | 361 | OC_ex_drawgame |
362 | + OC_ex_matchover | |
362 | 363 | OC_ex_matchno |
363 | 364 | OC_ex_tickspersecond |
364 | 365 | ) |
@@ -626,6 +627,7 @@ func (_ BytecodeExp) blor(v1 *BytecodeValue, v2 BytecodeValue) { | ||
626 | 627 | } |
627 | 628 | func (be BytecodeExp) run(c *Char, scpn int) BytecodeValue { |
628 | 629 | sys.bcStack.Clear() |
630 | + orgc := c | |
629 | 631 | for i := 1; i <= len(be); i++ { |
630 | 632 | switch be[i-1] { |
631 | 633 | case OC_jz8, OC_jnz8: |
@@ -649,15 +651,13 @@ func (be BytecodeExp) run(c *Char, scpn int) BytecodeValue { | ||
649 | 651 | case OC_jmp: |
650 | 652 | i += int(*(*int32)(unsafe.Pointer(&be[i]))) + 4 |
651 | 653 | case OC_int8: |
652 | - sys.bcStack.Push(BytecodeValue{VT_Int, float64(int8(be[i]))}) | |
654 | + sys.bcStack.Push(BytecodeInt(int32(int8(be[i])))) | |
653 | 655 | i++ |
654 | 656 | case OC_int: |
655 | - sys.bcStack.Push(BytecodeValue{VT_Int, | |
656 | - float64(*(*int32)(unsafe.Pointer(&be[i])))}) | |
657 | + sys.bcStack.Push(BytecodeInt(*(*int32)(unsafe.Pointer(&be[i])))) | |
657 | 658 | i += 4 |
658 | 659 | case OC_float: |
659 | - sys.bcStack.Push(BytecodeValue{VT_Float, | |
660 | - float64(*(*float32)(unsafe.Pointer(&be[i])))}) | |
660 | + sys.bcStack.Push(BytecodeFloat(*(*float32)(unsafe.Pointer(&be[i])))) | |
661 | 661 | i += 4 |
662 | 662 | case OC_blnot: |
663 | 663 | be.blnot(sys.bcStack.Top()) |
@@ -715,17 +715,34 @@ func (be BytecodeExp) run(c *Char, scpn int) BytecodeValue { | ||
715 | 715 | case OC_blor: |
716 | 716 | v2 := sys.bcStack.Pop() |
717 | 717 | be.blor(sys.bcStack.Top(), v2) |
718 | + case OC_ifelse: | |
719 | + v3 := sys.bcStack.Pop() | |
720 | + v2 := sys.bcStack.Pop() | |
721 | + if sys.bcStack.Top().ToB() { | |
722 | + *sys.bcStack.Top() = v2 | |
723 | + } else { | |
724 | + *sys.bcStack.Top() = v3 | |
725 | + } | |
718 | 726 | case OC_pop: |
719 | 727 | sys.bcStack.Pop() |
720 | 728 | case OC_dup: |
721 | 729 | sys.bcStack.Dup() |
722 | 730 | case OC_swap: |
723 | 731 | sys.bcStack.Swap() |
732 | + case OC_run: | |
733 | + l := int(*(*int32)(unsafe.Pointer(&be[i]))) | |
734 | + sys.bcStack.Push(be[i+4:i+4+l].run(c, scpn)) | |
735 | + i += 4 + l | |
724 | 736 | case OC_time: |
725 | 737 | sys.bcStack.Push(BytecodeInt(c.time())) |
738 | + case OC_alive: | |
739 | + sys.bcStack.Push(BytecodeBool(c.alive())) | |
740 | + case OC_random: | |
741 | + sys.bcStack.Push(BytecodeInt(Rand(0, 999))) | |
726 | 742 | default: |
727 | 743 | unimplemented() |
728 | 744 | } |
745 | + c = orgc | |
729 | 746 | } |
730 | 747 | return sys.bcStack.Pop() |
731 | 748 | } |
@@ -783,7 +800,7 @@ func (scb *StateControllerBase) add(id byte, exp []BytecodeExp) { | ||
783 | 800 | } |
784 | 801 | } |
785 | 802 | func (scb StateControllerBase) run(c *Char, ps *int32, |
786 | - f func(byte, []BytecodeExp)) bool { | |
803 | + f func(byte, []BytecodeExp) bool) bool { | |
787 | 804 | (*ps)-- |
788 | 805 | if *ps > 0 { |
789 | 806 | return false |
@@ -804,8 +821,8 @@ func (scb StateControllerBase) run(c *Char, ps *int32, | ||
804 | 821 | if !exp[0].evalB(c, scb.playerNo) { |
805 | 822 | return false |
806 | 823 | } |
807 | - } else { | |
808 | - f(id, exp) | |
824 | + } else if !f(id, exp) { | |
825 | + break | |
809 | 826 | } |
810 | 827 | } |
811 | 828 | *ps = scb.persistent |
@@ -828,7 +845,7 @@ const ( | ||
828 | 845 | ) |
829 | 846 | |
830 | 847 | func (sc stateDef) Run(c *Char, ps *int32) bool { |
831 | - StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) { | |
848 | + StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) bool { | |
832 | 849 | switch id { |
833 | 850 | case stateDef_hitcountpersist: |
834 | 851 | if !exp[0].evalB(c, sc.playerNo) { |
@@ -865,6 +882,7 @@ func (sc stateDef) Run(c *Char, ps *int32) bool { | ||
865 | 882 | case stateDef_poweradd: |
866 | 883 | c.addPower(exp[0].evalI(c, sc.playerNo)) |
867 | 884 | } |
885 | + return true | |
868 | 886 | }) |
869 | 887 | return false |
870 | 888 | } |
@@ -879,7 +897,7 @@ const ( | ||
879 | 897 | |
880 | 898 | func (sc hitBy) Run(c *Char, ps *int32) bool { |
881 | 899 | time := int32(1) |
882 | - StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) { | |
900 | + StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) bool { | |
883 | 901 | switch id { |
884 | 902 | case hitBy_time: |
885 | 903 | time = exp[0].evalI(c, sc.playerNo) |
@@ -888,6 +906,7 @@ func (sc hitBy) Run(c *Char, ps *int32) bool { | ||
888 | 906 | case hitBy_value2: |
889 | 907 | unimplemented() |
890 | 908 | } |
909 | + return true | |
891 | 910 | }) |
892 | 911 | return false |
893 | 912 | } |
@@ -896,7 +915,7 @@ type notHitBy hitBy | ||
896 | 915 | |
897 | 916 | func (sc notHitBy) Run(c *Char, ps *int32) bool { |
898 | 917 | time := int32(1) |
899 | - StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) { | |
918 | + StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) bool { | |
900 | 919 | switch id { |
901 | 920 | case hitBy_time: |
902 | 921 | time = exp[0].evalI(c, sc.playerNo) |
@@ -905,15 +924,273 @@ func (sc notHitBy) Run(c *Char, ps *int32) bool { | ||
905 | 924 | case hitBy_value2: |
906 | 925 | unimplemented() |
907 | 926 | } |
927 | + return true | |
908 | 928 | }) |
909 | 929 | return false |
910 | 930 | } |
911 | 931 | |
912 | 932 | type assertSpecial StateControllerBase |
913 | 933 | |
934 | +const ( | |
935 | + assertSpecial_flag byte = iota | |
936 | + assertSpecial_flag_g | |
937 | +) | |
938 | + | |
914 | 939 | func (sc assertSpecial) Run(c *Char, ps *int32) bool { |
915 | - StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) { | |
940 | + StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) bool { | |
941 | + switch id { | |
942 | + case assertSpecial_flag: | |
943 | + unimplemented() | |
944 | + case assertSpecial_flag_g: | |
945 | + sys.specialFlag |= GlobalSpecialFlag(exp[0].evalI(c, sc.playerNo)) | |
946 | + } | |
947 | + return true | |
948 | + }) | |
949 | + return false | |
950 | +} | |
951 | + | |
952 | +type playSnd StateControllerBase | |
953 | + | |
954 | +const ( | |
955 | + playSnd_value = iota | |
956 | + playSnd_channel | |
957 | + playSnd_lowpriority | |
958 | + playSnd_pan | |
959 | + playSnd_abspan | |
960 | + playSnd_volume | |
961 | + playSnd_freqmul | |
962 | + playSnd_loop | |
963 | +) | |
964 | + | |
965 | +func (sc playSnd) Run(c *Char, ps *int32) bool { | |
966 | + f, lw, lp := false, false, false | |
967 | + var g, n, ch, vo int32 = -1, 0, -1, 0 | |
968 | + if sys.cgi[sc.playerNo].ver[0] == 1 { | |
969 | + vo = 100 | |
970 | + } | |
971 | + var p, fr float32 = 0, 1 | |
972 | + x := &c.pos[0] | |
973 | + StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) bool { | |
974 | + switch id { | |
975 | + case playSnd_value: | |
976 | + f = exp[0].evalB(c, sc.playerNo) | |
977 | + g = exp[1].evalI(c, sc.playerNo) | |
978 | + if len(exp) > 2 { | |
979 | + n = exp[2].evalI(c, sc.playerNo) | |
980 | + } | |
981 | + case playSnd_channel: | |
982 | + ch = exp[0].evalI(c, sc.playerNo) | |
983 | + case playSnd_lowpriority: | |
984 | + lw = exp[0].evalB(c, sc.playerNo) | |
985 | + case playSnd_pan: | |
986 | + p = exp[0].evalF(c, sc.playerNo) | |
987 | + case playSnd_abspan: | |
988 | + x = nil | |
989 | + p = exp[0].evalF(c, sc.playerNo) | |
990 | + case playSnd_volume: | |
991 | + vo = exp[0].evalI(c, sc.playerNo) | |
992 | + case playSnd_freqmul: | |
993 | + fr = exp[0].evalF(c, sc.playerNo) | |
994 | + case playSnd_loop: | |
995 | + lp = exp[0].evalB(c, sc.playerNo) | |
996 | + } | |
997 | + return true | |
998 | + }) | |
999 | + c.playSound(f, lw, lp, g, n, ch, vo, p, fr, x) | |
1000 | + return false | |
1001 | +} | |
1002 | + | |
1003 | +type changeState StateControllerBase | |
1004 | + | |
1005 | +const ( | |
1006 | + changeState_value byte = iota | |
1007 | + changeState_ctrl | |
1008 | + changeState_anim | |
1009 | +) | |
1010 | + | |
1011 | +func (sc changeState) Run(c *Char, ps *int32) bool { | |
1012 | + var v, a, ctrl int32 = -1, -1, -1 | |
1013 | + StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) bool { | |
1014 | + switch id { | |
1015 | + case changeState_value: | |
1016 | + v = exp[0].evalI(c, sc.playerNo) | |
1017 | + case changeState_ctrl: | |
1018 | + ctrl = exp[0].evalI(c, sc.playerNo) | |
1019 | + case changeState_anim: | |
1020 | + a = exp[0].evalI(c, sc.playerNo) | |
1021 | + } | |
1022 | + return true | |
1023 | + }) | |
1024 | + c.changeState(v, a, ctrl) | |
1025 | + return true | |
1026 | +} | |
1027 | + | |
1028 | +type selfState changeState | |
1029 | + | |
1030 | +func (sc selfState) Run(c *Char, ps *int32) bool { | |
1031 | + var v, a, ctrl int32 = -1, -1, -1 | |
1032 | + StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) bool { | |
1033 | + switch id { | |
1034 | + case changeState_value: | |
1035 | + v = exp[0].evalI(c, sc.playerNo) | |
1036 | + case changeState_ctrl: | |
1037 | + ctrl = exp[0].evalI(c, sc.playerNo) | |
1038 | + case changeState_anim: | |
1039 | + a = exp[0].evalI(c, sc.playerNo) | |
1040 | + } | |
1041 | + return true | |
1042 | + }) | |
1043 | + c.selfState(v, a, ctrl) | |
1044 | + return true | |
1045 | +} | |
1046 | + | |
1047 | +type tagIn StateControllerBase | |
1048 | + | |
1049 | +const ( | |
1050 | + tagIn_stateno = iota | |
1051 | + tagIn_partnerstateno | |
1052 | +) | |
1053 | + | |
1054 | +func (sc tagIn) Run(c *Char, ps *int32) bool { | |
1055 | + var p *Char | |
1056 | + sn := int32(-1) | |
1057 | + ret := false | |
1058 | + StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) bool { | |
1059 | + if p == nil { | |
1060 | + p = c.partner(0) | |
1061 | + if p == nil { | |
1062 | + return false | |
1063 | + } | |
1064 | + } | |
1065 | + switch id { | |
1066 | + case tagIn_stateno: | |
1067 | + sn = exp[0].evalI(c, sc.playerNo) | |
1068 | + case tagIn_partnerstateno: | |
1069 | + if psn := exp[0].evalI(c, sc.playerNo); psn >= 0 { | |
1070 | + if sn >= 0 { | |
1071 | + c.changeState(sn, -1, -1) | |
1072 | + } | |
1073 | + p.standby = false | |
1074 | + p.changeState(psn, -1, -1) | |
1075 | + ret = true | |
1076 | + } else { | |
1077 | + return false | |
1078 | + } | |
1079 | + } | |
1080 | + return true | |
1081 | + }) | |
1082 | + return ret | |
1083 | +} | |
1084 | + | |
1085 | +type tagOut StateControllerBase | |
1086 | + | |
1087 | +const ( | |
1088 | + tagOut_ = iota | |
1089 | +) | |
1090 | + | |
1091 | +func (sc tagOut) Run(c *Char, ps *int32) bool { | |
1092 | + StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) bool { | |
1093 | + switch id { | |
1094 | + case tagOut_: | |
1095 | + c.standby = true | |
1096 | + } | |
1097 | + return true | |
1098 | + }) | |
1099 | + return true | |
1100 | +} | |
1101 | + | |
1102 | +type destroySelf StateControllerBase | |
1103 | + | |
1104 | +const ( | |
1105 | + destroySelf_recursive = iota | |
1106 | + destroySelf_removeexplods | |
1107 | +) | |
1108 | + | |
1109 | +func (sc destroySelf) Run(c *Char, ps *int32) bool { | |
1110 | + rec, rem := false, false | |
1111 | + StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) bool { | |
1112 | + switch id { | |
1113 | + case destroySelf_recursive: | |
1114 | + rec = exp[0].evalB(c, sc.playerNo) | |
1115 | + case destroySelf_removeexplods: | |
1116 | + rem = exp[0].evalB(c, sc.playerNo) | |
1117 | + } | |
1118 | + return true | |
1119 | + }) | |
1120 | + return c.destroySelf(rec, rem) | |
1121 | +} | |
1122 | + | |
1123 | +type changeAnim StateControllerBase | |
1124 | + | |
1125 | +const ( | |
1126 | + changeAnim_elem byte = iota | |
1127 | + changeAnim_value | |
1128 | +) | |
1129 | + | |
1130 | +func (sc changeAnim) Run(c *Char, ps *int32) bool { | |
1131 | + var elem int32 | |
1132 | + setelem := false | |
1133 | + StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) bool { | |
1134 | + switch id { | |
1135 | + case changeAnim_elem: | |
1136 | + elem = exp[0].evalI(c, sc.playerNo) | |
1137 | + setelem = true | |
1138 | + case changeAnim_value: | |
1139 | + c.changeAnim(exp[0].evalI(c, sc.playerNo)) | |
1140 | + if setelem { | |
1141 | + c.setAnimElem(elem) | |
1142 | + } | |
1143 | + } | |
1144 | + return true | |
1145 | + }) | |
1146 | + return false | |
1147 | +} | |
1148 | + | |
1149 | +type changeAnim2 changeAnim | |
1150 | + | |
1151 | +func (sc changeAnim2) Run(c *Char, ps *int32) bool { | |
1152 | + var elem int32 | |
1153 | + setelem := false | |
1154 | + StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) bool { | |
1155 | + switch id { | |
1156 | + case changeAnim_elem: | |
1157 | + elem = exp[0].evalI(c, sc.playerNo) | |
1158 | + setelem = true | |
1159 | + case changeAnim_value: | |
1160 | + c.changeAnim2(exp[0].evalI(c, sc.playerNo)) | |
1161 | + if setelem { | |
1162 | + c.setAnimElem(elem) | |
1163 | + } | |
1164 | + } | |
1165 | + return true | |
1166 | + }) | |
1167 | + return false | |
1168 | +} | |
1169 | + | |
1170 | +type helper StateControllerBase | |
1171 | + | |
1172 | +const ( | |
1173 | + helper_helpertype byte = iota | |
1174 | + helper_name | |
1175 | +) | |
1176 | + | |
1177 | +func (sc helper) Run(c *Char, ps *int32) bool { | |
1178 | + var h *Char | |
1179 | + StateControllerBase(sc).run(c, ps, func(id byte, exp []BytecodeExp) bool { | |
1180 | + if h == nil { | |
1181 | + h = c.newHelper() | |
1182 | + if h == nil { | |
1183 | + return false | |
1184 | + } | |
1185 | + } | |
1186 | + switch id { | |
1187 | + case helper_helpertype: | |
1188 | + h.player = exp[0].evalB(c, sc.playerNo) | |
1189 | + case helper_name: | |
1190 | + h.name = string(*(*[]byte)(unsafe.Pointer(&exp[0]))) | |
1191 | + } | |
916 | 1192 | unimplemented() |
1193 | + return true | |
917 | 1194 | }) |
918 | 1195 | return false |
919 | 1196 | } |
@@ -5,6 +5,36 @@ import ( | ||
5 | 5 | "strings" |
6 | 6 | ) |
7 | 7 | |
8 | +type CharSpecialFlag uint32 | |
9 | + | |
10 | +const ( | |
11 | + CSF_nostandguard CharSpecialFlag = 1 << iota | |
12 | + CSF_nocrouchguard | |
13 | + CSF_noairguard | |
14 | + CSF_noshadow | |
15 | + CSF_invisible | |
16 | + CSF_unguardable | |
17 | + CSF_nojugglecheck | |
18 | + CSF_noautoturn | |
19 | + CSF_nowalk | |
20 | +) | |
21 | + | |
22 | +type GlobalSpecialFlag uint32 | |
23 | + | |
24 | +const ( | |
25 | + GSF_intro GlobalSpecialFlag = 1 << iota | |
26 | + GSF_roundnotover | |
27 | + GSF_nomusic | |
28 | + GSF_nobardisplay | |
29 | + GSF_nobg | |
30 | + GSF_nofg | |
31 | + GSF_globalnoshadow | |
32 | + GSF_timerfreeze | |
33 | + GSF_nokosnd | |
34 | + GSF_nokoslow | |
35 | + GSF_noko | |
36 | +) | |
37 | + | |
8 | 38 | type CharData struct { |
9 | 39 | life int32 |
10 | 40 | power int32 |
@@ -279,6 +309,9 @@ type Char struct { | ||
279 | 309 | sprpriority int32 |
280 | 310 | juggle int32 |
281 | 311 | size CharSize |
312 | + pos [2]float32 | |
313 | + vel [2]float32 | |
314 | + standby bool | |
282 | 315 | } |
283 | 316 | |
284 | 317 | func newChar(n, idx int) (c *Char) { |
@@ -554,14 +587,20 @@ func (c *Char) setJuggle(juggle int32) { | ||
554 | 587 | c.juggle = juggle |
555 | 588 | } |
556 | 589 | func (c *Char) setXV(xv float32) { |
557 | - unimplemented() | |
590 | + c.vel[0] = xv | |
558 | 591 | } |
559 | 592 | func (c *Char) setYV(yv float32) { |
560 | - unimplemented() | |
593 | + c.vel[1] = yv | |
561 | 594 | } |
562 | 595 | func (c *Char) changeAnim(animNo int32) { |
563 | 596 | unimplemented() |
564 | 597 | } |
598 | +func (c *Char) changeAnim2(animNo int32) { | |
599 | + unimplemented() | |
600 | +} | |
601 | +func (c *Char) setAnimElem(e int32) { | |
602 | + unimplemented() | |
603 | +} | |
565 | 604 | func (c *Char) setCtrl(ctrl bool) { |
566 | 605 | unimplemented() |
567 | 606 | } |
@@ -572,3 +611,47 @@ func (c *Char) time() int32 { | ||
572 | 611 | unimplemented() |
573 | 612 | return 0 |
574 | 613 | } |
614 | +func (c *Char) alive() bool { | |
615 | + unimplemented() | |
616 | + return false | |
617 | +} | |
618 | +func (c *Char) playSound(f, lw, lp bool, g, n, ch, vo int32, | |
619 | + p, fr float32, x *float32) { | |
620 | + unimplemented() | |
621 | +} | |
622 | +func (c *Char) changeState(no, anim, ctrl int32) { | |
623 | + unimplemented() | |
624 | +} | |
625 | +func (c *Char) selfState(no, anim, ctrl int32) { | |
626 | + unimplemented() | |
627 | +} | |
628 | +func (c *Char) partner(n int32) *Char { | |
629 | + n = Max(0, n) | |
630 | + if int(n) > len(sys.chars)/2-2 { | |
631 | + return nil | |
632 | + } | |
633 | + var p int | |
634 | + if int(n) == c.playerNo>>1 { | |
635 | + p = c.playerNo + 2 | |
636 | + } else { | |
637 | + p = c.playerNo&1 + int(n)<<1 | |
638 | + if int(n) > c.playerNo>>1 { | |
639 | + p += 2 | |
640 | + } | |
641 | + } | |
642 | + if len(sys.chars[p]) > 0 { | |
643 | + return sys.chars[p][0] | |
644 | + } | |
645 | + return nil | |
646 | +} | |
647 | +func (c *Char) destroySelf(recursive, removeexplods bool) bool { | |
648 | + if c.helperIndex <= 0 { | |
649 | + return false | |
650 | + } | |
651 | + unimplemented() | |
652 | + return true | |
653 | +} | |
654 | +func (c *Char) newHelper() *Char { | |
655 | + unimplemented() | |
656 | + return nil | |
657 | +} |
@@ -150,6 +150,9 @@ func Atof(str string) float64 { | ||
150 | 150 | return f |
151 | 151 | } |
152 | 152 | func readDigit(d string) (int32, bool) { |
153 | + if len(d) == 0 || (len(d) >= 2 && d[0] == '0') { | |
154 | + return 0, false | |
155 | + } | |
153 | 156 | for _, c := range d { |
154 | 157 | if c < '0' || c > '9' { |
155 | 158 | return 0, false |
@@ -310,7 +310,6 @@ func (c *Compiler) kakkotojiru(in *string) error { | ||
310 | 310 | if c.token != ")" { |
311 | 311 | return Error(c.token + "の前に')'がありません") |
312 | 312 | } |
313 | - c.token = c.tokenizer(in) | |
314 | 313 | return nil |
315 | 314 | } |
316 | 315 | func (c *Compiler) expValue(out *BytecodeExp, in *string) (BytecodeValue, |
@@ -324,9 +323,56 @@ func (c *Compiler) expValue(out *BytecodeExp, in *string) (BytecodeValue, | ||
324 | 323 | if !sys.ignoreMostErrors { |
325 | 324 | defer func() { c.usiroOp = false }() |
326 | 325 | } |
326 | + var be1, be2, be3 BytecodeExp | |
327 | + var bv1, bv2, bv3 BytecodeValue | |
328 | + var err error | |
327 | 329 | switch c.token { |
328 | 330 | case "time": |
329 | 331 | out.append(OC_time) |
332 | + case "alive": | |
333 | + out.append(OC_alive) | |
334 | + case "ifelse": | |
335 | + if c.tokenizer(in) != "(" { | |
336 | + return BytecodeSF(), Error(c.token + "の次に'('がありません") | |
337 | + } | |
338 | + c.token = c.tokenizer(in) | |
339 | + if bv1, err = c.expBoolOr(&be1, in); err != nil { | |
340 | + return BytecodeSF(), err | |
341 | + } | |
342 | + if c.token != "," { | |
343 | + return BytecodeSF(), Error("','がありません") | |
344 | + } | |
345 | + c.token = c.tokenizer(in) | |
346 | + if bv2, err = c.expBoolOr(&be2, in); err != nil { | |
347 | + return BytecodeSF(), err | |
348 | + } | |
349 | + if c.token != "," { | |
350 | + return BytecodeSF(), Error("','がありません") | |
351 | + } | |
352 | + c.token = c.tokenizer(in) | |
353 | + if bv3, err = c.expBoolOr(&be3, in); err != nil { | |
354 | + return BytecodeSF(), err | |
355 | + } | |
356 | + if err := c.kakkotojiru(in); err != nil { | |
357 | + return BytecodeSF(), err | |
358 | + } | |
359 | + if bv1.IsSF() || bv2.IsSF() || bv3.IsSF() { | |
360 | + out.append(be1...) | |
361 | + out.appendValue(bv1) | |
362 | + out.append(be2...) | |
363 | + out.appendValue(bv2) | |
364 | + out.append(be3...) | |
365 | + out.appendValue(bv3) | |
366 | + out.append(OC_ifelse) | |
367 | + } else { | |
368 | + if bv1.ToB() { | |
369 | + bv = bv2 | |
370 | + } else { | |
371 | + bv = bv3 | |
372 | + } | |
373 | + } | |
374 | + case "random": | |
375 | + out.append(OC_random) | |
330 | 376 | default: |
331 | 377 | println(c.token) |
332 | 378 | unimplemented() |
@@ -409,14 +455,14 @@ func (c *Compiler) expPow(out *BytecodeExp, in *string) (BytecodeValue, | ||
409 | 455 | if err != nil { |
410 | 456 | return BytecodeSF(), err |
411 | 457 | } |
412 | - if !bv.IsSF() && !bv2.IsSF() { | |
413 | - out.pow(&bv, bv2, c.playerNo) | |
414 | - } else { | |
458 | + if bv.IsSF() || bv2.IsSF() { | |
415 | 459 | out.appendValue(bv) |
416 | 460 | out.append(be...) |
417 | 461 | out.appendValue(bv2) |
418 | 462 | out.append(OC_pow) |
419 | 463 | bv = BytecodeSF() |
464 | + } else { | |
465 | + out.pow(&bv, bv2, c.playerNo) | |
420 | 466 | } |
421 | 467 | } else { |
422 | 468 | break |
@@ -523,19 +569,20 @@ func (c *Compiler) expRange(out *BytecodeExp, in *string, | ||
523 | 569 | if err := c.kakkotojiru(in); err != nil { |
524 | 570 | return err |
525 | 571 | } |
526 | - if !bv.IsSF() && !bv2.IsSF() { | |
572 | + c.token = c.tokenizer(in) | |
573 | + if bv.IsSF() || bv2.IsSF() { | |
574 | + out.appendValue(*bv) | |
575 | + out.append(be2...) | |
576 | + out.appendValue(bv2) | |
577 | + out.append(opc) | |
578 | + *bv = BytecodeSF() | |
579 | + } else { | |
527 | 580 | switch opc { |
528 | 581 | case OC_eq: |
529 | 582 | out.eq(bv, bv2) |
530 | 583 | case OC_ne: |
531 | 584 | out.ne(bv, bv2) |
532 | 585 | } |
533 | - } else { | |
534 | - out.appendValue(*bv) | |
535 | - out.append(be2...) | |
536 | - out.appendValue(bv2) | |
537 | - out.append(opc) | |
538 | - *bv = BytecodeSF() | |
539 | 586 | } |
540 | 587 | return nil |
541 | 588 | } |
@@ -546,23 +593,7 @@ func (c *Compiler) expRange(out *BytecodeExp, in *string, | ||
546 | 593 | return Error("]か)がありません") |
547 | 594 | } |
548 | 595 | c.token = c.tokenizer(in) |
549 | - if !bv.IsSF() && !bv2.IsSF() && !bv3.IsSF() { | |
550 | - tmp := *bv | |
551 | - if open == "(" { | |
552 | - out.gt(&tmp, bv2) | |
553 | - } else { | |
554 | - out.ge(&tmp, bv2) | |
555 | - } | |
556 | - if close == ")" { | |
557 | - out.lt(bv, bv3) | |
558 | - } else { | |
559 | - out.le(bv, bv3) | |
560 | - } | |
561 | - bv.SetB(tmp.ToB() && bv.ToB()) | |
562 | - if opc == OC_ne { | |
563 | - bv.SetB(!bv.ToB()) | |
564 | - } | |
565 | - } else { | |
596 | + if bv.IsSF() || bv2.IsSF() || bv3.IsSF() { | |
566 | 597 | var op1, op2, op3 OpCode |
567 | 598 | if opc == OC_ne { |
568 | 599 | if open == "(" { |
@@ -600,6 +631,22 @@ func (c *Compiler) expRange(out *BytecodeExp, in *string, | ||
600 | 631 | out.append(op2) |
601 | 632 | out.append(op3) |
602 | 633 | *bv = BytecodeSF() |
634 | + } else { | |
635 | + tmp := *bv | |
636 | + if open == "(" { | |
637 | + out.gt(&tmp, bv2) | |
638 | + } else { | |
639 | + out.ge(&tmp, bv2) | |
640 | + } | |
641 | + if close == ")" { | |
642 | + out.lt(bv, bv3) | |
643 | + } else { | |
644 | + out.le(bv, bv3) | |
645 | + } | |
646 | + bv.SetB(tmp.ToB() && bv.ToB()) | |
647 | + if opc == OC_ne { | |
648 | + bv.SetB(!bv.ToB()) | |
649 | + } | |
603 | 650 | } |
604 | 651 | return nil |
605 | 652 | } |
@@ -653,14 +700,14 @@ func (_ *Compiler) expOneOpSub(out *BytecodeExp, in *string, bv *BytecodeValue, | ||
653 | 700 | if err != nil { |
654 | 701 | return err |
655 | 702 | } |
656 | - if !bv.IsSF() && !bv2.IsSF() { | |
657 | - opf(bv, bv2) | |
658 | - } else { | |
703 | + if bv.IsSF() || bv2.IsSF() { | |
659 | 704 | out.appendValue(*bv) |
660 | 705 | out.append(be...) |
661 | 706 | out.appendValue(bv2) |
662 | 707 | out.append(opc) |
663 | 708 | *bv = BytecodeSF() |
709 | + } else { | |
710 | + opf(bv, bv2) | |
664 | 711 | } |
665 | 712 | return nil |
666 | 713 | } |
@@ -853,7 +900,7 @@ func (c *Compiler) stateParam(is IniSection, name string, | ||
853 | 900 | return nil |
854 | 901 | } |
855 | 902 | func (c *Compiler) scAdd(sc *StateControllerBase, id byte, |
856 | - data string, vt ValueType, numArg int) error { | |
903 | + data string, vt ValueType, numArg int, topbe ...BytecodeExp) error { | |
857 | 904 | bes := []BytecodeExp{} |
858 | 905 | for n := 1; n <= numArg; n++ { |
859 | 906 | var be BytecodeExp |
@@ -871,7 +918,7 @@ func (c *Compiler) scAdd(sc *StateControllerBase, id byte, | ||
871 | 918 | break |
872 | 919 | } |
873 | 920 | } |
874 | - sc.add(id, bes) | |
921 | + sc.add(id, append(topbe, bes...)) | |
875 | 922 | return nil |
876 | 923 | } |
877 | 924 | func (c *Compiler) stateDef(is IniSection, sbc *StateBytecode) error { |
@@ -1063,6 +1110,287 @@ func (c *Compiler) notHitBy(is IniSection, sbc *StateBytecode, | ||
1063 | 1110 | func (c *Compiler) assertSpecial(is IniSection, sbc *StateBytecode, |
1064 | 1111 | sc *StateControllerBase) (StateController, error) { |
1065 | 1112 | return assertSpecial(*sc), c.stateSec(is, func() error { |
1113 | + foo := func(data string) error { | |
1114 | + switch data { | |
1115 | + case "nostandguard": | |
1116 | + sc.add(assertSpecial_flag, sc.iToExp(int32(CSF_nostandguard))) | |
1117 | + case "nocrouchguard": | |
1118 | + sc.add(assertSpecial_flag, sc.iToExp(int32(CSF_nocrouchguard))) | |
1119 | + case "noairguard": | |
1120 | + sc.add(assertSpecial_flag, sc.iToExp(int32(CSF_noairguard))) | |
1121 | + case "noshadow": | |
1122 | + sc.add(assertSpecial_flag, sc.iToExp(int32(CSF_noshadow))) | |
1123 | + case "invisible": | |
1124 | + sc.add(assertSpecial_flag, sc.iToExp(int32(CSF_invisible))) | |
1125 | + case "unguardable": | |
1126 | + sc.add(assertSpecial_flag, sc.iToExp(int32(CSF_unguardable))) | |
1127 | + case "nojugglecheck": | |
1128 | + sc.add(assertSpecial_flag, sc.iToExp(int32(CSF_nojugglecheck))) | |
1129 | + case "noautoturn": | |
1130 | + sc.add(assertSpecial_flag, sc.iToExp(int32(CSF_noautoturn))) | |
1131 | + case "nowalk": | |
1132 | + sc.add(assertSpecial_flag, sc.iToExp(int32(CSF_nowalk))) | |
1133 | + case "intro": | |
1134 | + sc.add(assertSpecial_flag_g, sc.iToExp(int32(GSF_intro))) | |
1135 | + case "roundnotover": | |
1136 | + sc.add(assertSpecial_flag_g, sc.iToExp(int32(GSF_roundnotover))) | |
1137 | + case "nomusic": | |
1138 | + sc.add(assertSpecial_flag_g, sc.iToExp(int32(GSF_nomusic))) | |
1139 | + case "nobardisplay": | |
1140 | + sc.add(assertSpecial_flag_g, sc.iToExp(int32(GSF_nobardisplay))) | |
1141 | + case "nobg": | |
1142 | + sc.add(assertSpecial_flag_g, sc.iToExp(int32(GSF_nobg))) | |
1143 | + case "nofg": | |
1144 | + sc.add(assertSpecial_flag_g, sc.iToExp(int32(GSF_nofg))) | |
1145 | + case "globalnoshadow": | |
1146 | + sc.add(assertSpecial_flag_g, sc.iToExp(int32(GSF_globalnoshadow))) | |
1147 | + case "timerfreeze": | |
1148 | + sc.add(assertSpecial_flag_g, sc.iToExp(int32(GSF_timerfreeze))) | |
1149 | + case "nokosnd": | |
1150 | + sc.add(assertSpecial_flag_g, sc.iToExp(int32(GSF_nokosnd))) | |
1151 | + case "nokoslow": | |
1152 | + sc.add(assertSpecial_flag_g, sc.iToExp(int32(GSF_nokoslow))) | |
1153 | + case "noko": | |
1154 | + sc.add(assertSpecial_flag_g, sc.iToExp(int32(GSF_noko))) | |
1155 | + default: | |
1156 | + return Error(data + "が無効な値です") | |
1157 | + } | |
1158 | + return nil | |
1159 | + } | |
1160 | + f := false | |
1161 | + if err := c.stateParam(is, "flag", func(data string) error { | |
1162 | + f = true | |
1163 | + return foo(data) | |
1164 | + }); err != nil { | |
1165 | + return err | |
1166 | + } | |
1167 | + if !f { | |
1168 | + return Error("flagが指定されていません") | |
1169 | + } | |
1170 | + if err := c.stateParam(is, "flag2", func(data string) error { | |
1171 | + return foo(data) | |
1172 | + }); err != nil { | |
1173 | + return err | |
1174 | + } | |
1175 | + if err := c.stateParam(is, "flag3", func(data string) error { | |
1176 | + return foo(data) | |
1177 | + }); err != nil { | |
1178 | + return err | |
1179 | + } | |
1180 | + return nil | |
1181 | + }) | |
1182 | +} | |
1183 | +func (c *Compiler) playSnd(is IniSection, sbc *StateBytecode, | |
1184 | + sc *StateControllerBase) (StateController, error) { | |
1185 | + return playSnd(*sc), c.stateSec(is, func() error { | |
1186 | + f := false | |
1187 | + if err := c.stateParam(is, "value", func(data string) error { | |
1188 | + f = true | |
1189 | + fflg := false | |
1190 | + if len(data) > 0 { | |
1191 | + switch data[0] { | |
1192 | + case 'F', 'f': | |
1193 | + fflg = true | |
1194 | + data = data[1:] | |
1195 | + case 'S', 's': | |
1196 | + data = data[1:] | |
1197 | + } | |
1198 | + } | |
1199 | + return c.scAdd(sc, playSnd_value, data, VT_Int, 2, | |
1200 | + sc.iToExp(Btoi(fflg))...) | |
1201 | + }); err != nil { | |
1202 | + return err | |
1203 | + } | |
1204 | + if !f { | |
1205 | + return Error("valueが指定されていません") | |
1206 | + } | |
1207 | + if err := c.stateParam(is, "channel", func(data string) error { | |
1208 | + return c.scAdd(sc, playSnd_channel, data, VT_Int, 1) | |
1209 | + }); err != nil { | |
1210 | + return err | |
1211 | + } | |
1212 | + if err := c.stateParam(is, "lowpriority", func(data string) error { | |
1213 | + return c.scAdd(sc, playSnd_lowpriority, data, VT_Bool, 1) | |
1214 | + }); err != nil { | |
1215 | + return err | |
1216 | + } | |
1217 | + if err := c.stateParam(is, "pan", func(data string) error { | |
1218 | + return c.scAdd(sc, playSnd_pan, data, VT_Float, 1) | |
1219 | + }); err != nil { | |
1220 | + return err | |
1221 | + } | |
1222 | + if err := c.stateParam(is, "abspan", func(data string) error { | |
1223 | + return c.scAdd(sc, playSnd_abspan, data, VT_Float, 1) | |
1224 | + }); err != nil { | |
1225 | + return err | |
1226 | + } | |
1227 | + var volname string | |
1228 | + if sys.cgi[c.playerNo].ver[0] == 1 { | |
1229 | + volname = "volumescale" | |
1230 | + } else { | |
1231 | + volname = "volume" | |
1232 | + } | |
1233 | + if err := c.stateParam(is, volname, func(data string) error { | |
1234 | + return c.scAdd(sc, playSnd_volume, data, VT_Int, 1) | |
1235 | + }); err != nil { | |
1236 | + return err | |
1237 | + } | |
1238 | + if err := c.stateParam(is, "freqmul", func(data string) error { | |
1239 | + return c.scAdd(sc, playSnd_freqmul, data, VT_Float, 1) | |
1240 | + }); err != nil { | |
1241 | + return err | |
1242 | + } | |
1243 | + if err := c.stateParam(is, "loop", func(data string) error { | |
1244 | + return c.scAdd(sc, playSnd_loop, data, VT_Bool, 1) | |
1245 | + }); err != nil { | |
1246 | + return err | |
1247 | + } | |
1248 | + return nil | |
1249 | + }) | |
1250 | +} | |
1251 | +func (c *Compiler) changeStateSub(is IniSection, | |
1252 | + sc *StateControllerBase) error { | |
1253 | + f := false | |
1254 | + if err := c.stateParam(is, "value", func(data string) error { | |
1255 | + f = true | |
1256 | + return c.scAdd(sc, changeState_value, data, VT_Int, 1) | |
1257 | + }); err != nil { | |
1258 | + return err | |
1259 | + } | |
1260 | + if !f { | |
1261 | + return Error("valueが指定されていません") | |
1262 | + } | |
1263 | + if err := c.stateParam(is, "ctrl", func(data string) error { | |
1264 | + return c.scAdd(sc, changeState_ctrl, data, VT_Int, 1) | |
1265 | + }); err != nil { | |
1266 | + return err | |
1267 | + } | |
1268 | + if err := c.stateParam(is, "anim", func(data string) error { | |
1269 | + return c.scAdd(sc, changeState_anim, data, VT_Int, 1) | |
1270 | + }); err != nil { | |
1271 | + return err | |
1272 | + } | |
1273 | + return nil | |
1274 | +} | |
1275 | +func (c *Compiler) changeState(is IniSection, sbc *StateBytecode, | |
1276 | + sc *StateControllerBase) (StateController, error) { | |
1277 | + return changeState(*sc), c.stateSec(is, func() error { | |
1278 | + return c.changeStateSub(is, sc) | |
1279 | + }) | |
1280 | +} | |
1281 | +func (c *Compiler) selfState(is IniSection, sbc *StateBytecode, | |
1282 | + sc *StateControllerBase) (StateController, error) { | |
1283 | + return selfState(*sc), c.stateSec(is, func() error { | |
1284 | + return c.changeStateSub(is, sc) | |
1285 | + }) | |
1286 | +} | |
1287 | +func (c *Compiler) tagIn(is IniSection, sbc *StateBytecode, | |
1288 | + sc *StateControllerBase) (StateController, error) { | |
1289 | + return tagIn(*sc), c.stateSec(is, func() error { | |
1290 | + f := false | |
1291 | + if err := c.stateParam(is, "stateno", func(data string) error { | |
1292 | + f = true | |
1293 | + return c.scAdd(sc, tagIn_stateno, data, VT_Int, 1) | |
1294 | + }); err != nil { | |
1295 | + return err | |
1296 | + } | |
1297 | + if !f { | |
1298 | + return Error("statenoが指定されていません") | |
1299 | + } | |
1300 | + f = false | |
1301 | + if err := c.stateParam(is, "partnerstateno", func(data string) error { | |
1302 | + f = true | |
1303 | + return c.scAdd(sc, tagIn_partnerstateno, data, VT_Int, 1) | |
1304 | + }); err != nil { | |
1305 | + return err | |
1306 | + } | |
1307 | + if !f { | |
1308 | + sc.add(tagIn_partnerstateno, sc.iToExp(-1)) | |
1309 | + } | |
1310 | + return nil | |
1311 | + }) | |
1312 | +} | |
1313 | +func (c *Compiler) tagOut(is IniSection, sbc *StateBytecode, | |
1314 | + sc *StateControllerBase) (StateController, error) { | |
1315 | + return tagOut(*sc), c.stateSec(is, func() error { | |
1316 | + sc.add(tagOut_, nil) | |
1317 | + return nil | |
1318 | + }) | |
1319 | +} | |
1320 | +func (c *Compiler) destroySelf(is IniSection, sbc *StateBytecode, | |
1321 | + sc *StateControllerBase) (StateController, error) { | |
1322 | + return destroySelf(*sc), c.stateSec(is, func() error { | |
1323 | + if err := c.stateParam(is, "recursive", func(data string) error { | |
1324 | + return c.scAdd(sc, destroySelf_recursive, data, VT_Bool, 1) | |
1325 | + }); err != nil { | |
1326 | + return err | |
1327 | + } | |
1328 | + if err := c.stateParam(is, "removeexplods", func(data string) error { | |
1329 | + return c.scAdd(sc, destroySelf_removeexplods, data, VT_Bool, 1) | |
1330 | + }); err != nil { | |
1331 | + return err | |
1332 | + } | |
1333 | + return nil | |
1334 | + }) | |
1335 | +} | |
1336 | +func (c *Compiler) changeAnimSub(is IniSection, | |
1337 | + sc *StateControllerBase) error { | |
1338 | + if err := c.stateParam(is, "elem", func(data string) error { | |
1339 | + return c.scAdd(sc, changeAnim_elem, data, VT_Int, 1) | |
1340 | + }); err != nil { | |
1341 | + return err | |
1342 | + } | |
1343 | + f := false | |
1344 | + if err := c.stateParam(is, "value", func(data string) error { | |
1345 | + f = true | |
1346 | + return c.scAdd(sc, changeAnim_value, data, VT_Int, 1) | |
1347 | + }); err != nil { | |
1348 | + return err | |
1349 | + } | |
1350 | + if !f { | |
1351 | + return Error("valueが指定されていません") | |
1352 | + } | |
1353 | + return nil | |
1354 | +} | |
1355 | +func (c *Compiler) changeAnim(is IniSection, sbc *StateBytecode, | |
1356 | + sc *StateControllerBase) (StateController, error) { | |
1357 | + return changeAnim(*sc), c.stateSec(is, func() error { | |
1358 | + return c.changeAnimSub(is, sc) | |
1359 | + }) | |
1360 | +} | |
1361 | +func (c *Compiler) changeAnim2(is IniSection, sbc *StateBytecode, | |
1362 | + sc *StateControllerBase) (StateController, error) { | |
1363 | + return changeAnim2(*sc), c.stateSec(is, func() error { | |
1364 | + return c.changeAnimSub(is, sc) | |
1365 | + }) | |
1366 | +} | |
1367 | +func (c *Compiler) helper(is IniSection, sbc *StateBytecode, | |
1368 | + sc *StateControllerBase) (StateController, error) { | |
1369 | + return helper(*sc), c.stateSec(is, func() error { | |
1370 | + if err := c.stateParam(is, "helpertype", func(data string) error { | |
1371 | + if len(data) == 0 { | |
1372 | + return Error("値が指定されていません") | |
1373 | + } | |
1374 | + switch strings.ToLower(data)[0] { | |
1375 | + case 'n': | |
1376 | + case 'p': | |
1377 | + sc.add(helper_helpertype, sc.iToExp(1)) | |
1378 | + default: | |
1379 | + return Error(data + "が無効な値です") | |
1380 | + } | |
1381 | + return nil | |
1382 | + }); err != nil { | |
1383 | + return err | |
1384 | + } | |
1385 | + if err := c.stateParam(is, "name", func(data string) error { | |
1386 | + if len(data) < 2 || data[0] != '"' || data[len(data)-1] != '"' { | |
1387 | + return Error("\"で囲まれていません") | |
1388 | + } | |
1389 | + sc.add(helper_name, sc.beToExp(BytecodeExp(data[1:len(data)-1]))) | |
1390 | + return nil | |
1391 | + }); err != nil { | |
1392 | + return err | |
1393 | + } | |
1066 | 1394 | unimplemented() |
1067 | 1395 | return nil |
1068 | 1396 | }) |
@@ -1130,6 +1458,24 @@ func (c *Compiler) stateCompile(bc *Bytecode, filename, def string) error { | ||
1130 | 1458 | scf = c.notHitBy |
1131 | 1459 | case "assertspecial": |
1132 | 1460 | scf = c.assertSpecial |
1461 | + case "playsnd": | |
1462 | + scf = c.playSnd | |
1463 | + case "changestate": | |
1464 | + scf = c.changeState | |
1465 | + case "selfstate": | |
1466 | + scf = c.selfState | |
1467 | + case "tagin": | |
1468 | + scf = c.tagIn | |
1469 | + case "tagout": | |
1470 | + scf = c.tagOut | |
1471 | + case "destroyself": | |
1472 | + scf = c.destroySelf | |
1473 | + case "changeanim": | |
1474 | + scf = c.changeAnim | |
1475 | + case "changeanim2": | |
1476 | + scf = c.changeAnim2 | |
1477 | + case "helper": | |
1478 | + scf = c.helper | |
1133 | 1479 | default: |
1134 | 1480 | println(data) |
1135 | 1481 | unimplemented() |
@@ -1159,7 +1505,7 @@ func (c *Compiler) stateCompile(bc *Bytecode, filename, def string) error { | ||
1159 | 1505 | } |
1160 | 1506 | default: |
1161 | 1507 | tn, ok := readDigit(name[7:]) |
1162 | - if !ok || tn <= 0 || tn > 65536 { | |
1508 | + if !ok || tn < 1 || tn > 65536 { | |
1163 | 1509 | errmes(Error("トリガー名 (" + name + ") が不正です")) |
1164 | 1510 | } |
1165 | 1511 | if len(trigger) < int(tn) { |
@@ -1208,12 +1554,10 @@ func (c *Compiler) stateCompile(bc *Bytecode, filename, def string) error { | ||
1208 | 1554 | } |
1209 | 1555 | var texp BytecodeExp |
1210 | 1556 | for i, e := range triggerall { |
1211 | - if len(e) > 0 { | |
1212 | - texp.append(e...) | |
1213 | - if i < len(triggerall)-1 { | |
1214 | - texp.append(OC_jz8, 0) | |
1215 | - texp.append(OC_pop) | |
1216 | - } | |
1557 | + texp.append(e...) | |
1558 | + if i < len(triggerall)-1 { | |
1559 | + texp.append(OC_jz8, 0) | |
1560 | + texp.append(OC_pop) | |
1217 | 1561 | } |
1218 | 1562 | } |
1219 | 1563 | if allUtikiri { |
@@ -1232,18 +1576,16 @@ func (c *Compiler) stateCompile(bc *Bytecode, filename, def string) error { | ||
1232 | 1576 | oldlen := len(te) |
1233 | 1577 | for j := len(tr) - 1; j >= 0; j-- { |
1234 | 1578 | tmp := tr[j] |
1235 | - if len(tmp) > 0 { | |
1236 | - if j < len(tr)-1 { | |
1237 | - if len(te) > int(math.MaxUint8-1) { | |
1238 | - tmp.appendJmp(OC_jz, int32(len(te)+1)) | |
1239 | - tmp.append(OC_pop) | |
1240 | - } else { | |
1241 | - tmp.append(OC_jz8, OpCode(len(te)+1)) | |
1242 | - tmp.append(OC_pop) | |
1243 | - } | |
1579 | + if j < len(tr)-1 { | |
1580 | + if len(te) > int(math.MaxUint8-1) { | |
1581 | + tmp.appendJmp(OC_jz, int32(len(te)+1)) | |
1582 | + tmp.append(OC_pop) | |
1583 | + } else { | |
1584 | + tmp.append(OC_jz8, OpCode(len(te)+1)) | |
1585 | + tmp.append(OC_pop) | |
1244 | 1586 | } |
1245 | - te = append(tmp, te...) | |
1246 | 1587 | } |
1588 | + te = append(tmp, te...) | |
1247 | 1589 | } |
1248 | 1590 | if len(te) == oldlen { |
1249 | 1591 | te = nil |
@@ -94,6 +94,7 @@ type System struct { | ||
94 | 94 | ignoreMostErrors bool |
95 | 95 | stringPool [MaxSimul * 2]StringPool |
96 | 96 | bcStack BytecodeStack |
97 | + specialFlag GlobalSpecialFlag | |
97 | 98 | } |
98 | 99 | |
99 | 100 | func (s *System) init(w, h int32) *lua.LState { |