From fd8c7bfa52c2e528721a4db502e1d1c6444ce773 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Thu, 30 Dec 2021 22:14:04 +1100 Subject: [PATCH] - Duke: Replace `player_struct` `poszv` with `vel.Z` calls. --- 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 | 2 +- source/games/duke/src/player_d.cpp | 72 +++++++++---------- source/games/duke/src/player_r.cpp | 74 ++++++++++---------- source/games/duke/src/player_w.cpp | 2 +- source/games/duke/src/premap.cpp | 2 +- source/games/duke/src/savegame.cpp | 2 +- source/games/duke/src/sectors.cpp | 2 +- source/games/duke/src/types.h | 2 +- wadsrc/static/zscript/games/duke/dukegame.zs | 2 +- 12 files changed, 85 insertions(+), 85 deletions(-) diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index e80e34baf..2253b1283 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -1972,7 +1972,7 @@ void movetransports_d(void) int k = 0; - if (onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].on_ground && ps[p].pos.Z > (sectp->floorz - (16 << 8)) && (PlayerInput(p, SB_CROUCH) || ps[p].poszv > 2048)) + if (onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].on_ground && ps[p].pos.Z > (sectp->floorz - (16 << 8)) && (PlayerInput(p, SB_CROUCH) || ps[p].vel.Z > 2048)) // if( onfloorz && sectlotag == 1 && ps[p].pos.z > (sectp->floorz-(6<<8)) ) { k = 1; diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index ed90f47d2..be13d6bbf 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -413,8 +413,8 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, break; case PLAYER_POSZV: - if (bSet) ps[iPlayer].poszv = lValue; - else SetGameVarID(lVar2, ps[iPlayer].poszv, sActor, sPlayer); + if (bSet) ps[iPlayer].vel.Z = lValue; + else SetGameVarID(lVar2, ps[iPlayer].vel.Z, sActor, sPlayer); break; case PLAYER_LAST_PISSED_TIME: @@ -2414,7 +2414,7 @@ int ParseState::parse(void) // sigh.. this was yet another place where number literals were used as bit masks for every single value, making the code totally unreadable. if( (l& pducking) && ps[g_p].on_ground && PlayerInput(g_p, SB_CROUCH)) j = 1; - else if( (l& pfalling) && ps[g_p].jumping_counter == 0 && !ps[g_p].on_ground && ps[g_p].poszv > 2048 ) + else if( (l& pfalling) && ps[g_p].jumping_counter == 0 && !ps[g_p].on_ground && ps[g_p].vel.Z > 2048 ) j = 1; else if( (l& pjumping) && ps[g_p].jumping_counter > 348 ) j = 1; diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 03ba3f159..bb70cf2cc 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -433,7 +433,7 @@ void hud_input(int plnum) else { p->hard_landing = 0; - p->poszv = 0; + p->vel.Z = 0; S_PlayActorSound(DUKE_JETPACK_OFF, pact); S_StopSound(DUKE_JETPACK_IDLE, pact); S_StopSound(DUKE_JETPACK_ON, pact); diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 205d7d4c1..a693a5141 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -1088,7 +1088,7 @@ DEFINE_FIELD_X(DukePlayer, player_struct, pyoff) DEFINE_FIELD_X(DukePlayer, player_struct, opyoff) //DEFINE_FIELD_X(DukePlayer, player_struct, posxv) //DEFINE_FIELD_X(DukePlayer, player_struct, posyv) -DEFINE_FIELD_X(DukePlayer, player_struct, poszv) +//DEFINE_FIELD_X(DukePlayer, player_struct, poszv) DEFINE_FIELD_X(DukePlayer, player_struct, last_pissed_time) DEFINE_FIELD_X(DukePlayer, player_struct, truefz) DEFINE_FIELD_X(DukePlayer, player_struct, truecz) diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index f8411dcbb..654988228 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -1796,16 +1796,16 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int else { p->on_ground = 0; - p->poszv += (gs.gravity + 80); // (TICSPERFRAME<<6); - if (p->poszv >= (4096 + 2048)) p->poszv = (4096 + 2048); - if (p->poszv > 2400 && p->falling_counter < 255) + p->vel.Z += (gs.gravity + 80); // (TICSPERFRAME<<6); + if (p->vel.Z >= (4096 + 2048)) p->vel.Z = (4096 + 2048); + if (p->vel.Z > 2400 && p->falling_counter < 255) { p->falling_counter++; if (p->falling_counter == 38 && !S_CheckActorSoundPlaying(pact, DUKE_SCREAM)) S_PlayActorSound(DUKE_SCREAM, pact); } - if ((p->pos.Z + p->poszv) >= (fz - (i << 8))) // hit the ground + if ((p->pos.Z + p->vel.Z) >= (fz - (i << 8))) // hit the ground { S_StopSound(DUKE_SCREAM, pact); if (!p->insector() || p->cursector->lotag != 1) @@ -1829,7 +1829,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int SetPlayerPal(p, PalEntry(32, 16, 0, 0)); } - else if (p->poszv > 2048) S_PlayActorSound(DUKE_LAND, pact); + else if (p->vel.Z > 2048) S_PlayActorSound(DUKE_LAND, pact); } } } @@ -1840,8 +1840,8 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int p->falling_counter = 0; S_StopSound(-1, pact, CHAN_VOICE); - if (psectlotag != ST_1_ABOVE_WATER && psectlotag != ST_2_UNDERWATER && p->on_ground == 0 && p->poszv > (6144 >> 1)) - p->hard_landing = p->poszv >> 10; + if (psectlotag != ST_1_ABOVE_WATER && psectlotag != ST_2_UNDERWATER && p->on_ground == 0 && p->vel.Z > (6144 >> 1)) + p->hard_landing = p->vel.Z >> 10; p->on_ground = 1; @@ -1852,8 +1852,8 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int int k = ((fz - (i << 8)) - p->pos.Z) >> 1; if (abs(k) < 256) k = 0; p->pos.Z += k; - p->poszv -= 768; - if (p->poszv < 0) p->poszv = 0; + p->vel.Z -= 768; + if (p->vel.Z < 0) p->vel.Z = 0; } else if (p->jumping_counter == 0) { @@ -1861,7 +1861,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int if (p->on_warping_sector == 0 && p->pos.Z > fz - (16 << 8)) { p->pos.Z = fz - (16 << 8); - p->poszv >>= 1; + p->vel.Z >>= 1; } } @@ -1895,11 +1895,11 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int if (psectlotag == 1 && p->jumping_counter > 768) { p->jumping_counter = 0; - p->poszv = -512; + p->vel.Z = -512; } else { - p->poszv -= bsin(2048 - 128 + p->jumping_counter) / 12; + p->vel.Z -= bsin(2048 - 128 + p->jumping_counter) / 12; p->jumping_counter += 180; p->on_ground = 0; } @@ -1907,18 +1907,18 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int else { p->jumping_counter = 0; - p->poszv = 0; + p->vel.Z = 0; } } - p->pos.Z += p->poszv; + p->pos.Z += p->vel.Z; if (p->pos.Z < (cz + (4 << 8))) { p->jumping_counter = 0; - if (p->poszv < 0) + if (p->vel.Z < 0) p->vel.X = p->vel.Y = 0; - p->poszv = 128; + p->vel.Z = 128; p->pos.Z = cz + (4 << 8); } } @@ -1947,38 +1947,38 @@ static void underwater(int snum, ESyncBits actions, int fz, int cz) if (actions & SB_JUMP) { // jump - if (p->poszv > 0) p->poszv = 0; - p->poszv -= 348; - if (p->poszv < -(256 * 6)) p->poszv = -(256 * 6); + if (p->vel.Z > 0) p->vel.Z = 0; + p->vel.Z -= 348; + if (p->vel.Z < -(256 * 6)) p->vel.Z = -(256 * 6); } else if (actions & SB_CROUCH) { // crouch - if (p->poszv < 0) p->poszv = 0; - p->poszv += 348; - if (p->poszv > (256 * 6)) p->poszv = (256 * 6); + if (p->vel.Z < 0) p->vel.Z = 0; + p->vel.Z += 348; + if (p->vel.Z > (256 * 6)) p->vel.Z = (256 * 6); } else { // normal view - if (p->poszv < 0) + if (p->vel.Z < 0) { - p->poszv += 256; - if (p->poszv > 0) - p->poszv = 0; + p->vel.Z += 256; + if (p->vel.Z > 0) + p->vel.Z = 0; } - if (p->poszv > 0) + if (p->vel.Z > 0) { - p->poszv -= 256; - if (p->poszv < 0) - p->poszv = 0; + p->vel.Z -= 256; + if (p->vel.Z < 0) + p->vel.Z = 0; } } - if (p->poszv > 2048) - p->poszv >>= 1; + if (p->vel.Z > 2048) + p->vel.Z >>= 1; - p->pos.Z += p->poszv; + p->pos.Z += p->vel.Z; if (p->pos.Z > (fz - (15 << 8))) p->pos.Z += ((fz - (15 << 8)) - p->pos.Z) >> 1; @@ -1986,7 +1986,7 @@ static void underwater(int snum, ESyncBits actions, int fz, int cz) if (p->pos.Z < (cz + (4 << 8))) { p->pos.Z = cz + (4 << 8); - p->poszv = 0; + p->vel.Z = 0; } if (p->scuba_on && (krand() & 255) < 8) @@ -2040,7 +2040,7 @@ int operateTripbomb(int snum) if (((hit.hitpos.X - p->pos.X) * (hit.hitpos.X - p->pos.X) + (hit.hitpos.Y - p->pos.Y) * (hit.hitpos.Y - p->pos.Y)) < (290 * 290)) { p->pos.Z = p->opos.Z; - p->poszv = 0; + p->vel.Z = 0; return 1; } @@ -2580,7 +2580,7 @@ static void operateweapon(int snum, ESyncBits actions) if (p->kickback_pic < 4) { p->pos.Z = p->opos.Z; - p->poszv = 0; + 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 b11050925..766520c45 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -2126,7 +2126,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int { p->VBumpTarget = 80; p->moto_bump_fast = 1; - p->poszv -= xs_CRoundToInt(gs.gravity * (p->MotoSpeed / 16.)); + p->vel.Z -= xs_CRoundToInt(gs.gravity * (p->MotoSpeed / 16.)); p->MotoOnGround = 0; if (S_CheckActorSoundPlaying(pact, 188)) S_StopSound(188, pact); @@ -2134,23 +2134,23 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int } else { - p->poszv += gs.gravity - 80 + int(120 - p->MotoSpeed); + p->vel.Z += gs.gravity - 80 + int(120 - p->MotoSpeed); if (!S_CheckActorSoundPlaying(pact, 189) && !S_CheckActorSoundPlaying(pact, 190)) S_PlayActorSound(190, pact); } } else - p->poszv += (gs.gravity + 80); // (TICSPERFRAME<<6); + p->vel.Z += (gs.gravity + 80); // (TICSPERFRAME<<6); - if (p->poszv >= (4096 + 2048)) p->poszv = (4096 + 2048); - if (p->poszv > 2400 && p->falling_counter < 255) + if (p->vel.Z >= (4096 + 2048)) p->vel.Z = (4096 + 2048); + if (p->vel.Z > 2400 && p->falling_counter < 255) { p->falling_counter++; if (p->falling_counter == 38 && !S_CheckActorSoundPlaying(pact, DUKE_SCREAM)) S_PlayActorSound(DUKE_SCREAM, pact); } - if ((p->pos.Z + p->poszv) >= (fz - (i << 8))) // hit the ground + if ((p->pos.Z + p->vel.Z) >= (fz - (i << 8))) // 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, int fz, int SetPlayerPal(p, PalEntry(32, 16, 0, 0)); } - else if (p->poszv > 2048) + else if (p->vel.Z > 2048) { if (p->OnMotorcycle) { @@ -2186,7 +2186,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int } else S_PlayActorSound(DUKE_LAND, pact); } - else if (p->poszv > 1024 && p->OnMotorcycle) + else if (p->vel.Z > 1024 && p->OnMotorcycle) { S_PlayActorSound(DUKE_LAND, pact); p->TurbCount = 12; @@ -2201,8 +2201,8 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int p->falling_counter = 0; S_StopSound(-1, pact, CHAN_VOICE); - if (psectlotag != ST_1_ABOVE_WATER && psectlotag != ST_2_UNDERWATER && p->on_ground == 0 && p->poszv > (6144 >> 1)) - p->hard_landing = p->poszv >> 10; + if (psectlotag != ST_1_ABOVE_WATER && psectlotag != ST_2_UNDERWATER && p->on_ground == 0 && p->vel.Z > (6144 >> 1)) + p->hard_landing = p->vel.Z >> 10; p->on_ground = 1; @@ -2213,8 +2213,8 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int int k = ((fz - (i << 8)) - p->pos.Z) >> 1; if (abs(k) < 256) k = 0; p->pos.Z += k; - p->poszv -= 768; - if (p->poszv < 0) p->poszv = 0; + p->vel.Z -= 768; + if (p->vel.Z < 0) p->vel.Z = 0; } else if (p->jumping_counter == 0) { @@ -2222,7 +2222,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int if (p->on_warping_sector == 0 && p->pos.Z > fz - (16 << 8)) { p->pos.Z = fz - (16 << 8); - p->poszv >>= 1; + p->vel.Z >>= 1; } } @@ -2252,11 +2252,11 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int if (psectlotag == ST_1_ABOVE_WATER && p->jumping_counter > 768) { p->jumping_counter = 0; - p->poszv = -512; + p->vel.Z = -512; } else { - p->poszv -= bsin(2048 - 128 + p->jumping_counter) / 12; + p->vel.Z -= bsin(2048 - 128 + p->jumping_counter) / 12; p->jumping_counter += 180; p->on_ground = 0; } @@ -2264,18 +2264,18 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int else { p->jumping_counter = 0; - p->poszv = 0; + p->vel.Z = 0; } } - p->pos.Z += p->poszv; + p->pos.Z += p->vel.Z; if (p->pos.Z < (cz + (4 << 8))) { p->jumping_counter = 0; - if (p->poszv < 0) + if (p->vel.Z < 0) p->vel.X = p->vel.Y = 0; - p->poszv = 128; + p->vel.Z = 128; p->pos.Z = cz + (4 << 8); } } @@ -2302,36 +2302,36 @@ static void underwater(int snum, ESyncBits actions, int fz, int cz) if ((actions & SB_JUMP) && !p->OnMotorcycle) { - if (p->poszv > 0) p->poszv = 0; - p->poszv -= 348; - if (p->poszv < -(256 * 6)) p->poszv = -(256 * 6); + if (p->vel.Z > 0) p->vel.Z = 0; + p->vel.Z -= 348; + if (p->vel.Z < -(256 * 6)) p->vel.Z = -(256 * 6); } else if ((actions & SB_CROUCH) || p->OnMotorcycle) { - if (p->poszv < 0) p->poszv = 0; - p->poszv += 348; - if (p->poszv > (256 * 6)) p->poszv = (256 * 6); + if (p->vel.Z < 0) p->vel.Z = 0; + p->vel.Z += 348; + if (p->vel.Z > (256 * 6)) p->vel.Z = (256 * 6); } else { - if (p->poszv < 0) + if (p->vel.Z < 0) { - p->poszv += 256; - if (p->poszv > 0) - p->poszv = 0; + p->vel.Z += 256; + if (p->vel.Z > 0) + p->vel.Z = 0; } - if (p->poszv > 0) + if (p->vel.Z > 0) { - p->poszv -= 256; - if (p->poszv < 0) - p->poszv = 0; + p->vel.Z -= 256; + if (p->vel.Z < 0) + p->vel.Z = 0; } } - if (p->poszv > 2048) - p->poszv >>= 1; + if (p->vel.Z > 2048) + p->vel.Z >>= 1; - p->pos.Z += p->poszv; + p->pos.Z += p->vel.Z; if (p->pos.Z > (fz - (15 << 8))) p->pos.Z += ((fz - (15 << 8)) - p->pos.Z) >> 1; @@ -2339,7 +2339,7 @@ static void underwater(int snum, ESyncBits actions, int fz, int cz) if (p->pos.Z < (cz + (4 << 8))) { p->pos.Z = cz + (4 << 8); - p->poszv = 0; + p->vel.Z = 0; } if (p->scuba_on && (krand() & 255) < 8) diff --git a/source/games/duke/src/player_w.cpp b/source/games/duke/src/player_w.cpp index 28d42fc77..707ffa972 100644 --- a/source/games/duke/src/player_w.cpp +++ b/source/games/duke/src/player_w.cpp @@ -440,7 +440,7 @@ void operateweapon_ww(int snum, ESyncBits actions) && p->kickback_pic < (aplWeaponFireDelay(p->curr_weapon, snum) + 1)) { p->pos.Z = p->opos.Z; - p->poszv = 0; + p->vel.Z = 0; } if (p->kickback_pic == aplWeaponSound2Time(p->curr_weapon, snum)) { diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index e4acccb10..446c45ad7 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -150,7 +150,7 @@ void resetplayerstats(int snum) p->hard_landing = 0; p->vel.X = 0; //!! p->vel.Y = 0; - p->poszv = 0; + p->vel.Z = 0; p->fric.X = 0; p->fric.Y = 0; p->somethingonplayer =nullptr; diff --git a/source/games/duke/src/savegame.cpp b/source/games/duke/src/savegame.cpp index af0914675..3bfc6a665 100644 --- a/source/games/duke/src/savegame.cpp +++ b/source/games/duke/src/savegame.cpp @@ -127,7 +127,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w, ("pyoff", w.pyoff) ("posxv", w.vel.X) ("posyv", w.vel.Y) - ("poszv", w.poszv) + ("poszv", w.vel.Z) ("last_pissed_time", w.last_pissed_time) ("truefz", w.truefz) ("truecz", w.truecz) diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index 3a1877d43..77c2bf899 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -351,7 +351,7 @@ void doanimations(void) if (ps[p].GetActor()->GetOwner() != nullptr) { ps[p].pos.Z += v; - ps[p].poszv = 0; + ps[p].vel.Z = 0; } DukeSectIterator it(dasectp); diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 06eb9fb4b..f5db1ba8a 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -205,7 +205,7 @@ struct player_struct int exitx, exity, loogiex[64], loogiey[64], numloogs, loogcnt; int invdisptime; int bobposx, bobposy, pyoff, opyoff; - int poszv, last_pissed_time, truefz, truecz; + int last_pissed_time, truefz, truecz; int player_par, visibility; int bobcounter; int randomflamex, crack_time; diff --git a/wadsrc/static/zscript/games/duke/dukegame.zs b/wadsrc/static/zscript/games/duke/dukegame.zs index d4f21a985..0165a9179 100644 --- a/wadsrc/static/zscript/games/duke/dukegame.zs +++ b/wadsrc/static/zscript/games/duke/dukegame.zs @@ -153,7 +153,7 @@ struct DukePlayer native int exitx, exity, loogiex[64], loogiey[64], numloogs, loogcnt; native int invdisptime; native int bobposx, bobposy, pyoff, opyoff; - native int poszv, last_pissed_time, truefz, truecz; + native int last_pissed_time, truefz, truecz; native int player_par, visibility; native int bobcounter; native int randomflamex, crack_time;