summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTony J. White <tjw@tjw.org>2009-10-03 11:43:44 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:15:17 +0000
commit82ef46c4c099fbfed24fa326ee6f501ad5535a30 (patch)
treeb5ab9c14e5d174721863fe37a35ab168e30d5f03 /src
parentd50e12bb38f69124416033039f8084b2bc11f972 (diff)
* add a new function BG_PrimaryWeapon() that returns the "primary"
weapon in a player's inventory * when changing classes by buying/selling bsuit, keep pers.classSelection in sync
Diffstat (limited to 'src')
-rw-r--r--src/game/bg_misc.c21
-rw-r--r--src/game/g_cmds.c2
2 files changed, 23 insertions, 0 deletions
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c
index 5177957c..06b85773 100644
--- a/src/game/bg_misc.c
+++ b/src/game/bg_misc.c
@@ -3864,3 +3864,24 @@ void BG_ClientListParse( clientList_t *list, const char *s )
sscanf( s, "%x%x", &list->hi, &list->lo );
}
+/*
+============
+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;
+}
+
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 755356b1..88baf39c 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -2088,6 +2088,7 @@ void Cmd_Buy_f( gentity_t *ent )
}
VectorCopy( newOrigin, ent->s.pos.trBase );
ent->client->ps.stats[ STAT_CLASS ] = PCL_HUMAN_BSUIT;
+ ent->client->pers.classSelection = PCL_HUMAN_BSUIT;
ent->client->ps.eFlags ^= EF_TELEPORT_BIT;
}
@@ -2190,6 +2191,7 @@ void Cmd_Sell_f( gentity_t *ent )
}
VectorCopy( newOrigin, ent->s.pos.trBase );
ent->client->ps.stats[ STAT_CLASS ] = PCL_HUMAN;
+ ent->client->pers.classSelection = PCL_HUMAN;
ent->client->ps.eFlags ^= EF_TELEPORT_BIT;
}