From 8f9b413d382f18108fc5c1b150bef576cbecde66 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Wed, 27 Sep 2023 21:14:58 +1000 Subject: [PATCH] - Always clear object in `PlayerAngles::initialize()` rather than expecting the caller to do it. --- source/core/gameinput.h | 4 +++- source/games/blood/src/player.cpp | 1 - source/games/duke/src/premap.cpp | 1 - source/games/exhumed/src/player.cpp | 1 - source/games/sw/src/ninja.cpp | 1 - 5 files changed, 3 insertions(+), 5 deletions(-) diff --git a/source/core/gameinput.h b/source/core/gameinput.h index f9f401861..1fddd662d 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -112,7 +112,9 @@ struct PlayerAngles // General methods. void initialize(DCoreActor* const actor, const DAngle viewyaw = nullAngle) { - if ((pActor = actor)) CameraAngles = PrevLerpAngles = pActor->spr.Angles; + *this = {}; + pActor = actor; + CameraAngles = PrevLerpAngles = pActor->spr.Angles; PrevViewAngles.Yaw = ViewAngles.Yaw = viewyaw; } DAngle getPitchWithView() diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index c5bf94e70..eff2992fc 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -801,7 +801,6 @@ void playerStart(int nPlayer, int bNewLevel) auto actor = actSpawnSprite(pStartZone->sector, pStartZone->pos, 6, 1); assert(actor->hasX()); pPlayer->actor = actor; - pPlayer->Angles = {}; pPlayer->Angles.initialize(pPlayer->actor); DUDEINFO* pDudeInfo = &dudeInfo[kDudePlayer1 + nPlayer - kDudeBase]; pPlayer->pDudeInfo = pDudeInfo; diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 2a8008c80..e4916f6d3 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -603,7 +603,6 @@ void resetpspritevars(int g, const DVector3& startpos, const DAngle startang) act->spr.pal = ps[j].palookup = ud.user_pals[j]; ps[j].actor = act; - ps[j].Angles = {}; ps[j].Angles.initialize(ps[j].actor, (currentLevel->levelNumber & 1)? DAngle90 : -DAngle90); ps[j].frag_ps = j; act->SetOwner(act); diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 0639d92cb..ecf6cc300 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -285,7 +285,6 @@ void RestartPlayer(int nPlayer) pPlayer->pPlayerViewSect = pPlayer->sPlayerSave.pSector; pPlayer->nPlayer = nPlayer; pPlayer->nHealth = 800; // TODO - define - pPlayer->Angles = {}; pPlayer->Angles.initialize(pPlayerActor); pPlayer->bIsMummified = false; pPlayer->nTorch = 0; diff --git a/source/games/sw/src/ninja.cpp b/source/games/sw/src/ninja.cpp index f64c69a41..a9b7965ab 100644 --- a/source/games/sw/src/ninja.cpp +++ b/source/games/sw/src/ninja.cpp @@ -2344,7 +2344,6 @@ void InitPlayerSprite(PLAYER* pp, const DVector3& spawnpos, const DAngle startan pp->actor = actor; pp->pnum = pnum; - pp->Angles = {}; pp->Angles.initialize(pp->actor); actor->spr.cstat |= (CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);