summaryrefslogtreecommitdiff
path: root/src/game/g_cmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/g_cmds.c')
-rw-r--r--src/game/g_cmds.c116
1 files changed, 59 insertions, 57 deletions
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 89183be0..755356b1 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -385,12 +385,13 @@ void Cmd_Give_f( gentity_t *ent )
gclient_t *client = ent->client;
if( client->ps.weapon != WP_ALEVEL3_UPG &&
- BG_FindInfinteAmmoForWeapon( client->ps.weapon ) )
+ BG_Weapon( client->ps.weapon )->infiniteAmmo )
return;
- BG_FindAmmoForWeapon( client->ps.weapon, &maxAmmo, &maxClips );
+ maxAmmo = BG_Weapon( client->ps.weapon )->maxAmmo;
+ maxClips = BG_Weapon( client->ps.weapon )->maxClips;
- if( BG_FindUsesEnergyForWeapon( client->ps.weapon ) &&
+ if( BG_Weapon( client->ps.weapon )->usesEnergy &&
BG_InventoryContainsUpgrade( UP_BATTPACK, client->ps.stats ) )
maxAmmo = (int)( (float)maxAmmo * BATTPACK_MODIFIER );
@@ -1461,8 +1462,8 @@ static qboolean G_RoomForClassChange( gentity_t *ent, class_t class, vec3_t newO
float maxHorizGrowth;
class_t oldClass = ent->client->ps.stats[ STAT_CLASS ];
- BG_FindBBoxForClass( oldClass, fromMins, fromMaxs, NULL, NULL, NULL );
- BG_FindBBoxForClass( class, toMins, toMaxs, NULL, NULL, NULL );
+ BG_ClassBoundingBox( oldClass, fromMins, fromMaxs, NULL, NULL, NULL );
+ BG_ClassBoundingBox( class, toMins, toMaxs, NULL, NULL, NULL );
VectorCopy( ent->s.origin, newOrigin );
@@ -1529,7 +1530,7 @@ void Cmd_Class_f( gentity_t *ent )
clientNum = ent->client - level.clients;
trap_Argv( 1, s, sizeof( s ) );
- newClass = BG_FindClassNumForName( s );
+ newClass = BG_ClassByName( s )->number;
if( ent->client->sess.spectatorState != SPECTATOR_NOT )
{
@@ -1551,7 +1552,7 @@ void Cmd_Class_f( gentity_t *ent )
return;
}
- if( !BG_FindStagesForClass( newClass, g_alienStage.integer ) )
+ if( !BG_ClassAllowedInStage( newClass, g_alienStage.integer ) )
{
G_TriggerMenu2( ent->client->ps.clientNum, MN_A_CLASSNOTATSTAGE, newClass );
return;
@@ -1567,12 +1568,12 @@ void Cmd_Class_f( gentity_t *ent )
else if( ent->client->pers.teamSelection == TEAM_HUMANS )
{
//set the item to spawn with
- if( !Q_stricmp( s, BG_FindNameForWeapon( WP_MACHINEGUN ) ) &&
+ if( !Q_stricmp( s, BG_Weapon( WP_MACHINEGUN )->name ) &&
BG_WeaponIsAllowed( WP_MACHINEGUN ) )
{
ent->client->pers.humanItemSelection = WP_MACHINEGUN;
}
- else if( !Q_stricmp( s, BG_FindNameForWeapon( WP_HBUILD ) ) &&
+ else if( !Q_stricmp( s, BG_Weapon( WP_HBUILD )->name ) &&
BG_WeaponIsAllowed( WP_HBUILD ) )
{
ent->client->pers.humanItemSelection = WP_HBUILD;
@@ -1661,7 +1662,7 @@ void Cmd_Class_f( gentity_t *ent )
int oldBoostTime = -1;
ent->client->pers.evolveHealthFraction = (float)ent->client->ps.stats[ STAT_HEALTH ] /
- (float)BG_FindHealthForClass( currentClass );
+ (float)BG_Class( currentClass )->health;
if( ent->client->pers.evolveHealthFraction < 0.0f )
ent->client->pers.evolveHealthFraction = 0.0f;
@@ -1780,9 +1781,7 @@ void Cmd_Destroy_f( gentity_t *ent )
// Don't allow destruction of buildables that cannot be rebuilt
if( G_TimeTilSuddenDeath( ) <= 0 )
- {
return;
- }
if( !g_markDeconstruct.integer && ent->client->ps.stats[ STAT_MISC ] > 0 )
{
@@ -1803,14 +1802,14 @@ void Cmd_Destroy_f( gentity_t *ent )
{
G_TeamCommand( ent->client->pers.teamSelection,
va( "print \"%s ^3DECONSTRUCTED^7 by %s^7\n\"",
- BG_FindHumanNameForBuildable( traceEnt->s.modelindex ),
+ BG_Buildable( traceEnt->s.modelindex )->humanName,
ent->client->pers.netname ) );
G_LogPrintf( "Decon: %i %i 0: %s deconstructed %s\n",
ent->client->ps.clientNum,
traceEnt->s.modelindex,
ent->client->pers.netname,
- BG_FindNameForBuildable( traceEnt->s.modelindex ) );
+ BG_Buildable( traceEnt->s.modelindex )->humanName );
G_Damage( traceEnt, ent, ent, forward, tr.endpos, ent->health, 0, MOD_SUICIDE );
G_FreeEntity( traceEnt );
@@ -1819,7 +1818,7 @@ void Cmd_Destroy_f( gentity_t *ent )
if( !g_cheats.integer )
{
ent->client->ps.stats[ STAT_MISC ] +=
- BG_FindBuildTimeForBuildable( traceEnt->s.modelindex );
+ BG_Buildable( traceEnt->s.modelindex )->buildTime;
}
}
}
@@ -1849,8 +1848,8 @@ void Cmd_ActivateItem_f( gentity_t *ent )
return;
}
- upgrade = BG_FindUpgradeNumForName( s );
- weapon = BG_FindWeaponNumForName( s );
+ upgrade = BG_UpgradeByName( s )->number;
+ weapon = BG_WeaponByName( s )->number;
if( upgrade != UP_NONE && BG_InventoryContainsUpgrade( upgrade, ent->client->ps.stats ) )
BG_ActivateUpgrade( upgrade, ent->client->ps.stats );
@@ -1875,11 +1874,11 @@ Deactivate an item
*/
void Cmd_DeActivateItem_f( gentity_t *ent )
{
- char s[ MAX_TOKEN_CHARS ];
- int upgrade;
+ char s[ MAX_TOKEN_CHARS ];
+ upgrade_t upgrade;
trap_Argv( 1, s, sizeof( s ) );
- upgrade = BG_FindUpgradeNumForName( s );
+ upgrade = BG_UpgradeByName( s )->number;
if( BG_InventoryContainsUpgrade( upgrade, ent->client->ps.stats ) )
BG_DeactivateUpgrade( upgrade, ent->client->ps.stats );
@@ -1895,12 +1894,13 @@ Cmd_ToggleItem_f
*/
void Cmd_ToggleItem_f( gentity_t *ent )
{
- char s[ MAX_TOKEN_CHARS ];
- int upgrade, weapon;
+ char s[ MAX_TOKEN_CHARS ];
+ weapon_t weapon;
+ upgrade_t upgrade;
trap_Argv( 1, s, sizeof( s ) );
- upgrade = BG_FindUpgradeNumForName( s );
- weapon = BG_FindWeaponNumForName( s );
+ upgrade = BG_UpgradeByName( s )->number;
+ weapon = BG_WeaponByName( s )->number;
if( weapon != WP_NONE )
{
@@ -1940,8 +1940,8 @@ void Cmd_Buy_f( gentity_t *ent )
trap_Argv( 1, s, sizeof( s ) );
- weapon = BG_FindWeaponNumForName( s );
- upgrade = BG_FindUpgradeNumForName( s );
+ weapon = BG_WeaponByName( s )->number;
+ upgrade = BG_UpgradeByName( s )->number;
// Seems odd to let people 'buy ammo' from a Reactor but allow this
// and make sure we only give energy ammo in this case
@@ -1954,7 +1954,7 @@ void Cmd_Buy_f( gentity_t *ent )
else
{
if( upgrade == UP_AMMO &&
- BG_FindUsesEnergyForWeapon( ent->client->ps.weapon ) )
+ BG_Weapon( ent->client->ps.weapon )->usesEnergy )
G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOENERGYAMMOHERE );
else
G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOARMOURYHERE );
@@ -1971,35 +1971,35 @@ void Cmd_Buy_f( gentity_t *ent )
}
//can afford this?
- if( BG_FindPriceForWeapon( weapon ) > (short)ent->client->ps.persistant[ PERS_CREDIT ] )
+ if( BG_Weapon( weapon )->price > (short)ent->client->ps.persistant[ PERS_CREDIT ] )
{
G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOFUNDS );
return;
}
//have space to carry this?
- if( BG_FindSlotsForWeapon( weapon ) & ent->client->ps.stats[ STAT_SLOTS ] )
+ if( BG_Weapon( weapon )->slots & ent->client->ps.stats[ STAT_SLOTS ] )
{
G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOSLOTS );
return;
}
// Only humans can buy stuff
- if( BG_FindTeamForWeapon( weapon ) != TEAM_HUMANS )
+ if( BG_Weapon( weapon )->team != TEAM_HUMANS )
{
trap_SendServerCommand( ent-g_entities, "print \"You can't buy alien items\n\"" );
return;
}
//are we /allowed/ to buy this?
- if( !BG_FindPurchasableForWeapon( weapon ) )
+ if( !BG_Weapon( weapon )->purchasable )
{
trap_SendServerCommand( ent-g_entities, "print \"You can't buy this item\n\"" );
return;
}
//are we /allowed/ to buy this?
- if( !BG_FindStagesForWeapon( weapon, g_humanStage.integer ) || !BG_WeaponIsAllowed( weapon ) )
+ if( !BG_WeaponAllowedInStage( weapon, g_humanStage.integer ) || !BG_WeaponIsAllowed( weapon ) )
{
trap_SendServerCommand( ent-g_entities, "print \"You can't buy this item\n\"" );
return;
@@ -2011,9 +2011,10 @@ void Cmd_Buy_f( gentity_t *ent )
//add to inventory
BG_AddWeaponToInventory( weapon, ent->client->ps.stats );
- BG_FindAmmoForWeapon( weapon, &maxAmmo, &maxClips );
+ maxAmmo = BG_Weapon( weapon )->maxAmmo;
+ maxClips = BG_Weapon( weapon )->maxClips;
- if( BG_FindUsesEnergyForWeapon( weapon ) &&
+ if( BG_Weapon( weapon )->usesEnergy &&
BG_InventoryContainsUpgrade( UP_BATTPACK, ent->client->ps.stats ) )
maxAmmo *= BATTPACK_MODIFIER;
@@ -2026,7 +2027,7 @@ void Cmd_Buy_f( gentity_t *ent )
ent->client->ps.stats[ STAT_MISC ] = 0;
//subtract from funds
- G_AddCreditToClient( ent->client, -(short)BG_FindPriceForWeapon( weapon ), qfalse );
+ G_AddCreditToClient( ent->client, -(short)BG_Weapon( weapon )->price, qfalse );
}
else if( upgrade != UP_NONE )
{
@@ -2038,35 +2039,35 @@ void Cmd_Buy_f( gentity_t *ent )
}
//can afford this?
- if( BG_FindPriceForUpgrade( upgrade ) > (short)ent->client->ps.persistant[ PERS_CREDIT ] )
+ if( BG_Upgrade( upgrade )->price > (short)ent->client->ps.persistant[ PERS_CREDIT ] )
{
G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOFUNDS );
return;
}
//have space to carry this?
- if( BG_FindSlotsForUpgrade( upgrade ) & ent->client->ps.stats[ STAT_SLOTS ] )
+ if( BG_Upgrade( upgrade )->slots & ent->client->ps.stats[ STAT_SLOTS ] )
{
G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOSLOTS );
return;
}
// Only humans can buy stuff
- if( BG_FindTeamForUpgrade( upgrade ) != TEAM_HUMANS )
+ if( BG_Upgrade( upgrade )->team != TEAM_HUMANS )
{
trap_SendServerCommand( ent-g_entities, "print \"You can't buy alien items\n\"" );
return;
}
//are we /allowed/ to buy this?
- if( !BG_FindPurchasableForUpgrade( upgrade ) )
+ if( !BG_Upgrade( upgrade )->purchasable )
{
trap_SendServerCommand( ent-g_entities, "print \"You can't buy this item\n\"" );
return;
}
//are we /allowed/ to buy this?
- if( !BG_FindStagesForUpgrade( upgrade, g_humanStage.integer ) || !BG_UpgradeIsAllowed( upgrade ) )
+ if( !BG_UpgradeAllowedInStage( upgrade, g_humanStage.integer ) || !BG_UpgradeIsAllowed( upgrade ) )
{
trap_SendServerCommand( ent-g_entities, "print \"You can't buy this item\n\"" );
return;
@@ -2098,7 +2099,7 @@ void Cmd_Buy_f( gentity_t *ent )
G_GiveClientMaxAmmo( ent, qtrue );
//subtract from funds
- G_AddCreditToClient( ent->client, -(short)BG_FindPriceForUpgrade( upgrade ), qfalse );
+ G_AddCreditToClient( ent->client, -(short)BG_Upgrade( upgrade )->price, qfalse );
}
else
G_TriggerMenu( ent->client->ps.clientNum, MN_H_UNKNOWNITEM );
@@ -2117,7 +2118,8 @@ void Cmd_Sell_f( gentity_t *ent )
{
char s[ MAX_TOKEN_CHARS ];
int i;
- int weapon, upgrade;
+ weapon_t weapon;
+ upgrade_t upgrade;
trap_Argv( 1, s, sizeof( s ) );
@@ -2128,8 +2130,8 @@ void Cmd_Sell_f( gentity_t *ent )
return;
}
- weapon = BG_FindWeaponNumForName( s );
- upgrade = BG_FindUpgradeNumForName( s );
+ weapon = BG_WeaponByName( s )->number;
+ upgrade = BG_UpgradeByName( s )->number;
if( weapon != WP_NONE )
{
@@ -2139,7 +2141,7 @@ void Cmd_Sell_f( gentity_t *ent )
return;
//are we /allowed/ to sell this?
- if( !BG_FindPurchasableForWeapon( weapon ) )
+ if( !BG_Weapon( weapon )->purchasable )
{
trap_SendServerCommand( ent-g_entities, "print \"You can't sell this weapon\n\"" );
return;
@@ -2158,7 +2160,7 @@ void Cmd_Sell_f( gentity_t *ent )
BG_RemoveWeaponFromInventory( weapon, ent->client->ps.stats );
//add to funds
- G_AddCreditToClient( ent->client, (short)BG_FindPriceForWeapon( weapon ), qfalse );
+ G_AddCreditToClient( ent->client, (short)BG_Weapon( weapon )->price, qfalse );
}
//if we have this weapon selected, force a new selection
@@ -2168,7 +2170,7 @@ void Cmd_Sell_f( gentity_t *ent )
else if( upgrade != UP_NONE )
{
//are we /allowed/ to sell this?
- if( !BG_FindPurchasableForUpgrade( upgrade ) )
+ if( !BG_Upgrade( upgrade )->purchasable )
{
trap_SendServerCommand( ent-g_entities, "print \"You can't sell this item\n\"" );
return;
@@ -2198,7 +2200,7 @@ void Cmd_Sell_f( gentity_t *ent )
G_GiveClientMaxAmmo( ent, qtrue );
//add to funds
- G_AddCreditToClient( ent->client, (short)BG_FindPriceForUpgrade( upgrade ), qfalse );
+ G_AddCreditToClient( ent->client, (short)BG_Upgrade( upgrade )->price, qfalse );
}
}
else if( !Q_stricmp( s, "weapons" ) )
@@ -2218,12 +2220,12 @@ void Cmd_Sell_f( gentity_t *ent )
}
if( BG_InventoryContainsWeapon( i, ent->client->ps.stats ) &&
- BG_FindPurchasableForWeapon( i ) )
+ BG_Weapon( i )->purchasable )
{
BG_RemoveWeaponFromInventory( i, ent->client->ps.stats );
//add to funds
- G_AddCreditToClient( ent->client, (short)BG_FindPriceForWeapon( i ), qfalse );
+ G_AddCreditToClient( ent->client, (short)BG_Weapon( i )->price, qfalse );
}
//if we have this weapon selected, force a new selection
@@ -2237,7 +2239,7 @@ void Cmd_Sell_f( gentity_t *ent )
{
//remove upgrade if carried
if( BG_InventoryContainsUpgrade( i, ent->client->ps.stats ) &&
- BG_FindPurchasableForUpgrade( i ) )
+ BG_Upgrade( i )->purchasable )
{
// shouldn't really need to test for this, but just to be safe
@@ -2260,7 +2262,7 @@ void Cmd_Sell_f( gentity_t *ent )
G_GiveClientMaxAmmo( ent, qtrue );
//add to funds
- G_AddCreditToClient( ent->client, (short)BG_FindPriceForUpgrade( i ), qfalse );
+ G_AddCreditToClient( ent->client, (short)BG_Upgrade( i )->price, qfalse );
}
}
}
@@ -2299,7 +2301,7 @@ void Cmd_Build_f( gentity_t *ent )
trap_Argv( 1, s, sizeof( s ) );
- buildable = BG_FindBuildNumForName( s );
+ buildable = BG_BuildableByName( s )->number;
if( G_TimeTilSuddenDeath( ) <= 0 )
{
@@ -2310,14 +2312,14 @@ void Cmd_Build_f( gentity_t *ent )
team = ent->client->ps.stats[ STAT_TEAM ];
if( buildable != BA_NONE &&
- ( ( 1 << ent->client->ps.weapon ) & BG_FindBuildWeaponForBuildable( buildable ) ) &&
+ ( ( 1 << ent->client->ps.weapon ) & BG_Buildable( buildable )->buildWeapon ) &&
!( ent->client->ps.stats[ STAT_STATE ] & SS_INFESTING ) &&
!( ent->client->ps.stats[ STAT_STATE ] & SS_HOVELING ) &&
BG_BuildableIsAllowed( buildable ) &&
- ( ( team == TEAM_ALIENS && BG_FindStagesForBuildable( buildable, g_alienStage.integer ) ) ||
- ( team == TEAM_HUMANS && BG_FindStagesForBuildable( buildable, g_humanStage.integer ) ) ) )
+ ( ( team == TEAM_ALIENS && BG_BuildableAllowedInStage( buildable, g_alienStage.integer ) ) ||
+ ( team == TEAM_HUMANS && BG_BuildableAllowedInStage( buildable, g_humanStage.integer ) ) ) )
{
- dist = BG_FindBuildDistForClass( ent->client->ps.stats[ STAT_CLASS ] );
+ dist = BG_Class( ent->client->ps.stats[ STAT_CLASS ] )->buildDist;
//these are the errors displayed when the builder first selects something to use
switch( G_CanBuild( ent, buildable, dist, origin ) )