diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index e6dd305f0..c3aa26a3c 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5308,12 +5308,6 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) // uncapped/interpolation interpmobjstate_t interp = {0}; - // okay... this is a hack, but weather isn't networked, so it should be ok - if (!P_PrecipThinker(thing)) - { - return; - } - // do interpolation if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value)) { @@ -5409,6 +5403,13 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) vis->gz = vis->gzt - FIXED_TO_FLOAT(spritecachedinfo[lumpoff].height); vis->precip = true; + + // okay... this is a hack, but weather isn't networked, so it should be ok + if (!(thing->precipflags & PCF_THUNK)) + { + P_PrecipThinker(thing); + thing->precipflags |= PCF_THUNK; + } } static boolean drewsky = false; diff --git a/src/m_perfstats.c b/src/m_perfstats.c index a8f9550f4..04e51a657 100644 --- a/src/m_perfstats.c +++ b/src/m_perfstats.c @@ -58,6 +58,7 @@ static ps_metric_t ps_regularcount = {0}; static ps_metric_t ps_scenerycount = {0}; static ps_metric_t ps_nothinkcount = {0}; static ps_metric_t ps_otherthcount = {0}; +static ps_metric_t ps_precipcount = {0}; static ps_metric_t ps_removecount = {0}; ps_metric_t ps_checkposition_calls = {0}; @@ -172,6 +173,7 @@ perfstatrow_t thinkercount_rows[] = { {" scenery", " Scenery: ", &ps_scenerycount, PS_LEVEL}, {" nothink", " Nothink: ", &ps_nothinkcount, PS_HIDE_ZERO|PS_LEVEL}, {" other ", " Other: ", &ps_otherthcount, PS_LEVEL}, + {" precip ", " Precipitation: ", &ps_precipcount, PS_LEVEL}, {" remove ", " Pending removal:", &ps_removecount, PS_LEVEL}, {0} }; @@ -570,6 +572,7 @@ static void PS_CountThinkers(void) ps_scenerycount.value.i = 0; ps_nothinkcount.value.i = 0; ps_otherthcount.value.i = 0; + ps_precipcount.value.i = 0; ps_removecount.value.i = 0; for (thinker = thinkercap.next; thinker != &thinkercap; thinker = thinker->next) { @@ -587,6 +590,8 @@ 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++; } diff --git a/src/p_local.h b/src/p_local.h index 67ca4beef..e1a07526a 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -70,7 +70,6 @@ extern thinker_t thinkercap; void P_InitThinkers(void); void P_AddThinker(thinker_t *thinker); void P_RemoveThinker(thinker_t *thinker); -void P_UnlinkThinker(thinker_t *thinker); // // P_USER diff --git a/src/p_mobj.c b/src/p_mobj.c index 86f9bd2e1..db2166935 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -338,7 +338,7 @@ static boolean P_SetPrecipMobjState(precipmobj_t *mobj, statenum_t state) if (state == S_NULL) { // Remove mobj - P_FreePrecipMobj(mobj); + P_RemovePrecipMobj(mobj); return false; } st = &states[state]; @@ -3592,35 +3592,26 @@ void P_RecalcPrecipInSector(sector_t *sector) // // P_NullPrecipThinker // -// Just the identification of a precip thinker. The thinker -// should never actually be called! +// For "Blank" precipitation // void P_NullPrecipThinker(precipmobj_t *mobj) { - (void)mobj; - I_Assert("P_NullPrecipThinker should not be called" == 0); + //(void)mobj; + mobj->precipflags &= ~PCF_THUNK; + R_ResetPrecipitationMobjInterpolationState(mobj); } -boolean P_PrecipThinker(precipmobj_t *mobj) +void P_PrecipThinker(precipmobj_t *mobj) { - if (mobj->lastThink == leveltime) - return true; // already thinked this tick - - mobj->lastThink = leveltime; - - R_ResetPrecipitationMobjInterpolationState(mobj); P_CycleStateAnimation((mobj_t *)mobj); if (mobj->state == &states[S_RAINRETURN]) { // Reset to ceiling! - if (!P_SetPrecipMobjState(mobj, mobj->info->spawnstate)) - return false; - + P_SetPrecipMobjState(mobj, mobj->info->spawnstate); mobj->z = mobj->ceilingz; mobj->momz = mobj->info->speed; mobj->precipflags &= ~PCF_SPLASH; - R_ResetPrecipitationMobjInterpolationState(mobj); } if (mobj->tics != -1) @@ -3637,23 +3628,20 @@ boolean P_PrecipThinker(precipmobj_t *mobj) // HACK: sprite changes are 1 tic late, so you would see splashes on the ceiling if not for this state. // We need to use the settings from the previous state, since some of those are NOT 1 tic late. INT32 frame = (mobj->frame & ~FF_FRAMEMASK); - - if (!P_SetPrecipMobjState(mobj, S_RAINRETURN)) - return false; - + P_SetPrecipMobjState(mobj, S_RAINRETURN); mobj->frame = frame; - return true; + return; } else { if (!P_SetPrecipMobjState(mobj, mobj->state->nextstate)) - return false; + return; } } } if (mobj->precipflags & PCF_SPLASH) - return true; + return; // adjust height if ((mobj->z += mobj->momz) <= mobj->floorz) @@ -3661,20 +3649,14 @@ boolean P_PrecipThinker(precipmobj_t *mobj) if ((mobj->info->deathstate == S_NULL) || (mobj->precipflags & PCF_PIT)) // no splashes on sky or bottomless pits { mobj->z = mobj->ceilingz; - R_ResetPrecipitationMobjInterpolationState(mobj); } else { - if (!P_SetPrecipMobjState(mobj, mobj->info->deathstate)) - return false; - + P_SetPrecipMobjState(mobj, mobj->info->deathstate); mobj->z = mobj->floorz; mobj->precipflags |= PCF_SPLASH; - R_ResetPrecipitationMobjInterpolationState(mobj); } } - - return true; } static void P_RingThinker(mobj_t *mobj) @@ -10062,7 +10044,7 @@ boolean P_MobjWasRemoved(mobj_t *mobj) return !(mobj && mobj->thinker.function.acp1 == (actionf_p1)P_MobjThinker); } -void P_FreePrecipMobj(precipmobj_t *mobj) +void P_RemovePrecipMobj(precipmobj_t *mobj) { // unlink from sector and block lists P_UnsetPrecipThingPosition(mobj); @@ -10074,9 +10056,7 @@ void P_FreePrecipMobj(precipmobj_t *mobj) } // free block - // Precipmobjs don't actually think using their thinker, - // so the free cannot be delayed. - P_UnlinkThinker((thinker_t*)mobj); + P_RemoveThinker((thinker_t *)mobj); } // Clearing out stuff for savegames @@ -10112,7 +10092,12 @@ void P_RemoveSavegameMobj(mobj_t *mobj) // free block // Here we use the same code as R_RemoveThinkerDelayed, but without reference counting (we're removing everything so it shouldn't matter) and without touching currentthinker since we aren't in P_RunThinkers - P_UnlinkThinker((thinker_t*)mobj); + { + thinker_t *thinker = (thinker_t *)mobj; + thinker_t *next = thinker->next; + (next->prev = thinker->prev)->next = next; + Z_Free(thinker); + } } static CV_PossibleValue_t respawnitemtime_cons_t[] = {{1, "MIN"}, {300, "MAX"}, {0, NULL}}; diff --git a/src/p_mobj.h b/src/p_mobj.h index 5c2a52e35..c4984e49c 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -476,8 +476,6 @@ typedef struct precipmobj_s INT32 tics; // state tic counter state_t *state; INT32 flags; // flags from mobjinfo tables - - tic_t lastThink; } precipmobj_t; typedef struct actioncache_s @@ -517,9 +515,9 @@ void P_SpawnParaloop(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 numb boolean P_BossTargetPlayer(mobj_t *actor, boolean closest); boolean P_SupermanLook4Players(mobj_t *actor); void P_DestroyRobots(void); -boolean P_PrecipThinker(precipmobj_t *mobj); +void P_PrecipThinker(precipmobj_t *mobj); void P_NullPrecipThinker(precipmobj_t *mobj); -void P_FreePrecipMobj(precipmobj_t *mobj); +void P_RemovePrecipMobj(precipmobj_t *mobj); void P_SetScale(mobj_t *mobj, fixed_t newscale); void P_XYMovement(mobj_t *mo); void P_EmeraldManager(void); diff --git a/src/p_spec.c b/src/p_spec.c index fd5fbea50..ad218f8bd 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2025,18 +2025,15 @@ void P_SwitchWeather(UINT8 newWeather) if (purge == true) { thinker_t *think; - thinker_t *next; precipmobj_t *precipmobj; - for (think = thinkercap.next; think != &thinkercap; think = next) + for (think = thinkercap.next; think != &thinkercap; think = think->next) { - next = think->next; - if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) continue; // not a precipmobj thinker precipmobj = (precipmobj_t *)think; - P_FreePrecipMobj(precipmobj); + P_RemovePrecipMobj(precipmobj); } } else if (swap != MT_NULL) // Rather than respawn all that crap, reuse it! diff --git a/src/p_tick.c b/src/p_tick.c index c00db9a2a..cc37ea0eb 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -213,6 +213,7 @@ static thinker_t *currentthinker; // void P_RemoveThinkerDelayed(thinker_t *thinker) { + thinker_t *next; #ifdef PARANOIA if (thinker->next) thinker->next = NULL; @@ -222,29 +223,14 @@ void P_RemoveThinkerDelayed(thinker_t *thinker) if (thinker->references) return; - R_DestroyLevelInterpolators(thinker); - + /* Remove from main thinker list */ + next = thinker->next; /* Note that currentthinker is guaranteed to point to us, * and since we're freeing our memory, we had better change that. So * point it to thinker->prev, so the iterator will correctly move on to * thinker->prev->next = thinker->next */ - currentthinker = thinker->prev; - /* Remove from main thinker list */ - P_UnlinkThinker(thinker); -} - -// -// P_UnlinkThinker() -// -// Actually removes thinker from the list and frees its memory. -// -void P_UnlinkThinker(thinker_t *thinker) -{ - thinker_t *next = thinker->next; - - I_Assert(thinker->references == 0); - - (next->prev = thinker->prev)->next = next; + (next->prev = currentthinker = thinker->prev)->next = next; + R_DestroyLevelInterpolators(thinker); Z_Free(thinker); } diff --git a/src/r_things.c b/src/r_things.c index ccfde4071..b948cb300 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1739,12 +1739,6 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) // uncapped/interpolation interpmobjstate_t interp = {0}; - // okay... this is a hack, but weather isn't networked, so it should be ok - if (!P_PrecipThinker(thing)) - { - return; - } - // do interpolation if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value)) { @@ -1837,7 +1831,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) if (thing->subsector->sector->cullheight) { if (R_DoCulling(thing->subsector->sector->cullheight, viewsector->cullheight, viewz, gz, gzt)) - return; // cap + goto weatherthink; } // store information in a vissprite @@ -1901,6 +1895,14 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) vis->precip = true; vis->vflip = false; vis->isScaled = false; + +weatherthink: + // okay... this is a hack, but weather isn't networked, so it should be ok + if (!(thing->precipflags & PCF_THUNK)) + { + P_PrecipThinker(thing); + thing->precipflags |= PCF_THUNK; + } } // R_AddSprites