diff --git a/src/k_kart.c b/src/k_kart.c index a00b3cdc5..9b21f8de0 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2120,7 +2120,7 @@ static void K_PlayGenericCombatSound(mobj_t *source, mobj_t *other, sfxenum_t sf boolean alwaysHear = false; - if (P_MobjWasRemoved(other) == false && other->player != NULL) + if (other != NULL && P_MobjWasRemoved(other) == false && other->player != NULL) alwaysHear = P_IsDisplayPlayer(other->player); if (cv_kartvoices.value) @@ -2653,7 +2653,7 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, mobj_t *inflicto static void K_RemoveGrowShrink(player_t *player) { - if (!P_MobjWasRemoved(player->mo)) + if (player->mo && !P_MobjWasRemoved(player->mo)) { if (player->kartstuff[k_growshrinktimer] > 0) // Play Shrink noise S_StartSound(player->mo, sfx_kc59); @@ -3066,7 +3066,7 @@ void K_SpawnKartExplosion(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 mobj->momy = FixedMul(FixedDiv(mobjy - y, dist), FixedDiv(dist, 6*FRACUNIT)); mobj->momz = FixedMul(FixedDiv(mobjz - z, dist), FixedDiv(dist, 6*FRACUNIT)); - if (!P_MobjWasRemoved(source)) + if (source && !P_MobjWasRemoved(source)) P_SetTarget(&mobj->target, source); } } @@ -3883,7 +3883,7 @@ static mobj_t *K_FindLastTrailMobj(player_t *player) if (!player || !(trail = player->mo) || !player->mo->hnext || !player->mo->hnext->health) return NULL; - while (!P_MobjWasRemoved(trail->hnext) && trail->hnext->health) + while (trail->hnext && !P_MobjWasRemoved(trail->hnext) && trail->hnext->health) { trail = trail->hnext; } @@ -4120,7 +4120,7 @@ void K_PuntMine(mobj_t *thismine, mobj_t *punter) fixed_t spd; mobj_t *mine; - if (P_MobjWasRemoved(thismine)) + if (!thismine || P_MobjWasRemoved(thismine)) return; //This guarantees you hit a mine being dragged @@ -4149,7 +4149,7 @@ void K_PuntMine(mobj_t *thismine, mobj_t *punter) else mine = thismine; - if (P_MobjWasRemoved(mine)) + if (!mine || P_MobjWasRemoved(mine)) return; spd = K_GetProjectileSpeed(); @@ -4316,7 +4316,7 @@ void K_DoSneaker(player_t *player, INT32 type) if (player->mo->hnext) { mobj_t *cur = player->mo->hnext; - while (!P_MobjWasRemoved(cur)) + while (cur && !P_MobjWasRemoved(cur)) { if (!cur->tracer) { @@ -4380,7 +4380,7 @@ static void K_DoShrink(player_t *user) K_DropItems(&players[i]); players[i].kartstuff[k_growshrinktimer] = -(20*TICRATE); - if (!P_MobjWasRemoved(players[i].mo)) + if (players[i].mo && !P_MobjWasRemoved(players[i].mo)) { players[i].mo->scalespeed = mapobjectscale/TICRATE; players[i].mo->destscale = (6*mapobjectscale)/8; @@ -4510,7 +4510,7 @@ void K_DropHnextList(player_t *player) mobjtype_t type; boolean orbit, ponground, dropall = true; - if (P_MobjWasRemoved(work)) + if (!work || P_MobjWasRemoved(work)) return; flip = P_MobjFlip(player->mo); @@ -4649,7 +4649,7 @@ void K_DropItems(player_t *player) K_DropHnextList(player); - if (!P_MobjWasRemoved(player->mo) && player->kartstuff[k_itemamount]) + if (player->mo && !P_MobjWasRemoved(player->mo) && player->kartstuff[k_itemamount]) { mobj_t *drop = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z + player->mo->height/2, MT_FLOATINGITEM); P_SetScale(drop, drop->scale>>4); @@ -4678,7 +4678,7 @@ void K_DropRocketSneaker(player_t *player) fixed_t flingangle; boolean leftshoe = true; //left shoe is first - if (P_MobjWasRemoved(player->mo) || P_MobjWasRemoved(player->mo->hnext)) + if (!(player->mo && !P_MobjWasRemoved(player->mo) && player->mo->hnext && !P_MobjWasRemoved(player->mo->hnext))) return; while ((shoe = shoe->hnext) && !P_MobjWasRemoved(shoe)) @@ -4717,7 +4717,7 @@ void K_DropRocketSneaker(player_t *player) void K_DropKitchenSink(player_t *player) { - if (P_MobjWasRemoved(player->mo) || P_MobjWasRemoved(player->mo->hnext)) + if (!(player->mo && !P_MobjWasRemoved(player->mo) && player->mo->hnext && !P_MobjWasRemoved(player->mo->hnext))) return; if (player->mo->hnext->type != MT_SINK_SHIELD) @@ -4734,13 +4734,13 @@ void K_RepairOrbitChain(mobj_t *orbit) mobj_t *cachenext = orbit->hnext; // First, repair the chain - if (!P_MobjWasRemoved(orbit->hnext) && orbit->hnext->health) + if (orbit->hnext && orbit->hnext->health && !P_MobjWasRemoved(orbit->hnext)) { P_SetTarget(&orbit->hnext->hprev, orbit->hprev); P_SetTarget(&orbit->hnext, NULL); } - if (!P_MobjWasRemoved(orbit->hprev) && orbit->hprev->health) + if (orbit->hprev && orbit->hprev->health && !P_MobjWasRemoved(orbit->hprev)) { P_SetTarget(&orbit->hprev->hnext, cachenext); P_SetTarget(&orbit->hprev, NULL); @@ -4755,7 +4755,7 @@ void K_RepairOrbitChain(mobj_t *orbit) mobj_t *cur = orbit->target->hnext; mobj_t *prev = NULL; - while (!P_MobjWasRemoved(cur)) + while (cur && !P_MobjWasRemoved(cur)) { prev = cur; cur = cur->hnext; @@ -4960,7 +4960,7 @@ static void K_MoveHeldObjects(player_t *player) player->kartstuff[k_bananadrag] = 0; // Just to make sure - while (!P_MobjWasRemoved(cur)) + while (cur && !P_MobjWasRemoved(cur)) { const fixed_t radius = FixedHypot(player->mo->radius, player->mo->radius) + FixedHypot(cur->radius, cur->radius); // mobj's distance from its Target, or Radius. fixed_t z; @@ -5038,7 +5038,7 @@ static void K_MoveHeldObjects(player_t *player) if (P_IsObjectOnGround(player->mo) && player->speed > 0) player->kartstuff[k_bananadrag]++; - while (!P_MobjWasRemoved(cur)) + while (cur && !P_MobjWasRemoved(cur)) { const fixed_t radius = FixedHypot(targ->radius, targ->radius) + FixedHypot(cur->radius, cur->radius); angle_t ang; @@ -5066,7 +5066,7 @@ static void K_MoveHeldObjects(player_t *player) else dist = cur->extravalue1/2; - if (P_MobjWasRemoved(targ)) + if (!targ || P_MobjWasRemoved(targ)) continue; // Shrink your items if the player shrunk too. @@ -5124,7 +5124,7 @@ static void K_MoveHeldObjects(player_t *player) mobj_t *cur = player->mo->hnext; INT32 num = 0; - while (!P_MobjWasRemoved(cur)) + while (cur && !P_MobjWasRemoved(cur)) { const fixed_t radius = FixedHypot(player->mo->radius, player->mo->radius) + FixedHypot(cur->radius, cur->radius); boolean vibrate = ((leveltime & 1) && !cur->tracer); @@ -5189,7 +5189,7 @@ static void K_MoveHeldObjects(player_t *player) } - if (!P_MobjWasRemoved(cur->tracer)) + if (cur->tracer && !P_MobjWasRemoved(cur->tracer)) { fixed_t diffx, diffy, diffz; @@ -5899,7 +5899,7 @@ void K_KartPlayerAfterThink(player_t *player) else targ = K_FindJawzTarget(player->mo, player); - if (!targ || P_MobjWasRemoved(targ->mo)) + if (!targ || !targ->mo || P_MobjWasRemoved(targ->mo)) { player->kartstuff[k_lastjawztarget] = -1; player->kartstuff[k_jawztargetdelay] = 0; @@ -6324,7 +6324,7 @@ static mobj_t *K_SpawnOrMoveMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t typ { mobj_t *mobj = source->watertrail[id]; - if (P_MobjWasRemoved(mobj)) + if (!mobj || P_MobjWasRemoved(mobj)) { mobj = P_SpawnMobj(x, y, z, type); diff --git a/src/p_enemy.c b/src/p_enemy.c index 2e1571689..77028fadd 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -672,7 +672,7 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround, boolean tracer, fixed if (player->pflags & PF_INVIS) continue; // ignore notarget - if (P_MobjWasRemoved(player->mo)) + if (!player->mo || P_MobjWasRemoved(player->mo)) continue; if (dist > 0 @@ -3852,7 +3852,7 @@ void A_GrenadeRing(mobj_t *actor) static inline boolean PIT_MineExplode(mobj_t *thing) { - if (P_MobjWasRemoved(grenade)) + if (!grenade || P_MobjWasRemoved(grenade)) return false; // There's the possibility these can chain react onto themselves after they've already died if there are enough all in one spot if (grenade->flags2 & MF2_DEBRIS) // don't explode twice @@ -8020,7 +8020,7 @@ void A_JawzChase(mobj_t *actor) if (actor->extravalue1) // Disable looking by setting this return; - if (P_MobjWasRemoved(actor->target)) // No source! + if (!actor->target || P_MobjWasRemoved(actor->target)) // No source! return; player = K_FindJawzTarget(actor, actor->target->player); @@ -10921,7 +10921,7 @@ void A_InvincSparkleRotate(mobj_t *actor) if (LUA_CallAction(A_INVINCSPARKLEROTATE, actor)) return; - if (P_MobjWasRemoved(actor->target)) + if (!actor->target || P_MobjWasRemoved(actor->target)) return; //CONS_Printf("%d\n", actor->movefactor/FRACUNIT); @@ -10937,7 +10937,7 @@ void A_InvincSparkleRotate(mobj_t *actor) actor->angle += ANG1*10*(actor->extravalue2); // Arbitrary value, change this if you want, I suppose. ghost = P_SpawnGhostMobj(actor); - if (!P_MobjWasRemoved(ghost)) + if (ghost != NULL && P_MobjWasRemoved(ghost) == false) { //ghost->frame |= FF_ADD; ghost->fuse = 4; diff --git a/src/p_floor.c b/src/p_floor.c index 9a09b2cc4..2aa9cf0f7 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -2516,7 +2516,7 @@ void T_CameraScanner(elevator_t *elevator) for (UINT8 i = 0; i <= splitscreen; i++) { - if (P_MobjWasRemoved(players[displayplayers[i]].mo)) + if (!players[displayplayers[i]].mo || P_MobjWasRemoved(players[displayplayers[i]].mo)) continue; if (players[displayplayers[i]].mo->subsector->sector == elevator->actionsector) diff --git a/src/p_inter.c b/src/p_inter.c index d20da0758..7e2d8b802 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -548,7 +548,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (player->spectator) return; - if (!P_MobjWasRemoved(special->tracer) && toucher == special->tracer) + if (special->tracer && !P_MobjWasRemoved(special->tracer) && toucher == special->tracer) { mobj_t *spbexplode; @@ -563,7 +563,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) spbexplode = P_SpawnMobj(toucher->x, toucher->y, toucher->z, MT_SPBEXPLOSION); spbexplode->extravalue1 = 1; // Tell K_ExplodePlayer to use extra knockback - if (!P_MobjWasRemoved(special->target)) + if (special->target && !P_MobjWasRemoved(special->target)) P_SetTarget(&spbexplode->target, special->target); P_RemoveMobj(special); @@ -572,7 +572,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) K_SpinPlayer(player, special->target, 0, special, false); return; case MT_SMK_MOLE: - if (!P_MobjWasRemoved(special->target)) + if (special->target && !P_MobjWasRemoved(special->target)) return; if (special->health <= 0 || toucher->health <= 0) @@ -1895,7 +1895,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) case MT_SMK_ICEBLOCK: { mobj_t *cur = target->hnext; - while (!P_MobjWasRemoved(cur)) + while (cur && !P_MobjWasRemoved(cur)) { P_SetMobjState(cur, S_SMK_ICEBLOCK2); cur = cur->hnext; @@ -2007,14 +2007,14 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) // kill tracer if (target->type == MT_FROGGER) { - if (!P_MobjWasRemoved(target->tracer)) + if (target->tracer && !P_MobjWasRemoved(target->tracer)) P_KillMobj(target->tracer, inflictor, source); } if (target->type == MT_FROGGER || target->type == MT_ROBRA_HEAD || target->type == MT_BLUEROBRA_HEAD) // clean hnext list { mobj_t *cur = target->hnext; - while (!P_MobjWasRemoved(cur)) + while (cur && !P_MobjWasRemoved(cur)) { P_KillMobj(cur, inflictor, source); cur = cur->hnext; @@ -2439,7 +2439,6 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da if (!metalrecording) { UINT8 shouldForce = LUA_HookShouldDamage(target, inflictor, source, damage); - if (P_MobjWasRemoved(target)) return (shouldForce == 1); // mobj was removed if (shouldForce == 1) diff --git a/src/p_map.c b/src/p_map.c index 1da5a72a5..2ead78d9e 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -321,7 +321,7 @@ static boolean PIT_CheckThing(mobj_t *thing) return true; // Ignore... things. - if (!tmthing || P_MobjWasRemoved(thing)) + if (!tmthing || !thing || P_MobjWasRemoved(thing)) return true; I_Assert(!P_MobjWasRemoved(tmthing)); diff --git a/src/p_mobj.c b/src/p_mobj.c index dc4128be1..b0ab45d89 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -66,7 +66,7 @@ void P_RunCachedActions(void) var2 = states[ac->statenum].var2; astate = &states[ac->statenum]; - if (!P_MobjWasRemoved(ac->mobj)) // just in case... + if (ac->mobj && !P_MobjWasRemoved(ac->mobj)) // just in case... states[ac->statenum].action.acp1(ac->mobj); next = ac->next; Z_Free(ac); @@ -3330,7 +3330,7 @@ void P_CalcChasePostImg(player_t *player, camera_t *thiscam) } #endif - if (player->awayviewtics && !P_MobjWasRemoved(player->awayviewmobj)) // Camera must obviously exist + if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) // Camera must obviously exist { camera_t dummycam; @@ -3826,7 +3826,7 @@ boolean P_BossTargetPlayer(mobj_t *actor, boolean closest) if (player->pflags & PF_INVIS || player->bot || player->spectator) continue; // ignore notarget - if (P_MobjWasRemoved(player->mo)) + if (!player->mo || P_MobjWasRemoved(player->mo)) continue; if (!P_CheckSight(actor, player->mo)) @@ -5933,7 +5933,7 @@ void P_RunShadows(void) next = mobj->hnext; P_SetTarget(&mobj->hnext, NULL); - if (P_MobjWasRemoved(mobj->target)) + if (!mobj->target || P_MobjWasRemoved(mobj->target)) { mobj->flags2 |= MF2_DONTDRAW; continue; // shouldn't you already be dead? @@ -6218,14 +6218,14 @@ void P_MobjThinker(mobj_t *mobj) return; // Remove dead target/tracer. - if (P_MobjWasRemoved(mobj->target)) + if (mobj->target && P_MobjWasRemoved(mobj->target)) P_SetTarget(&mobj->target, NULL); - if (P_MobjWasRemoved(mobj->tracer)) + if (mobj->tracer && P_MobjWasRemoved(mobj->tracer)) P_SetTarget(&mobj->tracer, NULL); // hnext/hprev changes suggested by toaster - if (P_MobjWasRemoved(mobj->hnext)) + if (mobj->hnext && P_MobjWasRemoved(mobj->hnext)) P_SetTarget(&mobj->hnext, NULL); - if (P_MobjWasRemoved(mobj->hprev)) + if (mobj->hprev && P_MobjWasRemoved(mobj->hprev)) P_SetTarget(&mobj->hprev, NULL); mobj->flags2 &= ~MF2_PUSHED; @@ -6959,7 +6959,7 @@ void P_MobjThinker(mobj_t *mobj) } break; case MT_FIREDITEM: - if (!P_MobjWasRemoved(mobj->target)) + if (mobj->target && !P_MobjWasRemoved(mobj->target)) { fixed_t x, y, z; if (mobj->movecount) @@ -8150,7 +8150,7 @@ void P_MobjThinker(mobj_t *mobj) P_MoveOrigin(mobj, mobj->target->x, mobj->target->y, mobj->target->z); break; case MT_BATTLEPOINT: - if (P_MobjWasRemoved(mobj->target)) + if (!mobj->target || P_MobjWasRemoved(mobj->target)) { P_RemoveMobj(mobj); return; @@ -8293,7 +8293,7 @@ void P_MobjThinker(mobj_t *mobj) const fixed_t rad = FixedMul(mobjinfo[MT_PLAYER].radius, mobj->target->scale); mobj_t *cur = mobj->hnext; - while (!P_MobjWasRemoved(cur)) + while (cur && !P_MobjWasRemoved(cur)) { fixed_t offx = rad; fixed_t offy = rad; @@ -8429,7 +8429,7 @@ void P_MobjThinker(mobj_t *mobj) { mobj_t *cur = mobj->hnext; - while (!P_MobjWasRemoved(cur)) + while (cur && !P_MobjWasRemoved(cur)) { cur->angle += FixedAngle(mobj->info->speed); P_MoveOrigin(cur, mobj->x + FINECOSINE((cur->angle*8)>>ANGLETOFINESHIFT), @@ -8461,7 +8461,7 @@ void P_MobjThinker(mobj_t *mobj) if (mobj->hnext) // Clean hnext list { mobj_t *cur = mobj->hnext; - while (!P_MobjWasRemoved(cur)) + while (cur && !P_MobjWasRemoved(cur)) { mobj_t *next = cur->hnext; P_RemoveMobj(cur); @@ -8489,7 +8489,7 @@ void P_MobjThinker(mobj_t *mobj) } else if (frogstate == S_FROGGER_ATTACK) { - if (P_MobjWasRemoved(mobj->tracer)) + if (!mobj->tracer || P_MobjWasRemoved(mobj->tracer)) { mobj->reactiontime = mobj->info->reactiontime; P_SetMobjState(mobj, S_FROGGER); @@ -8539,7 +8539,7 @@ void P_MobjThinker(mobj_t *mobj) if (mobj->hnext) // Clean hnext list { mobj_t *cur = mobj->hnext; - while (!P_MobjWasRemoved(cur)) + while (cur && !P_MobjWasRemoved(cur)) { mobj_t *next = cur->hnext; P_RemoveMobj(cur); @@ -8564,7 +8564,7 @@ void P_MobjThinker(mobj_t *mobj) fixed_t wy = mobj->tracer->y + (joint * (mobj->y - mobj->tracer->y) / (numjoints+1)); fixed_t wz = mobj->tracer->z + (joint * ((mobj->z + (mobj->height/2)) - mobj->tracer->z) / (numjoints+1)); - if (!P_MobjWasRemoved(cur)) + if (cur && !P_MobjWasRemoved(cur)) P_MoveOrigin(cur, wx, wy, wz); else cur = P_SpawnMobj(wx, wy, wz, MT_FROGTONGUE_JOINT); @@ -8629,14 +8629,14 @@ void P_MobjThinker(mobj_t *mobj) } } - if (mobj->extravalue1 && P_MobjWasRemoved(mobj->tracer)) + if ((mobj->extravalue1) && !(mobj->tracer && !P_MobjWasRemoved(mobj->tracer))) { mobj->reactiontime = 20*mobj->info->reactiontime; P_SetTarget(&mobj->target, NULL); mobj->extravalue1 = 0; } - if (!P_MobjWasRemoved(mobj->tracer) && !(leveltime % 10)) + if ((mobj->tracer && !P_MobjWasRemoved(mobj->tracer)) && !(leveltime % 10)) { mobj_t *dust = P_SpawnMobj(mobj->x + (P_RandomRange(-4, 4)<y + (P_RandomRange(-4, 4)<z - ((i+1) * (32 * mobj->scale)); - if (!P_MobjWasRemoved(cur)) + if (cur && !P_MobjWasRemoved(cur)) { if (i >= locnumsegs) // Remove extras { @@ -8722,7 +8722,7 @@ void P_MobjThinker(mobj_t *mobj) break; case MT_ROBRA_JOINT: case MT_BLUEROBRA_JOINT: - if (P_MobjWasRemoved(mobj->target)) + if (!mobj->target || P_MobjWasRemoved(mobj->target)) { P_RemoveMobj(mobj); return; @@ -8735,7 +8735,7 @@ void P_MobjThinker(mobj_t *mobj) P_SetMobjStateNF(mobj, mobj->info->spawnstate); break; case MT_SMK_MOLESPAWNER: - if (P_MobjWasRemoved(mobj->target)) + if (!mobj->target || P_MobjWasRemoved(mobj->target)) { mobj_t *newmole = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_SMK_MOLE); P_SetTarget(&mobj->target, newmole); @@ -8743,7 +8743,7 @@ void P_MobjThinker(mobj_t *mobj) } break; case MT_SMK_MOLE: - if (!P_MobjWasRemoved(mobj->target) && mobj->target->player) + if (mobj->target && !P_MobjWasRemoved(mobj->target) && mobj->target->player) { player_t *player = mobj->target->player; @@ -9206,7 +9206,7 @@ void P_MobjThinker(mobj_t *mobj) S_StartSound(debris, sfx_s3k82); } - while (!P_MobjWasRemoved(cur)) + while (cur && !P_MobjWasRemoved(cur)) { next = cur->hnext; P_RemoveMobj(cur); @@ -10209,7 +10209,7 @@ void P_RemoveMobj(mobj_t *mobj) { mobj_t *cur = mobj->hnext; - while (!P_MobjWasRemoved(cur)) + while (cur && !P_MobjWasRemoved(cur)) { mobj_t *prev = cur; // Kind of a dumb var, but we need to set cur before we remove the mobj cur = cur->hnext; @@ -10251,13 +10251,13 @@ void P_RemoveMobj(mobj_t *mobj) // repair hnext chain mobj_t *cachenext = mobj->hnext; - if (!P_MobjWasRemoved(mobj->hnext)) + if (mobj->hnext && !P_MobjWasRemoved(mobj->hnext)) { P_SetTarget(&mobj->hnext->hprev, mobj->hprev); P_SetTarget(&mobj->hnext, NULL); } - if (!P_MobjWasRemoved(mobj->hprev)) + if (mobj->hprev && !P_MobjWasRemoved(mobj->hprev)) { P_SetTarget(&mobj->hprev->hnext, cachenext); P_SetTarget(&mobj->hprev, NULL); @@ -11448,7 +11448,7 @@ void P_SpawnMapThing(mapthing_t *mthing) mobj = P_SpawnMobj(x, y, z, i); - if (P_MobjWasRemoved(mobj)) + if (!mobj || P_MobjWasRemoved(mobj)) { CONS_Alert(CONS_ERROR, "Failed to spawn map thing #%d at %d, %d. This will crash vanilla clients!\n", mthing->type, x>>FRACBITS, y>>FRACBITS); return; diff --git a/src/p_spec.c b/src/p_spec.c index 8b4568f93..670951163 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1298,7 +1298,7 @@ void T_ExecutorDelay(executor_t *e) { if (--e->timer <= 0) { - if (P_MobjWasRemoved(e->caller)) // If the mobj died while we were delaying + if (e->caller && P_MobjWasRemoved(e->caller)) // If the mobj died while we were delaying P_SetTarget(&e->caller, NULL); // Call with no mobj! P_ProcessLineSpecial(e->line, e->caller, e->sector); P_SetTarget(&e->caller, NULL); // Let the mobj know it can be removed now. diff --git a/src/p_tick.c b/src/p_tick.c index 4d3d82e21..2fb35533a 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -400,7 +400,7 @@ static void P_DeviceRumbleTick(void) continue; } - if (P_MobjWasRemoved(player->mo)) + if (player->mo == NULL) { continue; } @@ -647,12 +647,8 @@ void P_Ticker(boolean run) PS_START_TIMING(ps_playerthink_time); for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || P_MobjWasRemoved(players[i].mo)) - continue; - - P_PlayerThink(&players[i]); - } + if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) + P_PlayerThink(&players[i]); PS_STOP_TIMING(ps_playerthink_time); } @@ -671,11 +667,8 @@ void P_Ticker(boolean run) // Run any "after all the other thinkers" stuff for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || P_MobjWasRemoved(players[i].mo)) - continue; - P_PlayerAfterThink(&players[i]); - } + if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) + P_PlayerAfterThink(&players[i]); // Apply rumble to local players if (!demo.playback) @@ -688,7 +681,10 @@ void P_Ticker(boolean run) PS_STOP_TIMING(ps_lua_thinkframe_time); } + // Run shield positioning + //P_RunShields(); P_RunOverlays(); + P_RunShadows(); P_UpdateSpecials(); @@ -782,8 +778,10 @@ void P_Ticker(boolean run) if (modeattacking) G_GhostTicker(); - if (mapreset > 1 && (--mapreset <= 1) && server) // Remember: server uses it for mapchange, but EVERYONE ticks down for the animation - D_MapChange(gamemap, gametype, encoremode, true, 0, false, false); + if (mapreset > 1 + && --mapreset <= 1 + && server) // Remember: server uses it for mapchange, but EVERYONE ticks down for the animation + D_MapChange(gamemap, gametype, encoremode, true, 0, false, false); PS_START_TIMING(ps_lua_postthinkframe_time); LUA_HookPostThinkFrame(); @@ -846,22 +844,20 @@ void P_PreTicker(INT32 frames) LUA_HOOK(PreThinkFrame); for (i = 0; i < MAXPLAYERS; i++) - { - if (playeringame[i] || P_MobjWasRemoved(players[i].mo)) - continue; + if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) + { + // stupid fucking cmd hack + // if it isn't for this, players can move in preticker time + // (and disrupt demo recording and other things !!) + memcpy(&temptic, &players[i].cmd, sizeof(ticcmd_t)); + memset(&players[i].cmd, 0, sizeof(ticcmd_t)); + // correct angle on spawn... + players[i].cmd.angleturn = temptic.angleturn; - // stupid fucking cmd hack - // if it isn't for this, players can move in preticker time - // (and disrupt demo recording and other things !!) - memcpy(&temptic, &players[i].cmd, sizeof(ticcmd_t)); - memset(&players[i].cmd, 0, sizeof(ticcmd_t)); - // correct angle on spawn... - players[i].cmd.angleturn = temptic.angleturn; + P_PlayerThink(&players[i]); - P_PlayerThink(&players[i]); - - memcpy(&players[i].cmd, &temptic, sizeof(ticcmd_t)); - } + memcpy(&players[i].cmd, &temptic, sizeof(ticcmd_t)); + } // Dynamic slopeness if (midgamejoin) @@ -875,7 +871,7 @@ void P_PreTicker(INT32 frames) if (!playeringame[i]) continue; - if (P_MobjWasRemoved(players[i].mo)) + if (!players[i].mo || P_MobjWasRemoved(players[i].mo)) continue; P_PlayerAfterThink(&players[i]); diff --git a/src/p_user.c b/src/p_user.c index bb03049f6..388d09f28 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4285,7 +4285,7 @@ static void P_CalcPostImg(player_t *player, camera_t *thiscam) else pviewheight = player->mo->z + player->viewheight; - if (!P_MobjWasRemoved(player->awayviewmobj)) + if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) { sector = player->awayviewmobj->subsector->sector; pviewheight = player->awayviewmobj->z + 20*FRACUNIT;