Rename VM_OnEvent to VM_OnEvent_ and add move the checks for whether the event is actually defined or not to a wrapper declared static inline

git-svn-id: https://svn.eduke32.com/eduke32@4673 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2014-10-25 03:33:53 +00:00
parent f15a25a144
commit 62f13fad76
2 changed files with 46 additions and 38 deletions

View file

@ -117,11 +117,9 @@ static void VM_KillIt(int32_t iActor, int32_t iPlayer)
} }
// May recurse, e.g. through EVENT_XXX -> ... -> EVENT_KILLIT // May recurse, e.g. through EVENT_XXX -> ... -> EVENT_KILLIT
int32_t VM_OnEvent(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lDist, int32_t iReturn) int32_t VM_OnEvent_(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lDist, int32_t iReturn)
{ {
#ifdef LUNATIC #ifdef LUNATIC
if (L_IsInitialized(&g_ElState) && El_HaveEvent(iEventID))
{
const double t = gethiticks(); const double t = gethiticks();
int32_t ret = El_CallEvent(&g_ElState, iEventID, iActor, iPlayer, lDist, &iReturn); int32_t ret = El_CallEvent(&g_ElState, iEventID, iActor, iPlayer, lDist, &iReturn);
@ -132,15 +130,11 @@ int32_t VM_OnEvent(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lD
if (ret == 1) if (ret == 1)
VM_KillIt(iActor, iPlayer); VM_KillIt(iActor, iPlayer);
}
#else #else
if (apScriptGameEvent[iEventID])
{
intptr_t *oinsptr=insptr; intptr_t *oinsptr=insptr;
vmstate_t vm_backup; vmstate_t vm_backup;
vmstate_t tempvm = { iActor, iPlayer, lDist, vmstate_t tempvm ={ iActor, iPlayer, lDist,
iActor >= 0 ? &actor[iActor].t_data[0] : NULL, iActor >= 0 ? &actor[iActor].t_data[0] : NULL,
iActor >= 0 ? &sprite[iActor] : NULL, iActor >= 0 ? &sprite[iActor] : NULL,
0 }; 0 };
@ -166,7 +160,6 @@ int32_t VM_OnEvent(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lD
g_currentEventExec = backupEventExec; g_currentEventExec = backupEventExec;
iReturn = aGameVars[g_iReturnVarID].val.lValue; iReturn = aGameVars[g_iReturnVarID].val.lValue;
aGameVars[g_iReturnVarID].val.lValue = backupReturnVar; aGameVars[g_iReturnVarID].val.lValue = backupReturnVar;
}
#endif #endif
return iReturn; return iReturn;

View file

@ -152,7 +152,22 @@ void A_GetZLimits(int32_t iActor);
int32_t G_GetAngleDelta(int32_t a,int32_t na); int32_t G_GetAngleDelta(int32_t a,int32_t na);
void G_RestoreMapState(); void G_RestoreMapState();
void G_SaveMapState(); void G_SaveMapState();
int32_t VM_OnEvent(int32_t iEventID,int32_t iActor,int32_t iPlayer,int32_t lDist, int32_t iReturn);
int32_t VM_OnEvent_(int32_t iEventID,int32_t iActor,int32_t iPlayer,int32_t lDist, int32_t iReturn);
static inline int32_t VM_OnEvent(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lDist, int32_t iReturn)
{
#ifdef LUNATIC
if (!L_IsInitialized(&g_ElState) || !El_HaveEvent(iEventID))
return iReturn;
#else
if (!apScriptGameEvent[iEventID])
return iReturn;
#endif
return VM_OnEvent_(iEventID, iActor, iPlayer, lDist, iReturn);
}
void VM_ScriptInfo(void); void VM_ScriptInfo(void);
#define CON_ERRPRINTF(Text, ...) do { \ #define CON_ERRPRINTF(Text, ...) do { \