diff options
author | /dev/humancontroller <devhc@example.com> | 2017-04-13 11:30:00 +0000 |
---|---|---|
committer | /dev/humancontroller <devhc@example.com> | 2017-04-15 17:24:17 +0200 |
commit | 8cf1bba6ff535d76377b9cbb891d2ff1798648ab (patch) | |
tree | edc5a6627e45e74449c4608c322166572c3e9d03 /src/game | |
parent | 96aae565da71018d0273a2ba5ade60c95d30141b (diff) |
port bugfixes related to weapon reloading from the modern codebase
- fix the continuous blaster re-reraising bug when the primary weapon is out of ammo
- fix the reload requests sticking until a reloadable weapon is raised
- immediately interrupt a reload process when switching
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/bg_pmove.c | 7 | ||||
-rw-r--r-- | src/game/g_weapon.c | 63 |
2 files changed, 41 insertions, 29 deletions
diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c index 73ee6d9..c54fba0 100644 --- a/src/game/bg_pmove.c +++ b/src/game/bg_pmove.c @@ -2618,6 +2618,10 @@ static void PM_BeginWeaponChange( int weapon ) if( pm->ps->weapon == WP_LUCIFER_CANNON ) pm->ps->stats[ STAT_MISC ] = 0; + // cancel a reload + pm->ps->pm_flags &= ~PMF_WEAPON_RELOAD; + if( pm->ps->weaponstate == WEAPON_RELOADING ) + pm->ps->weaponTime = 0; // force this here to prevent flamer effect from continuing, among other issues pm->ps->generic1 = WPM_NOTFIRING; @@ -2836,7 +2840,8 @@ static void PM_Weapon( void ) } // check for end of clip - if( ( !ammo || pm->ps->pm_flags & PMF_WEAPON_RELOAD ) && clips ) + if( !BG_FindInfinteAmmoForWeapon( pm->ps->weapon ) && + ( !ammo || pm->ps->pm_flags & PMF_WEAPON_RELOAD ) && clips ) { pm->ps->pm_flags &= ~PMF_WEAPON_RELOAD; diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c index 7d3449e..3240df1 100644 --- a/src/game/g_weapon.c +++ b/src/game/g_weapon.c @@ -38,42 +38,49 @@ void G_ForceWeaponChange( gentity_t *ent, weapon_t weapon ) { int i; - if( ent ) + if( !ent ) + return; + + if( ent->client->ps.weaponstate == WEAPON_RELOADING ) { - ent->client->ps.pm_flags |= PMF_WEAPON_SWITCH; + ent->client->ps.torsoAnim = ( ( ent->client->ps.torsoAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | TORSO_RAISE; + ent->client->ps.weaponTime = 250; + ent->client->ps.weaponstate = WEAPON_READY; + } - if( weapon == WP_NONE - || !BG_InventoryContainsWeapon( weapon, ent->client->ps.stats )) + ent->client->ps.pm_flags |= PMF_WEAPON_SWITCH; + + if( weapon == WP_NONE + || !BG_InventoryContainsWeapon( weapon, ent->client->ps.stats )) + { + //switch to the first non blaster weapon + for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ ) { - //switch to the first non blaster weapon - for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ ) - { - if( i == WP_BLASTER ) - continue; + if( i == WP_BLASTER ) + continue; - if( BG_InventoryContainsWeapon( i, ent->client->ps.stats ) ) - { - ent->client->ps.persistant[ PERS_NEWWEAPON ] = i; - break; - } + if( BG_InventoryContainsWeapon( i, ent->client->ps.stats ) ) + { + ent->client->ps.persistant[ PERS_NEWWEAPON ] = i; + break; } - - //only got the blaster to switch to - if( i == WP_NUM_WEAPONS ) - ent->client->ps.persistant[ PERS_NEWWEAPON ] = WP_BLASTER; } - else - ent->client->ps.persistant[ PERS_NEWWEAPON ] = weapon; - - // Lak: The following hack has been moved to PM_BeginWeaponChange, but I'm going to - // redundantly leave it here as well just in case there's a case I'm forgetting - // because I don't want to face the gameplay consequences such an error would have - - // force this here to prevent flamer effect from continuing - ent->client->ps.generic1 = WPM_NOTFIRING; - ent->client->ps.weapon = ent->client->ps.persistant[ PERS_NEWWEAPON ]; + //only got the blaster to switch to + if( i == WP_NUM_WEAPONS ) + ent->client->ps.persistant[ PERS_NEWWEAPON ] = WP_BLASTER; } + else + ent->client->ps.persistant[ PERS_NEWWEAPON ] = weapon; + + // Lak: The following hack has been moved to PM_BeginWeaponChange, but I'm going to + // redundantly leave it here as well just in case there's a case I'm forgetting + // because I don't want to face the gameplay consequences such an error would have + + // force this here to prevent flamer effect from continuing + ent->client->ps.generic1 = WPM_NOTFIRING; + + ent->client->ps.weapon = ent->client->ps.persistant[ PERS_NEWWEAPON ]; } /* |