mirror of
https://bitbucket.org/CPMADevs/cnq3
synced 2024-11-10 06:31:48 +00:00
commands registered by cgame get removed after CG_SHUTDOWN
This commit is contained in:
parent
eb4b1d8615
commit
23d0273489
4 changed files with 39 additions and 2 deletions
|
@ -1,6 +1,8 @@
|
|||
|
||||
DD Mmm 17 - 1.49
|
||||
|
||||
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: using stb_image to load png and tga images
|
||||
|
|
|
@ -135,7 +135,7 @@ static void CL_SetUserCmdValue( int userCmdValue, float sensitivityScale )
|
|||
|
||||
static void CL_AddCgameCommand( const char* cmd )
|
||||
{
|
||||
Cmd_AddCommand( cmd, NULL );
|
||||
Cmd_AddCommandEx( cmd, NULL, qtrue );
|
||||
}
|
||||
|
||||
|
||||
|
@ -295,6 +295,7 @@ void CL_ShutdownCGame()
|
|||
VM_Call( cgvm, CG_SHUTDOWN );
|
||||
VM_Free( cgvm );
|
||||
cgvm = NULL;
|
||||
Cmd_RemoveCGameCommands();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -230,6 +230,7 @@ typedef struct cmd_function_s
|
|||
char *name;
|
||||
xcommand_t function;
|
||||
xcommandCompletion_t completion;
|
||||
qbool cgame; // registered by cgame?
|
||||
} cmd_function_t;
|
||||
|
||||
|
||||
|
@ -438,11 +439,13 @@ static void Cmd_TokenizeString2( const char* text, qbool ignoreQuotes )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void Cmd_TokenizeString( const char* text )
|
||||
{
|
||||
Cmd_TokenizeString2( text, qfalse );
|
||||
}
|
||||
|
||||
|
||||
void Cmd_TokenizeStringIgnoreQuotes( const char* text )
|
||||
{
|
||||
Cmd_TokenizeString2( text, qtrue );
|
||||
|
@ -450,6 +453,12 @@ void Cmd_TokenizeStringIgnoreQuotes( const char* text )
|
|||
|
||||
|
||||
void Cmd_AddCommand( const char* cmd_name, xcommand_t function )
|
||||
{
|
||||
Cmd_AddCommandEx( cmd_name, function, qfalse );
|
||||
}
|
||||
|
||||
|
||||
void Cmd_AddCommandEx( const char* cmd_name, xcommand_t function, qbool cgame )
|
||||
{
|
||||
cmd_function_t* cmd;
|
||||
|
||||
|
@ -469,6 +478,7 @@ void Cmd_AddCommand( const char* cmd_name, xcommand_t function )
|
|||
cmd->name = CopyString( cmd_name );
|
||||
cmd->function = function;
|
||||
cmd->completion = NULL;
|
||||
cmd->cgame = cgame;
|
||||
cmd->next = cmd_functions;
|
||||
cmd_functions = cmd;
|
||||
}
|
||||
|
@ -478,7 +488,7 @@ void Cmd_RemoveCommand( const char* cmd_name )
|
|||
{
|
||||
cmd_function_t** back = &cmd_functions;
|
||||
|
||||
while( 1 ) {
|
||||
for(;;) {
|
||||
cmd_function_t* cmd = *back;
|
||||
if ( !cmd ) {
|
||||
// command wasn't active
|
||||
|
@ -497,6 +507,28 @@ void Cmd_RemoveCommand( const char* cmd_name )
|
|||
}
|
||||
|
||||
|
||||
void Cmd_RemoveCGameCommands()
|
||||
{
|
||||
cmd_function_t** back = &cmd_functions;
|
||||
|
||||
for(;;) {
|
||||
cmd_function_t* const cmd = *back;
|
||||
if ( !cmd )
|
||||
break;
|
||||
|
||||
if ( !cmd->cgame ) {
|
||||
back = &cmd->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
*back = cmd->next;
|
||||
if ( cmd->name )
|
||||
Z_Free( cmd->name );
|
||||
Z_Free( cmd );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Cmd_SetAutoCompletion( const char* cmd_name, xcommandCompletion_t completion )
|
||||
{
|
||||
cmd_function_t* cmd;
|
||||
|
|
|
@ -351,8 +351,10 @@ void Cmd_Init();
|
|||
// if function is NULL, the command will be forwarded to the server
|
||||
// as a clc_clientCommand instead of executed locally
|
||||
void Cmd_AddCommand( const char* cmd_name, xcommand_t function );
|
||||
void Cmd_AddCommandEx( const char* cmd_name, xcommand_t function, qbool cgame );
|
||||
|
||||
void Cmd_RemoveCommand( const char* cmd_name );
|
||||
void Cmd_RemoveCGameCommands();
|
||||
|
||||
// auto-completion of command arguments
|
||||
void Cmd_SetAutoCompletion( const char* cmd_name, xcommandCompletion_t complete );
|
||||
|
|
Loading…
Reference in a new issue