From 15f1d8985572b1c32f626a67dda68a547e329d06 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Fri, 25 Nov 2022 18:31:59 +1100 Subject: [PATCH] - Wrap access to current pitch. --- source/core/gameinput.cpp | 18 ++++----- source/core/gameinput.h | 26 +++++++------ source/games/blood/src/player.cpp | 6 +-- source/games/duke/src/actors_d.cpp | 2 +- source/games/duke/src/gameexec.cpp | 6 +-- source/games/duke/src/input.cpp | 2 +- source/games/duke/src/player.cpp | 4 +- source/games/duke/src/player_r.cpp | 8 ++-- source/games/duke/src/prediction.cpp | 2 +- source/games/duke/src/premap.cpp | 2 +- source/games/exhumed/src/gun.cpp | 6 +-- source/games/exhumed/src/player.cpp | 18 ++++----- source/games/sw/src/jsector.cpp | 2 +- source/games/sw/src/jweapon.cpp | 6 +-- source/games/sw/src/player.cpp | 8 ++-- source/games/sw/src/weapon.cpp | 58 ++++++++++++++-------------- 16 files changed, 89 insertions(+), 85 deletions(-) diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index 6d61886aa..807be8c9b 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -181,33 +181,33 @@ void PlayerAngles::applyPitch(float const horz, ESyncBits* actions, double const // Process mouse input. if (horz) { - ZzHORIZON += DAngle::fromDeg(horz); + ZzHORIZON() += DAngle::fromDeg(horz); *actions &= ~SB_CENTERVIEW; } // Process keyboard input. if (auto aiming = !!(*actions & SB_AIM_DOWN) - !!(*actions & SB_AIM_UP)) { - ZzHORIZON += 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)) { - ZzHORIZON += 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))) { - const auto pitch = abs(ZzHORIZON); + const auto pitch = abs(ZzHORIZON()); const auto scale = pitch > PITCH_CNTRSINEOFFSET ? (pitch - PITCH_CNTRSINEOFFSET).Cos() : 1.; - scaletozero(ZzHORIZON, PITCH_CENTERSPEED * scale, scaleAdjust); - if (!ZzHORIZON.Sgn()) *actions &= ~SB_CENTERVIEW; + scaletozero(ZzHORIZON(), PITCH_CENTERSPEED * scale, scaleAdjust); + if (!ZzHORIZON().Sgn()) *actions &= ~SB_CENTERVIEW; } // clamp before we finish, even if it's clamped in the drawer. - ZzHORIZON = ClampViewPitch(ZzHORIZON); + ZzHORIZON() = ClampViewPitch(ZzHORIZON()); } else { @@ -340,7 +340,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngles& w, P ("spin", w.YawSpin) ("actor", w.pActor) ("inputdisabled", w.legacyDisabledYaw) - ("horiz", w.ZzHORIZON) + ("horiz", w.ZzHORIZON()) ("horizoff", w.ZzHORIZOFF) ("inputdisabled", w.legacyDisabledPitch) .EndObject(); @@ -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(); diff --git a/source/core/gameinput.h b/source/core/gameinput.h index b03f1300e..bd3be06d3 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -8,6 +8,10 @@ struct PlayerAngles { + // Temporary wrappers. + DAngle thisHoriz; + DAngle& ZzHORIZON() { return thisHoriz; } + friend FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngles& w, PlayerAngles* def); // Prototypes for applying input. @@ -33,7 +37,7 @@ struct PlayerAngles } else { - ZzHORIZON += value; + ZzHORIZON() += value; } } void setPitch(DAngle value, bool const backup = false) @@ -47,8 +51,8 @@ struct PlayerAngles } else { - ZzHORIZON = value; - if (backup) ZzOLDHORIZON = ZzHORIZON; + ZzHORIZON() = value; + if (backup) ZzOLDHORIZON = ZzHORIZON(); } } @@ -101,40 +105,40 @@ struct PlayerAngles // Legacy, to be removed. - DAngle ZzHORIZON, ZzOLDHORIZON, ZzHORIZOFF, ZzOHORIZOFF; + DAngle ZzOLDHORIZON, ZzHORIZOFF, ZzOHORIZOFF; void processLegacyHelperPitch(double const scaleAdjust) { if (targetedPitch()) { - auto delta = deltaangle(ZzHORIZON, legacyTargetPitch); + auto delta = deltaangle(ZzHORIZON(), legacyTargetPitch); if (abs(delta).Degrees() > 0.45) { - ZzHORIZON += delta * scaleAdjust; + ZzHORIZON() += delta * scaleAdjust; } else { - ZzHORIZON = legacyTargetPitch; + ZzHORIZON() = legacyTargetPitch; legacyTargetPitch = nullAngle; } } else if (legacyAdjustmentPitch.Sgn()) { - ZzHORIZON += legacyAdjustmentPitch * scaleAdjust; + ZzHORIZON() += legacyAdjustmentPitch * scaleAdjust; } } void backupPitch() { - ZzOLDHORIZON = ZzHORIZON; + ZzOLDHORIZON = ZzHORIZON(); ZzOHORIZOFF = ZzHORIZOFF; } void restorePitch() { - ZzHORIZON = ZzOLDHORIZON; + ZzHORIZON() = ZzOLDHORIZON; ZzHORIZOFF = ZzOHORIZOFF; } DAngle horizOLDSUM() { return ZzOLDHORIZON + ZzOHORIZOFF; } - DAngle horizSUM() { return ZzHORIZON + ZzHORIZOFF; } + DAngle horizSUM() { return ZzHORIZON() + ZzHORIZOFF; } DAngle horizLERPSUM(double const interpfrac) { return interpolatedvalue(horizOLDSUM(), horizSUM(), interpfrac); } void resetAdjustmentPitch() { legacyAdjustmentPitch = nullAngle; } diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index 45a006a1e..6a09749fb 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -822,7 +822,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->Angles.ZzHORIZON = pPlayer->Angles.ZzHORIZOFF = nullAngle; + pPlayer->Angles.ZzHORIZON() = pPlayer->Angles.ZzHORIZOFF = nullAngle; pPlayer->slope = 0; pPlayer->fragger = nullptr; pPlayer->underwaterTime = 1200; @@ -1559,7 +1559,7 @@ void ProcessInput(PLAYER* pPlayer) } pPlayer->deathTime += 4; if (!bSeqStat) - pPlayer->Angles.addPitch(deltaangle(pPlayer->Angles.ZzHORIZON, gi->playerPitchMax() * (1. - BobVal(min((pPlayer->deathTime << 3) + 512, 1536))) * 0.5)); + pPlayer->Angles.addPitch(deltaangle(pPlayer->Angles.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) @@ -1734,7 +1734,7 @@ void ProcessInput(PLAYER* pPlayer) pPlayer->Angles.unlockYaw(); pPlayer->Angles.unlockPitch(); - pPlayer->slope = pPlayer->Angles.ZzHORIZON.Tan(); + pPlayer->slope = pPlayer->Angles.ZzHORIZON().Tan(); if (pInput->actions & SB_INVPREV) { pInput->actions &= ~SB_INVPREV; diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 40fc165ee..d76b8b23d 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -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].Angles.ZzHORIZON.Tan() * 2048.)) * zinttoworld; + actor->spr.pos.Z = ps[p].GetActor()->getOffsetZ() + 8 + ps[p].pyoff - (actor->temp_data[2] + (ps[p].Angles.ZzHORIZON().Tan() * 2048.)) * zinttoworld; if (actor->temp_data[2] > 512) actor->temp_data[2] -= 128; diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index f012acbfd..d7fb83e08 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -346,7 +346,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, } ps[iPlayer].Angles.setPitch(maphoriz(-lValue)); } - else SetGameVarID(lVar2, int(ps[iPlayer].Angles.ZzHORIZON.Tan() * -128.), sActor, sPlayer); + else SetGameVarID(lVar2, int(ps[iPlayer].Angles.ZzHORIZON().Tan() * -128.), sActor, sPlayer); break; case PLAYER_OHORIZ: @@ -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].Angles.ZzHORIZON * (DAngle::fromDeg(9.) / GetMaxPitch())).Degrees())) : 0, sActor, sPlayer); + else SetGameVarID(lVar2, ps[iPlayer].sync.actions & SB_CENTERVIEW ? int(abs((ps[iPlayer].Angles.ZzHORIZON() * (DAngle::fromDeg(9.) / GetMaxPitch())).Degrees())) : 0, sActor, sPlayer); break; default: @@ -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; diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index b79b140bf..13d41d821 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -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->Angles.ZzHORIZON.Degrees()) > 2.2370)) + if (p->newOwner != nullptr || (p->sync.actions & SB_CENTERVIEW && abs(p->Angles.ZzHORIZON().Degrees()) > 2.2370)) { loc.horz = input.horz = 0; } diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 5578774c7..5c26bdf7d 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -378,7 +378,7 @@ void dokneeattack(int snum, const std::initializer_list & respawnlist) { p->oknee_incs = p->knee_incs; p->knee_incs++; - p->Angles.addPitch(deltaangle(p->Angles.ZzHORIZON, (p->GetActor()->getPosWithOffsetZ() - p->actorsqu->spr.pos).Pitch() * 1.1875)); + p->Angles.addPitch(deltaangle(p->Angles.ZzHORIZON(), (p->GetActor()->getPosWithOffsetZ() - p->actorsqu->spr.pos).Pitch() * 1.1875)); p->sync.actions |= SB_CENTERVIEW; if (p->knee_incs > 15) { @@ -622,7 +622,7 @@ void playerisdead(int snum, int psectlotag, double floorz, double ceilingz) backupplayer(p); - p->Angles.ZzHORIZOFF = p->Angles.ZzHORIZON = nullAngle; + p->Angles.ZzHORIZOFF = p->Angles.ZzHORIZON() = nullAngle; updatesector(p->GetActor()->getPosWithOffsetZ(), &p->cursector); diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 2e2719b7d..ba6466620 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -1472,7 +1472,7 @@ void checkweapons_r(player_struct* p) } p->OnMotorcycle = 0; p->gotweapon[MOTORCYCLE_WEAPON] = false; - p->Angles.ZzHORIZON = nullAngle; + p->Angles.ZzHORIZON() = nullAngle; p->moto_do_bump = 0; p->MotoSpeed = 0; p->TiltStatus = 0; @@ -1491,7 +1491,7 @@ void checkweapons_r(player_struct* p) } p->OnBoat = 0; p->gotweapon[BOAT_WEAPON] = false; - p->Angles.ZzHORIZON = nullAngle; + p->Angles.ZzHORIZON() = nullAngle; p->moto_do_bump = 0; p->MotoSpeed = 0; p->TiltStatus = 0; @@ -1718,7 +1718,7 @@ static void onMotorcycle(int snum, ESyncBits &actions) } if (horiz != FRACUNIT) { - p->Angles.addPitch(deltaangle(p->Angles.ZzHORIZON, maphoriz(-horiz))); + p->Angles.addPitch(deltaangle(p->Angles.ZzHORIZON(), maphoriz(-horiz))); } const DAngle adjust = mapangle(-510); @@ -1986,7 +1986,7 @@ static void onBoat(int snum, ESyncBits &actions) } if (horiz != FRACUNIT) { - p->Angles.addPitch(deltaangle(p->Angles.ZzHORIZON, maphoriz(-horiz))); + p->Angles.addPitch(deltaangle(p->Angles.ZzHORIZON(), maphoriz(-horiz))); } if (p->MotoSpeed > 0 && p->on_ground == 1 && (p->vehTurnLeft || p->vehTurnRight)) diff --git a/source/games/duke/src/prediction.cpp b/source/games/duke/src/prediction.cpp index e429cadf0..500bb7488 100644 --- a/source/games/duke/src/prediction.cpp +++ b/source/games/duke/src/prediction.cpp @@ -54,7 +54,7 @@ void resetmys() mypos = omypos = ps[myconnectindex].GetActor()->getPosWithOffsetZ(); myxvel = myyvel = myzvel = 0; myang = ps[myconnectindex].Angles.ZzANGLE; - myhoriz = omyhoriz = ps[myconnectindex].Angles.ZzHORIZON; + myhoriz = omyhoriz = ps[myconnectindex].Angles.ZzHORIZON(); myhorizoff = omyhorizoff = ps[myconnectindex].Angles.ZzHORIZOFF; mycursectnum = sectindex(ps[myconnectindex].cursector); myjumpingcounter = ps[myconnectindex].jumping_counter; diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 5f2a34a1e..6c58a7056 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -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; diff --git a/source/games/exhumed/src/gun.cpp b/source/games/exhumed/src/gun.cpp index a77930a1f..48ec4c5a8 100644 --- a/source/games/exhumed/src/gun.cpp +++ b/source/games/exhumed/src/gun.cpp @@ -729,7 +729,7 @@ loc_flag: // loc_27266: case kWeaponSword: { - nHeight += PlayerList[nLocalPlayer].Angles.ZzHORIZON.Tan() * 32.; + nHeight += PlayerList[nLocalPlayer].Angles.ZzHORIZON().Tan() * 32.; thePos.Z += nHeight; @@ -834,7 +834,7 @@ loc_flag: } case kWeaponPistol: { - double h = PlayerList[nLocalPlayer].Angles.ZzHORIZON.Tan() * 2.; + double h = PlayerList[nLocalPlayer].Angles.ZzHORIZON().Tan() * 2.; nHeight += h; DExhumedActor* target = nullptr; @@ -858,7 +858,7 @@ loc_flag: case kWeaponGrenade: { - ThrowGrenade(nPlayer, nHeight - 10, PlayerList[nLocalPlayer].Angles.ZzHORIZON.Tan()); + ThrowGrenade(nPlayer, nHeight - 10, PlayerList[nLocalPlayer].Angles.ZzHORIZON().Tan()); break; } case kWeaponStaff: diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 965942b29..b519d4392 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -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; @@ -1118,7 +1118,7 @@ void AIPlayer::Tick(RunListEvent* ev) zVelB = -zVelB; } - if (zVelB > 2 && !PlayerList[nPlayer].Angles.ZzHORIZON.Sgn() && cl_slopetilting) { + if (zVelB > 2 && !PlayerList[nPlayer].Angles.ZzHORIZON().Sgn() && cl_slopetilting) { PlayerList[nPlayer].nDestVertPan = nullAngle; } } @@ -2484,12 +2484,12 @@ sectdone: if (actions & (SB_AIM_UP | SB_AIM_DOWN) || sPlayerInput[nPlayer].pan) { - pPlayer->nDestVertPan = pPlayer->Angles.ZzHORIZON; + pPlayer->nDestVertPan = pPlayer->Angles.ZzHORIZON(); pPlayer->bPlayerPan = pPlayer->bLockPan = true; } else if (actions & (SB_LOOK_UP | SB_LOOK_DOWN | SB_CENTERVIEW)) { - pPlayer->nDestVertPan = pPlayer->Angles.ZzHORIZON; + pPlayer->nDestVertPan = pPlayer->Angles.ZzHORIZON(); pPlayer->bPlayerPan = pPlayer->bLockPan = false; } @@ -2500,7 +2500,7 @@ sectdone: if (cl_slopetilting && !pPlayer->bPlayerPan && !pPlayer->bLockPan) { - if (double nVertPan = deltaangle(pPlayer->Angles.ZzHORIZON, pPlayer->nDestVertPan).Tan() * 32.) + if (double nVertPan = deltaangle(pPlayer->Angles.ZzHORIZON(), pPlayer->nDestVertPan).Tan() * 32.) { pPlayer->Angles.addPitch(maphoriz(abs(nVertPan) >= 4 ? clamp(nVertPan, -4., 4.) : nVertPan * 2.)); } @@ -2620,7 +2620,7 @@ sectdone: } else { - if (PlayerList[nPlayer].Angles.ZzHORIZON.Sgn() > 0) + if (PlayerList[nPlayer].Angles.ZzHORIZON().Sgn() > 0) { PlayerList[nPlayer].Angles.setPitch(nullAngle); pPlayerActor->viewzoffset -= dVertPan[nPlayer]; @@ -2629,11 +2629,11 @@ sectdone: { PlayerList[nPlayer].Angles.addPitch(maphoriz(-dVertPan[nPlayer])); - if (PlayerList[nPlayer].Angles.ZzHORIZON.Degrees() <= 38) + if (PlayerList[nPlayer].Angles.ZzHORIZON().Degrees() <= 38) { PlayerList[nPlayer].Angles.setPitch(DAngle::fromDeg(-37.72)); } - else if (PlayerList[nPlayer].Angles.ZzHORIZON.Sgn() >= 0) + else if (PlayerList[nPlayer].Angles.ZzHORIZON().Sgn() >= 0) { if (!(pPlayerActor->sector()->Flag & kSectUnderwater)) { diff --git a/source/games/sw/src/jsector.cpp b/source/games/sw/src/jsector.cpp index 419349007..3e27920b4 100644 --- a/source/games/sw/src/jsector.cpp +++ b/source/games/sw/src/jsector.cpp @@ -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->Angles.ZzANGLE, cp->Angles.ZzHORIZON, cp->cursector, mirror[cnt].campic, smoothratio); + drawroomstotile(cp->actor->getPosWithOffsetZ(), cp->Angles.ZzANGLE, cp->Angles.ZzHORIZON(), cp->cursector, mirror[cnt].campic, smoothratio); } else { diff --git a/source/games/sw/src/jweapon.cpp b/source/games/sw/src/jweapon.cpp index d99cc642b..622184b1f 100644 --- a/source/games/sw/src/jweapon.cpp +++ b/source/games/sw/src/jweapon.cpp @@ -1285,7 +1285,7 @@ int PlayerInitChemBomb(PLAYER* pp) if (pp->Flags & (PF_DIVING) || SpriteInUnderwaterArea(actorNew)) actorNew->user.Flags |= (SPR_UNDERWATER); - setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON, HORIZ_MULTF); + setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON(), HORIZ_MULTF); double oclipdist = plActor->clipdist; plActor->clipdist = 0; @@ -1655,7 +1655,7 @@ int PlayerInitCaltrops(PLAYER* pp) if (pp->Flags & (PF_DIVING) || SpriteInUnderwaterArea(actorNew)) actorNew->user.Flags |= (SPR_UNDERWATER); - setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON, HORIZ_MULTF); + setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON(), HORIZ_MULTF); double oclipdist = plActor->clipdist; plActor->clipdist = 0; @@ -2198,7 +2198,7 @@ int SpawnShell(DSWActor* actor, int ShellNum) if (actor->user.PlayerP) { - setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, actor->user.PlayerP->Angles.ZzHORIZON, HORIZ_MULTF * (1. / 3.)); + setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, actor->user.PlayerP->Angles.ZzHORIZON(), HORIZ_MULTF * (1. / 3.)); } switch (actorNew->user.ID) diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 26e91406f..b3e60db62 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -5876,7 +5876,7 @@ void DoPlayerBeginDie(PLAYER* pp) static inline void DoPlayerDeathHoriz(PLAYER* pp, const DAngle target, const double speed) { - auto targetdelta = deltaangle(pp->Angles.ZzHORIZON, target); + auto targetdelta = deltaangle(pp->Angles.ZzHORIZON(), target); if (abs(targetdelta.Degrees()) > 1) { @@ -6023,7 +6023,7 @@ void DoPlayerDeathCheckKeys(PLAYER* pp) pp->input.actions |= SB_CENTERVIEW; plActor->spr.scale = DVector2(PLAYER_NINJA_XREPEAT, PLAYER_NINJA_YREPEAT); - pp->Angles.ZzHORIZON = nullAngle; + pp->Angles.ZzHORIZON() = nullAngle; plActor->user.ID = NINJA_RUN_R0; PlayerDeathReset(pp); @@ -7042,13 +7042,13 @@ void InitAllPlayers(void) extern bool NewGame; //int fz,cz; - pfirst->Angles.ZzHORIZON = nullAngle; + pfirst->Angles.ZzHORIZON() = nullAngle; // Initialize all [MAX_SW_PLAYERS] arrays here! 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; diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 34b6636d8..83f7d8f6a 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -11534,7 +11534,7 @@ int DoRing(DSWActor* actor) // put it out there actor->spr.pos += actor->spr.Angles.Yaw.ToVector() * actor->user.Dist; - if (pp) actor->spr.pos.Z -= actor->user.Dist * pp->Angles.ZzHORIZON.Tan() * 2.; // horizon math sucks... + if (pp) actor->spr.pos.Z -= actor->user.Dist * pp->Angles.ZzHORIZON().Tan() * 2.; // horizon math sucks... SetActor(actor, actor->spr.pos); @@ -11612,7 +11612,7 @@ void InitSpellRing(PLAYER* pp) // put it out there actorNew->spr.pos += actorNew->spr.Angles.Yaw.ToVector() * actorNew->user.Dist; - actorNew->spr.pos.Z += pp->actor->getOffsetZ() + 20 - (actorNew->user.Dist * pp->Angles.ZzHORIZON.Tan() * 2.); // horizon math sucks... + actorNew->spr.pos.Z += pp->actor->getOffsetZ() + 20 - (actorNew->user.Dist * pp->Angles.ZzHORIZON().Tan() * 2.); // horizon math sucks... actorNew->spr.Angles.Yaw += DAngle90; @@ -11984,7 +11984,7 @@ void InitSpellNapalm(PLAYER* pp) actor->spr.shade = -40; actor->spr.scale = DVector2(0.5, 0.5); actor->clipdist = 0; - setFreeAimVelocity(actor->vel.X, actor->vel.Z, pp->Angles.ZzHORIZON, HORIZ_MULTF); + setFreeAimVelocity(actor->vel.X, actor->vel.Z, pp->Angles.ZzHORIZON(), HORIZ_MULTF); actor->spr.cstat |= (CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_YCENTER); actor->spr.cstat &= ~(CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); actor->user.Flags2 |= (SPR2_BLUR_TAPER_FAST); @@ -12114,7 +12114,7 @@ int InitSpellMirv(PLAYER* pp) actorNew->spr.shade = -40; actorNew->spr.scale = DVector2(1.125, 1.125); actorNew->clipdist = 2; - setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON, HORIZ_MULTF); + setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON(), HORIZ_MULTF); actorNew->spr.cstat |= (CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_YCENTER); actorNew->spr.cstat &= ~(CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); @@ -12249,7 +12249,7 @@ int InitSwordAttack(PLAYER* pp) double dax = 1024., daz = 0; DAngle daang = pp->Angles.ZzANGLE; - setFreeAimVelocity(dax, daz, pp->Angles.ZzHORIZON, 1000. - (RandomRangeF(24000 / 256.) - 12000 / 256.)); + setFreeAimVelocity(dax, daz, pp->Angles.ZzHORIZON(), 1000. - (RandomRangeF(24000 / 256.) - 12000 / 256.)); FAFhitscan(pp->actor->getPosWithOffsetZ(), pp->cursector, DVector3(pp->Angles.ZzANGLE.ToVector() * dax, daz), hit, CLIPMASK_MISSILE); if (hit.hitSector == nullptr) @@ -12427,7 +12427,7 @@ int InitFistAttack(PLAYER* pp) HitInfo hit{}; double dax = 1024., daz = 0; auto daang = pp->Angles.ZzANGLE; - setFreeAimVelocity(dax, daz, pp->Angles.ZzHORIZON, 1000. - (RandomRangeF(24000 / 256.) - 12000 / 256.)); + setFreeAimVelocity(dax, daz, pp->Angles.ZzHORIZON(), 1000. - (RandomRangeF(24000 / 256.) - 12000 / 256.)); FAFhitscan(pp->actor->getPosWithOffsetZ(), pp->cursector, DVector3(pp->Angles.ZzANGLE.ToVector() * dax, daz), hit, CLIPMASK_MISSILE); if (hit.hitSector == nullptr) @@ -12988,7 +12988,7 @@ int InitStar(PLAYER* pp) actorNew->clipdist = 2; // zvel was overflowing with this calculation - had to move to a local long var double zvel = 0; - setFreeAimVelocity(actorNew->vel.X, zvel, pp->Angles.ZzHORIZON, (HORIZ_MULT + STAR_HORIZ_ADJ) * 0.5); + setFreeAimVelocity(actorNew->vel.X, zvel, pp->Angles.ZzHORIZON(), (HORIZ_MULT + STAR_HORIZ_ADJ) * 0.5); actorNew->user.ceiling_dist = (1); actorNew->user.floor_dist = (1); @@ -13088,7 +13088,7 @@ void InitHeartAttack(PLAYER* pp) actorNew->spr.shade = -10; actorNew->spr.scale = DVector2(0.8125, 0.8125); actorNew->clipdist = 0; - setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON, HORIZ_MULTF); + setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON(), HORIZ_MULTF); actorNew->spr.cstat &= ~(CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); actorNew->user.Flags2 |= (SPR2_DONT_TARGET_OWNER); actorNew->spr.cstat |= (CSTAT_SPRITE_INVISIBLE); @@ -13230,7 +13230,7 @@ int InitShotgun(PLAYER* pp) DAngle daang = DAngle22_5 * 0.5; if (WeaponAutoAimHitscan(pp->actor, &daz, &daang, false) == nullptr) { - setFreeAimVelocity(dax, daz, pp->Angles.ZzHORIZON, 1000.); + setFreeAimVelocity(dax, daz, pp->Angles.ZzHORIZON(), 1000.); daang = pp->Angles.ZzANGLE; } @@ -13392,7 +13392,7 @@ int InitLaser(PLAYER* pp) actorNew->clipdist = 4; // the slower the missile travels the less of a zvel it needs - setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON, 16.); + setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON(), 16.); actorNew->user.WeaponNum = actor->user.WeaponNum; actorNew->user.Radius = 200; @@ -13487,7 +13487,7 @@ int InitRail(PLAYER* pp) SetOwner(pp->actor, actorNew); actorNew->spr.scale = DVector2(0.8125, 0.8125); actorNew->spr.shade = -15; - setFreeAimVelocity(actorNew->vel.X, zvel, pp->Angles.ZzHORIZON, (HORIZ_MULT + 17) * 0.5); + setFreeAimVelocity(actorNew->vel.X, zvel, pp->Angles.ZzHORIZON(), (HORIZ_MULT + 17) * 0.5); actorNew->user.RotNum = 5; NewStateGroup(actorNew, &sg_Rail[0]); @@ -13651,7 +13651,7 @@ int InitRocket(PLAYER* pp) SetOwner(pp->actor, actorNew); actorNew->spr.scale = DVector2(1.40626, 1.40625); actorNew->spr.shade = -15; - setFreeAimVelocity(actorNew->vel.X, zvel, pp->Angles.ZzHORIZON, (HORIZ_MULT + 35) * 0.5); + setFreeAimVelocity(actorNew->vel.X, zvel, pp->Angles.ZzHORIZON(), (HORIZ_MULT + 35) * 0.5); actorNew->clipdist = 4; @@ -13758,7 +13758,7 @@ int InitBunnyRocket(PLAYER* pp) SetOwner(pp->actor, actorNew); actorNew->spr.scale = DVector2(1, 1); actorNew->spr.shade = -15; - setFreeAimVelocity(actorNew->vel.X, zvel, pp->Angles.ZzHORIZON, (HORIZ_MULT + 35) * 0.5); + setFreeAimVelocity(actorNew->vel.X, zvel, pp->Angles.ZzHORIZON(), (HORIZ_MULT + 35) * 0.5); actorNew->clipdist = 4; @@ -13860,7 +13860,7 @@ int InitNuke(PLAYER* pp) SetOwner(pp->actor, actorNew); actorNew->spr.scale = DVector2(2, 2); actorNew->spr.shade = -15; - setFreeAimVelocity(actorNew->vel.X, zvel, pp->Angles.ZzHORIZON, (HORIZ_MULT + 36) * 0.5); + setFreeAimVelocity(actorNew->vel.X, zvel, pp->Angles.ZzHORIZON(), (HORIZ_MULT + 36) * 0.5); actorNew->clipdist = 4; // Set to red palette @@ -14016,7 +14016,7 @@ int InitMicro(PLAYER* pp) return 0; double vel = 75., zvel = 0; - setFreeAimVelocity(vel, zvel, pp->Angles.ZzHORIZON, HORIZ_MULTF); + setFreeAimVelocity(vel, zvel, pp->Angles.ZzHORIZON(), HORIZ_MULTF); for (i = 0; i < MAX_MICRO; i++) { @@ -15221,7 +15221,7 @@ int InitTracerUzi(PLAYER* pp) static const short lat_dist[] = {800,-800}; - double nz = 8 + (pp->Angles.ZzHORIZON.Tan() * 36.); + double nz = 8 + (pp->Angles.ZzHORIZON().Tan() * 36.); // Spawn a shot // Inserting and setting up variables @@ -15260,7 +15260,7 @@ int InitTracerUzi(PLAYER* pp) return 0; } - setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON, actorNew->vel.X); + setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON(), actorNew->vel.X); plActor->clipdist = oclipdist; @@ -15525,7 +15525,7 @@ int InitUzi(PLAYER* pp) else { daang = pp->Angles.ZzANGLE + mapangle(RandomRange(24) - 12); - setFreeAimVelocity(dax, daz, pp->Angles.ZzHORIZON, 1000. - (RandomRangeF(24000/256.) - 12000/256.)); + setFreeAimVelocity(dax, daz, pp->Angles.ZzHORIZON(), 1000. - (RandomRangeF(24000/256.) - 12000/256.)); } DVector3 vect(daang.ToVector() * dax, daz); @@ -15697,7 +15697,7 @@ int InitTankShell(DSWActor* actor, PLAYER* pp) actorNew->spr.cstat |= (CSTAT_SPRITE_YCENTER); actorNew->spr.cstat |= (CSTAT_SPRITE_INVISIBLE); - setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON, actorNew->vel.X); + setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON(), actorNew->vel.X); WeaponAutoAim(actor, actorNew, DAngle22_5 / 2, false); // a bit of randomness @@ -15765,7 +15765,7 @@ int InitTurretMicro(DSWActor* actor, PLAYER* pp) SetOwner(plActor, actorNew); actorNew->spr.scale = DVector2(0.375, 0.375); actorNew->spr.shade = -15; - setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON, HORIZ_MULTF - RandomRangeF(8) + 5); + setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON(), HORIZ_MULTF - RandomRangeF(8) + 5); actorNew->clipdist = 4; @@ -15834,7 +15834,7 @@ int InitTurretRocket(DSWActor* actor, PLAYER* pp) actorNew->user.Flags2 |= (SPR2_SO_MISSILE); actorNew->spr.cstat |= (CSTAT_SPRITE_YCENTER); - setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON, actorNew->vel.X); + setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON(), actorNew->vel.X); WeaponAutoAim(actor, actorNew, DAngle22_5 / 2, false); // a bit of randomness @@ -15873,7 +15873,7 @@ int InitTurretFireball(DSWActor* actor, PLAYER* pp) actorNew->user.Flags2 |= (SPR2_SO_MISSILE); actorNew->spr.cstat |= (CSTAT_SPRITE_YCENTER); - setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON, actorNew->vel.X); + setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON(), actorNew->vel.X); WeaponAutoAim(actor, actorNew, DAngle22_5 / 2, false); // a bit of randomness @@ -15910,7 +15910,7 @@ int InitTurretRail(DSWActor* actor, PLAYER* pp) SetOwner(pp->actor, actorNew); actorNew->spr.scale = DVector2(0.8125, 0.8125); actorNew->spr.shade = -15; - setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON, HORIZ_MULTF); + setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON(), HORIZ_MULTF); actorNew->user.RotNum = 5; NewStateGroup(actorNew, &sg_Rail[0]); @@ -15957,7 +15957,7 @@ int InitTurretLaser(DSWActor* actor, PLAYER* pp) actorNew->spr.shade = -15; // the slower the missile travels the less of a zvel it needs - setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON, 16.); + setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON(), 16.); actorNew->user.Radius = 200; actorNew->user.ceiling_dist = (1); @@ -15996,7 +15996,7 @@ int InitSobjMachineGun(DSWActor* actor, PLAYER* pp) double daz = npos.Z; if (RANDOM_P2(1024) < 200) - InitTracerTurret(actor, pp->actor, pp->Angles.ZzHORIZON); + InitTracerTurret(actor, pp->actor, pp->Angles.ZzHORIZON()); DAngle daang = DAngle22_5 / 2; if (WeaponAutoAimHitscan(actor, &daz, &daang, false) != nullptr) @@ -16005,7 +16005,7 @@ int InitSobjMachineGun(DSWActor* actor, PLAYER* pp) } else { - setFreeAimVelocity(dax, daz, DAngle::fromDeg(min(pp->Angles.ZzHORIZON.Degrees(), 11.0515)), 1000 - RandomRangeF(80) + 40); + setFreeAimVelocity(dax, daz, DAngle::fromDeg(min(pp->Angles.ZzHORIZON().Degrees(), 11.0515)), 1000 - RandomRangeF(80) + 40); daang = actor->spr.Angles.Yaw; } @@ -16695,7 +16695,7 @@ int InitGrenade(PLAYER* pp) if (pp->Flags & (PF_DIVING) || SpriteInUnderwaterArea(actorNew)) actorNew->user.Flags |= (SPR_UNDERWATER); - setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON, HORIZ_MULTF); + setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON(), HORIZ_MULTF); auto oclipdist = actor->clipdist; actor->clipdist = 0; @@ -16811,7 +16811,7 @@ int InitMine(PLAYER* pp) actorNew->spr.scale = DVector2(0.5, 0.5); actorNew->spr.shade = -15; actorNew->clipdist = 8; - setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON, HORIZ_MULTF); + setFreeAimVelocity(actorNew->vel.X, actorNew->vel.Z, pp->Angles.ZzHORIZON(), HORIZ_MULTF); actorNew->user.WeaponNum = actor->user.WeaponNum; actorNew->user.Radius = 200; actorNew->user.ceiling_dist = (5); @@ -16946,7 +16946,7 @@ int InitFireball(PLAYER* pp) actorNew->user.ceiling_dist = (6); actorNew->user.floor_dist = (6); double zvel = 0.; - setFreeAimVelocity(actorNew->vel.X, zvel, pp->Angles.ZzHORIZON, 120.); + setFreeAimVelocity(actorNew->vel.X, zvel, pp->Angles.ZzHORIZON(), 120.); // at certain angles the clipping box was big enough to block the // initial positioning of the fireball.