diff --git a/source/core/coreplayer.h b/source/core/coreplayer.h index 133b98308..8b6667210 100644 --- a/source/core/coreplayer.h +++ b/source/core/coreplayer.h @@ -15,6 +15,7 @@ protected: CameraAngles = PrevLerpAngles = PrevViewAngles = ViewAngles = {}; PrevStrafeVel = StrafeVel = 0; YawSpin = nullAngle; + CameraPos = {}; memset(&lastcmd, 0, sizeof(lastcmd)); memset(&cmd, 0, sizeof(cmd)); actor = nullptr; @@ -26,6 +27,7 @@ public: DRotator PrevViewAngles, ViewAngles; double PrevStrafeVel, StrafeVel; DAngle YawSpin; + DVector3 CameraPos; ticcmd_t lastcmd, cmd; DCoreActor* actor; uint8_t pnum; diff --git a/source/games/exhumed/src/sequence.cpp b/source/games/exhumed/src/sequence.cpp index 581f6da38..cda6be7e1 100644 --- a/source/games/exhumed/src/sequence.cpp +++ b/source/games/exhumed/src/sequence.cpp @@ -409,7 +409,7 @@ void seq_PlotArrowSequence(const int nSprite, const FName seqFile, const int16_t { tspritetype* pTSprite = mytspriteArray->get(nSprite); - const DAngle nAngle = (nCamerapos.XY() - pTSprite->pos.XY()).Angle(); + const DAngle nAngle = (getPlayer(nLocalPlayer)->CameraPos.XY() - pTSprite->pos.XY()).Angle(); const int seqOffset = (((pTSprite->Angles.Yaw + DAngle90 + DAngle22_5 - nAngle).Buildang()) & kAngleMask) >> 8; const auto& seqFrame = getSequence(seqFile, seqIndex + seqOffset)->frames[frameIndex]; @@ -453,12 +453,13 @@ void seq_PlotArrowSequence(const int nSprite, const FName seqFile, const int16_t void seq_PlotSequence(const int nSprite, const FName seqFile, const int16_t seqIndex, const int16_t frameIndex, const int16_t nFlags) { tspritetype* pTSprite = mytspriteArray->get(nSprite); + const auto pPlayer = getPlayer(nLocalPlayer); int seqOffset = 0; if (!(nFlags & 1)) { - const DAngle nAngle = (nCamerapos.XY() - pTSprite->pos.XY()).Angle(); + const DAngle nAngle = (pPlayer->CameraPos.XY() - pTSprite->pos.XY()).Angle(); seqOffset = (((pTSprite->Angles.Yaw + DAngle22_5 - nAngle).Buildang()) & kAngleMask) >> 8; } @@ -508,7 +509,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 <= getPlayer(nLocalPlayer)->GetActor()->getOffsetZ()) + if (nFloorZ <= pPlayer->GetActor()->getOffsetZ()) { pTSprite->ownerActor = nullptr; } diff --git a/source/games/exhumed/src/view.cpp b/source/games/exhumed/src/view.cpp index 02a425b84..83429c385 100644 --- a/source/games/exhumed/src/view.cpp +++ b/source/games/exhumed/src/view.cpp @@ -34,7 +34,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS bool bSubTitles = true; -DVector3 nCamerapos; bool bTouchFloor; int nChunkTotal = 0; int nViewTop; @@ -77,6 +76,7 @@ void DrawView(double interpfrac, bool sceneonly) auto nPlayerOldCstat = pPlayerActor->spr.cstat; auto pDop = pPlayer->pDoppleSprite; auto nDoppleOldCstat = pDop->spr.cstat; + DVector3 nCamerapos; // update render angles. pPlayer->updateCameraAngles(interpfrac); @@ -125,6 +125,7 @@ void DrawView(double interpfrac, bool sceneonly) } } + pPlayer->CameraPos = nCamerapos; const auto ampos = nCamerapos.XY(); if (nSnakeCam >= 0 && !sceneonly) @@ -339,8 +340,7 @@ void SerializeView(FSerializer& arc) { if (arc.BeginObject("view")) { - arc("camerapos", nCamerapos) - ("chunktotal", nChunkTotal) + arc("chunktotal", nChunkTotal) ("camera", bCamera) .EndObject(); } diff --git a/source/games/exhumed/src/view.h b/source/games/exhumed/src/view.h index 43d654a8c..465f1808e 100644 --- a/source/games/exhumed/src/view.h +++ b/source/games/exhumed/src/view.h @@ -28,7 +28,6 @@ void DrawStatusBar(); void DrawView(double interpfrac, bool sceneonly = false); void ResetView(); -extern DVector3 nCamerapos; extern int nChunkTotal; extern tspriteArray* mytspriteArray; diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index 2f532f081..a7dae6c7b 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -362,7 +362,7 @@ void DoShadows(tspriteArray& tsprites, tspritetype* tsp, double viewz) else { // Alter the shadow's position so that it appears behind the sprite itself. - auto look = (tSpr->pos.XY() - getPlayer(screenpeek)->si.XY()).Angle(); + auto look = (tSpr->pos.XY() - getPlayer(screenpeek)->CameraPos.XY()).Angle(); tSpr->pos.XY() += look.ToVector() * 2; } @@ -783,7 +783,7 @@ static void analyzesprites(tspriteArray& tsprites, const DVector3& viewpos, doub if (pp->Flags & (PF_VIEW_FROM_OUTSIDE)) tsp->cstat |= (CSTAT_SPRITE_TRANSLUCENT); - auto pos = pp->si.plusZ(tsp->pos.Z); + auto pos = pp->CameraPos.plusZ(tsp->pos.Z); if (pp->Flags & (PF_CLIMBING)) { @@ -1253,7 +1253,7 @@ void drawscreen(DSWPlayer* pp, double interpfrac, bool sceneonly) updatesectorz(tpos, &tsect); } - pp->si = tpos.plusZ(-pp->GetActor()->getOffsetZ()); + pp->CameraPos = tpos.plusZ(-pp->GetActor()->getOffsetZ()); QuakeViewChange(camerapp, tpos, tangles.Yaw); int vis = g_visibility; diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 1d32a84a2..0a99646f7 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1712,7 +1712,6 @@ public: sectortype* hi_sectp, *lo_sectp; double circle_camera_dist; - DVector3 si; // save player interp position for PlayerSprite DVector2 vect, ovect, slide_vect; // these need floatification, but must be done together. vect is in 14.18 format! diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index 540e7ef20..67f4f16eb 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -334,7 +334,6 @@ void DSWPlayer::Serialize(FSerializer& arc) ("lo_sp", lowActor) ("last_camera_sp", last_camera_act) ("circle_camera_dist", circle_camera_dist) - ("si", si) ("vect", vect) ("friction", friction) ("slide_vect", slide_vect)