Skip to content

Commit

Permalink
- Wrap access to previous pitch.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjr4077au committed Nov 26, 2022
1 parent c2107fe commit 46aca77
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion source/core/gameinput.cpp
Expand Up @@ -350,7 +350,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngles& w, P
w.ZzOLDROTSCRNANG = w.ZzROTSCRNANG;
w.legacyDisabledYaw = w.legacyDisabledYaw;
w.resetAdjustmentYaw();
w.ZzOLDHORIZON = w.ZzHORIZON();
w.ZzOLDHORIZON() = w.ZzHORIZON();
w.ZzOHORIZOFF = w.ZzHORIZOFF;
w.legacyDisabledPitch = w.legacyDisabledPitch;
w.resetAdjustmentPitch();
Expand Down
12 changes: 7 additions & 5 deletions source/core/gameinput.h
Expand Up @@ -14,6 +14,8 @@ struct PlayerAngles
// Temporary wrappers.
DAngle thisHoriz;
DAngle& ZzHORIZON() { return thisHoriz; }
DAngle prevHoriz;
DAngle& ZzOLDHORIZON() { return prevHoriz; }

friend FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngles& w, PlayerAngles* def);

Expand Down Expand Up @@ -51,7 +53,7 @@ struct PlayerAngles
else
{
ZzHORIZON() = value;
if (backup) ZzOLDHORIZON = ZzHORIZON();
if (backup) ZzOLDHORIZON() = ZzHORIZON();
}
}

Expand Down Expand Up @@ -103,7 +105,7 @@ struct PlayerAngles


// Legacy, to be removed.
DAngle ZzOLDHORIZON, ZzHORIZOFF, ZzOHORIZOFF;
DAngle ZzHORIZOFF, ZzOHORIZOFF;
void processLegacyHelperPitch(double const scaleAdjust)
{
if (targetedPitch())
Expand All @@ -127,15 +129,15 @@ struct PlayerAngles
}
void backupPitch()
{
ZzOLDHORIZON = ZzHORIZON();
ZzOLDHORIZON() = ZzHORIZON();
ZzOHORIZOFF = ZzHORIZOFF;
}
void restorePitch()
{
ZzHORIZON() = ZzOLDHORIZON;
ZzHORIZON() = ZzOLDHORIZON();
ZzHORIZOFF = ZzOHORIZOFF;
}
DAngle horizOLDSUM() { return ZzOLDHORIZON + ZzOHORIZOFF; }
DAngle horizOLDSUM() { return ZzOLDHORIZON() + ZzOHORIZOFF; }
DAngle horizSUM() { return ZzHORIZON() + ZzHORIZOFF; }
DAngle horizLERPSUM(double const interpfrac) { return interpolatedvalue(horizOLDSUM(), horizSUM(), interpfrac); }
void resetAdjustmentPitch() { legacyAdjustmentPitch = nullAngle; }
Expand Down
4 changes: 2 additions & 2 deletions source/games/duke/src/gameexec.cpp
Expand Up @@ -350,7 +350,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
break;

case PLAYER_OHORIZ:
if (!bSet) SetGameVarID(lVar2, int(ps[iPlayer].Angles.ZzOLDHORIZON.Tan() * -128.), sActor, sPlayer);
if (!bSet) SetGameVarID(lVar2, int(ps[iPlayer].Angles.ZzOLDHORIZON().Tan() * -128.), sActor, sPlayer);
break;

case PLAYER_HORIZOFF:
Expand Down Expand Up @@ -2247,7 +2247,7 @@ int ParseState::parse(void)

ps[g_p].last_extra = g_ac->spr.extra = gs.max_player_health;
ps[g_p].wantweaponfire = -1;
ps[g_p].Angles.ZzOLDHORIZON = ps[g_p].Angles.ZzHORIZON() = nullAngle;
ps[g_p].Angles.ZzOLDHORIZON() = ps[g_p].Angles.ZzHORIZON() = nullAngle;
ps[g_p].on_crane = nullptr;
ps[g_p].frag_ps = g_p;
ps[g_p].Angles.ZzOHORIZOFF = ps[g_p].Angles.ZzHORIZOFF = nullAngle;
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/premap.cpp
Expand Up @@ -125,7 +125,7 @@ void resetplayerstats(int snum)
p->footprintpal = 0;
p->footprintshade = 0;
p->jumping_toggle = 0;
p->Angles.ZzOLDHORIZON = p->Angles.ZzHORIZON() = DAngle::fromDeg(-17.354);
p->Angles.ZzOLDHORIZON() = p->Angles.ZzHORIZON() = DAngle::fromDeg(-17.354);
p->Angles.ZzOHORIZOFF = p->Angles.ZzHORIZOFF = nullAngle;
p->bobcounter = 0;
p->on_ground = 0;
Expand Down
4 changes: 2 additions & 2 deletions source/games/exhumed/src/player.cpp
Expand Up @@ -411,7 +411,7 @@ void RestartPlayer(int nPlayer)

plr->nThrust.Zero();

plr->nDestVertPan = plr->Angles.ZzOLDHORIZON = plr->Angles.ZzHORIZON() = nullAngle;
plr->nDestVertPan = plr->Angles.ZzOLDHORIZON() = plr->Angles.ZzHORIZON() = nullAngle;
plr->nBreathTimer = 90;

plr->nTauntTimer = RandomSize(3) + 3;
Expand Down Expand Up @@ -507,7 +507,7 @@ void StartDeathSeq(int nPlayer, int nVal)

StopFiringWeapon(nPlayer);

PlayerList[nPlayer].Angles.ZzOLDHORIZON = PlayerList[nPlayer].Angles.ZzHORIZON() = nullAngle;
PlayerList[nPlayer].Angles.ZzOLDHORIZON() = PlayerList[nPlayer].Angles.ZzHORIZON() = nullAngle;
pActor->oviewzoffset = pActor->viewzoffset = -55;
PlayerList[nPlayer].nInvisible = 0;
dVertPan[nPlayer] = 15;
Expand Down
2 changes: 1 addition & 1 deletion source/games/sw/src/player.cpp
Expand Up @@ -7048,7 +7048,7 @@ void InitAllPlayers(void)
for (pp = Player; pp < &Player[MAX_SW_PLAYERS]; pp++)
{
pp->Angles.ZzANGLE = pp->Angles.ZzOLDANGLE = pfirst->Angles.ZzANGLE;
pp->Angles.ZzHORIZON() = pp->Angles.ZzOLDHORIZON = pfirst->Angles.ZzHORIZON();
pp->Angles.ZzHORIZON() = pp->Angles.ZzOLDHORIZON() = pfirst->Angles.ZzHORIZON();
pp->cursector = pfirst->cursector;
// set like this so that player can trigger something on start of the level
pp->lastcursector = pfirst->cursector+1;
Expand Down

0 comments on commit 46aca77

Please sign in to comment.