diff --git a/source/duke3d/src/gamedef.cpp b/source/duke3d/src/gamedef.cpp index 33994c1c6..2ce3da01b 100644 --- a/source/duke3d/src/gamedef.cpp +++ b/source/duke3d/src/gamedef.cpp @@ -144,19 +144,19 @@ static tokenmap_t const vm_keywords[] = { "addammo", CON_ADDAMMO }, { "addinventory", CON_ADDINVENTORY }, { "addkills", CON_ADDKILLS }, - { "addlog", CON_ADDLOG }, + { "addlog", CON_ADDLOGVAR }, { "addlogvar", CON_ADDLOGVAR }, { "addphealth", CON_ADDPHEALTH }, { "addstrength", CON_ADDSTRENGTH }, { "addvar", CON_ADDVAR }, { "addvarvar", CON_ADDVARVAR }, { "addweapon", CON_ADDWEAPON }, - { "addweaponvar", CON_ADDWEAPONVAR }, + { "addweaponvar", CON_ADDWEAPON }, { "ai", CON_AI }, { "andvar", CON_ANDVAR }, { "andvarvar", CON_ANDVARVAR }, { "angoff", CON_ANGOFF }, - { "angoffvar", CON_ANGOFFVAR }, + { "angoffvar", CON_ANGOFF }, { "appendevent", CON_APPENDEVENT }, { "betaname", CON_BETANAME }, { "break", CON_BREAK }, @@ -225,18 +225,18 @@ static tokenmap_t const vm_keywords[] = { "ends", CON_ENDS }, { "endswitch", CON_ENDSWITCH }, { "enhanced", CON_ENHANCED }, - { "eqspawnvar", CON_EQSPAWNVAR }, - { "eshootvar", CON_ESHOOTVAR }, - { "espawnvar", CON_ESPAWNVAR }, + { "eqspawnvar", CON_EQSPAWN }, + { "eshootvar", CON_ESHOOT }, + { "espawnvar", CON_ESPAWN }, { "eventloadactor", CON_EVENTLOADACTOR }, - { "ezshootvar", CON_EZSHOOTVAR }, + { "ezshootvar", CON_EZSHOOT }, { "fall", CON_FALL }, - { "findnearactor3dvar", CON_FINDNEARACTOR3DVAR }, - { "findnearactorvar", CON_FINDNEARACTORVAR }, - { "findnearactorzvar", CON_FINDNEARACTORZVAR }, - { "findnearsprite3dvar", CON_FINDNEARSPRITE3DVAR }, - { "findnearspritevar", CON_FINDNEARSPRITEVAR }, - { "findnearspritezvar", CON_FINDNEARSPRITEZVAR }, + { "findnearactor3dvar", CON_FINDNEARACTOR3D }, + { "findnearactorvar", CON_FINDNEARACTOR }, + { "findnearactorzvar", CON_FINDNEARACTORZ }, + { "findnearsprite3dvar", CON_FINDNEARSPRITE3D }, + { "findnearspritevar", CON_FINDNEARSPRITE }, + { "findnearspritezvar", CON_FINDNEARSPRITEZ }, { "findotherplayer", CON_FINDOTHERPLAYER }, { "findplayer", CON_FINDPLAYER }, { "flash", CON_FLASH }, @@ -278,14 +278,14 @@ static tokenmap_t const vm_keywords[] = { "getwall", CON_GETWALL }, { "getzrange", CON_GETZRANGE }, { "globalsound", CON_GLOBALSOUND }, - { "globalsoundvar", CON_GLOBALSOUNDVAR }, + { "globalsoundvar", CON_GLOBALSOUND }, { "gmaxammo", CON_GMAXAMMO }, { "guniqhudid", CON_GUNIQHUDID }, { "guts", CON_GUTS }, { "headspritesect", CON_HEADSPRITESECT }, { "headspritestat", CON_HEADSPRITESTAT }, { "hitradius", CON_HITRADIUS }, - { "hitradiusvar", CON_HITRADIUSVAR }, + { "hitradiusvar", CON_HITRADIUS }, { "hitscan", CON_HITSCAN }, { "ifaction", CON_IFACTION }, { "ifactioncount", CON_IFACTIONCOUNT }, @@ -416,7 +416,7 @@ static tokenmap_t const vm_keywords[] = { "preloadtrackslotforswap", CON_PRELOADTRACKSLOTFORSWAP }, { "pstomp", CON_PSTOMP }, { "qgetsysstr", CON_QGETSYSSTR }, - { "qspawnvar", CON_QSPAWNVAR }, + { "qspawnvar", CON_QSPAWN }, { "qsprintf", CON_QSPRINTF }, { "qstrcat", CON_QSTRCAT }, { "qstrcmp", CON_QSTRCMP }, @@ -488,7 +488,7 @@ static tokenmap_t const vm_keywords[] = { "shiftvarr", CON_SHIFTVARR }, { "shiftvarvarl", CON_SHIFTVARVARL }, { "shiftvarvarr", CON_SHIFTVARVARR }, - { "shootvar", CON_SHOOTVAR }, + { "shootvar", CON_SHOOT }, { "showview", CON_SHOWVIEW }, { "showviewunbiased", CON_SHOWVIEWUNBIASED }, { "showviewq16", CON_SHOWVIEWQ16 }, @@ -500,8 +500,8 @@ static tokenmap_t const vm_keywords[] = { "smaxammo", CON_SMAXAMMO }, { "sound", CON_SOUND }, { "soundonce", CON_SOUNDONCE }, - { "soundoncevar", CON_SOUNDONCEVAR }, - { "soundvar", CON_SOUNDVAR }, + { "soundoncevar", CON_SOUNDONCE }, + { "soundvar", CON_SOUND }, { "spawn", CON_SPAWN }, { "spawnceilingglass", CON_SPAWNCEILINGGLASS }, { "spawnwallstainedglass", CON_SPAWNWALLSTAINEDGLASS }, @@ -521,13 +521,13 @@ static tokenmap_t const vm_keywords[] = { "startscreen", CON_STARTSCREEN }, { "starttrack", CON_STARTTRACK }, { "starttrackslot", CON_STARTTRACKSLOT }, - { "starttrackvar", CON_STARTTRACKVAR }, + { "starttrackvar", CON_STARTTRACK }, { "state", CON_STATE }, { "stopactorsound", CON_STOPACTORSOUND }, { "stopallmusic", CON_STOPALLMUSIC }, { "stopallsounds", CON_STOPALLSOUNDS }, { "stopsound", CON_STOPSOUND }, - { "stopsoundvar", CON_STOPSOUNDVAR }, + { "stopsoundvar", CON_STOPSOUND }, { "strength", CON_STRENGTH }, { "subvar", CON_SUBVAR }, { "subvarvar", CON_SUBVARVAR }, @@ -554,7 +554,7 @@ static tokenmap_t const vm_keywords[] = { "writearraytofile", CON_WRITEARRAYTOFILE }, { "xorvar", CON_XORVAR }, { "xorvarvar", CON_XORVARVAR }, - { "zshootvar", CON_ZSHOOTVAR }, + { "zshootvar", CON_ZSHOOT }, { "{", CON_LEFTBRACE }, { "}", CON_RIGHTBRACE }, @@ -621,22 +621,22 @@ static tokenmap_t const vm_keywords[] = { "qputs", CON_REDEFINEQUOTE }, - { "espawn", CON_ESPAWNVAR }, - { "qspawn", CON_QSPAWNVAR }, - { "eqspawn", CON_EQSPAWNVAR }, + { "espawn", CON_ESPAWN }, + { "qspawn", CON_QSPAWN }, + { "eqspawn", CON_EQSPAWN }, - { "eshoot", CON_ESHOOTVAR }, - { "zshoot", CON_ZSHOOTVAR }, - { "ezshoot", CON_EZSHOOTVAR }, - { "shoot", CON_SHOOTVAR }, + { "eshoot", CON_ESHOOT }, + { "zshoot", CON_ZSHOOT }, + { "ezshoot", CON_EZSHOOT }, + { "shoot", CON_SHOOT }, - { "findnearactor", CON_FINDNEARACTORVAR }, - { "findnearactor3d", CON_FINDNEARACTOR3DVAR }, - { "findnearactorz", CON_FINDNEARACTORZVAR }, + { "findnearactor", CON_FINDNEARACTOR }, + { "findnearactor3d", CON_FINDNEARACTOR3D }, + { "findnearactorz", CON_FINDNEARACTORZ }, - { "findnearsprite", CON_FINDNEARSPRITEVAR }, - { "findnearsprite3d", CON_FINDNEARSPRITE3DVAR }, - { "findnearspritez", CON_FINDNEARSPRITEZVAR }, + { "findnearsprite", CON_FINDNEARSPRITE }, + { "findnearsprite3d", CON_FINDNEARSPRITE3D }, + { "findnearspritez", CON_FINDNEARSPRITEZ }, }; static const vec2_t varvartable[] = @@ -3099,7 +3099,7 @@ DO_DEFSTATE: C_GetManyVars(4); continue; - case CON_HITRADIUSVAR: + case CON_HITRADIUS: case CON_DRAWLINE256: C_GetManyVars(5); continue; @@ -3108,14 +3108,8 @@ DO_DEFSTATE: C_GetManyVars(6); continue; - case CON_HITRADIUS: - C_GetNextValue(LABEL_DEFINE); - C_GetNextValue(LABEL_DEFINE); - C_GetNextValue(LABEL_DEFINE); - fallthrough__; case CON_ADDAMMO: case CON_ADDINVENTORY: - case CON_ADDWEAPON: case CON_DEBRIS: case CON_GUTS: case CON_SIZEAT: @@ -3125,7 +3119,6 @@ DO_DEFSTATE: case CON_ADDKILLS: case CON_ADDPHEALTH: case CON_ADDSTRENGTH: - case CON_ANGOFF: case CON_CACTOR: case CON_CLIPDIST: case CON_COUNT: @@ -3133,7 +3126,6 @@ DO_DEFSTATE: case CON_DEBUG: case CON_ENDOFGAME: case CON_ENDOFLEVEL: - case CON_GLOBALSOUND: case CON_LOTSOFGLASS: case CON_MAIL: case CON_MONEY: @@ -3142,11 +3134,8 @@ DO_DEFSTATE: case CON_SAVE: case CON_SAVENN: case CON_SLEEPTIME: - case CON_SOUND: - case CON_SOUNDONCE: case CON_SPAWN: case CON_SPRITEPAL: - case CON_STOPSOUND: case CON_STRENGTH: C_GetNextValue(LABEL_DEFINE); continue; @@ -3213,12 +3202,12 @@ DO_DEFSTATE: continue; } - case CON_FINDNEARACTOR3DVAR: - case CON_FINDNEARACTORVAR: - case CON_FINDNEARACTORZVAR: - case CON_FINDNEARSPRITE3DVAR: - case CON_FINDNEARSPRITEVAR: - case CON_FINDNEARSPRITEZVAR: + case CON_FINDNEARACTOR3D: + case CON_FINDNEARACTOR: + case CON_FINDNEARACTORZ: + case CON_FINDNEARSPRITE3D: + case CON_FINDNEARSPRITE: + case CON_FINDNEARSPRITEZ: { C_GetNextValue(LABEL_DEFINE); // get @@ -3226,8 +3215,8 @@ DO_DEFSTATE: C_GetNextVar(); switch (tw) { - case CON_FINDNEARACTORZVAR: - case CON_FINDNEARSPRITEZVAR: + case CON_FINDNEARACTORZ: + case CON_FINDNEARSPRITEZ: C_GetNextVar(); default: break; @@ -3568,17 +3557,17 @@ setvarvar: fallthrough__; case CON_ACTIVATECHEAT: case CON_ADDLOGVAR: - case CON_ANGOFFVAR: + case CON_ANGOFF: case CON_CHECKACTIVATORMOTION: case CON_CHECKAVAILINVEN: case CON_CHECKAVAILWEAPON: case CON_CLEARMAPSTATE: case CON_CMENU: case CON_ECHO: - case CON_EQSPAWNVAR: - case CON_ESHOOTVAR: - case CON_ESPAWNVAR: - case CON_GLOBALSOUNDVAR: + case CON_EQSPAWN: + case CON_ESHOOT: + case CON_ESPAWN: + case CON_GLOBALSOUND: case CON_GUNIQHUDID: case CON_INITTIMER: case CON_JUMP: @@ -3586,7 +3575,7 @@ setvarvar: case CON_MOVESECTOR: case CON_OPERATEMASTERSWITCHES: case CON_OPERATERESPAWNS: - case CON_QSPAWNVAR: + case CON_QSPAWN: case CON_QUAKE: case CON_RESETPLAYERFLAGS: case CON_SAVEGAMEVAR: @@ -3597,12 +3586,12 @@ setvarvar: case CON_SETGAMEPALETTE: case CON_SETMUSICPOSITION: case CON_SETPLAYERANGLE: - case CON_SHOOTVAR: - case CON_SOUNDONCEVAR: - case CON_SOUNDVAR: + case CON_SHOOT: + case CON_SOUNDONCE: + case CON_SOUND: case CON_STARTCUTSCENE: - case CON_STARTTRACKVAR: - case CON_STOPSOUNDVAR: + case CON_STARTTRACK: + case CON_STOPSOUND: case CON_TIME: case CON_USERQUOTE: C_GetNextVar(); @@ -3634,7 +3623,7 @@ setvarvar: case CON_ACTORSOUND: case CON_CHANGESPRITESECT: case CON_CHANGESPRITESTAT: - case CON_EZSHOOTVAR: + case CON_EZSHOOT: case CON_GETPNAME: case CON_PRELOADTRACKSLOTFORSWAP: case CON_QGETSYSSTR: @@ -3647,7 +3636,7 @@ setvarvar: case CON_STARTTRACKSLOT: case CON_STOPACTORSOUND: case CON_SWAPTRACKSLOT: - case CON_ZSHOOTVAR: + case CON_ZSHOOT: C_GetManyVars(2); continue; @@ -3892,7 +3881,7 @@ setvarvar: continue; case CON_ACTIVATEBYSECTOR: - case CON_ADDWEAPONVAR: + case CON_ADDWEAPON: case CON_DIST: case CON_DIVSCALE: case CON_GETANGLE: @@ -4141,11 +4130,6 @@ setvarvar: } continue; - case CON_STARTTRACK: - // one parameter (track#) - C_GetNextValue(LABEL_DEFINE); - continue; - case CON_IFACTORSOUND: case CON_IFVARVARA: case CON_IFVARVARAE: @@ -5634,7 +5618,6 @@ repeatcase: g_scriptPtr--; continue; - case CON_ADDLOG: case CON_FALL: case CON_GETLASTPAL: case CON_GETTEXTURECEILING: diff --git a/source/duke3d/src/gamedef.h b/source/duke3d/src/gamedef.h index d36538736..9ff526e47 100644 --- a/source/duke3d/src/gamedef.h +++ b/source/duke3d/src/gamedef.h @@ -836,449 +836,432 @@ enum IterationTypes_t enum ScriptKeywords_t { - CON_ELSE, // 0 - CON_ACTOR, // 1 - CON_ADDAMMO, // 2 - CON_IFRND, // 3 - CON_ENDA, // 4 - CON_IFCANSEE, // 5 - CON_IFHITWEAPON, // 6 - CON_ACTION, // 7 - CON_IFPDISTL, // 8 - CON_IFPDISTG, // 9 - CON_DEFINELEVELNAME, // 10 - CON_STRENGTH, // 11 - CON_BREAK, // 12 - CON_SHOOT, // 13 - CON_PALFROM, // 14 - CON_SOUND, // 15 - CON_FALL, // 16 - CON_STATE, // 17 - CON_ENDS, // 18 - CON_DEFINE, // 19 - CON_RETURN, // 20 - CON_IFAI, // 21 - CON_KILLIT, // 22 - CON_ADDWEAPON, // 23 - CON_AI, // 24 - CON_ADDPHEALTH, // 25 - CON_IFDEAD, // 26 - CON_IFSQUISHED, // 27 - CON_SIZETO, // 28 - CON_LEFTBRACE, // 29 - CON_RIGHTBRACE, // 30 - CON_SPAWN, // 31 - CON_MOVE, // 32 - CON_IFWASWEAPON, // 33 - CON_IFACTION, // 34 - CON_IFACTIONCOUNT, // 35 - CON_RESETACTIONCOUNT, // 36 - CON_DEBRIS, // 37 - CON_PSTOMP, // 38 - CON_BLOCKCOMMENT, // 39 deprecated - CON_CSTAT, // 40 - CON_IFMOVE, // 41 - CON_RESETPLAYER, // 42 - CON_IFONWATER, // 43 - CON_IFINWATER, // 44 - CON_IFCANSHOOTTARGET, // 45 - CON_IFCOUNT, // 46 - CON_RESETCOUNT, // 47 - CON_ADDINVENTORY, // 48 - CON_IFACTORNOTSTAYPUT, // 49 - CON_HITRADIUS, // 50 - CON_IFP, // 51 - CON_COUNT, // 52 - CON_IFACTOR, // 53 - CON_MUSIC, // 54 - CON_INCLUDE, // 55 - CON_IFSTRENGTH, // 56 - CON_DEFINESOUND, // 57 - CON_GUTS, // 58 - CON_IFSPAWNEDBY, // 59 - CON_GAMESTARTUP, // 60 - CON_WACKPLAYER, // 61 - CON_IFGAPZL, // 62 - CON_IFHITSPACE, // 63 - CON_IFOUTSIDE, // 64 - CON_IFMULTIPLAYER, // 65 - CON_OPERATE, // 66 - CON_IFINSPACE, // 67 - CON_DEBUG, // 68 - CON_ENDOFGAME, // 69 - CON_IFBULLETNEAR, // 70 - CON_IFRESPAWN, // 71 - CON_IFFLOORDISTL, // 72 - CON_IFCEILINGDISTL, // 73 - CON_SPRITEPAL, // 74 - CON_IFPINVENTORY, // 75 - CON_BETANAME, // 76 - CON_CACTOR, // 77 - CON_IFPHEALTHL, // 78 - CON_DEFINEQUOTE, // 79 - CON_QUOTE, // 80 - CON_IFINOUTERSPACE, // 81 - CON_IFNOTMOVING, // 82 - CON_RESPAWNHITAG, // 83 - CON_TIP, // 84 - CON_IFSPRITEPAL, // 85 - CON_MONEY, // 86 - CON_SOUNDONCE, // 87 - CON_ADDKILLS, // 88 - CON_STOPSOUND, // 89 - CON_IFAWAYFROMWALL, // 90 - CON_IFCANSEETARGET, // 91 - CON_GLOBALSOUND, // 92 - CON_LOTSOFGLASS, // 93 - CON_IFGOTWEAPONCE, // 94 - CON_GETLASTPAL, // 95 - CON_PKICK, // 96 - CON_MIKESND, // 97 - CON_USERACTOR, // 98 - CON_SIZEAT, // 99 - CON_ADDSTRENGTH, // 100 - CON_CSTATOR, // 101 - CON_MAIL, // 102 - CON_PAPER, // 103 - CON_TOSSWEAPON, // 104 - CON_SLEEPTIME, // 105 - CON_NULLOP, // 106 - CON_DEFINEVOLUMENAME, // 107 - CON_DEFINESKILLNAME, // 108 - CON_IFNOSOUNDS, // 109 - CON_CLIPDIST, // 110 - CON_IFANGDIFFL, // 111 - CON_GAMEVAR, // 112 - CON_IFVARL, // 113 - CON_IFVARG, // 114 - CON_SETVARVAR, // 115 - CON_SETVAR, // 116 - CON_ADDVARVAR, // 117 - CON_ADDVAR, // 118 - CON_IFVARVARL, // 119 - CON_IFVARVARG, // 120 - CON_ADDLOGVAR, // 121 - CON_ADDLOG, // 122 - CON_ONEVENT, // 123 - CON_ENDEVENT, // 124 - CON_IFVARE, // 125 - CON_IFVARVARE, // 126 - CON_SPGETLOTAG, // 127 - CON_SPGETHITAG, // 128 - CON_SECTGETLOTAG, // 129 - CON_SECTGETHITAG, // 130 - CON_IFSOUND, // 131 - CON_GETTEXTUREFLOOR, // 132 - CON_GETTEXTURECEILING, // 133 - CON_INITTIMER, // 134 - CON_STARTTRACK, // 135 - CON_RANDVAR, // 136 - CON_ENHANCED, // 137 - CON_GETANGLETOTARGET, // 138 - CON_GETACTORANGLE, // 139 - CON_SETACTORANGLE, // 140 - CON_MULVAR, // 141 - CON_MULVARVAR, // 142 - CON_DIVVAR, // 143 - CON_DIVVARVAR, // 144 - CON_MODVAR, // 145 - CON_MODVARVAR, // 146 - CON_ANDVAR, // 147 - CON_ANDVARVAR, // 148 - CON_ORVAR, // 149 - CON_ORVARVAR, // 150 - CON_GETPLAYERANGLE, // 151 - CON_SETPLAYERANGLE, // 152 - CON_LOCKPLAYER, // 153 - CON_SETSECTOR, // 154 - CON_GETSECTOR, // 155 - CON_SETACTOR, // 156 - CON_GETACTOR, // 157 - CON_SETWALL, // 158 - CON_GETWALL, // 159 - CON_FINDNEARACTOR, // 160 - CON_FINDNEARACTORVAR, // 161 - CON_SETACTORVAR, // 162 - CON_GETACTORVAR, // 163 - CON_ESPAWN, // 164 - CON_GETPLAYER, // 165 - CON_SETPLAYER, // 166 - CON_SQRT, // 167 - CON_EVENTLOADACTOR, // 168 - CON_ESPAWNVAR, // 169 - CON_GETUSERDEF, // 170 - CON_SETUSERDEF, // 171 - CON_SUBVARVAR, // 172 - CON_SUBVAR, // 173 - CON_IFVARN, // 174 - CON_IFVARVARN, // 175 - CON_IFVARAND, // 176 - CON_IFVARVARAND, // 177 - CON_MYOS, // 178 - CON_MYOSPAL, // 179 - CON_DISPLAYRAND, // 180 - CON_SIN, // 181 - CON_XORVARVAR, // 182 - CON_XORVAR, // 183 - CON_RANDVARVAR, // 184 - CON_MYOSX, // 185 - CON_MYOSPALX, // 186 - CON_GMAXAMMO, // 187 - CON_SMAXAMMO, // 188 - CON_STARTLEVEL, // 189 - CON_ESHOOT, // 190 - CON_QSPAWN, // 191 - CON_ROTATESPRITE, // 192 - CON_DEFINEPROJECTILE, // 193 - CON_SPRITESHADOW, // 194 - CON_COS, // 195 - CON_ESHOOTVAR, // 196 - CON_FINDNEARACTOR3D, // 197 - CON_FINDNEARACTOR3DVAR, // 198 - CON_FLASH, // 199 - CON_QSPAWNVAR, // 200 - CON_EQSPAWN, // 201 - CON_EQSPAWNVAR, // 202 - CON_MINITEXT, // 203 - CON_GAMETEXT, // 204 - CON_DIGITALNUMBER, // 205 - CON_ADDWEAPONVAR, // 206 - CON_SETPROJECTILE, // 207 - CON_ANGOFF, // 208 - CON_UPDATESECTOR, // 209 - CON_INSERTSPRITEQ, // 210 - CON_ANGOFFVAR, // 211 - CON_WHILEVARN, // 212 - CON_SWITCH, // 213 - CON_CASE, // 214 - CON_DEFAULT, // 215 - CON_ENDSWITCH, // 216 - CON_SHOOTVAR, // 217 - CON_SOUNDVAR, // 218 - CON_FINDPLAYER, // 219 - CON_FINDOTHERPLAYER, // 220 - CON_ACTIVATEBYSECTOR, // 221 - CON_OPERATESECTORS, // 222 - CON_OPERATERESPAWNS, // 223 - CON_OPERATEACTIVATORS, // 224 - CON_OPERATEMASTERSWITCHES, // 225 - CON_CHECKACTIVATORMOTION, // 226 - CON_ZSHOOT, // 227 - CON_DIST, // 228 - CON_LDIST, // 229 - CON_SHIFTVARL, // 230 - CON_SHIFTVARR, // 231 - CON_SPRITENVG, // 232 - CON_GETANGLE, // 233 - CON_WHILEVARVARN, // 234 - CON_HITSCAN, // 235 - CON_TIME, // 236 - CON_GETPLAYERVAR, // 237 - CON_SETPLAYERVAR, // 238 - CON_MULSCALE, // 239 - CON_SETASPECT, // 240 - CON_EZSHOOT, // 241 - CON_SPRITENOSHADE, // 242 - CON_MOVESPRITE, // 243 - CON_CHECKAVAILWEAPON, // 244 - CON_SOUNDONCEVAR, // 245 - CON_UPDATESECTORZ, // 246 - CON_STOPALLSOUNDS, // 247 - CON_SSP, // 248 - CON_STOPSOUNDVAR, // 249 - CON_DISPLAYRANDVAR, // 250 - CON_DISPLAYRANDVARVAR, // 251 - CON_CHECKAVAILINVEN, // 252 - CON_GLOBALSOUNDVAR, // 253 - CON_GUNIQHUDID, // 254 - CON_GETPROJECTILE, // 255 - CON_GETTHISPROJECTILE, // 256 - CON_SETTHISPROJECTILE, // 257 - CON_DEFINECHEAT, // 258 - CON_CHEATKEYS, // 259 - CON_USERQUOTE, // 260 - CON_PRECACHE, // 261 - CON_DEFINEGAMEFUNCNAME, // 262 - CON_REDEFINEQUOTE, // 263 - CON_QSPRINTF, // 264 - CON_GETPNAME, // 265 - CON_QSTRCAT, // 266 - CON_QSTRCPY, // 267 - CON_SETSPRITE, // 268 - CON_ROTATEPOINT, // 269 - CON_DRAGPOINT, // 270 - CON_GETZRANGE, // 271 - CON_CHANGESPRITESTAT, // 272 - CON_GETCEILZOFSLOPE, // 273 - CON_GETFLORZOFSLOPE, // 274 - CON_NEARTAG, // 275 - CON_DEFINEGAMETYPE, // 276 - CON_CHANGESPRITESECT, // 277 - CON_SPRITEFLAGS, // 278 - CON_SAVEGAMEVAR, // 279 - CON_READGAMEVAR, // 280 - CON_FINDNEARSPRITE, // 281 - CON_FINDNEARSPRITEVAR, // 282 - CON_FINDNEARSPRITE3D, // 283 - CON_FINDNEARSPRITE3DVAR,// 284 - CON_DYNAMICREMAP, // 285 - CON_SETINPUT, // 286 - CON_GETINPUT, // 287 - CON_SAVE, // 288 - CON_CANSEE, // 289 - CON_CANSEESPR, // 290 - CON_FINDNEARACTORZ, // 291 - CON_FINDNEARACTORZVAR, // 292 - CON_FINDNEARSPRITEZ, // 293 - CON_FINDNEARSPRITEZVAR, // 294 - CON_ZSHOOTVAR, // 295 - CON_EZSHOOTVAR, // 296 - CON_GETCURRADDRESS, // 297 - CON_JUMP, // 298 - CON_QSTRLEN, // 299 - CON_GETINCANGLE, // 300 - CON_QUAKE, // 301 - CON_SHOWVIEW, // 302 - CON_HEADSPRITESTAT, // 303 - CON_PREVSPRITESTAT, // 304 - CON_NEXTSPRITESTAT, // 305 - CON_HEADSPRITESECT, // 306 - CON_PREVSPRITESECT, // 307 - CON_NEXTSPRITESECT, // 308 - CON_GETKEYNAME, // 309 - CON_QSUBSTR, // 310 - CON_GAMETEXTZ, // 311 - CON_DIGITALNUMBERZ, // 312 - CON_SPRITENOPAL, // 313 - CON_HITRADIUSVAR, // 314 - CON_ROTATESPRITE16, // 315 - CON_GAMEARRAY, // 316 - CON_SETARRAY, // 317 - CON_RESIZEARRAY, // 318 - CON_WRITEARRAYTOFILE, // 319 - CON_READARRAYFROMFILE, // 320 - CON_STARTTRACKVAR, // 321 - CON_QGETSYSSTR, // 322 - CON_GETTICKS, // 323 - CON_GETTSPR, // 324 - CON_SETTSPR, // 325 - CON_SAVEMAPSTATE, // 326 - CON_LOADMAPSTATE, // 327 - CON_CLEARMAPSTATE, // 328 - CON_SCRIPTSIZE, // 329 - CON_SETGAMENAME, // 330 - CON_CMENU, // 331 - CON_GETTIMEDATE, // 332 - CON_ACTIVATECHEAT, // 333 - CON_SETGAMEPALETTE, // 334 - CON_SETDEFNAME, // 335 - CON_SETCFGNAME, // 336 - CON_IFVAROR, // 337 - CON_IFVARVAROR, // 338 - CON_IFVARXOR, // 339 - CON_IFVARVARXOR, // 340 - CON_IFVAREITHER, // 341 - CON_IFVARVAREITHER, // 342 - CON_GETARRAYSIZE, // 343 - CON_SAVENN, // 344 - CON_COPY, // 345 - CON_INV, // 346 - CON_SECTOROFWALL, // 347 - CON_QSTRNCAT, // 348 - CON_IFACTORSOUND, // 349 - CON_STOPACTORSOUND, // 350 - CON_IFCLIENT, // 351 - CON_IFSERVER, // 352 - CON_SECTSETINTERPOLATION, // 353 - CON_SECTCLEARINTERPOLATION, // 354 - CON_CLIPMOVE, // 355 - CON_LINEINTERSECT, // 356 - CON_RAYINTERSECT, // 357 - CON_CALCHYPOTENUSE, // 358 - CON_CLIPMOVENOSLIDE, // 359 - CON_INCLUDEDEFAULT, // 360 - CON_SETACTORSOUNDPITCH, // 361 - CON_ECHO, // 362 - CON_SHOWVIEWUNBIASED, // 363 - CON_ROTATESPRITEA, // 364 - CON_SHADETO, // 365 - CON_ENDOFLEVEL, // 366 - CON_IFPLAYERSL, // 367 - CON_ACTIVATE, // 368 - CON_QSTRDIM, // 369 - CON_SCREENTEXT, // 370 - CON_DYNAMICSOUNDREMAP, // 371 - CON_SCREENSOUND, // 372 - CON_GETMUSICPOSITION, // 373 - CON_SETMUSICPOSITION, // 374 - CON_UNDEFINEVOLUME, // 375 - CON_UNDEFINESKILL, // 376 - CON_UNDEFINELEVEL, // 377 - CON_STARTCUTSCENE, // 378 - CON_IFCUTSCENE, // 379 - CON_DEFINEVOLUMEFLAGS, // 380 - CON_RESETPLAYERFLAGS, // 381 - CON_APPENDEVENT, // 382 - CON_DEFSTATE, // 383 - CON_SHIFTVARVARL, // 384 - CON_SHIFTVARVARR, // 385 - CON_IFVARVARLE, // 386 - CON_IFVARVARGE, // 387 - CON_IFVARVARBOTH, // 388 - CON_WHILEVARL, // 389 - CON_WHILEVARVARL, // 390 - CON_KLABS, // 391 - CON_IFVARLE, // 392 - CON_IFVARGE, // 393 - CON_IFVARBOTH, // 394 - CON_MOVESECTOR, // 395 - CON_FOR, // 396 - CON_NEXTSECTORNEIGHBORZ,// 397 - CON_CLAMP, // 398 - CON_IFPLAYBACKON, // 399 - CON_DIVSCALE, // 400 - CON_SCALEVAR, // 401 - CON_UNDEFINEGAMEFUNC, // 402 - CON_GETCLOSESTCOL, // 403 - CON_DRAWLINE256, // 404 - CON_DRAWLINERGB, // 405 - CON_STARTTRACKSLOT, // 406 - CON_STOPALLMUSIC, // 407 - CON_ACTORSOUND, // 408 - CON_STARTSCREEN, // 409 - CON_SCREENPAL, // 410 - CON_QSTRCMP, // 411 - CON_DIVR, // 412 - CON_DIVRU, // 413 - CON_SWAPTRACKSLOT, // 414 - CON_PRELOADTRACKSLOTFORSWAP, // 415 - CON_IFVARA, // 416 - CON_IFVARVARA, // 417 - CON_IFVARAE, // 418 - CON_IFVARVARAE, // 419 - CON_IFVARB, // 420 - CON_IFVARVARB, // 421 - CON_IFVARBE, // 422 - CON_IFVARVARBE, // 423 - CON_UNDEFINECHEAT, // 424 - CON_SHOWVIEWQ16, // 425 - CON_SHOWVIEWQ16UNBIASED,// 426 - CON_GETTILEDATA, // 427 - CON_SETTILEDATA, // 428 - CON_DAMAGEEVENTTILE, // 429 - CON_DAMAGEEVENTTILERANGE, // 430 - CON_SPAWNWALLGLASS, // 431 - CON_SPAWNWALLSTAINEDGLASS, // 432 - CON_SPAWNCEILINGGLASS, // 433 - CON_SWAPARRAYS, // 434 - CON_GETACTORSTRUCT, // 435 - CON_SETACTORSTRUCT, // 436 - CON_GETSPRITEEXT, // 437 - CON_SETSPRITEEXT, // 438 - CON_GETSPRITESTRUCT, // 439 - CON_SETSPRITESTRUCT, // 440 + CON_ACTION, + CON_ACTIVATE, + CON_ACTIVATEBYSECTOR, + CON_ACTIVATECHEAT, + CON_ACTORSOUND, + CON_ADDAMMO, + CON_ADDINVENTORY, + CON_ADDKILLS, + CON_ADDLOGVAR, + CON_ADDPHEALTH, + CON_ADDSTRENGTH, + CON_ADDVAR, + CON_ADDVARVAR, + CON_ADDWEAPON, + CON_AI, + CON_ANDVAR, + CON_ANDVARVAR, + CON_ANGOFF, + CON_BREAK, + CON_CACTOR, + CON_CALCHYPOTENUSE, + CON_CANSEE, + CON_CANSEESPR, + CON_CHANGESPRITESECT, + CON_CHANGESPRITESTAT, + CON_CHECKACTIVATORMOTION, + CON_CHECKAVAILINVEN, + CON_CHECKAVAILWEAPON, + CON_CLAMP, + CON_CLEARMAPSTATE, + CON_CLIPDIST, + CON_CLIPMOVE, + CON_CLIPMOVENOSLIDE, + CON_CMENU, + CON_COPY, + CON_COS, + CON_COUNT, + CON_CSTAT, + CON_CSTATOR, + CON_DEBRIS, + CON_DEBUG, + CON_DIGITALNUMBER, + CON_DIGITALNUMBERZ, + CON_DISPLAYRAND, + CON_DISPLAYRANDVAR, + CON_DISPLAYRANDVARVAR, + CON_DIST, + CON_DIVR, + CON_DIVRU, + CON_DIVSCALE, + CON_DIVVAR, + CON_DIVVARVAR, + CON_DRAGPOINT, + CON_DRAWLINE256, + CON_DRAWLINERGB, + CON_ECHO, + CON_ELSE, + CON_ENDA, + CON_ENDEVENT, + CON_ENDOFGAME, + CON_ENDOFLEVEL, + CON_ENDS, + CON_ENDSWITCH, + CON_EQSPAWN, + CON_ESHOOT, + CON_ESPAWN, + CON_EVENTLOADACTOR, + CON_EZSHOOT, + CON_FALL, + CON_FINDNEARACTOR3D, + CON_FINDNEARACTOR, + CON_FINDNEARACTORZ, + CON_FINDNEARSPRITE3D, + CON_FINDNEARSPRITE, + CON_FINDNEARSPRITEZ, + CON_FINDOTHERPLAYER, + CON_FINDPLAYER, + CON_FLASH, + CON_FOR, + CON_GAMETEXT, + CON_GAMETEXTZ, + CON_GETACTOR, + CON_GETACTORANGLE, + CON_GETACTORSTRUCT, + CON_GETACTORVAR, + CON_GETANGLE, + CON_GETANGLETOTARGET, + CON_GETARRAYSIZE, + CON_GETCEILZOFSLOPE, + CON_GETCLOSESTCOL, + CON_GETCURRADDRESS, + CON_GETFLORZOFSLOPE, + CON_GETINCANGLE, + CON_GETINPUT, + CON_GETKEYNAME, + CON_GETLASTPAL, + CON_GETMUSICPOSITION, + CON_GETPLAYER, + CON_GETPLAYERANGLE, + CON_GETPLAYERVAR, + CON_GETPNAME, + CON_GETPROJECTILE, + CON_GETSECTOR, + CON_GETSPRITEEXT, + CON_GETSPRITESTRUCT, + CON_GETTEXTURECEILING, + CON_GETTEXTUREFLOOR, + CON_GETTHISPROJECTILE, + CON_GETTICKS, + CON_GETTILEDATA, + CON_GETTIMEDATE, + CON_GETTSPR, + CON_GETUSERDEF, + CON_GETWALL, + CON_GETZRANGE, + CON_GLOBALSOUND, + CON_GMAXAMMO, + CON_GUNIQHUDID, + CON_GUTS, + CON_HEADSPRITESECT, + CON_HEADSPRITESTAT, + CON_HITRADIUS, + CON_HITSCAN, + CON_IFACTION, + CON_IFACTIONCOUNT, + CON_IFACTOR, + CON_IFACTORNOTSTAYPUT, + CON_IFACTORSOUND, + CON_IFAI, + CON_IFANGDIFFL, + CON_IFAWAYFROMWALL, + CON_IFBULLETNEAR, + CON_IFCANSEE, + CON_IFCANSEETARGET, + CON_IFCANSHOOTTARGET, + CON_IFCEILINGDISTL, + CON_IFCLIENT, + CON_IFCOUNT, + CON_IFCUTSCENE, + CON_IFDEAD, + CON_IFFLOORDISTL, + CON_IFGAPZL, + CON_IFGOTWEAPONCE, + CON_IFHITSPACE, + CON_IFHITWEAPON, + CON_IFINOUTERSPACE, + CON_IFINSPACE, + CON_IFINWATER, + CON_IFMOVE, + CON_IFMULTIPLAYER, + CON_IFNOSOUNDS, + CON_IFNOTMOVING, + CON_IFONWATER, + CON_IFOUTSIDE, + CON_IFP, + CON_IFPDISTG, + CON_IFPDISTL, + CON_IFPHEALTHL, + CON_IFPINVENTORY, + CON_IFPLAYBACKON, + CON_IFPLAYERSL, + CON_IFRESPAWN, + CON_IFRND, + CON_IFSERVER, + CON_IFSOUND, + CON_IFSPAWNEDBY, + CON_IFSPRITEPAL, + CON_IFSQUISHED, + CON_IFSTRENGTH, + CON_IFVARA, + CON_IFVARAE, + CON_IFVARAND, + CON_IFVARB, + CON_IFVARBE, + CON_IFVARBOTH, + CON_IFVARE, + CON_IFVAREITHER, + CON_IFVARG, + CON_IFVARGE, + CON_IFVARL, + CON_IFVARLE, + CON_IFVARN, + CON_IFVAROR, + CON_IFVARVARA, + CON_IFVARVARAE, + CON_IFVARVARAND, + CON_IFVARVARB, + CON_IFVARVARBE, + CON_IFVARVARBOTH, + CON_IFVARVARE, + CON_IFVARVAREITHER, + CON_IFVARVARG, + CON_IFVARVARGE, + CON_IFVARVARL, + CON_IFVARVARLE, + CON_IFVARVARN, + CON_IFVARVAROR, + CON_IFVARVARXOR, + CON_IFVARXOR, + CON_IFWASWEAPON, + CON_INITTIMER, + CON_INSERTSPRITEQ, + CON_INV, + CON_JUMP, + CON_KILLIT, + CON_KLABS, + CON_LDIST, + CON_LEFTBRACE, + CON_LINEINTERSECT, + CON_LOADMAPSTATE, + CON_LOCKPLAYER, + CON_LOTSOFGLASS, + CON_MAIL, + CON_MIKESND, + CON_MINITEXT, + CON_MODVAR, + CON_MODVARVAR, + CON_MONEY, + CON_MOVE, + CON_MOVESECTOR, + CON_MOVESPRITE, + CON_MULSCALE, + CON_MULVAR, + CON_MULVARVAR, + CON_MUSIC, + CON_MYOS, + CON_MYOSPAL, + CON_MYOSPALX, + CON_MYOSX, + CON_NEARTAG, + CON_NEXTSECTORNEIGHBORZ, + CON_NEXTSPRITESECT, + CON_NEXTSPRITESTAT, + CON_NULLOP, + CON_OPERATE, + CON_OPERATEACTIVATORS, + CON_OPERATEMASTERSWITCHES, + CON_OPERATERESPAWNS, + CON_OPERATESECTORS, + CON_ORVAR, + CON_ORVARVAR, + CON_PALFROM, + CON_PAPER, + CON_PKICK, + CON_PRECACHE, + CON_PRELOADTRACKSLOTFORSWAP, + CON_PREVSPRITESECT, + CON_PREVSPRITESTAT, + CON_PSTOMP, + CON_QGETSYSSTR, + CON_QSPAWN, + CON_QSPRINTF, + CON_QSTRCAT, + CON_QSTRCMP, + CON_QSTRCPY, + CON_QSTRDIM, + CON_QSTRLEN, + CON_QSTRNCAT, + CON_QSUBSTR, + CON_QUAKE, + CON_QUOTE, + CON_RANDVAR, + CON_RANDVARVAR, + CON_RAYINTERSECT, + CON_READARRAYFROMFILE, + CON_READGAMEVAR, + CON_REDEFINEQUOTE, + CON_RESETACTIONCOUNT, + CON_RESETCOUNT, + CON_RESETPLAYER, + CON_RESETPLAYERFLAGS, + CON_RESIZEARRAY, + CON_RESPAWNHITAG, + CON_RETURN, + CON_RIGHTBRACE, + CON_ROTATEPOINT, + CON_ROTATESPRITE, + CON_ROTATESPRITE16, + CON_ROTATESPRITEA, + CON_SAVE, + CON_SAVEGAMEVAR, + CON_SAVEMAPSTATE, + CON_SAVENN, + CON_SCALEVAR, + CON_SCREENPAL, + CON_SCREENSOUND, + CON_SCREENTEXT, + CON_SECTCLEARINTERPOLATION, + CON_SECTGETHITAG, + CON_SECTGETLOTAG, + CON_SECTOROFWALL, + CON_SECTSETINTERPOLATION, + CON_SETACTOR, + CON_SETACTORANGLE, + CON_SETACTORSOUNDPITCH, + CON_SETACTORSTRUCT, + CON_SETACTORVAR, + CON_SETARRAY, + CON_SETASPECT, + CON_SETGAMEPALETTE, + CON_SETINPUT, + CON_SETMUSICPOSITION, + CON_SETPLAYER, + CON_SETPLAYERANGLE, + CON_SETPLAYERVAR, + CON_SETPROJECTILE, + CON_SETSECTOR, + CON_SETSPRITE, + CON_SETSPRITEEXT, + CON_SETSPRITESTRUCT, + CON_SETTHISPROJECTILE, + CON_SETTILEDATA, + CON_SETTSPR, + CON_SETUSERDEF, + CON_SETVAR, + CON_SETVARVAR, + CON_SETWALL, + CON_SHADETO, + CON_SHIFTVARL, + CON_SHIFTVARR, + CON_SHIFTVARVARL, + CON_SHIFTVARVARR, + CON_SHOOT, + CON_SHOWVIEW, + CON_SHOWVIEWQ16, + CON_SHOWVIEWQ16UNBIASED, + CON_SHOWVIEWUNBIASED, + CON_SIN, + CON_SIZEAT, + CON_SIZETO, + CON_SLEEPTIME, + CON_SMAXAMMO, + CON_SOUNDONCE, + CON_SOUND, + CON_SPAWN, + CON_SPAWNCEILINGGLASS, + CON_SPAWNWALLGLASS, + CON_SPAWNWALLSTAINEDGLASS, + CON_SPGETHITAG, + CON_SPGETLOTAG, + CON_SPRITEFLAGS, + CON_SPRITEPAL, + CON_SQRT, + CON_SSP, + CON_STARTCUTSCENE, + CON_STARTLEVEL, + CON_STARTSCREEN, + CON_STARTTRACKSLOT, + CON_STARTTRACK, + CON_STATE, + CON_STOPACTORSOUND, + CON_STOPALLMUSIC, + CON_STOPALLSOUNDS, + CON_STOPSOUND, + CON_STRENGTH, + CON_SUBVAR, + CON_SUBVARVAR, + CON_SWAPARRAYS, + CON_SWAPTRACKSLOT, + CON_SWITCH, + CON_TIME, + CON_TIP, + CON_TOSSWEAPON, + CON_UPDATESECTOR, + CON_UPDATESECTORZ, + CON_USERQUOTE, + CON_WACKPLAYER, + CON_WHILEVARL, + CON_WHILEVARN, + CON_WHILEVARVARL, + CON_WHILEVARVARN, + CON_WRITEARRAYTOFILE, + CON_XORVAR, + CON_XORVARVAR, + CON_ZSHOOT, + + CON_OPCODE_END, + + // these are the keywords that don't get written into the bytecode + CON_ACTOR, + CON_APPENDEVENT, + CON_BETANAME, + CON_CASE, + CON_CHEATKEYS, + CON_DAMAGEEVENTTILE, + CON_DAMAGEEVENTTILERANGE, + CON_DEFAULT, + CON_DEFINE, + CON_DEFINECHEAT, + CON_DEFINEGAMEFUNCNAME, + CON_DEFINEGAMETYPE, + CON_DEFINELEVELNAME, + CON_DEFINEPROJECTILE, + CON_DEFINEQUOTE, + CON_DEFINESKILLNAME, + CON_DEFINESOUND, + CON_DEFINEVOLUMEFLAGS, + CON_DEFINEVOLUMENAME, + CON_DEFSTATE, + CON_DYNAMICREMAP, + CON_DYNAMICSOUNDREMAP, + CON_ENHANCED, + CON_GAMEARRAY, + CON_GAMESTARTUP, + CON_GAMEVAR, + CON_INCLUDE, + CON_INCLUDEDEFAULT, + CON_ONEVENT, + CON_SCRIPTSIZE, + CON_SETCFGNAME, + CON_SETDEFNAME, + CON_SETGAMENAME, + CON_SPRITENOPAL, + CON_SPRITENOSHADE, + CON_SPRITENVG, + CON_SPRITESHADOW, + CON_UNDEFINECHEAT, + CON_UNDEFINEGAMEFUNC, + CON_UNDEFINELEVEL, + CON_UNDEFINESKILL, + CON_UNDEFINEVOLUME, + CON_USERACTOR, + CON_END }; + // KEEPINSYNC with the keyword list in lunatic/con_lang.lua #endif diff --git a/source/duke3d/src/gameexec.cpp b/source/duke3d/src/gameexec.cpp index 35fed26ea..61b32a44f 100644 --- a/source/duke3d/src/gameexec.cpp +++ b/source/duke3d/src/gameexec.cpp @@ -74,6 +74,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop); # include "gamestructures.cpp" #endif +// be careful when changing this--the assignment used as a condition doubles as a null pointer check #define VM_CONDITIONAL(xxx) \ { \ if ((xxx) || ((insptr = (intptr_t *)insptr[1]) && ((*insptr & VM_INSTMASK) == CON_ELSE))) \ @@ -86,29 +87,26 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop); #if !defined LUNATIC void VM_ScriptInfo(intptr_t const *ptr, int range) { - if (!apScript || (!vm.pSprite && !vm.pPlayer && g_currentEvent == -1)) + if (!apScript || !ptr || g_currentEvent == -1) return; - if (ptr) + initprintf("\n"); + + for (auto pScript = max(ptr - (range >> 1), apScript), + p_end = min(ptr + (range >> 1), apScript + g_scriptSize); + pScript < p_end; + ++pScript) { - initprintf("\n"); + initprintf("%5d: %3d: ", (int32_t)(pScript - apScript), (int32_t)(pScript - ptr)); - for (auto pScript = max(ptr - (range >> 1), apScript), - p_end = min(ptr + (range >> 1), apScript + g_scriptSize); - pScript < p_end; - ++pScript) - { - initprintf("%5d: %3d: ", (int32_t)(pScript - apScript), (int32_t)(pScript - ptr)); - - if (*pScript >> 12 && (*pScript & VM_INSTMASK) < CON_END) - initprintf("%5d %s\n", (int32_t)(*pScript >> 12), VM_GetKeywordForID(*pScript & VM_INSTMASK)); - else - initprintf("%d\n", (int32_t)*pScript); - } - - initprintf("\n"); + if (*pScript >> 12 && (*pScript & VM_INSTMASK) < CON_OPCODE_END) + initprintf("%5d %s\n", (int32_t)(*pScript >> 12), VM_GetKeywordForID(*pScript & VM_INSTMASK)); + else + initprintf("%d\n", (int32_t)*pScript); } + initprintf("\n"); + if (ptr == insptr) { if (vm.pUSprite) @@ -155,43 +153,39 @@ static FORCE_INLINE int32_t VM_EventCommon__(int const &eventNum, int const &spr static void VM_DummySprite(void) { static uspritetype dummy_sprite; - static actor_t dummy; + static actor_t dummy_actor; vm.pUSprite = &dummy_sprite; - vm.pActor = &dummy; - vm.pData = &dummy.t_data[0]; + vm.pActor = &dummy_actor; + vm.pData = &dummy_actor.t_data[0]; } static FORCE_INLINE int32_t VM_EventCommon__(int const &eventNum, int const &spriteNum, int const &playerNum, int const &playerDist, int32_t returnValue) { - double const t = timerGetHiTicks(); - vmstate_t const tempvm = { spriteNum, playerNum, playerDist, 0, NULL, NULL, g_player[playerNum].ps, NULL }; + vmstate_t const tempvm = { spriteNum, playerNum, playerDist, 0, &sprite[spriteNum], &actor[spriteNum].t_data[0], g_player[playerNum].ps, &actor[spriteNum] }; - auto & returnVar = aGameVars[g_returnVarID].global; - int const backupReturnVar = returnVar; - int const backupEvent = g_currentEvent; - - returnVar = returnValue; - g_currentEvent = eventNum; - - auto const backupinsptr = insptr; - const vmstate_t vm_backup = vm; - - insptr = apScript + apScriptEvents[eventNum]; - vm = tempvm; - - // check tempvm instead of vm... this way, we are not actually loading - // FROM vm anywhere until VM_Execute() is called - if (EDUKE32_PREDICT_FALSE((unsigned) tempvm.spriteNum >= MAXSPRITES)) - VM_DummySprite(); - else + typedef struct { - vm.pSprite = &sprite[spriteNum]; - vm.pActor = &actor[spriteNum]; - vm.pData = &actor[spriteNum].t_data[0]; - } + vmstate_t vm; + intptr_t returnVar; + int currentEvent; + intptr_t const *insptr; + } eventbackup_t; - if ((unsigned)playerNum >= (unsigned)g_mostConcurrentPlayers) + auto &returnVar = aGameVars[g_returnVarID].global; + eventbackup_t const backup = { vm, returnVar, eventNum, insptr }; + g_currentEvent = eventNum; + + double const t = timerGetHiTicks(); + + vm = tempvm; + returnVar = returnValue; + insptr = apScript + apScriptEvents[eventNum]; + + if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES)) + VM_DummySprite(); + + if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)g_mostConcurrentPlayers)) vm.pPlayer = g_player[0].ps; VM_Execute(1); @@ -202,11 +196,12 @@ static FORCE_INLINE int32_t VM_EventCommon__(int const &eventNum, int const &spr // this needs to happen after VM_DeleteSprite() because VM_DeleteSprite() // can trigger additional events - vm = vm_backup; - insptr = backupinsptr; - g_currentEvent = backupEvent; returnValue = returnVar; - returnVar = backupReturnVar; + + vm = backup.vm; + returnVar = backup.returnVar; + g_currentEvent = backup.currentEvent; + insptr = backup.insptr; g_eventTotalMs[eventNum] += timerGetHiTicks()-t; g_eventCalls[eventNum]++; @@ -1271,23 +1266,24 @@ void Screen_Play(void) #if !defined LUNATIC GAMEEXEC_STATIC void VM_Execute(native_t loop) { - native_t tw = *insptr; - DukePlayer_t *const pPlayer = vm.pPlayer; + native_t tw; + auto const pPlayer = vm.pPlayer; - // jump directly into the loop, skipping branches during the first iteration - goto next_instruction; - - while (loop && (vm.flags & (VM_RETURN|VM_KILL|VM_NOEXECUTE)) == 0) + do { - tw = *insptr; - next_instruction: + tw = *insptr; g_errorLineNum = tw >> 12; g_tw = tw &= VM_INSTMASK; - if (tw == CON_LEFTBRACE) + if (tw == CON_ELSE) { - tw = *(++insptr), loop++; + insptr = (intptr_t *)insptr[1]; + goto next_instruction; + } + else if (tw == CON_LEFTBRACE) + { + insptr++, loop++; goto next_instruction; } else if (tw == CON_RIGHTBRACE) @@ -1295,22 +1291,17 @@ next_instruction: insptr++, loop--; continue; } - else if (tw == CON_ELSE) - { - insptr = (intptr_t *)insptr[1]; - tw = *insptr; - goto next_instruction; - } - else if (tw == CON_STATE) - { - auto tempscrptr = &insptr[2]; - insptr = (intptr_t *)insptr[1]; - VM_Execute(1); - insptr = tempscrptr; - continue; - } else switch (tw) { + case CON_STATE: + { + auto tempscrptr = &insptr[2]; + insptr = (intptr_t *)insptr[1]; + VM_Execute(1); + insptr = tempscrptr; + } + continue; + case CON_SETVAR: insptr++; if ((aGameVars[*insptr].flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) == 0) @@ -2687,18 +2678,6 @@ badindex: vm.pSprite->yrepeat = (uint8_t)*insptr++; continue; - case CON_SOUNDONCE: - if (EDUKE32_PREDICT_FALSE((unsigned)*(++insptr) >= MAXSOUNDS)) - { - CON_ERRPRINTF("invalid sound %d\n", (int32_t)*insptr++); - continue; - } - - if (!S_CheckSoundPlaying(vm.spriteNum, *insptr++)) - A_PlaySound(insptr[-1], vm.spriteNum); - - continue; - case CON_IFACTORSOUND: insptr++; { @@ -2726,17 +2705,6 @@ badindex: // VM_DoConditional(SoundOwner[*insptr][0].ow == vm.spriteNum); continue; - case CON_STOPSOUND: - if (EDUKE32_PREDICT_FALSE((unsigned)*(++insptr) >= MAXSOUNDS)) - { - CON_ERRPRINTF("invalid sound %d\n", (int32_t)*insptr); - continue; - } - if (S_CheckSoundPlaying(vm.spriteNum, *insptr)) - S_StopSound((int16_t)*insptr); - insptr++; - continue; - case CON_STOPACTORSOUND: insptr++; { @@ -2790,30 +2758,6 @@ badindex: continue; } - case CON_GLOBALSOUND: - if (EDUKE32_PREDICT_FALSE((unsigned)*(++insptr) >= MAXSOUNDS)) - { - CON_ERRPRINTF("invalid sound %d\n", (int32_t)*insptr); - continue; - } - if (vm.playerNum == screenpeek || (g_gametypeFlags[ud.coop] & GAMETYPE_COOPSOUND) -#ifdef SPLITSCREEN_MOD_HACKS - || (g_fakeMultiMode == 2) -#endif - ) - A_PlaySound(*insptr, g_player[screenpeek].ps->i); - insptr++; - continue; - - case CON_SOUND: - if (EDUKE32_PREDICT_FALSE((unsigned)*(++insptr) >= MAXSOUNDS)) - { - CON_ERRPRINTF("invalid sound %d\n", (int32_t)*insptr); - continue; - } - A_PlaySound(*insptr++, vm.spriteNum); - continue; - case CON_TIP: insptr++; pPlayer->tipincs = GAMETICSPERSEC; @@ -2919,14 +2863,6 @@ badindex: vm.flags |= VM_KILL; return; - case CON_ADDWEAPON: - insptr++; - { - int const weaponNum = *insptr++; - VM_AddWeapon(pPlayer, weaponNum, *insptr++); - continue; - } - case CON_DEBUG: insptr++; buildprint(*insptr++, "\n"); @@ -3006,7 +2942,7 @@ badindex: vm.pSprite->ang = krand() & 2047; continue; - case CON_ADDWEAPONVAR: + case CON_ADDWEAPON: insptr++; { int const weaponNum = Gv_GetVarX(*insptr++); @@ -3694,9 +3630,9 @@ badindex: case CON_TIME: insptr += 2; continue; - case CON_ESPAWNVAR: - case CON_EQSPAWNVAR: - case CON_QSPAWNVAR: + case CON_ESPAWN: + case CON_EQSPAWN: + case CON_QSPAWN: insptr++; { int const tileNum = Gv_GetVarX(*insptr++); @@ -3711,12 +3647,12 @@ badindex: switch (tw) { - case CON_EQSPAWNVAR: + case CON_EQSPAWN: if (spriteNum != -1) A_AddToDeleteQueue(spriteNum); fallthrough__; - case CON_ESPAWNVAR: aGameVars[g_returnVarID].global = spriteNum; break; - case CON_QSPAWNVAR: + case CON_ESPAWN: aGameVars[g_returnVarID].global = spriteNum; break; + case CON_QSPAWN: if (spriteNum != -1) A_AddToDeleteQueue(spriteNum); break; @@ -3724,8 +3660,8 @@ badindex: continue; } - case CON_SHOOTVAR: - case CON_ESHOOTVAR: + case CON_SHOOT: + case CON_ESHOOT: insptr++; { int j = Gv_GetVarX(*insptr++); @@ -3738,14 +3674,14 @@ badindex: j = A_Shoot(vm.spriteNum, j); - if (tw == CON_ESHOOTVAR) + if (tw == CON_ESHOOT) aGameVars[g_returnVarID].global = j; continue; } - case CON_EZSHOOTVAR: - case CON_ZSHOOTVAR: + case CON_EZSHOOT: + case CON_ZSHOOT: insptr++; { int const zvel = (int16_t)Gv_GetVarX(*insptr++); @@ -3759,7 +3695,7 @@ badindex: j = A_ShootWithZvel(vm.spriteNum, j, zvel); - if (tw == CON_EZSHOOTVAR) + if (tw == CON_EZSHOOT) aGameVars[g_returnVarID].global = j; continue; @@ -3770,10 +3706,10 @@ badindex: Menu_Change(Gv_GetVarX(*insptr++)); continue; - case CON_SOUNDVAR: - case CON_STOPSOUNDVAR: - case CON_SOUNDONCEVAR: - case CON_GLOBALSOUNDVAR: + case CON_SOUND: + case CON_STOPSOUND: + case CON_SOUNDONCE: + case CON_GLOBALSOUND: case CON_SCREENSOUND: insptr++; { @@ -3787,15 +3723,15 @@ badindex: switch (tw) { - case CON_SOUNDONCEVAR: + case CON_SOUNDONCE: if (!S_CheckSoundPlaying(vm.spriteNum, soundNum)) { fallthrough__; - case CON_SOUNDVAR: A_PlaySound((int16_t)soundNum, vm.spriteNum); + case CON_SOUND: A_PlaySound((int16_t)soundNum, vm.spriteNum); } continue; - case CON_GLOBALSOUNDVAR: A_PlaySound((int16_t)soundNum, g_player[screenpeek].ps->i); continue; - case CON_STOPSOUNDVAR: + case CON_GLOBALSOUND: A_PlaySound((int16_t)soundNum, g_player[screenpeek].ps->i); continue; + case CON_STOPSOUND: if (S_CheckSoundPlaying(vm.spriteNum, soundNum)) S_StopSound((int16_t)soundNum); continue; @@ -4059,11 +3995,6 @@ badindex: continue; } - case CON_ANGOFF: - insptr++; - spriteext[vm.spriteNum].angoff = *insptr++; - continue; - case CON_GETZRANGE: insptr++; { @@ -4563,7 +4494,7 @@ badindex: insptr++; continue; - case CON_HITRADIUSVAR: + case CON_HITRADIUS: insptr++; { int32_t params[5]; @@ -4572,11 +4503,6 @@ badindex: } continue; - case CON_HITRADIUS: - A_RadiusDamage(vm.spriteNum, insptr[1], insptr[2], insptr[3], insptr[4], insptr[5]); - insptr += 6; - continue; - case CON_IFP: { int const moveFlags = *(++insptr); @@ -4701,7 +4627,7 @@ badindex: insptr++; if (vm.pSprite->picnum != APLAYER) vm.pActor->tempang = vm.pSprite->pal; - vm.pSprite->pal = *insptr++; + vm.pSprite->pal = *insptr++; continue; case CON_CACTOR: @@ -4830,14 +4756,6 @@ badindex: continue; } - case CON_ADDLOG: - { - insptr++; - - initprintf(OSDTEXT_GREEN "CONLOG: L=%d\n", g_errorLineNum); - continue; - } - case CON_ADDLOGVAR: insptr++; { @@ -4943,10 +4861,10 @@ badindex: continue; } - case CON_FINDNEARACTORVAR: - case CON_FINDNEARSPRITEVAR: - case CON_FINDNEARACTOR3DVAR: - case CON_FINDNEARSPRITE3DVAR: + case CON_FINDNEARACTOR: + case CON_FINDNEARSPRITE: + case CON_FINDNEARACTOR3D: + case CON_FINDNEARSPRITE3D: insptr++; { // syntax findnearactorvar @@ -4962,10 +4880,10 @@ badindex: int findStatnum = STAT_ACTOR; int spriteNum; - if (tw == CON_FINDNEARSPRITEVAR || tw == CON_FINDNEARSPRITE3DVAR) + if (tw == CON_FINDNEARSPRITE || tw == CON_FINDNEARSPRITE3D) findStatnum = MAXSTATUS - 1; - if (tw == CON_FINDNEARACTOR3DVAR || tw == CON_FINDNEARSPRITE3DVAR) + if (tw == CON_FINDNEARACTOR3D || tw == CON_FINDNEARSPRITE3D) { do { @@ -4982,7 +4900,7 @@ badindex: } spriteNum = nextspritestat[spriteNum]; } - if (spriteNum == MAXSPRITES || tw == CON_FINDNEARACTOR3DVAR) + if (spriteNum == MAXSPRITES || tw == CON_FINDNEARACTOR3D) break; } while (findStatnum--); Gv_SetVarX(returnVar, foundSprite); @@ -5005,15 +4923,15 @@ badindex: spriteNum = nextspritestat[spriteNum]; } - if (spriteNum == MAXSPRITES || tw == CON_FINDNEARACTORVAR) + if (spriteNum == MAXSPRITES || tw == CON_FINDNEARACTOR) break; } while (findStatnum--); Gv_SetVarX(returnVar, foundSprite); continue; } - case CON_FINDNEARACTORZVAR: - case CON_FINDNEARSPRITEZVAR: + case CON_FINDNEARACTORZ: + case CON_FINDNEARSPRITEZ: insptr++; { // syntax findnearactorvar @@ -5031,7 +4949,7 @@ badindex: do { - int spriteNum = headspritestat[tw == CON_FINDNEARACTORZVAR ? STAT_ACTOR : findStatnum]; // all sprites + int spriteNum = headspritestat[tw == CON_FINDNEARACTORZ ? STAT_ACTOR : findStatnum]; // all sprites if (spriteNum == -1) continue; @@ -5052,7 +4970,7 @@ badindex: spriteNum = nextspritestat[spriteNum]; } while (spriteNum >= 0); - if (tw == CON_FINDNEARACTORZVAR || spriteNum == MAXSPRITES) + if (tw == CON_FINDNEARACTORZ || spriteNum == MAXSPRITES) break; } while (findStatnum--); Gv_SetVarX(returnVar, foundSprite); @@ -5163,7 +5081,7 @@ badindex: Gv_SetVarX(*insptr++, getangle(vm.pActor->lastv.x - vm.pSprite->x, vm.pActor->lastv.y - vm.pSprite->y)); continue; - case CON_ANGOFFVAR: + case CON_ANGOFF: insptr++; spriteext[vm.spriteNum].angoff = Gv_GetVarX(*insptr++); continue; @@ -5725,11 +5643,6 @@ badindex: continue; case CON_STARTTRACK: - insptr++; - G_StartTrackSlotWrap(ud.volume_number, *(insptr++)); - continue; - - case CON_STARTTRACKVAR: insptr++; G_StartTrackSlotWrap(ud.volume_number, Gv_GetVarX(*(insptr++))); continue; @@ -5994,7 +5907,7 @@ badindex: "Thank you!"); break; } - } + } while (loop && (vm.flags & (VM_RETURN|VM_KILL|VM_NOEXECUTE)) == 0); } // NORECURSE @@ -6065,7 +5978,8 @@ void VM_UpdateAnim(int spriteNum, int32_t *pData) // NORECURSE void A_Execute(int spriteNum, int playerNum, int playerDist) { - vmstate_t tempvm + // for some reason this is faster than using the C++ syntax; e.g vm = vmstate_t{ ... } + vmstate_t const tempvm = { spriteNum, playerNum, playerDist, 0, &sprite[spriteNum], &actor[spriteNum].t_data[0], g_player[playerNum].ps, &actor[spriteNum] }; vm = tempvm; @@ -6095,34 +6009,24 @@ void A_Execute(int spriteNum, int playerNum, int playerDist) VM_UpdateAnim(vm.spriteNum, vm.pData); + double t = timerGetHiTicks(); #ifdef LUNATIC int const picnum = vm.pSprite->picnum; if (L_IsInitialized(&g_ElState) && El_HaveActor(picnum)) - { - double t = timerGetHiTicks(); - killit = (El_CallActor(&g_ElState, picnum, spriteNum, playerNum, playerDist)==1); - - t = timerGetHiTicks()-t; - g_actorTotalMs[picnum] += t; - g_actorMinMs[picnum] = min(g_actorMinMs[picnum], t); - g_actorMaxMs[picnum] = max(g_actorMaxMs[picnum], t); - g_actorCalls[picnum]++; - } #else - double t = timerGetHiTicks(); int const picnum = vm.pSprite->picnum; insptr = 4 + (g_tile[vm.pSprite->picnum].execPtr); VM_Execute(1); insptr = NULL; +#endif t = timerGetHiTicks()-t; g_actorTotalMs[picnum] += t; g_actorMinMs[picnum] = min(g_actorMinMs[picnum], t); g_actorMaxMs[picnum] = max(g_actorMaxMs[picnum], t); g_actorCalls[picnum]++; -#endif #ifdef LUNATIC if (killit)