diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 37c133df4..be033173c 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -2038,17 +2038,13 @@ struct GameInterface : public ::GameInterface }; +END_SW_NS + +#include "swactor.h" + +BEGIN_SW_NS + // OVER and UNDER water macros -inline bool SpriteInDiveArea(SPRITEp sp) -{ - return (TEST(sp->sector()->extra, SECTFX_DIVE_AREA) ? true : false); -} - -inline bool SpriteInUnderwaterArea(SPRITEp sp) -{ - return (TEST(sp->sector()->extra, SECTFX_UNDERWATER | SECTFX_UNDERWATER2) ? true : false); -} - inline bool SectorIsDiveArea(sectortype* sect) { return (TEST(sect->extra, SECTFX_DIVE_AREA) ? true : false); @@ -2060,12 +2056,6 @@ inline bool SectorIsUnderwaterArea(sectortype* sect) return (TEST(sect->extra, SECTFX_UNDERWATER | SECTFX_UNDERWATER2) ? true : false); } -END_SW_NS - -#include "swactor.h" - -BEGIN_SW_NS - inline int PlayerFacingRange(PLAYERp pp, DSWActor* a, int range) { return (abs(getincangle(getangle(a->spr.pos.X - (pp)->pos.X, a->spr.pos.Y - (pp)->pos.Y), (pp)->angle.ang.asbuild())) < (range)); diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 9a70a05a9..c4825d04d 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1696,8 +1696,9 @@ void DoPlayerSpriteBob(PLAYERp pp, short player_height, short bob_amt, short bob void UpdatePlayerUnderSprite(PLAYERp pp) { - SPRITEp over_sp = &pp->Actor()->s(); - USERp over_u = pp->Actor()->u(); + auto actor = pp->actor; + SPRITEp over_sp = &actor->s(); + USERp over_u = actor->u(); SPRITEp sp; USERp u; @@ -1708,15 +1709,14 @@ void UpdatePlayerUnderSprite(PLAYERp pp) if (Prediction) return; - ASSERT(over_sp); ASSERT(over_u); // dont bother spawning if you ain't really in the water - water_level_z = over_sp->sector()->floorz; // - Z(pp->WadeDepth); + water_level_z = actor->spr.sector()->floorz; // - Z(pp->WadeDepth); // if not below water - above_water = (GetSpriteZOfBottom(over_sp) <= water_level_z); - in_dive_area = SpriteInDiveArea(over_sp); + above_water = (ActorZOfBottom(actor) <= water_level_z); + in_dive_area = SpriteInDiveArea(actor); // if not in dive area OR (in dive area AND above the water) - Kill it if (!in_dive_area || (in_dive_area && above_water)) @@ -1742,10 +1742,8 @@ void UpdatePlayerUnderSprite(PLAYERp pp) sp = &pp->PlayerUnderActor->s(); u = pp->PlayerUnderActor->u(); - sp->pos.X = over_sp->pos.X; - sp->pos.Y = over_sp->pos.Y; - sp->pos.Z = over_sp->pos.Z; - ChangeActorSect(pp->PlayerUnderActor, over_sp->sector()); + sp->pos = actor->spr.pos; + ChangeActorSect(pp->PlayerUnderActor, actor->spr.sector()); SpriteWarpToUnderwater(pp->PlayerUnderActor); @@ -1760,7 +1758,7 @@ void UpdatePlayerUnderSprite(PLAYERp pp) u->Rot = over_u->Rot; u->StateStart = over_u->StateStart; - sp->picnum = over_sp->picnum; + sp->picnum = actor->spr.picnum; }