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

This commit is contained in:
Mitchell Richters 2023-10-03 22:43:25 +11:00
parent f135097193
commit 2225fea10c
4 changed files with 11 additions and 14 deletions

View file

@ -104,7 +104,7 @@ 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(DDukePlayer* const p);
void playerJump(int snum, double fz, double cz);
void playerJump(DDukePlayer* const p, double fz, double cz);
void checklook(int snum, ESyncBits actions);
void playerCenterView(int snum);

View file

@ -688,22 +688,19 @@ void playerCrouch(DDukePlayer* const p)
}
}
void playerJump(int snum, double floorz, double ceilingz)
void playerJump(DDukePlayer* const p, double floorz, double ceilingz)
{
auto p = getPlayer(snum);
if (p->jumping_toggle == 0 && p->jumping_counter == 0)
if (p->jumping_toggle == 0 && p->jumping_counter == 0 && (floorz - ceilingz) > 56)
{
if ((floorz - ceilingz) > 56)
{
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum);
OnEvent(EVENT_JUMP, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum).value() == 0)
const auto pact = p->GetActor();
SetGameVarID(g_iReturnVarID, 0, pact, p->pnum);
OnEvent(EVENT_JUMP, p->pnum, pact, -1);
if (GetGameVarID(g_iReturnVarID, pact, p->pnum).value() == 0)
{
p->jumping_counter = 1;
p->jumping_toggle = 1;
}
}
}
}
//---------------------------------------------------------------------------

View file

@ -776,7 +776,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo
else if ((actions & SB_JUMP))
{
playerJump(snum, floorz, ceilingz);
playerJump(p, floorz, ceilingz);
}
if (p->jumping_counter && (actions & SB_JUMP) == 0)

View file

@ -1291,7 +1291,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo
else if ((actions & SB_JUMP) && !p->OnMotorcycle && p->jumping_toggle == 0)
{
playerJump(snum, floorz, ceilingz);
playerJump(p, floorz, ceilingz);
}
}