From 60a97f781e0776cf4e5cd572a76396b01d4e6ec1 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 27 Nov 2022 13:36:55 +1100 Subject: [PATCH] - Add `DCoreActor` pointer as `PlayerAngles::pActor`, setting and nulling where the player's actor is set. --- source/core/gameinput.cpp | 1 + source/core/gameinput.h | 5 +++++ source/games/blood/src/player.cpp | 1 + source/games/duke/src/premap.cpp | 1 + source/games/exhumed/src/init.cpp | 1 + source/games/exhumed/src/player.cpp | 4 ++++ source/games/sw/src/game.cpp | 1 + source/games/sw/src/ninja.cpp | 2 ++ 8 files changed, 16 insertions(+) diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index 0bc384ddb..6d61886aa 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -338,6 +338,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngles& w, P ("lookang", w.ZzLOOKANG) ("rotscrnang", w.ZzROTSCRNANG) ("spin", w.YawSpin) + ("actor", w.pActor) ("inputdisabled", w.legacyDisabledYaw) ("horiz", w.ZzHORIZON) ("horizoff", w.ZzHORIZOFF) diff --git a/source/core/gameinput.h b/source/core/gameinput.h index 53e2339e3..b03f1300e 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -17,6 +17,9 @@ struct PlayerAngles // Prototypes for applying view. void doViewPitch(const DVector2& pos, DAngle const ang, bool const aimmode, bool const canslopetilt, sectortype* const cursectnum, double const scaleAdjust = 1, bool const climbing = false); + // General methods. + void setActor(DCoreActor* const actor) { pActor = actor; } + // Pitch methods. void lockPitch() { legacyDisabledPitch = true; } void unlockPitch() { legacyDisabledPitch = false; } @@ -180,6 +183,8 @@ struct PlayerAngles void resetAdjustmentYaw() { legacyAdjustmentYaw = nullAngle; } private: + // Private data which should never be accessed publically. + DCoreActor* pActor; // Legacy, to be removed. diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index 395b50785..45a006a1e 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -801,6 +801,7 @@ void playerStart(int nPlayer, int bNewLevel) auto actor = actSpawnSprite(pStartZone->sector, pStartZone->pos, 6, 1); assert(actor->hasX()); pPlayer->actor = actor; + pPlayer->Angles.setActor(actor); DUDEINFO* pDudeInfo = &dudeInfo[kDudePlayer1 + nPlayer - kDudeBase]; pPlayer->pDudeInfo = pDudeInfo; playerSetRace(pPlayer, kModeHuman); diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 7e81281f8..5f2a34a1e 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -622,6 +622,7 @@ void resetpspritevars(int g, const DVector3& startpos) act->spr.pal = ps[j].palookup = ud.user_pals[j]; ps[j].actor = act; + ps[j].Angles.setActor(act); ps[j].frag_ps = j; act->SetOwner(act); diff --git a/source/games/exhumed/src/init.cpp b/source/games/exhumed/src/init.cpp index 7ef6d6396..fc368b9d1 100644 --- a/source/games/exhumed/src/init.cpp +++ b/source/games/exhumed/src/init.cpp @@ -156,6 +156,7 @@ uint8_t LoadLevel(MapRecord* map) for (i = 0; i < kMaxPlayers; i++) { PlayerList[i].pActor = nullptr; + PlayerList[i].Angles.setActor(nullptr); } g_visibility = 1024; diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 3e4f1984a..965942b29 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -181,6 +181,7 @@ void InitPlayer() { for (int i = 0; i < kMaxPlayers; i++) { PlayerList[i].pActor = nullptr; + PlayerList[i].Angles.setActor(nullptr); PlayerList[i].pPlayerPushSect = nullptr; PlayerList[i].pPlayerViewSect = nullptr; } @@ -209,6 +210,7 @@ void InitPlayerInventory(int nPlayer) PlayerList[nPlayer].nLives = kDefaultLives; PlayerList[nPlayer].pActor = nullptr; + PlayerList[nPlayer].Angles.setActor(nullptr); PlayerList[nPlayer].nRun = -1; PlayerList[nPlayer].nPistolClip = 6; @@ -260,6 +262,7 @@ void RestartPlayer(int nPlayer) ChangeActorStat(pActor, 0); plr->pActor = nullptr; + plr->Angles.setActor(nullptr); DExhumedActor* pFloorSprite = plr->pPlayerFloorSprite; if (pFloorSprite != nullptr) { @@ -356,6 +359,7 @@ void RestartPlayer(int nPlayer) plr->nSeqSize = 0; plr->pActor = pActor; + plr->Angles.setActor(pActor); plr->bIsMummified = false; if (plr->invincibility >= 0) { diff --git a/source/games/sw/src/game.cpp b/source/games/sw/src/game.cpp index b6db93368..37216e941 100644 --- a/source/games/sw/src/game.cpp +++ b/source/games/sw/src/game.cpp @@ -574,6 +574,7 @@ void TerminateLevel(void) pp->DoPlayerAction = nullptr; pp->actor = nullptr; + pp->Angles.setActor(nullptr); pp->PlayerUnderActor = nullptr; diff --git a/source/games/sw/src/ninja.cpp b/source/games/sw/src/ninja.cpp index 4338f0ebf..d7b1656ce 100644 --- a/source/games/sw/src/ninja.cpp +++ b/source/games/sw/src/ninja.cpp @@ -2407,6 +2407,8 @@ void InitPlayerSprite(PLAYER* pp, const DVector3& spawnpos) pp->actor = actor; pp->pnum = pnum; + pp->Angles.setActor(actor); + actor->spr.cstat |= (CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); actor->spr.extra |= (SPRX_PLAYER_OR_ENEMY); actor->spr.cstat &= ~(CSTAT_SPRITE_TRANSLUCENT);