From 4464497c2860680b0ddb3db7af6b5a1cfd30276c Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Wed, 4 Oct 2023 10:53:56 +1100 Subject: [PATCH] - Duke: Clean up player/actor accesses in `processinput_*()`. --- source/games/duke/src/dispatch.cpp | 4 +- source/games/duke/src/duke3d.h | 2 +- source/games/duke/src/funct.h | 2 +- source/games/duke/src/gameloop.cpp | 2 +- source/games/duke/src/player_d.cpp | 48 ++++++------ source/games/duke/src/player_r.cpp | 112 ++++++++++++++-------------- source/games/duke/src/sectors_r.cpp | 9 ++- source/games/duke/src/types.h | 4 +- 8 files changed, 90 insertions(+), 93 deletions(-) diff --git a/source/games/duke/src/dispatch.cpp b/source/games/duke/src/dispatch.cpp index 94a93b752..89a674004 100644 --- a/source/games/duke/src/dispatch.cpp +++ b/source/games/duke/src/dispatch.cpp @@ -51,8 +51,8 @@ int doincrements_d(DDukePlayer* p); int doincrements_r(DDukePlayer* p); void checkweapons_d(DDukePlayer* p); void checkweapons_r(DDukePlayer* p); -void processinput_d(int snum); -void processinput_r(int snum); +void processinput_d(DDukePlayer* const p); +void processinput_r(DDukePlayer* const p); void displayweapon_d(DDukePlayer* const p, double interpfrac); void displayweapon_r(DDukePlayer* const p, double interpfrac); void displaymasks_d(DDukePlayer* const p, int pal, double interpfrac); diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index d1f3a8390..12dc94d59 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -82,7 +82,7 @@ struct Dispatcher void (*selectweapon)(DDukePlayer* const p, int j); int (*doincrements)(DDukePlayer* p); void (*checkweapons)(DDukePlayer* p); - void (*processinput)(int snum); + void (*processinput)(DDukePlayer* const p); void (*displayweapon)(DDukePlayer* const p, double interpfrac); void (*displaymasks)(DDukePlayer* const p, int pal, double interpfrac); diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index ea6dfc76f..dc4a0254c 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -166,7 +166,7 @@ bool isanearoperator(int lotag); bool isanunderoperator(int lotag); int setanimation(sectortype* animsect, int animtype, walltype* animtarget, double thegoal, double thevel); int setanimation(sectortype* animsect, int animtype, sectortype* animtarget, double thegoal, double thevel); -void dofurniture(walltype* wallNum, sectortype* sectnum, int playerNum); +void dofurniture(DDukePlayer* const p, walltype* wallNum); void dotorch(); double hitawall(DDukePlayer* pl, walltype** hitWall); double hits(DDukeActor* snum); diff --git a/source/games/duke/src/gameloop.cpp b/source/games/duke/src/gameloop.cpp index baaf4ab04..edbe24c67 100644 --- a/source/games/duke/src/gameloop.cpp +++ b/source/games/duke/src/gameloop.cpp @@ -87,7 +87,7 @@ void GameInterface::Ticker() p->pals.a--; hud_input(p); - fi.processinput(i); + fi.processinput(p); fi.checksectors(i); } diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 33cf5513b..f1befff76 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -1523,16 +1523,14 @@ static void processweapon(DDukePlayer* const p, ESyncBits actions) // //--------------------------------------------------------------------------- -void processinput_d(int snum) +void processinput_d(DDukePlayer* const p) { int k, doubvel; double floorz, ceilingz, truefdist; Collision chz, clz; bool shrunk; int psectlotag; - DDukePlayer* p; - p = getPlayer(snum); auto pact = p->GetActor(); ESyncBits& actions = p->cmd.ucmd.actions; @@ -1541,7 +1539,7 @@ void processinput_d(int snum) const auto strafeVel = p->cmd.ucmd.vel.Y; constexpr auto maxVel = (117351124. / 10884538.); - processinputvel(snum); + processinputvel(p->pnum); auto psectp = p->cursector; if (psectp == nullptr) @@ -1558,14 +1556,14 @@ void processinput_d(int snum) p->spritebridge = 0; shrunk = (pact->spr.scale.Y < 0.5); - getzrange(p->GetActor()->getPosWithOffsetZ(), psectp, &ceilingz, chz, &floorz, clz, 10.1875, CLIPMASK0); + getzrange(pact->getPosWithOffsetZ(), psectp, &ceilingz, chz, &floorz, clz, 10.1875, CLIPMASK0); setPlayerActorViewZOffset(pact); - p->truefz = getflorzofslopeptr(psectp, p->GetActor()->getPosWithOffsetZ()); - p->truecz = getceilzofslopeptr(psectp, p->GetActor()->getPosWithOffsetZ()); + p->truefz = getflorzofslopeptr(psectp, pact->getPosWithOffsetZ()); + p->truecz = getceilzofslopeptr(psectp, pact->getPosWithOffsetZ()); - truefdist = abs(p->GetActor()->getOffsetZ() - p->truefz); + truefdist = abs(pact->getOffsetZ() - p->truefz); if (clz.type == kHitSector && psectlotag == 1 && truefdist > gs.playerheight + 16) psectlotag = 0; @@ -1593,7 +1591,7 @@ void processinput_d(int snum) } else if (badguy(clz.actor()) && clz.actor()->spr.scale.X > 0.375 && abs(pact->spr.pos.Z - clz.actor()->spr.pos.Z) < 84) { - auto ang = (clz.actor()->spr.pos.XY() - p->GetActor()->spr.pos.XY()).Angle(); + auto ang = (clz.actor()->spr.pos.XY() - pact->spr.pos.XY()).Angle(); p->vel.XY() -= ang.ToVector(); } CallStandingOn(clz.actor(), p); @@ -1636,10 +1634,10 @@ void processinput_d(int snum) return; } - if (p->GetActor()->spr.scale.X < 0.625 && p->jetpack_on == 0) + if (pact->spr.scale.X < 0.625 && p->jetpack_on == 0) { p->ofistsign = p->fistsign; - p->fistsign += int(p->GetActor()->vel.X * 16); + p->fistsign += int(pact->vel.X * 16); } if (p->transporter_hold > 0) @@ -1653,7 +1651,7 @@ void processinput_d(int snum) if (p->newOwner != nullptr) { - setForcedSyncInput(snum); + setForcedSyncInput(p->pnum); p->vel.X = p->vel.Y = 0; pact->vel.X = 0; @@ -1669,18 +1667,18 @@ void processinput_d(int snum) checklook(p, actions); p->Angles.doViewYaw(&p->cmd.ucmd); - p->updatecentering(snum); + p->updatecentering(); if (p->on_crane != nullptr) { - setForcedSyncInput(snum); + setForcedSyncInput(p->pnum); goto HORIZONLY; } p->playerweaponsway(pact->vel.X); - pact->vel.X = clamp((p->GetActor()->spr.pos.XY() - p->bobpos).Length(), 0., 32.); - if (p->on_ground) p->bobcounter += int(p->GetActor()->vel.X * 8); + pact->vel.X = clamp((pact->spr.pos.XY() - p->bobpos).Length(), 0., 32.); + if (p->on_ground) p->bobcounter += int(pact->vel.X * 8); p->backuppos(ud.clipping == 0 && ((p->insector() && p->cursector->floortexture == mirrortex) || !p->insector())); @@ -1707,7 +1705,7 @@ void processinput_d(int snum) p->vel.X = 0; p->vel.Y = 0; p->cmd.ucmd.ang.Yaw = nullAngle; - setForcedSyncInput(snum); + setForcedSyncInput(p->pnum); } p->Angles.doYawInput(&p->cmd.ucmd); @@ -1826,15 +1824,15 @@ HORIZONLY: Collision clip{}; if (ud.clipping) { - p->GetActor()->spr.pos.XY() += p->vel.XY() ; - updatesector(p->GetActor()->getPosWithOffsetZ(), &p->cursector); + pact->spr.pos.XY() += p->vel.XY() ; + updatesector(pact->getPosWithOffsetZ(), &p->cursector); ChangeActorSect(pact, p->cursector); } else - clipmove(p->GetActor()->spr.pos.XY(), p->GetActor()->getOffsetZ(), &p->cursector, p->vel.XY(), 10.25, 4., iif, CLIPMASK0, clip); + clipmove(pact->spr.pos.XY(), pact->getOffsetZ(), &p->cursector, p->vel.XY(), 10.25, 4., iif, CLIPMASK0, clip); if (p->jetpack_on == 0 && psectlotag != 2 && psectlotag != 1 && shrunk) - p->GetActor()->spr.pos.Z += 32; + pact->spr.pos.Z += 32; if (clip.type != kHitNone) checkplayerhurt_d(p, clip); @@ -1879,12 +1877,12 @@ HORIZONLY: if (p->cursector != pact->sector()) ChangeActorSect(pact, p->cursector); - auto oldpos = p->GetActor()->opos; + auto oldpos = pact->opos; int retry = 0; while (ud.clipping == 0) { int blocked; - blocked = (pushmove(p->GetActor()->spr.pos.XY(), p->GetActor()->getOffsetZ(), &p->cursector, 10.25, 4, 4, CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < DAngle90); + blocked = (pushmove(pact->spr.pos.XY(), pact->getOffsetZ(), &p->cursector, 10.25, 4, 4, CLIPMASK0) < 0 && furthestangle(pact, 8) < DAngle90); if (fabs(pact->floorz - pact->ceilingz) < 48 || blocked) { @@ -1895,8 +1893,8 @@ HORIZONLY: { if (!retry++) { - p->GetActor()->spr.pos = oldpos; - p->GetActor()->backuppos(); + pact->spr.pos = oldpos; + pact->backuppos(); continue; } quickkill(p); diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 8af7e5fd3..7b7898175 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -963,9 +963,8 @@ static void doVehicleThrottling(DDukePlayer* p, DDukeActor* pact, unsigned& flag // //--------------------------------------------------------------------------- -static void onMotorcycle(int snum, ESyncBits &actions) +static void onMotorcycle(DDukePlayer* const p, ESyncBits &actions) { - auto p = getPlayer(snum); auto pact = p->GetActor(); unsigned flags = outVehicleFlags(p, actions); @@ -1042,9 +1041,8 @@ static void onMotorcycle(int snum, ESyncBits &actions) // //--------------------------------------------------------------------------- -static void onBoat(int snum, ESyncBits &actions) +static void onBoat(DDukePlayer* const p, ESyncBits &actions) { - auto p = getPlayer(snum); auto pact = p->GetActor(); if (p->NotOnWater) @@ -1338,15 +1336,14 @@ static void movement(DDukePlayer* const p, ESyncBits actions, sectortype* psect, // //--------------------------------------------------------------------------- -void onMotorcycleMove(int snum, walltype* wal) +static void onMotorcycleMove(DDukePlayer* const p, walltype* wal) { - auto p = getPlayer(snum); auto pact = p->GetActor(); - double angleDelta = absangle(p->GetActor()->spr.Angles.Yaw, wal->delta().Angle()).Degrees(); + double angleDelta = absangle(pact->spr.Angles.Yaw, wal->delta().Angle()).Degrees(); double damageAmount = p->MotoSpeed * p->MotoSpeed; const double scale = (180. / 2048.); - p->GetActor()->spr.Angles.Yaw += DAngle::fromDeg(p->MotoSpeed * (krand() & 1 ? -scale : scale)); + pact->spr.Angles.Yaw += DAngle::fromDeg(p->MotoSpeed * (krand() & 1 ? -scale : scale)); // That's some very weird angles here... if (angleDelta >= 77.51 && angleDelta <= 102.13) @@ -1394,14 +1391,13 @@ void onMotorcycleMove(int snum, walltype* wal) // //--------------------------------------------------------------------------- -void onBoatMove(int snum, int psectlotag, walltype* wal) +void onBoatMove(DDukePlayer* const p, int psectlotag, walltype* wal) { - auto p = getPlayer(snum); auto pact = p->GetActor(); - double angleDelta = absangle(p->GetActor()->spr.Angles.Yaw, wal->delta().Angle()).Degrees(); + double angleDelta = absangle(pact->spr.Angles.Yaw, wal->delta().Angle()).Degrees(); const double scale = (90. / 2048.); - p->GetActor()->spr.Angles.Yaw += DAngle::fromDeg(p->MotoSpeed * (krand() & 1 ? -scale : scale)); + pact->spr.Angles.Yaw += DAngle::fromDeg(p->MotoSpeed * (krand() & 1 ? -scale : scale)); if (angleDelta >= 77.51 && angleDelta <= 102.13) { @@ -1436,22 +1432,23 @@ void onBoatMove(int snum, int psectlotag, walltype* wal) // //--------------------------------------------------------------------------- -void onMotorcycleHit(int snum, DDukeActor* victim) +static void onMotorcycleHit(DDukePlayer* const p, DDukeActor* victim) { - auto p = getPlayer(snum); if (badguy(victim) || victim->isPlayer()) { + const auto pact = p->GetActor(); + if (!victim->isPlayer()) { if (numplayers == 1) { Collision coll; - DAngle ang = p->TiltStatus * 20 + p->GetActor()->spr.Angles.Yaw; + DAngle ang = p->TiltStatus * 20 + pact->spr.Angles.Yaw; movesprite_ex(victim, DVector3(ang.ToVector() * 4, victim->vel.Z), CLIPMASK0, coll); } } else - victim->SetHitOwner(p->GetActor()); + victim->SetHitOwner(pact); victim->attackertype = RedneckMotoHitClass; victim->hitextra = int(p->MotoSpeed * 0.5); p->MotoSpeed -= p->MotoSpeed / 4.; @@ -1469,23 +1466,23 @@ void onMotorcycleHit(int snum, DDukeActor* victim) // //--------------------------------------------------------------------------- -void onBoatHit(int snum, DDukeActor* victim) +static void onBoatHit(DDukePlayer* const p, DDukeActor* victim) { - auto p = getPlayer(snum); - if (badguy(victim) || victim->isPlayer()) { + const auto pact = p->GetActor(); + if (!victim->isPlayer()) { if (numplayers == 1) { Collision coll; - DAngle ang = p->TiltStatus * 20 + p->GetActor()->spr.Angles.Yaw; + DAngle ang = p->TiltStatus * 20 + pact->spr.Angles.Yaw; movesprite_ex(victim, DVector3(ang.ToVector() * 2, victim->vel.Z), CLIPMASK0, coll); } } else - victim->SetHitOwner(p->GetActor()); + victim->SetHitOwner(pact); victim->attackertype = RedneckMotoHitClass; victim->hitextra = int(p->MotoSpeed * 0.25); p->MotoSpeed -= p->MotoSpeed / 4.; @@ -2255,7 +2252,7 @@ static void processweapon(DDukePlayer* const p, ESyncBits actions, sectortype* p // //--------------------------------------------------------------------------- -void processinput_r(int snum) +void processinput_r(DDukePlayer* const p) { int k, doubvel; Collision chz, clz; @@ -2263,7 +2260,6 @@ void processinput_r(int snum) int psectlotag; double floorz = 0, ceilingz = 0; - auto p = getPlayer(snum); auto pact = p->GetActor(); ESyncBits& actions = p->cmd.ucmd.actions; @@ -2275,14 +2271,14 @@ void processinput_r(int snum) auto psectp = p->cursector; if (p->OnMotorcycle && pact->spr.extra > 0) { - onMotorcycle(snum, actions); + onMotorcycle(p, actions); } else if (p->OnBoat && pact->spr.extra > 0) { - onBoat(snum, actions); + onBoat(p, actions); } - processinputvel(snum); + processinputvel(p->pnum); if (psectp == nullptr) { @@ -2301,7 +2297,7 @@ void processinput_r(int snum) while (auto act2 = it.Next()) { if (act2->GetClass() == RedneckWaterSurfaceClass) - if (act2->spr.pos.Z - 8 < p->GetActor()->getOffsetZ()) + if (act2->spr.pos.Z - 8 < pact->getOffsetZ()) psectlotag = ST_2_UNDERWATER; } } @@ -2321,19 +2317,19 @@ void processinput_r(int snum) shrunk = (pact->spr.scale.Y < 0.125); if (pact->clipdist == 16) { - getzrange(p->GetActor()->getPosWithOffsetZ(), psectp, &ceilingz, chz, &floorz, clz, 10.1875, CLIPMASK0); + getzrange(pact->getPosWithOffsetZ(), psectp, &ceilingz, chz, &floorz, clz, 10.1875, CLIPMASK0); } else { - getzrange(p->GetActor()->getPosWithOffsetZ(), psectp, &ceilingz, chz, &floorz, clz, 0.25, CLIPMASK0); + getzrange(pact->getPosWithOffsetZ(), psectp, &ceilingz, chz, &floorz, clz, 0.25, CLIPMASK0); } setPlayerActorViewZOffset(pact); - p->truefz = getflorzofslopeptr(psectp, p->GetActor()->getPosWithOffsetZ()); - p->truecz = getceilzofslopeptr(psectp, p->GetActor()->getPosWithOffsetZ()); + p->truefz = getflorzofslopeptr(psectp, pact->getPosWithOffsetZ()); + p->truecz = getceilzofslopeptr(psectp, pact->getPosWithOffsetZ()); - double truefdist = abs(p->GetActor()->getOffsetZ() - p->truefz); + double truefdist = abs(pact->getOffsetZ() - p->truefz); if (clz.type == kHitSector && psectlotag == 1 && truefdist > gs.playerheight + 16) psectlotag = 0; @@ -2391,7 +2387,7 @@ void processinput_r(int snum) } else if (badguy(clz.actor()) && clz.actor()->spr.scale.X > 0.375 && abs(pact->spr.pos.Z - clz.actor()->spr.pos.Z) < 84) { - auto ang = (clz.actor()->spr.pos.XY() - p->GetActor()->spr.pos.XY()).Angle(); + auto ang = (clz.actor()->spr.pos.XY() - pact->spr.pos.XY()).Angle(); p->vel.XY() -= ang.ToVector(); } if (clz.actor()->GetClass() == RedneckLadderClass) @@ -2449,10 +2445,10 @@ void processinput_r(int snum) return; } - if (p->GetActor()->spr.scale.X < 0.125 && p->jetpack_on == 0) + if (pact->spr.scale.X < 0.125 && p->jetpack_on == 0) { p->ofistsign = p->fistsign; - p->fistsign += int(p->GetActor()->vel.X * 16); + p->fistsign += int(pact->vel.X * 16); } if (p->transporter_hold > 0) @@ -2466,7 +2462,7 @@ void processinput_r(int snum) if (p->newOwner != nullptr) { - setForcedSyncInput(snum); + setForcedSyncInput(p->pnum); p->vel.X = p->vel.Y = 0; pact->vel.X = 0; @@ -2482,18 +2478,18 @@ void processinput_r(int snum) p->Angles.doViewYaw(&p->cmd.ucmd); p->apply_seasick(); - p->updatecentering(snum); + p->updatecentering(); if (p->on_crane != nullptr) { - setForcedSyncInput(snum); + setForcedSyncInput(p->pnum); goto HORIZONLY; } p->playerweaponsway(pact->vel.X); - pact->vel.X = clamp((p->GetActor()->spr.pos.XY() - p->bobpos).Length(), 0., 32.); - if (p->on_ground) p->bobcounter += int(p->GetActor()->vel.X * 8); + pact->vel.X = clamp((pact->spr.pos.XY() - p->bobpos).Length(), 0., 32.); + if (p->on_ground) p->bobcounter += int(pact->vel.X * 8); p->backuppos(ud.clipping == 0 && ((p->insector() && p->cursector->floortexture == mirrortex) || !p->insector())); @@ -2535,7 +2531,7 @@ void processinput_r(int snum) p->vel.X = 0; p->vel.Y = 0; p->cmd.ucmd.ang.Yaw = nullAngle; - setForcedSyncInput(snum); + setForcedSyncInput(p->pnum); } p->Angles.doYawInput(&p->cmd.ucmd); @@ -2709,15 +2705,15 @@ HORIZONLY: Collision clip{}; if (ud.clipping) { - p->GetActor()->spr.pos.XY() += p->vel.XY() ; - updatesector(p->GetActor()->getPosWithOffsetZ(), &p->cursector); + pact->spr.pos.XY() += p->vel.XY() ; + updatesector(pact->getPosWithOffsetZ(), &p->cursector); ChangeActorSect(pact, p->cursector); } else - clipmove(p->GetActor()->spr.pos.XY(), p->GetActor()->getOffsetZ(), &p->cursector, p->vel.XY(), 10.25, 4., iif, CLIPMASK0, clip); + clipmove(pact->spr.pos.XY(), pact->getOffsetZ(), &p->cursector, p->vel.XY(), 10.25, 4., iif, CLIPMASK0, clip); if (p->jetpack_on == 0 && psectlotag != 2 && psectlotag != 1 && shrunk) - p->GetActor()->spr.pos.Z += 32; + pact->spr.pos.Z += 32; if (clip.type != kHitNone) checkplayerhurt_r(p, clip); @@ -2730,11 +2726,11 @@ HORIZONLY: auto wal = clip.hitWall; if (p->OnMotorcycle) { - onMotorcycleMove(snum, wal); + onMotorcycleMove(p, wal); } else if (p->OnBoat) { - onBoatMove(snum, psectlotag, wal); + onBoatMove(p, psectlotag, wal); } else { @@ -2742,11 +2738,11 @@ HORIZONLY: { if (wal->lotag < 44) { - dofurniture(clip.hitWall, p->cursector, snum); - pushmove(p->GetActor()->spr.pos.XY(), p->GetActor()->getOffsetZ(), &p->cursector, 10.75, 4, 4, CLIPMASK0); + dofurniture(p, clip.hitWall); + pushmove(pact->spr.pos.XY(), pact->getOffsetZ(), &p->cursector, 10.75, 4, 4, CLIPMASK0); } else - pushmove(p->GetActor()->spr.pos.XY(), p->GetActor()->getOffsetZ(), &p->cursector, 10.75, 4, 4, CLIPMASK0); + pushmove(pact->spr.pos.XY(), pact->getOffsetZ(), &p->cursector, 10.75, 4, 4, CLIPMASK0); } } } @@ -2755,11 +2751,11 @@ HORIZONLY: { if (p->OnMotorcycle) { - onMotorcycleHit(snum, clip.actor()); + onMotorcycleHit(p, clip.actor()); } else if (p->OnBoat) { - onBoatHit(snum, clip.actor()); + onBoatHit(p, clip.actor()); } else if (badguy(clip.actor())) { @@ -2821,15 +2817,15 @@ HORIZONLY: if (p->cursector != pact->sector()) ChangeActorSect(pact, p->cursector); - auto oldpos = p->GetActor()->opos; + auto oldpos = pact->opos; int retry = 0; while (ud.clipping == 0) { int blocked; if (pact->clipdist == 16) - blocked = (pushmove(p->GetActor()->spr.pos.XY(), p->GetActor()->getOffsetZ(), &p->cursector, 8, 4, 4, CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < DAngle90); + blocked = (pushmove(pact->spr.pos.XY(), pact->getOffsetZ(), &p->cursector, 8, 4, 4, CLIPMASK0) < 0 && furthestangle(pact, 8) < DAngle90); else - blocked = (pushmove(p->GetActor()->spr.pos.XY(), p->GetActor()->getOffsetZ(), &p->cursector, 1, 4, 4, CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < DAngle90); + blocked = (pushmove(pact->spr.pos.XY(), pact->getOffsetZ(), &p->cursector, 1, 4, 4, CLIPMASK0) < 0 && furthestangle(pact, 8) < DAngle90); if (fabs(pact->floorz - pact->ceilingz) < 48 || blocked) { @@ -2840,8 +2836,8 @@ HORIZONLY: { if (!retry++) { - p->GetActor()->spr.pos = oldpos; - p->GetActor()->backuppos(); + pact->spr.pos = oldpos; + pact->backuppos(); continue; } quickkill(p); @@ -2885,7 +2881,7 @@ HORIZONLY: if (!d) d = 1; p->recoil -= d; - p->GetActor()->spr.Angles.Pitch += maphoriz(d); + pact->spr.Angles.Pitch += maphoriz(d); } p->Angles.doPitchInput(&p->cmd.ucmd); diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index a0bd9ffda..e2cfd5d0c 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -411,9 +411,10 @@ void checksectors_r(int snum) // //--------------------------------------------------------------------------- -void dofurniture(walltype* wlwal, sectortype* sectp, int snum) +void dofurniture(DDukePlayer* const p, walltype* wlwal) { assert(wlwal->twoSided()); + auto sectp = p->cursector; auto nextsect = wlwal->nextSector(); double movestep = min(sectp->hitag * maptoworld, 1.); @@ -464,8 +465,10 @@ void dofurniture(walltype* wlwal, sectortype* sectp, int snum) if (pos_ok) { - if (S_CheckActorSoundPlaying(getPlayer(snum)->GetActor(), 389) == 0) - S_PlayActorSound(389, getPlayer(snum)->GetActor()); + const auto pact = p->GetActor(); + + if (S_CheckActorSoundPlaying(pact, 389) == 0) + S_PlayActorSound(389, pact); for(auto& wal : nextsect->walls) { auto vec = wal.pos; diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 7d7f6a469..ee18045c4 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -376,7 +376,7 @@ public: bobpos = GetActor()->spr.pos.XY(); } - void updatecentering(const int snum) + void updatecentering() { if (!(cmd.ucmd.actions & SB_CENTERVIEW)) return; @@ -386,7 +386,7 @@ public: if ((centertest && returnlock) || !cmd.ucmd.ang.Pitch.Degrees()) { - setForcedSyncInput(snum); + setForcedSyncInput(pnum); cmd.ucmd.ang.Pitch = nullAngle; } else