Skip to content

Commit

Permalink
- Rename remaining PlayerHorizon methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjr4077au committed Nov 26, 2022
1 parent 9cd98a6 commit ce3ae65
Show file tree
Hide file tree
Showing 17 changed files with 54 additions and 55 deletions.
4 changes: 2 additions & 2 deletions source/core/gameinput.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -365,7 +365,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;
Expand Down
21 changes: 10 additions & 11 deletions source/core/gameinput.h
Expand Up @@ -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;
Expand All @@ -34,16 +34,15 @@ 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; }

// 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 target.Sgn() || inputdisabled; }

// Ticrate playsim adjustment setters and processor.
void addadjustment(DAngle const value)
void addToPitch(DAngle const value)
{
if (!SyncInput())
{
Expand All @@ -55,7 +54,7 @@ struct PlayerHorizon
}
}

void settarget(DAngle value, bool const backup = false)
void setNewPitch(DAngle value, bool const backup = false)
{
// Clamp incoming variable because sometimes the caller can exceed bounds.
value = ClampViewPitch(value);
Expand All @@ -71,9 +70,9 @@ struct PlayerHorizon
}
}

void processhelpers(double const scaleAdjust)
void processLegacyHelperPitch(double const scaleAdjust)
{
if (targetset())
if (targetedPitch())
{
auto delta = deltaangle(ZzHORIZON, target);

Expand Down
2 changes: 1 addition & 1 deletion source/games/blood/src/controls.cpp
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions source/games/blood/src/nnexts.cpp
Expand Up @@ -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.setNewPitch(maphoriz(-100. * tan(adjustment * pi::pi() * (1. / 1024.))));
pPlayer->horizon.lockPitch();
}
}

Expand Down
6 changes: 3 additions & 3 deletions source/games/blood/src/player.cpp
Expand Up @@ -1532,7 +1532,7 @@ void ProcessInput(PLAYER* pPlayer)
Item_JumpBoots = 3
};

pPlayer->horizon.resetadjustment();
pPlayer->horizon.resetAdjustmentPitch();
pPlayer->angle.resetadjustment();

DBloodActor* actor = pPlayer->actor;
Expand All @@ -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.addToPitch(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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion source/games/blood/src/view.cpp
Expand Up @@ -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();
}

//---------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/actors_d.cpp
Expand Up @@ -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.addToPitch(DAngle::fromDeg(-14.04));
ps[p].sync.actions |= SB_CENTERVIEW;

if (ps[p].loogcnt == 0)
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/actors_r.cpp
Expand Up @@ -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.addToPitch(DAngle::fromDeg(-14.04));
ps[p].sync.actions |= SB_CENTERVIEW;

if (ps[p].loogcnt == 0)
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/gameexec.cpp
Expand Up @@ -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.setNewPitch(maphoriz(-lValue));
}
else SetGameVarID(lVar2, int(ps[iPlayer].horizon.ZzHORIZON.Tan() * -128.), sActor, sPlayer);
break;
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/input.cpp
Expand Up @@ -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.
}

Expand Down
8 changes: 4 additions & 4 deletions source/games/duke/src/player.cpp
Expand Up @@ -117,7 +117,7 @@ void forceplayerangle(int snum)
{
player_struct* p = &ps[snum];

p->horizon.addadjustment(DAngle::fromDeg(-26.566));
p->horizon.addToPitch(DAngle::fromDeg(-26.566));
p->sync.actions |= SB_CENTERVIEW;
p->angle.rotscrnang = p->angle.look_ang = (DAngle22_5 - randomAngle(45)) / 2.;
}
Expand Down Expand Up @@ -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.addToPitch(deltaangle(p->horizon.ZzHORIZON, (p->GetActor()->getPosWithOffsetZ() - p->actorsqu->spr.pos).Pitch() * 1.1875));
p->sync.actions |= SB_CENTERVIEW;
if (p->knee_incs > 15)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -807,7 +807,7 @@ void player_struct::checkhardlanding()
{
if (hard_landing > 0)
{
horizon.addadjustment(maphoriz(hard_landing << 4));
horizon.addToPitch(maphoriz(hard_landing << 4));
hard_landing--;
}
}
Expand Down
4 changes: 2 additions & 2 deletions source/games/duke/src/player_d.cpp
Expand Up @@ -2719,7 +2719,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;
Expand Down Expand Up @@ -2757,7 +2757,7 @@ void processinput_d(int snum)

if (SyncInput())
{
p->horizon.backup();
p->horizon.backupPitch();
doslopetilting(p);
}

Expand Down
22 changes: 11 additions & 11 deletions source/games/duke/src/player_r.cpp
Expand Up @@ -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.addToPitch(deltaangle(p->horizon.ZzHORIZON, maphoriz(-horiz)));
}

const DAngle adjust = mapangle(-510);
Expand Down Expand Up @@ -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.addToPitch(deltaangle(p->horizon.ZzHORIZON, maphoriz(-horiz)));
}

if (p->MotoSpeed > 0 && p->on_ground == 1 && (p->vehTurnLeft || p->vehTurnRight))
Expand Down Expand Up @@ -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.addToPitch(DAngle::fromDeg(-0.4476));
p->recoil++;

if (p->kickback_pic <= 12)
Expand Down Expand Up @@ -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.addToPitch(DAngle::fromDeg(-8.88));
p->recoil += 20;
}
if (p->kickback_pic > 20)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -3349,7 +3349,7 @@ void processinput_r(int snum)

if (SyncInput())
{
p->horizon.backup();
p->horizon.backupPitch();
doslopetilting(p);
}

Expand Down Expand Up @@ -3890,7 +3890,7 @@ void processinput_r(int snum)
if (!d)
d = 1;
p->recoil -= d;
p->horizon.addadjustment(maphoriz(d));
p->horizon.addToPitch(maphoriz(d));
}

if (SyncInput())
Expand Down Expand Up @@ -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.setNewPitch(nullAngle);
}
if (!S_CheckActorSoundPlaying(p->GetActor(),186))
S_PlayActorSound(186, p->GetActor());
Expand Down Expand Up @@ -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.setNewPitch(nullAngle);
p->moto_do_bump = 0;
p->MotoSpeed = 0;
p->TiltStatus = 0;
Expand Down Expand Up @@ -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.setNewPitch(nullAngle);
}
}

Expand All @@ -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.setNewPitch(nullAngle);
p->moto_do_bump = 0;
p->MotoSpeed = 0;
p->TiltStatus = 0;
Expand Down
2 changes: 1 addition & 1 deletion source/games/exhumed/src/input.cpp
Expand Up @@ -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);
}

Expand Down
18 changes: 9 additions & 9 deletions source/games/exhumed/src/player.cpp
Expand Up @@ -314,7 +314,7 @@ void RestartPlayer(int nPlayer)
}

plr->angle.backup();
plr->horizon.backup();
plr->horizon.backupPitch();

plr->pPlayerFloorSprite = floorsprt;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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.setNewPitch(nullAngle, true);

sPlayerInput[nPlayer].vel.Zero();
pPlayerActor->vel.Zero();
Expand All @@ -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.setNewPitch(currentLevel->ex_ramses_horiz);
}
}
else
Expand Down Expand Up @@ -2498,7 +2498,7 @@ void AIPlayer::Tick(RunListEvent* ev)
{
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.addToPitch(maphoriz(abs(nVertPan) >= 4 ? clamp(nVertPan, -4., 4.) : nVertPan * 2.));
}
}
}
Expand Down Expand Up @@ -2618,16 +2618,16 @@ void AIPlayer::Tick(RunListEvent* ev)
{
if (PlayerList[nPlayer].horizon.ZzHORIZON.Sgn() > 0)
{
PlayerList[nPlayer].horizon.settarget(nullAngle);
PlayerList[nPlayer].horizon.setNewPitch(nullAngle);
pPlayerActor->viewzoffset -= dVertPan[nPlayer];
}
else
{
PlayerList[nPlayer].horizon.addadjustment(maphoriz(-dVertPan[nPlayer]));
PlayerList[nPlayer].horizon.addToPitch(maphoriz(-dVertPan[nPlayer]));

if (PlayerList[nPlayer].horizon.ZzHORIZON.Degrees() <= 38)
{
PlayerList[nPlayer].horizon.settarget(DAngle::fromDeg(-37.72));
PlayerList[nPlayer].horizon.setNewPitch(DAngle::fromDeg(-37.72));
}
else if (PlayerList[nPlayer].horizon.ZzHORIZON.Sgn() >= 0)
{
Expand Down

0 comments on commit ce3ae65

Please sign in to comment.