From 25e6c4ecf80d606b41beecc4a5341f1ca4843ec4 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Tue, 15 Nov 2022 17:57:27 +1100 Subject: [PATCH] - Duke: Wrap calls that get `player_struct::PlayerNowPosition.Z`. --- source/games/duke/src/actors.cpp | 8 ++--- source/games/duke/src/actors_d.cpp | 8 ++--- source/games/duke/src/actors_r.cpp | 10 +++--- source/games/duke/src/animatesprites_d.cpp | 4 +-- source/games/duke/src/animatesprites_r.cpp | 4 +-- source/games/duke/src/game_misc.cpp | 2 +- source/games/duke/src/gameexec.cpp | 4 +-- source/games/duke/src/player.cpp | 6 ++-- source/games/duke/src/player_d.cpp | 36 +++++++++++----------- source/games/duke/src/player_r.cpp | 30 +++++++++--------- source/games/duke/src/sectors.cpp | 2 +- source/games/duke/src/sectors_d.cpp | 2 +- source/games/duke/src/sectors_r.cpp | 2 +- source/games/duke/src/spawn.cpp | 2 +- source/games/duke/src/types.h | 4 +++ 15 files changed, 64 insertions(+), 60 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 98ffd4526..d740e219e 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -973,9 +973,9 @@ void recon(DDukeActor *actor, int explosion, int firelaser, int attacksnd, int p if (actor->temp_data[0] == 2) { - double l = ps[p].PlayerNowPosition.Z - actor->spr.pos.Z; + double l = ps[p].posZget() - actor->spr.pos.Z; if (fabs(l) < 48) actor->temp_data[0] = 3; - else actor->spr.pos.Z += (Sgn(ps[p].PlayerNowPosition.Z - actor->spr.pos.Z) * shift); // The shift here differs between Duke and RR. + else actor->spr.pos.Z += (Sgn(ps[p].posZget() - actor->spr.pos.Z) * shift); // The shift here differs between Duke and RR. } else { @@ -3499,7 +3499,7 @@ void handle_se27(DDukeActor* actor) ud.cameraactor = actor; actor->temp_data[0] = 999; actor->spr.angle += deltaangle(actor->spr.angle, (ps[p].posXY() - actor->spr.pos.XY()).Angle()) * 0.125; - actor->spr.yint = 100 + int((actor->spr.pos.Z - ps[p].PlayerNowPosition.Z) * (256. / 257.)); + actor->spr.yint = 100 + int((actor->spr.pos.Z - ps[p].posZget()) * (256. / 257.)); } else if (actor->temp_data[0] == 999) @@ -3579,7 +3579,7 @@ void handle_se24(DDukeActor *actor, bool scroll, double mult) { if (ps[p].cursector == actor->sector() && ps[p].on_ground) { - if (abs(ps[p].PlayerNowPosition.Z - ps[p].truefz) < gs.playerheight + 9) + if (abs(ps[p].posZget() - ps[p].truefz) < gs.playerheight + 9) { ps[p].fric += vec * (1. / 8.); // keeping the original velocity. to match the animation it should be ~1/24. } diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index d53b50f3d..364a5649c 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -1363,7 +1363,7 @@ void movetransports_d(void) } else if (!(sectlotag == 1 && ps[p].on_ground == 1)) break; - if (onfloorz == 0 && abs(act->spr.pos.Z - ps[p].PlayerNowPosition.Z) < 24) + if (onfloorz == 0 && abs(act->spr.pos.Z - ps[p].posZget()) < 24) if ((ps[p].jetpack_on == 0) || (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP))) || (ps[p].jetpack_on && PlayerInput(p, SB_CROUCH))) { @@ -1387,7 +1387,7 @@ void movetransports_d(void) int k = 0; - if (onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].on_ground && ps[p].PlayerNowPosition.Z > (sectp->floorz - 16) && (PlayerInput(p, SB_CROUCH) || ps[p].vel.Z > 8)) + if (onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].on_ground && ps[p].posZget() > (sectp->floorz - 16) && (PlayerInput(p, SB_CROUCH) || ps[p].vel.Z > 8)) // if( onfloorz && sectlotag == 1 && ps[p].pos.z > (sectp->floorz-(6<<8)) ) { k = 1; @@ -1406,7 +1406,7 @@ void movetransports_d(void) } - if (onfloorz && sectlotag == ST_2_UNDERWATER && ps[p].PlayerNowPosition.Z < (sectp->ceilingz + 6)) + if (onfloorz && sectlotag == ST_2_UNDERWATER && ps[p].posZget() < (sectp->ceilingz + 6)) { k = 1; // if( act2->spr.extra <= 0) break; @@ -1723,7 +1723,7 @@ static void greenslime(DDukeActor *actor) return; } - actor->spr.pos.Z = ps[p].PlayerNowPosition.Z + 8 + ps[p].pyoff - (actor->temp_data[2] + (ps[p].horizon.horiz.Tan() * 2048.)) * zinttoworld; + actor->spr.pos.Z = ps[p].posZget() + 8 + ps[p].pyoff - (actor->temp_data[2] + (ps[p].horizon.horiz.Tan() * 2048.)) * zinttoworld; if (actor->temp_data[2] > 512) actor->temp_data[2] -= 128; diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index a7770f5bd..ae79ac081 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -1248,7 +1248,7 @@ void movetransports_r(void) } else break; - if (onfloorz == 0 && fabs(act->spr.pos.Z - ps[p].PlayerNowPosition.Z) < 24) + if (onfloorz == 0 && fabs(act->spr.pos.Z - ps[p].posZget()) < 24) if ((ps[p].jetpack_on == 0) || (ps[p].jetpack_on && PlayerInput(p, SB_JUMP)) || (ps[p].jetpack_on && PlayerInput(p, SB_CROUCH))) { @@ -1271,14 +1271,14 @@ void movetransports_r(void) if (isRRRA()) { - if (onfloorz && sectlotag == 160 && ps[p].PlayerNowPosition.Z > sectp->floorz - 48) + if (onfloorz && sectlotag == 160 && ps[p].posZget() > sectp->floorz - 48) { k = 2; ps[p].posZset(Owner->sector()->ceilingz + 7); ps[p].backupz(); } - if (onfloorz && sectlotag == 161 && ps[p].PlayerNowPosition.Z < sectp->ceilingz + 6) + if (onfloorz && sectlotag == 161 && ps[p].posZget() < sectp->ceilingz + 6) { k = 2; if (ps[p].GetActor()->spr.extra <= 0) break; @@ -1287,7 +1287,7 @@ void movetransports_r(void) } } - if ((onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].PlayerNowPosition.Z > sectp->floorz - 6) || + if ((onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].posZget() > sectp->floorz - 6) || (onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].OnMotorcycle)) { if (ps[p].OnBoat) break; @@ -1303,7 +1303,7 @@ void movetransports_r(void) ps[p].moto_underwater = 1; } - if (onfloorz && sectlotag == ST_2_UNDERWATER && ps[p].PlayerNowPosition.Z < sectp->ceilingz + 6) + if (onfloorz && sectlotag == ST_2_UNDERWATER && ps[p].posZget() < sectp->ceilingz + 6) { k = 1; if (ps[p].GetActor()->spr.extra <= 0) break; diff --git a/source/games/duke/src/animatesprites_d.cpp b/source/games/duke/src/animatesprites_d.cpp index 5ecbe7846..182d6041a 100644 --- a/source/games/duke/src/animatesprites_d.cpp +++ b/source/games/duke/src/animatesprites_d.cpp @@ -345,7 +345,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi case DEVISTATOR_WEAPON: newtspr->picnum = DEVISTATORSPRITE; break; } - if (h->GetOwner()) newtspr->pos.Z = ps[p].PlayerNowPosition.Z - 12; + if (h->GetOwner()) newtspr->pos.Z = ps[p].posZget() - 12; else newtspr->pos.Z = h->spr.pos.Z - 51; if (ps[p].curr_weapon == HANDBOMB_WEAPON) { @@ -541,7 +541,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi floorz = h->floorz; - if (h->spr.pos.Z - floorz < 8 && ps[screenpeek].PlayerNowPosition.Z < floorz) + if (h->spr.pos.Z - floorz < 8 && ps[screenpeek].posZget() < floorz) { auto shadowspr = tsprites.newTSprite(); *shadowspr = *t; diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index 19fc81ed4..1616c4234 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -397,7 +397,7 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi case TIT_WEAPON: newtspr->picnum = TITSPRITE; break; } - if (h->GetOwner()) newtspr->pos.Z = ps[p].PlayerNowPosition.Z - 12; + if (h->GetOwner()) newtspr->pos.Z = ps[p].posZget() - 12; else newtspr->pos.Z = h->spr.pos.Z - 51; if (ps[p].curr_weapon == HANDBOMB_WEAPON) { @@ -705,7 +705,7 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi else floorz = h->floorz; - if (h->spr.pos.Z - floorz < 8 && ps[screenpeek].PlayerNowPosition.Z < floorz) + if (h->spr.pos.Z - floorz < 8 && ps[screenpeek].posZget() < floorz) { auto shadowspr = tsprites.newTSprite(); *shadowspr = *t; diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index 29e538ff8..6198f9799 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -431,7 +431,7 @@ bool GameInterface::DrawAutomapPlayer(const DVector2& mxy, const DVector2& cpos, auto& pp = ps[p]; auto act = pp.GetActor(); int i = TILE_APLAYERTOP + (act->vel.X > 1 && pp.on_ground ? (PlayClock >> 4) & 3 : 0); - double j = clamp(czoom * act->spr.scale.Y + abs(pp.truefz - pp.PlayerNowPosition.Z) * REPEAT_SCALE, 0.333, 2.); + double j = clamp(czoom * act->spr.scale.Y + abs(pp.truefz - pp.posZget()) * REPEAT_SCALE, 0.333, 2.); auto const vec = OutAutomapVector(mxy - cpos, cangvect, czoom, xydim); auto const daang = -((!SyncInput() ? act->spr.angle : act->interpolatedangle(interpfrac)) - cang).Normalized360().Degrees(); diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index a78331a5c..22069a456 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -334,7 +334,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, break; case PLAYER_POSZ: - if (!bSet) SetGameVarID(lVar2, int(ps[iPlayer].PlayerNowPosition.Z * (1 / zmaptoworld)), sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, int(ps[iPlayer].posZget() * (1 / zmaptoworld)), sActor, sPlayer); break; case PLAYER_HORIZ: @@ -2408,7 +2408,7 @@ int ParseState::parse(void) j = 1; else if( (l& prunning) && vel >= 0.5 && PlayerInput(g_p, SB_RUN) ) j = 1; - else if( (l& phigher) && ps[g_p].PlayerNowPosition.Z < g_ac->spr.pos.Z - 48) + else if( (l& phigher) && ps[g_p].posZget() < g_ac->spr.pos.Z - 48) j = 1; else if( (l& pwalkingback) && vel <= -0.5 && !(PlayerInput(g_p, SB_RUN)) ) j = 1; diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 743bcf969..f24bfc8d8 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -608,7 +608,7 @@ void playerisdead(int snum, int psectlotag, double floorz, double ceilingz) { if (p->on_warping_sector == 0) { - if (abs(p->PlayerNowPosition.Z - floorz) > (gs.playerheight * 0.5)) + if (abs(p->posZget() - floorz) > (gs.playerheight * 0.5)) p->posZadd(348/ 256.); } else @@ -630,7 +630,7 @@ void playerisdead(int snum, int psectlotag, double floorz, double ceilingz) pushmove(p->PlayerNowPosition, &p->cursector, 8, 4, 20, CLIPMASK0); if (floorz > ceilingz + 16 && actor->spr.pal != 1) - p->angle.rotscrnang = DAngle::fromBuild(p->dead_flag + ((floorz + p->PlayerNowPosition.Z) * 2)); + p->angle.rotscrnang = DAngle::fromBuild(p->dead_flag + ((floorz + p->posZget()) * 2)); p->on_warping_sector = 0; @@ -774,7 +774,7 @@ void player_struct::backuppos(bool noclipping) posY() = PlayerOldPosition.Y; } - PlayerOldPosition.Z = PlayerNowPosition.Z; + PlayerOldPosition.Z = posZget(); bobpos = posXY(); opyoff = pyoff; } diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 80f155d42..e398b4891 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -384,7 +384,7 @@ static void shootweapon(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int int j = findplayer(actor, &x); pos.Z -= 4; double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length(); - zvel = ((ps[j].PlayerNowPosition.Z - pos.Z) * 16) / dist; + zvel = ((ps[j].posZget() - pos.Z) * 16) / dist; zvel += 0.5 - krandf(1); if (actor->spr.picnum != BOSS1) { @@ -933,7 +933,7 @@ static void shootgrowspark(DDukeActor* actor, int p, DVector3 pos, DAngle ang) int j = findplayer(actor, &x); pos.Z -= 4; double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length(); - zvel = ((ps[j].PlayerNowPosition.Z - pos.Z) * 16) / dist; + zvel = ((ps[j].posZget() - pos.Z) * 16) / dist; zvel += 0.5 - krandf(1); ang += DAngle22_5 / 4 - randomAngle(22.5 / 2); } @@ -1022,7 +1022,7 @@ static void shootshrinker(DDukeActor* actor, int p, const DVector3& pos, DAngle double x; int j = findplayer(actor, &x); double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length(); - zvel = ((ps[j].PlayerNowPosition.Z - pos.Z) * 32) / dist; + zvel = ((ps[j].posZget() - pos.Z) * 32) / dist; } else zvel = 0; @@ -1729,9 +1729,9 @@ static void operateJetpack(int snum, ESyncBits actions, int psectlotag, double f if (psectlotag != 2 && p->scuba_on == 1) p->scuba_on = 0; - if (p->PlayerNowPosition.Z > floorz - k) - p->posZadd(((floorz - k) - p->PlayerNowPosition.Z) * 0.5); - if (p->PlayerNowPosition.Z < pact->ceilingz + 18) + if (p->posZget() > floorz - k) + p->posZadd(((floorz - k) - p->posZget()) * 0.5); + if (p->posZget() < pact->ceilingz + 18) p->posZset(pact->ceilingz + 18); } @@ -1786,11 +1786,11 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo footprints(snum); } - if (p->PlayerNowPosition.Z < floorz - i) //falling + if (p->posZget() < floorz - i) //falling { // not jumping or crouching - if ((actions & (SB_JUMP|SB_CROUCH)) == 0 && p->on_ground && (psect->floorstat & CSTAT_SECTOR_SLOPE) && p->PlayerNowPosition.Z >= (floorz - i - 16)) + if ((actions & (SB_JUMP|SB_CROUCH)) == 0 && p->on_ground && (psect->floorstat & CSTAT_SECTOR_SLOPE) && p->posZget() >= (floorz - i - 16)) p->posZset(floorz - i); else { @@ -1804,7 +1804,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo S_PlayActorSound(DUKE_SCREAM, pact); } - if (p->PlayerNowPosition.Z + p->vel.Z >= floorz - i) // hit the ground + if (p->posZget() + p->vel.Z >= floorz - i) // hit the ground { S_StopSound(DUKE_SCREAM, pact); if (!p->insector() || p->cursector->lotag != 1) @@ -1848,7 +1848,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo { //Smooth on the ground - double k = (floorz - i - p->PlayerNowPosition.Z) * 0.5; + double k = (floorz - i - p->posZget()) * 0.5; if (abs(k) < 1) k = 0; p->posZadd(k); p->vel.Z -= 3; @@ -1856,8 +1856,8 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo } else if (p->jumping_counter == 0) { - p->posZadd(((floorz - i * 0.5) - p->PlayerNowPosition.Z) * 0.5); //Smooth on the water - if (p->on_warping_sector == 0 && p->PlayerNowPosition.Z > floorz - 16) + p->posZadd(((floorz - i * 0.5) - p->posZget()) * 0.5); //Smooth on the water + if (p->on_warping_sector == 0 && p->posZget() > floorz - 16) { p->posZset(floorz - 16); p->vel.Z *= 0.5; @@ -1912,7 +1912,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo p->posZadd(p->vel.Z ); - if (p->PlayerNowPosition.Z < ceilingz + 4) + if (p->posZget() < ceilingz + 4) { p->jumping_counter = 0; if (p->vel.Z < 0) @@ -1979,10 +1979,10 @@ static void underwater(int snum, ESyncBits actions, double floorz, double ceilin p->posZadd(p->vel.Z ); - if (p->PlayerNowPosition.Z > floorz - 15) - p->posZadd((((floorz - 15) - p->PlayerNowPosition.Z) * 0.5)); + if (p->posZget() > floorz - 15) + p->posZadd((((floorz - 15) - p->posZget()) * 0.5)); - if (p->PlayerNowPosition.Z < ceilingz + 4) + if (p->posZget() < ceilingz + 4) { p->posZset(ceilingz + 4); p->vel.Z = 0; @@ -1995,7 +1995,7 @@ static void underwater(int snum, ESyncBits actions, double floorz, double ceilin { j->spr.pos += (p->angle.ang.ToVector() + DVector2(4 - (global_random & 8), 4 - (global_random & 8))) * 16; j->spr.scale = DVector2(0.046875, 0.3125); - j->spr.pos.Z = p->PlayerNowPosition.Z + 8; + j->spr.pos.Z = p->posZget() + 8; } } } @@ -2755,7 +2755,7 @@ void processinput_d(int snum) p->truefz = getflorzofslopeptr(psectp, p->PlayerNowPosition); p->truecz = getceilzofslopeptr(psectp, p->PlayerNowPosition); - truefdist = abs(p->PlayerNowPosition.Z - p->truefz); + truefdist = abs(p->posZget() - p->truefz); if (clz.type == kHitSector && psectlotag == 1 && truefdist > gs.playerheight + 16) psectlotag = 0; diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index c2699772f..a4f079716 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -245,7 +245,7 @@ static void shootweapon(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int int j = findplayer(actor, &x); pos.Z -= 4; double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length(); - zvel = ((ps[j].PlayerNowPosition.Z - pos.Z) * 16) / dist; + zvel = ((ps[j].posZget() - pos.Z) * 16) / dist; if (actor->spr.picnum != BOSS1) { zvel += 0.5 - krandf(1); @@ -2077,15 +2077,15 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo footprints(snum); } - if (p->PlayerNowPosition.Z < floorz - i) //falling + if (p->posZget() < floorz - i) //falling { - if ((actions & (SB_JUMP|SB_CROUCH)) == 0 && p->on_ground && (psect->floorstat & CSTAT_SECTOR_SLOPE) && p->PlayerNowPosition.Z >= (floorz - i - 16)) + if ((actions & (SB_JUMP|SB_CROUCH)) == 0 && p->on_ground && (psect->floorstat & CSTAT_SECTOR_SLOPE) && p->posZget() >= (floorz - i - 16)) p->posZset(floorz - i); else { p->on_ground = 0; - if ((p->OnMotorcycle || p->OnBoat) && floorz - i * 2 > p->PlayerNowPosition.Z) + if ((p->OnMotorcycle || p->OnBoat) && floorz - i * 2 > p->posZget()) { if (p->MotoOnGround) { @@ -2115,7 +2115,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo S_PlayActorSound(DUKE_SCREAM, pact); } - if (p->PlayerNowPosition.Z + p->vel.Z >= floorz - i) // hit the ground + if (p->posZget() + p->vel.Z >= floorz - i) // hit the ground { S_StopSound(DUKE_SCREAM, pact); if (!p->insector() || p->cursector->lotag != 1) @@ -2175,7 +2175,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo { //Smooth on the ground - double k = (floorz - i - p->PlayerNowPosition.Z) * 0.5; + double k = (floorz - i - p->posZget()) * 0.5; if (abs(k) < 1) k = 0; p->posZadd(k); p->vel.Z -= 3; @@ -2183,8 +2183,8 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo } else if (p->jumping_counter == 0) { - p->posZadd(((floorz - i * 0.5) - p->PlayerNowPosition.Z) * 0.5); //Smooth on the water - if (p->on_warping_sector == 0 && p->PlayerNowPosition.Z > floorz - 16) + p->posZadd(((floorz - i * 0.5) - p->posZget()) * 0.5); //Smooth on the water + if (p->on_warping_sector == 0 && p->posZget() > floorz - 16) { p->posZset(floorz - 16); p->vel.Z *= 0.5; @@ -2235,7 +2235,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo p->posZadd(p->vel.Z ); - if (p->PlayerNowPosition.Z < ceilingz + 4) + if (p->posZget() < ceilingz + 4) { p->jumping_counter = 0; if (p->vel.Z < 0) @@ -2298,10 +2298,10 @@ static void underwater(int snum, ESyncBits actions, double floorz, double ceilin p->posZadd(p->vel.Z ); - if (p->PlayerNowPosition.Z > floorz - 15) - p->posZadd((((floorz - 15) - p->PlayerNowPosition.Z) * 0.5)); + if (p->posZget() > floorz - 15) + p->posZadd((((floorz - 15) - p->posZget()) * 0.5)); - if (p->PlayerNowPosition.Z < ceilingz + 4) + if (p->posZget() < ceilingz + 4) { p->posZset(ceilingz + 4); p->vel.Z = 0; @@ -2314,7 +2314,7 @@ static void underwater(int snum, ESyncBits actions, double floorz, double ceilin { j->spr.pos += (p->angle.ang.ToVector() + DVector2(12 - (global_random & 8), 12 - (global_random & 8))) * 16; j->spr.scale = DVector2(0.046875, 0.03125); - j->spr.pos.Z = p->PlayerNowPosition.Z + 8; + j->spr.pos.Z = p->posZget() + 8; j->spr.cstat = CSTAT_SPRITE_TRANS_FLIP | CSTAT_SPRITE_TRANSLUCENT; } } @@ -3332,7 +3332,7 @@ void processinput_r(int snum) while (auto act2 = it.Next()) { if (act2->spr.picnum == RRTILE380) - if (act2->spr.pos.Z - 8 < p->PlayerNowPosition.Z) + if (act2->spr.pos.Z - 8 < p->posZget()) psectlotag = 2; } } @@ -3365,7 +3365,7 @@ void processinput_r(int snum) p->truefz = tempfz; p->truecz = getceilzofslopeptr(psectp, p->PlayerNowPosition); - double truefdist = abs(p->PlayerNowPosition.Z - tempfz); + double truefdist = abs(p->posZget() - tempfz); if (clz.type == kHitSector && psectlotag == 1 && truefdist > gs.playerheight + 16) psectlotag = 0; diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index 18bc7d02d..ba5b794b5 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -380,7 +380,7 @@ void doanimations(void) { for (auto p = connecthead; p >= 0; p = connectpoint2[p]) if (ps[p].cursector == dasectp) - if ((dasectp->floorz - ps[p].PlayerNowPosition.Z) < 64) + if ((dasectp->floorz - ps[p].posZget()) < 64) if (ps[p].GetActor()->GetOwner() != nullptr) { ps[p].posZadd(v); diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index dbe584029..8058316fc 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -452,7 +452,7 @@ bool checkhitswitch_d(int snum, walltype* wwal, DDukeActor *act) return 1; } - DVector3 v(spos, ps[snum].PlayerNowPosition.Z); + DVector3 v(spos, ps[snum].posZget()); switch (picnum) { default: diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 397b38c87..99be7214f 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -646,7 +646,7 @@ bool checkhitswitch_r(int snum, walltype* wwal, DDukeActor* act) setnextmap(false); } - DVector3 v(pos, ps[snum].PlayerNowPosition.Z); + DVector3 v(pos, ps[snum].posZget()); switch (picnum) { default: diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index 4aa08527f..fc4bf45dd 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -430,7 +430,7 @@ void initshell(DDukeActor* actj, DDukeActor* act, bool isshell) ang = ps[snum].angle.ang - mapangle((krand() & 63) + 8); //Fine tune act->temp_data[0] = krand() & 1; - act->spr.pos.Z = 3 + ps[snum].PlayerNowPosition.Z + ps[snum].pyoff + (ps[snum].horizon.sum().Tan() * 8.) + (!isshell ? 3 : 0); + act->spr.pos.Z = 3 + ps[snum].posZget() + ps[snum].pyoff + (ps[snum].horizon.sum().Tan() * 8.) + (!isshell ? 3 : 0); act->vel.Z = -krandf(1); } else diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 2ecc6cd2f..8b8d43288 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -379,6 +379,10 @@ struct player_struct { PlayerNowPosition.Z += val; } + double posZget() + { + return PlayerNowPosition.Z; + } }; struct Cycler