mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-16 01:11:44 +00:00
Switch VM_EventCommon to use references
git-svn-id: https://svn.eduke32.com/eduke32@7205 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
3b7f41e2bb
commit
0d652ae063
6 changed files with 56 additions and 59 deletions
|
@ -606,7 +606,7 @@ void A_DeleteSprite(int spriteNum)
|
|||
int32_t playerDist;
|
||||
int playerNum = A_FindPlayer(&sprite[spriteNum], &playerDist);
|
||||
|
||||
if (VM_OnEventWithDist_(EVENT_KILLIT, spriteNum, playerNum, playerDist))
|
||||
if (VM_OnEventWithDist__(EVENT_KILLIT, spriteNum, playerNum, playerDist))
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -8392,7 +8392,7 @@ static void G_DoEventGame(int const nEventID)
|
|||
|
||||
int32_t playerDist;
|
||||
int const playerNum = A_FindPlayer(&sprite[spriteNum], &playerDist);
|
||||
VM_OnEventWithDist_(nEventID, spriteNum, playerNum, playerDist);
|
||||
VM_OnEventWithDist__(nEventID, spriteNum, playerNum, playerDist);
|
||||
|
||||
spriteNum = nextSprite;
|
||||
}
|
||||
|
|
|
@ -1323,7 +1323,7 @@ int32_t A_InsertSprite(int16_t whatsect,int32_t s_x,int32_t s_y,int32_t s_z,int1
|
|||
int32_t p, pl = A_FindPlayer(s, &p);
|
||||
|
||||
block_deletesprite++;
|
||||
VM_OnEventWithDist_(EVENT_EGS, i, pl, p);
|
||||
VM_OnEventWithDist__(EVENT_EGS, i, pl, p);
|
||||
block_deletesprite--;
|
||||
}
|
||||
|
||||
|
@ -3411,7 +3411,7 @@ SPAWN_END:
|
|||
{
|
||||
int32_t p;
|
||||
int32_t pl=A_FindPlayer(&sprite[newSprite],&p);
|
||||
VM_OnEventWithDist_(EVENT_SPAWN,newSprite, pl, p);
|
||||
VM_OnEventWithDist__(EVENT_SPAWN,newSprite, pl, p);
|
||||
}
|
||||
|
||||
return newSprite;
|
||||
|
@ -3537,7 +3537,7 @@ static inline void G_DoEventAnimSprites(int tspriteNum)
|
|||
return;
|
||||
|
||||
spriteext[tsprOwner].tspr = &tsprite[tspriteNum];
|
||||
VM_OnEvent_(EVENT_ANIMATESPRITES, tsprOwner, screenpeek);
|
||||
VM_OnEvent__(EVENT_ANIMATESPRITES, tsprOwner, screenpeek);
|
||||
spriteext[tsprOwner].tspr = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ static int32_t g_checkingIfElse, g_processingState, g_lastKeyword = -1;
|
|||
static intptr_t *g_caseScriptPtr;
|
||||
static intptr_t previous_event;
|
||||
static int32_t g_numCases = 0, g_checkingCase = 0;
|
||||
static int32_t g_checkingSwitch = 0, g_currentEvent = -1;
|
||||
static int32_t g_checkingSwitch = 0;
|
||||
static int32_t g_labelsOnly = 0, g_dynamicTileMapping = 0, g_dynamicSoundMapping = 0;
|
||||
static int32_t g_numBraces = 0;
|
||||
|
||||
|
@ -779,10 +779,10 @@ const char *EventNames[MAXEVENTS] =
|
|||
};
|
||||
|
||||
#if !defined LUNATIC
|
||||
#define LABEL_SETUP_UNMATCHED(struct, memb, name, idx) \
|
||||
{ \
|
||||
name, idx, sizeof(struct[0].memb) | (is_unsigned <decltype(struct[0].memb)>::value ? LABEL_UNSIGNED : 0), 0, \
|
||||
offsetof(std::remove_pointer <decltype(&struct[0])>::type, memb) \
|
||||
#define LABEL_SETUP_UNMATCHED(struct, memb, name, idx) \
|
||||
{ \
|
||||
name, idx, sizeof(struct[0].memb) | (is_unsigned<decltype(struct[0].memb)>::value ? LABEL_UNSIGNED : 0), 0, \
|
||||
offsetof(std::remove_pointer<decltype(&struct[0])>::type, memb) \
|
||||
}
|
||||
|
||||
#define LABEL_SETUP(struct, memb, idx) LABEL_SETUP_UNMATCHED(struct, memb, #memb, idx)
|
||||
|
|
|
@ -48,7 +48,7 @@ vmstate_t vm;
|
|||
#if !defined LUNATIC
|
||||
int32_t g_tw;
|
||||
int32_t g_errorLineNum;
|
||||
int32_t g_currentEventExec = -1;
|
||||
int32_t g_currentEvent = -1;
|
||||
|
||||
intptr_t const *insptr;
|
||||
|
||||
|
@ -85,7 +85,7 @@ 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_currentEventExec == -1))
|
||||
if (!apScript || (!vm.pSprite && !vm.pPlayer && g_currentEvent == -1))
|
||||
return;
|
||||
|
||||
if (ptr)
|
||||
|
@ -134,7 +134,7 @@ intptr_t apScriptEvents[MAXEVENTS];
|
|||
|
||||
// May recurse, e.g. through EVENT_XXX -> ... -> EVENT_KILLIT
|
||||
#ifdef LUNATIC
|
||||
static FORCE_INLINE int32_t VM_EventCommon_(int eventNum, int spriteNum, int playerNum, int playerDist, int32_t returnValue)
|
||||
static FORCE_INLINE int32_t VM_EventCommon__(int const &eventNum, int const &spriteNum, int const &playerNum, int const &playerDist, int32_t returnValue)
|
||||
{
|
||||
const double t = timerGetHiTicks();
|
||||
int32_t ret = El_CallEvent(&g_ElState, eventNum, spriteNum, playerNum, playerDist, &returnValue);
|
||||
|
@ -161,20 +161,20 @@ static void VM_DummySprite(void)
|
|||
vm.pData = &dummy.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)
|
||||
static FORCE_INLINE int32_t VM_EventCommon__(int const &eventNum, int const &spriteNum, int const &playerNum, int const &playerDist, int32_t returnValue)
|
||||
{
|
||||
const double t = timerGetHiTicks();
|
||||
double const t = timerGetHiTicks();
|
||||
vmstate_t const tempvm = { spriteNum, playerNum, playerDist, 0, NULL, NULL, g_player[playerNum].ps, NULL };
|
||||
|
||||
const vmstate_t tempvm = { spriteNum, playerNum, playerDist, 0, NULL, NULL, g_player[playerNum].ps, NULL };
|
||||
auto & returnVar = aGameVars[g_returnVarID].global;
|
||||
int const backupReturnVar = returnVar;
|
||||
int const backupEvent = g_currentEvent;
|
||||
|
||||
int const backupReturnVar = aGameVars[g_returnVarID].global;
|
||||
int const backupEventExec = g_currentEventExec;
|
||||
returnVar = returnValue;
|
||||
g_currentEvent = eventNum;
|
||||
|
||||
aGameVars[g_returnVarID].global = returnValue;
|
||||
g_currentEventExec = eventNum;
|
||||
|
||||
intptr_t const *oinsptr = insptr;
|
||||
const vmstate_t vm_backup = vm;
|
||||
intptr_t const *backupinsptr = insptr;
|
||||
const vmstate_t vm_backup = vm;
|
||||
|
||||
insptr = apScript + apScriptEvents[eventNum];
|
||||
vm = tempvm;
|
||||
|
@ -201,12 +201,11 @@ static FORCE_INLINE int32_t VM_EventCommon_(int const eventNum, int const sprite
|
|||
// this needs to happen after VM_DeleteSprite() because VM_DeleteSprite()
|
||||
// can trigger additional events
|
||||
|
||||
vm = vm_backup;
|
||||
insptr = oinsptr;
|
||||
g_currentEventExec = backupEventExec;
|
||||
returnValue = aGameVars[g_returnVarID].global;
|
||||
|
||||
aGameVars[g_returnVarID].global = backupReturnVar;
|
||||
vm = vm_backup;
|
||||
insptr = backupinsptr;
|
||||
g_currentEvent = backupEvent;
|
||||
returnValue = returnVar;
|
||||
returnVar = backupReturnVar;
|
||||
|
||||
g_eventTotalMs[eventNum] += timerGetHiTicks()-t;
|
||||
g_eventCalls[eventNum]++;
|
||||
|
@ -219,34 +218,32 @@ static FORCE_INLINE int32_t VM_EventCommon_(int const eventNum, int const sprite
|
|||
// which are not only optimized further based on lDist or iReturn (or both) having values known at compile time,
|
||||
// but are called faster due to having less parameters
|
||||
|
||||
int32_t VM_OnEventWithBoth_(int const nEventID, int const spriteNum, int const playerNum, int const nDist, int32_t const nReturn)
|
||||
int32_t VM_OnEventWithBoth__(int const nEventID, int const spriteNum, int const playerNum, int const nDist, int32_t const nReturn)
|
||||
{
|
||||
return VM_EventCommon_(nEventID, spriteNum, playerNum, nDist, nReturn);
|
||||
return VM_EventCommon__(nEventID, spriteNum, playerNum, nDist, nReturn);
|
||||
}
|
||||
|
||||
int32_t VM_OnEventWithReturn_(int const nEventID, int const spriteNum, int const playerNum, int32_t const nReturn)
|
||||
int32_t VM_OnEventWithReturn__(int const nEventID, int const spriteNum, int const playerNum, int32_t const nReturn)
|
||||
{
|
||||
return VM_EventCommon_(nEventID, spriteNum, playerNum, -1, nReturn);
|
||||
return VM_EventCommon__(nEventID, spriteNum, playerNum, -1, nReturn);
|
||||
}
|
||||
|
||||
int32_t VM_OnEventWithDist_(int const nEventID, int const spriteNum, int const playerNum, int const nDist)
|
||||
int32_t VM_OnEventWithDist__(int const nEventID, int const spriteNum, int const playerNum, int const nDist)
|
||||
{
|
||||
return VM_EventCommon_(nEventID, spriteNum, playerNum, nDist, 0);
|
||||
return VM_EventCommon__(nEventID, spriteNum, playerNum, nDist, 0);
|
||||
}
|
||||
|
||||
int32_t VM_OnEvent_(int const nEventID, int const spriteNum, int const playerNum)
|
||||
int32_t VM_OnEvent__(int const nEventID, int const spriteNum, int const playerNum)
|
||||
{
|
||||
return VM_EventCommon_(nEventID, spriteNum, playerNum, -1, 0);
|
||||
return VM_EventCommon__(nEventID, spriteNum, playerNum, -1, 0);
|
||||
}
|
||||
|
||||
static int32_t VM_CheckSquished(void)
|
||||
static bool VM_CheckSquished(void)
|
||||
{
|
||||
usectortype const * const pSector = (usectortype *)§or[vm.pSprite->sectnum];
|
||||
auto const pSector = (usectortype *)§or[vm.pSprite->sectnum];
|
||||
|
||||
if (pSector->lotag == ST_23_SWINGING_DOOR ||
|
||||
(pSector->lotag == ST_1_ABOVE_WATER &&
|
||||
!A_CheckNoSE7Water((uspritetype const *)vm.pSprite, vm.pSprite->sectnum, pSector->lotag, NULL)) ||
|
||||
(vm.pSprite->picnum == APLAYER && ud.noclip))
|
||||
if (pSector->lotag == ST_23_SWINGING_DOOR || (vm.pSprite->picnum == APLAYER && ud.noclip) ||
|
||||
(pSector->lotag == ST_1_ABOVE_WATER && !A_CheckNoSE7Water((uspritetype const *)vm.pSprite, vm.pSprite->sectnum, pSector->lotag, NULL)))
|
||||
return 0;
|
||||
|
||||
int32_t floorZ = pSector->floorz;
|
||||
|
@ -6173,7 +6170,7 @@ void G_SaveMapState(void)
|
|||
|
||||
// If we're in EVENT_ANIMATESPRITES, we'll be saving pointer values to disk :-/
|
||||
#if !defined LUNATIC
|
||||
if (g_currentEventExec == EVENT_ANIMATESPRITES)
|
||||
if (g_currentEvent == EVENT_ANIMATESPRITES)
|
||||
initprintf("Line %d: savemapstate called from EVENT_ANIMATESPRITES. WHY?\n", g_errorLineNum);
|
||||
#endif
|
||||
Bmemcpy(&save->spriteext[0],&spriteext[0],sizeof(spriteext_t)*MAXSPRITES);
|
||||
|
@ -6312,7 +6309,7 @@ void G_RestoreMapState(void)
|
|||
// If we're restoring from EVENT_ANIMATESPRITES, all spriteext[].tspr
|
||||
// will be overwritten, so NULL them.
|
||||
#if !defined LUNATIC
|
||||
if (g_currentEventExec == EVENT_ANIMATESPRITES)
|
||||
if (g_currentEvent == EVENT_ANIMATESPRITES)
|
||||
{
|
||||
initprintf("Line %d: loadmapstate called from EVENT_ANIMATESPRITES. WHY?\n",g_errorLineNum);
|
||||
for (native_t i=0; i<MAXSPRITES; i++)
|
||||
|
|
|
@ -49,7 +49,7 @@ extern vmstate_t vm;
|
|||
#if !defined LUNATIC
|
||||
extern int32_t g_tw;
|
||||
extern int32_t g_errorLineNum;
|
||||
extern int32_t g_currentEventExec;
|
||||
extern int32_t g_currentEvent;
|
||||
|
||||
void A_LoadActor(int32_t spriteNum);
|
||||
#endif
|
||||
|
@ -75,12 +75,12 @@ void VM_DrawTileGeneric(int32_t x, int32_t y, int32_t zoom, int32_t tilenum,
|
|||
int32_t shade, int32_t orientation, int32_t p);
|
||||
#endif
|
||||
|
||||
int32_t VM_OnEventWithBoth_(int nEventID, int spriteNum, int playerNum, int nDist, int32_t nReturn);
|
||||
int32_t VM_OnEventWithReturn_(int nEventID, int spriteNum, int playerNum, int32_t nReturn);
|
||||
int32_t VM_OnEventWithDist_(int nEventID, int spriteNum, int playerNum, int nDist);
|
||||
int32_t VM_OnEvent_(int nEventID, int spriteNum, int playerNum);
|
||||
int32_t VM_OnEvent__(int nEventID, int spriteNum, int playerNum);
|
||||
int32_t VM_OnEventWithBoth__(int nEventID, int spriteNum, int playerNum, int nDist, int32_t nReturn);
|
||||
int32_t VM_OnEventWithDist__(int nEventID, int spriteNum, int playerNum, int nDist);
|
||||
int32_t VM_OnEventWithReturn__(int nEventID, int spriteNum, int playerNum, int32_t nReturn);
|
||||
|
||||
static FORCE_INLINE int VM_HaveEvent(int nEventID)
|
||||
static FORCE_INLINE bool VM_HaveEvent(int const nEventID)
|
||||
{
|
||||
#ifdef LUNATIC
|
||||
return L_IsInitialized(&g_ElState) && El_HaveEvent(nEventID);
|
||||
|
@ -89,24 +89,24 @@ static FORCE_INLINE int VM_HaveEvent(int nEventID)
|
|||
#endif
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t VM_OnEventWithBoth(int nEventID, int spriteNum, int playerNum, int nDist, int32_t nReturn)
|
||||
static FORCE_INLINE int32_t VM_OnEvent(int nEventID, int spriteNum, int playerNum)
|
||||
{
|
||||
return VM_HaveEvent(nEventID) ? VM_OnEventWithBoth_(nEventID, spriteNum, playerNum, nDist, nReturn) : nReturn;
|
||||
return VM_HaveEvent(nEventID) ? VM_OnEvent__(nEventID, spriteNum, playerNum) : 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t VM_OnEventWithReturn(int nEventID, int spriteNum, int playerNum, int nReturn)
|
||||
static FORCE_INLINE int32_t VM_OnEventWithBoth(int nEventID, int spriteNum, int playerNum, int nDist, int32_t nReturn)
|
||||
{
|
||||
return VM_HaveEvent(nEventID) ? VM_OnEventWithReturn_(nEventID, spriteNum, playerNum, nReturn) : nReturn;
|
||||
return VM_HaveEvent(nEventID) ? VM_OnEventWithBoth__(nEventID, spriteNum, playerNum, nDist, nReturn) : nReturn;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t VM_OnEventWithDist(int nEventID, int spriteNum, int playerNum, int nDist)
|
||||
{
|
||||
return VM_HaveEvent(nEventID) ? VM_OnEventWithDist_(nEventID, spriteNum, playerNum, nDist) : 0;
|
||||
return VM_HaveEvent(nEventID) ? VM_OnEventWithDist__(nEventID, spriteNum, playerNum, nDist) : 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t VM_OnEvent(int nEventID, int spriteNum, int playerNum)
|
||||
static FORCE_INLINE int32_t VM_OnEventWithReturn(int nEventID, int spriteNum, int playerNum, int nReturn)
|
||||
{
|
||||
return VM_HaveEvent(nEventID) ? VM_OnEvent_(nEventID, spriteNum, playerNum) : 0;
|
||||
return VM_HaveEvent(nEventID) ? VM_OnEventWithReturn__(nEventID, spriteNum, playerNum, nReturn) : nReturn;
|
||||
}
|
||||
|
||||
#define CON_ERRPRINTF(Text, ...) do { \
|
||||
|
|
|
@ -1250,7 +1250,7 @@ void G_DisplayRest(int32_t smoothratio)
|
|||
if (VM_HaveEvent(EVENT_DISPLAYREST))
|
||||
{
|
||||
int32_t vr=viewingrange, asp=yxaspect;
|
||||
VM_OnEvent_(EVENT_DISPLAYREST, g_player[screenpeek].ps->i, screenpeek);
|
||||
VM_OnEvent__(EVENT_DISPLAYREST, g_player[screenpeek].ps->i, screenpeek);
|
||||
renderSetAspect(vr, asp);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue