- Duke: Clean up player/actor accesses in playerCrouch().

This commit is contained in:
Mitchell Richters 2023-10-03 22:41:22 +11:00 committed by Christoph Oelckers
parent 2197128dc4
commit 443b66ea9d
4 changed files with 8 additions and 8 deletions

View file

@ -103,7 +103,7 @@ int endoflevel(DDukePlayer* const p);
void playerisdead(DDukePlayer* const p, int psectlotag, double fz, double cz);
void footprints(DDukePlayer* const p);
int makepainsounds(DDukePlayer* const p, int type);
void playerCrouch(int snum);
void playerCrouch(DDukePlayer* const p);
void playerJump(int snum, double fz, double cz);
void checklook(int snum, ESyncBits actions);

View file

@ -673,15 +673,15 @@ int timedexit(DDukePlayer* const p)
//
//---------------------------------------------------------------------------
void playerCrouch(int snum)
void playerCrouch(DDukePlayer* const p)
{
const auto p = getPlayer(snum);
const auto pact = p->GetActor();
const auto nVelMoveDown = abs(p->cmd.ucmd.vel.Z * (p->cmd.ucmd.vel.Z < 0));
constexpr double vel = 8 + 3;
SetGameVarID(g_iReturnVarID, 0, pact, snum);
OnEvent(EVENT_CROUCH, snum, pact, -1);
if (GetGameVarID(g_iReturnVarID, pact, snum).value() == 0)
SetGameVarID(g_iReturnVarID, 0, pact, p->pnum);
OnEvent(EVENT_CROUCH, p->pnum, pact, -1);
if (GetGameVarID(g_iReturnVarID, pact, p->pnum).value() == 0)
{
pact->spr.pos.Z += clamp(vel * !!(p->cmd.ucmd.actions & SB_CROUCH) + vel * nVelMoveDown, -vel, vel);
p->crack_time = CRACK_TIME;

View file

@ -767,7 +767,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo
if ((actions & SB_CROUCH) || p->cmd.ucmd.vel.Z < 0)
{
playerCrouch(snum);
playerCrouch(p);
}
// jumping

View file

@ -1283,7 +1283,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo
if (((actions & SB_CROUCH) || p->cmd.ucmd.vel.Z < 0) && !p->OnMotorcycle)
{
playerCrouch(snum);
playerCrouch(p);
}
if ((actions & SB_JUMP) == 0 && !p->OnMotorcycle && p->jumping_toggle == 1)