diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 41bd670b3..d53b50f3d 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -1372,8 +1372,8 @@ void movetransports_d(void) ps[p].backupxy(); if (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP) || ps[p].jetpack_on < 11)) - ps[p].PlayerNowPosition.Z = Owner->spr.pos.Z - 24; - else ps[p].PlayerNowPosition.Z = Owner->spr.pos.Z + 24; + ps[p].posZset(Owner->spr.pos.Z - 24); + else ps[p].posZset(Owner->spr.pos.Z + 24); ps[p].backupz(); auto pa = ps[p].GetActor(); @@ -1397,7 +1397,7 @@ void movetransports_d(void) } if (ps[p].GetActor()->spr.extra > 0) S_PlayActorSound(DUKE_UNDERWATER, act2); - ps[p].PlayerNowPosition.Z = Owner->sector()->ceilingz + 7; + ps[p].posZset(Owner->sector()->ceilingz + 7); ps[p].backupz(); // this is actually below the precision óf the original Build coordinate system... @@ -1416,7 +1416,7 @@ void movetransports_d(void) } S_PlayActorSound(DUKE_GASP, act2); - ps[p].PlayerNowPosition.Z = Owner->sector()->floorz - 7; + ps[p].posZset(Owner->sector()->floorz - 7); ps[p].backupz(); ps[p].jumping_toggle = 1; diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 8fab05bad..a7770f5bd 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -1257,8 +1257,8 @@ void movetransports_r(void) ps[p].backupxy(); if (ps[p].jetpack_on && (PlayerInput(p, SB_JUMP) || ps[p].jetpack_on < 11)) - ps[p].PlayerNowPosition.Z = Owner->spr.pos.Z - 24; - else ps[p].PlayerNowPosition.Z = Owner->spr.pos.Z + 24; + ps[p].posZset(Owner->spr.pos.Z - 24); + else ps[p].posZset(Owner->spr.pos.Z + 24); ps[p].backupz(); ChangeActorSect(act2, Owner->sector()); @@ -1274,7 +1274,7 @@ void movetransports_r(void) if (onfloorz && sectlotag == 160 && ps[p].PlayerNowPosition.Z > sectp->floorz - 48) { k = 2; - ps[p].PlayerNowPosition.Z = Owner->sector()->ceilingz + 7; + ps[p].posZset(Owner->sector()->ceilingz + 7); ps[p].backupz(); } @@ -1282,7 +1282,7 @@ void movetransports_r(void) { k = 2; if (ps[p].GetActor()->spr.extra <= 0) break; - ps[p].PlayerNowPosition.Z = Owner->sector()->floorz - 49; + ps[p].posZset(Owner->sector()->floorz - 49); ps[p].backupz(); } } @@ -1297,7 +1297,7 @@ void movetransports_r(void) FX_StopAllSounds(); } S_PlayActorSound(DUKE_UNDERWATER, ps[p].GetActor()); - ps[p].PlayerNowPosition.Z = Owner->sector()->ceilingz + 7; + ps[p].posZset(Owner->sector()->ceilingz + 7); ps[p].backupz(); if (ps[p].OnMotorcycle) ps[p].moto_underwater = 1; @@ -1313,7 +1313,7 @@ void movetransports_r(void) } S_PlayActorSound(DUKE_GASP, ps[p].GetActor()); - ps[p].PlayerNowPosition.Z = Owner->sector()->floorz - 7; + ps[p].posZset(Owner->sector()->floorz - 7); ps[p].backupz(); } diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index f919cd08c..8a265cce7 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -1732,7 +1732,7 @@ static void operateJetpack(int snum, ESyncBits actions, int psectlotag, double f if (p->PlayerNowPosition.Z > floorz - k) p->PlayerNowPosition.Z += ((floorz - k) - p->PlayerNowPosition.Z) * 0.5; if (p->PlayerNowPosition.Z < pact->ceilingz + 18) - p->PlayerNowPosition.Z = pact->ceilingz + 18; + p->posZset(pact->ceilingz + 18); } @@ -1791,7 +1791,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo // 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)) - p->PlayerNowPosition.Z = floorz - i; + p->posZset(floorz - i); else { p->on_ground = 0; @@ -1859,7 +1859,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo p->PlayerNowPosition.Z += ((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->PlayerNowPosition.Z = floorz - 16; + p->posZset(floorz - 16); p->vel.Z *= 0.5; } } @@ -1918,7 +1918,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo if (p->vel.Z < 0) p->vel.X = p->vel.Y = 0; p->vel.Z = 0.5; - p->PlayerNowPosition.Z = ceilingz + 4; + p->posZset(ceilingz + 4); } } @@ -1984,7 +1984,7 @@ static void underwater(int snum, ESyncBits actions, double floorz, double ceilin if (p->PlayerNowPosition.Z < ceilingz + 4) { - p->PlayerNowPosition.Z = ceilingz + 4; + p->posZset(ceilingz + 4); p->vel.Z = 0; } @@ -2043,7 +2043,7 @@ int operateTripbomb(int snum) auto delta = hit.hitpos.XY() - p->posXY(); if (delta.LengthSquared() < (18.125 * 18.125)) { - p->PlayerNowPosition.Z = p->PlayerOldPosition.Z; + p->posZset(p->PlayerOldPosition.Z); 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->PlayerNowPosition.Z = p->PlayerOldPosition.Z; + p->posZset(p->PlayerOldPosition.Z); 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 7167365ee..cc440bc3f 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -2080,7 +2080,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo if (p->PlayerNowPosition.Z < floorz - i) //falling { if ((actions & (SB_JUMP|SB_CROUCH)) == 0 && p->on_ground && (psect->floorstat & CSTAT_SECTOR_SLOPE) && p->PlayerNowPosition.Z >= (floorz - i - 16)) - p->PlayerNowPosition.Z = floorz - i; + p->posZset(floorz - i); else { p->on_ground = 0; @@ -2186,7 +2186,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo p->PlayerNowPosition.Z += ((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->PlayerNowPosition.Z = floorz - 16; + p->posZset(floorz - 16); p->vel.Z *= 0.5; } } @@ -2241,7 +2241,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo if (p->vel.Z < 0) p->vel.X = p->vel.Y = 0; p->vel.Z = 0.5; - p->PlayerNowPosition.Z = ceilingz + 4; + p->posZset(ceilingz + 4); } } @@ -2303,7 +2303,7 @@ static void underwater(int snum, ESyncBits actions, double floorz, double ceilin if (p->PlayerNowPosition.Z < ceilingz + 4) { - p->PlayerNowPosition.Z = ceilingz + 4; + p->posZset(ceilingz + 4); p->vel.Z = 0; } diff --git a/source/games/duke/src/player_w.cpp b/source/games/duke/src/player_w.cpp index 8e448e441..3106662ba 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->PlayerNowPosition.Z = p->PlayerOldPosition.Z; + p->posZset(p->PlayerOldPosition.Z); 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 4716922f3..629fb8449 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -370,6 +370,11 @@ struct player_struct { return PlayerNowPosition.XY(); } + + void posZset(const double val) + { + PlayerNowPosition.Z = val; + } }; struct Cycler