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:
Nev3r 2019-04-21 16:17:47 +02:00
parent fc9e141460
commit a3174fb56f
2 changed files with 14 additions and 1 deletions

View File

@ -62,6 +62,7 @@
#define P_GetPlayerSpinHeight(player) FixedMul(player->spinheight, player->mo->scale)
typedef enum{
THINK_LIMBO,
THINK_POLYOBJ,
THINK_MAIN,
THINK_DYNSLOPE,

View File

@ -244,10 +244,23 @@ void P_RemoveThinkerDelayed(void *pthinker)
//
void P_RemoveThinker(thinker_t *thinker)
{
thinker_t *next = thinker->next;
#ifdef HAVE_BLUA
LUA_InvalidateUserdata(thinker);
#endif
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;
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)
{
if (currentthinker->function.acp1)