diff options
Diffstat (limited to 'src/ui/ui_atoms.c')
-rw-r--r-- | src/ui/ui_atoms.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/ui/ui_atoms.c b/src/ui/ui_atoms.c index 9f0f3a9a..8f31225f 100644 --- a/src/ui/ui_atoms.c +++ b/src/ui/ui_atoms.c @@ -153,18 +153,18 @@ static void UI_MessageMode_f( void ) Menus_ActivateByName( "say" ); } -struct +struct uicmd { char *cmd; void ( *function )( void ); } commands[ ] = { - { "ui_load", UI_Load }, - { "ui_report", UI_Report }, - { "ui_cache", UI_Cache_f }, + { "closemenus", UI_CloseMenus_f }, + { "menu", UI_Menu_f }, { "messagemode", UI_MessageMode_f }, { "messagemode2", UI_MessageMode_f }, - { "menu", UI_Menu_f }, - { "closemenus", UI_CloseMenus_f } + { "ui_cache", UI_Cache_f }, + { "ui_load", UI_Load }, + { "ui_report", UI_Report } }; /* @@ -174,20 +174,17 @@ UI_ConsoleCommand */ qboolean UI_ConsoleCommand( int realTime ) { - char *cmd; - int i; + struct uicmd *cmd = bsearch( UI_Argv( 0 ), commands, + sizeof( commands ) / sizeof( commands[ 0 ] ), sizeof( commands[ 0 ] ), + cmdcmp ); uiInfo.uiDC.frameTime = realTime - uiInfo.uiDC.realTime; uiInfo.uiDC.realTime = realTime; - cmd = UI_Argv( 0 ); - for( i = 0; i < sizeof( commands ) / sizeof( commands[ 0 ] ); i++ ) + if( cmd ) { - if( Q_stricmp( commands[ i ].cmd, cmd ) == 0 ) - { - commands[ i ].function( ); - return qtrue; - } + cmd->function( ); + return qtrue; } return qfalse; |