From 7436505136de3c6b2034d80c53843ce214b82286 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Thu, 12 Jan 2006 17:05:09 +0000 Subject: * Fixed lcannon charge storage exploit * Fixed psaw/cgun inappropriate effects bug * Lcannon now has a minimum charge value --- src/cgame/cg_weapons.c | 9 ++++----- src/game/bg_pmove.c | 15 ++++++++++++++- src/game/bg_public.h | 2 ++ src/game/tremulous.h | 1 + 4 files changed, 21 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c index f37078f4..ecb2499b 100644 --- a/src/cgame/cg_weapons.c +++ b/src/cgame/cg_weapons.c @@ -742,7 +742,7 @@ CG_MachinegunSpinAngle */ #define SPIN_SPEED 0.9 #define COAST_TIME 1000 -static float CG_MachinegunSpinAngle( centity_t *cent ) +static float CG_MachinegunSpinAngle( centity_t *cent, qboolean firing ) { int delta; float angle; @@ -760,12 +760,11 @@ static float CG_MachinegunSpinAngle( centity_t *cent ) angle = cent->pe.barrelAngle + delta * speed; } - if( cent->pe.barrelSpinning == !( cent->currentState.eFlags & EF_FIRING ) ) + if( cent->pe.barrelSpinning == !firing ) { cent->pe.barrelTime = cg.time; cent->pe.barrelAngle = AngleMod( angle ); - cent->pe.barrelSpinning = !!( cent->currentState.eFlags & EF_FIRING ); - //TA: um? + cent->pe.barrelSpinning = firing; } return angle; @@ -876,7 +875,7 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent barrel.hModel = weapon->barrelModel; angles[ YAW ] = 0; angles[ PITCH ] = 0; - angles[ ROLL ] = CG_MachinegunSpinAngle( cent ); + angles[ ROLL ] = CG_MachinegunSpinAngle( cent, firing ); AnglesToAxis( angles, barrel.axis ); CG_PositionRotatedEntityOnTag( &barrel, &gun, weapon->weaponModel, "tag_barrel" ); diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c index 107d7929..a2a9f543 100644 --- a/src/game/bg_pmove.c +++ b/src/game/bg_pmove.c @@ -2601,6 +2601,10 @@ static void PM_BeginWeaponChange( int weapon ) if( pm->ps->weaponstate == WEAPON_DROPPING ) return; + //special case to prevent storing a charged up lcannon + if( pm->ps->weapon == WP_LUCIFER_CANNON ) + pm->ps->stats[ STAT_MISC ] = 0; + PM_AddEvent( EV_CHANGE_WEAPON ); pm->ps->weaponstate = WEAPON_DROPPING; pm->ps->weaponTime += 200; @@ -2865,8 +2869,15 @@ static void PM_Weapon( void ) } //erp this looks confusing - if( pm->ps->stats[ STAT_MISC ] > 0 ) + if( pm->ps->stats[ STAT_MISC ] > LCANNON_MIN_CHARGE ) attack1 = !attack1; + else if( pm->ps->stats[ STAT_MISC ] > 0 ) + { + pm->ps->stats[ STAT_MISC ] = 0; + pm->ps->weaponTime = 0; + pm->ps->weaponstate = WEAPON_READY; + return; + } break; default: @@ -2905,6 +2916,7 @@ static void PM_Weapon( void ) { pm->ps->weaponTime = 0; pm->ps->weaponstate = WEAPON_READY; + pm->ps->generic1 = WPM_NOTFIRING; return; } } @@ -2920,6 +2932,7 @@ static void PM_Weapon( void ) { pm->ps->weaponTime = 0; pm->ps->weaponstate = WEAPON_READY; + pm->ps->generic1 = WPM_NOTFIRING; return; } } diff --git a/src/game/bg_public.h b/src/game/bg_public.h index 6bcb0d4e..2fccdda8 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -331,6 +331,8 @@ typedef enum WPM_SECONDARY, WPM_TERTIARY, + WPM_NOTFIRING, + WPM_NUM_WEAPONMODES } weaponMode_t; diff --git a/src/game/tremulous.h b/src/game/tremulous.h index 8508a1e4..79eb67d5 100644 --- a/src/game/tremulous.h +++ b/src/game/tremulous.h @@ -408,6 +408,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define LCANNON_SPEED 350 #define LCANNON_CHARGE_TIME 2000 #define LCANNON_TOTAL_CHARGE 255 +#define LCANNON_MIN_CHARGE 50 #define HBUILD_PRICE 0 #define HBUILD_REPEAT 1000 -- cgit