mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-16 09:21:36 +00:00
gameexec.c: factor out 2x used code into VM_KillIt.
Also, for Lunatic, handle killit from events. git-svn-id: https://svn.eduke32.com/eduke32@3514 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
a83b2fee95
commit
6682313e87
3 changed files with 26 additions and 24 deletions
|
@ -103,18 +103,34 @@ void VM_ScriptInfo(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
static void VM_KillIt(int32_t iActor, int32_t iPlayer)
|
||||
{
|
||||
if (iActor >= 0)
|
||||
{
|
||||
// if player was set to squish, first stop that...
|
||||
if (iPlayer >= 0 && g_player[iPlayer].ps->actorsqu == iActor)
|
||||
g_player[iPlayer].ps->actorsqu = -1;
|
||||
|
||||
A_DeleteSprite(iActor);
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
#ifdef LUNATIC
|
||||
int32_t killit;
|
||||
const double t = gethitickms();
|
||||
|
||||
// TODO: handling of RETURN gamevar / iReturn / this function's return value
|
||||
if (L_IsInitialized(&g_ElState) && El_HaveEvent(iEventID))
|
||||
El_CallEvent(&g_ElState, iEventID, iActor, iPlayer, lDist);
|
||||
#endif
|
||||
if (El_CallEvent(&g_ElState, iEventID, iActor, iPlayer, lDist)==1)
|
||||
VM_KillIt(iActor, iPlayer);
|
||||
|
||||
g_eventTotalMs[iEventID] += gethitickms()-t;
|
||||
g_eventCalls[iEventID]++;
|
||||
#else
|
||||
|
||||
#if !defined LUNATIC
|
||||
if (apScriptGameEvent[iEventID])
|
||||
{
|
||||
intptr_t *oinsptr=insptr;
|
||||
|
@ -138,13 +154,7 @@ int32_t VM_OnEvent(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lD
|
|||
VM_Execute(1);
|
||||
|
||||
if (vm.g_flags & VM_KILL)
|
||||
{
|
||||
// if player was set to squish, first stop that...
|
||||
if (vm.g_p >= 0 && g_player[vm.g_p].ps->actorsqu == vm.g_i)
|
||||
g_player[vm.g_p].ps->actorsqu = -1;
|
||||
|
||||
A_DeleteSprite(vm.g_i);
|
||||
}
|
||||
VM_KillIt(iActor, iPlayer);
|
||||
|
||||
Bmemcpy(&vm, &vm_backup, sizeof(vmstate_t));
|
||||
insptr = oinsptr;
|
||||
|
@ -155,10 +165,6 @@ int32_t VM_OnEvent(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lD
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef LUNATIC
|
||||
g_eventTotalMs[iEventID] += gethitickms()-t;
|
||||
g_eventCalls[iEventID]++;
|
||||
#endif
|
||||
return iReturn;
|
||||
}
|
||||
|
||||
|
@ -5124,12 +5130,10 @@ finish_qsprintf:
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// NORECURSE
|
||||
void A_LoadActor(int32_t iActor)
|
||||
{
|
||||
#if !defined LUNATIC
|
||||
vm.g_i = iActor; // Sprite ID
|
||||
vm.g_p = -1; // iPlayer; // Player ID
|
||||
vm.g_x = -1; // lDist; // ?
|
||||
|
@ -5155,8 +5159,9 @@ void A_LoadActor(int32_t iActor)
|
|||
|
||||
if (vm.g_flags & VM_KILL)
|
||||
A_DeleteSprite(vm.g_i);
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
// NORECURSE
|
||||
void A_Execute(int32_t iActor,int32_t iPlayer,int32_t lDist)
|
||||
|
@ -5244,11 +5249,7 @@ void A_Execute(int32_t iActor,int32_t iPlayer,int32_t lDist)
|
|||
#endif
|
||||
)
|
||||
{
|
||||
// if player was set to squish, first stop that...
|
||||
if (vm.g_p >= 0 && g_player[vm.g_p].ps->actorsqu == vm.g_i)
|
||||
g_player[vm.g_p].ps->actorsqu = -1;
|
||||
|
||||
A_DeleteSprite(vm.g_i);
|
||||
VM_KillIt(iActor, iPlayer);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -135,6 +135,8 @@ extern vmstate_t vm;
|
|||
extern int32_t g_tw;
|
||||
extern int32_t g_errorLineNum;
|
||||
extern int32_t g_currentEventExec;
|
||||
|
||||
void A_LoadActor(int32_t iActor);
|
||||
#endif
|
||||
|
||||
void A_Execute(int32_t iActor,int32_t iPlayer,int32_t lDist);
|
||||
|
@ -142,7 +144,6 @@ void A_Fall(int32_t iActor);
|
|||
int32_t A_FurthestVisiblePoint(int32_t iActor,spritetype *ts,int32_t *dax,int32_t *day);
|
||||
int32_t A_GetFurthestAngle(int32_t iActor,int32_t angs);
|
||||
void A_GetZLimits(int32_t iActor);
|
||||
void A_LoadActor(int32_t iActor);
|
||||
int32_t G_GetAngleDelta(int32_t a,int32_t na);
|
||||
void G_RestoreMapState(mapstate_t *save);
|
||||
void G_RestoreMapState(mapstate_t *save);
|
||||
|
|
|
@ -1142,8 +1142,8 @@ static inline void prelevel(char g)
|
|||
nexti = nextspritestat[i];
|
||||
#if !defined LUNATIC
|
||||
A_ResetVars(i);
|
||||
#endif
|
||||
A_LoadActor(i);
|
||||
#endif
|
||||
VM_OnEvent(EVENT_LOADACTOR, i, -1, -1, 0);
|
||||
if (sprite[i].lotag == UINT16_MAX && (sprite[i].cstat&16))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue