Skip to content

Commit

Permalink
Fixed (all games): If weapon ammo requirements are edited in values.d…
Browse files Browse the repository at this point in the history
…ed so that all weapons require ammo; When all ammo had been expended P_MaybeChangeWeapon correctly concluded that no change would produce a fire-able weapon and thus player_t->pendingWeapon == WT_NOCHANGE. However, P_CheckAmmo was then changing the psprite to the downstate regardless of the fact that no weapon would subsequently be raised afterwards (leaving the player running around with no weapon in view and no means to change weapon again even after collecting more ammo).
  • Loading branch information
danij committed Jul 11, 2008
1 parent c41a293 commit f226a90
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 16 deletions.
9 changes: 7 additions & 2 deletions doomsday/plugins/jdoom/src/p_pspr.c
Expand Up @@ -169,7 +169,7 @@ boolean P_CheckAmmo(player_t *player)

// Check we have enough of ALL ammo types used by this weapon.
good = true;
for(i=0; i < NUM_AMMO_TYPES && good; ++i)
for(i = 0; i < NUM_AMMO_TYPES && good; ++i)
{
if(!weaponInfo[player->readyWeapon][player->class].mode[0].ammoType[i])
continue; // Weapon does not take this type of ammo.
Expand All @@ -191,7 +191,8 @@ boolean P_CheckAmmo(player_t *player)
P_MaybeChangeWeapon(player, WT_NOCHANGE, AT_NOAMMO, false);

// Now set appropriate weapon overlay.
P_SetPsprite(player, ps_weapon, weaponInfo[player->readyWeapon][player->class].mode[0].downState);
if(player->pendingWeapon != WT_NOCHANGE)
P_SetPsprite(player, ps_weapon, weaponInfo[player->readyWeapon][player->class].mode[0].downState);

return false;
}
Expand Down Expand Up @@ -402,6 +403,8 @@ void C_DECL A_Punch(player_t *player, pspdef_t *psp)
int damage;
float slope;

P_ShotAmmo(player);
player->update |= PSF_AMMO;
if(IS_CLIENT)
return;

Expand Down Expand Up @@ -435,6 +438,8 @@ void C_DECL A_Saw(player_t *player, pspdef_t *psp)
int damage;
float slope;

P_ShotAmmo(player);
player->update |= PSF_AMMO;
if(IS_CLIENT)
return;

Expand Down
13 changes: 8 additions & 5 deletions doomsday/plugins/jdoom64/src/p_pspr.c
Expand Up @@ -190,7 +190,8 @@ boolean P_CheckAmmo(player_t *player)
P_MaybeChangeWeapon(player, WT_NOCHANGE, AT_NOAMMO, false);

// Now set appropriate weapon overlay.
P_SetPsprite(player, ps_weapon, weaponInfo[player->readyWeapon][player->class].mode[0].downState);
if(player->pendingWeapon != WT_NOCHANGE)
P_SetPsprite(player, ps_weapon, weaponInfo[player->readyWeapon][player->class].mode[0].downState);

return false;
}
Expand Down Expand Up @@ -404,6 +405,8 @@ void C_DECL A_Punch(player_t *player, pspdef_t *psp)
int damage;
float slope;

P_ShotAmmo(player);
player->update |= PSF_AMMO;
if(IS_CLIENT)
return;

Expand Down Expand Up @@ -435,6 +438,8 @@ void C_DECL A_Saw(player_t *player, pspdef_t *psp)
int damage;
float slope;

P_ShotAmmo(player);
player->update |= PSF_AMMO;
if(IS_CLIENT)
return;

Expand Down Expand Up @@ -533,16 +538,14 @@ void C_DECL A_FireSingleLaser(player_t *player, pspdef_t *psp)
mobj_t *pmo;
short laserPower;

P_ShotAmmo(player);
P_SetPsprite(player, ps_flash,
weaponInfo[player->readyWeapon][player->class].mode[0].flashState);

player->update |= PSF_AMMO;
if(IS_CLIENT)
return;

P_ShotAmmo(player);

pmo = player->plr->mo;
player->update |= PSF_AMMO;

laserPower = 0;
if(player->artifacts[it_laserpw1])
Expand Down
14 changes: 9 additions & 5 deletions doomsday/plugins/jheretic/src/p_pspr.c
Expand Up @@ -680,7 +680,7 @@ void GetDefState(char *def, int *val)
/**
*Initialize weapon info, maxammo and clipammo.
*/
void P_InitWeaponInfo()
void P_InitWeaponInfo(void)
{
#define WPINF "Weapon Info|"

Expand Down Expand Up @@ -817,8 +817,9 @@ boolean P_CheckAmmo(player_t *player)
// Out of ammo, pick a weapon to change to.
P_MaybeChangeWeapon(player, WT_NOCHANGE, AT_NOAMMO, false);

P_SetPsprite(player, ps_weapon,
weaponInfo[player->readyWeapon][player->class].mode[lvl].downState);
if(player->pendingWeapon != WT_NOCHANGE)
P_SetPsprite(player, ps_weapon, weaponInfo[player->readyWeapon][player->class].mode[lvl].downState);

return false;
}

Expand Down Expand Up @@ -1124,6 +1125,7 @@ void C_DECL A_BeakAttackPL1(player_t *player, pspdef_t *psp)
int damage;
float slope;

P_ShotAmmo(player);
damage = 1 + (P_Random() & 3);
angle = player->plr->mo->angle;
slope = P_AimLineAttack(player->plr->mo, angle, MELEERANGE);
Expand All @@ -1149,6 +1151,7 @@ void C_DECL A_BeakAttackPL2(player_t *player, pspdef_t *psp)
int damage;
float slope;

P_ShotAmmo(player);
damage = HITDICE(4);
angle = player->plr->mo->angle;
slope = P_AimLineAttack(player->plr->mo, angle, MELEERANGE);
Expand All @@ -1174,6 +1177,7 @@ void C_DECL A_StaffAttackPL1(player_t *player, pspdef_t *psp)
int damage;
float slope;

P_ShotAmmo(player);
damage = 5 + (P_Random() & 15);
angle = player->plr->mo->angle;
angle += (P_Random() - P_Random()) << 18;
Expand All @@ -1197,6 +1201,7 @@ void C_DECL A_StaffAttackPL2(player_t *player, pspdef_t *psp)
int damage;
float slope;

P_ShotAmmo(player);
damage = 18 + (P_Random() & 63);
angle = player->plr->mo->angle;
angle += (P_Random() - P_Random()) << 18;
Expand Down Expand Up @@ -1621,7 +1626,6 @@ void C_DECL A_FireSkullRodPL1(player_t *player, pspdef_t *psp)
return;

P_ShotAmmo(player);

if(IS_CLIENT)
return;

Expand All @@ -1640,7 +1644,6 @@ void C_DECL A_FireSkullRodPL1(player_t *player, pspdef_t *psp)
void C_DECL A_FireSkullRodPL2(player_t *player, pspdef_t *psp)
{
P_ShotAmmo(player);

if(IS_CLIENT)
return;

Expand Down Expand Up @@ -1901,6 +1904,7 @@ void C_DECL A_GauntletAttack(player_t *player, pspdef_t *psp)
int damage, randVal;
float slope, dist;

P_ShotAmmo(player);
psp->pos[VX] = ((P_Random() & 3) - 2);
psp->pos[VY] = WEAPONTOP + (P_Random() & 3);
angle = player->plr->mo->angle;
Expand Down
5 changes: 3 additions & 2 deletions doomsday/plugins/jhexen/src/p_pspr.c
Expand Up @@ -535,8 +535,9 @@ boolean P_CheckAmmo(player_t *plr)
P_MaybeChangeWeapon(plr, WT_NOCHANGE, AT_NOAMMO, false);

// Now set appropriate weapon overlay.
P_SetPsprite(plr, ps_weapon,
weaponInfo[plr->readyWeapon][plr->class].mode[0].downState);
if(player->pendingWeapon != WT_NOCHANGE)
P_SetPsprite(plr, ps_weapon, weaponInfo[plr->readyWeapon][plr->class].mode[0].downState);

return false;
}

Expand Down
19 changes: 17 additions & 2 deletions doomsday/plugins/wolftc/src/p_pspr.c
Expand Up @@ -188,7 +188,8 @@ boolean P_CheckAmmo(player_t *player)
P_MaybeChangeWeapon(player, WT_NOCHANGE, AT_NOAMMO, false);

// Now set appropriate weapon overlay.
P_SetPsprite(player, ps_weapon, weaponInfo[player->readyWeapon][player->class].mode[0].downState);
if(player->pendingWeapon != WT_NOCHANGE)
P_SetPsprite(player, ps_weapon, weaponInfo[player->readyWeapon][player->class].mode[0].downState);

return false;
}
Expand Down Expand Up @@ -397,6 +398,8 @@ void C_DECL A_Punch(player_t *player, pspdef_t * psp)
int damage;
float slope;

P_ShotAmmo(player);
player->update |= PSF_AMMO;
if(IS_CLIENT)
return;

Expand Down Expand Up @@ -428,6 +431,8 @@ void C_DECL A_Saw(player_t *player, pspdef_t *psp)
int damage;
float slope;

P_ShotAmmo(player);
player->update |= PSF_AMMO;
if(IS_CLIENT)
return;

Expand Down Expand Up @@ -913,6 +918,8 @@ void C_DECL A_Knife(player_t *player, pspdef_t *psp)
int damage;
float slope;

P_ShotAmmo(player);
player->update |= PSF_AMMO;
if(IS_CLIENT)
return;

Expand Down Expand Up @@ -1719,11 +1726,16 @@ void C_DECL A_FireCMissile2(player_t *player, pspdef_t * psp)
//
void C_DECL A_FireCMissile2NA(player_t *player, pspdef_t * psp)
{
P_ShotAmmo(player);

P_SetPsprite(player, ps_flash,
weaponInfo[player->readyWeapon][player->class].mode[0].flashState +
(P_Random() & 1));

player->update |= PSF_AMMO;
if(IS_CLIENT)
return;

P_SpawnMissile(MT_CATAPMISSILE2, player->plr->mo, NULL);
}

Expand All @@ -1733,10 +1745,13 @@ void C_DECL A_FireCMissile2NA(player_t *player, pspdef_t * psp)
//
void C_DECL A_FireCMissile3(player_t *player, pspdef_t * psp)
{

P_ShotAmmo(player);
P_SetPsprite(player, ps_flash,
weaponInfo[player->readyWeapon][player->class].mode[0].flashState +
(P_Random() & 1));
player->update |= PSF_AMMO;
if(IS_CLIENT)
return;

P_SpawnMissile(MT_CATAPMISSILE2, player->plr->mo, NULL);
}
Expand Down

0 comments on commit f226a90

Please sign in to comment.