diff --git a/source/games/sw/src/actor.cpp b/source/games/sw/src/actor.cpp index 245608528..974c647fe 100644 --- a/source/games/sw/src/actor.cpp +++ b/source/games/sw/src/actor.cpp @@ -42,18 +42,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms BEGIN_SW_NS -IMPLEMENT_CLASS(DSWActor, false, true) -IMPLEMENT_POINTERS_START(DSWActor) -IMPLEMENT_POINTER(ownerActor) -IMPLEMENT_POINTER(user.lowActor) -IMPLEMENT_POINTER(user.lowActor) -IMPLEMENT_POINTER(user.highActor) -IMPLEMENT_POINTER(user.targetActor) -IMPLEMENT_POINTER(user.flameActor) -IMPLEMENT_POINTER(user.attachActor) -IMPLEMENT_POINTER(user.WpnGoalActor) -IMPLEMENT_POINTERS_END - extern int jump_grav; extern STATE s_DebrisNinja[]; diff --git a/source/games/sw/src/bunny.cpp b/source/games/sw/src/bunny.cpp index bf972f581..5c09c221c 100644 --- a/source/games/sw/src/bunny.cpp +++ b/source/games/sw/src/bunny.cpp @@ -951,9 +951,9 @@ int DoBunnyQuickJump(DSWActor* actor) DoPickCloseBunny(actor); // Random Chance of like sexes fighting - if (u->lowActor) + DSWActor* hitActor = u->lowActor; + if (hitActor) { - auto hitActor = u->lowActor; SPRITEp tsp = &hitActor->s(); USERp tu = hitActor->u(); @@ -993,9 +993,9 @@ int DoBunnyQuickJump(DSWActor* actor) } // Get layed! - if (u->lowActor && u->spal == PALETTE_PLAYER8) // Only males check this + hitActor = u->lowActor; + if (hitActor && u->spal == PALETTE_PLAYER8) // Only males check this { - auto hitActor = u->lowActor; SPRITEp tsp = &hitActor->s(); USERp tu = hitActor->u(); diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index 1e4c5669a..c97cffc96 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -1364,12 +1364,16 @@ void UpdateWallPortalState() } else { - auto sp = &mirror[i].cameraActor->s(); - if (!TEST_BOOL1(sp)) + DSWActor* cam = mirror[i].cameraActor; + if (cam) { - wal->portalflags = PORTAL_WALL_TO_SPRITE; - wal->portalnum = i; - wall_to_sprite_actors[i] = mirror[i].cameraActor; + auto sp = &cam->s(); + if (!TEST_BOOL1(sp)) + { + wal->portalflags = PORTAL_WALL_TO_SPRITE; + wal->portalnum = i; + wall_to_sprite_actors[i] = cam; + } } } } diff --git a/source/games/sw/src/game.cpp b/source/games/sw/src/game.cpp index 6a8a4a466..5634c9eb9 100644 --- a/source/games/sw/src/game.cpp +++ b/source/games/sw/src/game.cpp @@ -90,6 +90,18 @@ CVAR(Bool, sw_bunnyrockets, false, CVAR_SERVERINFO | CVAR_CHEAT); // This is a BEGIN_SW_NS +IMPLEMENT_CLASS(DSWActor, false, true) +IMPLEMENT_POINTERS_START(DSWActor) +IMPLEMENT_POINTER(ownerActor) +IMPLEMENT_POINTER(user.lowActor) +IMPLEMENT_POINTER(user.lowActor) +IMPLEMENT_POINTER(user.highActor) +IMPLEMENT_POINTER(user.targetActor) +IMPLEMENT_POINTER(user.flameActor) +IMPLEMENT_POINTER(user.attachActor) +IMPLEMENT_POINTER(user.WpnGoalActor) +IMPLEMENT_POINTERS_END + void pClearSpriteList(PLAYERp pp); extern int sw_snd_scratch; diff --git a/source/games/sw/src/interpso.cpp b/source/games/sw/src/interpso.cpp index 2883a6f90..3cc02ffea 100644 --- a/source/games/sw/src/interpso.cpp +++ b/source/games/sw/src/interpso.cpp @@ -353,7 +353,8 @@ void so_dointerpolations(int32_t smoothratio) // Stick at b // instead, using TSPRITE info if possible. if (data->curelement >= soi_sprx && data->curelement <= soi_sprz) { - auto actor = data->actorofang; + DSWActor* actor = data->actorofang; + if (!actor) continue; USERp u = actor->u(); if (u && (actor->s().statnum != STAT_DEFAULT) && ((TEST(u->Flags, SPR_SKIP4) && (actor->s().statnum <= STAT_SKIP4_INTERP_END)) || @@ -362,7 +363,11 @@ void so_dointerpolations(int32_t smoothratio) // Stick at b } if (data->curelement == soi_sprang) - data->actorofang->s().ang = NORM_ANGLE(data->lastoldipos + MulScale(data->lastangdiff, ratio, 16)); + { + DSWActor* actor = data->actorofang; + if (!actor) continue; + actor->s().ang = NORM_ANGLE(data->lastoldipos + MulScale(data->lastangdiff, ratio, 16)); + } else { delta = data->lastipos - data->lastoldipos; diff --git a/source/games/sw/src/jweapon.cpp b/source/games/sw/src/jweapon.cpp index 507326fea..bee304794 100644 --- a/source/games/sw/src/jweapon.cpp +++ b/source/games/sw/src/jweapon.cpp @@ -2069,7 +2069,7 @@ int DoCarryFlag(DSWActor* actor) SPRITEp sp = &actor->s(); const int FLAG_DETONATE_STATE = 99; - auto fown = u->flagOwnerActor; + DSWActor* fown = u->flagOwnerActor; if (!fown) return 0; SPRITEp fp = &fown->s(); USERp fu = fown->u(); @@ -2226,7 +2226,7 @@ int DoCarryFlagNoDet(DSWActor* actor) SPRITEp ap = &u->attachActor->s(); USERp au = u->attachActor->u(); - auto fown = u->flagOwnerActor; + DSWActor* fown = u->flagOwnerActor; if (!fown) return 0; SPRITEp fp = &fown->s(); USERp fu = fown->u(); diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index e808b6a6d..82eeef9cd 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -2556,7 +2556,8 @@ void DoPlayerMoveVehicle(PLAYERp pp) { int z; int floor_dist; - auto actor = pp->sop->sp_child; + DSWActor* actor = pp->sop->sp_child; + if (!actor) return; SPRITEp sp = &actor->s(); auto psp = &pp->Actor()->s(); USERp u = actor->u(); diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index 2c4101ae5..11b77d7c9 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -1748,7 +1748,8 @@ PlayerPart: for (i = 0; sop->so_actors[i] != nullptr; i++) { - auto actor = sop->so_actors[i]; + DSWActor* actor = sop->so_actors[i]; + if (!actor) continue; sp = &actor->s(); u = actor->u(); @@ -1977,7 +1978,8 @@ void KillSectorObjectSprites(SECTOR_OBJECTp sop) for (i = 0; sop->so_actors[i] != nullptr; i++) { - auto actor = sop->so_actors[i]; + DSWActor* actor = sop->so_actors[i]; + if (!actor) continue; sp = &actor->s(); u = actor->u(); @@ -2002,8 +2004,9 @@ void UpdateSectorObjectSprites(SECTOR_OBJECTp sop) for (i = 0; sop->so_actors[i] != nullptr; i++) { - auto actor = sop->so_actors[i]; - sp = &actor->s(); + DSWActor* actor = sop->so_actors[i]; + if (!actor) continue; + sp = &actor->s(); SetActorZ(actor, &sp->pos); } @@ -2837,7 +2840,9 @@ void DoTornadoObject(SECTOR_OBJECTp sop) void DoAutoTurretObject(SECTOR_OBJECTp sop) { - auto actor = sop->sp_child; + DSWActor* actor = sop->sp_child; + if (!actor) return; + USERp u = actor->u(); short delta_ang; int diff; @@ -2861,8 +2866,9 @@ void DoAutoTurretObject(SECTOR_OBJECTp sop) { for (i = 0; sop->so_actors[i] != nullptr; i++) { - auto sActor = sop->so_actors[i]; - auto shootp = &sActor->s(); + DSWActor* sActor = sop->so_actors[i]; + if (!sActor) continue; + auto shootp = &sActor->s(); if (shootp->statnum == STAT_SO_SHOOT_POINT) { @@ -2887,7 +2893,9 @@ void DoAutoTurretObject(SECTOR_OBJECTp sop) { for (i = 0; sop->so_actors[i] != nullptr; i++) { - auto sActor = sop->so_actors[i]; + DSWActor* sActor = sop->so_actors[i]; + if (!sActor) continue; + auto shootp = &sActor->s(); if (shootp->statnum == STAT_SO_SHOOT_POINT) diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 2e1449e89..e82ab64a1 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -4216,7 +4216,8 @@ bool VehicleMoveHit(DSWActor* actor) sop = u->sop_parent; // sprite controlling sop - auto ctrlr = sop->controller; + DSWActor* ctrlr = sop->controller; + if (!ctrlr) return false; cp = &ctrlr->s(); switch (u->coll.type) @@ -5280,7 +5281,7 @@ int ActorStdMissile(DSWActor* actor, DSWActor* weapActor) } // Reset the weapons target before dying - auto goal = wu->WpnGoalActor; + DSWActor* goal = wu->WpnGoalActor; if (goal != nullptr) { // attempt to see if it was killed @@ -8182,7 +8183,8 @@ int DoPlasmaFountain(DSWActor* actor) } else { - auto attachActor = u->attachActor; + DSWActor* attachActor = u->attachActor; + if (!attachActor) return 0; ap = &attachActor->s(); // move with sprite @@ -8887,7 +8889,7 @@ int DoMineStuck(DSWActor* actor) constexpr int MINE_DETONATE_STATE = 99; // if no Owner then die - auto attachActor = u->attachActor; + DSWActor* attachActor = u->attachActor; if (attachActor != nullptr) { SPRITEp ap = &attachActor->s(); @@ -9343,7 +9345,7 @@ int DoEMPBurst(DSWActor* actor) USER* u = actor->u(); SPRITEp sp = &actor->s(); - auto attachActor = u->attachActor; + DSWActor* attachActor = u->attachActor; if (attachActor != nullptr) { SPRITEp ap = &attachActor->s(); @@ -13185,7 +13187,7 @@ DSWActor* AimHitscanToTarget(DSWActor* actor, int *z, short *ang, int z_ratio) SPRITEp hp; USERp hu; - auto hitActor = u->targetActor; + DSWActor* hitActor = u->targetActor; if (hitActor == nullptr) return nullptr; @@ -16808,7 +16810,8 @@ int InitSobjGun(PLAYERp pp) for (i = 0; pp->sop->so_actors[i] != nullptr; i++) { - auto actor = pp->sop->so_actors[i]; + DSWActor* actor = pp->sop->so_actors[i]; + if (!actor) continue; sp = &actor->s(); if (sp->statnum == STAT_SO_SHOOT_POINT) { @@ -17079,7 +17082,8 @@ int InitTurretMgun(SECTOR_OBJECTp sop) for (i = 0; sop->so_actors[i] != nullptr; i++) { - auto actor = sop->so_actors[i]; + DSWActor* actor = sop->so_actors[i]; + if (!actor) continue; sp = &actor->s(); if (sp->statnum == STAT_SO_SHOOT_POINT) {