- Blood: Clean up some getPlayer() and DCorePlayer::GetActor() accesses in ticker.

This commit is contained in:
Mitchell Richters 2023-11-04 19:58:28 +11:00
parent da81b63256
commit 2797919f2c
4 changed files with 20 additions and 18 deletions

View file

@ -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;

View file

@ -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)

View file

@ -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;
}
//---------------------------------------------------------------------------

View file

@ -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);