mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-16 09:21:36 +00:00
C-CON: Enumify quick structure access.
git-svn-id: https://svn.eduke32.com/eduke32@5087 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
4682da7a22
commit
5c8a2e3ea6
4 changed files with 55 additions and 43 deletions
|
@ -1628,7 +1628,7 @@ static void C_GetNextVarType(int32_t type)
|
|||
if (i < 0)
|
||||
{
|
||||
i=GetDefID(label+(g_numLabels<<6));
|
||||
if (i < g_iSpriteVarID || i > g_iActorVarID)
|
||||
if ((unsigned) (i - g_iStructVarIDs) >= NUMQUICKSTRUCTS)
|
||||
i = -1;
|
||||
|
||||
if (EDUKE32_PREDICT_FALSE(i < 0))
|
||||
|
@ -1686,16 +1686,24 @@ static void C_GetNextVarType(int32_t type)
|
|||
C_GetNextLabelName();
|
||||
/*initprintf("found xxx label of \"%s\"\n", label+(g_numLabels<<6));*/
|
||||
|
||||
if (i == g_iSpriteVarID)
|
||||
switch (i - g_iStructVarIDs)
|
||||
{
|
||||
case STRUCT_SPRITE:
|
||||
lLabelID=C_GetLabelNameOffset(&actorH,Bstrtolower(label+(g_numLabels<<6)));
|
||||
else if (i == g_iSectorVarID)
|
||||
break;
|
||||
case STRUCT_SECTOR:
|
||||
lLabelID=C_GetLabelNameOffset(§orH,Bstrtolower(label+(g_numLabels<<6)));
|
||||
else if (i == g_iWallVarID)
|
||||
break;
|
||||
case STRUCT_WALL:
|
||||
lLabelID=C_GetLabelNameOffset(&wallH,Bstrtolower(label+(g_numLabels<<6)));
|
||||
else if (i == g_iPlayerVarID)
|
||||
break;
|
||||
case STRUCT_PLAYER:
|
||||
lLabelID=C_GetLabelNameOffset(&playerH,Bstrtolower(label+(g_numLabels<<6)));
|
||||
else if (i == g_iActorVarID)
|
||||
break;
|
||||
case STRUCT_ACTORVAR:
|
||||
lLabelID=GetDefID(label+(g_numLabels<<6));
|
||||
break;
|
||||
}
|
||||
|
||||
//printf("LabelID is %d\n",lLabelID);
|
||||
if (EDUKE32_PREDICT_FALSE(lLabelID == -1))
|
||||
|
@ -1707,8 +1715,9 @@ static void C_GetNextVarType(int32_t type)
|
|||
|
||||
bitptr[(g_scriptPtr-script)>>3] &= ~(BITPTR_POINTER<<((g_scriptPtr-script)&7));
|
||||
|
||||
if (i == g_iSpriteVarID)
|
||||
switch (i - g_iStructVarIDs)
|
||||
{
|
||||
case STRUCT_SPRITE:
|
||||
*g_scriptPtr++=ActorLabels[lLabelID].lId;
|
||||
|
||||
//printf("member's flags are: %02Xh\n",ActorLabels[lLabelID].flags);
|
||||
|
@ -1719,13 +1728,14 @@ static void C_GetNextVarType(int32_t type)
|
|||
// get the ID of the DEF
|
||||
C_GetNextVarType(0);
|
||||
}
|
||||
}
|
||||
else if (i == g_iSectorVarID)
|
||||
break;
|
||||
case STRUCT_SECTOR:
|
||||
*g_scriptPtr++=SectorLabels[lLabelID].lId;
|
||||
else if (i == g_iWallVarID)
|
||||
*g_scriptPtr++=SectorLabels[lLabelID].lId;
|
||||
else if (i == g_iPlayerVarID)
|
||||
{
|
||||
break;
|
||||
case STRUCT_WALL:
|
||||
*g_scriptPtr++=WallLabels[lLabelID].lId;
|
||||
break;
|
||||
case STRUCT_PLAYER:
|
||||
*g_scriptPtr++=PlayerLabels[lLabelID].lId;
|
||||
|
||||
//printf("member's flags are: %02Xh\n",ActorLabels[lLabelID].flags);
|
||||
|
@ -1736,9 +1746,11 @@ static void C_GetNextVarType(int32_t type)
|
|||
// get the ID of the DEF
|
||||
C_GetNextVarType(0);
|
||||
}
|
||||
}
|
||||
else if (i == g_iActorVarID)
|
||||
break;
|
||||
case STRUCT_ACTORVAR:
|
||||
*g_scriptPtr++=lLabelID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -55,11 +55,18 @@ 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 "THISACTOR"
|
||||
extern int32_t g_iSpriteVarID;
|
||||
extern int32_t g_iSectorVarID;
|
||||
extern int32_t g_iWallVarID;
|
||||
extern int32_t g_iPlayerVarID;
|
||||
extern int32_t g_iActorVarID;
|
||||
|
||||
// KEEPINSYNC gamevars.c: "special vars for struct access"
|
||||
enum QuickStructureAccess_t {
|
||||
STRUCT_SPRITE,
|
||||
STRUCT_SECTOR,
|
||||
STRUCT_WALL,
|
||||
STRUCT_PLAYER,
|
||||
STRUCT_ACTORVAR,
|
||||
NUMQUICKSTRUCTS,
|
||||
};
|
||||
|
||||
extern int32_t g_iStructVarIDs;
|
||||
|
||||
extern intptr_t *apScriptGameEvent[MAXGAMEEVENTS];
|
||||
#endif
|
||||
|
|
|
@ -76,11 +76,7 @@ int32_t g_iLoTagID = -1; // var ID of "LOTAG"
|
|||
int32_t g_iHiTagID = -1; // var ID of "HITAG"
|
||||
int32_t g_iTextureID = -1; // var ID of "TEXTURE"
|
||||
int32_t g_iThisActorID = -1; // var ID of "THISACTOR"
|
||||
int32_t g_iSpriteVarID = -1;
|
||||
int32_t g_iSectorVarID = -1;
|
||||
int32_t g_iWallVarID = -1;
|
||||
int32_t g_iPlayerVarID = -1;
|
||||
int32_t g_iActorVarID = -1;
|
||||
int32_t g_iStructVarIDs = -1;
|
||||
|
||||
GAMEEXEC_STATIC void VM_Execute(int32_t loop);
|
||||
|
||||
|
@ -3927,7 +3923,7 @@ finish_qsprintf:
|
|||
else if (*insptr&(MAXGAMEVARS<<3))
|
||||
{
|
||||
// FIXME FIXME FIXME
|
||||
if ((lVarID & (MAXGAMEVARS-1)) == g_iActorVarID)
|
||||
if ((lVarID & (MAXGAMEVARS-1)) == g_iStructVarIDs + STRUCT_ACTORVAR)
|
||||
{
|
||||
intptr_t const *oinsptr = insptr++;
|
||||
int32_t index = Gv_GetVarX(*insptr++);
|
||||
|
|
|
@ -653,9 +653,9 @@ nastyhacks:
|
|||
int indexvar = *insptr;
|
||||
int32_t index=Gv_GetVar(*insptr++, iActor, iPlayer);
|
||||
|
||||
switch ((id&(MAXGAMEVARS-1)) - g_iSpriteVarID)
|
||||
switch ((id&(MAXGAMEVARS-1)) - g_iStructVarIDs)
|
||||
{
|
||||
case 0: //if (id == g_iSpriteVarID)
|
||||
case STRUCT_SPRITE:
|
||||
{
|
||||
int const label = *insptr++;
|
||||
|
||||
|
@ -673,7 +673,7 @@ nastyhacks:
|
|||
break;
|
||||
}
|
||||
|
||||
case 3: //else if (id == g_iPlayerVarID)
|
||||
case STRUCT_PLAYER:
|
||||
{
|
||||
int const label = *insptr++;
|
||||
|
||||
|
@ -692,11 +692,11 @@ nastyhacks:
|
|||
break;
|
||||
}
|
||||
|
||||
case 4: //else if (id == g_iActorVarID)
|
||||
case STRUCT_ACTORVAR:
|
||||
rv = Gv_GetVar(*insptr++, index, iPlayer);
|
||||
break;
|
||||
|
||||
case 1: //else if (id == g_iSectorVarID)
|
||||
case STRUCT_SECTOR:
|
||||
if (indexvar == g_iThisActorID) index = sprite[vm.g_i].sectnum;
|
||||
if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXSECTORS))
|
||||
{
|
||||
|
@ -707,7 +707,7 @@ nastyhacks:
|
|||
rv = VM_GetSector(index, *insptr++);
|
||||
break;
|
||||
|
||||
case 2: //else if (id == g_iWallVarID)
|
||||
case STRUCT_WALL:
|
||||
if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXWALLS))
|
||||
{
|
||||
iPlayer = index;
|
||||
|
@ -840,9 +840,9 @@ int32_t __fastcall Gv_GetSpecialVarX(int32_t id)
|
|||
int indexvar = *insptr;
|
||||
int index = Gv_GetVarX(*insptr++);
|
||||
|
||||
switch ((id & (MAXGAMEVARS - 1)) - g_iSpriteVarID)
|
||||
switch ((id & (MAXGAMEVARS - 1)) - g_iStructVarIDs)
|
||||
{
|
||||
case 0: // if (id == g_iSpriteVarID)
|
||||
case STRUCT_SPRITE:
|
||||
{
|
||||
int const label = *insptr++;
|
||||
|
||||
|
@ -861,7 +861,7 @@ int32_t __fastcall Gv_GetSpecialVarX(int32_t id)
|
|||
break;
|
||||
}
|
||||
|
||||
case 3: // else if (id == g_iPlayerVarID)
|
||||
case STRUCT_PLAYER:
|
||||
{
|
||||
int const label = *insptr++;
|
||||
|
||||
|
@ -882,11 +882,11 @@ int32_t __fastcall Gv_GetSpecialVarX(int32_t id)
|
|||
break;
|
||||
}
|
||||
|
||||
case 4: // else if (id == g_iActorVarID)
|
||||
case STRUCT_ACTORVAR:
|
||||
rv = Gv_GetVar(*insptr++, index, vm.g_p);
|
||||
break;
|
||||
|
||||
case 1: // else if (id == g_iSectorVarID)
|
||||
case STRUCT_SECTOR:
|
||||
if (indexvar == g_iThisActorID)
|
||||
index = sprite[vm.g_i].sectnum;
|
||||
|
||||
|
@ -900,7 +900,7 @@ int32_t __fastcall Gv_GetSpecialVarX(int32_t id)
|
|||
rv = VM_GetSector(index, *insptr++);
|
||||
break;
|
||||
|
||||
case 2: // else if (id == g_iWallVarID)
|
||||
case STRUCT_WALL:
|
||||
if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXWALLS))
|
||||
{
|
||||
id = index;
|
||||
|
@ -1140,11 +1140,7 @@ void Gv_ResetSystemDefaults(void)
|
|||
g_iTextureID = Gv_GetVarIndex("TEXTURE");
|
||||
g_iThisActorID = Gv_GetVarIndex("THISACTOR");
|
||||
|
||||
g_iSpriteVarID = Gv_GetVarIndex("sprite");
|
||||
g_iSectorVarID = Gv_GetVarIndex("sector");
|
||||
g_iWallVarID = Gv_GetVarIndex("wall");
|
||||
g_iPlayerVarID = Gv_GetVarIndex("player");
|
||||
g_iActorVarID = Gv_GetVarIndex("actorvar");
|
||||
g_iStructVarIDs = Gv_GetVarIndex("sprite");
|
||||
#endif
|
||||
|
||||
for (int i = 0; i <= MAXTILES - 1; i++)
|
||||
|
@ -1467,6 +1463,7 @@ static void Gv_AddSystemVars(void)
|
|||
Gv_NewVar("THISACTOR", 0, GAMEVAR_READONLY | GAMEVAR_SYSTEM);
|
||||
|
||||
// special vars for struct access
|
||||
// KEEPINSYNC gamedef.h: enum QuickStructureAccess_t
|
||||
Gv_NewVar("sprite", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
||||
Gv_NewVar("sector", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
||||
Gv_NewVar("wall", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
||||
|
|
Loading…
Reference in a new issue