mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
More of them. Includes the possiblity of typing m32script commands directly into the OSD (without "do", see osdtryscript in mapster32.cfg) and improved diagnostics.
git-svn-id: https://svn.eduke32.com/eduke32@1649 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
30877e925a
commit
02379ee1d2
11 changed files with 454 additions and 402 deletions
|
@ -169,11 +169,6 @@ extern uint32_t m32_drawlinepat;
|
||||||
|
|
||||||
extern int32_t g_iReturnVar;
|
extern int32_t g_iReturnVar;
|
||||||
extern int32_t m32_sortvar1, m32_sortvar2;
|
extern int32_t m32_sortvar1, m32_sortvar2;
|
||||||
extern int32_t g_iReturnVarID;
|
|
||||||
extern int32_t g_iLoTagID; // var ID of "LOTAG"
|
|
||||||
extern int32_t g_iHiTagID; // var ID of "HITAG"
|
|
||||||
extern int32_t g_iTextureID; // var ID of "TEXTURE"
|
|
||||||
extern int32_t g_iThisActorID; // var ID of "I" ///"THISACTOR"
|
|
||||||
|
|
||||||
//extern int32_t g_numRealPalettes;
|
//extern int32_t g_numRealPalettes;
|
||||||
//extern int32_t g_scriptDebug;
|
//extern int32_t g_scriptDebug;
|
||||||
|
@ -182,7 +177,7 @@ extern int32_t g_numQuoteRedefinitions;
|
||||||
|
|
||||||
extern hashtable_t h_gamevars;
|
extern hashtable_t h_gamevars;
|
||||||
extern hashtable_t h_arrays;
|
extern hashtable_t h_arrays;
|
||||||
extern hashtable_t h_keywords;
|
//extern hashtable_t h_keywords;
|
||||||
extern hashtable_t h_gamefuncs;
|
extern hashtable_t h_gamefuncs;
|
||||||
|
|
||||||
|
|
||||||
|
@ -232,4 +227,23 @@ extern int32_t numsprites;
|
||||||
extern int32_t zoom;
|
extern int32_t zoom;
|
||||||
extern int32_t halfxdim16, midydim16;
|
extern int32_t halfxdim16, midydim16;
|
||||||
|
|
||||||
|
|
||||||
|
#define M32_FLAG_NEGATE (MAXGAMEVARS<<1)
|
||||||
|
#define M32_FLAG_ARRAY (MAXGAMEVARS<<2)
|
||||||
|
#define M32_FLAG_SPECIAL (MAXGAMEVARS<<3)
|
||||||
|
|
||||||
|
// IDs of special vars
|
||||||
|
#define M32_SPRITE_VAR_ID 0
|
||||||
|
#define M32_SECTOR_VAR_ID 1
|
||||||
|
#define M32_WALL_VAR_ID 2
|
||||||
|
#define M32_TSPRITE_VAR_ID 3
|
||||||
|
|
||||||
|
#define M32_THISACTOR_VAR_ID 4
|
||||||
|
#define M32_RETURN_VAR_ID 5
|
||||||
|
#define M32_LOTAG_VAR_ID 6
|
||||||
|
#define M32_HITAG_VAR_ID 7
|
||||||
|
#define M32_TEXTURE_VAR_ID 8
|
||||||
|
|
||||||
|
#define M32_PRINTERROR(Text, ...) OSD_Printf(OSD_ERROR "Line %d, %s: " Text "\n", g_errorLineNum, keyw[g_tw], ## __VA_ARGS__)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -244,9 +244,10 @@ int32_t loadsetup(const char *fn)
|
||||||
graphicsmode = min(max(Batoi(val),0),2);
|
graphicsmode = min(max(Batoi(val),0),2);
|
||||||
|
|
||||||
if (readconfig(fp, "ambiencetoggle", val, VL) > 0) AmbienceToggle = Batoi(val);
|
if (readconfig(fp, "ambiencetoggle", val, VL) > 0) AmbienceToggle = Batoi(val);
|
||||||
|
|
||||||
if (readconfig(fp, "parlock", val, VL) > 0) ParentalLock = Batoi(val);
|
if (readconfig(fp, "parlock", val, VL) > 0) ParentalLock = Batoi(val);
|
||||||
|
|
||||||
|
if (readconfig(fp, "osdtryscript", val, VL) > 0) m32_osd_tryscript = Batoi(val);
|
||||||
|
|
||||||
for (i=0; i<256; i++)
|
for (i=0; i<256; i++)
|
||||||
remap[i]=i;
|
remap[i]=i;
|
||||||
|
|
||||||
|
@ -399,7 +400,12 @@ int32_t writesetup(const char *fn)
|
||||||
"graphicsmode = %d\n\n"
|
"graphicsmode = %d\n\n"
|
||||||
"; Ambient sounds in 3D mode (0:off, 1:on)\n"
|
"; Ambient sounds in 3D mode (0:off, 1:on)\n"
|
||||||
"ambiencetoggle = %d\n"
|
"ambiencetoggle = %d\n"
|
||||||
"parlock = %d\n\n"
|
"parlock = %d\n"
|
||||||
|
"\n"
|
||||||
|
"; Try executing m32script on invalid command in the OSD? This makes\n"
|
||||||
|
"; typing m32script commands into the OSD directly possible.\n"
|
||||||
|
"osdtryscript = %d\n"
|
||||||
|
"\n"
|
||||||
#if 1
|
#if 1
|
||||||
"; Key Settings\n"
|
"; Key Settings\n"
|
||||||
"; Here's a map of all the keyboard scan codes: NOTE: values are listed in hex!\n"
|
"; Here's a map of all the keyboard scan codes: NOTE: values are listed in hex!\n"
|
||||||
|
@ -470,6 +476,7 @@ int32_t writesetup(const char *fn)
|
||||||
option[3], msens, unrealedlook, pk_uedaccel, quickmapcycling,
|
option[3], msens, unrealedlook, pk_uedaccel, quickmapcycling,
|
||||||
revertCTRL,scrollamount,pk_turnaccel,pk_turndecel,autosave,
|
revertCTRL,scrollamount,pk_turnaccel,pk_turndecel,autosave,
|
||||||
showheightindicators,graphicsmode,AmbienceToggle,ParentalLock,
|
showheightindicators,graphicsmode,AmbienceToggle,ParentalLock,
|
||||||
|
!!m32_osd_tryscript,
|
||||||
#if 1
|
#if 1
|
||||||
keys[0], keys[1], keys[2], keys[3], keys[4], keys[5],
|
keys[0], keys[1], keys[2], keys[3], keys[4], keys[5],
|
||||||
keys[6], keys[7], keys[8], keys[9], keys[10], keys[11],
|
keys[6], keys[7], keys[8], keys[9], keys[10], keys[11],
|
||||||
|
|
|
@ -124,6 +124,9 @@ static cvar_t *cvars = NULL;
|
||||||
static uint32_t osdnumcvars = 0;
|
static uint32_t osdnumcvars = 0;
|
||||||
static hashtable_t h_cvars = { MAXSYMBOLS<<1, NULL };
|
static hashtable_t h_cvars = { MAXSYMBOLS<<1, NULL };
|
||||||
|
|
||||||
|
int32_t m32_osd_tryscript=0; // whether to try executing m32script on unkown command in the osd
|
||||||
|
extern void M32RunScript(const char *s);
|
||||||
|
|
||||||
int32_t OSD_RegisterCvar(const cvar_t *cvar)
|
int32_t OSD_RegisterCvar(const cvar_t *cvar)
|
||||||
{
|
{
|
||||||
const char *cp;
|
const char *cp;
|
||||||
|
@ -1653,8 +1656,14 @@ int32_t OSD_Dispatch(const char *cmd)
|
||||||
|
|
||||||
if ((symb = findexactsymbol(wp)) == NULL)
|
if ((symb = findexactsymbol(wp)) == NULL)
|
||||||
{
|
{
|
||||||
if (wp[0] != '/' || wp[1] != '/') // cheap hack for comments in cfgs
|
if ((wp[0] != '/' || wp[1] != '/') && !m32_osd_tryscript) // cheap hack for comments in cfgs
|
||||||
|
{
|
||||||
OSD_Printf(OSDTEXT_RED "\"%s\" is not a valid command or cvar\n", wp);
|
OSD_Printf(OSDTEXT_RED "\"%s\" is not a valid command or cvar\n", wp);
|
||||||
|
}
|
||||||
|
else if (m32_osd_tryscript)
|
||||||
|
{
|
||||||
|
M32RunScript(cmd);
|
||||||
|
}
|
||||||
Bfree(workbuf);
|
Bfree(workbuf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -4616,7 +4616,7 @@ static void Keys3d(void)
|
||||||
{
|
{
|
||||||
if (ASSERT_AIMING)
|
if (ASSERT_AIMING)
|
||||||
{
|
{
|
||||||
AIMED_CF_SEL(shade) += tsign;
|
AIMED_CF_SEL(shade) += tsign*(1+3*eitherCTRL);
|
||||||
message("%s %d shade %d", Typestr[searchstat], i, AIMED_CF_SEL(shade));
|
message("%s %d shade %d", Typestr[searchstat], i, AIMED_CF_SEL(shade));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7310,6 +7310,7 @@ static int32_t osdcmd_noclip(const osdfuncparm_t *parm)
|
||||||
{
|
{
|
||||||
UNREFERENCED_PARAMETER(parm);
|
UNREFERENCED_PARAMETER(parm);
|
||||||
noclip = !noclip;
|
noclip = !noclip;
|
||||||
|
OSD_Printf("Clipping %s\n", noclip?"disabled":"enabled");
|
||||||
|
|
||||||
return OSDCMD_OK;
|
return OSDCMD_OK;
|
||||||
}
|
}
|
||||||
|
@ -7410,6 +7411,11 @@ static int32_t osdcmd_vars_pk(const osdfuncparm_t *parm)
|
||||||
pk_uedaccel = pk_uedaccel>5 ? 5:pk_uedaccel;
|
pk_uedaccel = pk_uedaccel>5 ? 5:pk_uedaccel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (!Bstrcasecmp(parm->name, "osd_tryscript"))
|
||||||
|
{
|
||||||
|
m32_osd_tryscript = !m32_osd_tryscript;
|
||||||
|
OSD_Printf("Try M32 script execution on invalid OSD command: %s\n", m32_osd_tryscript?"on":"off");
|
||||||
|
}
|
||||||
return OSDCMD_OK;
|
return OSDCMD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7498,30 +7504,30 @@ static int32_t osdcmd_do(const osdfuncparm_t *parm)
|
||||||
{
|
{
|
||||||
intptr_t tscrofs;
|
intptr_t tscrofs;
|
||||||
char *tp;
|
char *tp;
|
||||||
int32_t i, j, slen;
|
int32_t i, j, slen, ofs;
|
||||||
int32_t onumconstants=g_numSavedConstants;
|
int32_t onumconstants=g_numSavedConstants;
|
||||||
|
|
||||||
if (parm->numparms < 1)
|
if (parm->numparms==0)
|
||||||
return OSDCMD_SHOWHELP;
|
return OSDCMD_SHOWHELP;
|
||||||
|
|
||||||
tscrofs = (g_scriptPtr-script);
|
tscrofs = (g_scriptPtr-script);
|
||||||
|
|
||||||
slen = Bstrlen(parm->raw+2);
|
ofs = 2*(parm->numparms>0); // true if "do" command
|
||||||
|
slen = Bstrlen(parm->raw+ofs);
|
||||||
tp = Bmalloc(slen+2);
|
tp = Bmalloc(slen+2);
|
||||||
if (!tp)
|
if (!tp) goto OUTOFMEM;
|
||||||
{
|
Bmemcpy(tp, parm->raw+ofs, slen);
|
||||||
initprintf("OUT OF MEMORY!\n");
|
|
||||||
return OSDCMD_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bmemcpy(tp, parm->raw+2, slen);
|
// needed so that subsequent commands won't execute old stuff.
|
||||||
tp[slen] = '\n';
|
tp[slen] = '\n';
|
||||||
tp[slen+1] = '\0';
|
tp[slen+1] = '\0';
|
||||||
|
|
||||||
g_didDefineSomething = 0;
|
g_didDefineSomething = 0;
|
||||||
|
|
||||||
C_Compile(tp, 0);
|
C_Compile(tp, 0);
|
||||||
Bfree(tp);
|
|
||||||
|
if (parm->numparms>=0)
|
||||||
|
Bfree(tp);
|
||||||
|
|
||||||
if (g_numCompilerErrors)
|
if (g_numCompilerErrors)
|
||||||
{
|
{
|
||||||
|
@ -7547,12 +7553,24 @@ static int32_t osdcmd_do(const osdfuncparm_t *parm)
|
||||||
}
|
}
|
||||||
|
|
||||||
return OSDCMD_OK;
|
return OSDCMD_OK;
|
||||||
|
OUTOFMEM:
|
||||||
|
OSD_Printf("OUT OF MEMORY!\n");
|
||||||
|
return OSDCMD_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void M32RunScript(const char *s)
|
||||||
|
{
|
||||||
|
osdfuncparm_t parm;
|
||||||
|
|
||||||
|
parm.numparms = -1;
|
||||||
|
parm.raw = s;
|
||||||
|
|
||||||
|
osdcmd_do(&parm);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t osdcmd_endisableevent(const osdfuncparm_t *parm)
|
static int32_t osdcmd_endisableevent(const osdfuncparm_t *parm)
|
||||||
{
|
{
|
||||||
int32_t i, j, enable;
|
int32_t i, j, enable;
|
||||||
char buf[64] = "EVENT_";
|
|
||||||
|
|
||||||
if (!label) return OSDCMD_OK;
|
if (!label) return OSDCMD_OK;
|
||||||
|
|
||||||
|
@ -7569,28 +7587,44 @@ static int32_t osdcmd_endisableevent(const osdfuncparm_t *parm)
|
||||||
|
|
||||||
if (parm->numparms == 1)
|
if (parm->numparms == 1)
|
||||||
{
|
{
|
||||||
if (!Bstrcasecmp(parm->parms[0], "all"))
|
if (!Bstrcasecmp(parm->parms[0], "all") || !Bstrcasecmp(parm->parms[0], "a"))
|
||||||
{
|
{
|
||||||
for (i=0; i<MAXEVENTS; i++)
|
for (i=0; i<MAXEVENTS; i++)
|
||||||
aEventEnabled[i] = enable?1:0;
|
aEventEnabled[i] = enable?1:0;
|
||||||
|
OSD_Printf("Enabled all events.\n");
|
||||||
return OSDCMD_OK;
|
return OSDCMD_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i<parm->numparms; i++)
|
for (i=0; i<parm->numparms; i++)
|
||||||
{
|
{
|
||||||
|
char buf[64] = "EVENT_", buf2[64];
|
||||||
|
|
||||||
if (isdigit(parm->parms[i][0]))
|
if (isdigit(parm->parms[i][0]))
|
||||||
|
{
|
||||||
j = atoi(parm->parms[i]);
|
j = atoi(parm->parms[i]);
|
||||||
|
Bsprintf(buf2, "event %d", j);
|
||||||
|
}
|
||||||
else if (!Bstrncmp(parm->parms[i], "EVENT_", 6))
|
else if (!Bstrncmp(parm->parms[i], "EVENT_", 6))
|
||||||
|
{
|
||||||
j = hash_find(&h_labels, parm->parms[i]);
|
j = hash_find(&h_labels, parm->parms[i]);
|
||||||
|
Bstrncpy(buf2, parm->parms[i], sizeof(buf2));
|
||||||
|
buf2[sizeof(buf2)-1] = '\0';
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Bstrncat(buf, parm->parms[i], sizeof(buf)-6-1);
|
Bstrncat(buf, parm->parms[i], sizeof(buf)-6-1);
|
||||||
j = hash_find(&h_labels, buf);
|
j = hash_find(&h_labels, buf);
|
||||||
|
Bmemcpy(buf2, buf, sizeof(buf2));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j>=0 && j<MAXEVENTS)
|
if (j>=0 && j<MAXEVENTS)
|
||||||
|
{
|
||||||
aEventEnabled[j] = enable?1:0;
|
aEventEnabled[j] = enable?1:0;
|
||||||
|
OSD_Printf("%sabled %s.\n", enable?"En":"Dis", buf2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
OSD_Printf("Invalid event %s.\n", buf2);
|
||||||
}
|
}
|
||||||
return OSDCMD_OK;
|
return OSDCMD_OK;
|
||||||
}
|
}
|
||||||
|
@ -7629,6 +7663,7 @@ static int32_t registerosdcommands(void)
|
||||||
OSD_RegisterFunction("scriptinfo", "scriptinfo: shows information about compiled M32 script", osdcmd_scriptinfo);
|
OSD_RegisterFunction("scriptinfo", "scriptinfo: shows information about compiled M32 script", osdcmd_scriptinfo);
|
||||||
OSD_RegisterFunction("enableevent", "enableevent <all|EVENT_...|(event number)>", osdcmd_endisableevent);
|
OSD_RegisterFunction("enableevent", "enableevent <all|EVENT_...|(event number)>", osdcmd_endisableevent);
|
||||||
OSD_RegisterFunction("disableevent", "disableevent <all|EVENT_...|(event number)>", osdcmd_endisableevent);
|
OSD_RegisterFunction("disableevent", "disableevent <all|EVENT_...|(event number)>", osdcmd_endisableevent);
|
||||||
|
OSD_RegisterFunction("osd_tryscript", "osd_tryscript: Toggles execution of M32 script on invalid OSD command", osdcmd_vars_pk);
|
||||||
// OSD_RegisterFunction("disasm", "disasm [s|e] <state or event number>", osdcmd_disasm);
|
// OSD_RegisterFunction("disasm", "disasm [s|e] <state or event number>", osdcmd_disasm);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,6 +198,8 @@ uint32_t g_frameDelay = 0;
|
||||||
extern char forcegl;
|
extern char forcegl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void M32RunScript(const char *s) {}; // needed for linking since it's referenced from build/src/osd.c
|
||||||
|
|
||||||
int32_t kopen4loadfrommod(char *filename, char searchfirst)
|
int32_t kopen4loadfrommod(char *filename, char searchfirst)
|
||||||
{
|
{
|
||||||
static char fn[BMAX_PATH];
|
static char fn[BMAX_PATH];
|
||||||
|
@ -11776,6 +11778,9 @@ MAIN_LOOP_RESTART:
|
||||||
}
|
}
|
||||||
else G_UpdateScreenArea();
|
else G_UpdateScreenArea();
|
||||||
|
|
||||||
|
// G_GameExit(" "); ///
|
||||||
|
|
||||||
|
// ud.auto_run = ud.config.RunMode;
|
||||||
ud.showweapons = ud.config.ShowOpponentWeapons;
|
ud.showweapons = ud.config.ShowOpponentWeapons;
|
||||||
g_player[myconnectindex].ps->aim_mode = ud.mouseaiming;
|
g_player[myconnectindex].ps->aim_mode = ud.mouseaiming;
|
||||||
g_player[myconnectindex].ps->auto_aim = ud.config.AutoAim;
|
g_player[myconnectindex].ps->auto_aim = ud.config.AutoAim;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -25,19 +25,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#ifndef _m32def_h_
|
#ifndef _m32def_h_
|
||||||
#define _m32def_h_
|
#define _m32def_h_
|
||||||
|
|
||||||
extern int32_t g_iReturnVarID; // var ID of "RETURN"
|
|
||||||
extern int32_t g_iLoTagID; // var ID of "LOTAG"
|
|
||||||
extern int32_t g_iHiTagID; // var ID of "HITAG"
|
|
||||||
extern int32_t g_iTextureID; // var ID of "TEXTURE"
|
|
||||||
|
|
||||||
extern int32_t g_iThisActorID; // var ID of "I" ///"THISACTOR"
|
|
||||||
|
|
||||||
extern int32_t g_iSpriteVarID;
|
|
||||||
extern int32_t g_iSectorVarID;
|
|
||||||
extern int32_t g_iWallVarID;
|
|
||||||
|
|
||||||
#define ABORTERRCNT 8
|
#define ABORTERRCNT 8
|
||||||
#define CON_ERROR OSD_ERROR "Line %d, %s: "
|
|
||||||
|
#define C_CUSTOMERROR(Text, ...) do { \
|
||||||
|
C_ReportError(-1); \
|
||||||
|
initprintf("%s:%d: error: " Text "\n", g_szScriptFileName, g_lineNumber, ## __VA_ARGS__); \
|
||||||
|
g_numCompilerErrors++; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define C_CUSTOMWARNING(Text, ...) do { \
|
||||||
|
C_ReportError(-1); \
|
||||||
|
initprintf("%s:%d: warning: " Text "\n", g_szScriptFileName, g_lineNumber, ## __VA_ARGS__); \
|
||||||
|
g_numCompilerWarnings++; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
extern char g_szScriptFileName[BMAX_PATH];
|
extern char g_szScriptFileName[BMAX_PATH];
|
||||||
extern int32_t g_totalLines,g_lineNumber;
|
extern int32_t g_totalLines,g_lineNumber;
|
||||||
|
@ -111,7 +111,7 @@ enum ScriptError_t
|
||||||
{
|
{
|
||||||
ERROR_CLOSEBRACKET,
|
ERROR_CLOSEBRACKET,
|
||||||
ERROR_EVENTONLY,
|
ERROR_EVENTONLY,
|
||||||
ERROR_EXCEEDSMAXTILES,
|
// ERROR_EXCEEDSMAXTILES,
|
||||||
ERROR_EXPECTEDKEYWORD,
|
ERROR_EXPECTEDKEYWORD,
|
||||||
ERROR_FOUNDWITHIN,
|
ERROR_FOUNDWITHIN,
|
||||||
ERROR_ISAKEYWORD,
|
ERROR_ISAKEYWORD,
|
||||||
|
@ -136,7 +136,7 @@ enum ScriptError_t
|
||||||
WARNING_DUPLICATEDEFINITION,
|
WARNING_DUPLICATEDEFINITION,
|
||||||
WARNING_LABELSONLY,
|
WARNING_LABELSONLY,
|
||||||
WARNING_NAMEMATCHESVAR,
|
WARNING_NAMEMATCHESVAR,
|
||||||
WARNING_CONSTANTBITSIZE,
|
// WARNING_CONSTANTBITSIZE,
|
||||||
WARNING_OUTSIDEDRAWSPRITE,
|
WARNING_OUTSIDEDRAWSPRITE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ void VM_OnEvent(register int32_t iEventID, register int32_t iActor)
|
||||||
{
|
{
|
||||||
if (iEventID < 0 || iEventID >= MAXEVENTS)
|
if (iEventID < 0 || iEventID >= MAXEVENTS)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "invalid event ID",g_errorLineNum,keyw[g_tw]);
|
M32_PRINTERROR("invalid event ID");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ static int32_t X_DoSort(const int32_t *lv, const int32_t *rv)
|
||||||
if ((vm.g_i < 0 || vm.g_i>=MAXSPRITES) && \
|
if ((vm.g_i < 0 || vm.g_i>=MAXSPRITES) && \
|
||||||
(vm.g_st!=0 || searchstat!=3 || (vm.g_i=searchwall, vm.g_sp=&sprite[vm.g_i], 0))) \
|
(vm.g_st!=0 || searchstat!=3 || (vm.g_i=searchwall, vm.g_sp=&sprite[vm.g_i], 0))) \
|
||||||
{ \
|
{ \
|
||||||
OSD_Printf(CON_ERROR "Current sprite index invalid!\n", g_errorLineNum, keyw[g_tw]); \
|
M32_PRINTERROR("Current sprite index invalid!"); \
|
||||||
vm.flags |= VMFLAG_ERROR; \
|
vm.flags |= VMFLAG_ERROR; \
|
||||||
continue; \
|
continue; \
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ static int32_t X_DoSort(const int32_t *lv, const int32_t *rv)
|
||||||
#define X_ERROR_INVALIDSPRI(dasprite) \
|
#define X_ERROR_INVALIDSPRI(dasprite) \
|
||||||
if (dasprite < 0 || dasprite>=MAXSPRITES) \
|
if (dasprite < 0 || dasprite>=MAXSPRITES) \
|
||||||
{ \
|
{ \
|
||||||
OSD_Printf(CON_ERROR "Invalid sprite index %d!\n", g_errorLineNum, keyw[g_tw], dasprite); \
|
M32_PRINTERROR("Invalid sprite index %d!", dasprite); \
|
||||||
vm.flags |= VMFLAG_ERROR; \
|
vm.flags |= VMFLAG_ERROR; \
|
||||||
continue; \
|
continue; \
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ static int32_t X_DoSort(const int32_t *lv, const int32_t *rv)
|
||||||
#define X_ERROR_INVALIDSECT(dasect) \
|
#define X_ERROR_INVALIDSECT(dasect) \
|
||||||
if (dasect < 0 || dasect>=numsectors) \
|
if (dasect < 0 || dasect>=numsectors) \
|
||||||
{ \
|
{ \
|
||||||
OSD_Printf(CON_ERROR "Invalid sector index %d!\n", g_errorLineNum, keyw[g_tw], dasect); \
|
M32_PRINTERROR("Invalid sector index %d!", dasect); \
|
||||||
vm.flags |= VMFLAG_ERROR; \
|
vm.flags |= VMFLAG_ERROR; \
|
||||||
continue; \
|
continue; \
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ static int32_t X_DoSort(const int32_t *lv, const int32_t *rv)
|
||||||
#define X_ERROR_INVALIDSP() \
|
#define X_ERROR_INVALIDSP() \
|
||||||
if (!vm.g_sp && (vm.g_st!=0 || searchstat!=3 || (vm.g_sp=&sprite[searchwall], 0))) \
|
if (!vm.g_sp && (vm.g_st!=0 || searchstat!=3 || (vm.g_sp=&sprite[searchwall], 0))) \
|
||||||
{ \
|
{ \
|
||||||
OSD_Printf(CON_ERROR "Current sprite invalid!\n", g_errorLineNum, keyw[g_tw]); \
|
M32_PRINTERROR("Current sprite invalid!"); \
|
||||||
vm.flags |= VMFLAG_ERROR; \
|
vm.flags |= VMFLAG_ERROR; \
|
||||||
continue; \
|
continue; \
|
||||||
}
|
}
|
||||||
|
@ -270,13 +270,13 @@ static int32_t X_DoSort(const int32_t *lv, const int32_t *rv)
|
||||||
#define X_ERROR_INVALIDQUOTE(q, array) \
|
#define X_ERROR_INVALIDQUOTE(q, array) \
|
||||||
if (q<0 || q>=MAXQUOTES) \
|
if (q<0 || q>=MAXQUOTES) \
|
||||||
{ \
|
{ \
|
||||||
OSD_Printf(CON_ERROR "Invalid quote number %d!\n", g_errorLineNum, keyw[g_tw], q); \
|
M32_PRINTERROR("Invalid quote number %d!", q); \
|
||||||
vm.flags |= VMFLAG_ERROR; \
|
vm.flags |= VMFLAG_ERROR; \
|
||||||
continue; \
|
continue; \
|
||||||
} \
|
} \
|
||||||
else if (array[q] == NULL) \
|
else if (array[q] == NULL) \
|
||||||
{ \
|
{ \
|
||||||
OSD_Printf(CON_ERROR "Null quote %d!\n", g_errorLineNum, keyw[g_tw], q); \
|
M32_PRINTERROR("Null quote %d!", q); \
|
||||||
vm.flags |= VMFLAG_ERROR; \
|
vm.flags |= VMFLAG_ERROR; \
|
||||||
continue; \
|
continue; \
|
||||||
} \
|
} \
|
||||||
|
@ -420,7 +420,7 @@ skip_check:
|
||||||
int32_t j = Gv_GetVarX(*insptr++);
|
int32_t j = Gv_GetVarX(*insptr++);
|
||||||
if (j<0 || j>=(g_scriptPtr-script))
|
if (j<0 || j>=(g_scriptPtr-script))
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "script index out of bounds (%d)\n", g_errorLineNum, keyw[g_tw], j);
|
M32_PRINTERROR("script index out of bounds (%d)", j);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -511,17 +511,17 @@ skip_check:
|
||||||
|
|
||||||
if (j<0 || j >= g_gameArrayCount)
|
if (j<0 || j >= g_gameArrayCount)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Tried to set invalid array ID (%d)\n", g_errorLineNum, keyw[g_tw], j);
|
M32_PRINTERROR("Tried to set invalid array ID (%d)", j);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
}
|
}
|
||||||
if (aGameArrays[j].dwFlags & GAMEARRAY_READONLY)
|
if (aGameArrays[j].dwFlags & GAMEARRAY_READONLY)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Tried to set on read-only array `%s'\n", g_errorLineNum, keyw[g_tw], aGameArrays[j].szLabel);
|
M32_PRINTERROR("Tried to set on read-only array `%s'", aGameArrays[j].szLabel);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
}
|
}
|
||||||
if (index >= aGameArrays[j].size || index < 0)
|
if (index >= aGameArrays[j].size || index < 0)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Array index %d out of bounds\n", g_errorLineNum, keyw[g_tw], index);
|
M32_PRINTERROR("Array index %d out of bounds", index);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
}
|
}
|
||||||
if (vm.flags&VMFLAG_ERROR) continue;
|
if (vm.flags&VMFLAG_ERROR) continue;
|
||||||
|
@ -546,7 +546,7 @@ skip_check:
|
||||||
|
|
||||||
if (asize<=0 || asize>65536)
|
if (asize<=0 || asize>65536)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Invalid array size %d (max: 65536)\n",g_errorLineNum,keyw[g_tw]);
|
M32_PRINTERROR("Invalid array size %d (max: 65536)");
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -556,7 +556,7 @@ skip_check:
|
||||||
if (aGameArrays[j].vals == NULL)
|
if (aGameArrays[j].vals == NULL)
|
||||||
{
|
{
|
||||||
aGameArrays[j].size = 0;
|
aGameArrays[j].size = 0;
|
||||||
OSD_Printf(CON_ERROR "Out of memory!\n",g_errorLineNum,keyw[g_tw]);
|
M32_PRINTERROR("Out of memory!");
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -576,17 +576,17 @@ skip_check:
|
||||||
|
|
||||||
if (si<0 || si>=g_gameArrayCount)
|
if (si<0 || si>=g_gameArrayCount)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Invalid array %d!\n",g_errorLineNum,keyw[g_tw],si);
|
M32_PRINTERROR("Invalid array %d!", si);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
}
|
}
|
||||||
if (di<0 || di>=g_gameArrayCount)
|
if (di<0 || di>=g_gameArrayCount)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Invalid array %d!\n",g_errorLineNum,keyw[g_tw],di);
|
M32_PRINTERROR("Invalid array %d!", di);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
}
|
}
|
||||||
if (aGameArrays[di].dwFlags & GAMEARRAY_READONLY)
|
if (aGameArrays[di].dwFlags & GAMEARRAY_READONLY)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Array %d is read-only!\n",g_errorLineNum,keyw[g_tw],di);
|
M32_PRINTERROR("Array %d is read-only!", di);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
}
|
}
|
||||||
if (vm.flags&VMFLAG_ERROR) continue;
|
if (vm.flags&VMFLAG_ERROR) continue;
|
||||||
|
@ -655,7 +655,7 @@ skip_check:
|
||||||
insptr++;
|
insptr++;
|
||||||
if (*(insptr+1) == 0)
|
if (*(insptr+1) == 0)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Divide by zero.\n",g_errorLineNum,keyw[g_tw]);
|
M32_PRINTERROR("Divide by zero.");
|
||||||
insptr += 2;
|
insptr += 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -667,7 +667,7 @@ skip_check:
|
||||||
insptr++;
|
insptr++;
|
||||||
if (*(insptr+1) == 0)
|
if (*(insptr+1) == 0)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Mod by zero.\n",g_errorLineNum,keyw[g_tw]);
|
M32_PRINTERROR("Mod by zero.");
|
||||||
insptr += 2;
|
insptr += 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -725,7 +725,7 @@ skip_check:
|
||||||
|
|
||||||
if (l2==0)
|
if (l2==0)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Divide by zero.\n",g_errorLineNum,keyw[g_tw]);
|
M32_PRINTERROR("Divide by zero.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Gv_SetVarX(j, Gv_GetVarX(j)/l2);
|
Gv_SetVarX(j, Gv_GetVarX(j)/l2);
|
||||||
|
@ -740,7 +740,7 @@ skip_check:
|
||||||
|
|
||||||
if (l2==0)
|
if (l2==0)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Mod by zero.\n",g_errorLineNum,keyw[g_tw]);
|
M32_PRINTERROR("Mod by zero.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -886,12 +886,12 @@ skip_check:
|
||||||
|
|
||||||
if (xvar < 0 || xvar >= MAXSPRITES || sprite[xvar].statnum==MAXSTATUS)
|
if (xvar < 0 || xvar >= MAXSPRITES || sprite[xvar].statnum==MAXSTATUS)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "invalid sprite %d\n",g_errorLineNum,keyw[g_tw],xvar);
|
M32_PRINTERROR("invalid sprite %d", xvar);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
}
|
}
|
||||||
if (yvar < 0 || yvar >= MAXSPRITES || sprite[yvar].statnum==MAXSTATUS)
|
if (yvar < 0 || yvar >= MAXSPRITES || sprite[yvar].statnum==MAXSTATUS)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "invalid sprite %d\n",g_errorLineNum,keyw[g_tw],yvar);
|
M32_PRINTERROR("invalid sprite %d", yvar);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
}
|
}
|
||||||
if (vm.flags&VMFLAG_ERROR) continue;
|
if (vm.flags&VMFLAG_ERROR) continue;
|
||||||
|
@ -1136,7 +1136,7 @@ skip_check:
|
||||||
if (count<=0) continue;
|
if (count<=0) continue;
|
||||||
if (count > aGameArrays[aridx].size)
|
if (count > aGameArrays[aridx].size)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Count of elements to sort (%d) exceeds array size (%d)!\n",g_errorLineNum,keyw[g_tw],count,aGameArrays[aridx].size);
|
M32_PRINTERROR("Count of elements to sort (%d) exceeds array size (%d)!", count,aGameArrays[aridx].size);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1287,7 +1287,7 @@ skip_check:
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
OSD_Printf(CON_ERROR "Unknown iteration type %d!\n",g_errorLineNum,keyw[g_tw],how);
|
M32_PRINTERROR("Unknown iteration type %d!", how);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
continue;
|
continue;
|
||||||
badindex:
|
badindex:
|
||||||
|
@ -1387,7 +1387,7 @@ badindex:
|
||||||
int32_t key=Gv_GetVarX(*insptr);
|
int32_t key=Gv_GetVarX(*insptr);
|
||||||
if (key<0 || key >= (int32_t)(sizeof(keystatus)/sizeof(keystatus[0])))
|
if (key<0 || key >= (int32_t)(sizeof(keystatus)/sizeof(keystatus[0])))
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Invalid key %d!\n",g_errorLineNum,keyw[g_tw],key);
|
M32_PRINTERROR("Invalid key %d!", key);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1497,8 +1497,7 @@ badindex:
|
||||||
res = inside(x, y, sectnum);
|
res = inside(x, y, sectnum);
|
||||||
if (res == -1)
|
if (res == -1)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Sector index %d out of range!\n",g_errorLineNum,keyw[g_tw],
|
M32_PRINTERROR("Sector index %d out of range!", sectnum);
|
||||||
sectnum);
|
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1538,7 +1537,7 @@ badindex:
|
||||||
X_ERROR_INVALIDSECT(dasectnum);
|
X_ERROR_INVALIDSECT(dasectnum);
|
||||||
if (numsprites >= MAXSPRITES)
|
if (numsprites >= MAXSPRITES)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Maximum number of sprites reached.\n",g_errorLineNum,keyw[g_tw]);
|
M32_PRINTERROR("Maximum number of sprites reached.");
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1558,13 +1557,13 @@ badindex:
|
||||||
|
|
||||||
if (ospritenum<0 || ospritenum>=MAXSPRITES || sprite[ospritenum].statnum==MAXSTATUS)
|
if (ospritenum<0 || ospritenum>=MAXSPRITES || sprite[ospritenum].statnum==MAXSTATUS)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Tried to duplicate nonexistent sprite %d\n",g_errorLineNum,keyw[g_tw],ospritenum);
|
M32_PRINTERROR("Tried to duplicate nonexistent sprite %d", ospritenum);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
}
|
}
|
||||||
if ((tw==CON_DUPSPRITE && numsprites >= MAXSPRITES) ||
|
if ((tw==CON_DUPSPRITE && numsprites >= MAXSPRITES) ||
|
||||||
(tw==CON_DUPSPRITE && spritesortcnt >= MAXSPRITESONSCREEN))
|
(tw==CON_DUPSPRITE && spritesortcnt >= MAXSPRITESONSCREEN))
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Maximum number of sprites reached.\n",g_errorLineNum,keyw[g_tw]);
|
M32_PRINTERROR("Maximum number of sprites reached.");
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
}
|
}
|
||||||
if (vm.flags&VMFLAG_ERROR) continue;
|
if (vm.flags&VMFLAG_ERROR) continue;
|
||||||
|
@ -1575,7 +1574,7 @@ badindex:
|
||||||
|
|
||||||
if (nspritenum < 0)
|
if (nspritenum < 0)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Internal error.\n",g_errorLineNum,keyw[g_tw]);
|
M32_PRINTERROR("Internal error.");
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1616,7 +1615,7 @@ badindex:
|
||||||
|
|
||||||
if (dapoint<0 || dapoint>=numwalls)
|
if (dapoint<0 || dapoint>=numwalls)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Invalid wall %d\n",g_errorLineNum,keyw[g_tw],dapoint);
|
M32_PRINTERROR("Invalid wall %d", dapoint);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1823,7 +1822,7 @@ badindex:
|
||||||
int32_t j=Gv_GetVarX(*insptr++);
|
int32_t j=Gv_GetVarX(*insptr++);
|
||||||
if (j < 0 || j > MAXSTATUS)
|
if (j < 0 || j > MAXSTATUS)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "invalid status list %d\n",g_errorLineNum,keyw[g_tw],j);
|
M32_PRINTERROR("invalid status list %d", j);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1893,12 +1892,12 @@ badindex:
|
||||||
|
|
||||||
if (lVar1<0 || lVar1>=MAXSPRITES || sprite[lVar1].statnum==MAXSTATUS)
|
if (lVar1<0 || lVar1>=MAXSPRITES || sprite[lVar1].statnum==MAXSTATUS)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Invalid sprite %d\n",g_errorLineNum,keyw[g_tw],lVar1);
|
M32_PRINTERROR("Invalid sprite %d", lVar1);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
}
|
}
|
||||||
if (lVar2<0 || lVar2>=MAXSPRITES || sprite[lVar2].statnum==MAXSTATUS)
|
if (lVar2<0 || lVar2>=MAXSPRITES || sprite[lVar2].statnum==MAXSTATUS)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Invalid sprite %d\n",g_errorLineNum,keyw[g_tw],lVar2);
|
M32_PRINTERROR("Invalid sprite %d", lVar2);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1920,8 +1919,7 @@ badindex:
|
||||||
X_ERROR_INVALIDSPRI(i);
|
X_ERROR_INVALIDSPRI(i);
|
||||||
if (j<0 || j >= (tw==CON_CHANGESPRITESTAT?MAXSTATUS:numsectors))
|
if (j<0 || j >= (tw==CON_CHANGESPRITESTAT?MAXSTATUS:numsectors))
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Invalid %s: %d\n", tw==CON_CHANGESPRITESTAT?"statnum":"sector",
|
M32_PRINTERROR("Invalid %s: %d", tw==CON_CHANGESPRITESTAT?"statnum":"sector", j);
|
||||||
g_errorLineNum,keyw[g_tw],j);
|
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1946,7 +1944,7 @@ badindex:
|
||||||
|
|
||||||
if (wallnum<0 || wallnum>=numwalls)
|
if (wallnum<0 || wallnum>=numwalls)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Invalid wall %d\n",g_errorLineNum,keyw[g_tw],wallnum);
|
M32_PRINTERROR("Invalid wall %d", wallnum);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2006,14 +2004,14 @@ badindex:
|
||||||
{
|
{
|
||||||
char buf[80] = "", buf2[80] = "";
|
char buf[80] = "", buf2[80] = "";
|
||||||
int32_t code = (int32_t)*insptr, val = Gv_GetVarX(code);
|
int32_t code = (int32_t)*insptr, val = Gv_GetVarX(code);
|
||||||
int32_t negate=code&(MAXGAMEVARS<<1);
|
int32_t negate=code&M32_FLAG_NEGATE;
|
||||||
|
|
||||||
if (code & (0xFFFFFFFF-(MAXGAMEVARS-1)))
|
if (code & (0xFFFFFFFF-(MAXGAMEVARS-1)))
|
||||||
{
|
{
|
||||||
char pp1[4][8] = {"sprite","sector","wall","tsprite"};
|
char pp1[4][8] = {"sprite","sector","wall","tsprite"};
|
||||||
const memberlabel_t *pp2[4] = {SpriteLabels, SectorLabels, WallLabels, SpriteLabels};
|
const memberlabel_t *pp2[4] = {SpriteLabels, SectorLabels, WallLabels, SpriteLabels};
|
||||||
|
|
||||||
if ((code&(MAXGAMEVARS<<2)) || (code&(MAXGAMEVARS<<3)))
|
if ((code&M32_FLAG_ARRAY) || (code&M32_FLAG_SPECIAL))
|
||||||
{
|
{
|
||||||
if (code&MAXGAMEVARS)
|
if (code&MAXGAMEVARS)
|
||||||
Bsprintf(buf2, "%d", (code>>16)&0xffff);
|
Bsprintf(buf2, "%d", (code>>16)&0xffff);
|
||||||
|
@ -2032,10 +2030,10 @@ badindex:
|
||||||
default: Bsprintf(buf, "(??? constant)"); break;
|
default: Bsprintf(buf, "(??? constant)"); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (code&(MAXGAMEVARS<<2))
|
else if (code&M32_FLAG_ARRAY)
|
||||||
Bsprintf(buf, "%s[%s]", aGameArrays[code&(MAXGAMEARRAYS-1)].szLabel?
|
Bsprintf(buf, "%s[%s]", aGameArrays[code&(MAXGAMEARRAYS-1)].szLabel?
|
||||||
aGameArrays[code&(MAXGAMEARRAYS-1)].szLabel:"???", buf2);
|
aGameArrays[code&(MAXGAMEARRAYS-1)].szLabel:"???", buf2);
|
||||||
else if (code&(MAXGAMEVARS<<3))
|
else if (code&M32_FLAG_SPECIAL)
|
||||||
Bsprintf(buf, "%s[%s].%s", pp1[code&3], buf2, pp2[code&3][(code>>2)&31].name);
|
Bsprintf(buf, "%s[%s].%s", pp1[code&3], buf2, pp2[code&3][(code>>2)&31].name);
|
||||||
else
|
else
|
||||||
Bsprintf(buf, "???");
|
Bsprintf(buf, "???");
|
||||||
|
@ -2197,7 +2195,7 @@ badindex:
|
||||||
case CON_QGETSYSSTR:
|
case CON_QGETSYSSTR:
|
||||||
if (ScriptQuotes[i] == NULL)
|
if (ScriptQuotes[i] == NULL)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "null quote %d %d\n",g_errorLineNum,keyw[g_tw],i,j);
|
M32_PRINTERROR("null quote %d %d", i,j);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (j)
|
switch (j)
|
||||||
|
@ -2209,7 +2207,7 @@ badindex:
|
||||||
Bstrcpy(ScriptQuotes[i], "Mapster32"VERSION BUILDDATE);
|
Bstrcpy(ScriptQuotes[i], "Mapster32"VERSION BUILDDATE);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
OSD_Printf(CON_ERROR "unknown str ID %d %d\n",g_errorLineNum,keyw[g_tw],i,j);
|
M32_PRINTERROR("unknown str ID %d %d", i,j);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
@ -2499,37 +2497,37 @@ dodefault:
|
||||||
case CON_SPGETLOTAG:
|
case CON_SPGETLOTAG:
|
||||||
insptr++;
|
insptr++;
|
||||||
X_ERROR_INVALIDSP();
|
X_ERROR_INVALIDSP();
|
||||||
Gv_SetVarX(g_iLoTagID, vm.g_sp->lotag);
|
Gv_SetVarX(M32_LOTAG_VAR_ID, vm.g_sp->lotag);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case CON_SPGETHITAG:
|
case CON_SPGETHITAG:
|
||||||
insptr++;
|
insptr++;
|
||||||
X_ERROR_INVALIDSP();
|
X_ERROR_INVALIDSP();
|
||||||
Gv_SetVarX(g_iHiTagID, vm.g_sp->hitag);
|
Gv_SetVarX(M32_HITAG_VAR_ID, vm.g_sp->hitag);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case CON_SECTGETLOTAG:
|
case CON_SECTGETLOTAG:
|
||||||
insptr++;
|
insptr++;
|
||||||
X_ERROR_INVALIDSP();
|
X_ERROR_INVALIDSP();
|
||||||
Gv_SetVarX(g_iLoTagID, sector[vm.g_sp->sectnum].lotag);
|
Gv_SetVarX(M32_LOTAG_VAR_ID, sector[vm.g_sp->sectnum].lotag);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case CON_SECTGETHITAG:
|
case CON_SECTGETHITAG:
|
||||||
insptr++;
|
insptr++;
|
||||||
X_ERROR_INVALIDSP();
|
X_ERROR_INVALIDSP();
|
||||||
Gv_SetVarX(g_iHiTagID, sector[vm.g_sp->sectnum].hitag);
|
Gv_SetVarX(M32_HITAG_VAR_ID, sector[vm.g_sp->sectnum].hitag);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case CON_GETTEXTUREFLOOR:
|
case CON_GETTEXTUREFLOOR:
|
||||||
insptr++;
|
insptr++;
|
||||||
X_ERROR_INVALIDSP();
|
X_ERROR_INVALIDSP();
|
||||||
Gv_SetVarX(g_iTextureID, sector[vm.g_sp->sectnum].floorpicnum);
|
Gv_SetVarX(M32_TEXTURE_VAR_ID, sector[vm.g_sp->sectnum].floorpicnum);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case CON_GETTEXTURECEILING:
|
case CON_GETTEXTURECEILING:
|
||||||
insptr++;
|
insptr++;
|
||||||
X_ERROR_INVALIDSP();
|
X_ERROR_INVALIDSP();
|
||||||
Gv_SetVarX(g_iTextureID, sector[vm.g_sp->sectnum].ceilingpicnum);
|
Gv_SetVarX(M32_TEXTURE_VAR_ID, sector[vm.g_sp->sectnum].ceilingpicnum);
|
||||||
continue;
|
continue;
|
||||||
// ^^^
|
// ^^^
|
||||||
case CON_DRAWLINE16:
|
case CON_DRAWLINE16:
|
||||||
|
@ -2615,7 +2613,7 @@ dodefault:
|
||||||
int32_t j=Gv_GetVarX(*insptr);
|
int32_t j=Gv_GetVarX(*insptr);
|
||||||
if (j<0 || j>=MAXSOUNDS)
|
if (j<0 || j>=MAXSOUNDS)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],j);
|
M32_PRINTERROR("Invalid sound %d", j);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
insptr++;
|
insptr++;
|
||||||
continue;
|
continue;
|
||||||
|
@ -2641,7 +2639,7 @@ dodefault:
|
||||||
int32_t j=Gv_GetVarX(*insptr++), var=*insptr++;
|
int32_t j=Gv_GetVarX(*insptr++), var=*insptr++;
|
||||||
if (j<0 || j>=MAXSOUNDS)
|
if (j<0 || j>=MAXSOUNDS)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],j);
|
M32_PRINTERROR("Invalid sound %d", j);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
insptr++;
|
insptr++;
|
||||||
continue;
|
continue;
|
||||||
|
@ -2661,7 +2659,7 @@ dodefault:
|
||||||
|
|
||||||
if (j<0 || j>=MAXSOUNDS)
|
if (j<0 || j>=MAXSOUNDS)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],j);
|
M32_PRINTERROR("Invalid sound %d", j);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,10 +120,10 @@ static int32_t __fastcall VM_AccessWall(int32_t how, int32_t lVar1, int32_t lLab
|
||||||
}
|
}
|
||||||
|
|
||||||
badwall:
|
badwall:
|
||||||
OSD_Printf(CON_ERROR "Invalid wall %d\n",g_errorLineNum,keyw[g_tw],i);
|
M32_PRINTERROR("Invalid wall %d", i);
|
||||||
return -1;
|
return -1;
|
||||||
readonly:
|
readonly:
|
||||||
OSD_Printf(CON_ERROR "Wall structure member `%s' is read-only.\n",g_errorLineNum,keyw[g_tw],WallLabels[lLabelID].name);
|
M32_PRINTERROR("Wall structure member `%s' is read-only.", WallLabels[lLabelID].name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ static int32_t __fastcall VM_AccessSector(int32_t how, int32_t lVar1, int32_t lL
|
||||||
int32_t lValue;
|
int32_t lValue;
|
||||||
int32_t i = (how&ACCESS_USEVARS) ? sprite[vm.g_i].sectnum : lVar1;
|
int32_t i = (how&ACCESS_USEVARS) ? sprite[vm.g_i].sectnum : lVar1;
|
||||||
|
|
||||||
if ((how&ACCESS_USEVARS) && lVar1 != g_iThisActorID)
|
if ((how&ACCESS_USEVARS) && lVar1 != M32_THISACTOR_VAR_ID)
|
||||||
i = Gv_GetVarX(lVar1);
|
i = Gv_GetVarX(lVar1);
|
||||||
|
|
||||||
if (i<0 || i >= numsectors)
|
if (i<0 || i >= numsectors)
|
||||||
|
@ -237,10 +237,10 @@ static int32_t __fastcall VM_AccessSector(int32_t how, int32_t lVar1, int32_t lL
|
||||||
}
|
}
|
||||||
|
|
||||||
badsector:
|
badsector:
|
||||||
OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],i);
|
M32_PRINTERROR("Invalid sector %d", i);
|
||||||
return -1;
|
return -1;
|
||||||
readonly:
|
readonly:
|
||||||
OSD_Printf(CON_ERROR "Sector structure member `%s' is read-only.\n",g_errorLineNum,keyw[g_tw],SectorLabels[lLabelID].name);
|
M32_PRINTERROR("Sector structure member `%s' is read-only.", SectorLabels[lLabelID].name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ static int32_t __fastcall VM_AccessSprite(int32_t how, int32_t lVar1, int32_t lL
|
||||||
int32_t lValue;
|
int32_t lValue;
|
||||||
register int32_t i = (how&ACCESS_USEVARS) ? vm.g_i : lVar1;
|
register int32_t i = (how&ACCESS_USEVARS) ? vm.g_i : lVar1;
|
||||||
|
|
||||||
if ((how&ACCESS_USEVARS) && lVar1 != g_iThisActorID)
|
if ((how&ACCESS_USEVARS) && lVar1 != M32_THISACTOR_VAR_ID)
|
||||||
i = Gv_GetVarX(lVar1);
|
i = Gv_GetVarX(lVar1);
|
||||||
|
|
||||||
if (i < 0 || i >= MAXSPRITES)
|
if (i < 0 || i >= MAXSPRITES)
|
||||||
|
@ -348,11 +348,10 @@ badactor:
|
||||||
// OSD_Printf(CON_ERROR "tried to set %s on invalid target sprite (%d) from spr %d pic %d gv %s\n",g_errorLineNum,keyw[g_tw],
|
// OSD_Printf(CON_ERROR "tried to set %s on invalid target sprite (%d) from spr %d pic %d gv %s\n",g_errorLineNum,keyw[g_tw],
|
||||||
// SpriteLabels[lLabelID].name,i,vm.g_i,vm.g_sp->picnum,
|
// SpriteLabels[lLabelID].name,i,vm.g_i,vm.g_sp->picnum,
|
||||||
// (lVar1<MAXGAMEVARS)?aGameVars[lVar1].szLabel:"extended");
|
// (lVar1<MAXGAMEVARS)?aGameVars[lVar1].szLabel:"extended");
|
||||||
OSD_Printf(CON_ERROR "tried to set %s on invalid target sprite (%d)\n",g_errorLineNum,keyw[g_tw],
|
M32_PRINTERROR("tried to set %s on invalid target sprite (%d)", SpriteLabels[lLabelID].name, i);
|
||||||
SpriteLabels[lLabelID].name,i);
|
|
||||||
return -1;
|
return -1;
|
||||||
readonly:
|
readonly:
|
||||||
OSD_Printf(CON_ERROR "Sprite structure member `%s' is read-only.\n",g_errorLineNum,keyw[g_tw],SpriteLabels[lLabelID].name);
|
M32_PRINTERROR("Sprite structure member `%s' is read-only.", SpriteLabels[lLabelID].name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,7 +362,7 @@ static int32_t __fastcall VM_AccessTsprite(int32_t how, int32_t lVar1, int32_t l
|
||||||
int32_t i = (how&ACCESS_USEVARS) ? vm.g_i : lVar1;
|
int32_t i = (how&ACCESS_USEVARS) ? vm.g_i : lVar1;
|
||||||
spritetype *datspr;
|
spritetype *datspr;
|
||||||
|
|
||||||
if ((how&ACCESS_USEVARS) && lVar1 != g_iThisActorID)
|
if ((how&ACCESS_USEVARS) && lVar1 != M32_THISACTOR_VAR_ID)
|
||||||
i = Gv_GetVarX(lVar1);
|
i = Gv_GetVarX(lVar1);
|
||||||
|
|
||||||
if (how&ACCESS_SPRITEEXT)
|
if (how&ACCESS_SPRITEEXT)
|
||||||
|
@ -458,10 +457,10 @@ static int32_t __fastcall VM_AccessTsprite(int32_t how, int32_t lVar1, int32_t l
|
||||||
}
|
}
|
||||||
|
|
||||||
badsprite:
|
badsprite:
|
||||||
OSD_Printf(CON_ERROR "invalid target sprite (%d)\n",g_errorLineNum,keyw[g_tw],i);
|
M32_PRINTERROR("invalid target sprite (%d)", i);
|
||||||
return -1;
|
return -1;
|
||||||
badtspr:
|
badtspr:
|
||||||
OSD_Printf(CON_ERROR "Internal bug, tsprite is unavailable\n",g_errorLineNum,keyw[g_tw]);
|
M32_PRINTERROR("Internal bug, tsprite is unavailable");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,17 +77,13 @@ int32_t Gv_NewArray(const char *pszLabel, void *arrayptr, intptr_t asize, uint32
|
||||||
|
|
||||||
if (g_gameArrayCount >= MAXGAMEARRAYS)
|
if (g_gameArrayCount >= MAXGAMEARRAYS)
|
||||||
{
|
{
|
||||||
g_numCompilerErrors++;
|
C_CUSTOMERROR("too many arrays! (max: %d)", MAXGAMEARRAYS);
|
||||||
C_ReportError(-1);
|
|
||||||
initprintf("%s:%d: error: too many arrays! (max: %d)\n",g_szScriptFileName,g_lineNumber, MAXGAMEARRAYS);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Bstrlen(pszLabel) > (MAXARRAYLABEL-1))
|
if (Bstrlen(pszLabel) > (MAXARRAYLABEL-1))
|
||||||
{
|
{
|
||||||
g_numCompilerErrors++;
|
C_CUSTOMERROR("array name `%s' exceeds limit of %d characters.", pszLabel, MAXARRAYLABEL);
|
||||||
C_ReportError(-1);
|
|
||||||
initprintf("%s:%d: error: array name `%s' exceeds limit of %d characters.\n",g_szScriptFileName,g_lineNumber,pszLabel, MAXARRAYLABEL);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,9 +94,7 @@ int32_t Gv_NewArray(const char *pszLabel, void *arrayptr, intptr_t asize, uint32
|
||||||
|
|
||||||
if (aGameArrays[i].dwFlags&GAMEARRAY_TYPEMASK)
|
if (aGameArrays[i].dwFlags&GAMEARRAY_TYPEMASK)
|
||||||
{
|
{
|
||||||
g_numCompilerWarnings++;
|
C_CUSTOMWARNING("ignored redefining system array `%s'.", pszLabel);
|
||||||
C_ReportError(-1);
|
|
||||||
initprintf("%s:%d: warning: didn't redefine system array `%s'.\n",g_szScriptFileName,g_lineNumber,pszLabel);
|
|
||||||
}
|
}
|
||||||
// C_ReportError(WARNING_DUPLICATEDEFINITION);
|
// C_ReportError(WARNING_DUPLICATEDEFINITION);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -108,9 +102,7 @@ int32_t Gv_NewArray(const char *pszLabel, void *arrayptr, intptr_t asize, uint32
|
||||||
|
|
||||||
if (!(dwFlags&GAMEARRAY_VARSIZE) && (asize<=0 || asize>=65536))
|
if (!(dwFlags&GAMEARRAY_VARSIZE) && (asize<=0 || asize>=65536))
|
||||||
{
|
{
|
||||||
g_numCompilerErrors++;
|
C_CUSTOMERROR("invalid array size %d. Must be between 1 and 65536", (int32_t)asize);
|
||||||
C_ReportError(-1);
|
|
||||||
initprintf("%s:%d: error: invalid array size %d. Must be between 1 and 65536\n",g_szScriptFileName,g_lineNumber,(int32_t)asize);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,17 +135,13 @@ int32_t Gv_NewVar(const char *pszLabel, intptr_t lValue, uint32_t dwFlags)
|
||||||
|
|
||||||
if (g_gameVarCount >= MAXGAMEVARS)
|
if (g_gameVarCount >= MAXGAMEVARS)
|
||||||
{
|
{
|
||||||
g_numCompilerErrors++;
|
C_CUSTOMERROR("too many gamevars! (max: %d)", MAXGAMEVARS);
|
||||||
C_ReportError(-1);
|
|
||||||
initprintf("%s:%d: error: too many gamevars!\n",g_szScriptFileName,g_lineNumber);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Bstrlen(pszLabel) > (MAXVARLABEL-1))
|
if (Bstrlen(pszLabel) > (MAXVARLABEL-1))
|
||||||
{
|
{
|
||||||
g_numCompilerErrors++;
|
C_CUSTOMERROR("variable name `%s' exceeds limit of %d characters.", pszLabel, MAXVARLABEL);
|
||||||
C_ReportError(-1);
|
|
||||||
initprintf("%s:%d: error: variable name `%s' exceeds limit of %d characters.\n",g_szScriptFileName,g_lineNumber,pszLabel, MAXVARLABEL);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,12 +210,12 @@ int32_t Gv_NewVar(const char *pszLabel, intptr_t lValue, uint32_t dwFlags)
|
||||||
|
|
||||||
int32_t __fastcall Gv_GetVarN(register int32_t id) // 'N' for "no side-effects"... vars only!
|
int32_t __fastcall Gv_GetVarN(register int32_t id) // 'N' for "no side-effects"... vars only!
|
||||||
{
|
{
|
||||||
if (id == g_iThisActorID)
|
if (id == M32_THISACTOR_VAR_ID)
|
||||||
return vm.g_i;
|
return vm.g_i;
|
||||||
|
|
||||||
if (id & (0xFFFFFFFF-(MAXGAMEVARS-1)))
|
if (id & (0xFFFFFFFF-(MAXGAMEVARS-1)))
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Gv_GetVarN(): invalid var index %d\n",g_errorLineNum,keyw[g_tw],id);
|
M32_PRINTERROR("Gv_GetVarN(): invalid var index %d", id);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -249,7 +237,7 @@ int32_t __fastcall Gv_GetVarN(register int32_t id) // 'N' for "no side-effects"
|
||||||
case GAMEVAR_CHARPTR:
|
case GAMEVAR_CHARPTR:
|
||||||
return *((uint8_t*)aGameVars[id].val.lValue);
|
return *((uint8_t*)aGameVars[id].val.lValue);
|
||||||
default:
|
default:
|
||||||
OSD_Printf(CON_ERROR "Gv_GetVarN(): WTF??\n",g_errorLineNum,keyw[g_tw]);
|
M32_PRINTERROR("Gv_GetVarN(): WTF??");
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -257,7 +245,7 @@ int32_t __fastcall Gv_GetVarN(register int32_t id) // 'N' for "no side-effects"
|
||||||
|
|
||||||
int32_t __fastcall Gv_GetVarX(register int32_t id)
|
int32_t __fastcall Gv_GetVarX(register int32_t id)
|
||||||
{
|
{
|
||||||
if (id == g_iThisActorID)
|
if (id == M32_THISACTOR_VAR_ID)
|
||||||
return vm.g_i;
|
return vm.g_i;
|
||||||
|
|
||||||
if ((id & 0x0000FFFC) == MAXGAMEVARS)
|
if ((id & 0x0000FFFC) == MAXGAMEVARS)
|
||||||
|
@ -271,18 +259,18 @@ int32_t __fastcall Gv_GetVarX(register int32_t id)
|
||||||
case 2:
|
case 2:
|
||||||
return labelval[(id>>16)&0xffff];
|
return labelval[(id>>16)&0xffff];
|
||||||
default:
|
default:
|
||||||
OSD_Printf(CON_ERROR "Gv_GetVarX() (constant): WTF??\n",g_errorLineNum,keyw[g_tw]);
|
M32_PRINTERROR("Gv_GetVarX() (constant): WTF??");
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
register int32_t negateResult = (id&(MAXGAMEVARS<<1))>>(LOG2MAXGV+1);
|
register int32_t negateResult = (id&M32_FLAG_NEGATE)>>(LOG2MAXGV+1);
|
||||||
|
|
||||||
if (id & (0xFFFFFFFF-(MAXGAMEVARS-1)))
|
if (id & (0xFFFFFFFF-(MAXGAMEVARS-1)))
|
||||||
{
|
{
|
||||||
if (id&(MAXGAMEVARS<<2)) // array
|
if (id&M32_FLAG_ARRAY) // array
|
||||||
{
|
{
|
||||||
register int32_t index;
|
register int32_t index;
|
||||||
int32_t siz;
|
int32_t siz;
|
||||||
|
@ -300,7 +288,7 @@ int32_t __fastcall Gv_GetVarX(register int32_t id)
|
||||||
|
|
||||||
if (index < 0 || index >= siz)
|
if (index < 0 || index >= siz)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Gv_GetVarX(): invalid array index (%s[%d])\n",g_errorLineNum,keyw[g_tw],aGameArrays[id].szLabel,index);
|
M32_PRINTERROR("Gv_GetVarX(): invalid array index (%s[%d])", aGameArrays[id].szLabel, index);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,13 +302,13 @@ int32_t __fastcall Gv_GetVarX(register int32_t id)
|
||||||
case GAMEARRAY_OFCHAR:
|
case GAMEARRAY_OFCHAR:
|
||||||
return ((((uint8_t *)aGameArrays[id].vals)[index] ^ -negateResult) + negateResult);
|
return ((((uint8_t *)aGameArrays[id].vals)[index] ^ -negateResult) + negateResult);
|
||||||
default:
|
default:
|
||||||
OSD_Printf(CON_ERROR "Gv_GetVarX() (array): WTF??\n",g_errorLineNum,keyw[g_tw]);
|
M32_PRINTERROR("Gv_GetVarX() (array): WTF??");
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id&(MAXGAMEVARS<<3)) // struct shortcut vars
|
if (id&M32_FLAG_SPECIAL) // struct shortcut vars
|
||||||
{
|
{
|
||||||
register int32_t index, memberid;
|
register int32_t index, memberid;
|
||||||
|
|
||||||
|
@ -332,17 +320,17 @@ int32_t __fastcall Gv_GetVarX(register int32_t id)
|
||||||
|
|
||||||
switch (id&3)
|
switch (id&3)
|
||||||
{
|
{
|
||||||
case 0: //if (id == g_iSpriteVarID)
|
case M32_SPRITE_VAR_ID:
|
||||||
return ((VM_AccessSprite(0, index, memberid, 0) ^ -negateResult) + negateResult);
|
return ((VM_AccessSprite(0, index, memberid, 0) ^ -negateResult) + negateResult);
|
||||||
case 1: //else if (id == g_iSectorVarID)
|
case M32_SECTOR_VAR_ID:
|
||||||
// if (index == vm.g_i) index = sprite[vm.g_i].sectnum;
|
// if (index == vm.g_i) index = sprite[vm.g_i].sectnum;
|
||||||
return ((VM_AccessSector(0, index, memberid, 0) ^ -negateResult) + negateResult);
|
return ((VM_AccessSector(0, index, memberid, 0) ^ -negateResult) + negateResult);
|
||||||
case 2: //else if (id == g_iWallVarID)
|
case M32_WALL_VAR_ID:
|
||||||
return ((VM_AccessWall(0, index, memberid, 0) ^ -negateResult) + negateResult);
|
return ((VM_AccessWall(0, index, memberid, 0) ^ -negateResult) + negateResult);
|
||||||
case 3:
|
case M32_TSPRITE_VAR_ID:
|
||||||
return ((VM_AccessTsprite(0, index, memberid, 0) ^ -negateResult) + negateResult);
|
return ((VM_AccessTsprite(0, index, memberid, 0) ^ -negateResult) + negateResult);
|
||||||
// default:
|
// default:
|
||||||
// OSD_Printf(CON_ERROR "Gv_GetVarX() (special): WTF??\n",g_errorLineNum,keyw[g_tw]);
|
// M32_PRINTERROR("Gv_GetVarX() (special): WTF??");
|
||||||
// return -1;
|
// return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -351,7 +339,7 @@ int32_t __fastcall Gv_GetVarX(register int32_t id)
|
||||||
|
|
||||||
if (!negateResult)
|
if (!negateResult)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Gv_GetVarX(): invalid gamevar ID (%d)\n",g_errorLineNum,keyw[g_tw],id);
|
M32_PRINTERROR("Gv_GetVarX(): invalid gamevar ID (%d)", id);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -377,7 +365,7 @@ int32_t __fastcall Gv_GetVarX(register int32_t id)
|
||||||
case GAMEVAR_CHARPTR:
|
case GAMEVAR_CHARPTR:
|
||||||
return ((*((uint8_t*)aGameVars[id].val.lValue) ^ -negateResult) + negateResult);
|
return ((*((uint8_t*)aGameVars[id].val.lValue) ^ -negateResult) + negateResult);
|
||||||
default:
|
default:
|
||||||
OSD_Printf(CON_ERROR "Gv_GetVarX(): WTF??\n",g_errorLineNum,keyw[g_tw]);
|
M32_PRINTERROR("Gv_GetVarX(): WTF??");
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -388,7 +376,7 @@ void __fastcall Gv_SetVarX(register int32_t id, register int32_t lValue)
|
||||||
{
|
{
|
||||||
if (id & (0xFFFFFFFF-(MAXGAMEVARS-1)))
|
if (id & (0xFFFFFFFF-(MAXGAMEVARS-1)))
|
||||||
{
|
{
|
||||||
if (id&(MAXGAMEVARS<<2)) // array
|
if (id&M32_FLAG_ARRAY) // array
|
||||||
{
|
{
|
||||||
register int32_t index;
|
register int32_t index;
|
||||||
int32_t siz;
|
int32_t siz;
|
||||||
|
@ -405,7 +393,7 @@ void __fastcall Gv_SetVarX(register int32_t id, register int32_t lValue)
|
||||||
|
|
||||||
if (index < 0 || index >= siz)
|
if (index < 0 || index >= siz)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Gv_SetVarX(): invalid array index (%s[%d])\n",g_errorLineNum,keyw[g_tw],aGameArrays[id].szLabel,index);
|
M32_PRINTERROR("Gv_SetVarX(): invalid array index (%s[%d])", aGameArrays[id].szLabel, index);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -423,14 +411,14 @@ void __fastcall Gv_SetVarX(register int32_t id, register int32_t lValue)
|
||||||
((uint8_t *)aGameArrays[id].vals)[index] = (uint8_t)lValue;
|
((uint8_t *)aGameArrays[id].vals)[index] = (uint8_t)lValue;
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
OSD_Printf(CON_ERROR "Gv_SetVarX() (array): WTF??\n",g_errorLineNum,keyw[g_tw]);
|
M32_PRINTERROR("Gv_SetVarX() (array): WTF??");
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id&(MAXGAMEVARS<<3)) // struct shortcut vars
|
if (id&M32_FLAG_SPECIAL) // struct shortcut vars
|
||||||
{
|
{
|
||||||
register int32_t index, memberid;
|
register int32_t index, memberid;
|
||||||
|
|
||||||
|
@ -442,26 +430,26 @@ void __fastcall Gv_SetVarX(register int32_t id, register int32_t lValue)
|
||||||
|
|
||||||
switch (id&3)
|
switch (id&3)
|
||||||
{
|
{
|
||||||
case 0: //if (id == g_iSpriteVarID)
|
case M32_SPRITE_VAR_ID:
|
||||||
VM_AccessSprite(1, index, memberid, lValue);
|
VM_AccessSprite(1, index, memberid, lValue);
|
||||||
return;
|
return;
|
||||||
case 1: //else if (id == g_iSectorVarID)
|
case M32_SECTOR_VAR_ID:
|
||||||
// if (index == vm.g_i) index = sprite[vm.g_i].sectnum;
|
// if (index == vm.g_i) index = sprite[vm.g_i].sectnum;
|
||||||
VM_AccessSector(1, index, memberid, lValue);
|
VM_AccessSector(1, index, memberid, lValue);
|
||||||
return;
|
return;
|
||||||
case 2: //else if (id == g_iWallVarID)
|
case M32_WALL_VAR_ID:
|
||||||
VM_AccessWall(1, index, memberid, lValue);
|
VM_AccessWall(1, index, memberid, lValue);
|
||||||
return;
|
return;
|
||||||
case 3:
|
case M32_TSPRITE_VAR_ID:
|
||||||
VM_AccessTsprite(1, index, memberid, lValue);
|
VM_AccessTsprite(1, index, memberid, lValue);
|
||||||
return;
|
return;
|
||||||
// default:
|
// default:
|
||||||
// OSD_Printf(CON_ERROR "Gv_SetVarX(): WTF??\n",g_errorLineNum,keyw[g_tw]);
|
// M32_PRINTERROR("Gv_SetVarX(): WTF??");
|
||||||
// return;
|
// return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OSD_Printf(CON_ERROR "Gv_SetVarX(): invalid gamevar ID (%d)\n",g_errorLineNum,keyw[g_tw],id);
|
M32_PRINTERROR("Gv_SetVarX(): invalid gamevar ID (%d)", id);
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -479,9 +467,9 @@ void __fastcall Gv_SetVarX(register int32_t id, register int32_t lValue)
|
||||||
{
|
{
|
||||||
int32_t ival = lValue;
|
int32_t ival = lValue;
|
||||||
float fval = *(float *)&ival;
|
float fval = *(float *)&ival;
|
||||||
if (fval!=fval || fval<-3.3e38 || fval > 3.3e38)
|
if (fval!=fval || fval<-3.4e38 || fval > 3.4e38)
|
||||||
{
|
{
|
||||||
OSD_Printf(CON_ERROR "Gv_SetVarX(): tried to set float var to NaN or infinity\n",g_errorLineNum,keyw[g_tw]);
|
M32_PRINTERROR("Gv_SetVarX(): tried to set float var to NaN or infinity");
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -496,7 +484,7 @@ void __fastcall Gv_SetVarX(register int32_t id, register int32_t lValue)
|
||||||
*((uint8_t*)aGameVars[id].val.lValue)=(uint8_t)lValue;
|
*((uint8_t*)aGameVars[id].val.lValue)=(uint8_t)lValue;
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
OSD_Printf(CON_ERROR "Gv_SetVarX(): WTF??\n",g_errorLineNum,keyw[g_tw]);
|
M32_PRINTERROR("Gv_SetVarX(): WTF??");
|
||||||
vm.flags |= VMFLAG_ERROR;
|
vm.flags |= VMFLAG_ERROR;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -525,25 +513,19 @@ static void Gv_AddSystemVars(void)
|
||||||
|
|
||||||
//AddLog("Gv_AddSystemVars");
|
//AddLog("Gv_AddSystemVars");
|
||||||
|
|
||||||
// special vars for struct access; must be at top and in this order
|
// special vars for struct access
|
||||||
g_iSpriteVarID = g_gameVarCount;
|
// MUST be at top and in this order!!!
|
||||||
Gv_NewVar("sprite", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
Gv_NewVar("sprite", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
||||||
g_iSectorVarID = g_gameVarCount;
|
|
||||||
Gv_NewVar("sector", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
Gv_NewVar("sector", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
||||||
g_iWallVarID = g_gameVarCount;
|
|
||||||
Gv_NewVar("wall", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
Gv_NewVar("wall", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
||||||
Gv_NewVar("tsprite", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
Gv_NewVar("tsprite", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
||||||
|
|
||||||
g_iReturnVarID = g_gameVarCount;
|
// these too have to be in here and in order!
|
||||||
Gv_NewVar("RETURN", (intptr_t)&g_iReturnVar, GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
|
|
||||||
g_iLoTagID = g_gameVarCount;
|
|
||||||
Gv_NewVar("LOTAG", 0, GAMEVAR_SYSTEM);
|
|
||||||
g_iHiTagID = g_gameVarCount;
|
|
||||||
Gv_NewVar("HITAG", 0, GAMEVAR_SYSTEM);
|
|
||||||
g_iTextureID = g_gameVarCount;
|
|
||||||
Gv_NewVar("TEXTURE", 0, GAMEVAR_SYSTEM);
|
|
||||||
g_iThisActorID = g_gameVarCount;
|
|
||||||
Gv_NewVar("I", 0, GAMEVAR_READONLY | GAMEVAR_SYSTEM); // THISACTOR
|
Gv_NewVar("I", 0, GAMEVAR_READONLY | GAMEVAR_SYSTEM); // THISACTOR
|
||||||
|
Gv_NewVar("RETURN", (intptr_t)&g_iReturnVar, GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
|
||||||
|
Gv_NewVar("LOTAG", 0, GAMEVAR_SYSTEM);
|
||||||
|
Gv_NewVar("HITAG", 0, GAMEVAR_SYSTEM);
|
||||||
|
Gv_NewVar("TEXTURE", 0, GAMEVAR_SYSTEM);
|
||||||
|
|
||||||
Gv_NewVar("xdim",(intptr_t)&xdim, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_READONLY);
|
Gv_NewVar("xdim",(intptr_t)&xdim, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_READONLY);
|
||||||
Gv_NewVar("ydim",(intptr_t)&ydim, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_READONLY);
|
Gv_NewVar("ydim",(intptr_t)&ydim, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_READONLY);
|
||||||
|
|
Loading…
Reference in a new issue