From c09b9f71f5229ac5bc9b72e2a8371c7bafa0ad69 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 5 Feb 2022 13:40:30 +0100 Subject: [PATCH] - cleanup, part 3. --- source/games/duke/src/ccmds.cpp | 3 +-- source/games/duke/src/gameexec.cpp | 9 ++++----- source/games/duke/src/inlines.h | 2 +- source/games/duke/src/player.cpp | 16 +++++++++------- source/games/duke/src/player_d.cpp | 22 +++++++++++----------- source/games/duke/src/player_r.cpp | 8 +++++--- source/games/duke/src/player_w.cpp | 2 +- source/games/duke/src/types.h | 6 ------ 8 files changed, 32 insertions(+), 36 deletions(-) diff --git a/source/games/duke/src/ccmds.cpp b/source/games/duke/src/ccmds.cpp index 3853433fac1..595d7df4c43 100644 --- a/source/games/duke/src/ccmds.cpp +++ b/source/games/duke/src/ccmds.cpp @@ -115,8 +115,7 @@ void GameInterface::WarpToCoords(int x, int y, int z, int ang, int horz) { player_struct* p = &ps[myconnectindex]; - p->player_set_int_xy({ x, y}); - p->player_set_int_z(z); + p->pos = DVector3(x, y, z); p->backupxyz(); if (ang != INT_MIN) diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 1da0e41ab0c..d25b907423a 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -1981,8 +1981,7 @@ int ParseState::parse(void) break; case concmd_larrybird: insptr++; - ps[g_p].player_set_int_z(ps[g_p].GetActor()->sector()->int_ceilingz()); - ps[g_p].GetActor()->set_int_z(ps[g_p].player_int_pos().Z); + ps[g_p].GetActor()->spr.pos.Z = ps[g_p].pos.Z = ps[g_p].GetActor()->sector()->ceilingz; break; case concmd_destroyit: insptr++; @@ -2224,12 +2223,12 @@ int ParseState::parse(void) { // I am not convinced this is even remotely smart to be executed from here.. pickrandomspot(g_p); - g_ac->set_int_pos(ps[g_p].player_int_pos()); + g_ac->spr.pos = ps[g_p].pos; ps[g_p].backupxyz(); ps[g_p].setbobpos(); g_ac->backuppos(); - updatesector(ps[g_p].player_int_pos().X, ps[g_p].player_int_pos().Y, &ps[g_p].cursector); - SetActor(ps[g_p].GetActor(), vec3_t( ps[g_p].player_int_pos().X, ps[g_p].player_int_pos().Y, ps[g_p].player_int_pos().Z + gs.int_playerheight )); + updatesector(ps[g_p].pos, &ps[g_p].cursector); + SetActor(ps[g_p].GetActor(), ps[g_p].pos.plusZ(gs.playerheight )); g_ac->spr.cstat = CSTAT_SPRITE_BLOCK_ALL; g_ac->spr.shade = -12; diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index d54eaf25f73..304510fa18b 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -208,7 +208,7 @@ inline bool playrunning() inline void doslopetilting(player_struct* p, double const scaleAdjust = 1) { bool const canslopetilt = p->on_ground && p->insector() && p->cursector->lotag != ST_2_UNDERWATER && (p->cursector->floorstat & CSTAT_SECTOR_SLOPE); - p->horizon.calcviewpitch(p->player_int_pos().vec2, p->angle.ang, p->aim_mode == 0, canslopetilt, p->cursector, scaleAdjust); + p->horizon.calcviewpitch(p->pos, p->angle.ang, p->aim_mode == 0, canslopetilt, p->cursector, scaleAdjust); } //--------------------------------------------------------------------------- diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 7295fe032dd..f5206947ad6 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -560,8 +560,8 @@ void playerisdead(int snum, int psectlotag, int fz, int cz) if (actor->spr.pal != 1) { SetPlayerPal(p, PalEntry(63, 63, 0, 0)); - p->player_add_int_z(-(16 << 8)); - actor->add_int_z(-(16 << 8)); + p->pos.Z -= 16; + actor->spr.pos.Z -= 16; } #if 0 if (ud.recstat == 1 && ud.multimode < 2) @@ -609,7 +609,7 @@ void playerisdead(int snum, int psectlotag, int fz, int cz) if (p->on_warping_sector == 0) { if (abs(p->player_int_pos().Z - fz) > (gs.int_playerheight >> 1)) - p->player_add_int_z(348); + p->pos.Z += 348/ 256.; } else { @@ -706,7 +706,7 @@ void playerCrouch(int snum) OnEvent(EVENT_CROUCH, snum, p->GetActor(), -1); if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum).value() == 0) { - p->player_add_int_z((2048 + 768)); + p->pos.Z += 8 + 3; p->crack_time = CRACK_TIME; } } @@ -765,14 +765,16 @@ void player_struct::backuppos(bool noclipping) { if (!noclipping) { - backupxy(); + opos.X = pos.X; + opos.Y = pos.Y; } else { - restorexy(); + pos.X = opos.X; + pos.Y = opos.Y; } - backupz(); + opos.Z = pos.Z; bobpos.X = player_int_pos().X; bobpos.Y = player_int_pos().Y; opyoff = pyoff; diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 82f43c6a4c1..0439b366be0 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -1667,7 +1667,6 @@ void checkweapons_d(struct player_struct* p) static void operateJetpack(int snum, ESyncBits actions, int psectlotag, int fz, int cz, int shrunk) { - int j; auto p = &ps[snum]; auto pact = p->GetActor(); p->on_ground = 0; @@ -1687,13 +1686,14 @@ static void operateJetpack(int snum, ESyncBits actions, int psectlotag, int fz, if (p->jetpack_on < 11) { p->jetpack_on++; - p->player_add_int_z(-(p->jetpack_on << 7)); //Goin up + p->pos.Z -= (p->jetpack_on * 0.5); //Goin up } else if (p->jetpack_on == 11 && !S_CheckActorSoundPlaying(pact, DUKE_JETPACK_IDLE)) S_PlayActorSound(DUKE_JETPACK_IDLE, pact); - if (shrunk) j = 512; - else j = 2048; + double dist; + if (shrunk) dist = 2; + else dist = 8; if (actions & SB_JUMP) //A (soar high) { @@ -1702,7 +1702,7 @@ static void operateJetpack(int snum, ESyncBits actions, int psectlotag, int fz, OnEvent(EVENT_SOARUP, snum, p->GetActor(), -1); if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum).value() == 0) { - p->player_add_int_z(-j); + p->pos.Z -= dist; p->crack_time = CRACK_TIME; } } @@ -1714,7 +1714,7 @@ static void operateJetpack(int snum, ESyncBits actions, int psectlotag, int fz, OnEvent(EVENT_SOARDOWN, snum, p->GetActor(), -1); if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum).value() == 0) { - p->player_add_int_z(j); + p->pos.Z += dist; p->crack_time = CRACK_TIME; } } @@ -1727,9 +1727,9 @@ static void operateJetpack(int snum, ESyncBits actions, int psectlotag, int fz, p->scuba_on = 0; if (p->player_int_pos().Z > (fz - (k << 8))) - p->player_add_int_z(((fz - (k << 8)) - p->player_int_pos().Z) >> 1); + p->pos.Z += (((fz - (k << 8)) - p->player_int_pos().Z) >> 1) * zinttoworld; if (p->player_int_pos().Z < (pact->actor_int_ceilingz() + (18 << 8))) - p->player_set_int_z(pact->actor_int_ceilingz() + (18 << 8)); + p->pos.Z = pact->ceilingz + 18; } @@ -2034,7 +2034,7 @@ int operateTripbomb(int snum) if ((hit.hitWall->twoSided() && hit.hitWall->nextSector()->lotag <= 2) || (!hit.hitWall->twoSided() && hit.hitSector->lotag <= 2)) if (((hit.hitpos.X - p->player_int_pos().X) * (hit.hitpos.X - p->player_int_pos().X) + (hit.hitpos.Y - p->player_int_pos().Y) * (hit.hitpos.Y - p->player_int_pos().Y)) < (290 * 290)) { - p->player_set_int_z(p->player_int_opos().Z); + p->pos.Z = p->opos.Z; p->vel.Z = 0; return 1; } @@ -2572,7 +2572,7 @@ static void operateweapon(int snum, ESyncBits actions) case TRIPBOMB_WEAPON: // Claymore in NAM if (p->kickback_pic < 4) { - p->player_set_int_z(p->player_int_opos().Z); + p->pos.Z = p->opos.Z; p->vel.Z = 0; if (p->kickback_pic == 3) fi.shoot(pact, HANDHOLDINGLASER); @@ -3034,7 +3034,7 @@ void processinput_d(int snum) clipmove(p->pos, &p->cursector, p->vel.X, p->vel.Y, 164, (4 << 8), ii, CLIPMASK0, clip); if (p->jetpack_on == 0 && psectlotag != 2 && psectlotag != 1 && shrunk) - p->player_add_int_z(32 << 8); + p->pos.Z += 32; if (clip.type != kHitNone) checkplayerhurt_d(p, clip); diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 7894763fb19..075ab4b9464 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -3803,7 +3803,7 @@ void processinput_r(int snum) clipmove(p->pos, &p->cursector, p->vel.X, p->vel.Y, 164, (4 << 8), i, CLIPMASK0, clip); if (p->jetpack_on == 0 && psectlotag != 2 && psectlotag != 1 && shrunk) - p->player_add_int_z(32 << 8); + p->pos.Z += 32; if (clip.type != kHitNone) checkplayerhurt_r(p, clip); @@ -4046,7 +4046,8 @@ void OnMotorcycle(struct player_struct *p, DDukeActor* motosprite) { if (motosprite) { - p->getxyfromactor(motosprite); + p->pos.X = motosprite->spr.pos.X; + p->pos.Y = motosprite->spr.pos.Y; p->angle.ang = buildang(motosprite->spr.ang); p->ammo_amount[MOTORCYCLE_WEAPON] = motosprite->saved_ammo; deletesprite(motosprite); @@ -4125,7 +4126,8 @@ void OnBoat(struct player_struct *p, DDukeActor* boat) { if (boat) { - p->getxyfromactor(boat); + p->pos.X = boat->spr.pos.X; + p->pos.Y = boat->spr.pos.Y; p->angle.ang = buildang(boat->spr.ang); p->ammo_amount[BOAT_WEAPON] = boat->saved_ammo; deletesprite(boat); diff --git a/source/games/duke/src/player_w.cpp b/source/games/duke/src/player_w.cpp index ec6122cfb1f..1cc7c6fb835 100644 --- a/source/games/duke/src/player_w.cpp +++ b/source/games/duke/src/player_w.cpp @@ -439,7 +439,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->player_set_int_z(p->player_int_opos().Z); + p->pos.Z = p->opos.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 4463b3f5b26..b5a2d12cf78 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -372,12 +372,6 @@ struct player_struct opos.Y = pos.Y; } - void restorexy() - { - pos.X = opos.X; - pos.Y = opos.Y; - } - void backupz() { opos.Z = pos.Z;