- Duke: Clean up player/actor accesses in all input look functions.

This commit is contained in:
Mitchell Richters 2023-10-03 22:50:50 +11:00 committed by Christoph Oelckers
parent 8e2d4a3f52
commit 0e1520ab1f
4 changed files with 52 additions and 52 deletions

View file

@ -106,12 +106,12 @@ int makepainsounds(DDukePlayer* const p, int type);
void playerCrouch(DDukePlayer* const p); void playerCrouch(DDukePlayer* const p);
void playerJump(DDukePlayer* const p, double fz, double cz); void playerJump(DDukePlayer* const p, double fz, double cz);
void checklook(int snum, ESyncBits actions); void checklook(DDukePlayer* const p, ESyncBits actions);
void playerCenterView(int snum); void playerCenterView(DDukePlayer* const p);
void playerLookUp(int snum, ESyncBits actions); void playerLookUp(DDukePlayer* const p, ESyncBits actions);
void playerLookDown(int snum, ESyncBits actions); void playerLookDown(DDukePlayer* const p, ESyncBits actions);
void playerAimUp(int snum, ESyncBits actions); void playerAimUp(DDukePlayer* const p, ESyncBits actions);
void playerAimDown(int snum, ESyncBits actions); void playerAimDown(DDukePlayer* const p, ESyncBits actions);
DDukeActor* aim(DDukeActor* s, int aang, bool force = true, bool* b = nullptr); DDukeActor* aim(DDukeActor* s, int aang, bool force = true, bool* b = nullptr);
DDukeActor* aim_(DDukeActor* actor, DDukeActor* weapon, double aimangle, bool* b = nullptr); DDukeActor* aim_(DDukeActor* actor, DDukeActor* weapon, double aimangle, bool* b = nullptr);
void shoot(DDukeActor* actor, PClass* cls); void shoot(DDukeActor* actor, PClass* cls);

View file

@ -819,15 +819,15 @@ void DDukePlayer::playerweaponsway(double xvel)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void checklook(int snum, ESyncBits actions) void checklook(DDukePlayer* const p, ESyncBits actions)
{ {
auto p = getPlayer(snum); const auto pact = p->GetActor();
if ((actions & SB_LOOK_LEFT) && !p->OnMotorcycle) if ((actions & SB_LOOK_LEFT) && !p->OnMotorcycle)
{ {
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum); SetGameVarID(g_iReturnVarID, 0, pact, p->pnum);
OnEvent(EVENT_LOOKLEFT, snum, p->GetActor(), -1); OnEvent(EVENT_LOOKLEFT, p->pnum, pact, -1);
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum).value() != 0) if (GetGameVarID(g_iReturnVarID, pact, p->pnum).value() != 0)
{ {
actions &= ~SB_LOOK_LEFT; actions &= ~SB_LOOK_LEFT;
} }
@ -835,9 +835,9 @@ void checklook(int snum, ESyncBits actions)
if ((actions & SB_LOOK_RIGHT) && !p->OnMotorcycle) if ((actions & SB_LOOK_RIGHT) && !p->OnMotorcycle)
{ {
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum); SetGameVarID(g_iReturnVarID, 0, pact, p->pnum);
OnEvent(EVENT_LOOKRIGHT, snum, p->GetActor(), -1); OnEvent(EVENT_LOOKRIGHT, p->pnum, pact, -1);
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum).value() != 0) if (GetGameVarID(g_iReturnVarID, pact, p->pnum).value() != 0)
{ {
actions &= ~SB_LOOK_RIGHT; actions &= ~SB_LOOK_RIGHT;
} }
@ -850,16 +850,16 @@ void checklook(int snum, ESyncBits actions)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void playerCenterView(int snum) void playerCenterView(DDukePlayer* const p)
{ {
auto p = getPlayer(snum); const auto pact = p->GetActor();
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum); SetGameVarID(g_iReturnVarID, 0, pact, p->pnum);
OnEvent(EVENT_RETURNTOCENTER, snum, p->GetActor(), -1); OnEvent(EVENT_RETURNTOCENTER, p->pnum, pact, -1);
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum).value() == 0) if (GetGameVarID(g_iReturnVarID, pact, p->pnum).value() == 0)
{ {
p->cmd.ucmd.actions |= SB_CENTERVIEW; p->cmd.ucmd.actions |= SB_CENTERVIEW;
p->cmd.ucmd.ang.Pitch = nullAngle; p->cmd.ucmd.ang.Pitch = nullAngle;
setForcedSyncInput(snum); setForcedSyncInput(p->pnum);
} }
else else
{ {
@ -867,12 +867,12 @@ void playerCenterView(int snum)
} }
} }
void playerLookUp(int snum, ESyncBits actions) void playerLookUp(DDukePlayer* const p, ESyncBits actions)
{ {
auto p = getPlayer(snum); const auto pact = p->GetActor();
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum); SetGameVarID(g_iReturnVarID, 0, pact, p->pnum);
OnEvent(EVENT_LOOKUP, snum, p->GetActor(), -1); OnEvent(EVENT_LOOKUP, p->pnum, pact, -1);
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum).value() == 0) if (GetGameVarID(g_iReturnVarID, pact, p->pnum).value() == 0)
{ {
p->cmd.ucmd.actions |= SB_CENTERVIEW; p->cmd.ucmd.actions |= SB_CENTERVIEW;
} }
@ -882,12 +882,12 @@ void playerLookUp(int snum, ESyncBits actions)
} }
} }
void playerLookDown(int snum, ESyncBits actions) void playerLookDown(DDukePlayer* const p, ESyncBits actions)
{ {
auto p = getPlayer(snum); const auto pact = p->GetActor();
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum); SetGameVarID(g_iReturnVarID, 0, pact, p->pnum);
OnEvent(EVENT_LOOKDOWN, snum, p->GetActor(), -1); OnEvent(EVENT_LOOKDOWN, p->pnum, pact, -1);
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum).value() == 0) if (GetGameVarID(g_iReturnVarID, pact, p->pnum).value() == 0)
{ {
p->cmd.ucmd.actions |= SB_CENTERVIEW; p->cmd.ucmd.actions |= SB_CENTERVIEW;
} }
@ -897,23 +897,23 @@ void playerLookDown(int snum, ESyncBits actions)
} }
} }
void playerAimUp(int snum, ESyncBits actions) void playerAimUp(DDukePlayer* const p, ESyncBits actions)
{ {
auto p = getPlayer(snum); const auto pact = p->GetActor();
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum); SetGameVarID(g_iReturnVarID, 0, pact, p->pnum);
OnEvent(EVENT_AIMUP, snum, p->GetActor(), -1); OnEvent(EVENT_AIMUP, p->pnum, pact, -1);
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum).value() != 0) if (GetGameVarID(g_iReturnVarID, pact, p->pnum).value() != 0)
{ {
p->cmd.ucmd.actions &= ~SB_AIM_UP; p->cmd.ucmd.actions &= ~SB_AIM_UP;
} }
} }
void playerAimDown(int snum, ESyncBits actions) void playerAimDown(DDukePlayer* const p, ESyncBits actions)
{ {
auto p = getPlayer(snum); const auto pact = p->GetActor();
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum); SetGameVarID(g_iReturnVarID, 0, pact, p->pnum);
OnEvent(EVENT_AIMDOWN, snum, p->GetActor(), -1); // due to a typo in WW2GI's CON files this is the same as EVENT_AIMUP. OnEvent(EVENT_AIMDOWN, p->pnum, pact, -1); // due to a typo in WW2GI's CON files this is the same as EVENT_AIMUP.
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum).value() != 0) if (GetGameVarID(g_iReturnVarID, pact, p->pnum).value() != 0)
{ {
p->cmd.ucmd.actions &= ~SB_AIM_DOWN; p->cmd.ucmd.actions &= ~SB_AIM_DOWN;
} }

View file

@ -1671,7 +1671,7 @@ void processinput_d(int snum)
doubvel = TICSPERFRAME; doubvel = TICSPERFRAME;
checklook(snum,actions); checklook(p, actions);
p->Angles.doViewYaw(&p->cmd.ucmd); p->Angles.doViewYaw(&p->cmd.ucmd);
p->updatecentering(snum); p->updatecentering(snum);
@ -1916,23 +1916,23 @@ HORIZONLY:
// center_view // center_view
if (actions & SB_CENTERVIEW || (p->hard_landing && (cl_dukepitchmode & kDukePitchLandingRecenter))) if (actions & SB_CENTERVIEW || (p->hard_landing && (cl_dukepitchmode & kDukePitchLandingRecenter)))
{ {
playerCenterView(snum); playerCenterView(p);
} }
else if ((actions & SB_LOOK_UP) == SB_LOOK_UP) else if ((actions & SB_LOOK_UP) == SB_LOOK_UP)
{ {
playerLookUp(snum, actions); playerLookUp(p, actions);
} }
else if ((actions & SB_LOOK_DOWN) == SB_LOOK_DOWN) else if ((actions & SB_LOOK_DOWN) == SB_LOOK_DOWN)
{ {
playerLookDown(snum, actions); playerLookDown(p, actions);
} }
else if ((actions & SB_LOOK_UP) == SB_AIM_UP) else if ((actions & SB_LOOK_UP) == SB_AIM_UP)
{ {
playerAimUp(snum, actions); playerAimUp(p, actions);
} }
else if ((actions & SB_LOOK_DOWN) == SB_AIM_DOWN) else if ((actions & SB_LOOK_DOWN) == SB_AIM_DOWN)
{ // aim_down { // aim_down
playerAimDown(snum, actions); playerAimDown(p, actions);
} }
p->Angles.doPitchInput(&p->cmd.ucmd); p->Angles.doPitchInput(&p->cmd.ucmd);

View file

@ -2482,7 +2482,7 @@ void processinput_r(int snum)
doubvel = TICSPERFRAME; doubvel = TICSPERFRAME;
checklook(snum, actions); checklook(p, actions);
p->Angles.doViewYaw(&p->cmd.ucmd); p->Angles.doViewYaw(&p->cmd.ucmd);
p->apply_seasick(); p->apply_seasick();
@ -2865,23 +2865,23 @@ HORIZONLY:
if (actions & SB_CENTERVIEW || (p->hard_landing && (cl_dukepitchmode & kDukePitchLandingRecenter))) if (actions & SB_CENTERVIEW || (p->hard_landing && (cl_dukepitchmode & kDukePitchLandingRecenter)))
{ {
playerCenterView(snum); playerCenterView(p);
} }
else if ((actions & SB_LOOK_UP) == SB_LOOK_UP) else if ((actions & SB_LOOK_UP) == SB_LOOK_UP)
{ {
playerLookUp(snum, actions); playerLookUp(p, actions);
} }
else if ((actions & SB_LOOK_DOWN) == SB_LOOK_DOWN) else if ((actions & SB_LOOK_DOWN) == SB_LOOK_DOWN)
{ {
playerLookDown(snum, actions); playerLookDown(p, actions);
} }
else if ((actions & SB_LOOK_UP) == SB_AIM_UP && !p->OnMotorcycle) else if ((actions & SB_LOOK_UP) == SB_AIM_UP && !p->OnMotorcycle)
{ {
playerAimUp(snum, actions); playerAimUp(p, actions);
} }
else if ((actions & SB_LOOK_DOWN) == SB_AIM_DOWN && !p->OnMotorcycle) else if ((actions & SB_LOOK_DOWN) == SB_AIM_DOWN && !p->OnMotorcycle)
{ {
playerAimDown(snum, actions); playerAimDown(p, actions);
} }
if (p->recoil && p->kickback_pic == 0) if (p->recoil && p->kickback_pic == 0)
{ {