Add a temporary limbo list for thinkers that need to be freed, in order to keep other lists clean, especially the mobj list.
Signed-off-by: Nev3r <apophycens@gmail.com>
This commit is contained in:
parent
fc9e141460
commit
a3174fb56f
|
@ -62,6 +62,7 @@
|
||||||
#define P_GetPlayerSpinHeight(player) FixedMul(player->spinheight, player->mo->scale)
|
#define P_GetPlayerSpinHeight(player) FixedMul(player->spinheight, player->mo->scale)
|
||||||
|
|
||||||
typedef enum{
|
typedef enum{
|
||||||
|
THINK_LIMBO,
|
||||||
THINK_POLYOBJ,
|
THINK_POLYOBJ,
|
||||||
THINK_MAIN,
|
THINK_MAIN,
|
||||||
THINK_DYNSLOPE,
|
THINK_DYNSLOPE,
|
||||||
|
|
14
src/p_tick.c
14
src/p_tick.c
|
@ -244,10 +244,23 @@ void P_RemoveThinkerDelayed(void *pthinker)
|
||||||
//
|
//
|
||||||
void P_RemoveThinker(thinker_t *thinker)
|
void P_RemoveThinker(thinker_t *thinker)
|
||||||
{
|
{
|
||||||
|
thinker_t *next = thinker->next;
|
||||||
#ifdef HAVE_BLUA
|
#ifdef HAVE_BLUA
|
||||||
LUA_InvalidateUserdata(thinker);
|
LUA_InvalidateUserdata(thinker);
|
||||||
#endif
|
#endif
|
||||||
thinker->function.acp1 = P_RemoveThinkerDelayed;
|
thinker->function.acp1 = P_RemoveThinkerDelayed;
|
||||||
|
|
||||||
|
if (currentthinker == thinker)
|
||||||
|
currentthinker = thinker->prev;
|
||||||
|
|
||||||
|
// Remove thinker from its current list.
|
||||||
|
(next->prev = thinker->prev)->next = next;
|
||||||
|
|
||||||
|
// Now add it to the limbo list
|
||||||
|
thlist[THINK_LIMBO].prev->next = thinker;
|
||||||
|
thinker->next = &thlist[THINK_LIMBO];
|
||||||
|
thinker->prev = thlist[THINK_LIMBO].prev;
|
||||||
|
thlist[THINK_LIMBO].prev = thinker;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -298,7 +311,6 @@ static inline void P_RunThinkers(void)
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < NUM_THINKERLISTS; i++)
|
for (i = 0; i < NUM_THINKERLISTS; i++)
|
||||||
{
|
{
|
||||||
CONS_Printf("Running thinker list %d.\n", i);
|
|
||||||
for (currentthinker = thlist[i].next; currentthinker != &thlist[i]; currentthinker = currentthinker->next)
|
for (currentthinker = thlist[i].next; currentthinker != &thlist[i]; currentthinker = currentthinker->next)
|
||||||
{
|
{
|
||||||
if (currentthinker->function.acp1)
|
if (currentthinker->function.acp1)
|
||||||
|
|
Loading…
Reference in New Issue