summaryrefslogtreecommitdiff
path: root/src/game/g_cmds.c
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2001-03-22 01:57:00 +0000
committerTim Angus <tim@ngus.net>2001-03-22 01:57:00 +0000
commitfbe70db07dd5dc85a83d98d3ef789de41d22545b (patch)
tree8d211b0fb6d6fdcb5c5fb9c0c512ba377517055a /src/game/g_cmds.c
parent8a3452aa2a8fd7f82d267a1de0b05288b8d92dfe (diff)
Restructuring of the builables routines.
Diffstat (limited to 'src/game/g_cmds.c')
-rw-r--r--src/game/g_cmds.c47
1 files changed, 12 insertions, 35 deletions
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index d6eb998b..1687504f 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -1903,11 +1903,8 @@ Cmd_Build_f
*/
void Cmd_Build_f( gentity_t *ent )
{
- gitem_t *item;
char s[ MAX_TOKEN_CHARS ];
int buildable;
- qboolean dontBuild = qfalse;
-
trap_Argv( 1, s, sizeof( s ) );
@@ -1915,23 +1912,14 @@ void Cmd_Build_f( gentity_t *ent )
BG_gotWeapon( WP_ABUILD, ent->client->ps.stats ) &&
( ent->client->ps.weapon == WP_ABUILD ) )
{
- if( !Q_stricmp(s, "0") || !Q_stricmp(s, "spawn") )
- buildable = BA_A_SPAWN;
- else if( !Q_stricmp(s, "1") || !Q_stricmp(s, "defense1") )
- buildable = BA_A_DEF1;
- else
- {
- trap_SendServerCommand( ent-g_entities, va("print \"Unknown item\n\"" ) );
- dontBuild = qtrue;
- }
+ buildable = BG_FindBuildNumForName( s );
- if( !dontBuild )
+ if( buildable == BA_NONE )
+ trap_SendServerCommand( ent-g_entities, va("print \"Unknown item\n\"" ) );
+ else
{
- item = BG_FindItemForBuildable( buildable );
- if( itemFits( ent, item, -50 ) )
- {
- Build_Item( ent, item, -50 );
- }
+ if( itemFits( ent, buildable, -50 ) )
+ Build_Item( ent, buildable, -50 );
else
trap_SendServerCommand( ent-g_entities, va("print \"Location is not suitable\n\"" ) );
}
@@ -1940,25 +1928,14 @@ void Cmd_Build_f( gentity_t *ent )
BG_gotWeapon( WP_HBUILD, ent->client->ps.stats ) &&
( ent->client->ps.weapon == WP_HBUILD ) )
{
- if( !Q_stricmp(s, "0") || !Q_stricmp(s, "spawn") )
- buildable = BA_H_SPAWN;
- else if( !Q_stricmp(s, "1") || !Q_stricmp(s, "defense1") )
- buildable = BA_H_DEF1;
- else if( !Q_stricmp(s, "2") || !Q_stricmp(s, "mcu") )
- buildable = BA_H_MCU;
- else
- {
- trap_SendServerCommand( ent-g_entities, va("print \"Unknown item\n\"" ) );
- dontBuild = qtrue;
- }
+ buildable = BG_FindBuildNumForName( s );
- if( !dontBuild )
+ if( buildable == BA_NONE )
+ trap_SendServerCommand( ent-g_entities, va("print \"Unknown item\n\"" ) );
+ else
{
- item = BG_FindItemForBuildable( buildable );
- if( itemFits( ent, item, 80 ) )
- {
- Build_Item( ent, item, 80 );
- }
+ if( itemFits( ent, buildable, 80 ) )
+ Build_Item( ent, buildable, 80 );
else
trap_SendServerCommand( ent-g_entities, va("print \"Location is not suitable\n\"" ) );
}