summaryrefslogtreecommitdiff
path: root/src/cgame
diff options
context:
space:
mode:
Diffstat (limited to 'src/cgame')
-rw-r--r--src/cgame/cg_consolecmds.c51
-rw-r--r--src/cgame/cg_servercmds.c36
2 files changed, 41 insertions, 46 deletions
diff --git a/src/cgame/cg_consolecmds.c b/src/cgame/cg_consolecmds.c
index 17eddac1..da583214 100644
--- a/src/cgame/cg_consolecmds.c
+++ b/src/cgame/cg_consolecmds.c
@@ -185,31 +185,30 @@ static void CG_UIMenu_f( void )
static consoleCommand_t commands[ ] =
{
- { "ui_menu", CG_UIMenu_f },
- { "testgun", CG_TestGun_f },
- { "testmodel", CG_TestModel_f },
+ { "+scores", CG_ScoresDown_f },
+ { "-scores", CG_ScoresUp_f },
+ { "clientlist", CG_ClientList_f },
+ { "destroyTestPS", CG_DestroyTestPS_f },
+ { "destroyTestTS", CG_DestroyTestTS_f },
{ "nextframe", CG_TestModelNextFrame_f },
- { "prevframe", CG_TestModelPrevFrame_f },
{ "nextskin", CG_TestModelNextSkin_f },
+ { "prevframe", CG_TestModelPrevFrame_f },
{ "prevskin", CG_TestModelPrevSkin_f },
- { "viewpos", CG_Viewpos_f },
- { "+scores", CG_ScoresDown_f },
- { "-scores", CG_ScoresUp_f },
- { "scoresUp", CG_scrollScoresUp_f },
{ "scoresDown", CG_scrollScoresDown_f },
- { "sizeup", CG_SizeUp_f },
+ { "scoresUp", CG_scrollScoresUp_f },
{ "sizedown", CG_SizeDown_f },
- { "weapnext", CG_NextWeapon_f },
- { "weapprev", CG_PrevWeapon_f },
- { "weapon", CG_Weapon_f },
+ { "sizeup", CG_SizeUp_f },
+ { "testgun", CG_TestGun_f },
+ { "testmodel", CG_TestModel_f },
{ "testPS", CG_TestPS_f },
- { "destroyTestPS", CG_DestroyTestPS_f },
{ "testTS", CG_TestTS_f },
- { "destroyTestTS", CG_DestroyTestTS_f },
- { "clientlist", CG_ClientList_f },
+ { "ui_menu", CG_UIMenu_f },
+ { "viewpos", CG_Viewpos_f },
+ { "weapnext", CG_NextWeapon_f },
+ { "weapon", CG_Weapon_f },
+ { "weapprev", CG_PrevWeapon_f }
};
-
/*
=================
CG_ConsoleCommand
@@ -220,21 +219,17 @@ Cmd_Argc() / Cmd_Argv()
*/
qboolean CG_ConsoleCommand( void )
{
- const char *cmd;
- int i;
+ consoleCommand_t *cmd;
- cmd = CG_Argv( 0 );
+ cmd = bsearch( CG_Argv( 0 ), commands,
+ sizeof( commands ) / sizeof( commands[ 0 ]), sizeof( commands[ 0 ] ),
+ cmdcmp );
- for( i = 0; i < sizeof( commands ) / sizeof( commands[ 0 ] ); i++ )
- {
- if( !Q_stricmp( cmd, commands[ i ].cmd ) )
- {
- commands[ i ].function( );
- return qtrue;
- }
- }
+ if( !cmd )
+ return qfalse;
- return qfalse;
+ cmd->function( );
+ return qtrue;
}
diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c
index 920858fc..6c43782a 100644
--- a/src/cgame/cg_servercmds.c
+++ b/src/cgame/cg_servercmds.c
@@ -1278,21 +1278,21 @@ static void CG_PTRConfirm_f( void )
static consoleCommand_t svcommands[ ] =
{
+ { "chat", CG_Chat_f },
+ { "clientLevelShot", CG_ClientLevelShot_f },
{ "cp", CG_CenterPrint_f },
{ "cs", CG_ConfigStringModified },
- { "print", CG_Print_f },
- { "chat", CG_Chat_f },
- { "scores", CG_ParseScores },
- { "tinfo", CG_ParseTeamInfo },
{ "map_restart", CG_MapRestart },
- { "clientLevelShot", CG_ClientLevelShot_f },
- { "servermenu", CG_ServerMenu_f },
- { "serverclosemenus", CG_ServerCloseMenus_f },
{ "poisoncloud", CG_PoisonCloud_f },
- { "voice", CG_ParseVoice },
- { "ptrcrequest", CG_PTRRequest_f },
+ { "print", CG_Print_f },
+ { "ptrcconfirm", CG_PTRConfirm_f },
{ "ptrcissue", CG_PTRIssue_f },
- { "ptrcconfirm", CG_PTRConfirm_f }
+ { "ptrcrequest", CG_PTRRequest_f },
+ { "scores", CG_ParseScores },
+ { "serverclosemenus", CG_ServerCloseMenus_f },
+ { "servermenu", CG_ServerMenu_f },
+ { "tinfo", CG_ParseTeamInfo },
+ { "voice", CG_ParseVoice }
};
/*
@@ -1305,18 +1305,18 @@ Cmd_Argc() / Cmd_Argv()
*/
static void CG_ServerCommand( void )
{
- const char *cmd;
- int i;
+ const char *cmd;
+ consoleCommand_t *command;
cmd = CG_Argv( 0 );
+ command = bsearch( cmd, svcommands, sizeof( svcommands ) /
+ sizeof( svcommands[ 0 ]), sizeof( svcommands[ 0 ] ),
+ cmdcmp );
- for( i = 0; i < sizeof( svcommands ) / sizeof( svcommands[ 0 ] ); i++ )
+ if( command )
{
- if( !Q_stricmp( cmd, svcommands[ i ].cmd ) )
- {
- svcommands[ i ].function( );
- return;
- }
+ command->function( );
+ return;
}
CG_Printf( "Unknown client game command: %s\n", cmd );