From f226a90dbe9cde694feb61eca88554b3a3e0a60f Mon Sep 17 00:00:00 2001 From: danij Date: Fri, 11 Jul 2008 12:15:57 +0000 Subject: [PATCH] Fixed (all games): If weapon ammo requirements are edited in values.ded 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). --- doomsday/plugins/jdoom/src/p_pspr.c | 9 +++++++-- doomsday/plugins/jdoom64/src/p_pspr.c | 13 ++++++++----- doomsday/plugins/jheretic/src/p_pspr.c | 14 +++++++++----- doomsday/plugins/jhexen/src/p_pspr.c | 5 +++-- doomsday/plugins/wolftc/src/p_pspr.c | 19 +++++++++++++++++-- 5 files changed, 44 insertions(+), 16 deletions(-) diff --git a/doomsday/plugins/jdoom/src/p_pspr.c b/doomsday/plugins/jdoom/src/p_pspr.c index 538d04b728..973000904b 100644 --- a/doomsday/plugins/jdoom/src/p_pspr.c +++ b/doomsday/plugins/jdoom/src/p_pspr.c @@ -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. @@ -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; } @@ -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; @@ -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; diff --git a/doomsday/plugins/jdoom64/src/p_pspr.c b/doomsday/plugins/jdoom64/src/p_pspr.c index 35b89ec268..6f89e7452b 100644 --- a/doomsday/plugins/jdoom64/src/p_pspr.c +++ b/doomsday/plugins/jdoom64/src/p_pspr.c @@ -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; } @@ -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; @@ -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; @@ -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]) diff --git a/doomsday/plugins/jheretic/src/p_pspr.c b/doomsday/plugins/jheretic/src/p_pspr.c index 214cab715d..e1566288b9 100644 --- a/doomsday/plugins/jheretic/src/p_pspr.c +++ b/doomsday/plugins/jheretic/src/p_pspr.c @@ -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|" @@ -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; } @@ -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); @@ -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); @@ -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; @@ -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; @@ -1621,7 +1626,6 @@ void C_DECL A_FireSkullRodPL1(player_t *player, pspdef_t *psp) return; P_ShotAmmo(player); - if(IS_CLIENT) return; @@ -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; @@ -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; diff --git a/doomsday/plugins/jhexen/src/p_pspr.c b/doomsday/plugins/jhexen/src/p_pspr.c index 6fdf6ae511..d0d6f848d5 100644 --- a/doomsday/plugins/jhexen/src/p_pspr.c +++ b/doomsday/plugins/jhexen/src/p_pspr.c @@ -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; } diff --git a/doomsday/plugins/wolftc/src/p_pspr.c b/doomsday/plugins/wolftc/src/p_pspr.c index 3aa154d6f1..7ad6231de2 100644 --- a/doomsday/plugins/wolftc/src/p_pspr.c +++ b/doomsday/plugins/wolftc/src/p_pspr.c @@ -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; } @@ -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; @@ -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; @@ -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; @@ -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); } @@ -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); }