From fbe70db07dd5dc85a83d98d3ef789de41d22545b Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Thu, 22 Mar 2001 01:57:00 +0000 Subject: Restructuring of the builables routines. --- src/game/g_cmds.c | 47 ++++++++++++----------------------------------- 1 file changed, 12 insertions(+), 35 deletions(-) (limited to 'src/game/g_cmds.c') 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\"" ) ); } -- cgit