diff --git a/src/m_perfstats.c b/src/m_perfstats.c index a8f9550f4..30640b21c 100644 --- a/src/m_perfstats.c +++ b/src/m_perfstats.c @@ -10,6 +10,7 @@ /// \brief Performance measurement tools. #include "m_perfstats.h" +#include "p_mobj.h" #include "v_video.h" #include "i_video.h" #include "d_netcmd.h" @@ -58,6 +59,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}; @@ -171,6 +173,7 @@ perfstatrow_t thinkercount_rows[] = { {" regular", " Regular: ", &ps_regularcount, PS_LEVEL}, {" scenery", " Scenery: ", &ps_scenerycount, PS_LEVEL}, {" nothink", " Nothink: ", &ps_nothinkcount, PS_HIDE_ZERO|PS_LEVEL}, + {" precip ", " Precipitation: ", &ps_precipcount, PS_LEVEL}, {" other ", " Other: ", &ps_otherthcount, PS_LEVEL}, {" remove ", " Pending removal:", &ps_removecount, PS_LEVEL}, {0} @@ -569,11 +572,14 @@ static void PS_CountThinkers(void) ps_regularcount.value.i = 0; ps_scenerycount.value.i = 0; ps_nothinkcount.value.i = 0; + ps_precipcount.value.i = 0; ps_otherthcount.value.i = 0; ps_removecount.value.i = 0; for (thinker = thinkercap.next; thinker != &thinkercap; thinker = thinker->next) { - ps_thinkercount.value.i++; + if (thinker->function.acp1 != (actionf_p1)P_NullPrecipThinker) + ps_thinkercount.value.i++; + if (thinker->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) ps_removecount.value.i++; else if (thinker->function.acp1 == (actionf_p1)P_MobjThinker) @@ -587,6 +593,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_mobj.c b/src/p_mobj.c index c70f9816c..91cf6f388 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10205,9 +10205,8 @@ consvar_t cv_suddendeath = {"suddendeath", "Off", CV_NETVAR|CV_CHEAT|CV_NOSHOWHE void P_SpawnPrecipitation(void) { - INT32 i, j, k, mrand; - fixed_t basex, basey, x, y, z, height; - fixed_t precipscale = cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT; + INT32 i, mrand; + fixed_t basex, basey, j, x, y, z; subsector_t *precipsector = NULL; precipmobj_t *rainmo = NULL; @@ -10220,9 +10219,10 @@ void P_SpawnPrecipitation(void) basex = bmaporgx + (i % bmapwidth) * MAPBLOCKSIZE; basey = bmaporgy + (i / bmapwidth) * MAPBLOCKSIZE; - for (j = 0; j < FRACUNIT; j += precipscale) + for (j = 0; j < FRACUNIT; j += cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT) { - UINT16 numparticles = 0; + INT32 floorz; + INT32 ceilingz; x = ((cv_lessprecip.value ? basex*1.5 : basex) + ((M_RandomKey(MAPBLOCKUNITS<<3)<>3)); y = ((cv_lessprecip.value ? basey*1.5 : basey) + ((M_RandomKey(MAPBLOCKUNITS<<3)<>3)); @@ -10237,50 +10237,37 @@ void P_SpawnPrecipitation(void) // Not in a sector with visible sky? if (precipsector->sector->ceilingpic != skyflatnum) continue; - - height = precipsector->sector->ceilingheight - precipsector->sector->floorheight; - height = FixedDiv(height, precipscale); - // Exists, but is too small for reasonable precipitation. - if (height < 64<sector->floorheight <= precipsector->sector->ceilingheight - (32<sector->ceilingheight; - for (k = 0; k < numparticles; k++) + if (curWeather == PRECIP_SNOW) { - INT32 floorz; - INT32 ceilingz; + rainmo = P_SpawnPrecipMobj(x, y, z, MT_SNOWFLAKE); + mrand = M_RandomByte(); + if (mrand < 64) + P_SetPrecipMobjState(rainmo, S_SNOW3); + else if (mrand < 144) + P_SetPrecipMobjState(rainmo, S_SNOW2); + } + else // everything else. + rainmo = P_SpawnPrecipMobj(x, y, z, MT_RAIN); - if (curWeather == PRECIP_SNOW) - { - rainmo = P_SpawnPrecipMobj(x, y, z, MT_SNOWFLAKE); - mrand = M_RandomByte(); - if (mrand < 64) - P_SetPrecipMobjState(rainmo, S_SNOW3); - else if (mrand < 144) - P_SetPrecipMobjState(rainmo, S_SNOW2); - } - else // everything else. - rainmo = P_SpawnPrecipMobj(x, y, z, MT_RAIN); + floorz = rainmo->floorz >> FRACBITS; + ceilingz = rainmo->ceilingz >> FRACBITS; - floorz = rainmo->floorz >> FRACBITS; - ceilingz = rainmo->ceilingz >> FRACBITS; - - if (floorz < ceilingz) - { - // Randomly assign a height, now that floorz is set. - rainmo->z = M_RandomRange(floorz, ceilingz) << FRACBITS; - } - else - { - // ...except if the floor is above the ceiling. - rainmo->z = ceilingz << FRACBITS; - } + if (floorz < ceilingz) + { + // Randomly assign a height, now that floorz is set. + rainmo->z = M_RandomRange(floorz, ceilingz) << FRACBITS; + } + else + { + // ...except if the floor is above the ceiling. + rainmo->z = ceilingz << FRACBITS; } } } diff --git a/src/p_tick.c b/src/p_tick.c index ed7252dc6..9dbdd7ed5 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -287,7 +287,7 @@ mobj_t *P_SetTarget(mobj_t **mop, mobj_t *targ) { if (*mop) // If there was a target already, decrease its refcount (*mop)->thinker.references--; -if ((*mop = targ) != NULL) // Set new target and if non-NULL, increase its counter + if ((*mop = targ) != NULL) // Set new target and if non-NULL, increase its counter targ->thinker.references++; return targ; } @@ -318,8 +318,12 @@ static inline void P_RunThinkers(void) { for (currentthinker = thinkercap.next; currentthinker != &thinkercap; currentthinker = currentthinker->next) { - if (currentthinker->function.acp1) - currentthinker->function.acp1(currentthinker); + if (currentthinker->function.acp1 == (actionf_p1)P_NullPrecipThinker) + continue; +#ifdef PARANOIA + I_Assert(currentthinker->function.acp1 != NULL) +#endif + currentthinker->function.acp1(currentthinker); } }