From e4dd69f5b0bc0bf2e6e572648f1caa9d9dbac063 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Tue, 15 Nov 2022 18:41:04 +1100 Subject: [PATCH] - Duke: Wrap calls that get `player_struct::PlayerOldPosition.Z`. --- source/games/duke/src/actors.cpp | 2 +- source/games/duke/src/gameexec.cpp | 2 +- source/games/duke/src/player_d.cpp | 12 ++++++------ source/games/duke/src/player_r.cpp | 6 +++--- source/games/duke/src/player_w.cpp | 2 +- source/games/duke/src/types.h | 4 ++++ 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 1adb62fe5..a7643a164 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -4437,7 +4437,7 @@ void movefta(void) { double r1 = zrand(32); double r2 = zrand(52); - canseeme = cansee({ sx, sy, act->spr.pos.Z - r2 }, act->sector(), { px, py, ps[p].PlayerOldPosition.Z - r1 }, ps[p].cursector); + canseeme = cansee({ sx, sy, act->spr.pos.Z - r2 }, act->sector(), { px, py, ps[p].posoldZget() - r1 }, ps[p].cursector); } } else diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 47a56eea8..2ade95a01 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -389,7 +389,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, case PLAYER_OPOSZ: if (bSet) ps[iPlayer].posoldZset(lValue * zmaptoworld); - else SetGameVarID(lVar2, int(ps[iPlayer].PlayerOldPosition.Z * (1 / zmaptoworld)), sActor, sPlayer); + else SetGameVarID(lVar2, int(ps[iPlayer].posoldZget() * (1 / zmaptoworld)), sActor, sPlayer); break; case PLAYER_PYOFF: diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index f0b2263d3..665be39af 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -109,7 +109,7 @@ static void shootfireball(DDukeActor *actor, int p, DVector3 pos, DAngle ang) double scratch; int j = findplayer(actor, &scratch); double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length(); - zvel = ((ps[j].PlayerOldPosition.Z - pos.Z + 3) * vel) / dist; + zvel = ((ps[j].posoldZget() - pos.Z + 3) * vel) / dist; } else { @@ -165,7 +165,7 @@ static void shootflamethrowerflame(DDukeActor* actor, int p, DVector3 spos, DAng double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length(); if (dist != 0) - zvel = (((ps[j].PlayerOldPosition.Z - spos.Z) * vel) / dist); + zvel = (((ps[j].posoldZget() - spos.Z) * vel) / dist); if (badguy(actor) && (actor->spr.hitag & face_player_smart) != 0) sang = actor->spr.angle + mapangle((krand() & 31) - 16); @@ -605,7 +605,7 @@ static void shootstuff(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int a ang += DAngle22_5 / 8 - randomAngle(22.5 / 4); #if 1 double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length(); - zvel = ((ps[j].PlayerOldPosition.Z - pos.Z + 3) * vel) / dist; + zvel = ((ps[j].posoldZget() - pos.Z + 3) * vel) / dist; #else // this is for pitch corrected velocity auto dist = (ps[j].GetActor()->spr.pos - actor->spr.pos).Resized(vel); @@ -712,7 +712,7 @@ static void shootrpg(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int atw double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length(); - zvel = ((ps[j].PlayerOldPosition.Z - pos.Z) * vel) / dist; + zvel = ((ps[j].posoldZget() - pos.Z) * vel) / dist; if (badguy(actor) && (actor->spr.hitag & face_player_smart)) ang = actor->spr.angle + randomAngle(DAngle22_5 / 4) - DAngle22_5 / 8; @@ -2043,7 +2043,7 @@ int operateTripbomb(int snum) auto delta = hit.hitpos.XY() - p->posXY(); if (delta.LengthSquared() < (18.125 * 18.125)) { - p->posZset(p->PlayerOldPosition.Z); + p->posZset(p->posoldZget()); p->vel.Z = 0; return 1; } @@ -2585,7 +2585,7 @@ static void operateweapon(int snum, ESyncBits actions) case TRIPBOMB_WEAPON: // Claymore in NAM if (p->kickback_pic < 4) { - p->posZset(p->PlayerOldPosition.Z); + p->posZset(p->posoldZget()); p->vel.Z = 0; if (p->kickback_pic == 3) fi.shoot(pact, HANDHOLDINGLASER); diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index ddc9ec03f..3d55f9da7 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -526,7 +526,7 @@ static void shootstuff(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int a ang += DAngle22_5 / 8. - randomAngle(22.5 / 4); double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length(); - zvel = ((ps[j].PlayerOldPosition.Z - pos.Z + 3) * vel) / dist; + zvel = ((ps[j].posoldZget() - pos.Z + 3) * vel) / dist; } double oldzvel = zvel; @@ -623,7 +623,7 @@ static void shootrpg(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int atw } double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length(); - zvel = ((ps[j].PlayerOldPosition.Z - pos.Z) * vel) / dist; + zvel = ((ps[j].posoldZget() - pos.Z) * vel) / dist; if (badguy(actor) && (actor->spr.hitag & face_player_smart)) ang = actor->spr.angle + randomAngle(22.5 / 4) - DAngle22_5 / 8; @@ -758,7 +758,7 @@ static void shootwhip(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int at ang += DAngle22_5/8 - randomAngle(22.5 / 4); double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length(); - zvel = ((ps[j].PlayerOldPosition.Z - pos.Z + 3) * vel) / dist; + zvel = ((ps[j].posoldZget() - pos.Z + 3) * vel) / dist; } double oldzvel = zvel; diff --git a/source/games/duke/src/player_w.cpp b/source/games/duke/src/player_w.cpp index a1f73caf3..b4febaf13 100644 --- a/source/games/duke/src/player_w.cpp +++ b/source/games/duke/src/player_w.cpp @@ -436,7 +436,7 @@ void operateweapon_ww(int snum, ESyncBits actions) if (aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_STANDSTILL && p->kickback_pic < (aplWeaponFireDelay(p->curr_weapon, snum) + 1)) { - p->posZset(p->PlayerOldPosition.Z); + p->posZset(p->posoldZget()); p->vel.Z = 0; } if (p->kickback_pic == aplWeaponSound2Time(p->curr_weapon, snum)) diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index d6635169f..ae595b131 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -418,6 +418,10 @@ struct player_struct { PlayerOldPosition.Z = val; } + double posoldZget() + { + return PlayerOldPosition.Z; + } }; struct Cycler