diff --git a/src/m_perfstats.c b/src/m_perfstats.c index 3c5526678..15f419a00 100644 --- a/src/m_perfstats.c +++ b/src/m_perfstats.c @@ -577,8 +577,7 @@ static void PS_CountThinkers(void) ps_removecount.value.i = 0; for (thinker = thinkercap.next; thinker != &thinkercap; thinker = thinker->next) { - if (thinker->function.acp1 != (actionf_p1)P_NullPrecipThinker) - ps_thinkercount.value.i++; + ps_thinkercount.value.i++; if (thinker->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) ps_removecount.value.i++; @@ -593,11 +592,18 @@ static void PS_CountThinkers(void) else ps_regularcount.value.i++; } - else if (thinker->function.acp1 == (actionf_p1)P_NullPrecipThinker) - ps_precipcount.value.i++; else ps_otherthcount.value.i++; } + + for (thinker = precipcap.next; thinker != &precipcap; thinker = thinker->next) + { + if (thinker->function.acp1 != (actionf_p1)P_NullPrecipThinker) + continue; // not a precipmobj thinker + + ps_precipcount.value.i++; + } + /*for (i = 0; i < NUM_THINKERLISTS; i++) { for (thinker = thlist[i].next; thinker != &thlist[i]; thinker = thinker->next) diff --git a/src/p_local.h b/src/p_local.h index 08323e052..698254df3 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -63,10 +63,12 @@ // both the head and tail of the thinker list extern thinker_t thinkercap; +extern thinker_t precipcap; extern mobj_t *mobjcache; void P_InitThinkers(void); void P_AddThinker(thinker_t *thinker); +void P_AddPrecipThinker(thinker_t *thinker); void P_RemoveThinker(thinker_t *thinker); void P_UnlinkThinker(thinker_t *thinker); diff --git a/src/p_mobj.c b/src/p_mobj.c index 1fe8a3213..72f789131 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9982,7 +9982,7 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype mobj->momz = cv_mobjscaleprecip.value ? FixedMul(info->speed, mapobjectscale) : info->speed; mobj->thinker.function.acp1 = (actionf_p1)P_NullPrecipThinker; - P_AddThinker(&mobj->thinker); + P_AddPrecipThinker(&mobj->thinker); CalculatePrecipFloor(mobj); diff --git a/src/p_saveg.c b/src/p_saveg.c index 898a53d68..5b70695d7 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1680,8 +1680,7 @@ static void P_NetArchiveThinkers(savebuffer_t *save) // save off the current thinkers for (th = thinkercap.next; th != &thinkercap; th = th->next) { - if (!(th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed - || th->function.acp1 == (actionf_p1)P_NullPrecipThinker)) + if (th->function.acp1 != (actionf_p1)P_RemoveThinkerDelayed) numsaved++; if (th->function.acp1 == (actionf_p1)P_MobjThinker) @@ -1689,9 +1688,6 @@ static void P_NetArchiveThinkers(savebuffer_t *save) SaveMobjThinker(save, th, tc_mobj); continue; } -#ifdef PARANOIA - else if (th->function.acp1 == (actionf_p1)P_NullPrecipThinker); -#endif else if (th->function.acp1 == (actionf_p1)T_MoveCeiling) { SaveCeilingThinker(save, th, tc_ceiling); @@ -2685,7 +2681,22 @@ static void P_NetUnArchiveThinkers(savebuffer_t *save) { next = currentthinker->next; - if (currentthinker->function.acp1 == (actionf_p1)P_MobjThinker || currentthinker->function.acp1 == (actionf_p1)P_NullPrecipThinker) + if (currentthinker->function.acp1 == (actionf_p1)P_MobjThinker) + P_RemoveSavegameMobj((mobj_t *)currentthinker); // item isn't saved, don't remove it + else + { + (next->prev = currentthinker->prev)->next = next; + R_DestroyLevelInterpolators(currentthinker); + Z_Free(currentthinker); + } + } + + currentthinker = precipcap.next; + for (currentthinker = precipcap.next; currentthinker != &precipcap; currentthinker = next) + { + next = currentthinker->next; + + if (currentthinker->function.acp1 == (actionf_p1)P_NullPrecipThinker) P_RemoveSavegameMobj((mobj_t *)currentthinker); // item isn't saved, don't remove it else { diff --git a/src/p_spec.c b/src/p_spec.c index a7a2a6928..1c3970b78 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1783,7 +1783,7 @@ void P_SwitchWeather(INT32 weathernum) thinker_t *next; precipmobj_t *precipmobj; - for (think = thinkercap.next; think != &thinkercap; think = next) + for (think = precipcap.next; think != &precipcap; think = next) { next = think->next; @@ -1800,7 +1800,7 @@ void P_SwitchWeather(INT32 weathernum) precipmobj_t *precipmobj; state_t *st; - for (think = thinkercap.next; think != &thinkercap; think = think->next) + for (think = precipcap.next; think != &precipcap; think = think->next) { if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) continue; // not a precipmobj thinker diff --git a/src/p_tick.c b/src/p_tick.c index 3b0cadde8..e6239e312 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -49,6 +49,7 @@ tic_t leveltime; // Both the head and tail of the thinker list. thinker_t thinkercap; +thinker_t precipcap; void Command_Numthinkers_f(void) { @@ -104,12 +105,25 @@ void Command_Numthinkers_f(void) return; } - for (think = thinkercap.next; think != &thinkercap; think = think->next) + if (num == 2) // P_NullPrecipThinker { - if (think->function.acp1 != action) - continue; + for (think = precipcap.next; think != &precipcap; think = think->next) + { + if (think->function.acp1 != action) + continue; - count++; + count++; + } + } + else + { + for (think = thinkercap.next; think != &thinkercap; think = think->next) + { + if (think->function.acp1 != action) + continue; + + count++; + } } CONS_Printf("%d\n", count); @@ -181,6 +195,7 @@ void Command_CountMobjs_f(void) void P_InitThinkers(void) { thinkercap.prev = thinkercap.next = &thinkercap; + precipcap.prev = precipcap.next = &precipcap; waypointcap = NULL; } @@ -200,6 +215,22 @@ void P_AddThinker(thinker_t *thinker) thinker->cachable = (thinker->function.acp1 == (actionf_p1)P_MobjThinker); } +// +// P_AddPrecipThinker +// Adds a new precip thinker at the end of the list. +// +void P_AddPrecipThinker(thinker_t *thinker) +{ + precipcap.prev->next = thinker; + thinker->next = &precipcap; + thinker->prev = precipcap.prev; + precipcap.prev = thinker; + + thinker->references = 0; // killough 11/98: init reference counter to 0 + + thinker->cachable = false; +} + // // killough 11/98: // @@ -341,8 +372,6 @@ static inline void P_RunThinkers(void) { for (currentthinker = thinkercap.next; currentthinker != &thinkercap; currentthinker = currentthinker->next) { - if (currentthinker->function.acp1 == (actionf_p1)P_NullPrecipThinker) - continue; #ifdef PARANOIA I_Assert(currentthinker->function.acp1 != NULL) #endif diff --git a/src/r_main.c b/src/r_main.c index 39b2618ce..6e13786a1 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -310,7 +310,7 @@ static void Precipstuff_OnChange(void) thinker_t *next; precipmobj_t *precipmobj; - for (think = thinkercap.next; think != &thinkercap; think = next) + for (think = precipcap.next; think != &precipcap; think = next) { next = think->next;