From 61bc8c23cf4e2108077ba7478bc2603bee5380df Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sat, 30 Sep 2023 20:44:31 +1000 Subject: [PATCH] - Exhumed: Wrap access to player's actor pointer. --- source/games/exhumed/src/bubbles.cpp | 2 +- source/games/exhumed/src/exhumed.h | 2 +- source/games/exhumed/src/grenade.cpp | 6 +-- source/games/exhumed/src/gun.cpp | 8 +-- source/games/exhumed/src/init.cpp | 4 +- source/games/exhumed/src/items.cpp | 10 ++-- source/games/exhumed/src/map.cpp | 4 +- source/games/exhumed/src/move.cpp | 8 +-- source/games/exhumed/src/osdcmds.cpp | 2 +- source/games/exhumed/src/player.cpp | 72 +++++++++++++-------------- source/games/exhumed/src/player.h | 6 ++- source/games/exhumed/src/ra.cpp | 6 +-- source/games/exhumed/src/ramses.cpp | 2 +- source/games/exhumed/src/runlist.cpp | 2 +- source/games/exhumed/src/sequence.cpp | 4 +- source/games/exhumed/src/snake.cpp | 6 +-- source/games/exhumed/src/sound.cpp | 10 ++-- source/games/exhumed/src/switch.cpp | 2 +- source/games/exhumed/src/view.cpp | 2 +- 19 files changed, 81 insertions(+), 77 deletions(-) diff --git a/source/games/exhumed/src/bubbles.cpp b/source/games/exhumed/src/bubbles.cpp index ca7225bd5..0a4de6f6c 100644 --- a/source/games/exhumed/src/bubbles.cpp +++ b/source/games/exhumed/src/bubbles.cpp @@ -53,7 +53,7 @@ static DExhumedActor* BuildBubble(const DVector3& pos, sectortype* pSector, cons nSize -= 4; // Was inita global previously. - const auto nAngle = PlayerList[nPlayer].pActor->spr.Angles.Yaw; + const auto nAngle = PlayerList[nPlayer].GetActor()->spr.Angles.Yaw; const auto pActor = insertActor(pSector, 402); pActor->spr.pos = pos; diff --git a/source/games/exhumed/src/exhumed.h b/source/games/exhumed/src/exhumed.h index a6ac4d27a..94dda7641 100644 --- a/source/games/exhumed/src/exhumed.h +++ b/source/games/exhumed/src/exhumed.h @@ -234,7 +234,7 @@ struct GameInterface : public ::GameInterface bool DrawAutomapPlayer(const DVector2& mxy, const DVector2& cpos, const DAngle cang, const DVector2& xydim, const double czoom, double const interpfrac) override; DAngle playerPitchMin() override { return DAngle::fromDeg(49.5); } DAngle playerPitchMax() override { return DAngle::fromDeg(-49.5); } - DCoreActor* getConsoleActor() override { return PlayerList[nLocalPlayer].pActor; } + DCoreActor* getConsoleActor() override { return PlayerList[nLocalPlayer].GetActor(); } void ToggleThirdPerson() override; void processSprites(tspriteArray& tsprites, const DVector3& view, DAngle viewang, double interpfrac) override; int GetCurrentSkill() override; diff --git a/source/games/exhumed/src/grenade.cpp b/source/games/exhumed/src/grenade.cpp index 31941bc43..b9e5cfc94 100644 --- a/source/games/exhumed/src/grenade.cpp +++ b/source/games/exhumed/src/grenade.cpp @@ -69,7 +69,7 @@ void ThrowGrenade(int nPlayer, double dz, double push1) return; DExhumedActor* pActor = PlayerList[nPlayer].pPlayerGrenade; - auto pPlayerActor = PlayerList[nPlayer].pActor; + auto pPlayerActor = PlayerList[nPlayer].GetActor(); DAngle nAngle = pPlayerActor->spr.Angles.Yaw; @@ -123,7 +123,7 @@ void BuildGrenade(int nPlayer) { auto pActor = insertActor(PlayerList[nPlayer].pPlayerViewSect, 201); - auto pPlayerActor = PlayerList[nPlayer].pActor; + auto pPlayerActor = PlayerList[nPlayer].GetActor(); pActor->spr.pos = pPlayerActor->spr.pos.plusZ(-15); pActor->spr.shade = -64; @@ -199,7 +199,7 @@ void ExplodeGrenade(DExhumedActor* pActor) if (pActor->nTurn < 0) { - auto pPlayerActor = PlayerList[nPlayer].pActor; + auto pPlayerActor = PlayerList[nPlayer].GetActor(); auto nAngle = pPlayerActor->spr.Angles.Yaw; DVector2 vect = nAngle.ToVector() * 32; diff --git a/source/games/exhumed/src/gun.cpp b/source/games/exhumed/src/gun.cpp index ebef15d62..e3a79d6f7 100644 --- a/source/games/exhumed/src/gun.cpp +++ b/source/games/exhumed/src/gun.cpp @@ -287,7 +287,7 @@ void ResetSwordSeqs() Collision CheckCloseRange(int nPlayer, DVector3& pos, sectortype* *ppSector) { - auto pActor = PlayerList[nPlayer].pActor; + auto pActor = PlayerList[nPlayer].GetActor(); HitInfo hit{}; hitscan(pos, *ppSector, DVector3(pActor->spr.Angles.Yaw.ToVector() * 1024, 0 ), hit, CLIPMASK1); @@ -357,7 +357,7 @@ void MoveWeapons(int nPlayer) if (!pPlayer->bIsFiring || (nSectFlag & kSectUnderwater)) pPlayer->nTemperature = 0; - auto pPlayerActor = pPlayer->pActor; + auto pPlayerActor = pPlayer->GetActor(); int nWeapon = pPlayer->nCurrentWeapon; if (nWeapon < -1) @@ -413,7 +413,7 @@ void MoveWeapons(int nPlayer) if (!WeaponCanFire(nPlayer)) { if (!dword_96E22) { - D3PlayFX(StaticSound[4], pPlayer->pActor); + D3PlayFX(StaticSound[4], pPlayer->GetActor()); } } else @@ -904,7 +904,7 @@ loc_flag: void DrawWeapons(Player* const pPlayer, double interpfrac) { - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); const int nWeapon = pPlayer->nCurrentWeapon; if (bCamera || nWeapon < -1) diff --git a/source/games/exhumed/src/init.cpp b/source/games/exhumed/src/init.cpp index 699836aff..9bd25706d 100644 --- a/source/games/exhumed/src/init.cpp +++ b/source/games/exhumed/src/init.cpp @@ -772,9 +772,9 @@ void ExamineSprites(TArray& actors) if (nNetPlayerCount) { - auto pActor = insertActor(PlayerList[nLocalPlayer].pActor->sector(), 0); + auto pActor = insertActor(PlayerList[nLocalPlayer].GetActor()->sector(), 0); - pActor->spr.pos = PlayerList[nLocalPlayer].pActor->spr.pos; + pActor->spr.pos = PlayerList[nLocalPlayer].GetActor()->spr.pos; pActor->spr.cstat = CSTAT_SPRITE_INVISIBLE; nNetStartSprite[nNetStartSprites] = pActor; nNetStartSprites++; diff --git a/source/games/exhumed/src/items.cpp b/source/games/exhumed/src/items.cpp index 0cde5d972..64a9469a3 100644 --- a/source/games/exhumed/src/items.cpp +++ b/source/games/exhumed/src/items.cpp @@ -204,7 +204,7 @@ static bool UseEye(int nPlayer) if (PlayerList[nPlayer].nInvisible >= 0) PlayerList[nPlayer].nInvisible = 900; - auto pActor = PlayerList[nPlayer].pActor; + auto pActor = PlayerList[nPlayer].GetActor(); pActor->spr.cstat |= CSTAT_SPRITE_INVISIBLE; @@ -233,7 +233,7 @@ static bool UseMask(int nPlayer) if (nPlayer == nLocalPlayer) { - D3PlayFX(StaticSound[kSound31], PlayerList[nPlayer].pActor); + D3PlayFX(StaticSound[kSound31], PlayerList[nPlayer].GetActor()); } return true; } @@ -269,7 +269,7 @@ bool UseHeart(int nPlayer) if (nPlayer == nLocalPlayer) { ItemFlash(); - D3PlayFX(StaticSound[kSound31], PlayerList[nPlayer].pActor); + D3PlayFX(StaticSound[kSound31], PlayerList[nPlayer].GetActor()); } return true; } @@ -290,7 +290,7 @@ bool UseScarab(int nPlayer) if (nPlayer == nLocalPlayer) { ItemFlash(); - D3PlayFX(StaticSound[kSound31], PlayerList[nPlayer].pActor); + D3PlayFX(StaticSound[kSound31], PlayerList[nPlayer].GetActor()); } return true; } @@ -303,7 +303,7 @@ static bool UseHand(int nPlayer) if (nPlayer == nLocalPlayer) { ItemFlash(); - D3PlayFX(StaticSound[kSound31], PlayerList[nPlayer].pActor); + D3PlayFX(StaticSound[kSound31], PlayerList[nPlayer].GetActor()); } return true; } diff --git a/source/games/exhumed/src/map.cpp b/source/games/exhumed/src/map.cpp index 287d97635..fa7d54a12 100644 --- a/source/games/exhumed/src/map.cpp +++ b/source/games/exhumed/src/map.cpp @@ -45,7 +45,7 @@ void GrabMap() void UpdateMap() { - const auto initsectp = PlayerList[nLocalPlayer].pActor->sector(); + const auto initsectp = PlayerList[nLocalPlayer].GetActor()->sector(); if (initsectp->ceilingpal != 3 || (PlayerList[nLocalPlayer].nTorch != 0)) { MarkSectorSeen(initsectp); } @@ -73,7 +73,7 @@ bool GameInterface::DrawAutomapPlayer(const DVector2& mxy, const DVector2& cpos, { if (i == nLocalPlayer)// || gGameOptions.nGameType == 1) { - auto pPlayerActor = PlayerList[i].pActor; + auto pPlayerActor = PlayerList[i].GetActor(); auto vect = OutAutomapVector(mxy - cpos, cangvect, czoom, xydim); DrawTexture(twod, pPlayerActor->spr.spritetexture(), true, vect.X, vect.Y, DTA_ClipLeft, viewport3d.Left(), DTA_ClipTop, viewport3d.Top(), DTA_ScaleX, czoom * (2. / 3.), DTA_ScaleY, czoom * (2. / 3.), DTA_CenterOffset, true, diff --git a/source/games/exhumed/src/move.cpp b/source/games/exhumed/src/move.cpp index 7ed6babab..3a9952755 100644 --- a/source/games/exhumed/src/move.cpp +++ b/source/games/exhumed/src/move.cpp @@ -271,7 +271,7 @@ Collision movespritez(DExhumedActor* pActor, double z, double height, double cli if (pSect2->Flag & kSectUnderwater) { - if (pActor == PlayerList[nLocalPlayer].pActor) { + if (pActor == PlayerList[nLocalPlayer].GetActor()) { D3PlayFX(StaticSound[kSound2], pActor); } @@ -616,7 +616,7 @@ DExhumedActor* FindPlayer(DExhumedActor* pActor, int nDistance, bool dontengage) if (i >= nTotalPlayers) return nullptr; - pPlayerActor = PlayerList[i].pActor; + pPlayerActor = PlayerList[i].GetActor(); if ((pPlayerActor->spr.cstat & CSTAT_SPRITE_BLOCK_ALL) && (!(pPlayerActor->spr.cstat & CSTAT_SPRITE_INVISIBLE))) { @@ -930,7 +930,7 @@ void SetQuake(DExhumedActor* pActor, int nVal) { for (int i = 0; i < nTotalPlayers; i++) { - auto nSqrt = ((PlayerList[i].pActor->spr.pos.XY() - pActor->spr.pos.XY()) * (1. / 16.)).Length(); + auto nSqrt = ((PlayerList[i].GetActor()->spr.pos.XY() - pActor->spr.pos.XY()) * (1. / 16.)).Length(); if (nSqrt) { @@ -1015,7 +1015,7 @@ Collision AngleChase(DExhumedActor* pActor, DExhumedActor* pActor2, int threshol DVector3 WheresMyMouth(int nPlayer, sectortype **sectnum) { - auto pActor = PlayerList[nPlayer].pActor; + auto pActor = PlayerList[nPlayer].GetActor(); double height = GetActorHeight(pActor) * 0.5; *sectnum = pActor->sector(); diff --git a/source/games/exhumed/src/osdcmds.cpp b/source/games/exhumed/src/osdcmds.cpp index 320ce9b94..ccc9db728 100644 --- a/source/games/exhumed/src/osdcmds.cpp +++ b/source/games/exhumed/src/osdcmds.cpp @@ -61,7 +61,7 @@ static int osdcmd_doors(CCmdFuncPtr parm) static int osdcmd_spawn(CCmdFuncPtr parm) { - auto pActor = PlayerList[nLocalPlayer].pActor; + auto pActor = PlayerList[nLocalPlayer].GetActor(); if (parm->numparms != 1) return CCMD_SHOWHELP; if (!pActor) return CCMD_SHOWHELP; auto c = parm->parms[0]; diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index ecf6cc300..17de9481f 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -86,7 +86,7 @@ size_t MarkPlayers() { for (auto& p : PlayerList) { - GC::Mark(p.pActor); + GC::Mark(p.actor); GC::Mark(p.pDoppleSprite); GC::Mark(p.pPlayerFloorSprite); GC::Mark(p.pPlayerGrenade); @@ -123,7 +123,7 @@ void InitPlayer() { const auto pPlayer = &PlayerList[i]; - pPlayer->pActor = nullptr; + pPlayer->actor = nullptr; pPlayer->Angles = {}; pPlayer->pPlayerPushSect = nullptr; pPlayer->pPlayerViewSect = nullptr; @@ -151,7 +151,7 @@ void InitPlayerInventory(int nPlayer) pPlayer->nItem = -1; pPlayer->nPlayerSwear = 4; pPlayer->nLives = kDefaultLives; - pPlayer->pActor = nullptr; + pPlayer->actor = nullptr; pPlayer->Angles = {}; pPlayer->nRun = -1; pPlayer->nPistolClip = 6; @@ -190,7 +190,7 @@ int GetPlayerFromActor(DExhumedActor* pActor) void RestartPlayer(int nPlayer) { const auto pPlayer = &PlayerList[nPlayer]; - DExhumedActor* pPlayerActor = pPlayer->pActor; + DExhumedActor* pPlayerActor = pPlayer->GetActor(); DExhumedActor* pDopSprite = pPlayer->pDoppleSprite; DExhumedActor* pFloorSprite = pPlayer->pPlayerFloorSprite; @@ -201,7 +201,7 @@ void RestartPlayer(int nPlayer) ChangeActorStat(pPlayerActor, 0); - pPlayer->pActor = nullptr; + pPlayer->actor = nullptr; pPlayer->Angles = {}; if (pFloorSprite) @@ -279,7 +279,7 @@ void RestartPlayer(int nPlayer) pDopSprite->spr.lotag = runlist_HeadRun() + 1; pDopSprite->spr.intowner = runlist_AddRunRec(pDopSprite->spr.lotag - 1, nPlayer, 0xA0000); - pPlayer->pActor = pPlayerActor; + pPlayer->actor = pPlayerActor; pPlayer->pDoppleSprite = pDopSprite; pPlayer->pPlayerFloorSprite = pFloorSprite; pPlayer->pPlayerViewSect = pPlayer->sPlayerSave.pSector; @@ -361,7 +361,7 @@ int GrabPlayer() void StartDeathSeq(int nPlayer, int nVal) { const auto pPlayer = &PlayerList[nPlayer]; - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); const auto pPlayerSect = pPlayerActor->sector(); FreeRa(nPlayer); @@ -455,7 +455,7 @@ int AddAmmo(int nPlayer, int nWeapon, int nAmmoAmount) void SetPlayerMummified(int nPlayer, int bIsMummified) { const auto pPlayer = &PlayerList[nPlayer]; - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); pPlayerActor->vel.XY().Zero(); @@ -482,7 +482,7 @@ void SetPlayerMummified(int nPlayer, int bIsMummified) void ShootStaff(int nPlayer) { const auto pPlayer = &PlayerList[nPlayer]; - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); pPlayerActor->nAction = 15; pPlayerActor->nFrame = 0; @@ -531,7 +531,7 @@ void AIPlayer::Draw(RunListEvent* ev) assert(nPlayer >= 0 && nPlayer < kMaxPlayers); const auto pPlayer = &PlayerList[nPlayer]; - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); const auto playerSeq = &PlayerSeq[pPlayerActor->nAction]; seq_PlotSequence(ev->nParam, pPlayerActor->nSeqFile, playerSeq->nSeqId, pPlayerActor->nFrame, playerSeq->nFlags); } @@ -552,7 +552,7 @@ void AIPlayer::RadialDamage(RunListEvent* ev) if (pPlayer->nHealth <= 0) return; - ev->nDamage = runlist_CheckRadialDamage(pPlayer->pActor); + ev->nDamage = runlist_CheckRadialDamage(pPlayer->GetActor()); Damage(ev); } @@ -573,7 +573,7 @@ void AIPlayer::Damage(RunListEvent* ev) if (!nDamage || !pPlayer->nHealth) return; - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); const auto pDamageActor = (!ev->isRadialEvent()) ? ev->pOtherActor : ev->pRadialActor->pTarget.Get(); if (!pPlayer->invincibility) @@ -843,7 +843,7 @@ static void doPickupHealth(Player* pPlayer, DExhumedActor* pPickupActor, int nIt void doPlayerItemPickups(Player* const pPlayer) { - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); const auto pPlayerSect = pPlayerActor->sector(); if (const auto pPickupActor = feebtag(pPlayerActor->spr.pos, pPlayerSect, pPlayer->nMagic, pPlayer->nHealth, 48)) @@ -1043,7 +1043,7 @@ void doPlayerItemPickups(Player* const pPlayer) void updatePlayerTarget(Player* const pPlayer) { - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); const auto pRa = &Ra[pPlayer->nPlayer]; const auto nAngVect = (-pPlayerActor->spr.Angles.Yaw).ToVector(); @@ -1106,7 +1106,7 @@ void updatePlayerTarget(Player* const pPlayer) static void updatePlayerVelocity(Player* const pPlayer) { - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); if (pPlayer->nHealth > 0) { @@ -1236,7 +1236,7 @@ unsigned GameInterface::getCrouchState() static void updatePlayerAction(Player* const pPlayer) { - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); const auto pInput = &pPlayer->input; const auto kbdDir = !!(pInput->actions & SB_CROUCH) - !!(pInput->actions & SB_JUMP); const double dist = pPlayer->bUnderwater ? 8 : 14; @@ -1355,7 +1355,7 @@ static void updatePlayerAction(Player* const pPlayer) static void doPlayerCounters(Player* const pPlayer) { - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); const bool bConsolePlayer = pPlayer->nPlayer == nLocalPlayer; if (pPlayer->nTorch > 0) @@ -1436,7 +1436,7 @@ static void doPlayerCounters(Player* const pPlayer) static void doPlayerUnderwater(Player* const pPlayer, const bool oUnderwater) { - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); const bool bUnderwater = pPlayer->pPlayerViewSect->Flag & kSectUnderwater; if (!pPlayer->invincibility) @@ -1530,7 +1530,7 @@ static void doPlayerRamses(Player* const pPlayer) if (nTotalPlayers <= 1) { - pPlayer->pActor->vel.Zero(); + pPlayer->GetActor()->vel.Zero(); if (nFreeze < 1) { @@ -1570,7 +1570,7 @@ static void doPlayerGravity(DExhumedActor* const pPlayerActor) static void doPlayerCameraEffects(Player* const pPlayer, const double nDestVertPan) { - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); const auto nUnderwater = !!(pPlayerActor->sector()->Flag & kSectUnderwater); constexpr auto maxVel = 15.25; @@ -1617,7 +1617,7 @@ static void updatePlayerFloorActor(Player* const pPlayer) if (nTotalPlayers <= 1 || !pFloorActor) return; - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); const auto pPlayerSect = pPlayerActor->sector(); pFloorActor->spr.pos.XY() = pPlayerActor->spr.pos.XY(); pFloorActor->spr.pos.Z = pPlayerSect->floorz; @@ -1634,7 +1634,7 @@ static void updatePlayerFloorActor(Player* const pPlayer) static void updatePlayerDoppleActor(Player* const pPlayer) { - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); const auto pPlayerSect = pPlayerActor->sector(); DExhumedActor* const pDopple = pPlayer->pDoppleSprite; pDopple->spr.pos = pPlayerActor->spr.pos; @@ -1659,7 +1659,7 @@ static void updatePlayerDoppleActor(Player* const pPlayer) static void updatePlayerViewSector(Player* const pPlayer, const Collision& nMove, const DVector3& spr_vel) { - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); const auto pPlayerSect = pPlayerActor->sector(); const auto bPlayerBelowCeil = (pPlayerActor->getOffsetZ() + pPlayer->nQuake) < pPlayerSect->ceilingz; const auto pViewSect = bPlayerBelowCeil && pPlayerSect->pAbove ? pPlayerSect->pAbove : pPlayerSect; @@ -1698,7 +1698,7 @@ static void updatePlayerViewSector(Player* const pPlayer, const Collision& nMove static void doPlayerFloorDamage(Player* const pPlayer, const double nStartVelZ) { - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); pPlayer->nThrust *= 0.5; if (nStartVelZ < (6500 / 256.)) @@ -1727,7 +1727,7 @@ static void doPlayerFloorDamage(Player* const pPlayer, const double nStartVelZ) static void doPlayerMovingBlocks(Player* const pPlayer, const Collision& nMove, const DVector3& spr_vel, sectortype* const spr_sect) { - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); sectortype* sect; DAngle nNormal = nullAngle; @@ -1788,7 +1788,7 @@ static bool doPlayerInput(Player* const pPlayer) // update the player/actor's velocity before anything. updatePlayerVelocity(pPlayer); - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); const auto spr_vel = DVector3(pPlayerActor->vel.XY() * (pPlayer->bIsMummified ? 0.5 : 1.), pPlayerActor->vel.Z); const auto spr_sect = pPlayerActor->sector(); @@ -1877,7 +1877,7 @@ static bool doPlayerInput(Player* const pPlayer) static void doPlayerRunlistSignals(Player* const pPlayer, sectortype* const pStartSect) { - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); const auto pPlayerSect = pPlayerActor->sector(); if (pPlayer->bTouchFloor && pPlayerSect->lotag > 0) @@ -1916,7 +1916,7 @@ static void doPlayerRunlistSignals(Player* const pPlayer, sectortype* const pSta static bool doPlayerDeathRestart(Player* const pPlayer) { - if (!(pPlayer->input.actions & SB_OPEN) || pPlayer->pActor->nAction < 16) + if (!(pPlayer->input.actions & SB_OPEN) || pPlayer->GetActor()->nAction < 16) return true; pPlayer->input.actions &= ~SB_OPEN; @@ -1932,9 +1932,9 @@ static bool doPlayerDeathRestart(Player* const pPlayer) if (pPlayer->nLives && nNetTime) { - if (pPlayer->pActor->nAction != 20) + if (pPlayer->GetActor()->nAction != 20) { - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); pPlayerActor->spr.setspritetexture(getSequence("joe", 120)->getFirstFrameTexture()); pPlayerActor->spr.cstat = 0; pPlayerActor->spr.pos.Z = pPlayerActor->sector()->floorz; @@ -1962,7 +1962,7 @@ static bool doPlayerDeathRestart(Player* const pPlayer) static void doPlayerActionSequence(Player* const pPlayer) { - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); const auto playerSeq = getSequence(pPlayerActor->nSeqFile, PlayerSeq[pPlayerActor->nAction].nSeqId); const auto& seqFrame = playerSeq->frames[pPlayerActor->nFrame]; @@ -2017,7 +2017,7 @@ static void doPlayerActionSequence(Player* const pPlayer) static void doPlayerDeathPitch(Player* const pPlayer) { - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); pPlayer->nThrust.Zero(); if (pPlayerActor->viewzoffset >= -11) @@ -2059,7 +2059,7 @@ void AIPlayer::Tick(RunListEvent* ev) assert(nPlayer >= 0 && nPlayer < kMaxPlayers); const auto pPlayer = &PlayerList[nPlayer]; - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); pPlayerActor->spr.setspritetexture(getSequence(pPlayerActor->nSeqFile, PlayerSeq[nHeightTemplate[pPlayerActor->nAction]].nSeqId)->getFirstFrameTexture()); pPlayer->pDoppleSprite->spr.setspritetexture(pPlayerActor->spr.spritetexture()); @@ -2109,7 +2109,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, Player& w, Player* if (arc.BeginObject(keyname)) { arc("health", w.nHealth) - ("sprite", w.pActor) + ("sprite", w.actor) ("mummy", w.bIsMummified) ("invincible", w.invincibility) ("air", w.nAir) @@ -2200,7 +2200,7 @@ DEFINE_FIELD_X(ExhumedPlayer, Player, nLives); DEFINE_FIELD_X(ExhumedPlayer, Player, nDouble); DEFINE_FIELD_X(ExhumedPlayer, Player, nInvisible); DEFINE_FIELD_X(ExhumedPlayer, Player, nTorch); -DEFINE_FIELD_X(ExhumedPlayer, Player, pActor); +DEFINE_FIELD_X(ExhumedPlayer, Player, actor); DEFINE_FIELD_X(ExhumedPlayer, Player, bIsMummified); DEFINE_FIELD_X(ExhumedPlayer, Player, invincibility); DEFINE_FIELD_X(ExhumedPlayer, Player, nAir); @@ -2244,7 +2244,7 @@ DEFINE_ACTION_FUNCTION(_ExhumedPlayer, IsUnderwater) DEFINE_ACTION_FUNCTION(_ExhumedPlayer, GetAngle) { PARAM_SELF_STRUCT_PROLOGUE(Player); - ACTION_RETURN_INT(self->pActor->spr.Angles.Yaw.Buildang()); + ACTION_RETURN_INT(self->GetActor()->spr.Angles.Yaw.Buildang()); } diff --git a/source/games/exhumed/src/player.h b/source/games/exhumed/src/player.h index 3d6cd4f90..854d592dd 100644 --- a/source/games/exhumed/src/player.h +++ b/source/games/exhumed/src/player.h @@ -49,7 +49,7 @@ struct PlayerSave struct Player { - DExhumedActor* pActor; + DExhumedActor* actor; int16_t nHealth; int16_t nLives; int16_t nDouble; @@ -112,6 +112,10 @@ struct Player TObjPtr pDoppleSprite; TObjPtr pTarget; + inline DExhumedActor* GetActor() + { + return actor; + } }; extern int PlayerCount; diff --git a/source/games/exhumed/src/ra.cpp b/source/games/exhumed/src/ra.cpp index e0757cadf..c54eb430f 100644 --- a/source/games/exhumed/src/ra.cpp +++ b/source/games/exhumed/src/ra.cpp @@ -108,7 +108,7 @@ void FreeRa(int nPlayer) void BuildRa(int nPlayer) { - auto pPlayerActor = PlayerList[nPlayer].pActor; + auto pPlayerActor = PlayerList[nPlayer].GetActor(); auto pActor = insertActor(pPlayerActor->sector(), 203); @@ -189,7 +189,7 @@ void MoveRaToEnemy(int nPlayer) } pActor->spr.cstat = CSTAT_SPRITE_INVISIBLE; - pTarget = PlayerList[nPlayer].pActor; + pTarget = PlayerList[nPlayer].GetActor(); } pActor->spr.pos = pTarget->spr.pos.plusZ(-GetActorHeight(pTarget)); @@ -297,7 +297,7 @@ void AIRa::Tick(RunListEvent* ev) { if (PlayerList[nPlayer].nAmmo[kWeaponRing] > 0) { - runlist_DamageEnemy(Ra[nPlayer].pTarget, PlayerList[Ra[nPlayer].nPlayer].pActor, BulletInfo[kWeaponRing].nDamage); + runlist_DamageEnemy(Ra[nPlayer].pTarget, PlayerList[Ra[nPlayer].nPlayer].GetActor(), BulletInfo[kWeaponRing].nDamage); AddAmmo(nPlayer, kWeaponRing, -WeaponInfo[kWeaponRing].d); SetQuake(pActor, 100); } diff --git a/source/games/exhumed/src/ramses.cpp b/source/games/exhumed/src/ramses.cpp index f1d3eadc7..a9bad76a8 100644 --- a/source/games/exhumed/src/ramses.cpp +++ b/source/games/exhumed/src/ramses.cpp @@ -196,7 +196,7 @@ void DoSpiritHead() auto Worktile = GetWritablePixels(aTexIds[kTexTileRamsesWorkTile]); const auto pPlayer = &PlayerList[0]; - const auto pPlayerActor = pPlayer->pActor; + const auto pPlayerActor = pPlayer->GetActor(); const auto nSpiritAngle = (pSpiritSprite->spr.pos.XY() - pPlayerActor->spr.pos.XY()).Angle(); pPlayerActor->spr.Angles.Yaw += deltaangle(pPlayerActor->spr.Angles.Yaw, nSpiritAngle) * 0.25; pPlayerActor->spr.Angles.Pitch += deltaangle(pPlayerActor->spr.Angles.Pitch, currentLevel->ex_ramses_horiz) * 0.25; diff --git a/source/games/exhumed/src/runlist.cpp b/source/games/exhumed/src/runlist.cpp index 6de42a499..128b243db 100644 --- a/source/games/exhumed/src/runlist.cpp +++ b/source/games/exhumed/src/runlist.cpp @@ -1865,7 +1865,7 @@ void runlist_DamageEnemy(DExhumedActor* pActor, DExhumedActor* pActor2, int nDam if (PlayerList[nPlayer].nTauntTimer <= 0) { // Do a taunt - auto pPlayerActor = PlayerList[nPlayer].pActor; + auto pPlayerActor = PlayerList[nPlayer].GetActor(); auto pSector = pPlayerActor->sector(); if (!(pSector->Flag & kSectUnderwater)) diff --git a/source/games/exhumed/src/sequence.cpp b/source/games/exhumed/src/sequence.cpp index d6ba0cc36..520094ce2 100644 --- a/source/games/exhumed/src/sequence.cpp +++ b/source/games/exhumed/src/sequence.cpp @@ -508,7 +508,7 @@ void seq_PlotSequence(const int nSprite, const FName seqFile, const int16_t seqI const auto pSector = pTSprite->sectp; const double nFloorZ = pSector->floorz; - if (nFloorZ <= PlayerList[nLocalPlayer].pActor->viewzoffset + PlayerList[nLocalPlayer].pActor->spr.pos.Z) + if (nFloorZ <= PlayerList[nLocalPlayer].GetActor()->viewzoffset + PlayerList[nLocalPlayer].GetActor()->spr.pos.Z) { pTSprite->ownerActor = nullptr; } @@ -552,7 +552,7 @@ DEFINE_FIELD_X(Seq, Seq, flags); DEFINE_ACTION_FUNCTION(_SeqFrame, playSound) { PARAM_SELF_STRUCT_PROLOGUE(SeqFrame); - self->playSound(PlayerList[nLocalPlayer].pActor); + self->playSound(PlayerList[nLocalPlayer].GetActor()); return 0; } diff --git a/source/games/exhumed/src/snake.cpp b/source/games/exhumed/src/snake.cpp index 24346c23b..aee3c88d3 100644 --- a/source/games/exhumed/src/snake.cpp +++ b/source/games/exhumed/src/snake.cpp @@ -138,7 +138,7 @@ void ExplodeSnakeSprite(DExhumedActor* pActor, int nPlayer) // take a copy of this, to revert after call to runlist_RadialDamageEnemy() DExhumedActor* nOwner = pActor->pTarget; - pActor->pTarget = PlayerList[nPlayer].pActor; + pActor->pTarget = PlayerList[nPlayer].GetActor(); runlist_RadialDamageEnemy(pActor, nDamage, BulletInfo[kWeaponStaff].nRadius); @@ -161,7 +161,7 @@ void BuildSnake(int nPlayer, double zVal) { zVal -= 5; - auto pPlayerActor = PlayerList[nPlayer].pActor; + auto pPlayerActor = PlayerList[nPlayer].GetActor(); auto pViewSect = PlayerList[nPlayer].pPlayerViewSect; auto nPic = getSequence("snakbody", 0)->getFirstFrameTexture(); @@ -277,7 +277,7 @@ void BuildSnake(int nPlayer, double zVal) DExhumedActor* FindSnakeEnemy(int nSnake) { int nPlayer = SnakeList[nSnake].nSnakePlayer; - auto pPlayerActor = PlayerList[nPlayer].pActor; + auto pPlayerActor = PlayerList[nPlayer].GetActor(); DExhumedActor* pActor = SnakeList[nSnake].pSprites[0]; // CHECKME if (!pActor) return nullptr; diff --git a/source/games/exhumed/src/sound.cpp b/source/games/exhumed/src/sound.cpp index 1910fb281..19d459efc 100644 --- a/source/games/exhumed/src/sound.cpp +++ b/source/games/exhumed/src/sound.cpp @@ -418,7 +418,7 @@ void EXSoundEngine::CalcPosVel(int type, const void* source, const float pt[3], Snake* pSnake = &SnakeList[nSnakeCam]; campos = pSnake->pSprites[0]->spr.pos; } - else if (const auto pActor = PlayerList[nLocalPlayer].pActor) + else if (const auto pActor = PlayerList[nLocalPlayer].GetActor()) { campos = pActor->spr.pos; } @@ -485,7 +485,7 @@ void GameInterface::UpdateSounds() if (nFreeze) return; - const auto pActor = PlayerList[nLocalPlayer].pActor; + const auto pActor = PlayerList[nLocalPlayer].GetActor(); DVector3 pos; DAngle ang; @@ -628,7 +628,7 @@ void PlayFX2(int nSound, DExhumedActor* pActor, int sectf, EChanFlags chanflags, } // Nuke: added nSprite >= 0 check - if (pActor != PlayerList[nLocalPlayer].pActor && pActor != nullptr && (pActor->spr.cstat & CSTAT_SPRITE_BLOCK_ALL)) + if (pActor != PlayerList[nLocalPlayer].GetActor() && pActor != nullptr && (pActor->spr.cstat & CSTAT_SPRITE_BLOCK_ALL)) nCreepyTimer = kCreepyCount; } @@ -669,7 +669,7 @@ void CheckAmbience(sectortype* sect) { if (sect == pSector2) { - amb = GetSoundPos(PlayerList[0].pActor->spr.pos); + amb = GetSoundPos(PlayerList[0].GetActor()->spr.pos); } else { @@ -716,7 +716,7 @@ void UpdateCreepySounds() if (totalmoves & 2) adder.Y = -adder.Y; - auto sp = PlayerList[nLocalPlayer].pActor->spr.pos + adder; + auto sp = PlayerList[nLocalPlayer].GetActor()->spr.pos + adder; creepy = GetSoundPos(sp); auto soundid = FSoundID::fromInt((seqFrameSound & 0x1ff) + 1); diff --git a/source/games/exhumed/src/switch.cpp b/source/games/exhumed/src/switch.cpp index 6e507be53..1b6c99086 100644 --- a/source/games/exhumed/src/switch.cpp +++ b/source/games/exhumed/src/switch.cpp @@ -556,7 +556,7 @@ void AISWPressSector::Use(RunListEvent* ev) { if (SwitchData[nSwitch].nKeyMask) { - PlayFXAtXYZ(StaticSound[nSwitchSound], PlayerList[nPlayer].pActor->spr.pos, CHANF_LISTENERZ); + PlayFXAtXYZ(StaticSound[nSwitchSound], PlayerList[nPlayer].GetActor()->spr.pos, CHANF_LISTENERZ); StatusMessage(300, GStrings("TXT_EX_NEEDKEY")); } diff --git a/source/games/exhumed/src/view.cpp b/source/games/exhumed/src/view.cpp index 63d9ed677..3316977c6 100644 --- a/source/games/exhumed/src/view.cpp +++ b/source/games/exhumed/src/view.cpp @@ -73,7 +73,7 @@ void DrawView(double interpfrac, bool sceneonly) DoInterpolations(interpfrac); auto pPlayer = &PlayerList[nLocalPlayer]; - auto pPlayerActor = pPlayer->pActor; + auto pPlayerActor = pPlayer->GetActor(); auto nPlayerOldCstat = pPlayerActor->spr.cstat; auto pDop = pPlayer->pDoppleSprite; auto nDoppleOldCstat = pDop->spr.cstat;