- Rename remaining PlayerHorizon methods.

This commit is contained in:
Mitchell Richters 2022-11-27 13:56:35 +11:00 committed by Christoph Oelckers
parent 3758d93ad8
commit 9ab8db04db
17 changed files with 55 additions and 55 deletions

View file

@ -176,7 +176,7 @@ void processMovement(InputPacket* const currInput, InputPacket* const inputBuffe
void PlayerHorizon::applyinput(float const horz, ESyncBits* actions, double const scaleAdjust)
{
// Process only if movement isn't locked.
if (!movementlocked())
if (!lockedPitch())
{
// Process mouse input.
if (horz)
@ -367,7 +367,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerHorizon& w,
w.ZzOLDHORIZON = w.ZzHORIZON;
w.ZzOHORIZOFF = w.ZzHORIZOFF;
w.inputdisabled = w.inputdisabled;
w.resetadjustment();
w.resetAdjustmentPitch();
}
}
return arc;

View file

@ -17,12 +17,12 @@ struct PlayerHorizon
void calcviewpitch(const DVector2& pos, DAngle const ang, bool const aimmode, bool const canslopetilt, sectortype* const cursectnum, double const scaleAdjust = 1, bool const climbing = false);
// Interpolation helpers.
void backup()
void backupPitch()
{
ZzOLDHORIZON = ZzHORIZON;
ZzOHORIZOFF = ZzHORIZOFF;
}
void restore()
void restorePitch()
{
ZzHORIZON = ZzOLDHORIZON;
ZzHORIZOFF = ZzOHORIZOFF;
@ -34,16 +34,16 @@ struct PlayerHorizon
DAngle horizLERPSUM(double const interpfrac) { return interpolatedvalue(horizOLDSUM(), horizSUM(), interpfrac); }
// Ticrate playsim adjustment helpers.
void resetadjustment() { adjustment = nullAngle; }
bool targetset() { return target.Sgn(); }
void resetAdjustmentPitch() { adjustment = nullAngle; }
bool targetedPitch() { return target.Sgn(); }
// Input locking helpers.
void lockinput() { inputdisabled = true; }
void unlockinput() { inputdisabled = false; }
bool movementlocked() { return targetset() || inputdisabled; }
void lockPitch() { inputdisabled = true; }
void unlockPitch() { inputdisabled = false; }
bool lockedPitch() { return targetedPitch() || inputdisabled; }
// Ticrate playsim adjustment setters and processor.
void addadjustment(DAngle const value)
void addPitch(DAngle const value)
{
if (!SyncInput())
{
@ -55,7 +55,7 @@ struct PlayerHorizon
}
}
void settarget(DAngle value, bool const backup = false)
void setPitch(DAngle value, bool const backup = false)
{
// Clamp incoming variable because sometimes the caller can exceed bounds.
value = ClampViewPitch(value);
@ -71,9 +71,9 @@ struct PlayerHorizon
}
}
void processhelpers(double const scaleAdjust)
void processLegacyHelperPitch(double const scaleAdjust)
{
if (targetset())
if (targetedPitch())
{
auto delta = deltaangle(ZzHORIZON, target);

View file

@ -68,7 +68,7 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju
}
pPlayer->angle.processhelpers(scaleAdjust);
pPlayer->horizon.processhelpers(scaleAdjust);
pPlayer->horizon.processLegacyHelperPitch(scaleAdjust);
UpdatePlayerSpriteAngle(pPlayer);
}

View file

@ -2186,8 +2186,8 @@ void trPlayerCtrlSetLookAngle(int value, PLAYER* pPlayer)
if (const double adjustment = clamp(value * 0.125 * (value > 0 ? lookStepUp : lookStepDown), downAngle, upAngle))
{
pPlayer->horizon.settarget(maphoriz(-100. * tan(adjustment * pi::pi() * (1. / 1024.))));
pPlayer->horizon.lockinput();
pPlayer->horizon.setPitch(maphoriz(-100. * tan(adjustment * pi::pi() * (1. / 1024.))));
pPlayer->horizon.lockPitch();
}
}

View file

@ -1532,7 +1532,7 @@ void ProcessInput(PLAYER* pPlayer)
Item_JumpBoots = 3
};
pPlayer->horizon.resetadjustment();
pPlayer->horizon.resetAdjustmentPitch();
pPlayer->angle.resetadjustment();
DBloodActor* actor = pPlayer->actor;
@ -1558,7 +1558,7 @@ void ProcessInput(PLAYER* pPlayer)
}
pPlayer->deathTime += 4;
if (!bSeqStat)
pPlayer->horizon.addadjustment(deltaangle(pPlayer->horizon.ZzHORIZON, gi->playerPitchMax() * (1. - BobVal(min((pPlayer->deathTime << 3) + 512, 1536))) * 0.5));
pPlayer->horizon.addPitch(deltaangle(pPlayer->horizon.ZzHORIZON, gi->playerPitchMax() * (1. - BobVal(min((pPlayer->deathTime << 3) + 512, 1536))) * 0.5));
if (pPlayer->curWeapon)
pInput->setNewWeapon(pPlayer->curWeapon);
if (pInput->actions & SB_OPEN)
@ -1731,7 +1731,7 @@ void ProcessInput(PLAYER* pPlayer)
}
pPlayer->angle.unlockinput();
pPlayer->horizon.unlockinput();
pPlayer->horizon.unlockPitch();
pPlayer->slope = pPlayer->horizon.ZzHORIZON.Tan();
if (pInput->actions & SB_INVPREV)

View file

@ -66,7 +66,7 @@ void viewBackupView(int nPlayer)
pPlayer->oswayHeight = pPlayer->swayHeight;
pPlayer->oswayWidth = pPlayer->swayWidth;
pPlayer->angle.backup();
pPlayer->horizon.backup();
pPlayer->horizon.backupPitch();
}
//---------------------------------------------------------------------------

View file

@ -928,7 +928,7 @@ static bool weaponhitsprite(DDukeActor* proj, DDukeActor *targ, bool fireball)
if (proj->spr.picnum == SPIT)
{
ps[p].horizon.addadjustment(DAngle::fromDeg(-14.04));
ps[p].horizon.addPitch(DAngle::fromDeg(-14.04));
ps[p].sync.actions |= SB_CENTERVIEW;
if (ps[p].loogcnt == 0)

View file

@ -796,7 +796,7 @@ static bool weaponhitsprite(DDukeActor *proj, DDukeActor *targ, const DVector3 &
guts_r(proj, RABBITJIBC, 2, myconnectindex);
}
ps[p].horizon.addadjustment(DAngle::fromDeg(-14.04));
ps[p].horizon.addPitch(DAngle::fromDeg(-14.04));
ps[p].sync.actions |= SB_CENTERVIEW;
if (ps[p].loogcnt == 0)

View file

@ -344,7 +344,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
{
ps[iPlayer].sync.actions &= ~SB_CENTERVIEW;
}
ps[iPlayer].horizon.settarget(maphoriz(-lValue));
ps[iPlayer].horizon.setPitch(maphoriz(-lValue));
}
else SetGameVarID(lVar2, int(ps[iPlayer].horizon.ZzHORIZON.Tan() * -128.), sActor, sPlayer);
break;

View file

@ -842,7 +842,7 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju
}
p->angle.processhelpers(scaleAdjust);
p->horizon.processhelpers(scaleAdjust);
p->horizon.processLegacyHelperPitch(scaleAdjust);
p->GetActor()->spr.Angles.Yaw = p->angle.ang; // check me out later.
}

View file

@ -117,7 +117,7 @@ void forceplayerangle(int snum)
{
player_struct* p = &ps[snum];
p->horizon.addadjustment(DAngle::fromDeg(-26.566));
p->horizon.addPitch(DAngle::fromDeg(-26.566));
p->sync.actions |= SB_CENTERVIEW;
p->angle.rotscrnang = p->angle.look_ang = (DAngle22_5 - randomAngle(45)) / 2.;
}
@ -378,7 +378,7 @@ void dokneeattack(int snum, const std::initializer_list<int> & respawnlist)
{
p->oknee_incs = p->knee_incs;
p->knee_incs++;
p->horizon.addadjustment(deltaangle(p->horizon.ZzHORIZON, (p->GetActor()->getPosWithOffsetZ() - p->actorsqu->spr.pos).Pitch() * 1.1875));
p->horizon.addPitch(deltaangle(p->horizon.ZzHORIZON, (p->GetActor()->getPosWithOffsetZ() - p->actorsqu->spr.pos).Pitch() * 1.1875));
p->sync.actions |= SB_CENTERVIEW;
if (p->knee_incs > 15)
{
@ -547,7 +547,7 @@ inline void backupplayer(player_struct* p)
{
p->backuppos();
p->angle.backup();
p->horizon.backup();
p->horizon.backupPitch();
}
void playerisdead(int snum, int psectlotag, double floorz, double ceilingz)
@ -807,7 +807,7 @@ void player_struct::checkhardlanding()
{
if (hard_landing > 0)
{
horizon.addadjustment(maphoriz(hard_landing << 4));
horizon.addPitch(maphoriz(hard_landing << 4));
hard_landing--;
}
}

View file

@ -2725,7 +2725,7 @@ void processinput_d(int snum)
p = &ps[snum];
auto pact = p->GetActor();
p->horizon.resetadjustment();
p->horizon.resetAdjustmentPitch();
p->angle.resetadjustment();
ESyncBits& actions = p->sync.actions;
@ -2763,7 +2763,7 @@ void processinput_d(int snum)
if (SyncInput())
{
p->horizon.backup();
p->horizon.backupPitch();
doslopetilting(p);
}

View file

@ -1718,7 +1718,7 @@ static void onMotorcycle(int snum, ESyncBits &actions)
}
if (horiz != FRACUNIT)
{
p->horizon.addadjustment(deltaangle(p->horizon.ZzHORIZON, maphoriz(-horiz)));
p->horizon.addPitch(deltaangle(p->horizon.ZzHORIZON, maphoriz(-horiz)));
}
const DAngle adjust = mapangle(-510);
@ -1986,7 +1986,7 @@ static void onBoat(int snum, ESyncBits &actions)
}
if (horiz != FRACUNIT)
{
p->horizon.addadjustment(deltaangle(p->horizon.ZzHORIZON, maphoriz(-horiz)));
p->horizon.addPitch(deltaangle(p->horizon.ZzHORIZON, maphoriz(-horiz)));
}
if (p->MotoSpeed > 0 && p->on_ground == 1 && (p->vehTurnLeft || p->vehTurnRight))
@ -2894,7 +2894,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
case RIFLEGUN_WEAPON:
p->kickback_pic++;
p->horizon.addadjustment(DAngle::fromDeg(-0.4476));
p->horizon.addPitch(DAngle::fromDeg(-0.4476));
p->recoil++;
if (p->kickback_pic <= 12)
@ -3066,7 +3066,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
else if (p->kickback_pic == 12)
{
p->vel.XY() -= p->angle.ang.ToVector();
p->horizon.addadjustment(DAngle::fromDeg(-8.88));
p->horizon.addPitch(DAngle::fromDeg(-8.88));
p->recoil += 20;
}
if (p->kickback_pic > 20)
@ -3272,7 +3272,7 @@ void processinput_r(int snum)
auto p = &ps[snum];
auto pact = p->GetActor();
p->horizon.resetadjustment();
p->horizon.resetAdjustmentPitch();
p->angle.resetadjustment();
ESyncBits& actions = p->sync.actions;
@ -3349,7 +3349,7 @@ void processinput_r(int snum)
if (SyncInput())
{
p->horizon.backup();
p->horizon.backupPitch();
doslopetilting(p);
}
@ -3890,7 +3890,7 @@ HORIZONLY:
if (!d)
d = 1;
p->recoil -= d;
p->horizon.addadjustment(maphoriz(d));
p->horizon.addPitch(maphoriz(d));
}
if (SyncInput())
@ -3960,7 +3960,7 @@ void OnMotorcycle(player_struct *p, DDukeActor* motosprite)
p->gotweapon[MOTORCYCLE_WEAPON] = true;
p->vel.X = 0;
p->vel.Y = 0;
p->horizon.settarget(nullAngle);
p->horizon.setPitch(nullAngle);
}
if (!S_CheckActorSoundPlaying(p->GetActor(),186))
S_PlayActorSound(186, p->GetActor());
@ -3991,7 +3991,7 @@ void OffMotorcycle(player_struct *p)
p->gotweapon[MOTORCYCLE_WEAPON] = false;
p->curr_weapon = p->last_full_weapon;
checkavailweapon(p);
p->horizon.settarget(nullAngle);
p->horizon.setPitch(nullAngle);
p->moto_do_bump = 0;
p->MotoSpeed = 0;
p->TiltStatus = 0;
@ -4034,7 +4034,7 @@ void OnBoat(player_struct *p, DDukeActor* boat)
p->gotweapon[BOAT_WEAPON] = true;
p->vel.X = 0;
p->vel.Y = 0;
p->horizon.settarget(nullAngle);
p->horizon.setPitch(nullAngle);
}
}
@ -4052,7 +4052,7 @@ void OffBoat(player_struct *p)
p->gotweapon[BOAT_WEAPON] = false;
p->curr_weapon = p->last_full_weapon;
checkavailweapon(p);
p->horizon.settarget(nullAngle);
p->horizon.setPitch(nullAngle);
p->moto_do_bump = 0;
p->MotoSpeed = 0;
p->TiltStatus = 0;

View file

@ -96,7 +96,7 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju
}
pPlayer->angle.processhelpers(scaleAdjust);
pPlayer->horizon.processhelpers(scaleAdjust);
pPlayer->horizon.processLegacyHelperPitch(scaleAdjust);
UpdatePlayerSpriteAngle(pPlayer);
}

View file

@ -314,7 +314,7 @@ void RestartPlayer(int nPlayer)
}
plr->angle.backup();
plr->horizon.backup();
plr->horizon.backupPitch();
plr->pPlayerFloorSprite = floorsprt;
@ -905,9 +905,9 @@ void AIPlayer::Tick(RunListEvent* ev)
int nActionB = PlayerList[nPlayer].nAction;
PlayerList[nPlayer].angle.backup();
PlayerList[nPlayer].horizon.backup();
PlayerList[nPlayer].horizon.backupPitch();
PlayerList[nPlayer].angle.resetadjustment();
PlayerList[nPlayer].horizon.resetadjustment();
PlayerList[nPlayer].horizon.resetAdjustmentPitch();
pPlayerActor->vel.XY() = sPlayerInput[nPlayer].vel;
@ -1075,7 +1075,7 @@ void AIPlayer::Tick(RunListEvent* ev)
PlayerList[nPlayer].angle.settarget(ang, true);
pPlayerActor->spr.Angles.Yaw = ang;
PlayerList[nPlayer].horizon.settarget(nullAngle, true);
PlayerList[nPlayer].horizon.setPitch(nullAngle, true);
sPlayerInput[nPlayer].vel.Zero();
pPlayerActor->vel.Zero();
@ -1088,7 +1088,7 @@ void AIPlayer::Tick(RunListEvent* ev)
InitSpiritHead();
PlayerList[nPlayer].nDestVertPan = nullAngle;
PlayerList[nPlayer].horizon.settarget(currentLevel->ex_ramses_horiz);
PlayerList[nPlayer].horizon.setPitch(currentLevel->ex_ramses_horiz);
}
}
else
@ -2498,7 +2498,7 @@ sectdone:
{
if (double nVertPan = deltaangle(pPlayer->horizon.ZzHORIZON, pPlayer->nDestVertPan).Tan() * 32.)
{
pPlayer->horizon.addadjustment(maphoriz(abs(nVertPan) >= 4 ? clamp(nVertPan, -4., 4.) : nVertPan * 2.));
pPlayer->horizon.addPitch(maphoriz(abs(nVertPan) >= 4 ? clamp(nVertPan, -4., 4.) : nVertPan * 2.));
}
}
}
@ -2618,16 +2618,16 @@ sectdone:
{
if (PlayerList[nPlayer].horizon.ZzHORIZON.Sgn() > 0)
{
PlayerList[nPlayer].horizon.settarget(nullAngle);
PlayerList[nPlayer].horizon.setPitch(nullAngle);
pPlayerActor->viewzoffset -= dVertPan[nPlayer];
}
else
{
PlayerList[nPlayer].horizon.addadjustment(maphoriz(-dVertPan[nPlayer]));
PlayerList[nPlayer].horizon.addPitch(maphoriz(-dVertPan[nPlayer]));
if (PlayerList[nPlayer].horizon.ZzHORIZON.Degrees() <= 38)
{
PlayerList[nPlayer].horizon.settarget(DAngle::fromDeg(-37.72));
PlayerList[nPlayer].horizon.setPitch(DAngle::fromDeg(-37.72));
}
else if (PlayerList[nPlayer].horizon.ZzHORIZON.Sgn() >= 0)
{

View file

@ -201,7 +201,7 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju
}
pp->angle.processhelpers(scaleAdjust);
pp->horizon.processhelpers(scaleAdjust);
pp->horizon.processLegacyHelperPitch(scaleAdjust);
}
if (packet)

View file

@ -5880,7 +5880,7 @@ static inline void DoPlayerDeathHoriz(PLAYER* pp, const DAngle target, const dou
if (abs(targetdelta.Degrees()) > 1)
{
pp->horizon.addadjustment(DAngle::fromDeg(speed * targetdelta.Sgn()));
pp->horizon.addPitch(DAngle::fromDeg(speed * targetdelta.Sgn()));
}
}
@ -6694,7 +6694,7 @@ void MoveSkipSavePos(void)
pp->actor->backuppos();
pp->obob_z = pp->bob_z;
pp->angle.backup();
pp->horizon.backup();
pp->horizon.backupPitch();
pp->opbob_amt = pp->pbob_amt;
}
@ -6987,7 +6987,7 @@ void domovethings(void)
// Reset flags used while tying input to framerate
pp->Flags2 &= ~(PF2_INPUT_CAN_AIM|PF2_INPUT_CAN_TURN_GENERAL|PF2_INPUT_CAN_TURN_VEHICLE|PF2_INPUT_CAN_TURN_TURRET);
pp->horizon.resetadjustment();
pp->horizon.resetAdjustmentPitch();
pp->angle.resetadjustment();
// disable synchronised input if set by game.