This repository has been archived on 2022-06-27. You can view files and clone it, but cannot push or open issues or pull requests.
Xash3DArchive/launch/cmd.c

707 lines
14 KiB
C
Raw Normal View History

2007-11-25 22:00:00 +01:00
//=======================================================================
// Copyright XashXT Group 2007 <20>
// cmd.c - script command processing module
//=======================================================================
2007-11-18 22:00:00 +01:00
2007-11-25 22:00:00 +01:00
#include "launch.h"
2007-11-18 22:00:00 +01:00
#define MAX_CMD_BUFFER 16384
#define MAX_CMD_LINE 1024
typedef struct
{
byte *data;
int maxsize;
int cursize;
} cmd_t;
int cmd_wait;
cmd_t cmd_text;
byte cmd_text_buf[MAX_CMD_BUFFER];
/*
=============================================================================
COMMAND BUFFER
=============================================================================
*/
/*
============
Cbuf_Init
============
*/
2007-11-25 22:00:00 +01:00
void Cbuf_Init( void )
2007-11-18 22:00:00 +01:00
{
cmd_text.data = cmd_text_buf;
cmd_text.maxsize = MAX_CMD_BUFFER;
cmd_text.cursize = 0;
}
/*
============
Cbuf_AddText
Adds command text at the end of the buffer
============
*/
2009-10-02 22:00:00 +02:00
void Cbuf_AddText( const char *text )
2007-11-18 22:00:00 +01:00
{
2007-11-25 22:00:00 +01:00
int l;
2007-11-18 22:00:00 +01:00
2009-10-02 22:00:00 +02:00
l = com.strlen( text );
if( cmd_text.cursize + l >= cmd_text.maxsize )
2007-11-18 22:00:00 +01:00
{
2009-10-02 22:00:00 +02:00
MsgDev( D_WARN, "Cbuf_AddText: overflow\n" );
2007-11-18 22:00:00 +01:00
return;
}
2009-10-02 22:00:00 +02:00
Mem_Copy( &cmd_text.data[cmd_text.cursize], text, l );
2007-11-25 22:00:00 +01:00
cmd_text.cursize += l;
2007-11-18 22:00:00 +01:00
}
/*
============
Cbuf_InsertText
Adds command text immediately after the current command
Adds a \n to the text
============
*/
2010-09-10 22:00:00 +02:00
void Cbuf_InsertText( const char *text )
2007-11-18 22:00:00 +01:00
{
int i, len;
2009-10-02 22:00:00 +02:00
len = com.strlen( text ) + 1;
if( len + cmd_text.cursize > cmd_text.maxsize )
2007-11-18 22:00:00 +01:00
{
2009-10-02 22:00:00 +02:00
MsgDev( D_WARN, "Cbuf_InsertText overflowed\n" );
2007-11-18 22:00:00 +01:00
return;
}
// move the existing command text
2009-10-02 22:00:00 +02:00
for( i = cmd_text.cursize - 1; i >= 0; i-- )
2007-11-18 22:00:00 +01:00
{
cmd_text.data[i + len] = cmd_text.data[i];
}
// copy the new text in
Mem_Copy( cmd_text.data, (char *)text, len - 1 );
2009-10-02 22:00:00 +02:00
cmd_text.data[len - 1] = '\n'; // add a \n
2007-11-18 22:00:00 +01:00
cmd_text.cursize += len;
}
/*
============
Cbuf_ExecuteText
============
*/
2009-10-02 22:00:00 +02:00
void Cbuf_ExecuteText( int exec_when, const char *text )
2007-11-18 22:00:00 +01:00
{
2009-10-02 22:00:00 +02:00
switch( exec_when )
2007-11-18 22:00:00 +01:00
{
case EXEC_NOW:
2009-10-02 22:00:00 +02:00
if( text && com.strlen( text ))
Cmd_ExecuteString( text );
2007-11-18 22:00:00 +01:00
else Cbuf_Execute();
break;
case EXEC_INSERT:
2009-10-02 22:00:00 +02:00
Cbuf_InsertText( text );
2007-11-18 22:00:00 +01:00
break;
case EXEC_APPEND:
2009-10-02 22:00:00 +02:00
Cbuf_AddText( text );
2007-11-18 22:00:00 +01:00
break;
default:
2009-10-02 22:00:00 +02:00
MsgDev( D_ERROR, "Cbuf_ExecuteText: bad execute target\n" );
2007-11-18 22:00:00 +01:00
break;
}
}
/*
============
Cbuf_Execute
============
*/
void Cbuf_Execute( void )
{
char *text;
char line[MAX_CMD_LINE];
2010-06-20 22:00:00 +02:00
int i, quotes;
2007-11-18 22:00:00 +01:00
2008-11-12 22:00:00 +01:00
while( cmd_text.cursize )
2007-11-18 22:00:00 +01:00
{
if( cmd_wait )
{
// skip out while text still remains in buffer, leaving it for next frame
cmd_wait--;
break;
}
// find a \n or ; line break
text = (char *)cmd_text.data;
quotes = 0;
2009-10-02 22:00:00 +02:00
for( i = 0; i < cmd_text.cursize; i++ )
2007-11-18 22:00:00 +01:00
{
2009-10-02 22:00:00 +02:00
if( text[i] == '"') quotes++;
if(!( quotes & 1 ) && text[i] == ';' )
2007-11-18 22:00:00 +01:00
break; // don't break if inside a quoted string
2009-10-02 22:00:00 +02:00
if( text[i] == '\n' || text[i] == '\r' ) break;
2007-11-18 22:00:00 +01:00
}
2009-10-02 22:00:00 +02:00
if( i >= MAX_CMD_LINE - 1 )
Sys_Error( "Cbuf_Execute: command string owerflow\n" );
Mem_Copy( line, text, i );
2007-11-18 22:00:00 +01:00
line[i] = 0;
2009-10-02 22:00:00 +02:00
2007-11-18 22:00:00 +01:00
// delete the text from the command buffer and move remaining commands down
// this is necessary because commands (exec) can insert data at the
// beginning of the text buffer
2009-10-02 22:00:00 +02:00
if( i == cmd_text.cursize )
{
cmd_text.cursize = 0;
}
2007-11-18 22:00:00 +01:00
else
{
i++;
cmd_text.cursize -= i;
2009-10-02 22:00:00 +02:00
memmove( text, text + i, cmd_text.cursize );
2007-11-18 22:00:00 +01:00
}
// execute the command line
2008-11-12 22:00:00 +01:00
Cmd_ExecuteString( line );
2007-11-18 22:00:00 +01:00
}
}
/*
==============================================================================
SCRIPT COMMANDS
==============================================================================
*/
/*
===============
Cmd_StuffCmds_f
Adds command line parameters as script statements
Commands lead with a +, and continue until a - or another +
2007-11-25 22:00:00 +01:00
xash +prog jctest.qp +cmd amlev1
xash -nosound +cmd amlev1
2007-11-18 22:00:00 +01:00
===============
*/
void Cmd_StuffCmds_f( void )
{
int i, j, l = 0;
2010-07-26 22:00:00 +02:00
char build[MAX_SYSPATH]; // this is for all commandline options combined (and is bounds checked)
2007-11-18 22:00:00 +01:00
2010-07-29 22:00:00 +02:00
if( Cmd_Argc() != 1 )
2007-11-18 22:00:00 +01:00
{
2010-07-29 22:00:00 +02:00
Msg( "Usage: stuffcmds : execute command line parameters\n" );
2007-11-18 22:00:00 +01:00
return;
}
// no reason to run the commandline arguments twice
2010-07-29 22:00:00 +02:00
if( Sys.stuffcmdsrun ) return;
2007-11-18 22:00:00 +01:00
2007-11-25 22:00:00 +01:00
Sys.stuffcmdsrun = true;
2007-11-18 22:00:00 +01:00
build[0] = 0;
2010-07-29 22:00:00 +02:00
for( i = 0; i < fs_argc; i++ )
2007-11-18 22:00:00 +01:00
{
2010-07-29 22:00:00 +02:00
if( fs_argv[i] && fs_argv[i][0] == '+' && ( fs_argv[i][1] < '0' || fs_argv[i][1] > '9' ) && l + com.strlen( fs_argv[i] ) - 1 <= sizeof( build ) - 1 )
2007-11-18 22:00:00 +01:00
{
j = 1;
2010-07-29 22:00:00 +02:00
while( fs_argv[i][j] )
build[l++] = fs_argv[i][j++];
for( i++; i < fs_argc; i++ )
2007-11-18 22:00:00 +01:00
{
2010-07-29 22:00:00 +02:00
if( !fs_argv[i] ) continue;
if(( fs_argv[i][0] == '+' || fs_argv[i][0] == '-' ) && ( fs_argv[i][1] < '0' || fs_argv[i][1] > '9' ))
2007-11-18 22:00:00 +01:00
break;
2010-07-29 22:00:00 +02:00
if( l + com.strlen( fs_argv[i]) + 4 > sizeof( build ) - 1 )
2007-11-18 22:00:00 +01:00
break;
build[l++] = ' ';
2010-07-29 22:00:00 +02:00
if( com.strchr( fs_argv[i], ' ' ))
build[l++] = '\"';
for( j = 0; fs_argv[i][j]; j++ )
build[l++] = fs_argv[i][j];
if( com.strchr( fs_argv[i], ' ' ))
build[l++] = '\"';
2007-11-18 22:00:00 +01:00
}
build[l++] = '\n';
i--;
}
}
// now terminate the combined string and prepend it to the command buffer
// we already reserved space for the terminator
build[l++] = 0;
2007-11-25 22:00:00 +01:00
Cbuf_InsertText( build );
2007-11-18 22:00:00 +01:00
}
/*
============
Cmd_Wait_f
Causes execution of the remainder of the command buffer to be delayed until
next frame. This allows commands like:
bind g "cmd use rocket ; +attack ; wait ; -attack ; cmd use blaster"
============
*/
2009-12-04 22:00:00 +01:00
void Cmd_Wait_f( void )
2007-11-18 22:00:00 +01:00
{
2009-12-04 22:00:00 +01:00
if( Cmd_Argc() == 1 ) cmd_wait = 1;
else cmd_wait = com.atoi( Cmd_Argv( 1 ));
2007-11-18 22:00:00 +01:00
}
/*
===============
Cmd_Exec_f
===============
*/
2009-12-04 22:00:00 +01:00
void Cmd_Exec_f( void )
2007-11-18 22:00:00 +01:00
{
2010-07-30 22:00:00 +02:00
string cfgpath;
2008-10-27 22:00:00 +01:00
size_t len;
char *f;
2009-10-02 22:00:00 +02:00
2008-10-27 22:00:00 +01:00
if( Cmd_Argc() != 2 )
2007-11-18 22:00:00 +01:00
{
2009-10-02 22:00:00 +02:00
Msg( "Usage: exec <filename>\n" );
2007-11-18 22:00:00 +01:00
return;
}
2010-09-09 22:00:00 +02:00
com.strncpy( cfgpath, Cmd_Argv( 1 ), sizeof( cfgpath ));
2010-07-30 22:00:00 +02:00
FS_DefaultExtension( cfgpath, ".cfg" ); // append as default
2007-11-18 22:00:00 +01:00
2011-03-02 22:00:00 +01:00
f = FS_LoadFile( cfgpath, &len, false );
2009-10-02 22:00:00 +02:00
if( !f )
2007-11-18 22:00:00 +01:00
{
2010-07-30 22:00:00 +02:00
MsgDev( D_NOTE, "couldn't exec %s\n", Cmd_Argv( 1 ));
2007-11-18 22:00:00 +01:00
return;
}
2009-10-02 22:00:00 +02:00
2010-07-30 22:00:00 +02:00
MsgDev( D_INFO, "execing %s\n", Cmd_Argv( 1 ));
2009-10-02 22:00:00 +02:00
Cbuf_InsertText( f );
Mem_Free( f );
2007-11-18 22:00:00 +01:00
}
/*
===============
Cmd_Echo_f
Just prints the rest of the line to the console
===============
*/
2007-11-25 22:00:00 +01:00
void Cmd_Echo_f( void )
2007-11-18 22:00:00 +01:00
{
int i;
for(i = 1; i < Cmd_Argc(); i++)
2007-11-25 22:00:00 +01:00
Msg("%s ",Cmd_Argv(i));
2007-11-18 22:00:00 +01:00
Msg ("\n");
}
/*
=============================================================================
COMMAND EXECUTION
=============================================================================
*/
2010-10-23 22:00:00 +02:00
#define CMD_EXTDLL BIT( 0 )
2007-11-18 22:00:00 +01:00
typedef struct cmd_function_s
{
struct cmd_function_s *next;
char *name;
char *desc;
xcommand_t function;
2010-10-23 22:00:00 +02:00
int flags;
2007-11-18 22:00:00 +01:00
} cmd_function_t;
2009-10-02 22:00:00 +02:00
static int cmd_argc;
2010-09-09 22:00:00 +02:00
static char *cmd_argv[MAX_CMD_TOKENS];
2009-10-02 22:00:00 +02:00
static char cmd_tokenized[MAX_CMD_BUFFER]; // will have 0 bytes inserted
static cmd_function_t *cmd_functions; // possible commands to execute
2007-11-18 22:00:00 +01:00
/*
============
Cmd_Argc
============
*/
2010-10-23 22:00:00 +02:00
uint Cmd_Argc( void )
2007-11-18 22:00:00 +01:00
{
return cmd_argc;
}
/*
============
Cmd_Argv
============
*/
2010-04-02 22:00:00 +02:00
char *Cmd_Argv( uint arg )
2007-11-18 22:00:00 +01:00
{
2007-11-25 22:00:00 +01:00
if( arg >= cmd_argc )
2007-11-18 22:00:00 +01:00
return "";
return cmd_argv[arg];
}
/*
============
Cmd_Args
Returns a single string containing argv(1) to argv(argc()-1)
============
*/
2008-07-19 22:00:00 +02:00
char *Cmd_Args( void )
2007-11-18 22:00:00 +01:00
{
2008-07-23 22:00:00 +02:00
static char cmd_args[MAX_SYSPATH];
2007-11-25 22:00:00 +01:00
int i;
2007-11-18 22:00:00 +01:00
cmd_args[0] = 0;
// build only for current call
2007-11-25 22:00:00 +01:00
for( i = 1; i < cmd_argc; i++ )
2007-11-18 22:00:00 +01:00
{
2008-11-18 22:00:00 +01:00
com.strcat( cmd_args, cmd_argv[i] );
if( i != cmd_argc - 1 ) com.strcat( cmd_args, " " );
2007-11-18 22:00:00 +01:00
}
return cmd_args;
}
/*
============
Cmd_TokenizeString
Parses the given string into command line tokens.
The text is copied to a seperate buffer and 0 characters
are inserted in the apropriate place, The argv array
will point into this temporary buffer.
============
*/
2009-10-02 22:00:00 +02:00
void Cmd_TokenizeString( const char *text_in )
2007-11-18 22:00:00 +01:00
{
const char *text;
char *textOut;
cmd_argc = 0; // clear previous args
2007-11-25 22:00:00 +01:00
if( !text_in ) return;
2007-11-18 22:00:00 +01:00
text = text_in;
textOut = cmd_tokenized;
while( 1 )
{
// this is usually something malicious
2010-09-09 22:00:00 +02:00
if( cmd_argc == MAX_CMD_TOKENS ) return;
2007-11-18 22:00:00 +01:00
2009-10-02 22:00:00 +02:00
while( 1 )
2007-11-18 22:00:00 +01:00
{
// skip whitespace
2009-10-02 22:00:00 +02:00
while( *text && *text <= ' ' ) text++;
if( !*text ) return; // all tokens parsed
2007-11-18 22:00:00 +01:00
// skip // comments
2009-10-02 22:00:00 +02:00
if( text[0] == '/' && text[1] == '/' ) return; // all tokens parsed
2007-11-18 22:00:00 +01:00
// skip /* */ comments
2009-10-02 22:00:00 +02:00
if( text[0] == '/' && text[1] =='*' )
2007-11-18 22:00:00 +01:00
{
2009-10-02 22:00:00 +02:00
while( *text && ( text[0] != '*' || text[1] != '/' )) text++;
if( !*text ) return; // all tokens parsed
2007-11-18 22:00:00 +01:00
text += 2;
}
else break; // we are ready to parse a token
}
// handle quoted strings
2009-10-02 22:00:00 +02:00
if( *text == '"' )
2007-11-18 22:00:00 +01:00
{
cmd_argv[cmd_argc] = textOut;
cmd_argc++;
text++;
2009-10-02 22:00:00 +02:00
while( *text && *text != '"' )
*textOut++ = *text++;
2007-11-18 22:00:00 +01:00
*textOut++ = 0;
2009-10-02 22:00:00 +02:00
if( !*text ) return; // all tokens parsed
2007-11-18 22:00:00 +01:00
text++;
continue;
}
// regular token
cmd_argv[cmd_argc] = textOut;
cmd_argc++;
// skip until whitespace, quote, or command
2009-10-02 22:00:00 +02:00
while( *text > ' ' )
2007-11-18 22:00:00 +01:00
{
2009-10-02 22:00:00 +02:00
if( text[0] == '"' ) break;
if( text[0] == '/' && text[1] == '/' ) break;
2007-11-18 22:00:00 +01:00
// skip /* */ comments
2009-10-02 22:00:00 +02:00
if( text[0] == '/' && text[1] =='*' ) break;
2007-11-18 22:00:00 +01:00
*textOut++ = *text++;
}
*textOut++ = 0;
if( !*text ) return; // all tokens parsed
}
}
/*
============
Cmd_AddCommand
============
*/
2009-10-02 22:00:00 +02:00
void Cmd_AddCommand( const char *cmd_name, xcommand_t function, const char *cmd_desc )
2007-11-18 22:00:00 +01:00
{
cmd_function_t *cmd;
// fail if the command already exists
2010-10-23 22:00:00 +02:00
if( Cmd_Exists( cmd_name ))
2007-11-18 22:00:00 +01:00
{
MsgDev(D_INFO, "Cmd_AddCommand: %s already defined\n", cmd_name);
return;
}
// use a small malloc to avoid zone fragmentation
2010-10-23 22:00:00 +02:00
cmd = Malloc( sizeof( cmd_function_t ));
2007-11-18 22:00:00 +01:00
cmd->name = copystring( cmd_name );
cmd->desc = copystring( cmd_desc );
cmd->function = function;
cmd->next = cmd_functions;
cmd_functions = cmd;
}
2010-10-23 22:00:00 +02:00
/*
============
Cmd_AddGameCommand
============
*/
void Cmd_AddGameCommand( const char *cmd_name, xcommand_t function )
{
cmd_function_t *cmd;
// fail if the command already exists
if( Cmd_Exists( cmd_name ))
{
MsgDev(D_INFO, "Cmd_AddCommand: %s already defined\n", cmd_name);
return;
}
// use a small malloc to avoid zone fragmentation
cmd = Malloc( sizeof( cmd_function_t ));
cmd->name = copystring( cmd_name );
cmd->function = function;
cmd->flags = CMD_EXTDLL;
cmd->next = cmd_functions;
cmd_functions = cmd;
}
2007-11-18 22:00:00 +01:00
/*
============
Cmd_RemoveCommand
============
*/
void Cmd_RemoveCommand (const char *cmd_name)
{
cmd_function_t *cmd, **back;
back = &cmd_functions;
while( 1 )
{
cmd = *back;
if (!cmd ) return;
if (!strcmp( cmd_name, cmd->name ))
{
*back = cmd->next;
2007-11-25 22:00:00 +01:00
if(cmd->name) Mem_Free(cmd->name);
if(cmd->desc) Mem_Free(cmd->desc);
Mem_Free(cmd);
2007-11-18 22:00:00 +01:00
return;
}
back = &cmd->next;
}
}
/*
============
2007-11-27 22:00:00 +01:00
Cmd_LookupCmds
2007-11-18 22:00:00 +01:00
============
*/
2008-08-15 22:00:00 +02:00
void Cmd_LookupCmds( char *buffer, void *ptr, setpair_t callback )
2007-11-18 22:00:00 +01:00
{
cmd_function_t *cmd;
2010-02-10 22:00:00 +01:00
// nothing to process ?
if( !callback ) return;
2007-11-18 22:00:00 +01:00
2010-02-10 22:00:00 +01:00
for( cmd = cmd_functions; cmd; cmd = cmd->next )
2007-11-27 22:00:00 +01:00
{
2010-02-10 22:00:00 +01:00
if( !buffer ) callback( cmd->name, (char *)cmd->function, cmd->desc, ptr );
2007-11-27 22:00:00 +01:00
else callback( cmd->name, (char *)cmd->function, buffer, ptr );
}
2007-11-18 22:00:00 +01:00
}
/*
============
Cmd_Exists
============
*/
2010-10-26 22:00:00 +02:00
qboolean Cmd_Exists( const char *cmd_name )
2007-11-18 22:00:00 +01:00
{
cmd_function_t *cmd;
2009-12-04 22:00:00 +01:00
for( cmd = cmd_functions; cmd; cmd = cmd->next )
2007-11-18 22:00:00 +01:00
{
2010-07-29 22:00:00 +02:00
if( !com.strcmp( cmd_name, cmd->name ))
2007-11-18 22:00:00 +01:00
return true;
}
return false;
}
/*
============
Cmd_ExecuteString
A complete command line has been parsed, so try to execute it
============
*/
void Cmd_ExecuteString( const char *text )
{
cmd_function_t *cmd, **prev;
// execute the command line
Cmd_TokenizeString( text );
if( !Cmd_Argc()) return; // no tokens
// check registered command functions
2009-10-02 22:00:00 +02:00
for( prev = &cmd_functions; *prev; prev = &cmd->next )
2007-11-18 22:00:00 +01:00
{
cmd = *prev;
2010-07-29 22:00:00 +02:00
if( !com.stricmp( cmd_argv[0], cmd->name ))
2007-11-18 22:00:00 +01:00
{
// 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
2008-12-20 22:00:00 +01:00
if( !cmd->function )
2009-08-05 22:00:00 +02:00
Cmd_ExecuteString( va( "cmd %s", text ));
2007-11-18 22:00:00 +01:00
else cmd->function();
return;
}
}
// check cvars
2010-11-19 22:00:00 +01:00
if( Cvar_Command( )) return;
2008-12-20 22:00:00 +01:00
2010-02-02 22:00:00 +01:00
if( Sys.app_name == HOST_NORMAL && Sys.CmdFwd )
2009-08-05 22:00:00 +02:00
{
// all unrecognized commands will be forwarded to a server
2010-02-02 22:00:00 +01:00
Sys.CmdFwd();
2009-08-05 22:00:00 +02:00
}
2010-11-19 22:00:00 +01:00
else if( text[0] != '@' )
{
// commands with leading '@' are hidden system commands
Msg( "Unknown command \"%s\"\n", text );
}
2007-11-18 22:00:00 +01:00
}
/*
============
Cmd_List_f
============
*/
2007-11-25 22:00:00 +01:00
void Cmd_List_f( void )
2007-11-18 22:00:00 +01:00
{
cmd_function_t *cmd;
int i = 0;
char *match;
2009-08-05 22:00:00 +02:00
if( Cmd_Argc() > 1 ) match = Cmd_Argv( 1 );
2007-11-18 22:00:00 +01:00
else match = NULL;
2008-11-18 22:00:00 +01:00
for( cmd = cmd_functions; cmd; cmd = cmd->next )
2007-11-18 22:00:00 +01:00
{
2010-09-10 22:00:00 +02:00
if( match && !com.stricmpext( match, cmd->name ))
2007-11-18 22:00:00 +01:00
continue;
2009-08-05 22:00:00 +02:00
Msg( "%s\n", cmd->name );
2007-11-18 22:00:00 +01:00
i++;
}
2009-08-05 22:00:00 +02:00
Msg( "%i commands\n", i );
2007-11-18 22:00:00 +01:00
}
2010-10-23 22:00:00 +02:00
/*
============
Cmd_Unlink
unlink all commands with flag CVAR_EXTDLL
============
*/
void Cmd_Unlink( void )
{
cmd_function_t *cmd;
cmd_function_t **prev;
int count = 0;
if( Cvar_VariableInteger( "host_gameloaded" ))
{
Msg( "can't unlink cvars while game is loaded\n" );
return;
}
// unlink commands first
Cmd_Unlink ();
prev = &cmd_functions;
while( 1 )
{
cmd = *prev;
if( !cmd ) break;
if( !( cmd->flags & CMD_EXTDLL ))
{
prev = &cmd->next;
continue;
}
*prev = cmd->next;
if( cmd->name ) Mem_Free( cmd->name );
if( cmd->desc ) Mem_Free( cmd->desc );
Mem_Free( cmd );
count++;
}
}
2007-11-18 22:00:00 +01:00
/*
============
Cmd_Init
============
*/
2007-11-25 22:00:00 +01:00
void Cmd_Init( void )
2007-11-18 22:00:00 +01:00
{
2007-11-25 22:00:00 +01:00
Cbuf_Init();
2008-08-04 22:00:00 +02:00
cmd_functions = NULL;
2007-11-18 22:00:00 +01:00
// register our commands
Cmd_AddCommand ("exec", Cmd_Exec_f, "execute a script file" );
Cmd_AddCommand ("echo", Cmd_Echo_f, "print a message to the console (useful in scripts)" );
Cmd_AddCommand ("wait", Cmd_Wait_f, "make script execution wait for some rendered frames" );
Cmd_AddCommand ("cmdlist", Cmd_List_f, "display all console commands beginning with the specified prefix" );
2011-02-15 22:00:00 +01:00
Cmd_AddCommand ("stuffcmds", Cmd_StuffCmds_f, va( "execute commandline parameters (must be present in %s.rc script)", Sys.ModuleName ));
2007-11-18 22:00:00 +01:00
2007-12-17 22:00:00 +01:00
Memory_Init_Commands(); // memlib stats
}