From 82ef46c4c099fbfed24fa326ee6f501ad5535a30 Mon Sep 17 00:00:00 2001 From: "Tony J. White" Date: Sat, 3 Oct 2009 11:43:44 +0000 Subject: * 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 --- src/game/bg_misc.c | 21 +++++++++++++++++++++ src/game/g_cmds.c | 2 ++ 2 files changed, 23 insertions(+) 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; } -- cgit