mirror of
https://github.com/FWGS/xash3d-fwgs
synced 2024-12-25 02:05:26 +01:00
Forgot to add cvars into basecmd. Add basecmd_test to check is basecmd valid
This commit is contained in:
parent
0561ac2076
commit
5d48708615
@ -15,6 +15,7 @@ GNU General Public License for more details.
|
||||
|
||||
#include "common.h"
|
||||
#include "base_cmd.h"
|
||||
#include "cdll_int.h"
|
||||
|
||||
// TODO: use another hash function, as COM_HashKey depends on string length
|
||||
#define HASH_SIZE 128 // 128 * 4 * 4 == 2048 bytes
|
||||
@ -227,3 +228,60 @@ void BaseCmd_Stats_f( void )
|
||||
Con_Printf( "Bucket maximum length: %d\n", maxsize );
|
||||
Con_Printf( "Empty buckets: %d\n", empty );
|
||||
}
|
||||
|
||||
static void BaseCmd_CheckCvars( const char *key, const char *value, void *buffer, void *ptr )
|
||||
{
|
||||
base_command_t *v = BaseCmd_Find( HM_CVAR, key );
|
||||
qboolean *invalid = ptr;
|
||||
|
||||
if( !v )
|
||||
{
|
||||
Con_Printf( "Cvar %s is missing in basecmd\n", key );
|
||||
*invalid = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
BaseCmd_Stats_f
|
||||
|
||||
testing order matches cbuf execute
|
||||
============
|
||||
*/
|
||||
void BaseCmd_Test_f( void )
|
||||
{
|
||||
void *cmd;
|
||||
cmdalias_t *a;
|
||||
qboolean invalid = false;
|
||||
|
||||
// Cmd_LookupCmds don't allows to check alias, so just iterate
|
||||
for( a = Cmd_AliasGetList(); a; a = a->next )
|
||||
{
|
||||
base_command_t *v = BaseCmd_Find( HM_CMDALIAS, a->name );
|
||||
|
||||
if( !v )
|
||||
{
|
||||
Con_Printf( "Alias %s is missing in basecmd\n", a->name );
|
||||
invalid = true;
|
||||
}
|
||||
}
|
||||
|
||||
for( cmd = Cmd_GetFirstFunctionHandle(); cmd;
|
||||
cmd = Cmd_GetNextFunctionHandle( cmd ) )
|
||||
{
|
||||
base_command_t *v = BaseCmd_Find( HM_CMD, Cmd_GetName( cmd ) );
|
||||
|
||||
if( !v )
|
||||
{
|
||||
Con_Printf( "Command %s is missing in basecmd\n", Cmd_GetName( cmd ) );
|
||||
invalid = true;
|
||||
}
|
||||
}
|
||||
|
||||
Cvar_LookupVars( 0, NULL, &invalid, BaseCmd_CheckCvars );
|
||||
|
||||
if( !invalid )
|
||||
{
|
||||
Con_Printf( "BaseCmd is valid\n" );
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ void BaseCmd_Insert ( base_command_type_e type, base_command_t *basecmd, const c
|
||||
qboolean BaseCmd_Replace( base_command_type_e type, base_command_t *basecmd, const char *name ); // only if same name
|
||||
void BaseCmd_Remove ( base_command_type_e type, const char *name );
|
||||
void BaseCmd_Stats_f( void ); // to be registered later
|
||||
void BaseCmd_Test_f( void ); // to be registered later
|
||||
|
||||
#endif // XASH_HASHED_VARS
|
||||
|
||||
|
@ -1164,5 +1164,6 @@ void Cmd_Init( void )
|
||||
|
||||
#if defined(XASH_HASHED_VARS)
|
||||
Cmd_AddCommand( "basecmd_stats", BaseCmd_Stats_f, "print info about basecmd usage" );
|
||||
Cmd_AddCommand( "basecmd_test", BaseCmd_Test_f, "test basecmd" );
|
||||
#endif
|
||||
}
|
||||
|
@ -40,6 +40,10 @@ find the specified variable by name
|
||||
*/
|
||||
convar_t *Cvar_FindVarExt( const char *var_name, int ignore_group )
|
||||
{
|
||||
// TODO: ignore group for cvar
|
||||
#if defined(XASH_HASHED_VARS)
|
||||
return (convar_t *)BaseCmd_Find( HM_CVAR, var_name );
|
||||
#else
|
||||
convar_t *var;
|
||||
|
||||
if( !var_name )
|
||||
@ -55,6 +59,7 @@ convar_t *Cvar_FindVarExt( const char *var_name, int ignore_group )
|
||||
}
|
||||
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@ -239,6 +244,10 @@ int Cvar_UnlinkVar( const char *var_name, int group )
|
||||
continue;
|
||||
}
|
||||
|
||||
#if defined(XASH_HASHED_VARS)
|
||||
BaseCmd_Remove( HM_CVAR, var->name );
|
||||
#endif
|
||||
|
||||
// unlink variable from list
|
||||
freestring( var->string );
|
||||
*prev = var->next;
|
||||
@ -401,6 +410,11 @@ convar_t *Cvar_Get( const char *name, const char *value, int flags, const char *
|
||||
// tell engine about changes
|
||||
Cvar_Changed( var );
|
||||
|
||||
#if defined(XASH_HASHED_VARS)
|
||||
// add to map
|
||||
BaseCmd_Insert( HM_CVAR, var, var->name );
|
||||
#endif
|
||||
|
||||
return var;
|
||||
}
|
||||
|
||||
@ -464,6 +478,11 @@ void Cvar_RegisterVariable( convar_t *var )
|
||||
|
||||
// tell engine about changes
|
||||
Cvar_Changed( var );
|
||||
|
||||
#if defined(XASH_HASHED_VARS)
|
||||
// add to map
|
||||
BaseCmd_Insert( HM_CVAR, var, var->name );
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user