diff --git a/engine/common/con_utils.c b/engine/common/con_utils.c index e5d931ea..cf29aae8 100644 --- a/engine/common/con_utils.c +++ b/engine/common/con_utils.c @@ -598,6 +598,16 @@ static void Con_AddCommandToList( const char *s, const char *unused1, const char list->cmds[list->matchCount++] = copystring( s ); } +/* +================= +Con_SortCmds +================= +*/ +static int Con_SortCmds( const void *arg1, const void *arg2 ) +{ + return Q_stricmp( *(const char **)arg1, *(const char **)arg2 ); +} + /* ===================================== Cmd_GetCommandsList @@ -632,6 +642,8 @@ qboolean Cmd_GetCommandsList( const char *s, char *completedname, int length ) Q_strncpy( completedname, matchbuf, length ); if( list.matchCount == 1 ) return true; + qsort( list.cmds, list.matchCount, sizeof( char* ), Con_SortCmds ); + for( i = 0; i < list.matchCount; i++ ) { Q_strncpy( matchbuf, list.cmds[i], sizeof( matchbuf )); @@ -1026,16 +1038,6 @@ qboolean Cmd_AutocompleteName( const char *source, int arg, char *buffer, size_t return false; } -/* -================= -Con_SortCmds -================= -*/ -static int Con_SortCmds( const void *arg1, const void *arg2 ) -{ - return Q_stricmp( *(const char **)arg1, *(const char **)arg2 ); -} - /* =============== Con_PrintCmdMatches