Skip to content

Commit

Permalink
- Preserve one legacy getter that's needed extensively in Duke.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjr4077au committed Nov 26, 2022
1 parent 9bef329 commit 7c491d0
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 30 deletions.
5 changes: 4 additions & 1 deletion source/core/gameinput.h
Expand Up @@ -38,6 +38,10 @@ struct PlayerAngles
void backupViewAngles() { PrevViewAngles = ViewAngles; }

// Angle getters.
DAngle getPitchWithView()
{
return pActor->spr.Angles.Pitch + ViewAngles.Pitch;
}
DRotator lerpViewAngles(const double interpfrac)
{
return interpolatedvalue(PrevViewAngles, ViewAngles, interpfrac);
Expand Down Expand Up @@ -108,7 +112,6 @@ struct PlayerAngles


// Legacy, to be removed.
DAngle horizSUM(const double interpfrac = 1) { return ZzHORIZON() + interpolatedvalue(PrevViewAngles.Pitch, ViewAngles.Pitch, interpfrac); }
DAngle horizLERPSUM(double const interpfrac) { return interpolatedvalue(ZzOLDHORIZON() + PrevViewAngles.Pitch, ZzHORIZON() + ViewAngles.Pitch, interpfrac); }
DAngle angSUM(const double interpfrac) { return ZzANGLE() + angLERPLOOKANG(interpfrac); }
DAngle angLERPSUM(double const interpfrac) { return interpolatedvalue(ZzOLDANGLE() + PrevViewAngles.Yaw, ZzANGLE() + ViewAngles.Yaw, interpfrac); }
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/hudweapon_d.cpp
Expand Up @@ -230,7 +230,7 @@ void displayweapon_d(int snum, double interpfrac)

auto offpair = p->Angles.getWeaponOffsets(interpfrac);
auto offsets = offpair.first;
auto horiz = !SyncInput() ? p->Angles.horizSUM(interpfrac) : p->Angles.horizLERPSUM(interpfrac);
auto horiz = !SyncInput() ? p->Angles.getPitchWithView(interpfrac) : p->Angles.horizLERPSUM(interpfrac);
auto pitchoffset = -interpolatedvalue(0., 16., horiz / DAngle90);
auto yawinput = getavel(snum) * (1. / 16.);
auto angle = -offpair.second;
Expand Down
4 changes: 2 additions & 2 deletions source/games/duke/src/player.cpp
Expand Up @@ -245,7 +245,7 @@ DDukeActor* aim(DDukeActor* actor, int abase)
if (plr->curr_weapon == PISTOL_WEAPON && !isWW2GI())
{
double vel = 1024, zvel = 0;
setFreeAimVelocity(vel, zvel, plr->Angles.horizSUM(), 16.);
setFreeAimVelocity(vel, zvel, plr->Angles.getPitchWithView(), 16.);

HitInfo hit{};
hitscan(plr->GetActor()->getPosWithOffsetZ().plusZ(4), actor->sector(), DVector3(actor->spr.Angles.Yaw.ToVector() * vel, zvel), hit, CLIPMASK1);
Expand Down Expand Up @@ -343,7 +343,7 @@ DDukeActor* aim(DDukeActor* actor, int abase)
if (actor->isPlayer())
{
double checkval = (act->spr.pos.Z - actor->spr.pos.Z) * 1.25 / sdist;
double horiz = ps[actor->PlayerIndex()].Angles.horizSUM().Tan();
double horiz = ps[actor->PlayerIndex()].Angles.getPitchWithView().Tan();
check = abs(checkval - horiz) < 0.78125;
}
else check = 1;
Expand Down
26 changes: 13 additions & 13 deletions source/games/duke/src/player_d.cpp
Expand Up @@ -113,7 +113,7 @@ static void shootfireball(DDukeActor *actor, int p, DVector3 pos, DAngle ang)
}
else
{
setFreeAimVelocity(vel, zvel, ps[p].Angles.horizSUM(), 49.);
setFreeAimVelocity(vel, zvel, ps[p].Angles.getPitchWithView(), 49.);
pos += (ang + DAngle1 * 61.171875).ToVector() * (1024. / 448.);
pos.Z += 3;
}
Expand Down Expand Up @@ -175,7 +175,7 @@ static void shootflamethrowerflame(DDukeActor* actor, int p, DVector3 spos, DAng
}
else
{
setFreeAimVelocity(vel, zvel, ps[p].Angles.horizSUM(), 40.5);
setFreeAimVelocity(vel, zvel, ps[p].Angles.getPitchWithView(), 40.5);

// WTF???
DAngle myang = DAngle90 - (DAngle180 - abs(abs((spos.XY() - ps[p].GetActor()->spr.pos.XY()).Angle() - sang) - DAngle180));
Expand Down Expand Up @@ -233,7 +233,7 @@ static void shootknee(DDukeActor* actor, int p, DVector3 pos, DAngle ang)

if (p >= 0)
{
setFreeAimVelocity(vel, zvel, ps[p].Angles.horizSUM(), 16.);
setFreeAimVelocity(vel, zvel, ps[p].Angles.getPitchWithView(), 16.);
pos.Z += 6;
ang += DAngle1 * 2.64;
}
Expand Down Expand Up @@ -365,14 +365,14 @@ static void shootweapon(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int
if (aimed == nullptr)
{
// no target
setFreeAimVelocity(vel, zvel, ps[p].Angles.horizSUM(), 16.);
setFreeAimVelocity(vel, zvel, ps[p].Angles.getPitchWithView(), 16.);
}
zvel += (zRange / 2) - krandf(zRange);
}
else if (aimed == nullptr)
{
ang += DAngle22_5 / 8 - randomAngle(22.5 / 4);
setFreeAimVelocity(vel, zvel, ps[p].Angles.horizSUM(), 16.);
setFreeAimVelocity(vel, zvel, ps[p].Angles.getPitchWithView(), 16.);
zvel += 0.5 - krandf(1);
}

Expand Down Expand Up @@ -596,7 +596,7 @@ static void shootstuff(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int a
ang = (aimed->spr.pos.XY() - pos.XY()).Angle();
}
else
setFreeAimVelocity(vel, zvel, ps[p].Angles.horizSUM(), 49.);
setFreeAimVelocity(vel, zvel, ps[p].Angles.getPitchWithView(), 49.);
}
else
{
Expand Down Expand Up @@ -683,7 +683,7 @@ static void shootrpg(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int atw
ang = (aimed->spr.pos.XY() - pos.XY()).Angle();
}
else
setFreeAimVelocity(vel, zvel, ps[p].Angles.horizSUM(), 40.5);
setFreeAimVelocity(vel, zvel, ps[p].Angles.getPitchWithView(), 40.5);

if (atwith == RPG)
S_PlayActorSound(RPG_SHOOT, actor);
Expand Down Expand Up @@ -822,7 +822,7 @@ static void shootlaser(DDukeActor* actor, int p, DVector3 pos, DAngle ang)
HitInfo hit{};

if (p >= 0)
setFreeAimVelocity(vel, zvel, ps[p].Angles.horizSUM(), 16.);
setFreeAimVelocity(vel, zvel, ps[p].Angles.getPitchWithView(), 16.);
else zvel = 0;

hitscan(pos, sectp, DVector3(ang.ToVector() * vel, zvel * 64), hit, CLIPMASK1);
Expand Down Expand Up @@ -921,7 +921,7 @@ static void shootgrowspark(DDukeActor* actor, int p, DVector3 pos, DAngle ang)
else
{
ang += DAngle22_5 / 8 - randomAngle(22.5 / 4);
setFreeAimVelocity(vel, zvel, ps[p].Angles.horizSUM(), 16.);
setFreeAimVelocity(vel, zvel, ps[p].Angles.getPitchWithView(), 16.);
zvel += 0.5 - krandf(1);
}

Expand Down Expand Up @@ -1015,7 +1015,7 @@ static void shootshrinker(DDukeActor* actor, int p, const DVector3& pos, DAngle
ang = (aimed->spr.pos.XY() - pos.XY()).Angle();
}
else
setFreeAimVelocity(vel, zvel, ps[p].Angles.horizSUM(), 49.);
setFreeAimVelocity(vel, zvel, ps[p].Angles.getPitchWithView(), 49.);
}
else if (actor->spr.statnum != 3)
{
Expand Down Expand Up @@ -2010,7 +2010,7 @@ int operateTripbomb(int snum)
auto p = &ps[snum];
HitInfo hit{};
double vel = 1024, zvel = 0;
setFreeAimVelocity(vel, zvel, p->Angles.horizSUM(), 16.);
setFreeAimVelocity(vel, zvel, p->Angles.getPitchWithView(), 16.);

hitscan(p->GetActor()->getPosWithOffsetZ(), p->cursector, DVector3(p->Angles.ZzANGLE().ToVector() * vel, zvel), hit, CLIPMASK1);

Expand Down Expand Up @@ -2200,12 +2200,12 @@ static void operateweapon(int snum, ESyncBits actions)
if (p->on_ground && (actions & SB_CROUCH))
{
vel = 15/16.;
zvel = p->Angles.horizSUM().Sin() * 10.;
zvel = p->Angles.getPitchWithView().Sin() * 10.;
}
else
{
vel = 140/16.;
setFreeAimVelocity(vel, zvel, p->Angles.horizSUM(), 10.);
setFreeAimVelocity(vel, zvel, p->Angles.getPitchWithView(), 10.);
zvel -= 4;
}

Expand Down
20 changes: 10 additions & 10 deletions source/games/duke/src/player_r.cpp
Expand Up @@ -91,7 +91,7 @@ static void shootmelee(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int a

if (p >= 0)
{
setFreeAimVelocity(vel, zvel, ps[p].Angles.horizSUM(), 16.);
setFreeAimVelocity(vel, zvel, ps[p].Angles.getPitchWithView(), 16.);
pos.Z += 6;
ang += DAngle1 * 2.64;
}
Expand Down Expand Up @@ -224,7 +224,7 @@ static void shootweapon(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int
if (aimed == nullptr)
{
ang += DAngle22_5 / 8 - randomAngle(22.5 / 4);
setFreeAimVelocity(vel, zvel, ps[p].Angles.horizSUM(), 16.);
setFreeAimVelocity(vel, zvel, ps[p].Angles.getPitchWithView(), 16.);
zvel += 0.5 - krandf(1);
}
}
Expand All @@ -234,7 +234,7 @@ static void shootweapon(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int
ang += DAngle22_5 / 2 - randomAngle(22.5);
else
ang += DAngle22_5 / 8 - randomAngle(22.5 / 4);
if (aimed == nullptr) setFreeAimVelocity(vel, zvel, ps[p].Angles.horizSUM(), 16.);
if (aimed == nullptr) setFreeAimVelocity(vel, zvel, ps[p].Angles.getPitchWithView(), 16.);
zvel += 0.5 - krandf(1);
}
pos.Z -= 2;
Expand Down Expand Up @@ -511,7 +511,7 @@ static void shootstuff(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int a
}
else
{
setFreeAimVelocity(vel, zvel, ps[p].Angles.horizSUM(), 49.);
setFreeAimVelocity(vel, zvel, ps[p].Angles.getPitchWithView(), 49.);
}
}
else
Expand Down Expand Up @@ -596,7 +596,7 @@ static void shootrpg(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int atw
ang = (aimed->spr.pos.XY() - pos.XY()).Angle();
}
else
setFreeAimVelocity(vel, zvel, ps[p].Angles.horizSUM(), 40.5);
setFreeAimVelocity(vel, zvel, ps[p].Angles.getPitchWithView(), 40.5);

if (atwith == RPG)
S_PlayActorSound(RPG_SHOOT, actor);
Expand Down Expand Up @@ -746,7 +746,7 @@ static void shootwhip(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int at
ang = (aimed->spr.pos.XY() - pos.XY()).Angle();
}
else
setFreeAimVelocity(vel, zvel, ps[p].Angles.horizSUM(), 49.);
setFreeAimVelocity(vel, zvel, ps[p].Angles.getPitchWithView(), 49.);
}
else
{
Expand Down Expand Up @@ -2674,12 +2674,12 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
if (p->on_ground && (actions & SB_CROUCH))
{
vel = 15 / 16.;
zvel = p->Angles.horizSUM().Sin() * 10.;
zvel = p->Angles.getPitchWithView().Sin() * 10.;
}
else
{
vel = 140 / 16.;
setFreeAimVelocity(vel, zvel, p->Angles.horizSUM(), 10.);
setFreeAimVelocity(vel, zvel, p->Angles.getPitchWithView(), 10.);
zvel -= 4;
}

Expand Down Expand Up @@ -3082,12 +3082,12 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
if (p->on_ground && (actions & SB_CROUCH) && !p->OnMotorcycle)
{
vel = 15 / 16.;
setFreeAimVelocity(vel, zvel, p->Angles.horizSUM(), 10.);
setFreeAimVelocity(vel, zvel, p->Angles.getPitchWithView(), 10.);
}
else
{
vel = 2.;
setFreeAimVelocity(vel, zvel, p->Angles.horizSUM(), 10.);
setFreeAimVelocity(vel, zvel, p->Angles.getPitchWithView(), 10.);
zvel -= 4;
}

Expand Down
4 changes: 2 additions & 2 deletions source/games/duke/src/player_w.cpp
Expand Up @@ -333,12 +333,12 @@ void operateweapon_ww(int snum, ESyncBits actions)
if (p->on_ground && (actions & SB_CROUCH))
{
vel = 15 / 16.;
setFreeAimVelocity(vel, zvel, p->Angles.horizSUM(), 10.);
setFreeAimVelocity(vel, zvel, p->Angles.getPitchWithView(), 10.);
}
else
{
vel = 140 / 16.;
setFreeAimVelocity(vel, zvel, p->Angles.horizSUM(), 10.);
setFreeAimVelocity(vel, zvel, p->Angles.getPitchWithView(), 10.);
zvel -= 4;
}

Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/spawn.cpp
Expand Up @@ -430,7 +430,7 @@ void initshell(DDukeActor* actj, DDukeActor* act, bool isshell)
ang = ps[snum].Angles.ZzANGLE() - mapangle((krand() & 63) + 8); //Fine tune

act->temp_data[0] = krand() & 1;
act->spr.pos.Z = 3 + ps[snum].GetActor()->getOffsetZ() + ps[snum].pyoff + (ps[snum].Angles.horizSUM().Tan() * 8.) + (!isshell ? 3 : 0);
act->spr.pos.Z = 3 + ps[snum].GetActor()->getOffsetZ() + ps[snum].pyoff + (ps[snum].Angles.getPitchWithView().Tan() * 8.) + (!isshell ? 3 : 0);
act->vel.Z = -krandf(1);
}
else
Expand Down

0 comments on commit 7c491d0

Please sign in to comment.