From 2797919f2c8c64277830e8d23788ec2c8793a2d1 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sat, 4 Nov 2023 19:58:28 +1100 Subject: [PATCH] - Blood: Clean up some `getPlayer()` and `DCorePlayer::GetActor()` accesses in ticker. --- source/games/blood/src/blood.cpp | 26 ++++++++++++++------------ source/games/blood/src/player.cpp | 2 +- source/games/blood/src/view.cpp | 8 ++++---- source/games/blood/src/view.h | 2 +- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/source/games/blood/src/blood.cpp b/source/games/blood/src/blood.cpp index c535ebad3..12f49cd22 100644 --- a/source/games/blood/src/blood.cpp +++ b/source/games/blood/src/blood.cpp @@ -439,16 +439,18 @@ void GameInterface::Ticker() thinktime.Reset(); thinktime.Clock(); - DBloodPlayer* pPlayer = getPlayer(myconnectindex); + const auto mciPlayer = getPlayer(myconnectindex); + const auto mciActor = mciPlayer->GetActor(); // disable synchronised input if set by game. gameInput.ResetInputSync(); for (int i = connecthead; i >= 0; i = connectpoint2[i]) { - getPlayer(i)->resetCameraAngles(); - viewBackupView(i); - playerProcess(getPlayer(i)); + const auto pPlayer = getPlayer(i); + pPlayer->resetCameraAngles(); + viewBackupView(pPlayer); + playerProcess(pPlayer); } trProcessBusy(); @@ -463,25 +465,25 @@ void GameInterface::Ticker() actortime.Unclock(); viewCorrectPrediction(); - ambProcess(pPlayer); - viewUpdateDelirium(pPlayer); + ambProcess(mciPlayer); + viewUpdateDelirium(mciPlayer); gi->UpdateSounds(); - if (pPlayer->hand == 1) + if (mciPlayer->hand == 1) { - const int CHOKERATE = 8; - const int COUNTRATE = 30; + static constexpr int CHOKERATE = 8; + static constexpr int COUNTRATE = 30; gChokeCounter += CHOKERATE; while (gChokeCounter >= COUNTRATE) { - gChoke.callback(pPlayer); + gChoke.callback(mciPlayer); gChokeCounter -= COUNTRATE; } } thinktime.Unclock(); // update console player's viewzoffset at the end of the tic. - pPlayer->GetActor()->oviewzoffset = pPlayer->GetActor()->viewzoffset; - pPlayer->GetActor()->viewzoffset = pPlayer->zView - pPlayer->GetActor()->spr.pos.Z; + mciActor->oviewzoffset = mciActor->viewzoffset; + mciActor->viewzoffset = mciPlayer->zView - mciActor->spr.pos.Z; gFrameCount++; PlayClock += kTicsPerFrame; diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index b9ddec82a..abed6814c 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -756,7 +756,7 @@ void playerResetInertia(DBloodPlayer* pPlayer) pPlayer->zView = pPlayer->GetActor()->spr.pos.Z - pPosture->eyeAboveZ; pPlayer->zWeapon = pPlayer->GetActor()->spr.pos.Z - pPosture->weaponAboveZ; pPlayer->GetActor()->oviewzoffset = pPlayer->GetActor()->viewzoffset = pPlayer->zView - pPlayer->GetActor()->spr.pos.Z; - viewBackupView(pPlayer->pnum); + viewBackupView(pPlayer); } void playerCorrectInertia(DBloodPlayer* pPlayer, const DVector3& oldpos) diff --git a/source/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index 84156fa37..8f748bbba 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -56,17 +56,17 @@ int gViewIndex; // //--------------------------------------------------------------------------- -void viewBackupView(int nPlayer) +void viewBackupView(DBloodPlayer* pPlayer) { - DBloodPlayer* pPlayer = getPlayer(nPlayer); + const auto pActor = pPlayer->GetActor(); pPlayer->ozView = pPlayer->zView; pPlayer->ozWeapon = pPlayer->zWeapon - pPlayer->zView - 12; pPlayer->obobHeight = pPlayer->bobHeight; pPlayer->obobWidth = pPlayer->bobWidth; pPlayer->oswayHeight = pPlayer->swayHeight; pPlayer->oswayWidth = pPlayer->swayWidth; - pPlayer->GetActor()->backuploc(); - pPlayer->GetActor()->interpolated = true; + pActor->backuploc(); + pActor->interpolated = true; } //--------------------------------------------------------------------------- diff --git a/source/games/blood/src/view.h b/source/games/blood/src/view.h index 0efb40d32..b286c83f8 100644 --- a/source/games/blood/src/view.h +++ b/source/games/blood/src/view.h @@ -79,7 +79,7 @@ void hudDraw(DBloodPlayer* pPlayer, sectortype* pSector, double bobx, double bob void viewInitializePrediction(void); void viewUpdatePrediction(InputPacket* pInput); void viewCorrectPrediction(void); -void viewBackupView(int nPlayer); +void viewBackupView(DBloodPlayer* pPlayer); void InitStatusBar(void); void UpdateStatusBar(DBloodPlayer* pPlayer); void viewInit(void);