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

This commit is contained in:
Mitchell Richters 2023-10-03 21:32:23 +11:00 committed by Christoph Oelckers
parent 287df1c18a
commit 9e56237f99
5 changed files with 6 additions and 8 deletions

View file

@ -45,8 +45,8 @@ int ifhitbyweapon_r(DDukeActor* sn);
int ifhitbyweapon_d(DDukeActor* sn);
void incur_damage_d(DDukePlayer* p);
void incur_damage_r(DDukePlayer* p);
void selectweapon_d(int snum, int j);
void selectweapon_r(int snum, int j);
void selectweapon_d(DDukePlayer* const p, int j);
void selectweapon_r(DDukePlayer* const p, int j);
int doincrements_d(DDukePlayer* p);
int doincrements_r(DDukePlayer* p);
void checkweapons_d(DDukePlayer* p);

View file

@ -79,7 +79,7 @@ struct Dispatcher
// player
void (*incur_damage)(DDukePlayer* p);
void (*selectweapon)(int snum, int j);
void (*selectweapon)(DDukePlayer* const p, int j);
int (*doincrements)(DDukePlayer* p);
void (*checkweapons)(DDukePlayer* p);
void (*processinput)(int snum);

View file

@ -246,7 +246,7 @@ void hud_input(DDukePlayer* const p)
p->wantweaponfire = weap - 1;
// Here we have to be extra careful that the weapons do not get mixed up, so let's keep the code for Duke and RR completely separate.
fi.selectweapon(p->pnum, weap);
fi.selectweapon(p, weap);
if (!!(p->cmd.ucmd.actions & SB_HOLSTER))
{

View file

@ -86,10 +86,9 @@ void incur_damage_d(DDukePlayer* p)
//
//---------------------------------------------------------------------------
void selectweapon_d(int snum, int weap) // playernum, weaponnum
void selectweapon_d(DDukePlayer* const p, int weap) // playernum, weaponnum
{
int i, j, k;
auto p = getPlayer(snum);
if (p->last_pissed_time <= (26 * 218) && p->show_empty_weapon == 0 && p->kickback_pic == 0 && p->quick_kick == 0 && p->GetActor()->spr.scale.X > 0.5 && p->access_incs == 0 && p->knee_incs == 0)
{
if ((p->weapon_pos == 0 || (p->holster_weapon && p->weapon_pos == -9)))

View file

@ -85,10 +85,9 @@ void incur_damage_r(DDukePlayer* p)
//
//---------------------------------------------------------------------------
void selectweapon_r(int snum, int weap)
void selectweapon_r(DDukePlayer* const p, int weap)
{
int i, j, k;
auto p = getPlayer(snum);
if (p->last_pissed_time <= (26 * 218) && p->show_empty_weapon == 0 && p->kickback_pic == 0 && p->quick_kick == 0 && p->GetActor()->spr.scale.X > 0.125 && p->access_incs == 0 && p->knee_incs == 0)
{
if ((p->weapon_pos == 0 || (p->holster_weapon && p->weapon_pos == -9)))