mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 18:50:47 +00:00
Use function overloading to clean up some of the CON event execution function names
git-svn-id: https://svn.eduke32.com/eduke32@7636 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
078ef9b871
commit
562e6f419c
6 changed files with 61 additions and 60 deletions
|
@ -647,7 +647,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_ExecuteEvent(EVENT_KILLIT, spriteNum, playerNum, playerDist))
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -811,7 +811,7 @@ void A_MoveSector(int spriteNum)
|
|||
int32_t playerDist;
|
||||
spritetype *const pSprite = &sprite[spriteNum];
|
||||
int const playerNum = A_FindPlayer(pSprite, &playerDist);
|
||||
int const rotateAngle = VM_OnEventWithBoth(EVENT_MOVESECTOR, spriteNum, playerNum, playerDist, T3(spriteNum));
|
||||
int const rotateAngle = VM_OnEvent(EVENT_MOVESECTOR, spriteNum, playerNum, playerDist, T3(spriteNum));
|
||||
int originIdx = T2(spriteNum);
|
||||
|
||||
pSprite->x += (pSprite->xvel * (sintable[(pSprite->ang + 512) & 2047])) >> 14;
|
||||
|
@ -5772,7 +5772,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
|
|||
int playerNum = A_FindPlayer(pSprite, &playerDist);
|
||||
DukePlayer_t *const pPlayer = g_player[playerNum].ps;
|
||||
|
||||
if (VM_OnEventWithBoth(EVENT_MOVEEFFECTORS, spriteNum, playerNum, playerDist, 0))
|
||||
if (VM_OnEvent(EVENT_MOVEEFFECTORS, spriteNum, playerNum, playerDist, 0))
|
||||
{
|
||||
spriteNum = nextSprite;
|
||||
continue;
|
||||
|
@ -8426,7 +8426,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_ExecuteEvent(nEventID, spriteNum, playerNum, playerDist);
|
||||
|
||||
spriteNum = nextSprite;
|
||||
}
|
||||
|
|
|
@ -1327,7 +1327,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(&sprite[newSprite], &p);
|
||||
|
||||
block_deletesprite++;
|
||||
VM_OnEventWithDist__(EVENT_EGS, newSprite, pl, p);
|
||||
VM_ExecuteEvent(EVENT_EGS, newSprite, pl, p);
|
||||
block_deletesprite--;
|
||||
}
|
||||
|
||||
|
@ -3408,7 +3408,7 @@ SPAWN_END:
|
|||
{
|
||||
int32_t p;
|
||||
int32_t pl=A_FindPlayer(&sprite[newSprite],&p);
|
||||
VM_OnEventWithDist__(EVENT_SPAWN,newSprite, pl, p);
|
||||
VM_ExecuteEvent(EVENT_SPAWN,newSprite, pl, p);
|
||||
}
|
||||
|
||||
return newSprite;
|
||||
|
@ -3534,7 +3534,7 @@ static inline void G_DoEventAnimSprites(int tspriteNum)
|
|||
return;
|
||||
|
||||
spriteext[tsprOwner].tspr = &tsprite[tspriteNum];
|
||||
VM_OnEvent__(EVENT_ANIMATESPRITES, tsprOwner, screenpeek);
|
||||
VM_ExecuteEvent(EVENT_ANIMATESPRITES, tsprOwner, screenpeek);
|
||||
spriteext[tsprOwner].tspr = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ intptr_t apScriptEvents[MAXEVENTS];
|
|||
|
||||
// May recurse, e.g. through EVENT_XXX -> ... -> EVENT_KILLIT
|
||||
#ifdef LUNATIC
|
||||
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_EventInlineInternal__(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);
|
||||
|
@ -153,7 +153,9 @@ static inline void VM_DummySprite(void)
|
|||
vm.pData = &dummy_actor.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)
|
||||
// verification that the event actually exists happens elsewhere
|
||||
static FORCE_INLINE int32_t VM_EventInlineInternal__(int const &eventNum, int const &spriteNum, int const &playerNum,
|
||||
int const playerDist = -1, int32_t returnValue = 0)
|
||||
{
|
||||
vmstate_t const tempvm = { spriteNum, playerNum, playerDist, 0, &sprite[spriteNum], &actor[spriteNum].t_data[0], g_player[playerNum].ps, &actor[spriteNum] };
|
||||
|
||||
|
@ -203,28 +205,27 @@ static FORCE_INLINE int32_t VM_EventCommon__(int const &eventNum, int const &spr
|
|||
}
|
||||
#endif
|
||||
|
||||
// the idea here is that the compiler inlines the call to VM_EventCommon_() and gives us a set of full functions
|
||||
// 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
|
||||
// the idea here is that the compiler inlines the call to VM_OnEvent_Internal__() and gives us a set of
|
||||
// functions which are optimized further based on distance/return having values known at compile time
|
||||
|
||||
int32_t VM_OnEventWithBoth__(int const nEventID, int const spriteNum, int const playerNum, int const nDist, int32_t const nReturn)
|
||||
int32_t VM_ExecuteEvent(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_EventInlineInternal__(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_ExecuteEvent(int const nEventID, int const spriteNum, int const playerNum, int const nDist)
|
||||
{
|
||||
return VM_EventCommon__(nEventID, spriteNum, playerNum, -1, nReturn);
|
||||
return VM_EventInlineInternal__(nEventID, spriteNum, playerNum, nDist);
|
||||
}
|
||||
|
||||
int32_t VM_OnEventWithDist__(int const nEventID, int const spriteNum, int const playerNum, int const nDist)
|
||||
int32_t VM_ExecuteEvent(int const nEventID, int const spriteNum, int const playerNum)
|
||||
{
|
||||
return VM_EventCommon__(nEventID, spriteNum, playerNum, nDist, 0);
|
||||
return VM_EventInlineInternal__(nEventID, spriteNum, playerNum);
|
||||
}
|
||||
|
||||
int32_t VM_OnEvent__(int const nEventID, int const spriteNum, int const playerNum)
|
||||
int32_t VM_ExecuteEventWithValue(int const nEventID, int const spriteNum, int const playerNum, int32_t const nReturn)
|
||||
{
|
||||
return VM_EventCommon__(nEventID, spriteNum, playerNum, -1, 0);
|
||||
return VM_EventInlineInternal__(nEventID, spriteNum, playerNum, -1, nReturn);
|
||||
}
|
||||
|
||||
static bool VM_CheckSquished(void)
|
||||
|
|
|
@ -32,15 +32,49 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
# include "lunatic_game.h"
|
||||
#endif
|
||||
|
||||
int32_t VM_ExecuteEvent(int const nEventID, int const spriteNum, int const playerNum, int const nDist, int32_t const nReturn);
|
||||
int32_t VM_ExecuteEvent(int const nEventID, int const spriteNum, int const playerNum, int const nDist);
|
||||
int32_t VM_ExecuteEvent(int const nEventID, int const spriteNum, int const playerNum);
|
||||
int32_t VM_ExecuteEventWithValue(int const nEventID, int const spriteNum, int const playerNum, int32_t const nReturn);
|
||||
|
||||
static FORCE_INLINE bool VM_HaveEvent(int const nEventID)
|
||||
{
|
||||
#ifdef LUNATIC
|
||||
return L_IsInitialized(&g_ElState) && El_HaveEvent(nEventID);
|
||||
#else
|
||||
return !!apScriptEvents[nEventID];
|
||||
#endif
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t VM_OnEvent(int nEventID, int spriteNum, int playerNum, int nDist, int32_t nReturn)
|
||||
{
|
||||
return VM_HaveEvent(nEventID) ? VM_ExecuteEvent(nEventID, spriteNum, playerNum, nDist, nReturn) : nReturn;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t VM_OnEvent(int nEventID, int spriteNum, int playerNum, int nDist)
|
||||
{
|
||||
return VM_HaveEvent(nEventID) ? VM_ExecuteEvent(nEventID, spriteNum, playerNum, nDist) : 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t VM_OnEvent(int nEventID, int spriteNum, int playerNum)
|
||||
{
|
||||
return VM_HaveEvent(nEventID) ? VM_ExecuteEvent(nEventID, spriteNum, playerNum) : 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t VM_OnEventWithReturn(int nEventID, int spriteNum, int playerNum, int32_t nReturn)
|
||||
{
|
||||
return VM_HaveEvent(nEventID) ? VM_ExecuteEventWithValue(nEventID, spriteNum, playerNum, nReturn) : nReturn;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum vmflags_t
|
||||
{
|
||||
VM_RETURN = 0x00000001,
|
||||
VM_KILL = 0x00000002,
|
||||
VM_NOEXECUTE = 0x00000004,
|
||||
VM_RETURN = 0x00000001,
|
||||
VM_KILL = 0x00000002,
|
||||
VM_NOEXECUTE = 0x00000004,
|
||||
};
|
||||
|
||||
extern int32_t ticrandomseed;
|
||||
|
@ -81,40 +115,6 @@ static inline void VM_DrawTilePalSmall(int32_t x, int32_t y, int32_t tilenum, in
|
|||
void VM_DrawTileSmall(int32_t x, int32_t y, int32_t tilenum, int32_t shade, int32_t orientation);
|
||||
#endif
|
||||
|
||||
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 bool VM_HaveEvent(int const nEventID)
|
||||
{
|
||||
#ifdef LUNATIC
|
||||
return L_IsInitialized(&g_ElState) && El_HaveEvent(nEventID);
|
||||
#else
|
||||
return !!apScriptEvents[nEventID];
|
||||
#endif
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t VM_OnEvent(int nEventID, int spriteNum, int playerNum)
|
||||
{
|
||||
return VM_HaveEvent(nEventID) ? VM_OnEvent__(nEventID, spriteNum, playerNum) : 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t VM_OnEventWithBoth(int nEventID, int spriteNum, int playerNum, int nDist, int32_t 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;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t VM_OnEventWithReturn(int nEventID, int spriteNum, int playerNum, int nReturn)
|
||||
{
|
||||
return VM_HaveEvent(nEventID) ? VM_OnEventWithReturn__(nEventID, spriteNum, playerNum, nReturn) : nReturn;
|
||||
}
|
||||
|
||||
#define CON_ERRPRINTF(Text, ...) do { \
|
||||
vm.flags |= VM_RETURN; \
|
||||
OSD_Printf("Line %d, %s: " Text, g_errorLineNum, VM_GetKeywordForID(g_tw), ## __VA_ARGS__); \
|
||||
|
|
|
@ -1271,7 +1271,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_ExecuteEvent(EVENT_DISPLAYREST, g_player[screenpeek].ps->i, screenpeek);
|
||||
renderSetAspect(vr, asp);
|
||||
}
|
||||
|
||||
|
|
|
@ -1806,7 +1806,7 @@ void Sect_DamageFloor_Internal(int const spriteNum, int const sectNum)
|
|||
|
||||
// NOTE: pass RETURN in the dist argument, too.
|
||||
int const RETURN_in = 131072 + sectNum;
|
||||
/* int32_t const returnValue = */ VM_OnEventWithBoth(EVENT_DAMAGEHPLANE, -1, -1, RETURN_in, RETURN_in);
|
||||
/* int32_t const returnValue = */ VM_OnEvent(EVENT_DAMAGEHPLANE, -1, -1, RETURN_in, RETURN_in);
|
||||
|
||||
#if 0
|
||||
// No hard-coded floor damage effects.
|
||||
|
@ -1832,7 +1832,7 @@ void Sect_DamageCeiling_Internal(int const spriteNum, int const sectNum)
|
|||
|
||||
// NOTE: pass RETURN in the dist argument, too.
|
||||
int const RETURN_in = 65536 + sectNum;
|
||||
int32_t const returnValue = VM_OnEventWithBoth(EVENT_DAMAGEHPLANE, -1, -1, RETURN_in, RETURN_in);
|
||||
int32_t const returnValue = VM_OnEvent(EVENT_DAMAGEHPLANE, -1, -1, RETURN_in, RETURN_in);
|
||||
|
||||
if (returnValue < 0)
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue