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

This commit is contained in:
Mitchell Richters 2023-10-04 10:40:20 +11:00
parent 3ee76dee66
commit df673952d9
2 changed files with 12 additions and 14 deletions

View file

@ -1446,9 +1446,8 @@ static void operateweapon(DDukePlayer* const p, ESyncBits actions)
//
//---------------------------------------------------------------------------
static void processweapon(int snum, ESyncBits actions)
static void processweapon(DDukePlayer* const p, ESyncBits actions)
{
auto p = getPlayer(snum);
auto pact = p->GetActor();
int shrunk = (pact->spr.scale.Y < 0.5);
@ -1456,11 +1455,11 @@ static void processweapon(int snum, ESyncBits actions)
{
if (isWW2GI())
{
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum);
SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->GetActor(), snum);
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike(p->curr_weapon, p), p->GetActor(), snum);
OnEvent(EVENT_HOLSTER, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum).value() == 0)
SetGameVarID(g_iReturnVarID, 0, pact, p->pnum);
SetGameVarID(g_iWeaponVarID, p->curr_weapon, pact, p->pnum);
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike(p->curr_weapon, p), pact, p->pnum);
OnEvent(EVENT_HOLSTER, p->pnum, pact, -1);
if (GetGameVarID(g_iReturnVarID, pact, p->pnum).value() == 0)
{
// now it uses the game definitions...
if (aplWeaponFlags(p->curr_weapon, p) & WEAPON_FLAG_HOLSTER_CLEARS_CLIP)
@ -1660,8 +1659,8 @@ void processinput_d(int snum)
fi.doincrements(p);
if (isWW2GI() && aplWeaponWorksLike(p->curr_weapon, p) == HANDREMOTE_WEAPON) processweapon(snum, actions);
if (!isWW2GI() && p->curr_weapon == HANDREMOTE_WEAPON) processweapon(snum, actions);
if (isWW2GI() && aplWeaponWorksLike(p->curr_weapon, p) == HANDREMOTE_WEAPON) processweapon(p, actions);
if (!isWW2GI() && p->curr_weapon == HANDREMOTE_WEAPON) processweapon(p, actions);
return;
}
@ -1972,7 +1971,7 @@ HORIZONLY:
}
// HACKS
processweapon(snum, actions);
processweapon(p, actions);
}
END_DUKE_NS

View file

@ -2201,9 +2201,8 @@ static void operateweapon(DDukePlayer* const p, ESyncBits actions, sectortype* p
//
//---------------------------------------------------------------------------
static void processweapon(int snum, ESyncBits actions, sectortype* psectp)
static void processweapon(DDukePlayer* const p, ESyncBits actions, sectortype* psectp)
{
auto p = getPlayer(snum);
auto pact = p->GetActor();
int shrunk = (pact->spr.scale.Y < 0.125);
@ -2473,7 +2472,7 @@ void processinput_r(int snum)
fi.doincrements(p);
if (p->curr_weapon == THROWINGDYNAMITE_WEAPON) processweapon(snum, actions, psectp);
if (p->curr_weapon == THROWINGDYNAMITE_WEAPON) processweapon(p, actions, psectp);
return;
}
@ -2926,7 +2925,7 @@ HORIZONLY:
else p->weapon_pos--;
}
processweapon(snum, actions, psectp);
processweapon(p, actions, psectp);
}
//---------------------------------------------------------------------------