2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 // cmd.c -- Quake script command processing module
24 #define MAX_ALIAS_NAME 32
25 // this is the largest script file that can be executed in one step
26 // LordHavoc: inreased this from 8192 to 32768
27 #define CMDBUFSIZE 32768
28 // maximum number of parameters to a command
30 // maximum tokenizable commandline length (counting NUL terminations)
31 #define CMD_TOKENIZELENGTH (MAX_INPUTLINE + 80)
33 typedef struct cmdalias_s
35 struct cmdalias_s *next;
36 char name[MAX_ALIAS_NAME];
40 static cmdalias_t *cmd_alias;
42 static qboolean cmd_wait;
44 static mempool_t *cmd_mempool;
46 static char cmd_tokenizebuffer[CMD_TOKENIZELENGTH];
47 static int cmd_tokenizebufferpos = 0;
49 //=============================================================================
55 Causes execution of the remainder of the command buffer to be delayed until
56 next frame. This allows commands like:
57 bind g "impulse 5 ; +attack ; wait ; -attack ; impulse 2"
60 static void Cmd_Wait_f (void)
66 =============================================================================
70 =============================================================================
73 static sizebuf_t cmd_text;
74 static unsigned char cmd_text_buf[CMDBUFSIZE];
80 Adds command text at the end of the buffer
83 void Cbuf_AddText (const char *text)
87 l = (int)strlen (text);
89 if (cmd_text.cursize + l >= cmd_text.maxsize)
91 Con_Print("Cbuf_AddText: overflow\n");
95 SZ_Write (&cmd_text, (const unsigned char *)text, (int)strlen (text));
103 Adds command text immediately after the current command
104 Adds a \n to the text
105 FIXME: actually change the command buffer to do less copying
108 void Cbuf_InsertText (const char *text)
113 // copy off any commands still remaining in the exec buffer
114 templen = cmd_text.cursize;
117 temp = (char *)Mem_Alloc (tempmempool, templen);
118 memcpy (temp, cmd_text.data, templen);
119 SZ_Clear (&cmd_text);
124 // add the entire text of the file
127 // add the copied off data
130 SZ_Write (&cmd_text, (const unsigned char *)temp, templen);
140 static void Cmd_PreprocessString( const char *intext, char *outtext, unsigned maxoutlen, cmdalias_t *alias );
141 void Cbuf_Execute (void)
145 char line[MAX_INPUTLINE];
146 char preprocessed[MAX_INPUTLINE];
149 // LordHavoc: making sure the tokenizebuffer doesn't get filled up by repeated crashes
150 cmd_tokenizebufferpos = 0;
152 while (cmd_text.cursize)
154 // find a \n or ; line break
155 text = (char *)cmd_text.data;
158 for (i=0 ; i< cmd_text.cursize ; i++)
162 if ( !quotes && text[i] == ';')
163 break; // don't break if inside a quoted string
164 if (text[i] == '\r' || text[i] == '\n')
168 memcpy (line, text, i);
171 // delete the text from the command buffer and move remaining commands down
172 // this is necessary because commands (exec, alias) can insert data at the
173 // beginning of the text buffer
175 if (i == cmd_text.cursize)
176 cmd_text.cursize = 0;
180 cmd_text.cursize -= i;
181 memcpy (cmd_text.data, text+i, cmd_text.cursize);
184 // execute the command line
185 Cmd_PreprocessString( line, preprocessed, sizeof(preprocessed), NULL );
186 Cmd_ExecuteString (preprocessed, src_command);
189 { // skip out while text still remains in buffer, leaving it
198 ==============================================================================
202 ==============================================================================
209 Adds command line parameters as script statements
210 Commands lead with a +, and continue until a - or another +
211 quake +prog jctest.qp +cmd amlev1
212 quake -nosound +cmd amlev1
215 qboolean host_stuffcmdsrun = false;
216 void Cmd_StuffCmds_f (void)
219 // this is per command, and bounds checked (no buffer overflows)
220 char build[MAX_INPUTLINE];
222 if (Cmd_Argc () != 1)
224 Con_Print("stuffcmds : execute command line parameters\n");
228 host_stuffcmdsrun = true;
229 for (i = 0;i < com_argc;i++)
231 if (com_argv[i] && com_argv[i][0] == '+' && (com_argv[i][1] < '0' || com_argv[i][1] > '9'))
235 while (com_argv[i][j])
236 build[l++] = com_argv[i][j++];
238 for (;i < com_argc;i++)
242 if ((com_argv[i][0] == '+' || com_argv[i][0] == '-') && (com_argv[i][1] < '0' || com_argv[i][1] > '9'))
244 if (l + strlen(com_argv[i]) + 5 > sizeof(build))
248 for (j = 0;com_argv[i][j];j++)
249 build[l++] = com_argv[i][j];
254 Cbuf_InsertText (build);
266 static void Cmd_Exec_f (void)
270 if (Cmd_Argc () != 2)
272 Con_Print("exec <filename> : execute a script file\n");
276 f = (char *)FS_LoadFile (Cmd_Argv(1), tempmempool, false, NULL);
279 Con_Printf("couldn't exec %s\n",Cmd_Argv(1));
282 Con_DPrintf("execing %s\n",Cmd_Argv(1));
284 // if executing default.cfg for the first time, lock the cvar defaults
285 // it may seem backwards to insert this text BEFORE the default.cfg
286 // but Cbuf_InsertText inserts before, so this actually ends up after it.
287 if (!strcmp(Cmd_Argv(1), "default.cfg"))
288 Cbuf_InsertText("\ncvar_lockdefaults\n");
290 // insert newline after the text to make sure the last line is terminated (some text editors omit the trailing newline)
291 // (note: insertion order here is backwards from execution order, so this adds it after the text, by calling it before...)
292 Cbuf_InsertText ("\n");
302 Just prints the rest of the line to the console
305 static void Cmd_Echo_f (void)
309 for (i=1 ; i<Cmd_Argc() ; i++)
310 Con_Printf("%s ",Cmd_Argv(i));
315 // Support Doom3-style Toggle Console Command
320 Toggles a specified console variable amongst the values specified (default is 0 and 1)
323 static void Cmd_Toggle_f(void)
325 // Acquire Number of Arguments
326 int nNumArgs = Cmd_Argc();
329 // No Arguments Specified; Print Usage
330 Con_Print("Toggle Console Variable - Usage\n toggle <variable> - toggles between 0 and 1\n toggle <variable> <value> - toggles between 0 and <value>\n toggle <variable> [string 1] [string 2]...[string n] - cycles through all strings\n");
332 { // Correct Arguments Specified
333 // Acquire Potential CVar
334 cvar_t* cvCVar = Cvar_FindVar( Cmd_Argv(1) );
341 Cvar_SetValueQuick(cvCVar, 0);
343 Cvar_SetValueQuick(cvCVar, 1);
347 { // 0 and Specified Usage
348 if(cvCVar->integer == atoi(Cmd_Argv(2) ) )
349 // CVar is Specified Value; // Reset to 0
350 Cvar_SetValueQuick(cvCVar, 0);
352 if(cvCVar->integer == 0)
353 // CVar is 0; Specify Value
354 Cvar_SetQuick(cvCVar, Cmd_Argv(2) );
356 // CVar does not match; Reset to 0
357 Cvar_SetValueQuick(cvCVar, 0);
360 { // Variable Values Specified
364 for(nCnt = 2; nCnt < nNumArgs; nCnt++)
365 { // Cycle through Values
366 if( strcmp(cvCVar->string, Cmd_Argv(nCnt) ) == 0)
367 { // Current Value Located; Increment to Next
368 if( (nCnt + 1) == nNumArgs)
369 // Max Value Reached; Reset
370 Cvar_SetQuick(cvCVar, Cmd_Argv(2) );
373 Cvar_SetQuick(cvCVar, Cmd_Argv(nCnt + 1) );
382 // Value not Found; Reset to Original
383 Cvar_SetQuick(cvCVar, Cmd_Argv(2) );
389 Con_Printf("ERROR : CVar '%s' not found\n", Cmd_Argv(2) );
398 Creates a new command that executes a command string (possibly ; seperated)
401 static void Cmd_Alias_f (void)
404 char cmd[MAX_INPUTLINE];
411 Con_Print("Current alias commands:\n");
412 for (a = cmd_alias ; a ; a=a->next)
413 Con_Printf("%s : %s\n", a->name, a->value);
418 if (strlen(s) >= MAX_ALIAS_NAME)
420 Con_Print("Alias name is too long\n");
424 // if the alias already exists, reuse it
425 for (a = cmd_alias ; a ; a=a->next)
427 if (!strcmp(s, a->name))
436 cmdalias_t *prev, *current;
438 a = (cmdalias_t *)Z_Malloc (sizeof(cmdalias_t));
439 strlcpy (a->name, s, sizeof (a->name));
440 // insert it at the right alphanumeric position
441 for( prev = NULL, current = cmd_alias ; current && strcmp( current->name, a->name ) < 0 ; prev = current, current = current->next )
452 // copy the rest of the command line
453 cmd[0] = 0; // start out with a null string
455 for (i=2 ; i< c ; i++)
457 strlcat (cmd, Cmd_Argv(i), sizeof (cmd));
459 strlcat (cmd, " ", sizeof (cmd));
461 strlcat (cmd, "\n", sizeof (cmd));
463 alloclen = strlen (cmd) + 1;
464 a->value = (char *)Z_Malloc (alloclen);
465 memcpy (a->value, cmd, alloclen);
469 =============================================================================
473 =============================================================================
476 typedef struct cmd_function_s
478 struct cmd_function_s *next;
480 const char *description;
486 static const char *cmd_argv[MAX_ARGS];
487 static const char *cmd_null_string = "";
488 static const char *cmd_args;
489 cmd_source_t cmd_source;
492 static cmd_function_t *cmd_functions; // possible commands to execute
497 Preprocesses strings and replaces $*, $param#, $cvar accordingly
499 static void Cmd_PreprocessString( const char *intext, char *outtext, unsigned maxoutlen, cmdalias_t *alias ) {
504 // don't crash if there's no room in the outtext buffer
505 if( maxoutlen == 0 ) {
508 maxoutlen--; // because of \0
514 while( *in && outlen < maxoutlen ) {
515 if( *in == '$' && !inquote ) {
516 // this is some kind of expansion, see what comes after the $
518 // replacements that can always be used:
519 // $$ is replaced with $, to allow escaping $
520 // $<cvarname> is replaced with the contents of the cvar
522 // the following can be used in aliases only:
523 // $* is replaced with all formal parameters (including name of the alias - this probably is not desirable)
524 // $0 is replaced with the name of this alias
525 // $<number> is replaced with an argument to this alias (or copied as-is if no such parameter exists), can be multiple digits
527 outtext[outlen++] = *in++;
528 } else if( *in == '*' && alias ) {
529 const char *linein = Cmd_Args();
531 // include all parameters
533 while( *linein && outlen < maxoutlen ) {
534 outtext[outlen++] = *linein++;
539 } else if( '0' <= *in && *in <= '9' && alias ) {
543 argnum = strtol( in, &nexttoken, 10 );
545 if( 0 <= argnum && argnum < Cmd_Argc() ) {
546 const char *param = Cmd_Argv( argnum );
547 while( *param && outlen < maxoutlen ) {
548 outtext[outlen++] = *param++;
551 } else if( argnum >= Cmd_Argc() ) {
552 Con_Printf( "Warning: Not enough parameters passed to alias '%s', at least %i expected:\n %s\n", alias->name, argnum, alias->value );
553 outtext[outlen++] = '$';
557 const char *tempin = in;
559 COM_ParseTokenConsole( &tempin );
560 // don't expand rcon_password or similar cvars (CVAR_PRIVATE flag)
561 if ((cvar = Cvar_FindVar(&com_token[0])) && !(cvar->flags & CVAR_PRIVATE)) {
562 const char *cvarcontent = cvar->string;
563 while( *cvarcontent && outlen < maxoutlen ) {
564 outtext[outlen++] = *cvarcontent++;
569 Con_Printf( "Warning: could not find cvar %s when expanding alias %s\n %s\n", com_token, alias->name, alias->value );
571 Con_Printf( "Warning: could not find cvar %s\n", com_token );
573 outtext[outlen++] = '$';
580 outtext[outlen++] = *in++;
590 Called for aliases and fills in the alias into the cbuffer
593 static void Cmd_ExecuteAlias (cmdalias_t *alias)
595 static char buffer[ MAX_INPUTLINE + 2 ];
596 Cmd_PreprocessString( alias->value, buffer, sizeof(buffer) - 2, alias );
597 // insert at start of command buffer, so that aliases execute in order
598 // (fixes bug introduced by Black on 20050705)
599 Cbuf_InsertText( buffer );
606 CmdList Added by EvilTypeGuy eviltypeguy@qeradiant.com
607 Thanks to Matthias "Maddes" Buecher, http://www.inside3d.com/qip/
611 static void Cmd_List_f (void)
619 partial = Cmd_Argv (1);
620 len = (int)strlen(partial);
629 for (cmd = cmd_functions; cmd; cmd = cmd->next)
631 if (partial && strncmp(partial, cmd->name, len))
633 Con_Printf("%s : %s\n", cmd->name, cmd->description);
638 Con_Printf("%i Command%s beginning with \"%s\"\n\n", count, (count > 1) ? "s" : "", partial);
640 Con_Printf("%i Command%s\n\n", count, (count > 1) ? "s" : "");
650 cmd_mempool = Mem_AllocPool("commands", 0, NULL);
651 // space for commands and script files
652 cmd_text.data = cmd_text_buf;
653 cmd_text.maxsize = sizeof(cmd_text_buf);
654 cmd_text.cursize = 0;
657 void Cmd_Init_Commands (void)
660 // register our commands
662 Cmd_AddCommand ("stuffcmds",Cmd_StuffCmds_f, "execute commandline parameters (must be present in quake.rc script)");
663 Cmd_AddCommand ("exec",Cmd_Exec_f, "execute a script file");
664 Cmd_AddCommand ("echo",Cmd_Echo_f, "print a message to the console (useful in scripts)");
665 Cmd_AddCommand ("alias",Cmd_Alias_f, "create a script function (parameters are passed in as $1 through $9, and $* for all parameters)");
666 Cmd_AddCommand ("cmd", Cmd_ForwardToServer, "send a console commandline to the server (used by some mods)");
667 Cmd_AddCommand ("wait", Cmd_Wait_f, "make script execution wait for next rendered frame");
668 Cmd_AddCommand ("set", Cvar_Set_f, "create or change the value of a console variable");
669 Cmd_AddCommand ("seta", Cvar_SetA_f, "create or change the value of a console variable that will be saved to config.cfg");
671 // 2000-01-09 CmdList, CvarList commands By Matthias "Maddes" Buecher
672 // Added/Modified by EvilTypeGuy eviltypeguy@qeradiant.com
673 Cmd_AddCommand ("cmdlist", Cmd_List_f, "lists all console commands beginning with the specified prefix");
674 Cmd_AddCommand ("cvarlist", Cvar_List_f, "lists all console variables beginning with the specified prefix");
676 Cmd_AddCommand ("cvar_lockdefaults", Cvar_LockDefaults_f, "stores the current values of all cvars into their default values, only used once during startup after parsing default.cfg");
677 Cmd_AddCommand ("cvar_resettodefaults_all", Cvar_ResetToDefaults_All_f, "sets all cvars to their locked default values");
678 Cmd_AddCommand ("cvar_resettodefaults_nosaveonly", Cvar_ResetToDefaults_NoSaveOnly_f, "sets all non-saved cvars to their locked default values (variables that will not be saved to config.cfg)");
679 Cmd_AddCommand ("cvar_resettodefaults_saveonly", Cvar_ResetToDefaults_SaveOnly_f, "sets all saved cvars to their locked default values (variables that will be saved to config.cfg)");
682 // Support Doom3-style Toggle Command
683 Cmd_AddCommand( "toggle", Cmd_Toggle_f, "toggles a console variable's values (use for more info)");
691 void Cmd_Shutdown(void)
693 Mem_FreePool(&cmd_mempool);
711 const char *Cmd_Argv (int arg)
713 if (arg >= cmd_argc )
714 return cmd_null_string;
715 return cmd_argv[arg];
723 const char *Cmd_Args (void)
733 Parses the given string into command line tokens.
736 // AK: This function should only be called from ExcuteString because the current design is a bit of an hack
737 static void Cmd_TokenizeString (const char *text)
746 // skip whitespace up to a /n
747 while (*text && *text <= ' ' && *text != '\r' && *text != '\n')
754 if (*text == '\n' || *text == '\r')
756 // a newline separates commands in the buffer
757 if (*text == '\r' && text[1] == '\n')
769 if (!COM_ParseTokenConsole(&text))
772 if (cmd_argc < MAX_ARGS)
774 l = (int)strlen(com_token) + 1;
775 if (cmd_tokenizebufferpos + l > CMD_TOKENIZELENGTH)
777 Con_Printf("Cmd_TokenizeString: ran out of %i character buffer space for command arguements\n", CMD_TOKENIZELENGTH);
780 memcpy (cmd_tokenizebuffer + cmd_tokenizebufferpos, com_token, l);
781 cmd_argv[cmd_argc] = cmd_tokenizebuffer + cmd_tokenizebufferpos;
782 cmd_tokenizebufferpos += l;
794 void Cmd_AddCommand (const char *cmd_name, xcommand_t function, const char *description)
797 cmd_function_t *prev, *current;
799 // fail if the command is a variable name
800 if (Cvar_FindVar( cmd_name ))
802 Con_Printf("Cmd_AddCommand: %s already defined as a var\n", cmd_name);
806 // fail if the command already exists
807 for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
809 if (!strcmp (cmd_name, cmd->name))
813 Con_Printf("Cmd_AddCommand: %s already defined\n", cmd_name);
818 cmd->csqcfunc = true;
824 cmd = (cmd_function_t *)Mem_Alloc(cmd_mempool, sizeof(cmd_function_t));
825 cmd->name = cmd_name;
826 cmd->function = function;
827 cmd->description = description;
828 if(!function) //[515]: csqc
829 cmd->csqcfunc = true;
830 cmd->next = cmd_functions;
832 // insert it at the right alphanumeric position
833 for( prev = NULL, current = cmd_functions ; current && strcmp( current->name, cmd->name ) < 0 ; prev = current, current = current->next )
848 qboolean Cmd_Exists (const char *cmd_name)
852 for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
853 if (!strcmp (cmd_name,cmd->name))
865 const char *Cmd_CompleteCommand (const char *partial)
870 len = strlen(partial);
876 for (cmd = cmd_functions; cmd; cmd = cmd->next)
877 if (!strncasecmp(partial, cmd->name, len))
884 Cmd_CompleteCountPossible
886 New function for tab-completion system
888 Thanks to Fett erich@heintz.com
892 int Cmd_CompleteCountPossible (const char *partial)
899 len = strlen(partial);
904 // Loop through the command list and count all partial matches
905 for (cmd = cmd_functions; cmd; cmd = cmd->next)
906 if (!strncasecmp(partial, cmd->name, len))
913 Cmd_CompleteBuildList
915 New function for tab-completion system
917 Thanks to Fett erich@heintz.com
921 const char **Cmd_CompleteBuildList (const char *partial)
926 size_t sizeofbuf = (Cmd_CompleteCountPossible (partial) + 1) * sizeof (const char *);
929 len = strlen(partial);
930 buf = (const char **)Mem_Alloc(tempmempool, sizeofbuf + sizeof (const char *));
931 // Loop through the alias list and print all matches
932 for (cmd = cmd_functions; cmd; cmd = cmd->next)
933 if (!strncasecmp(partial, cmd->name, len))
934 buf[bpos++] = cmd->name;
940 // written by LordHavoc
941 void Cmd_CompleteCommandPrint (const char *partial)
944 size_t len = strlen(partial);
945 // Loop through the command list and print all matches
946 for (cmd = cmd_functions; cmd; cmd = cmd->next)
947 if (!strncasecmp(partial, cmd->name, len))
948 Con_Printf("%s : %s\n", cmd->name, cmd->description);
954 New function for tab-completion system
956 Thanks to Fett erich@heintz.com
960 const char *Cmd_CompleteAlias (const char *partial)
965 len = strlen(partial);
971 for (alias = cmd_alias; alias; alias = alias->next)
972 if (!strncasecmp(partial, alias->name, len))
978 // written by LordHavoc
979 void Cmd_CompleteAliasPrint (const char *partial)
982 size_t len = strlen(partial);
983 // Loop through the alias list and print all matches
984 for (alias = cmd_alias; alias; alias = alias->next)
985 if (!strncasecmp(partial, alias->name, len))
986 Con_Printf("%s : %s\n", alias->name, alias->value);
991 Cmd_CompleteAliasCountPossible
993 New function for tab-completion system
995 Thanks to Fett erich@heintz.com
999 int Cmd_CompleteAliasCountPossible (const char *partial)
1007 len = strlen(partial);
1012 // Loop through the command list and count all partial matches
1013 for (alias = cmd_alias; alias; alias = alias->next)
1014 if (!strncasecmp(partial, alias->name, len))
1021 Cmd_CompleteAliasBuildList
1023 New function for tab-completion system
1024 Added by EvilTypeGuy
1025 Thanks to Fett erich@heintz.com
1029 const char **Cmd_CompleteAliasBuildList (const char *partial)
1034 size_t sizeofbuf = (Cmd_CompleteAliasCountPossible (partial) + 1) * sizeof (const char *);
1037 len = strlen(partial);
1038 buf = (const char **)Mem_Alloc(tempmempool, sizeofbuf + sizeof (const char *));
1039 // Loop through the alias list and print all matches
1040 for (alias = cmd_alias; alias; alias = alias->next)
1041 if (!strncasecmp(partial, alias->name, len))
1042 buf[bpos++] = alias->name;
1048 void Cmd_ClearCsqcFuncs (void)
1050 cmd_function_t *cmd;
1051 for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
1052 cmd->csqcfunc = false;
1055 qboolean CL_VM_ConsoleCommand (const char *cmd);
1060 A complete command line has been parsed, so try to execute it
1061 FIXME: lookupnoadd the token to speed search?
1064 void Cmd_ExecuteString (const char *text, cmd_source_t src)
1067 cmd_function_t *cmd;
1070 oldpos = cmd_tokenizebufferpos;
1073 Cmd_TokenizeString (text);
1075 // execute the command line
1078 cmd_tokenizebufferpos = oldpos;
1079 return; // no tokens
1083 for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
1085 if (!strcasecmp (cmd_argv[0],cmd->name))
1087 if(cmd->function && !cmd->csqcfunc)
1090 if(CL_VM_ConsoleCommand (text)) //[515]: csqc
1095 cmd_tokenizebufferpos = oldpos;
1101 for (a=cmd_alias ; a ; a=a->next)
1103 if (!strcasecmp (cmd_argv[0], a->name))
1105 Cmd_ExecuteAlias(a);
1106 cmd_tokenizebufferpos = oldpos;
1112 if (!Cvar_Command () && host_framecount > 0)
1113 Con_Printf("Unknown command \"%s\"\n", Cmd_Argv(0));
1115 cmd_tokenizebufferpos = oldpos;
1121 Cmd_ForwardStringToServer
1123 Sends an entire command string over to the server, unprocessed
1126 void Cmd_ForwardStringToServer (const char *s)
1128 if (cls.state != ca_connected)
1130 Con_Printf("Can't \"%s\", not connected\n", s);
1137 // LordHavoc: thanks to Fuh for bringing the pure evil of SZ_Print to my
1138 // attention, it has been eradicated from here, its only (former) use in
1139 // all of darkplaces.
1140 if (cls.protocol == PROTOCOL_QUAKEWORLD)
1141 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
1143 MSG_WriteByte(&cls.netcon->message, clc_stringcmd);
1144 SZ_Write(&cls.netcon->message, (const unsigned char *)s, (int)strlen(s) + 1);
1151 Sends the entire command line over to the server
1154 void Cmd_ForwardToServer (void)
1157 if (!strcasecmp(Cmd_Argv(0), "cmd"))
1159 // we want to strip off "cmd", so just send the args
1160 s = Cmd_Argc() > 1 ? Cmd_Args() : "";
1164 // we need to keep the command name, so send Cmd_Argv(0), a space and then Cmd_Args()
1165 s = va("%s %s", Cmd_Argv(0), Cmd_Argc() > 1 ? Cmd_Args() : "");
1167 // don't send an empty forward message if the user tries "cmd" by itself
1170 Cmd_ForwardStringToServer(s);
1178 Returns the position (1 to argc-1) in the command's argument list
1179 where the given parameter apears, or 0 if not present
1183 int Cmd_CheckParm (const char *parm)
1189 Con_Printf ("Cmd_CheckParm: NULL");
1193 for (i = 1; i < Cmd_Argc (); i++)
1194 if (!strcasecmp (parm, Cmd_Argv (i)))