engine: restore command escaping

This commit is contained in:
Alibek Omarov 2021-11-16 15:50:04 +03:00 committed by a1batross
parent 1de1852409
commit 508eb7ab5f
2 changed files with 36 additions and 1 deletions

View File

@ -983,7 +983,7 @@ static void Cmd_ExecuteStringWithPrivilegeCheck( const char *text, qboolean isPr
cmd_condlevel = 0;
// cvar value substitution
if( cmd_scripting && cmd_scripting->value )
if( CVAR_TO_BOOL( cmd_scripting ))
{
while( *text )
{
@ -1330,9 +1330,43 @@ void Cmd_Null_f( void )
{
}
/*
==========
Cmd_Escape
inserts escape sequences
==========
*/
void Cmd_Escape( char *newCommand, const char *oldCommand, int len )
{
int c;
int scripting = CVAR_TO_BOOL( cmd_scripting );
while( (c = *oldCommand++) && len > 1 )
{
if( c == '"' )
{
*newCommand++ = '\\';
len--;
}
if( scripting && c == '$')
{
*newCommand++ = '$';
len--;
}
*newCommand++ = c; len--;
}
*newCommand++ = 0;
}
/*
============
Cmd_Init
============
*/
void Cmd_Init( void )

View File

@ -503,6 +503,7 @@ qboolean Cmd_GetMovieList( const char *s, char *completedname, int length );
void Cmd_TokenizeString( const char *text );
void Cmd_ExecuteString( const char *text );
void Cmd_ForwardToServer( void );
void Cmd_Escape( char *newCommand, const char *oldCommand, int len );
//
// zone.c