diff --git a/src/m_perfstats.c b/src/m_perfstats.c index 84ad883d1..fd08d1a9c 100644 --- a/src/m_perfstats.c +++ b/src/m_perfstats.c @@ -50,17 +50,14 @@ ps_metric_t ps_tictime = {0}; ps_metric_t ps_playerthink_time = {0}; ps_metric_t ps_thinkertime = {0}; -ps_metric_t ps_thlist_times[NUM_THINKERLISTS]; +//ps_metric_t ps_thlist_times[NUM_THINKERLISTS]; static ps_metric_t ps_thinkercount = {0}; -static ps_metric_t ps_polythcount = {0}; -static ps_metric_t ps_mainthcount = {0}; static ps_metric_t ps_mobjcount = {0}; 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_dynslopethcount = {0}; +static ps_metric_t ps_otherthcount = {0}; static ps_metric_t ps_precipcount = {0}; static ps_metric_t ps_removecount = {0}; @@ -157,11 +154,11 @@ perfstatrow_t gamelogic_rows[] = { {"logic ", "Game logic: ", &ps_tictime, PS_TIME}, {" plrthnk", " P_PlayerThink: ", &ps_playerthink_time, PS_TIME|PS_LEVEL}, {" thnkers", " P_RunThinkers: ", &ps_thinkertime, PS_TIME|PS_LEVEL}, - {" plyobjs", " Polyobjects: ", &ps_thlist_times[THINK_POLYOBJ], PS_TIME|PS_LEVEL}, +/* {" plyobjs", " Polyobjects: ", &ps_thlist_times[THINK_POLYOBJ], PS_TIME|PS_LEVEL}, {" main ", " Main: ", &ps_thlist_times[THINK_MAIN], PS_TIME|PS_LEVEL}, {" mobjs ", " Mobjs: ", &ps_thlist_times[THINK_MOBJ], PS_TIME|PS_LEVEL}, - //{" dynslop", " Dynamic slopes: ", &ps_thlist_times[THINK_DYNSLOPE], PS_TIME|PS_LEVEL}, - {" precip ", " Precipitation: ", &ps_thlist_times[THINK_PRECIP], PS_TIME|PS_LEVEL}, + {" dynslop", " Dynamic slopes: ", &ps_thlist_times[THINK_DYNSLOPE], PS_TIME|PS_LEVEL}, + {" precip ", " Precipitation: ", &ps_thlist_times[THINK_PRECIP], PS_TIME|PS_LEVEL},*/ {" lprethinkf", " LUAh_PreThinkFrame:", &ps_lua_prethinkframe_time, PS_TIME|PS_LEVEL}, {" lthinkf", " LUAh_ThinkFrame:", &ps_lua_thinkframe_time, PS_TIME|PS_LEVEL}, {" lpostthinkf", " LUAh_PostThinkFrame:", &ps_lua_postthinkframe_time, PS_TIME|PS_LEVEL}, @@ -171,14 +168,11 @@ perfstatrow_t gamelogic_rows[] = { perfstatrow_t thinkercount_rows[] = { {"thnkers", "Thinkers: ", &ps_thinkercount, PS_LEVEL}, - {" plyobjs", " Polyobjects: ", &ps_polythcount, PS_LEVEL}, - {" main ", " Main: ", &ps_mainthcount, PS_LEVEL}, {" mobjs ", " Mobjs: ", &ps_mobjcount, PS_LEVEL}, {" regular", " Regular: ", &ps_regularcount, PS_LEVEL}, {" scenery", " Scenery: ", &ps_scenerycount, PS_LEVEL}, {" nothink", " Nothink: ", &ps_nothinkcount, PS_HIDE_ZERO|PS_LEVEL}, - //{" dynslop", " Dynamic slopes: ", &ps_dynslopethcount, PS_LEVEL}, - //{" other ", " Other: ", &ps_otherthcount, PS_LEVEL}, + {" other ", " Other: ", &ps_otherthcount, PS_LEVEL}, {" precip ", " Precipitation: ", &ps_precipcount, PS_LEVEL}, {" remove ", " Pending removal:", &ps_removecount, PS_LEVEL}, {0} @@ -573,18 +567,14 @@ static void PS_CountThinkers(void) thinker_t *thinker; ps_thinkercount.value.i = 0; - ps_polythcount.value.i = 0; - ps_mainthcount.value.i = 0; ps_mobjcount.value.i = 0; ps_regularcount.value.i = 0; ps_scenerycount.value.i = 0; ps_nothinkcount.value.i = 0; - //ps_otherthcount.value.i = 0; - //ps_dynslopethcount.value.i = 0; + ps_otherthcount.value.i = 0; ps_precipcount.value.i = 0; ps_removecount.value.i = 0; - - /*for (thinker = thlist[THINK_MAIN].next; thinker != &thlist[THINK_MAIN]; thinker = thinker->next) + for (thinker = thlist[THINK_MAIN].next; thinker != &thlist[THINK_MAIN]; thinker = thinker->next) { ps_thinkercount.value.i++; if (thinker->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) @@ -604,9 +594,8 @@ static void PS_CountThinkers(void) ps_precipcount.value.i++; else ps_otherthcount.value.i++; - }*/ - - for (int i = 0; i < NUM_THINKERLISTS; i++) + } + /*for (i = 0; i < NUM_THINKERLISTS; i++) { for (thinker = thlist[i].next; thinker != &thlist[i]; thinker = thinker->next) { @@ -631,12 +620,12 @@ static void PS_CountThinkers(void) ps_regularcount.value.i++; } } - //else if (i == THINK_DYNSLOPE) - //ps_dynslopethcount.value.i++; + else if (i == THINK_DYNSLOPE) + ps_dynslopethcount.value.i++; else if (i == THINK_PRECIP) ps_precipcount.value.i++; } - } + }*/ } // Update all metrics that are calculated on every tick. diff --git a/src/p_enemy.c b/src/p_enemy.c index 5f752deb9..dfd5ea139 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -2417,7 +2417,6 @@ void A_1upThinker(mobj_t *actor) if (closestplayer == -1 || skins[players[closestplayer].skin].spritedef.numframes <= states[S_PLAY_BOX1].frame) { // Closest player not found (no players in game?? may be empty dedicated server!), or does not have correct sprite. - actor->frame = 0; if (actor->tracer) { mobj_t *tracer = actor->tracer; @@ -2637,10 +2636,7 @@ void A_BossDeath(mobj_t *mo) continue; mo2 = (mobj_t *)th; - if (mo2 == mo) - continue; - - if ((mo2->flags & MF_BOSS) && mo2->health > 0) + if (mo2 != mo && (mo2->flags & MF_BOSS) && mo2->health > 0) goto bossjustdie; // other boss not dead - just go straight to dying! } @@ -2695,7 +2691,7 @@ bossjustdie: for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; + continue; mo2 = (mobj_t *)th; @@ -6870,7 +6866,7 @@ void A_Boss3Path(mobj_t *actor) for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; + continue; mo2 = (mobj_t *)th; diff --git a/src/p_inter.c b/src/p_inter.c index c3b44dcfa..04a8b7696 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1211,12 +1211,11 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) continue; mo2 = (mobj_t *)th; - - if (mo2->type != MT_KOOPA) - continue; - - mo2->momz = 5*FRACUNIT; - break; + if (mo2->type == MT_KOOPA) + { + mo2->momz = 5*FRACUNIT; + break; + } } } break; @@ -2370,14 +2369,12 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) continue; mo = (mobj_t *)th; - if (mo->type != (mobjtype_t)target->info->mass) - continue; - if (mo->tracer != target) - continue; - - P_RemoveMobj(mo); - - if (++i == 2) // we've already removed 2 of these, let's stop now + if (mo->type == (mobjtype_t)target->info->mass && mo->tracer == target) + { + P_RemoveMobj(mo); + i++; + } + if (i == 2) // we've already removed 2 of these, let's stop now break; } } diff --git a/src/p_map.c b/src/p_map.c index 733ca6b5c..e5b2bc974 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -3706,23 +3706,16 @@ static boolean PIT_ChangeSector(mobj_t *thing, boolean realcrush) continue; crumbler = (elevator_t *)think; - - if (!crumbler->player) - continue; - if (!crumbler->player->mo) - continue; - if (crumbler->player->mo == thing) - continue; - if (crumbler->actionsector != thing->subsector->sector) - continue; - if (crumbler->sector != rover->master->frontsector) - continue; - if (crumbler->type != elevateBounce) - continue; - if (crumbler->type != elevateContinuous) - continue; - killer = crumbler->player->mo; + if (crumbler->player && crumbler->player->mo + && crumbler->player->mo != thing + && crumbler->actionsector == thing->subsector->sector + && crumbler->sector == rover->master->frontsector + && (crumbler->type == elevateBounce + || crumbler->type == elevateContinuous)) + { + killer = crumbler->player->mo; + } } } } diff --git a/src/p_mobj.c b/src/p_mobj.c index 5415c575a..d39f70430 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -4119,6 +4119,8 @@ static void P_Boss3Thinker(mobj_t *mobj) continue; if (mo2->spawnpoint->angle != mobj->threshold) continue; + if (mo2->spawnpoint->extrainfo != mobj->cusval) + continue; P_SetTarget(&mobj->tracer, mo2); break; diff --git a/src/p_spec.c b/src/p_spec.c index da9da9803..db2ba3e91 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3759,17 +3759,11 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers // The chimps are my friends.. heeheeheheehehee..... - LouisJM for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - mo2 = (mobj_t *)th; - - if (!mo2) - continue; - - if (mo2->type != MT_EGGTRAP) - continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; - + mo2 = (mobj_t *)th; + if (mo2->type != MT_EGGTRAP) + continue; P_KillMobj(mo2, NULL, player->mo); } diff --git a/src/p_tick.c b/src/p_tick.c index 95047bb25..0c9b3bff3 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -237,7 +237,32 @@ void P_RemoveThinkerDelayed(thinker_t *thinker) thinker_t *next; if (thinker->references != 0) + { +#ifdef PARANOIA + if (thinker->debug_time > leveltime) + { + thinker->debug_time = leveltime + 2; // do not print errors again + } + // Removed mobjs can be the target of another mobj. In + // that case, the other mobj will manage its reference + // to the removed mobj in P_MobjThinker. However, if + // the removed mobj is removed after the other object + // thinks, the reference management is delayed by one + // tic. + else if (thinker->debug_time < leveltime) + { + CONS_Printf( + "PARANOIA/P_RemoveThinkerDelayed: %p %s references=%d\n", + (void*)thinker, + MobjTypeName((mobj_t*)thinker), + thinker->references + ); + + thinker->debug_time = leveltime + 2; // do not print this error again + } +#endif return; + } /* Remove from main thinker list */ next = thinker->next; @@ -258,6 +283,7 @@ void P_RemoveThinkerDelayed(thinker_t *thinker) { Z_Free(thinker); } + } // @@ -292,18 +318,13 @@ void P_RemoveThinker(thinker_t *thinker) mobj_t *P_SetTarget(mobj_t **mop, mobj_t *targ) { - if (*mop) // If there was a target already, decrease its refcount + if (*mop) // If there was a target already, decrease its refcount (*mop)->thinker.references--; - - if (targ != NULL) // Set new target and if non-NULL, increase its counter - targ->thinker.references++; - - *mop = targ; - + if ((*mop = targ) != NULL) // Set new target and if non-NULL, increase its counter + targ->thinker.references++; return targ; } - // // P_RunThinkers // @@ -339,6 +360,7 @@ static inline void P_RunThinkers(void) currentthinker->function.acp1(currentthinker); } } + } // diff --git a/src/r_data.c b/src/r_data.c index c348f37fd..bece7f040 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1771,8 +1771,7 @@ void R_PrecacheLevel(void) if (spritepresent == NULL) I_Error("%s: Out of memory looking up sprites", "R_PrecacheLevel"); for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) - if (th->function.acp1 != (actionf_p1)P_RemoveThinkerDelayed) - spritepresent[((mobj_t *)th)->sprite] = 1; + spritepresent[((mobj_t *)th)->sprite] = 1; spritememory = 0; for (i = 0; i < numsprites; i++)