mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +00:00
some more functions for m32-script
git-svn-id: https://svn.eduke32.com/eduke32@1499 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
d7951477f5
commit
e7acafc9e7
7 changed files with 296 additions and 46 deletions
|
@ -5,10 +5,16 @@ include names.h
|
|||
|
||||
gamevar i 0 1 // per-block (top-level, event, or state) variable
|
||||
gamevar j 0 1
|
||||
gamevar k 0 1
|
||||
gamevar l 0 1
|
||||
|
||||
gamevar tmp 0 0
|
||||
|
||||
gamevar davr 65536 0
|
||||
gamevar dayx 65536 0
|
||||
|
||||
gamevar drawcol 9 0
|
||||
|
||||
define TQUOTE 3
|
||||
|
||||
definequote 0 OK
|
||||
|
@ -20,16 +26,27 @@ definequote TQUOTE write on me!
|
|||
definequote 4 ASPECT: VR=%d, YX=%d
|
||||
definequote 5 KEY:%d
|
||||
|
||||
definequote 6 time: %d ms
|
||||
definequote 7 SPRITES:
|
||||
|
||||
gamearray ar 128
|
||||
gamearray parm 8
|
||||
|
||||
defstate artest
|
||||
for j range 128
|
||||
getarraysize ar tmp
|
||||
resizearray ar 65536
|
||||
getticks parm[2]
|
||||
for j range 65536
|
||||
set ar[j] j
|
||||
set i 0
|
||||
for j range 128
|
||||
for j range 65536
|
||||
add i ar[j]
|
||||
ife i 8128 quote 0 else quote 1
|
||||
getticks parm[3]
|
||||
resizearray ar tmp
|
||||
ife i 2147450880 quote 0 else quote 1
|
||||
sub parm[3] parm[2]
|
||||
qsprintf TQUOTE 6 parm[3]
|
||||
quote TQUOTE
|
||||
ends
|
||||
|
||||
defstate setas
|
||||
|
@ -39,44 +56,92 @@ defstate setas
|
|||
setaspect davr j
|
||||
ends
|
||||
|
||||
onevent EVENT_ANALYZESPRITES
|
||||
for i drawnsprites
|
||||
ifactor LIZTROOP spritepal 6
|
||||
endevent
|
||||
|
||||
onevent EVENT_ENTER3DMODE
|
||||
state setas
|
||||
endevent
|
||||
|
||||
onevent EVENT_ANALYZESPRITES
|
||||
|
||||
for i drawnsprites
|
||||
{
|
||||
switch tsprite[i].picnum
|
||||
case LIZTROOP spritepal 1 break
|
||||
case PIGCOP spritepal 2 break
|
||||
case BOSS1 spritepal 6 break
|
||||
endswitch
|
||||
}
|
||||
/*
|
||||
for i drawnsprites
|
||||
{
|
||||
ife tsprite[i].picnum LIZTROOP spritepal 1 else
|
||||
ife tsprite[i].picnum PIGCOP spritepal 2 else
|
||||
ife tsprite[i].picnum BOSS1 spritepal 6
|
||||
}
|
||||
*/
|
||||
endevent
|
||||
|
||||
defstate cmp_by_lotag
|
||||
set RETURN sprite[SV2].lotag
|
||||
sub RETURN sprite[SV1].lotag
|
||||
ends
|
||||
|
||||
onevent EVENT_DRAW2DSCREEN
|
||||
ifl cursectnum 0 return
|
||||
|
||||
getarraysize ar tmp
|
||||
set j 0
|
||||
for i spritesofsector cursectnum
|
||||
{
|
||||
ifge j tmp nullop else
|
||||
ifactor LOCATORS
|
||||
{
|
||||
set ar[j] i
|
||||
add j 1
|
||||
}
|
||||
}
|
||||
|
||||
set tmp j
|
||||
sort ar tmp cmp_by_lotag
|
||||
|
||||
sub tmp 1
|
||||
for i range tmp
|
||||
{
|
||||
set j ar[i]
|
||||
set k i, add k 1, set k ar[k]
|
||||
drawline16b sprite[j].x sprite[j].y sprite[k].x sprite[k].y drawcol
|
||||
}
|
||||
/*
|
||||
set drawlinepat -1
|
||||
for i allsprites
|
||||
ifactor LIZTROOP
|
||||
drawcircle16b sprite[i].x sprite[i].y 256 9
|
||||
// set i totalclock
|
||||
// shiftr i 6
|
||||
// drawcircle16b posx posy 256 i
|
||||
// set j i
|
||||
// add j 8
|
||||
// drawcircle16 halfxdim16 midydim16 12 j
|
||||
// qsprintf 3 2 i j
|
||||
// printmessage16 3
|
||||
*/
|
||||
|
||||
/*
|
||||
set i totalclock
|
||||
shiftr i 6
|
||||
drawcircle16b posx posy 256 i
|
||||
set j i
|
||||
add j 8
|
||||
drawcircle16 halfxdim16 midydim16 12 j
|
||||
qsprintf 3 2 i j
|
||||
printmessage16 3
|
||||
*/
|
||||
endevent
|
||||
|
||||
onevent EVENT_OVERHEADEDITOR
|
||||
|
||||
for i range 27
|
||||
{
|
||||
ifkey alphakeys[i]
|
||||
ifholdkey alphakeys[i]
|
||||
{
|
||||
qsprintf TQUOTE 5 i
|
||||
quote TQUOTE
|
||||
}
|
||||
}
|
||||
|
||||
for i range 10
|
||||
// ife 0 1
|
||||
{
|
||||
ifkey numberkeys[i]
|
||||
ifholdkey numberkeys[i]
|
||||
{
|
||||
qsprintf TQUOTE 5 i
|
||||
quote TQUOTE
|
||||
|
@ -88,14 +153,39 @@ onevent EVENT_KEYS3D
|
|||
for i range 10
|
||||
// ife 0 1
|
||||
{
|
||||
ifkey numberkeys[i]
|
||||
ifholdkey numberkeys[i]
|
||||
{
|
||||
qsprintf TQUOTE 5 i
|
||||
quote TQUOTE
|
||||
}
|
||||
}
|
||||
|
||||
ifkey KEY_SPACE
|
||||
ifhitkey KEY_SPACE
|
||||
{
|
||||
ifn searchstat 3 break
|
||||
ifn sprite[searchwall].picnum SECTOREFFECTOR break
|
||||
set tmp 0
|
||||
ife sprite[searchwall].lotag 7 set tmp 1
|
||||
ife sprite[searchwall].lotag 17 set tmp 1
|
||||
ife tmp 0 break
|
||||
|
||||
for i allsprites
|
||||
{
|
||||
ifn i searchwall, ifactor SECTOREFFECTOR, ife sprite[i].lotag sprite[searchwall].lotag
|
||||
ife sprite[i].hitag sprite[searchwall].hitag
|
||||
{
|
||||
add posx sprite[i].x, sub posx sprite[searchwall].x
|
||||
add posy sprite[i].y, sub posy sprite[searchwall].y
|
||||
add posz sprite[i].z, sub posz sprite[searchwall].z
|
||||
|
||||
updatecursectnum
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ifholdkey KEY_0
|
||||
// ife 0 1
|
||||
{
|
||||
ifeithershift sub davr 512 else add davr 512
|
||||
|
|
|
@ -89,8 +89,8 @@ enum GameEvent_t {
|
|||
EVENT_ANALYZESPRITES,
|
||||
EVENT_INSERTSPRITE2D,
|
||||
EVENT_INSERTSPRITE3D,
|
||||
EVENT_DRAW2DSCREEN, // must be 4
|
||||
// EVENT_KEYS2D,
|
||||
EVENT_DRAW2DSCREEN,
|
||||
EVENT_KEYS2D,
|
||||
EVENT_KEYS3D,
|
||||
EVENT_OVERHEADEDITOR,
|
||||
MAXEVENTS
|
||||
|
@ -163,6 +163,8 @@ extern int32_t g_gameArrayCount, g_systemArrayCount;
|
|||
extern uint32_t m32_drawlinepat;
|
||||
|
||||
|
||||
extern int32_t g_iReturnVar;
|
||||
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"
|
||||
|
|
|
@ -8198,7 +8198,7 @@ static void Keys2d(void)
|
|||
keystatus[KEYSC_J]=0;
|
||||
}
|
||||
|
||||
// X_OnEvent(EVENT_KEYS2D, -1);
|
||||
X_OnEvent(EVENT_KEYS2D, -1);
|
||||
|
||||
}// end key2d
|
||||
|
||||
|
|
|
@ -81,6 +81,8 @@ static int32_t statesinfo_allocsize = 512;
|
|||
static char tempbuf[2048];
|
||||
static char tlabel[MAXLABELLEN];
|
||||
|
||||
int32_t g_iReturnVar=0;
|
||||
int32_t m32_sortvar1, m32_sortvar2;
|
||||
int32_t g_iReturnVarID=-1; // var ID of "RETURN"
|
||||
int32_t g_iLoTagID=-1; // var ID of "LOTAG"
|
||||
int32_t g_iHiTagID=-1; // var ID of "HITAG"
|
||||
|
@ -252,6 +254,7 @@ const char *keyw[] =
|
|||
"getangle",
|
||||
"getincangle",
|
||||
|
||||
"sort",
|
||||
"for", // *
|
||||
|
||||
"ifvarl",
|
||||
|
@ -282,7 +285,8 @@ const char *keyw[] =
|
|||
"whilevarvarn",
|
||||
"whilevarvarl",
|
||||
|
||||
"ifkey",
|
||||
"ifhitkey",
|
||||
"ifholdkey",
|
||||
"ifrnd",
|
||||
"ifangdiffl",
|
||||
"ifspritepal",
|
||||
|
@ -306,6 +310,7 @@ const char *keyw[] =
|
|||
"dupsprite",
|
||||
"deletesprite",
|
||||
"lastwall",
|
||||
"updatecursectnum",
|
||||
"updatesector",
|
||||
"updatesectorz",
|
||||
"getzrange",
|
||||
|
@ -318,6 +323,7 @@ const char *keyw[] =
|
|||
"getceilzofslope",
|
||||
"getflorzofslope",
|
||||
"bsetsprite", // *
|
||||
"setfirstwall",
|
||||
"changespritestat",
|
||||
"changespritesect",
|
||||
"headspritestat",
|
||||
|
@ -642,7 +648,7 @@ static int32_t C_SkipComments(void)
|
|||
static inline int32_t ispecial(const char c)
|
||||
{
|
||||
if (c == ' ' || c == 0x0d || c == '(' || c == ')' ||
|
||||
c == ',' || c == ';' || (c == 0x0a && ++g_lineNumber))
|
||||
c == ',' || c == ';' || (c == 0x0a /*&& ++g_lineNumber*/))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
@ -687,11 +693,9 @@ static void C_GetNextLabelName(void)
|
|||
if (i < MAXLABELLEN-1)
|
||||
tlabel[i++] = *(textptr++);
|
||||
else
|
||||
i++, textptr++;
|
||||
textptr++;
|
||||
}
|
||||
|
||||
if (i >= MAXLABELLEN-1)
|
||||
i = MAXLABELLEN-1;
|
||||
tlabel[i] = 0;
|
||||
// if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1)
|
||||
// initprintf("%s:%d: debug: got label `%s'.\n",g_szScriptFileName,g_lineNumber,tlabel);
|
||||
|
@ -919,6 +923,14 @@ static void C_GetNextVarType(int32_t type)
|
|||
flags &= ~(MAXGAMEVARS<<2); // not an array
|
||||
flags |= (MAXGAMEVARS<<3);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((aGameArrays[id].dwFlags & GAMEARRAY_READONLY) && type&GAMEVAR_READONLY)
|
||||
{
|
||||
C_ReportError(ERROR_ARRAYREADONLY);
|
||||
g_numCompilerErrors++;
|
||||
}
|
||||
}
|
||||
|
||||
C_GetNextVarType(GAMEVAR_SPECIAL); // _SPECIAL signifies that we want only simple vars or a constant
|
||||
g_scriptPtr--;
|
||||
|
@ -977,7 +989,7 @@ static void C_GetNextVarType(int32_t type)
|
|||
else // simple gamevar
|
||||
*g_scriptPtr++ = (aridx<<16 | id | (lLabelID<<2) | flags);
|
||||
}
|
||||
else
|
||||
else // if (flags & (MAXGAMEVARS<<2))
|
||||
{
|
||||
if ((aridx & 0x0000FFFF) == MAXGAMEVARS) // constant
|
||||
*g_scriptPtr++ = (aridx | id | flags);
|
||||
|
@ -1593,6 +1605,32 @@ static int32_t C_ParseCommand(void)
|
|||
}
|
||||
return 0;
|
||||
|
||||
case CON_SORT:
|
||||
C_GetNextLabelName();
|
||||
i = GetGamearrayID(tlabel);
|
||||
if (i >= 0)
|
||||
{
|
||||
*g_scriptPtr++ = i;
|
||||
if (aGameArrays[i].dwFlags & GAMEARRAY_READONLY)
|
||||
{
|
||||
C_ReportError(ERROR_ARRAYREADONLY);
|
||||
g_numCompilerErrors++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
C_ReportError(ERROR_NOTAGAMEARRAY);
|
||||
g_numCompilerErrors++;
|
||||
}
|
||||
C_SkipComments();
|
||||
C_GetNextVar(); // element count to sort
|
||||
|
||||
if (C_GetKeyword() >= 0)
|
||||
{
|
||||
*g_scriptPtr++ = -1;
|
||||
return 0;
|
||||
}
|
||||
// fall-through
|
||||
case CON_STATE:
|
||||
C_GetNextLabelName();
|
||||
|
||||
|
@ -1602,7 +1640,6 @@ static int32_t C_ParseCommand(void)
|
|||
C_ReportError(ERROR_ISAKEYWORD);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (hash_find(&gamevarH, tlabel)>=0)
|
||||
{
|
||||
g_numCompilerWarnings++;
|
||||
|
@ -2230,7 +2267,10 @@ repeatcase:
|
|||
if (i >= 0)
|
||||
*g_scriptPtr++ = i;
|
||||
else
|
||||
{
|
||||
C_ReportError(ERROR_NOTAGAMEARRAY);
|
||||
g_numCompilerErrors++;
|
||||
}
|
||||
|
||||
C_SkipComments();// skip comments and whitespace
|
||||
if (*textptr != '[')
|
||||
|
@ -2254,9 +2294,20 @@ repeatcase:
|
|||
|
||||
i = GetGamearrayID(tlabel);
|
||||
if (i >= 0)
|
||||
{
|
||||
*g_scriptPtr++ = i;
|
||||
|
||||
if (aGameArrays[i].dwFlags & GAMEARRAY_READONLY)
|
||||
{
|
||||
C_ReportError(ERROR_ARRAYREADONLY);
|
||||
g_numCompilerErrors++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
C_ReportError(ERROR_NOTAGAMEARRAY);
|
||||
g_numCompilerErrors++;
|
||||
}
|
||||
|
||||
C_SkipComments();// skip comments and whitespace
|
||||
if (*textptr != '[')
|
||||
|
@ -2282,12 +2333,21 @@ repeatcase:
|
|||
case CON_RESIZEARRAY:
|
||||
C_GetNextLabelName();
|
||||
i = GetGamearrayID(tlabel);
|
||||
if (i > (-1))
|
||||
if (i >= 0)
|
||||
{
|
||||
*g_scriptPtr++ = i;
|
||||
if (tw==CON_RESIZEARRAY && (aGameArrays[i].dwFlags&(GAMEARRAY_TYPEMASK)))
|
||||
{
|
||||
C_ReportError(-1);
|
||||
initprintf("%s:%d: error: can't resize system array `%s'.\n",g_szScriptFileName,g_lineNumber,tlabel);
|
||||
g_numCompilerErrors++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
C_ReportError(ERROR_NOTAGAMEARRAY);
|
||||
g_numCompilerErrors++;
|
||||
}
|
||||
C_SkipComments();
|
||||
C_GetNextVar();
|
||||
return 0;
|
||||
|
@ -2302,7 +2362,10 @@ repeatcase:
|
|||
*g_scriptPtr++ = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
C_ReportError(ERROR_NOTAGAMEARRAY);
|
||||
g_numCompilerErrors++;
|
||||
}
|
||||
C_GetNextValue(LABEL_DEFINE);
|
||||
return 0;
|
||||
#endif
|
||||
|
@ -2503,7 +2566,8 @@ repeatcase:
|
|||
case CON_WHILEVARVARN:
|
||||
case CON_WHILEVARVARL:
|
||||
// ---
|
||||
case CON_IFKEY:
|
||||
case CON_IFHITKEY:
|
||||
case CON_IFHOLDKEY:
|
||||
case CON_IFRND:
|
||||
// vvv if* using current sprite
|
||||
case CON_IFANGDIFFL:
|
||||
|
@ -2607,6 +2671,9 @@ repeatcase:
|
|||
C_GetNextVarType(GAMEVAR_READONLY);
|
||||
break;
|
||||
|
||||
case CON_UPDATECURSECTNUM:
|
||||
return 0;
|
||||
|
||||
case CON_UPDATESECTOR:
|
||||
case CON_UPDATESECTORZ:
|
||||
C_GetManyVars(2);
|
||||
|
@ -2657,6 +2724,7 @@ repeatcase:
|
|||
C_GetManyVars(4);
|
||||
break;
|
||||
|
||||
case CON_SETFIRSTWALL:
|
||||
case CON_CHANGESPRITESTAT:
|
||||
case CON_CHANGESPRITESECT:
|
||||
case CON_HEADSPRITESTAT:
|
||||
|
@ -2967,7 +3035,7 @@ static void C_AddDefaultDefinitions(void)
|
|||
C_AddDefinition("EVENT_INSERTSPRITE2D", EVENT_INSERTSPRITE2D, LABEL_EVENT);
|
||||
C_AddDefinition("EVENT_INSERTSPRITE3D", EVENT_INSERTSPRITE3D, LABEL_EVENT);
|
||||
C_AddDefinition("EVENT_DRAW2DSCREEN", EVENT_DRAW2DSCREEN, LABEL_EVENT);
|
||||
// C_AddDefinition("EVENT_KEYS2D", EVENT_KEYS2D, LABEL_EVENT);
|
||||
C_AddDefinition("EVENT_KEYS2D", EVENT_KEYS2D, LABEL_EVENT);
|
||||
C_AddDefinition("EVENT_KEYS3D", EVENT_KEYS3D, LABEL_EVENT);
|
||||
C_AddDefinition("EVENT_OVERHEADEDITOR", EVENT_OVERHEADEDITOR, LABEL_EVENT);
|
||||
|
||||
|
@ -3371,6 +3439,10 @@ void C_ReportError(int32_t iError)
|
|||
initprintf("%s:%d: error: variable `%s' is read-only.\n",
|
||||
g_szScriptFileName, g_lineNumber, tlabel);
|
||||
break;
|
||||
case ERROR_ARRAYREADONLY:
|
||||
initprintf("%s:%d: error: array `%s' is read-only.\n",
|
||||
g_szScriptFileName, g_lineNumber, tlabel);
|
||||
break;
|
||||
case ERROR_VARTYPEMISMATCH:
|
||||
initprintf("%s:%d: error: variable `%s' is of the wrong type.\n",
|
||||
g_szScriptFileName, g_lineNumber, tlabel);
|
||||
|
|
|
@ -124,6 +124,7 @@ enum ScriptError_t
|
|||
ERROR_SYMBOLNOTRECOGNIZED,
|
||||
ERROR_SYNTAXERROR,
|
||||
ERROR_VARREADONLY,
|
||||
ERROR_ARRAYREADONLY,
|
||||
ERROR_VARTYPEMISMATCH,
|
||||
ERROR_LABELINUSE,
|
||||
// WARNING_BADGAMEVAR,
|
||||
|
@ -314,6 +315,7 @@ enum ScriptKeywords_t
|
|||
CON_GETANGLE,
|
||||
CON_GETINCANGLE,
|
||||
|
||||
CON_SORT,
|
||||
CON_FOR,
|
||||
|
||||
// if & while var
|
||||
|
@ -347,7 +349,8 @@ enum ScriptKeywords_t
|
|||
CON_WHILEVARVARL,
|
||||
|
||||
// other if*
|
||||
CON_IFKEY,
|
||||
CON_IFHITKEY,
|
||||
CON_IFHOLDKEY,
|
||||
CON_IFRND,
|
||||
|
||||
// if* using current sprite
|
||||
|
@ -382,6 +385,7 @@ enum ScriptKeywords_t
|
|||
CON_DUPSPRITE,
|
||||
CON_DELETESPRITE,
|
||||
CON_LASTWALL,
|
||||
CON_UPDATECURSECTNUM,
|
||||
CON_UPDATESECTOR,
|
||||
CON_UPDATESECTORZ,
|
||||
CON_GETZRANGE,
|
||||
|
@ -394,6 +398,7 @@ enum ScriptKeywords_t
|
|||
CON_GETCEILZOFSLOPE,
|
||||
CON_GETFLORZOFSLOPE,
|
||||
CON_BSETSPRITE, // was CON_SETSPRITE
|
||||
CON_SETFIRSTWALL,
|
||||
CON_CHANGESPRITESTAT,
|
||||
CON_CHANGESPRITESECT,
|
||||
CON_HEADSPRITESTAT,
|
||||
|
|
|
@ -52,6 +52,7 @@ uint32_t m32_drawlinepat=0xffffffff;
|
|||
|
||||
instype *insptr;
|
||||
int32_t X_DoExecute(int32_t once);
|
||||
static instype *x_sortingstateptr;
|
||||
|
||||
#include "m32structures.c"
|
||||
|
||||
|
@ -146,7 +147,10 @@ void X_OnEvent(register int32_t iEventID, register int32_t iActor)
|
|||
X_DoExecute(0);
|
||||
|
||||
if (vm.g_errorFlag)
|
||||
{
|
||||
aEventEnabled[iEventID] = 0;
|
||||
message("ERROR executing %s. Event disabled.", label+(iEventID*MAXLABELLEN));
|
||||
}
|
||||
|
||||
// restore old values...
|
||||
Bmemcpy(&vm, &vm_backup, sizeof(vmstate_t));
|
||||
|
@ -195,6 +199,20 @@ static inline void __fastcall X_DoConditional(register int32_t condition)
|
|||
}
|
||||
}
|
||||
|
||||
static int32_t X_DoSortDefault(const int32_t *lv, const int32_t *rv)
|
||||
{
|
||||
return (*rv - *lv);
|
||||
}
|
||||
|
||||
static int32_t X_DoSort(const int32_t *lv, const int32_t *rv)
|
||||
{
|
||||
m32_sortvar1 = *lv;
|
||||
m32_sortvar2 = *rv;
|
||||
insptr = x_sortingstateptr;
|
||||
X_DoExecute(0);
|
||||
return g_iReturnVar;
|
||||
}
|
||||
|
||||
#define X_ERROR_INVALIDCI() \
|
||||
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))) \
|
||||
|
@ -273,12 +291,13 @@ skip_check:
|
|||
case CON_STATE:
|
||||
{
|
||||
instype *tempscrptr = insptr+2;
|
||||
int32_t stateidx = *(insptr+1), o_g_st = vm.g_st;
|
||||
int32_t stateidx = *(insptr+1), o_g_st = vm.g_st, oret=vm.g_returnFlag;
|
||||
|
||||
insptr = script + statesinfo[stateidx].ofs;
|
||||
vm.g_st = 1+MAXEVENTS+stateidx;
|
||||
X_DoExecute(0);
|
||||
vm.g_st = o_g_st;
|
||||
vm.g_returnFlag = oret;
|
||||
insptr = tempscrptr;
|
||||
}
|
||||
continue;
|
||||
|
@ -356,7 +375,7 @@ skip_check:
|
|||
// //AddLog("No Matching Case: No Default to use");
|
||||
// }
|
||||
}
|
||||
insptr = (instype *)(script + lEnd);
|
||||
insptr = (instype *)(lCodeInsPtr + lEnd);
|
||||
//Bsprintf(g_szBuf,"insptr=%d. ", (int32_t)insptr); AddLog(g_szBuf);
|
||||
//AddLog("Done Processing Switch");
|
||||
continue;
|
||||
|
@ -489,7 +508,8 @@ skip_check:
|
|||
insptr++;
|
||||
{
|
||||
int32_t j=*insptr++;
|
||||
Gv_SetVarX(*insptr++,aGameArrays[j].size);
|
||||
Gv_SetVarX(*insptr++, (aGameArrays[j].dwFlags&GAMEARRAY_VARSIZE) ?
|
||||
Gv_GetVarN(aGameArrays[j].size) : aGameArrays[j].size);
|
||||
}
|
||||
continue;
|
||||
|
||||
|
@ -498,6 +518,7 @@ skip_check:
|
|||
{
|
||||
int32_t j=*insptr++;
|
||||
int32_t asize = Gv_GetVarX(*insptr++);
|
||||
|
||||
if (asize<=0 || asize>65536)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Invalid array size %d (max: 65536)\n",g_errorLineNum,keyw[g_tw]);
|
||||
|
@ -1043,6 +1064,36 @@ skip_check:
|
|||
continue;
|
||||
}
|
||||
|
||||
case CON_SORT:
|
||||
insptr++;
|
||||
{
|
||||
int32_t aridx=*insptr++, count=Gv_GetVarX(*insptr++), state=*insptr++;
|
||||
int32_t o_g_st=vm.g_st;
|
||||
instype *end=insptr;
|
||||
|
||||
if (count<=0) continue;
|
||||
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);
|
||||
vm.g_errorFlag = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (state < 0)
|
||||
{
|
||||
qsort(aGameArrays[aridx].vals, count, sizeof(int32_t), (int32_t(*)(const void*,const void*))X_DoSortDefault);
|
||||
}
|
||||
else
|
||||
{
|
||||
x_sortingstateptr = script + statesinfo[state].ofs;
|
||||
vm.g_st = 1+MAXEVENTS+state;
|
||||
qsort(aGameArrays[aridx].vals, count, sizeof(int32_t), (int32_t(*)(const void*,const void*))X_DoSort);
|
||||
vm.g_st = o_g_st;
|
||||
insptr = end;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
|
||||
case CON_FOR: // special-purpose iteration
|
||||
insptr++;
|
||||
{
|
||||
|
@ -1251,7 +1302,8 @@ badindex:
|
|||
X_DoConditional(rnd(Gv_GetVarX(*(++insptr))));
|
||||
continue;
|
||||
|
||||
case CON_IFKEY:
|
||||
case CON_IFHITKEY:
|
||||
case CON_IFHOLDKEY:
|
||||
insptr++;
|
||||
{
|
||||
int32_t key=Gv_GetVarX(*insptr);
|
||||
|
@ -1263,9 +1315,13 @@ badindex:
|
|||
}
|
||||
X_DoConditional(keystatus[key]);
|
||||
|
||||
if ((key>=KEYSC_1 && key<=KEYSC_ENTER) || (key>=KEYSC_A && key<=KEYSC_BQUOTE)
|
||||
|| (key>=KEYSC_BSLASH && key<=KEYSC_SLASH))
|
||||
keystatus[key] = 0;
|
||||
if (tw==CON_IFHITKEY)
|
||||
{
|
||||
if (!(key==0 || key==KEYSC_ESC || key==KEYSC_TILDE || key==KEYSC_gENTER ||
|
||||
key==KEYSC_LALT || key==KEYSC_RALT || key==KEYSC_LCTRL || key==KEYSC_RCTRL ||
|
||||
key==KEYSC_LSHIFT || key==KEYSC_RSHIFT))
|
||||
keystatus[key] = 0;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
|
||||
|
@ -1623,6 +1679,21 @@ badindex:
|
|||
}
|
||||
|
||||
// CURSPR
|
||||
case CON_SETFIRSTWALL:
|
||||
insptr++;
|
||||
{
|
||||
int32_t sect=Gv_GetVarX(*insptr++), wal=Gv_GetVarX(*insptr++);
|
||||
|
||||
X_ERROR_INVALIDSECT(sect);
|
||||
setfirstwall(sect, wal);
|
||||
}
|
||||
continue;
|
||||
|
||||
case CON_UPDATECURSECTNUM:
|
||||
insptr++;
|
||||
updatesectorz(pos.x, pos.y, pos.z, &cursectnum);
|
||||
continue;
|
||||
|
||||
case CON_UPDATESECTOR:
|
||||
case CON_UPDATESECTORZ:
|
||||
insptr++;
|
||||
|
|
|
@ -76,7 +76,7 @@ int32_t Gv_NewArray(const char *pszLabel, void *arrayptr, intptr_t asize, uint32
|
|||
{
|
||||
g_numCompilerErrors++;
|
||||
C_ReportError(-1);
|
||||
initprintf("%s:%d: error: too many arrays!\n",g_szScriptFileName,g_lineNumber);
|
||||
initprintf("%s:%d: error: too many arrays! (max: %d)\n",g_szScriptFileName,g_lineNumber, MAXGAMEARRAYS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,13 @@ int32_t Gv_NewArray(const char *pszLabel, void *arrayptr, intptr_t asize, uint32
|
|||
if (i>=0 && !(aGameArrays[i].dwFlags & GAMEARRAY_RESET))
|
||||
{
|
||||
// found it it's a duplicate in error
|
||||
// g_numCompilerWarnings++;
|
||||
|
||||
if (aGameArrays[i].dwFlags&GAMEARRAY_TYPEMASK)
|
||||
{
|
||||
g_numCompilerWarnings++;
|
||||
C_ReportError(-1);
|
||||
initprintf("%s:%d: warning: didn't redefine system array `%s'.\n",g_szScriptFileName,g_lineNumber,pszLabel);
|
||||
}
|
||||
// C_ReportError(WARNING_DUPLICATEDEFINITION);
|
||||
return 0;
|
||||
}
|
||||
|
@ -508,7 +514,7 @@ static void Gv_AddSystemVars(void)
|
|||
Gv_NewVar("tsprite", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
||||
|
||||
g_iReturnVarID = g_gameVarCount;
|
||||
Gv_NewVar("RETURN", 0, GAMEVAR_SYSTEM);
|
||||
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;
|
||||
|
@ -593,6 +599,10 @@ static void Gv_AddSystemVars(void)
|
|||
Gv_NewVar("midydim16", (intptr_t)&midydim16, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
|
||||
Gv_NewVar("ydim16",(intptr_t)&ydim16, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_READONLY);
|
||||
|
||||
Gv_NewVar("SV1",(intptr_t)&m32_sortvar1, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_READONLY);
|
||||
Gv_NewVar("SV2",(intptr_t)&m32_sortvar2, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_READONLY);
|
||||
Gv_NewVar("spritesortcnt",(intptr_t)&spritesortcnt, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_READONLY);
|
||||
|
||||
g_systemVarCount = g_gameVarCount;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue