- Wrap access to previous pitch.

This commit is contained in:
Mitchell Richters 2022-11-25 18:32:31 +11:00 committed by Christoph Oelckers
parent 15f1d89855
commit fd05d320ff
6 changed files with 14 additions and 12 deletions

View file

@ -352,7 +352,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();

View file

@ -11,6 +11,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);
@ -52,7 +54,7 @@ struct PlayerAngles
else
{
ZzHORIZON() = value;
if (backup) ZzOLDHORIZON = ZzHORIZON();
if (backup) ZzOLDHORIZON() = ZzHORIZON();
}
}
@ -105,7 +107,7 @@ struct PlayerAngles
// Legacy, to be removed.
DAngle ZzOLDHORIZON, ZzHORIZOFF, ZzOHORIZOFF;
DAngle ZzHORIZOFF, ZzOHORIZOFF;
void processLegacyHelperPitch(double const scaleAdjust)
{
if (targetedPitch())
@ -129,15 +131,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; }

View file

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

View file

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

View file

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

View file

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