summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cgame/cg_draw.c6
-rw-r--r--src/cgame/cg_main.c9
-rw-r--r--src/cgame/cg_weapons.c5
-rw-r--r--src/game/bg_misc.c37
-rw-r--r--src/game/bg_public.h1
-rw-r--r--src/game/g_active.c2
-rw-r--r--src/game/g_client.c13
-rw-r--r--src/game/g_cmds.c32
-rw-r--r--src/game/g_trigger.c2
-rw-r--r--src/game/g_weapon.c65
10 files changed, 42 insertions, 130 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c
index cc3ab830..42811ef7 100644
--- a/src/cgame/cg_draw.c
+++ b/src/cgame/cg_draw.c
@@ -636,7 +636,7 @@ static void CG_DrawPlayerAmmoValue( rectDef_t *rect, vec4_t color )
int valueMarked = -1;
qboolean bp = qfalse;
- switch( BG_PrimaryWeapon( cg.snap->ps.stats ) )
+ switch( cg.snap->ps.stats[ STAT_WEAPON ] )
{
case WP_NONE:
case WP_BLASTER:
@@ -776,7 +776,7 @@ static void CG_DrawPlayerBuildTimer( rectDef_t *rect, vec4_t color )
if( ps->stats[ STAT_MISC ] <= 0 )
return;
- switch( BG_PrimaryWeapon( ps->stats ) )
+ switch( ps->stats[ STAT_WEAPON ] )
{
case WP_ABUILD:
case WP_ABUILD2:
@@ -812,7 +812,7 @@ static void CG_DrawPlayerClipsValue( rectDef_t *rect, vec4_t color )
int value;
playerState_t *ps = &cg.snap->ps;
- switch( BG_PrimaryWeapon( ps->stats ) )
+ switch( ps->stats[ STAT_WEAPON ] )
{
case WP_NONE:
case WP_BLASTER:
diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c
index fd2d258f..8680aeca 100644
--- a/src/cgame/cg_main.c
+++ b/src/cgame/cg_main.c
@@ -400,12 +400,9 @@ static void CG_SetUIVars( void )
*carriageCvar = 0;
//determine what the player is carrying
- for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ )
- {
- if( BG_InventoryContainsWeapon( i, cg.snap->ps.stats ) &&
- BG_Weapon( i )->purchasable )
- strcat( carriageCvar, va( "W%d ", i ) );
- }
+ if( BG_Weapon( cg.snap->ps.stats[ STAT_WEAPON ] )->purchasable )
+ strcat( carriageCvar, va( "W%d ", cg.snap->ps.stats[ STAT_WEAPON ] ) );
+
for( i = UP_NONE + 1; i < UP_NUM_UPGRADES; i++ )
{
if( BG_InventoryContainsUpgrade( i, cg.snap->ps.stats ) &&
diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c
index 0d50e421..6d09d3d9 100644
--- a/src/cgame/cg_weapons.c
+++ b/src/cgame/cg_weapons.c
@@ -1353,10 +1353,7 @@ CG_WeaponSelectable
*/
static qboolean CG_WeaponSelectable( weapon_t weapon )
{
- if( !BG_InventoryContainsWeapon( weapon, cg.snap->ps.stats ) )
- return qfalse;
-
- return qtrue;
+ return BG_InventoryContainsWeapon( weapon, cg.snap->ps.stats );
}
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c
index c6412327..cc1fcc62 100644
--- a/src/game/bg_misc.c
+++ b/src/game/bg_misc.c
@@ -3338,26 +3338,24 @@ Returns the credit value of a player
*/
int BG_GetValueOfPlayer( playerState_t *ps )
{
- int i, worth = 0;
-
+ int worth = 0;
+
worth = BG_Class( ps->stats[ STAT_CLASS ] )->value;
// Humans have worth from their equipment as well
if( ps->stats[ STAT_TEAM ] == TEAM_HUMANS )
{
+ upgrade_t i;
for( i = UP_NONE + 1; i < UP_NUM_UPGRADES; i++ )
{
if( BG_InventoryContainsUpgrade( i, ps->stats ) )
worth += BG_Upgrade( i )->price;
}
- for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ )
- {
- if( BG_InventoryContainsWeapon( i, ps->stats ) )
- worth += BG_Weapon( i )->price;
- }
+ if( ps->stats[ STAT_WEAPON ] != WP_NONE )
+ worth += BG_Weapon( ps->stats[ STAT_WEAPON ] )->price;
}
-
+
return worth;
}
@@ -3828,29 +3826,6 @@ qboolean BG_BuildableIsAllowed( buildable_t buildable )
/*
============
-BG_PrimaryWeapon
-============
-*/
-weapon_t BG_PrimaryWeapon( int stats[ ] )
-{
- int i;
-
- for( i = WP_NONE; i < WP_NUM_WEAPONS; i++ )
- {
- if( BG_Weapon( i )->slots != SLOT_WEAPON )
- continue;
- if( BG_InventoryContainsWeapon( i, stats ) )
- return i;
- }
-
- if( BG_InventoryContainsWeapon( WP_BLASTER, stats ) )
- return WP_BLASTER;
-
- return WP_NONE;
-}
-
-/*
-============
BG_LoadEmoticons
============
*/
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index 08436dd0..17f7bb61 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -1242,7 +1242,6 @@ qboolean BG_WeaponIsAllowed( weapon_t weapon );
qboolean BG_UpgradeIsAllowed( upgrade_t upgrade );
qboolean BG_ClassIsAllowed( class_t class );
qboolean BG_BuildableIsAllowed( buildable_t buildable );
-weapon_t BG_PrimaryWeapon( int stats[ ] );
// Friendly Fire Flags
#define FFF_HUMANS 1
diff --git a/src/game/g_active.c b/src/game/g_active.c
index edd57a6a..021f1299 100644
--- a/src/game/g_active.c
+++ b/src/game/g_active.c
@@ -606,7 +606,7 @@ void ClientTimerActions( gentity_t *ent, int msec )
client->ps.stats[ STAT_STAMINA ] = -STAMINA_MAX;
if( weapon == WP_ABUILD || weapon == WP_ABUILD2 ||
- BG_InventoryContainsWeapon( WP_HBUILD, client->ps.stats ) )
+ client->ps.stats[ STAT_WEAPON ] == WP_HBUILD )
{
// Update build timer
if( client->ps.stats[ STAT_MISC ] > 0 )
diff --git a/src/game/g_client.c b/src/game/g_client.c
index 96b16c3d..cc271890 100644
--- a/src/game/g_client.c
+++ b/src/game/g_client.c
@@ -1484,18 +1484,7 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles
if( !spawn )
G_UseTargets( spawnPoint, ent );
- // select the highest weapon number available, after any
- // spawn given items have fired
- client->ps.weapon = 1;
-
- for( i = WP_NUM_WEAPONS - 1; i > 0 ; i-- )
- {
- if( BG_InventoryContainsWeapon( i, client->ps.stats ) )
- {
- client->ps.weapon = i;
- break;
- }
- }
+ client->ps.weapon = client->ps.stats[ STAT_WEAPON ];
}
// run a client frame to drop exactly to the floor,
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 5299af18..171df605 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -1089,7 +1089,7 @@ void Cmd_VSay_f( gentity_t *ent )
weapon = WP_NONE;
if( ent->client->sess.spectatorState == SPECTATOR_NOT )
{
- weapon = BG_PrimaryWeapon( ent->client->ps.stats );
+ weapon = ent->client->ps.stats[ STAT_WEAPON ];
}
track = BG_VoiceTrackFind( cmd->tracks, ent->client->pers.teamSelection,
@@ -2350,36 +2350,6 @@ void Cmd_Sell_f( gentity_t *ent )
G_AddCreditToClient( ent->client, (short)BG_Upgrade( upgrade )->price, qfalse );
}
}
- else if( !Q_stricmp( s, "weapons" ) )
- {
- weapon_t selected = BG_GetPlayerWeapon( &ent->client->ps );
-
- if( !BG_PlayerCanChangeWeapon( &ent->client->ps ) )
- return;
-
- for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ )
- {
- //guard against selling the HBUILD weapons exploit
- if( i == WP_HBUILD && ent->client->ps.stats[ STAT_MISC ] > 0 )
- {
- G_TriggerMenu( ent->client->ps.clientNum, MN_H_ARMOURYBUILDTIMER );
- continue;
- }
-
- if( BG_InventoryContainsWeapon( i, ent->client->ps.stats ) &&
- BG_Weapon( i )->purchasable )
- {
- ent->client->ps.stats[ STAT_WEAPON ] = WP_NONE;
-
- //add to funds
- G_AddCreditToClient( ent->client, (short)BG_Weapon( i )->price, qfalse );
- }
-
- //if we have this weapon selected, force a new selection
- if( i == selected )
- G_ForceWeaponChange( ent, WP_NONE );
- }
- }
else if( !Q_stricmp( s, "upgrades" ) )
{
for( i = UP_NONE + 1; i < UP_NUM_UPGRADES; i++ )
diff --git a/src/game/g_trigger.c b/src/game/g_trigger.c
index 65bf1bd1..b3d21860 100644
--- a/src/game/g_trigger.c
+++ b/src/game/g_trigger.c
@@ -1097,7 +1097,7 @@ void trigger_ammo_touch( gentity_t *self, gentity_t *other, trace_t *trace )
if( other->client->ps.weaponstate != WEAPON_READY )
return;
- weapon = BG_PrimaryWeapon( other->client->ps.stats );
+ weapon = other->client->ps.stats[ STAT_WEAPON ];
if( BG_Weapon( weapon )->usesEnergy && self->spawnflags & 2 )
return;
diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c
index 19a6c4ca..a359a0f3 100644
--- a/src/game/g_weapon.c
+++ b/src/game/g_weapon.c
@@ -45,16 +45,9 @@ void G_ForceWeaponChange( gentity_t *ent, weapon_t weapon )
ps->weaponTime = 250;
ps->weaponstate = WEAPON_READY;
}
-
- if( weapon == WP_NONE ||
- !BG_InventoryContainsWeapon( weapon, ps->stats ) )
- {
- // switch to the first non blaster weapon
- ps->persistant[ PERS_NEWWEAPON ] =
- BG_PrimaryWeapon( ent->client->ps.stats );
- }
- else
- ps->persistant[ PERS_NEWWEAPON ] = weapon;
+
+ ps->persistant[ PERS_NEWWEAPON ] = ( weapon == WP_BLASTER ) ?
+ WP_BLASTER : ps->stats[ STAT_WEAPON ];
// force this here to prevent flamer effect from continuing
ps->generic1 = WPM_NOTFIRING;
@@ -70,42 +63,34 @@ G_GiveClientMaxAmmo
*/
void G_GiveClientMaxAmmo( gentity_t *ent, qboolean buyingEnergyAmmo )
{
- int i, maxAmmo, maxClips;
- qboolean restoredAmmo = qfalse, restoredEnergy = qfalse;
+ int maxAmmo;
+ weapon_t weapon = ent->client->ps.stats[ STAT_WEAPON ];
- for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ )
- {
- qboolean energyWeapon;
-
- energyWeapon = BG_Weapon( i )->usesEnergy;
- if( !BG_InventoryContainsWeapon( i, ent->client->ps.stats ) ||
- BG_Weapon( i )->infiniteAmmo ||
- BG_WeaponIsFull( i, ent->client->ps.stats,
- ent->client->ps.ammo, ent->client->ps.clips ) ||
- ( buyingEnergyAmmo && !energyWeapon ) )
- continue;
-
- maxAmmo = BG_Weapon( i )->maxAmmo;
- maxClips = BG_Weapon( i )->maxClips;
-
- // Apply battery pack modifier
- if( energyWeapon &&
- BG_InventoryContainsUpgrade( UP_BATTPACK, ent->client->ps.stats ) )
- {
- maxAmmo *= BATTPACK_MODIFIER;
- restoredEnergy = qtrue;
- }
+ if( BG_Weapon( weapon )->infiniteAmmo )
+ return;
- ent->client->ps.ammo = maxAmmo;
- ent->client->ps.clips = maxClips;
+ if( buyingEnergyAmmo && !BG_Weapon( weapon )->usesEnergy )
+ return;
- restoredAmmo = qtrue;
+ if( BG_WeaponIsFull( weapon, ent->client->ps.stats, ent->client->ps.ammo,
+ ent->client->ps.clips ) )
+ return;
+
+ maxAmmo = BG_Weapon( weapon )->maxAmmo;
+
+ // Apply battery pack modifier
+ if( BG_Weapon( weapon )->usesEnergy &&
+ BG_InventoryContainsUpgrade( UP_BATTPACK, ent->client->ps.stats ) )
+ {
+ maxAmmo *= BATTPACK_MODIFIER;
}
- if( restoredAmmo )
- G_ForceWeaponChange( ent, ent->client->ps.weapon );
+ ent->client->ps.ammo = maxAmmo;
+ ent->client->ps.clips = BG_Weapon( weapon )->maxClips;
+
+ G_ForceWeaponChange( ent, ent->client->ps.weapon );
- if( restoredEnergy )
+ if( BG_Weapon( weapon )->usesEnergy )
G_AddEvent( ent, EV_RPTUSE_SOUND, 0 );
}