Skip to content

Commit

Permalink
- Rename PlayerHorizon::horiz in preparation for replacement work.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjr4077au committed Nov 26, 2022
1 parent 5a1c4f5 commit 81bb213
Show file tree
Hide file tree
Showing 16 changed files with 84 additions and 84 deletions.
16 changes: 8 additions & 8 deletions source/core/gameinput.cpp
Expand Up @@ -181,31 +181,31 @@ void PlayerHorizon::applyinput(float const horz, ESyncBits* actions, double cons
// Process mouse input.
if (horz)
{
horiz += DAngle::fromDeg(horz);
ZzHORIZON += DAngle::fromDeg(horz);
*actions &= ~SB_CENTERVIEW;
}

// Process keyboard input.
if (auto aiming = !!(*actions & SB_AIM_DOWN) - !!(*actions & SB_AIM_UP))
{
horiz += getTicrateScale(PITCH_AIMSPEED) * scaleAdjust * aiming;
ZzHORIZON += getTicrateScale(PITCH_AIMSPEED) * scaleAdjust * aiming;
*actions &= ~SB_CENTERVIEW;
}
if (auto looking = !!(*actions & SB_LOOK_DOWN) - !!(*actions & SB_LOOK_UP))
{
horiz += getTicrateScale(PITCH_LOOKSPEED) * scaleAdjust * looking;
ZzHORIZON += getTicrateScale(PITCH_LOOKSPEED) * scaleAdjust * looking;
*actions |= SB_CENTERVIEW;
}

// Do return to centre.
if ((*actions & SB_CENTERVIEW) && !(*actions & (SB_LOOK_UP|SB_LOOK_DOWN)))
{
scaletozero(horiz, PITCH_CENTERSPEED * (PITCH_CNTRSINEOFFSET - abs(horiz)).Sin(), scaleAdjust);
if (!horiz.Sgn()) *actions &= ~SB_CENTERVIEW;
scaletozero(ZzHORIZON, PITCH_CENTERSPEED * (PITCH_CNTRSINEOFFSET - abs(ZzHORIZON)).Sin(), scaleAdjust);
if (!ZzHORIZON.Sgn()) *actions &= ~SB_CENTERVIEW;
}

// clamp before we finish, even if it's clamped in the drawer.
horiz = ClampViewPitch(horiz);
ZzHORIZON = ClampViewPitch(ZzHORIZON);
}
else
{
Expand Down Expand Up @@ -355,14 +355,14 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerHorizon& w,
{
if (arc.BeginObject(keyname))
{
arc("horiz", w.horiz)
arc("horiz", w.ZzHORIZON)
("horizoff", w.horizoff)
("inputdisabled", w.inputdisabled)
.EndObject();

if (arc.isReading())
{
w.ohoriz = w.horiz;
w.ohoriz = w.ZzHORIZON;
w.ohorizoff = w.horizoff;
w.inputdisabled = w.inputdisabled;
w.resetadjustment();
Expand Down
22 changes: 11 additions & 11 deletions source/core/gameinput.h
Expand Up @@ -8,7 +8,7 @@

struct PlayerHorizon
{
DAngle horiz, ohoriz, horizoff, ohorizoff;
DAngle ZzHORIZON, ohoriz, horizoff, ohorizoff;

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

Expand All @@ -19,18 +19,18 @@ struct PlayerHorizon
// Interpolation helpers.
void backup()
{
ohoriz = horiz;
ohoriz = ZzHORIZON;
ohorizoff = horizoff;
}
void restore()
{
horiz = ohoriz;
ZzHORIZON = ohoriz;
horizoff = ohorizoff;
}

// Commonly used getters.
DAngle osum() { return ohoriz + ohorizoff; }
DAngle sum() { return horiz + horizoff; }
DAngle sum() { return ZzHORIZON + horizoff; }
DAngle interpolatedsum(double const interpfrac) { return interpolatedvalue(osum(), sum(), interpfrac); }

// Ticrate playsim adjustment helpers.
Expand All @@ -51,7 +51,7 @@ struct PlayerHorizon
}
else
{
horiz += value;
ZzHORIZON += value;
}
}

Expand All @@ -66,30 +66,30 @@ struct PlayerHorizon
}
else
{
horiz = value;
if (backup) ohoriz = horiz;
ZzHORIZON = value;
if (backup) ohoriz = ZzHORIZON;
}
}

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

if (abs(delta).Degrees() > 0.45)
{
horiz += delta * scaleAdjust;
ZzHORIZON += delta * scaleAdjust;
}
else
{
horiz = target;
ZzHORIZON = target;
target = nullAngle;
}
}
else if (adjustment.Sgn())
{
horiz += adjustment * scaleAdjust;
ZzHORIZON += adjustment * scaleAdjust;
}
}

Expand Down
6 changes: 3 additions & 3 deletions source/games/blood/src/player.cpp
Expand Up @@ -821,7 +821,7 @@ void playerStart(int nPlayer, int bNewLevel)
pPlayer->actor->xspr.health = pDudeInfo->startHealth << 4;
pPlayer->actor->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE;
pPlayer->bloodlust = 0;
pPlayer->horizon.horiz = pPlayer->horizon.horizoff = nullAngle;
pPlayer->horizon.ZzHORIZON = pPlayer->horizon.horizoff = nullAngle;
pPlayer->slope = 0;
pPlayer->fragger = nullptr;
pPlayer->underwaterTime = 1200;
Expand Down Expand Up @@ -1558,7 +1558,7 @@ void ProcessInput(PLAYER* pPlayer)
}
pPlayer->deathTime += 4;
if (!bSeqStat)
pPlayer->horizon.addadjustment(deltaangle(pPlayer->horizon.horiz, gi->playerPitchMax() * (1. - BobVal(min((pPlayer->deathTime << 3) + 512, 1536))) * 0.5));
pPlayer->horizon.addadjustment(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 @@ -1733,7 +1733,7 @@ void ProcessInput(PLAYER* pPlayer)
pPlayer->angle.unlockinput();
pPlayer->horizon.unlockinput();

pPlayer->slope = pPlayer->horizon.horiz.Tan();
pPlayer->slope = pPlayer->horizon.ZzHORIZON.Tan();
if (pInput->actions & SB_INVPREV)
{
pInput->actions &= ~SB_INVPREV;
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/actors_d.cpp
Expand Up @@ -1719,7 +1719,7 @@ static void greenslime(DDukeActor *actor)
return;
}

actor->spr.pos.Z = ps[p].GetActor()->getOffsetZ() + 8 + ps[p].pyoff - (actor->temp_data[2] + (ps[p].horizon.horiz.Tan() * 2048.)) * zinttoworld;
actor->spr.pos.Z = ps[p].GetActor()->getOffsetZ() + 8 + ps[p].pyoff - (actor->temp_data[2] + (ps[p].horizon.ZzHORIZON.Tan() * 2048.)) * zinttoworld;

if (actor->temp_data[2] > 512)
actor->temp_data[2] -= 128;
Expand Down
6 changes: 3 additions & 3 deletions source/games/duke/src/gameexec.cpp
Expand Up @@ -346,7 +346,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
}
ps[iPlayer].horizon.settarget(maphoriz(-lValue));
}
else SetGameVarID(lVar2, int(ps[iPlayer].horizon.horiz.Tan() * -128.), sActor, sPlayer);
else SetGameVarID(lVar2, int(ps[iPlayer].horizon.ZzHORIZON.Tan() * -128.), sActor, sPlayer);
break;

case PLAYER_OHORIZ:
Expand Down Expand Up @@ -925,7 +925,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,

case PLAYER_RETURN_TO_CENTER:
if (bSet) ps[iPlayer].sync.actions |= SB_CENTERVIEW;
else SetGameVarID(lVar2, ps[iPlayer].sync.actions & SB_CENTERVIEW ? int(abs((ps[iPlayer].horizon.horiz * (DAngle::fromDeg(9.) / GetMaxPitch())).Degrees())) : 0, sActor, sPlayer);
else SetGameVarID(lVar2, ps[iPlayer].sync.actions & SB_CENTERVIEW ? int(abs((ps[iPlayer].horizon.ZzHORIZON * (DAngle::fromDeg(9.) / GetMaxPitch())).Degrees())) : 0, sActor, sPlayer);
break;

default:
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].horizon.ohoriz = ps[g_p].horizon.horiz = nullAngle;
ps[g_p].horizon.ohoriz = ps[g_p].horizon.ZzHORIZON = nullAngle;
ps[g_p].on_crane = nullptr;
ps[g_p].frag_ps = g_p;
ps[g_p].horizon.ohorizoff = ps[g_p].horizon.horizoff = nullAngle;
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/input.cpp
Expand Up @@ -792,7 +792,7 @@ static void FinalizeInput(player_struct *p, InputPacket& input)
loc.avel = input.avel = 0;
}

if (p->newOwner != nullptr || (p->sync.actions & SB_CENTERVIEW && abs(p->horizon.horiz.Degrees()) > 2.2370))
if (p->newOwner != nullptr || (p->sync.actions & SB_CENTERVIEW && abs(p->horizon.ZzHORIZON.Degrees()) > 2.2370))
{
loc.horz = input.horz = 0;
}
Expand Down
4 changes: 2 additions & 2 deletions source/games/duke/src/player.cpp
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.horiz, (p->GetActor()->getPosWithOffsetZ() - p->actorsqu->spr.pos).Pitch() * 1.1875));
p->horizon.addadjustment(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 @@ -622,7 +622,7 @@ void playerisdead(int snum, int psectlotag, double floorz, double ceilingz)

backupplayer(p);

p->horizon.horizoff = p->horizon.horiz = nullAngle;
p->horizon.horizoff = p->horizon.ZzHORIZON = nullAngle;

updatesector(p->GetActor()->getPosWithOffsetZ(), &p->cursector);

Expand Down
8 changes: 4 additions & 4 deletions source/games/duke/src/player_r.cpp
Expand Up @@ -1472,7 +1472,7 @@ void checkweapons_r(player_struct* p)
}
p->OnMotorcycle = 0;
p->gotweapon[MOTORCYCLE_WEAPON] = false;
p->horizon.horiz = nullAngle;
p->horizon.ZzHORIZON = nullAngle;
p->moto_do_bump = 0;
p->MotoSpeed = 0;
p->TiltStatus = 0;
Expand All @@ -1491,7 +1491,7 @@ void checkweapons_r(player_struct* p)
}
p->OnBoat = 0;
p->gotweapon[BOAT_WEAPON] = false;
p->horizon.horiz = nullAngle;
p->horizon.ZzHORIZON = nullAngle;
p->moto_do_bump = 0;
p->MotoSpeed = 0;
p->TiltStatus = 0;
Expand Down Expand Up @@ -1718,7 +1718,7 @@ static void onMotorcycle(int snum, ESyncBits &actions)
}
if (horiz != FRACUNIT)
{
p->horizon.addadjustment(deltaangle(p->horizon.horiz, maphoriz(-horiz)));
p->horizon.addadjustment(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.horiz, maphoriz(-horiz)));
p->horizon.addadjustment(deltaangle(p->horizon.ZzHORIZON, maphoriz(-horiz)));
}

if (p->MotoSpeed > 0 && p->on_ground == 1 && (p->vehTurnLeft || p->vehTurnRight))
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/prediction.cpp
Expand Up @@ -54,7 +54,7 @@ void resetmys()
mypos = omypos = ps[myconnectindex].GetActor()->getPosWithOffsetZ();
myxvel = myyvel = myzvel = 0;
myang = ps[myconnectindex].angle.ang;
myhoriz = omyhoriz = ps[myconnectindex].horizon.horiz;
myhoriz = omyhoriz = ps[myconnectindex].horizon.ZzHORIZON;
myhorizoff = omyhorizoff = ps[myconnectindex].horizon.horizoff;
mycursectnum = sectindex(ps[myconnectindex].cursector);
myjumpingcounter = ps[myconnectindex].jumping_counter;
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->horizon.ohoriz = p->horizon.horiz = DAngle::fromDeg(-17.354);
p->horizon.ohoriz = p->horizon.ZzHORIZON = DAngle::fromDeg(-17.354);
p->horizon.ohorizoff = p->horizon.horizoff = nullAngle;
p->bobcounter = 0;
p->on_ground = 0;
Expand Down
6 changes: 3 additions & 3 deletions source/games/exhumed/src/gun.cpp
Expand Up @@ -729,7 +729,7 @@ void MoveWeapons(int nPlayer)
// loc_27266:
case kWeaponSword:
{
nHeight += PlayerList[nLocalPlayer].horizon.horiz.Tan() * 32.;
nHeight += PlayerList[nLocalPlayer].horizon.ZzHORIZON.Tan() * 32.;

thePos.Z += nHeight;

Expand Down Expand Up @@ -834,7 +834,7 @@ void MoveWeapons(int nPlayer)
}
case kWeaponPistol:
{
double h = PlayerList[nLocalPlayer].horizon.horiz.Tan() * 2.;
double h = PlayerList[nLocalPlayer].horizon.ZzHORIZON.Tan() * 2.;
nHeight += h;

DExhumedActor* target = nullptr;
Expand All @@ -858,7 +858,7 @@ void MoveWeapons(int nPlayer)

case kWeaponGrenade:
{
ThrowGrenade(nPlayer, nHeight - 10, PlayerList[nLocalPlayer].horizon.horiz.Tan());
ThrowGrenade(nPlayer, nHeight - 10, PlayerList[nLocalPlayer].horizon.ZzHORIZON.Tan());
break;
}
case kWeaponStaff:
Expand Down
18 changes: 9 additions & 9 deletions source/games/exhumed/src/player.cpp
Expand Up @@ -407,7 +407,7 @@ void RestartPlayer(int nPlayer)

plr->nThrust.Zero();

plr->nDestVertPan = plr->horizon.ohoriz = plr->horizon.horiz = nullAngle;
plr->nDestVertPan = plr->horizon.ohoriz = plr->horizon.ZzHORIZON = nullAngle;
plr->nBreathTimer = 90;

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

StopFiringWeapon(nPlayer);

PlayerList[nPlayer].horizon.ohoriz = PlayerList[nPlayer].horizon.horiz = nullAngle;
PlayerList[nPlayer].horizon.ohoriz = PlayerList[nPlayer].horizon.ZzHORIZON = nullAngle;
pActor->oviewzoffset = pActor->viewzoffset = -55;
PlayerList[nPlayer].nInvisible = 0;
dVertPan[nPlayer] = 15;
Expand Down Expand Up @@ -1114,7 +1114,7 @@ void AIPlayer::Tick(RunListEvent* ev)
zVelB = -zVelB;
}

if (zVelB > 2 && !PlayerList[nPlayer].horizon.horiz.Sgn() && cl_slopetilting) {
if (zVelB > 2 && !PlayerList[nPlayer].horizon.ZzHORIZON.Sgn() && cl_slopetilting) {
PlayerList[nPlayer].nDestVertPan = nullAngle;
}
}
Expand Down Expand Up @@ -2480,12 +2480,12 @@ void AIPlayer::Tick(RunListEvent* ev)

if (actions & (SB_AIM_UP | SB_AIM_DOWN) || sPlayerInput[nPlayer].pan)
{
pPlayer->nDestVertPan = pPlayer->horizon.horiz;
pPlayer->nDestVertPan = pPlayer->horizon.ZzHORIZON;
pPlayer->bPlayerPan = pPlayer->bLockPan = true;
}
else if (actions & (SB_LOOK_UP | SB_LOOK_DOWN | SB_CENTERVIEW))
{
pPlayer->nDestVertPan = pPlayer->horizon.horiz;
pPlayer->nDestVertPan = pPlayer->horizon.ZzHORIZON;
pPlayer->bPlayerPan = pPlayer->bLockPan = false;
}

Expand All @@ -2496,7 +2496,7 @@ void AIPlayer::Tick(RunListEvent* ev)

if (cl_slopetilting && !pPlayer->bPlayerPan && !pPlayer->bLockPan)
{
if (double nVertPan = deltaangle(pPlayer->horizon.horiz, pPlayer->nDestVertPan).Tan() * 32.)
if (double nVertPan = deltaangle(pPlayer->horizon.ZzHORIZON, pPlayer->nDestVertPan).Tan() * 32.)
{
pPlayer->horizon.addadjustment(maphoriz(abs(nVertPan) >= 4 ? clamp(nVertPan, -4., 4.) : nVertPan * 2.));
}
Expand Down Expand Up @@ -2616,7 +2616,7 @@ void AIPlayer::Tick(RunListEvent* ev)
}
else
{
if (PlayerList[nPlayer].horizon.horiz.Sgn() > 0)
if (PlayerList[nPlayer].horizon.ZzHORIZON.Sgn() > 0)
{
PlayerList[nPlayer].horizon.settarget(nullAngle);
pPlayerActor->viewzoffset -= dVertPan[nPlayer];
Expand All @@ -2625,11 +2625,11 @@ void AIPlayer::Tick(RunListEvent* ev)
{
PlayerList[nPlayer].horizon.addadjustment(maphoriz(-dVertPan[nPlayer]));

if (PlayerList[nPlayer].horizon.horiz.Degrees() <= 38)
if (PlayerList[nPlayer].horizon.ZzHORIZON.Degrees() <= 38)
{
PlayerList[nPlayer].horizon.settarget(DAngle::fromDeg(-37.72));
}
else if (PlayerList[nPlayer].horizon.horiz.Sgn() >= 0)
else if (PlayerList[nPlayer].horizon.ZzHORIZON.Sgn() >= 0)
{
if (!(pPlayerActor->sector()->Flag & kSectUnderwater))
{
Expand Down
2 changes: 1 addition & 1 deletion source/games/sw/src/jsector.cpp
Expand Up @@ -612,7 +612,7 @@ void JS_DrawCameras(PLAYER* pp, const DVector3& campos, double smoothratio)

if (TEST_BOOL11(camactor) && numplayers > 1)
{
drawroomstotile(cp->actor->getPosWithOffsetZ(), cp->angle.ang, cp->horizon.horiz, cp->cursector, mirror[cnt].campic, smoothratio);
drawroomstotile(cp->actor->getPosWithOffsetZ(), cp->angle.ang, cp->horizon.ZzHORIZON, cp->cursector, mirror[cnt].campic, smoothratio);
}
else
{
Expand Down

0 comments on commit 81bb213

Please sign in to comment.