summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cgame/cg_main.c18
-rw-r--r--src/cgame/cg_weapons.c2
-rw-r--r--src/game/bg_misc.c91
-rw-r--r--src/game/bg_public.h9
-rw-r--r--src/game/g_client.c6
-rw-r--r--src/game/g_cmds.c25
-rw-r--r--src/game/g_main.c15
7 files changed, 75 insertions, 91 deletions
diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c
index 96362760..d48800fa 100644
--- a/src/cgame/cg_main.c
+++ b/src/cgame/cg_main.c
@@ -1423,6 +1423,18 @@ static clientInfo_t * CG_InfoFromScoreIndex( int index, int team, int *scoreInde
return &cgs.clientinfo[ cg.scores[ index ].client ];
}
+static qboolean CG_ClientIsReady( int clientNum )
+{
+ int val = clientNum / 4;
+ const char *s = CG_ConfigString( CS_CLIENTS_READY );
+ while( *s && val-- )
+ s++;
+ if( !*s )
+ return qfalse;
+ sscanf( s, "%1x", &val );
+ return ( ( val & ( clientNum % 4 ) ) != 0 );
+}
+
static const char *CG_FeederItemText( float feederID, int index, int column, qhandle_t *handle )
{
int scoreIndex = 0;
@@ -1441,8 +1453,7 @@ static const char *CG_FeederItemText( float feederID, int index, int column, qha
info = CG_InfoFromScoreIndex( index, team, &scoreIndex );
sp = &cg.scores[ scoreIndex ];
- if( ( atoi( CG_ConfigString( CS_CLIENTS_READY ) ) & ( 1 << sp->client ) ) &&
- cg.intermissionStarted )
+ if( cg.intermissionStarted && CG_ClientIsReady( sp->client ) )
showIcons = qfalse;
else if( cg.snap->ps.pm_type == PM_SPECTATOR || cg.snap->ps.pm_flags & PMF_FOLLOW ||
team == cg.snap->ps.stats[ STAT_TEAM ] || cg.intermissionStarted )
@@ -1484,8 +1495,7 @@ static const char *CG_FeederItemText( float feederID, int index, int column, qha
break;
case 2:
- if( ( atoi( CG_ConfigString( CS_CLIENTS_READY ) ) & ( 1 << sp->client ) ) &&
- cg.intermissionStarted )
+ if( cg.intermissionStarted && CG_ClientIsReady( sp->client ) )
return "Ready";
break;
diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c
index 414d3a89..55a0a2ff 100644
--- a/src/cgame/cg_weapons.c
+++ b/src/cgame/cg_weapons.c
@@ -2087,6 +2087,8 @@ void CG_Bleed( vec3_t origin, vec3_t normal, int entityNum )
bleedPS = cgs.media.alienBuildableBleedPS;
else if( team == TEAM_HUMANS )
bleedPS = cgs.media.humanBuildableBleedPS;
+ else
+ return;
}
else
return;
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c
index cbc0425c..db01881c 100644
--- a/src/game/bg_misc.c
+++ b/src/game/bg_misc.c
@@ -3088,55 +3088,53 @@ qboolean BG_WeaponIsFull( weapon_t weapon, int stats[ ], int ammo, int clips )
/*
========================
-BG_AddWeaponToInventory
+BG_InventoryContainsWeapon
-Give a player a weapon
+Does the player hold a weapon?
========================
*/
-void BG_AddWeaponToInventory( int weapon, int stats[ ] )
+qboolean BG_InventoryContainsWeapon( int weapon, int stats[ ] )
{
- if( weapon <= 15 )
- stats[ STAT_WEAPONS ] |= 1 << weapon;
- else
- stats[ STAT_WEAPONS2 ] |= 1 << ( weapon - 16 );
-
- if( stats[ STAT_SLOTS ] & BG_Weapon( weapon )->slots )
- Com_Printf( S_COLOR_YELLOW "WARNING: Held items conflict with weapon %d\n", weapon );
+ // humans always have a blaster
+ if( stats[ STAT_TEAM ] == TEAM_HUMANS && weapon == WP_BLASTER )
+ return qtrue;
- stats[ STAT_SLOTS ] |= BG_Weapon( weapon )->slots;
+ return ( stats[ STAT_WEAPON ] == weapon );
}
/*
========================
-BG_RemoveWeaponToInventory
+BG_SlotsForInventory
-Take a weapon from a player
+Calculate the slots used by an inventory and warn of conflicts
========================
*/
-void BG_RemoveWeaponFromInventory( int weapon, int stats[ ] )
+int BG_SlotsForInventory( int stats[ ] )
{
- if( weapon <= 15 )
- stats[ STAT_WEAPONS ] &= ~( 1 << weapon );
- else
- stats[ STAT_WEAPONS2 ] &= ~( 1 << ( weapon - 16 ) );
-
- stats[ STAT_SLOTS ] &= ~BG_Weapon( weapon )->slots;
-}
+ int i, slot, slots;
-/*
-========================
-BG_InventoryContainsWeapon
+ slots = BG_Weapon( stats[ STAT_WEAPON ] )->slots;
+ if( stats[ STAT_TEAM ] == TEAM_HUMANS )
+ slots |= BG_Weapon( WP_BLASTER )->slots;
-Does the player hold a weapon?
-========================
-*/
-qboolean BG_InventoryContainsWeapon( int weapon, int stats[ ] )
-{
- int weaponList;
+ for( i = UP_NONE; i < UP_NUM_UPGRADES; i++ )
+ {
+ if( BG_InventoryContainsUpgrade( i, stats ) )
+ {
+ slot = BG_Upgrade( i )->slots;
- weaponList = ( stats[ STAT_WEAPONS ] & 0x0000FFFF ) | ( ( stats[ STAT_WEAPONS2 ] << 16 ) & 0xFFFF0000 );
+ // this check should never be true
+ if( slots & slot )
+ {
+ Com_Printf( S_COLOR_YELLOW "WARNING: held item %d conflicts with "
+ "inventory slot %d\n", i, slot );
+ }
- return( weaponList & ( 1 << weapon ) );
+ slots |= slot;
+ }
+ }
+
+ return slots;
}
/*
@@ -3149,11 +3147,6 @@ Give the player an upgrade
void BG_AddUpgradeToInventory( int item, int stats[ ] )
{
stats[ STAT_ITEMS ] |= ( 1 << item );
-
- if( stats[ STAT_SLOTS ] & BG_Upgrade( item )->slots )
- Com_Printf( S_COLOR_YELLOW "WARNING: Held items conflict with upgrade %d\n", item );
-
- stats[ STAT_SLOTS ] |= BG_Upgrade( item )->slots;
}
/*
@@ -3166,8 +3159,6 @@ Take an upgrade from the player
void BG_RemoveUpgradeFromInventory( int item, int stats[ ] )
{
stats[ STAT_ITEMS ] &= ~( 1 << item );
-
- stats[ STAT_SLOTS ] &= ~BG_Upgrade( item )->slots;
}
/*
@@ -3415,28 +3406,6 @@ weapon_t BG_GetPlayerWeapon( playerState_t *ps )
}
/*
-=================
-BG_HasEnergyWeapon
-
-Returns true if the player has an energy weapon.
-=================
-*/
-qboolean BG_HasEnergyWeapon( playerState_t *ps )
-{
- int i;
-
- for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ )
- {
- if( !BG_InventoryContainsWeapon( i, ps->stats ) ||
- !BG_Weapon( i )->usesEnergy )
- continue;
-
- return qtrue;
- }
- return qfalse;
-}
-
-/*
===============
atof_neg
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index 4547bb80..b40863df 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -207,11 +207,9 @@ typedef enum
{
STAT_HEALTH,
STAT_ITEMS,
- STAT_SLOTS, // tracks the amount of stuff human players are carrying
STAT_ACTIVEITEMS,
- STAT_WEAPONS, // 16 bit fields
- STAT_WEAPONS2, // another 16 bits to push the max weapon count up
- STAT_MAX_HEALTH, // health / armor limit, changable by handicap
+ STAT_WEAPON, // current primary weapon
+ STAT_MAX_HEALTH,// health / armor limit, changable by handicap
STAT_CLASS, // player class (for aliens AND humans)
STAT_TEAM, // player team
STAT_STAMINA, // stamina (human only)
@@ -1087,9 +1085,8 @@ typedef struct
} upgradeAttributes_t;
qboolean BG_WeaponIsFull( weapon_t weapon, int stats[ ], int ammo, int clips );
-void BG_AddWeaponToInventory( int weapon, int stats[ ] );
-void BG_RemoveWeaponFromInventory( int weapon, int stats[ ] );
qboolean BG_InventoryContainsWeapon( int weapon, int stats[ ] );
+int BG_SlotsForInventory( int stats[ ] );
void BG_AddUpgradeToInventory( int item, int stats[ ] );
void BG_RemoveUpgradeFromInventory( int item, int stats[ ] );
qboolean BG_InventoryContainsUpgrade( int item, int stats[ ] );
diff --git a/src/game/g_client.c b/src/game/g_client.c
index 6320df2f..1582a606 100644
--- a/src/game/g_client.c
+++ b/src/game/g_client.c
@@ -1437,9 +1437,6 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles
// calculate each client's acceleration
ent->evaluateAcceleration = qtrue;
- client->ps.stats[ STAT_WEAPONS ] = 0;
- client->ps.stats[ STAT_WEAPONS2 ] = 0;
- client->ps.stats[ STAT_SLOTS ] = 0;
client->ps.stats[ STAT_MISC ] = 0;
client->ps.eFlags = flags;
@@ -1456,7 +1453,6 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles
// clear entity values
if( ent->client->pers.classSelection == PCL_HUMAN )
{
- BG_AddWeaponToInventory( WP_BLASTER, client->ps.stats );
BG_AddUpgradeToInventory( UP_MEDKIT, client->ps.stats );
weapon = client->pers.humanItemSelection;
}
@@ -1467,7 +1463,7 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles
maxAmmo = BG_Weapon( weapon )->maxAmmo;
maxClips = BG_Weapon( weapon )->maxClips;
- BG_AddWeaponToInventory( weapon, client->ps.stats );
+ client->ps.stats[ STAT_WEAPON ] = weapon;
client->ps.ammo = maxAmmo;
client->ps.clips = maxClips;
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 82d3828d..57b43c85 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -2078,8 +2078,9 @@ Cmd_Buy_f
void Cmd_Buy_f( gentity_t *ent )
{
char s[ MAX_TOKEN_CHARS ];
- int weapon, upgrade, maxAmmo, maxClips;
- qboolean energyOnly;
+ weapon_t weapon;
+ upgrade_t upgrade, maxAmmo, maxClips;
+ qboolean energyOnly;
trap_Argv( 1, s, sizeof( s ) );
@@ -2089,7 +2090,8 @@ void Cmd_Buy_f( gentity_t *ent )
// Only give energy from reactors or repeaters
if( G_BuildableRange( ent->client->ps.origin, 100, BA_H_ARMOURY ) )
energyOnly = qfalse;
- else if( upgrade == UP_AMMO && BG_HasEnergyWeapon( &ent->client->ps ) &&
+ else if( upgrade == UP_AMMO &&
+ BG_Weapon( ent->client->ps.stats[ STAT_WEAPON ] )->usesEnergy &&
( G_BuildableRange( ent->client->ps.origin, 100, BA_H_REACTOR ) ||
G_BuildableRange( ent->client->ps.origin, 100, BA_H_REPEATER ) ) )
energyOnly = qtrue;
@@ -2141,7 +2143,7 @@ void Cmd_Buy_f( gentity_t *ent )
}
//have space to carry this?
- if( BG_Weapon( weapon )->slots & ent->client->ps.stats[ STAT_SLOTS ] )
+ if( BG_Weapon( weapon )->slots & BG_SlotsForInventory( ent->client->ps.stats ) )
{
G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOSLOTS );
return;
@@ -2151,8 +2153,7 @@ void Cmd_Buy_f( gentity_t *ent )
if( !BG_PlayerCanChangeWeapon( &ent->client->ps ) )
return;
- //add to inventory
- BG_AddWeaponToInventory( weapon, ent->client->ps.stats );
+ ent->client->ps.stats[ STAT_WEAPON ] = weapon;
maxAmmo = BG_Weapon( weapon )->maxAmmo;
maxClips = BG_Weapon( weapon )->maxClips;
@@ -2188,7 +2189,7 @@ void Cmd_Buy_f( gentity_t *ent )
}
//have space to carry this?
- if( BG_Upgrade( upgrade )->slots & ent->client->ps.stats[ STAT_SLOTS ] )
+ if( BG_Upgrade( upgrade )->slots & BG_SlotsForInventory( ent->client->ps.stats ) )
{
G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOSLOTS );
return;
@@ -2273,7 +2274,11 @@ void Cmd_Sell_f( gentity_t *ent )
return;
}
- weapon = BG_WeaponByName( s )->number;
+ if( !Q_stricmpn( s, "weapon", 6 ) )
+ weapon = ent->client->ps.stats[ STAT_WEAPON ];
+ else
+ weapon = BG_WeaponByName( s )->number;
+
upgrade = BG_UpgradeByName( s )->number;
if( weapon != WP_NONE )
@@ -2300,7 +2305,7 @@ void Cmd_Sell_f( gentity_t *ent )
return;
}
- BG_RemoveWeaponFromInventory( weapon, ent->client->ps.stats );
+ ent->client->ps.stats[ STAT_WEAPON ] = WP_NONE;
//add to funds
G_AddCreditToClient( ent->client, (short)BG_Weapon( weapon )->price, qfalse );
@@ -2366,7 +2371,7 @@ void Cmd_Sell_f( gentity_t *ent )
if( BG_InventoryContainsWeapon( i, ent->client->ps.stats ) &&
BG_Weapon( i )->purchasable )
{
- BG_RemoveWeaponFromInventory( i, ent->client->ps.stats );
+ ent->client->ps.stats[ STAT_WEAPON ] = WP_NONE;
//add to funds
G_AddCreditToClient( ent->client, (short)BG_Weapon( i )->price, qfalse );
diff --git a/src/game/g_main.c b/src/game/g_main.c
index bcda98ab..0c8aa33f 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -1788,7 +1788,9 @@ void CheckIntermissionExit( void )
int ready, notReady, numPlayers;
int i;
gclient_t *cl;
- int readyMask;
+ byte readyMasks[ ( MAX_CLIENTS + 7 ) / 8 ];
+ char readyString[ 2 * sizeof( readyMasks ) + 1 ];
+ int index;
//if no clients are connected, just exit
if( !level.numConnectedClients )
@@ -1800,8 +1802,8 @@ void CheckIntermissionExit( void )
// see which players are ready
ready = 0;
notReady = 0;
- readyMask = 0;
numPlayers = 0;
+ Com_Memset( readyMasks, 0, sizeof( readyMasks ) );
for( i = 0; i < g_maxclients.integer; i++ )
{
cl = level.clients + i;
@@ -1814,8 +1816,7 @@ void CheckIntermissionExit( void )
if( cl->readyToExit )
{
ready++;
- if( i < 16 )
- readyMask |= 1 << i;
+ readyMasks[ i / 8 ] |= 1 << ( 7 - ( i % 8 ) );
}
else
notReady++;
@@ -1823,7 +1824,11 @@ void CheckIntermissionExit( void )
numPlayers++;
}
- trap_SetConfigstring( CS_CLIENTS_READY, va( "%d", readyMask ) );
+ for( i = 0; i < sizeof( readyMasks ); i++ )
+ Com_sprintf( &readyString[ i * 2 ], sizeof( readyString ) - i * 2,
+ "%2.2x", readyMasks[ i ] );
+
+ trap_SetConfigstring( CS_CLIENTS_READY, readyString );
// never exit in less than five seconds
if( level.time < level.intermissiontime + 5000 )