Skip to content

Commit

Permalink
Fix some weapon-switching issues
Browse files Browse the repository at this point in the history
More specifically, this fixes a bug whereby weapon alignment wouldn't take effect if the weapon were fired right after raising it, and seemingly another bug regarding improper handling of the case where the raising state is the same as the ready state.

See fabiangreffrath@0775134.
  • Loading branch information
MrAlaux committed Apr 6, 2024
1 parent 7234f47 commit 5a23a99
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/p_pspr.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ void A_Recoil(player_t* player)

static void P_SetPsprite(player_t *player, int position, statenum_t stnum)
{
P_SetPspritePtr(player, &player->psprites[position], stnum);

if (position == ps_weapon)
{
const weaponinfo_t wp = weaponinfo[player->readyweapon];
Expand All @@ -96,6 +94,8 @@ static void P_SetPsprite(player_t *player, int position, statenum_t stnum)
else if (stnum == wp.downstate)
player->switching = weapswitch_lowering;
}

P_SetPspritePtr(player, &player->psprites[position], stnum);
}

//
Expand Down Expand Up @@ -395,7 +395,6 @@ boolean P_CheckAmmo(player_t *player)
player->pendingweapon = P_SwitchWeapon(player); // phares
// Now set appropriate weapon overlay.
P_SetPsprite(player,ps_weapon,weaponinfo[player->readyweapon].downstate);
player->switching = weapswitch_lowering;
}

#if 0 /* PROBABLY UNSAFE */
Expand Down Expand Up @@ -639,7 +638,6 @@ void A_CheckReload(player_t *player, pspdef_t *psp)
// for us later on.
boom_weapon_state_injection = true;
P_SetPsprite(player, ps_weapon, weaponinfo[player->readyweapon].downstate);
player->switching = weapswitch_lowering;
}
}

Expand Down Expand Up @@ -1442,7 +1440,7 @@ void P_MovePsprites(player_t *player)
// [FG] center the weapon sprite horizontally and push up vertically
else if (player->attackdown && center_weapon_strict & WEAPON_CENTERED) // [Nugget] Horizontal weapon centering
{
psp->sx2 = (1 - STRICTMODE(sx_fix))*FRACUNIT; // [Nugget] Correct first person sprite centering
psp->sx2 = (1 - STRICTMODE(sx_fix)) * FRACUNIT; // [Nugget] Correct first person sprite centering
if (center_weapon_strict == WEAPON_CENTERED) // [Nugget] Horizontal weapon centering
psp->sy2 = WEAPONTOP;
}
Expand Down

0 comments on commit 5a23a99

Please sign in to comment.