mirror of
https://bitbucket.org/CPMADevs/cnq3
synced 2024-11-10 06:31:48 +00:00
keep cvars and commands alphabetically sorted
This commit is contained in:
parent
23d0273489
commit
9b776ab343
3 changed files with 51 additions and 11 deletions
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
DD Mmm 17 - 1.49
|
DD Mmm 17 - 1.49
|
||||||
|
|
||||||
|
chg: cvars and commands are alphabetically sorted
|
||||||
|
|
||||||
fix: commands registered by cgame no longer auto-complete after the cgame qvm has shut down
|
fix: commands registered by cgame no longer auto-complete after the cgame qvm has shut down
|
||||||
|
|
||||||
chg: removed r_stencilbits, r_depthbits, r_colorbits, r_texturebits and r_ext_compressed_textures
|
chg: removed r_stencilbits, r_depthbits, r_colorbits, r_texturebits and r_ext_compressed_textures
|
||||||
|
|
|
@ -479,8 +479,31 @@ void Cmd_AddCommandEx( const char* cmd_name, xcommand_t function, qbool cgame )
|
||||||
cmd->function = function;
|
cmd->function = function;
|
||||||
cmd->completion = NULL;
|
cmd->completion = NULL;
|
||||||
cmd->cgame = cgame;
|
cmd->cgame = cgame;
|
||||||
cmd->next = cmd_functions;
|
|
||||||
cmd_functions = cmd;
|
// add the command
|
||||||
|
if ( cmd_functions == NULL || Q_stricmp(cmd_functions->name, cmd_name) > 0 ) {
|
||||||
|
// insert as the first command
|
||||||
|
cmd_function_t* const next = cmd_functions;
|
||||||
|
cmd_functions = cmd;
|
||||||
|
cmd->next = next;
|
||||||
|
} else {
|
||||||
|
// insert after some other command
|
||||||
|
cmd_function_t* curr = cmd_functions;
|
||||||
|
cmd_function_t* prev = cmd_functions;
|
||||||
|
for (;;) {
|
||||||
|
if ( Q_stricmp(curr->name, cmd_name) > 0 )
|
||||||
|
break;
|
||||||
|
|
||||||
|
prev = curr;
|
||||||
|
if ( curr->next == NULL )
|
||||||
|
break;
|
||||||
|
|
||||||
|
curr = curr->next;
|
||||||
|
}
|
||||||
|
cmd_function_t* const next = prev->next;
|
||||||
|
prev->next = cmd;
|
||||||
|
cmd->next = next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -577,12 +600,6 @@ void Cmd_ExecuteString( const char* text )
|
||||||
for ( prev = &cmd_functions ; *prev ; prev = &cmd->next ) {
|
for ( prev = &cmd_functions ; *prev ; prev = &cmd->next ) {
|
||||||
cmd = *prev;
|
cmd = *prev;
|
||||||
if ( !Q_stricmp( cmd_argv[0],cmd->name ) ) {
|
if ( !Q_stricmp( cmd_argv[0],cmd->name ) ) {
|
||||||
// rearrange the links so that the command will be
|
|
||||||
// near the head of the list next time it is used
|
|
||||||
*prev = cmd->next;
|
|
||||||
cmd->next = cmd_functions;
|
|
||||||
cmd_functions = cmd;
|
|
||||||
|
|
||||||
// perform the action
|
// perform the action
|
||||||
if ( !cmd->function ) {
|
if ( !cmd->function ) {
|
||||||
// let the cgame or game handle it
|
// let the cgame or game handle it
|
||||||
|
|
|
@ -322,13 +322,34 @@ breaks every single mod except CPMA otherwise, but it IS wrong, and critically s
|
||||||
var->resetString = CopyString( var_value );
|
var->resetString = CopyString( var_value );
|
||||||
|
|
||||||
// link the variable in
|
// link the variable in
|
||||||
var->next = cvar_vars;
|
if ( cvar_vars == NULL || Q_stricmp(cvar_vars->name, var_name) > 0 ) {
|
||||||
cvar_vars = var;
|
// insert as the first cvar
|
||||||
|
cvar_t* const next = cvar_vars;
|
||||||
|
cvar_vars = var;
|
||||||
|
var->next = next;
|
||||||
|
} else {
|
||||||
|
// insert after some other cvar
|
||||||
|
cvar_t* curr = cvar_vars;
|
||||||
|
cvar_t* prev = cvar_vars;
|
||||||
|
for (;;) {
|
||||||
|
if ( Q_stricmp(curr->name, var_name) > 0 )
|
||||||
|
break;
|
||||||
|
|
||||||
|
prev = curr;
|
||||||
|
if ( curr->next == NULL )
|
||||||
|
break;
|
||||||
|
|
||||||
|
curr = curr->next;
|
||||||
|
}
|
||||||
|
cvar_t* const next = prev->next;
|
||||||
|
prev->next = var;
|
||||||
|
var->next = next;
|
||||||
|
}
|
||||||
|
|
||||||
var->flags = flags;
|
var->flags = flags;
|
||||||
cvar_modifiedFlags |= flags; // needed so USERINFO cvars created by cgame actually get sent
|
cvar_modifiedFlags |= flags; // needed so USERINFO cvars created by cgame actually get sent
|
||||||
|
|
||||||
long hash = Cvar_Hash(var_name);
|
const long hash = Cvar_Hash( var_name );
|
||||||
var->hashNext = hashTable[hash];
|
var->hashNext = hashTable[hash];
|
||||||
hashTable[hash] = var;
|
hashTable[hash] = var;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue