take cmd.[ch] back to basics. the gib code is temporarily gone pending

renovations. cmd_source handling is a little hacky in nq, but it's working.
This commit is contained in:
Bill Currie 2002-07-31 05:19:03 +00:00
parent 021decc7bd
commit ad6e025a91
41 changed files with 442 additions and 2586 deletions

View file

@ -5,7 +5,6 @@
@extern integer () Cmd_Argc; @extern integer () Cmd_Argc;
@extern string (integer arg) Cmd_Argv; @extern string (integer arg) Cmd_Argv;
@extern string (integer arg) Cmd_Args; @extern string (integer arg) Cmd_Args;
@extern string (integer arg) Cmd_Argu;
@extern void (string value) Cmd_Return; @extern void (string value) Cmd_Return;
#endif//__cmd_h #endif//__cmd_h

View file

@ -4,5 +4,4 @@ void (string name, void () func) Cmd_AddCommand = #0;
integer () Cmd_Argc = #0; integer () Cmd_Argc = #0;
string (integer arg) Cmd_Argv = #0; string (integer arg) Cmd_Argv = #0;
string (integer arg) Cmd_Args = #0; string (integer arg) Cmd_Args = #0;
string (integer arg) Cmd_Argu = #0;
void (string value) Cmd_Return = #0; void (string value) Cmd_Return = #0;

View file

@ -32,6 +32,8 @@
#ifndef __QF_cbuf_h #ifndef __QF_cbuf_h
#define __QF_cbuf_h #define __QF_cbuf_h
#include "QF/qtypes.h"
typedef struct cbuf_args_s { typedef struct cbuf_args_s {
int argc; int argc;
struct dstring_s **argv; struct dstring_s **argv;
@ -45,8 +47,19 @@ typedef struct cbuf_s {
cbuf_args_t *args; cbuf_args_t *args;
void (*extract_line) (struct cbuf_s *cbuf); void (*extract_line) (struct cbuf_s *cbuf);
void (*parse_line) (struct cbuf_s *cbuf); void (*parse_line) (struct cbuf_s *cbuf);
qboolean wait;
} cbuf_t; } cbuf_t;
extern cbuf_t *cbuf_active;
extern const char *com_token;
const char *COM_Parse (const char *data);
void COM_TokenizeString (const char *str, cbuf_args_t *args);
cbuf_args_t *Cbuf_ArgsNew (void);
void Cbuf_ArgsDelete (cbuf_args_t *);
void Cbuf_ArgsAdd (cbuf_args_t *args, const char *arg);
cbuf_t *Cbuf_New (void); cbuf_t *Cbuf_New (void);
void CBuf_Delete (cbuf_t *cbuf); void CBuf_Delete (cbuf_t *cbuf);
void Cbuf_AddText (cbuf_t *cbuf, const char *text); void Cbuf_AddText (cbuf_t *cbuf, const char *text);

View file

@ -26,124 +26,11 @@
$Id$ $Id$
*/ */
#ifndef __cmd_h #ifndef __QF_cmd_h
#define __cmd_h #define __QF_cmd_h
#include "QF/qtypes.h" #include "QF/qtypes.h"
typedef struct cmd_localvar_s {
struct dstring_s *key, *value;
} cmd_localvar_t;
typedef struct cmd_token_s {
struct dstring_s *original, *processed; // Token before and after processing
enum {
cmd_original,
cmd_process,
cmd_done
} state;
unsigned int pos; // Last position in string (used by Cmd_ProcessEmbedded)
char delim; // Character that delimeted token
} cmd_token_t;
typedef struct cmd_buffer_s {
// Data
struct dstring_s *buffer; // Actual text
unsigned int argc, maxargc; // Number of args, number of args allocated
struct cmd_token_s **argv; // Tokens
struct dstring_s *realline; // Actual command being processed
struct dstring_s *line; // Processed command line
struct dstring_s *looptext; // If a looping buffer, the text we are looping on
struct dstring_s *retval; // Value returned to this buffer
unsigned int *args; // Array of positions of each token in processed line
unsigned int *argsu; // Array of positions of each token in original line
struct hashtab_s *locals; // Local variables
// Flags
qboolean subroutine; // Temporarily stopped so a subroutine can run
qboolean again; // The last command needs to be executed again for some reason
qboolean wait; // Execution paused until next frame
qboolean legacy; // Backwards compatible with old console buffer
qboolean ownvars; // Buffer has its own set of local variables (as opposed to sharing with another buffer)
unsigned int loop; // Buffer loops itself. If true, value signifies number of loops done so far
qboolean embedded; // Buffer exists to evaluate embedded command
qboolean restricted; // Restricted commands should not run in this buffer
// Sleep data
double timeleft;
double lasttime;
// Execution position
enum {
cmd_ready, // Ready to read a command
cmd_tokenized, // Command successfully tokenized
cmd_processed // Command successfully processed, it can be run
} position;
// Return value status
enum {
cmd_normal, // Normal status
cmd_waiting, // Waiting for a return value
cmd_returned // Return value available
} returned;
// Stack
struct cmd_buffer_s *prev, *next; // Neighboring buffers in stack
} cmd_buffer_t;
typedef struct cmd_thread_s {
struct cmd_buffer_s *cbuf; // Actual buffer
long int id; // Thread id
struct cmd_thread_s *prev, *next; // Linked list
} cmd_thread_t;
typedef struct cmd_event_s {
struct dstring_s *name, *command;
} cmd_event_t;
//===========================================================================
void escape (struct dstring_s * dstr, const char *clist);
/*
Any number of commands can be added in a frame, from several different sources,
into several different buffers.
Most commands come from either keybindings or console line input, but remote
servers can also send across commands and entire text files can be execed.
The + command line options are also added to the command buffer.
The game starts with a Cbuf_AddText ("exec quake.rc\n"); Cbuf_Execute ();
*/
void Cbuf_Init (void);
// allocates all needed command buffers
void Cbuf_AddTextTo (cmd_buffer_t *buffer, const char *text);
// adds text to the end of a specific buffer
void Cbuf_AddText (const char *text);
// adds text to the end of the active buffer. By default this is the console buffer.
void Cbuf_InsertText (const char *text);
// inserts text at the beginning of the active buffer, ahead of other commands
void Cbuf_InsertTextTo (cmd_buffer_t *buffer, const char *text);
// insert text at the beginning of a particular buffer
void Cbuf_Execute_Sets (void);
// executes all set and setrom commands in the console buffer. Used early in startup.
void Cbuf_Execute (void);
// Executes all threads in reverse order of creation, all commands from key binds,
// all commands from the console buffer, and all commands stuffed by the server
// Normally called once per frame, but may be explicitly invoked.
// Do not call inside a command function!
//===========================================================================
typedef void (*xcommand_t) (void); typedef void (*xcommand_t) (void);
typedef enum { typedef enum {
@ -156,90 +43,29 @@ extern cmd_source_t cmd_source;
void Cmd_Init_Hash (void); void Cmd_Init_Hash (void);
void Cmd_Init (void); void Cmd_Init (void);
void cl_Cmd_Init (void);
int Cmd_AddCommand (const char *cmd_name, xcommand_t function, const char *description); int Cmd_AddCommand (const char *cmd_name, xcommand_t function, const char *description);
int Cmd_RemoveCommand (const char *cmd_name); int Cmd_RemoveCommand (const char *cmd_name);
// called by the init functions of other parts of the program to
// register commands and functions to call for them.
// The cmd_name is referenced later, so it should not be in temp memory
// if function is NULL, the command will be forwarded to the server
// as a clc_stringcmd instead of being executed locally
qboolean Cmd_Exists (const char *cmd_name); qboolean Cmd_Exists (const char *cmd_name);
// used by the cvar code to check for cvar / command name overlap
const char *Cmd_CompleteCommand (const char *partial); const char *Cmd_CompleteCommand (const char *partial);
// attempts to match a partial command for automatic command line completion
// returns NULL if nothing fits
int Cmd_CompleteCountPossible (const char *partial); int Cmd_CompleteCountPossible (const char *partial);
const char **Cmd_CompleteBuildList (const char *partial); const char **Cmd_CompleteBuildList (const char *partial);
const char *Cmd_CompleteAlias (const char *partial);
// Enhanced console completion by Fett erich@heintz.com
// Added by EvilTypeGuy eviltypeguy@qeradiant.com
int Cmd_Argc (void); int Cmd_Argc (void);
// Returns the number of arguments passed to the console command
const char *Cmd_Argv (int arg); const char *Cmd_Argv (int arg);
// Returns the arg-th argument passed to the command, 0 being the name of the command
const char *Cmd_Args (int start); const char *Cmd_Args (int start);
// Returns the entire command line starting at the start-th token struct cbuf_args_s;
const char *Cmd_Argu (int arg); void Cmd_Command (struct cbuf_args_s *args);
// Returns the unprocessed version of an argument
const char *Cmd_Argsu (int arg);
// Like Cmd_Args, but returns the unprocessed version
// The functions that execute commands get their parameters with these
// functions. Cmd_Argv () will return an empty string, not a NULL
// if arg > argc, so string operations are always safe.
int Cmd_Process (void);
// Processes all parsed tokens according to the type of buffer
// and the settings of each token
void Cmd_TokenizeString (const char *text, qboolean legacy);
// Takes a null terminated string. Does not need to be /n terminated.
// breaks the string up into arg tokens.
void Cmd_ExecuteParsed (cmd_source_t src);
// Executes a previously tokenized command
int Cmd_ExecuteString (const char *text, cmd_source_t src); int Cmd_ExecuteString (const char *text, cmd_source_t src);
// Executes a single command in the context of a private buffer struct cbuf_s;
// This allows the rest of QF to access console commands without void Cmd_StuffCmds (struct cbuf_s *cbuf);
// affecting the console buffer
void Cmd_ForwardToServer (void);
// adds the current command line as a clc_stringcmd to the client message.
// things like godmode, noclip, etc, are commands directed to the server,
// so when they are typed in at the console, they will need to be forwarded.
void Cmd_StuffCmds_f (void);
// stuffs console commands on the command line into the console buffer
void Cmd_Exec_File (const char *path); void Cmd_Exec_File (const char *path);
// dumps a file into the console buffer. Does not execute it as a subroutine
// like the exec command!
extern char *com_token;
const char *COM_Parse (const char *data);
// This is the legacy token parser. It exists only to satisfy certain portions
// of the code
void Cmd_Return (const char *value); void Cmd_Return (const char *value);
// Returns a value to GIB so that it can be picked up for embedded commands
void Cmd_Error (const char *message); void Cmd_Error (const char *message);
// Generates a GIB error
qboolean Cmd_Restricted (void);
// Returns true if current buffer is restricted
extern struct cbuf_args_s *cmd_args;
extern struct cvar_s *cmd_warncmd; extern struct cvar_s *cmd_warncmd;
// Determines if warnings resulting from console commands are printed
extern cmd_buffer_t *cmd_legacybuffer; // Allow access to the legacy buffer as an alternate console buffer #endif//__QF_cmd_h
extern cmd_buffer_t *cmd_keybindbuffer; // Allow access to dedicated key binds command buffer
#endif // __cmd_h

View file

@ -380,7 +380,7 @@ extern imt_t game_target;
extern struct keybind_s { extern struct keybind_s {
char *str; char *str;
qboolean restricted; struct cbuf_s *cbuf;
} keybindings[IMT_LAST][QFK_LAST]; } keybindings[IMT_LAST][QFK_LAST];
extern int keydown[QFK_LAST]; extern int keydown[QFK_LAST];
@ -390,7 +390,7 @@ void Key_Init_Cvars (void);
void Key_WriteBindings (VFile *f); void Key_WriteBindings (VFile *f);
void Key_ClearStates (void); void Key_ClearStates (void);
const char *Key_GetBinding (imt_t imt, knum_t key); const char *Key_GetBinding (imt_t imt, knum_t key);
void Key_SetBinding (imt_t target, knum_t keynum, const char *binding, qboolean restricted); void Key_SetBinding (imt_t target, knum_t keynum, const char *binding);
const char *Key_KeynumToString (knum_t keynum); const char *Key_KeynumToString (knum_t keynum);

View file

@ -58,6 +58,7 @@ typedef struct console_data_s {
int force_commandline; int force_commandline;
int ormask; int ormask;
void (*quit)(void); void (*quit)(void);
struct cbuf_s *cbuf;
} console_data_t; } console_data_t;
#endif // __QF_plugin_console_h_ #endif // __QF_plugin_console_h_

View file

@ -40,6 +40,7 @@ static const char rcsid[] =
#include <stdarg.h> #include <stdarg.h>
#include <errno.h> #include <errno.h>
#include "QF/cbuf.h"
#include "QF/cmd.h" #include "QF/cmd.h"
#include "QF/console.h" #include "QF/console.h"
#include "QF/cvar.h" #include "QF/cvar.h"
@ -290,17 +291,17 @@ C_ExecLine (const char *line)
if (line[0] == '/' && line [1] == '/') if (line[0] == '/' && line [1] == '/')
goto no_lf; goto no_lf;
else if (line[0] == '|') else if (line[0] == '|')
Cbuf_AddText (line); Cbuf_AddText (con_data.cbuf, line);
else if (line[0] == '\\' || line[0] == '/') else if (line[0] == '\\' || line[0] == '/')
Cbuf_AddText (line + 1); Cbuf_AddText (con_data.cbuf, line + 1);
else if (cl_chatmode->int_val != 1 && CheckForCommand (line)) else if (cl_chatmode->int_val != 1 && CheckForCommand (line))
Cbuf_AddText (line); Cbuf_AddText (con_data.cbuf, line);
else if (cl_chatmode->int_val) { else if (cl_chatmode->int_val) {
Cbuf_AddText ("say "); Cbuf_AddText (con_data.cbuf, "say ");
Cbuf_AddText (line); Cbuf_AddText (con_data.cbuf, line);
} else } else
Cbuf_AddText (line); Cbuf_AddText (con_data.cbuf, line);
Cbuf_AddText ("\n"); Cbuf_AddText (con_data.cbuf, "\n");
no_lf: no_lf:
Con_Printf ("%s\n", line); Con_Printf ("%s\n", line);
} }
@ -310,10 +311,9 @@ C_Say (const char *line)
{ {
dstring_t *dstr = dstring_newstr (); dstring_t *dstr = dstring_newstr ();
dstring_appendstr (dstr, line); dstring_appendstr (dstr, line);
escape (dstr, "\"$#~\\"); Cbuf_AddText (con_data.cbuf, "say \"");
Cbuf_AddTextTo (cmd_keybindbuffer, "say \""); Cbuf_AddText (con_data.cbuf, dstr->str);
Cbuf_AddTextTo (cmd_keybindbuffer, dstr->str); Cbuf_AddText (con_data.cbuf, "\"\n");
Cbuf_AddTextTo (cmd_keybindbuffer, "\"\n");
dstring_delete (dstr); dstring_delete (dstr);
key_dest = key_game; key_dest = key_game;
game_target = IMT_0; game_target = IMT_0;
@ -324,10 +324,9 @@ C_SayTeam (const char *line)
{ {
dstring_t *dstr = dstring_newstr (); dstring_t *dstr = dstring_newstr ();
dstring_appendstr (dstr, line); dstring_appendstr (dstr, line);
escape (dstr, "\""); Cbuf_AddText (con_data.cbuf, "say_team \"");
Cbuf_AddTextTo (cmd_keybindbuffer, "say_team \""); Cbuf_AddText (con_data.cbuf, dstr->str);
Cbuf_AddTextTo (cmd_keybindbuffer, dstr->str); Cbuf_AddText (con_data.cbuf, "\"\n");
Cbuf_AddTextTo (cmd_keybindbuffer, "\"\n");
dstring_delete (dstr); dstring_delete (dstr);
key_dest = key_game; key_dest = key_game;
game_target = IMT_0; game_target = IMT_0;
@ -515,7 +514,7 @@ C_KeyEvent (knum_t key, short unicode, qboolean down)
return; return;
case key_console: case key_console:
if (!con_data.force_commandline) { if (!con_data.force_commandline) {
Cbuf_AddTextTo (cmd_keybindbuffer, "toggleconsole\n"); Cbuf_AddText (con_data.cbuf, "toggleconsole\n");
return; return;
} }
case key_game: case key_game:

View file

@ -55,6 +55,7 @@ static const char rcsid[] =
#include <signal.h> #include <signal.h>
#include <stdlib.h> #include <stdlib.h>
#include "QF/cbuf.h"
#include "QF/cmd.h" #include "QF/cmd.h"
#include "QF/console.h" #include "QF/console.h"
#include "QF/cvar.h" #include "QF/cvar.h"
@ -66,6 +67,7 @@ static const char rcsid[] =
#include "compat.h" #include "compat.h"
static console_data_t con_data;
#ifdef HAVE_CURSES_H #ifdef HAVE_CURSES_H
static int use_curses = 1; static int use_curses = 1;
@ -115,7 +117,7 @@ C_ExecLine (const char *line)
{ {
if (line[0] == '/') if (line[0] == '/')
line++; line++;
Cbuf_AddText (line); Cbuf_AddText (con_data.cbuf, line);
} }
static inline void static inline void
@ -410,7 +412,7 @@ C_ProcessInput (void)
const char *cmd = Sys_ConsoleInput (); const char *cmd = Sys_ConsoleInput ();
if (!cmd) if (!cmd)
break; break;
Cbuf_AddText (cmd); Cbuf_AddText (con_data.cbuf, cmd);
} }
} }
@ -448,7 +450,6 @@ static console_funcs_t plugin_info_console_funcs = {
C_CheckResize, C_CheckResize,
C_NewMap, C_NewMap,
}; };
static console_data_t plugin_info_console_data;
static plugin_funcs_t plugin_info_funcs = { static plugin_funcs_t plugin_info_funcs = {
&plugin_info_general_funcs, &plugin_info_general_funcs,
@ -461,7 +462,7 @@ static plugin_data_t plugin_info_data = {
&plugin_info_general_data, &plugin_info_general_data,
0, 0,
0, 0,
&plugin_info_console_data, &con_data,
}; };
static plugin_t plugin_info = { static plugin_t plugin_info = {

View file

@ -30,15 +30,25 @@ static const char rcsid[] =
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
#include "QF/cmd.h" #include "QF/cbuf.h"
#include "QF/progs.h" #include "QF/progs.h"
static cbuf_t *cbuf; //FIXME use a properly allocated cbuf rather than this hack
static inline void
check_cbuf (void)
{
if (!cbuf)
cbuf = Cbuf_New ();
}
static void static void
bi_Cbuf_AddText (progs_t *pr) bi_Cbuf_AddText (progs_t *pr)
{ {
const char *text = P_STRING (pr, 0); const char *text = P_STRING (pr, 0);
Cbuf_AddText (text); check_cbuf ();
Cbuf_AddText (cbuf, text);
} }
static void static void
@ -46,19 +56,22 @@ bi_Cbuf_InsertText (progs_t *pr)
{ {
const char *text = P_STRING (pr, 0); const char *text = P_STRING (pr, 0);
Cbuf_InsertText (text); check_cbuf ();
Cbuf_InsertText (cbuf, text);
} }
static void static void
bi_Cbuf_Execute (progs_t *pr) bi_Cbuf_Execute (progs_t *pr)
{ {
Cbuf_Execute (); check_cbuf ();
Cbuf_Execute (cbuf);
} }
static void static void
bi_Cbuf_Execute_Sets (progs_t *pr) bi_Cbuf_Execute_Sets (progs_t *pr)
{ {
Cbuf_Execute_Sets (); check_cbuf ();
Cbuf_Execute_Sets (cbuf);
} }
void void

View file

@ -142,12 +142,6 @@ bi_Cmd_Args (progs_t *pr)
RETURN_STRING (pr, Cmd_Args (P_INT (pr, 0))); RETURN_STRING (pr, Cmd_Args (P_INT (pr, 0)));
} }
static void
bi_Cmd_Argu (progs_t *pr)
{
RETURN_STRING (pr, Cmd_Argu (P_INT (pr, 0)));
}
static void static void
bi_Cmd_Return (progs_t *pr) bi_Cmd_Return (progs_t *pr)
{ {
@ -172,6 +166,5 @@ Cmd_Progs_Init (progs_t *pr)
PR_AddBuiltin (pr, "Cmd_Argc", bi_Cmd_Argc, -1); PR_AddBuiltin (pr, "Cmd_Argc", bi_Cmd_Argc, -1);
PR_AddBuiltin (pr, "Cmd_Argv", bi_Cmd_Argv, -1); PR_AddBuiltin (pr, "Cmd_Argv", bi_Cmd_Argv, -1);
PR_AddBuiltin (pr, "Cmd_Args", bi_Cmd_Args, -1); PR_AddBuiltin (pr, "Cmd_Args", bi_Cmd_Args, -1);
PR_AddBuiltin (pr, "Cmd_Argu", bi_Cmd_Argu, -1);
PR_AddBuiltin (pr, "Cmd_Return", bi_Cmd_Return, -1); PR_AddBuiltin (pr, "Cmd_Return", bi_Cmd_Return, -1);
} }

View file

@ -38,10 +38,20 @@ static const char rcsid[] =
# include <strings.h> # include <strings.h>
#endif #endif
#include "QF/cbuf.h"
#include "QF/keys.h" #include "QF/keys.h"
#include "QF/progs.h" #include "QF/progs.h"
#include "QF/zone.h" #include "QF/zone.h"
static cbuf_t *cbuf; //FIXME use a properly allocated cbuf rather than this hack
static inline void
check_cbuf (void)
{
if (!cbuf)
cbuf = Cbuf_New ();
}
/* /*
bi_Key_SetBinding bi_Key_SetBinding
@ -53,12 +63,16 @@ bi_Key_SetBinding (progs_t *pr)
int target = P_INT (pr, 0); int target = P_INT (pr, 0);
int keynum = P_INT (pr, 1); int keynum = P_INT (pr, 1);
const char *binding = P_STRING (pr, 2); const char *binding = P_STRING (pr, 2);
cbuf_t *tcb = cbuf_active;
if(strlen(binding) == 0 || binding[0] == '\0') { if(strlen(binding) == 0 || binding[0] == '\0') {
binding = NULL; /* unbind a binding */ binding = NULL; /* unbind a binding */
} }
Key_SetBinding (target, keynum, binding, false); check_cbuf ();
cbuf_active = cbuf;
Key_SetBinding (target, keynum, binding);
cbuf_active = tcb;
} }
/* /*

View file

@ -39,7 +39,7 @@ static const char rcsid[] =
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include "QF/cmd.h" #include "QF/cbuf.h"
#include "QF/crc.h" #include "QF/crc.h"
#include "QF/cvar.h" #include "QF/cvar.h"
#include "QF/hash.h" #include "QF/hash.h"
@ -785,6 +785,7 @@ ED_ParseEdict (progs_t * pr, const char *data, edict_t *ent)
qboolean anglehack; qboolean anglehack;
qboolean init; qboolean init;
char keyname[256]; char keyname[256];
const char *token;
int n; int n;
init = false; init = false;
@ -802,19 +803,19 @@ ED_ParseEdict (progs_t * pr, const char *data, edict_t *ent)
if (!data) if (!data)
PR_Error (pr, "ED_ParseEntity: EOF without closing brace"); PR_Error (pr, "ED_ParseEntity: EOF without closing brace");
token = com_token;
// anglehack is to allow QuakeEd to write single scalar angles // anglehack is to allow QuakeEd to write single scalar angles
// and allow them to be turned into vectors. (FIXME...) // and allow them to be turned into vectors. (FIXME...)
if (!strcmp (com_token, "angle")) { if (!strcmp (token, "angle")) {
strcpy (com_token, "angles"); token = "angles";
anglehack = true; anglehack = true;
} else } else
anglehack = false; anglehack = false;
// FIXME: change light to _light to get rid of this hack if (!strcmp (token, "light"))
if (!strcmp (com_token, "light")) token = "light_lev"; // hack for single light def
strcpy (com_token, "light_lev"); // hack for single light def
strcpy (keyname, com_token); strcpy (keyname, token);
// another hack to fix heynames with trailing spaces // another hack to fix heynames with trailing spaces
n = strlen (keyname); n = strlen (keyname);

View file

@ -26,7 +26,7 @@ libQFutil_la_LDFLAGS= -version-info 1:0:0
libQFutil_la_LIBADD= libasm.la $(Z_LIBS) $(DL_LIBS) libQFutil_la_LIBADD= libasm.la $(Z_LIBS) $(DL_LIBS)
libQFutil_la_DEPENDENCIES= libasm.la libQFutil_la_DEPENDENCIES= libasm.la
libQFutil_la_SOURCES= \ libQFutil_la_SOURCES= \
buildnum.c checksum.c cmd.c crc.c cvar.c dstring.c exp.c fendian.c \ buildnum.c cbuf.c checksum.c cmd.c crc.c cvar.c dstring.c exp.c fendian.c \
getopt.c getopt1.c hash.c info.c link.c mathlib.c mdfour.c msg.c ops.c \ getopt.c getopt1.c hash.c info.c link.c mathlib.c mdfour.c msg.c ops.c \
pakfile.c pcx.c plugin.c qargs.c qendian.c qfplist.c quakefs.c quakeio.c \ pakfile.c pcx.c plugin.c qargs.c qendian.c qfplist.c quakefs.c quakeio.c \
sizebuf.c string.c sys.c tga.c va.c ver_check.c wad.c zone.c $(fnmatch) sizebuf.c string.c sys.c tga.c va.c ver_check.c wad.c zone.c $(fnmatch)

View file

@ -43,6 +43,7 @@ static const char rcsid[] =
#include <stdlib.h> #include <stdlib.h>
#include "QF/cbuf.h" #include "QF/cbuf.h"
#include "QF/cmd.h"
#include "QF/dstring.h" #include "QF/dstring.h"
#include "QF/qtypes.h" #include "QF/qtypes.h"
@ -50,6 +51,7 @@ static const char rcsid[] =
static dstring_t *_com_token; static dstring_t *_com_token;
const char *com_token; const char *com_token;
cbuf_t *cbuf_active;
cbuf_args_t * cbuf_args_t *
Cbuf_ArgsNew (void) Cbuf_ArgsNew (void)
@ -184,7 +186,7 @@ extract_line (cbuf_t *cbuf)
if (text[i] == '/' && text[i + 1] == '/') { if (text[i] == '/' && text[i + 1] == '/') {
int j = i; int j = i;
while (j < len && text[j] != '\n' && text[j] != '\r') while (j < len && text[j] != '\n' && text[j] != '\r')
i++; j++;
dstring_snip (cbuf->buf, i, j - i); dstring_snip (cbuf->buf, i, j - i);
len -= j - i; len -= j - i;
} }
@ -248,25 +250,33 @@ Cbuf_InsertText (cbuf_t *cbuf, const char *text)
void void
Cbuf_Execute (cbuf_t *cbuf) Cbuf_Execute (cbuf_t *cbuf)
{ {
cbuf_args_t *args = cbuf->args;
cbuf_active = cbuf;
while (cbuf->buf->str[0]) { while (cbuf->buf->str[0]) {
cbuf->extract_line (cbuf); cbuf->extract_line (cbuf);
cbuf->parse_line (cbuf); cbuf->parse_line (cbuf);
if (!cbuf->args->argc) if (!args->argc)
continue; continue;
Cmd_ExecCmd (cbuf->args); Cmd_Command (args);
if (cbuf->wait)
break;
} }
} }
void void
Cbuf_Execute_Sets (cbuf_t *cbuf) Cbuf_Execute_Sets (cbuf_t *cbuf)
{ {
cbuf_args_t *args = cbuf->args;
cbuf_active = cbuf;
while (cbuf->buf->str[0]) { while (cbuf->buf->str[0]) {
cbuf->extract_line (cbuf); cbuf->extract_line (cbuf);
cbuf->parse_line (cbuf); cbuf->parse_line (cbuf);
if (!cbuf->args->argc) if (!args->argc)
continue; continue;
if (strequal (cbuf->args->argv[0]->str, "set") if (strequal (args->argv[0]->str, "set")
|| strequal (cbuf->args->argv[0]->str, "setrom")) || strequal (args->argv[0]->str, "setrom"))
Cmd_ExecCmd (cbuf); Cmd_Command (args);
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -41,6 +41,7 @@ static const char rcsid[] =
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "QF/cbuf.h"
#include "QF/cmd.h" #include "QF/cmd.h"
#include "QF/console.h" #include "QF/console.h"
#include "QF/cvar.h" #include "QF/cvar.h"
@ -385,10 +386,10 @@ Key_Game (knum_t key, short unicode)
{ {
const char *kb; const char *kb;
char cmd[1024]; char cmd[1024];
cmd_buffer_t *tbuffer; cbuf_t *cbuf;
kb = Key_GetBinding(game_target, key); kb = Key_GetBinding(game_target, key);
tbuffer = keybindings[game_target][key].restricted ? cmd_legacybuffer : cmd_keybindbuffer; cbuf = keybindings[game_target][key].cbuf;
if (!kb && (game_target > IMT_0)) if (!kb && (game_target > IMT_0))
kb = Key_GetBinding(IMT_0, key); kb = Key_GetBinding(IMT_0, key);
@ -399,20 +400,17 @@ Key_Game (knum_t key, short unicode)
if (!kb) if (!kb)
return false; return false;
if (!keydown[key]) {
if (kb[0] == '+') {
snprintf (cmd, sizeof (cmd), "-%s %d\n", kb + 1, key);
Cbuf_AddTextTo (tbuffer, cmd);
}
} else if (keydown[key] == 1) {
if (kb[0] == '+') { if (kb[0] == '+') {
if (keydown[key] == 1)
snprintf (cmd, sizeof (cmd), "%s %d\n", kb, key); snprintf (cmd, sizeof (cmd), "%s %d\n", kb, key);
Cbuf_AddTextTo (tbuffer, cmd); else
snprintf (cmd, sizeof (cmd), "-%s %d\n", kb + 1, key);
} else { } else {
if (!keydown[key])
return true;
snprintf (cmd, sizeof (cmd), "%s\n", kb); snprintf (cmd, sizeof (cmd), "%s\n", kb);
Cbuf_AddTextTo (tbuffer, cmd);
}
} }
Cbuf_AddText (cbuf, cmd);
return true; return true;
} }
@ -535,7 +533,7 @@ Key_In_Unbind (const char *imt, const char *key)
return; return;
} }
Key_SetBinding (t, b, NULL, false); Key_SetBinding (t, b, NULL);
} }
void void
@ -555,11 +553,11 @@ Key_Unbindall_f (void)
for (j = 0; j < IMT_LAST; j++) for (j = 0; j < IMT_LAST; j++)
for (i = 0; i < QFK_LAST; i++) for (i = 0; i < QFK_LAST; i++)
Key_SetBinding (j, i, NULL, false); Key_SetBinding (j, i, NULL);
} }
void void
Key_In_Bind (const char *imt, const char *key, const char *cmd, qboolean restricted) Key_In_Bind (const char *imt, const char *key, const char *cmd)
{ {
int t, b; int t, b;
@ -583,7 +581,7 @@ Key_In_Bind (const char *imt, const char *key, const char *cmd, qboolean restric
Con_Printf ("%s %s is not bound\n", imt, key); Con_Printf ("%s %s is not bound\n", imt, key);
return; return;
} }
Key_SetBinding (t, b, cmd, restricted); Key_SetBinding (t, b, cmd);
} }
void void
@ -616,7 +614,7 @@ Key_In_Bind_f (void)
} }
} }
Key_In_Bind (imt, key, cmd, Cmd_Restricted ()); Key_In_Bind (imt, key, cmd);
} }
void void
@ -661,7 +659,7 @@ Key_Bind_f (void)
} }
} }
Key_In_Bind (imt, key, cmd, Cmd_Restricted ()); Key_In_Bind (imt, key, cmd);
} }
void void
@ -833,7 +831,7 @@ Key_GetBinding (imt_t imt, knum_t key)
} }
void void
Key_SetBinding (imt_t target, knum_t keynum, const char *binding, qboolean restricted) Key_SetBinding (imt_t target, knum_t keynum, const char *binding)
{ {
if (keynum == -1) if (keynum == -1)
return; return;
@ -847,5 +845,5 @@ Key_SetBinding (imt_t target, knum_t keynum, const char *binding, qboolean restr
if (binding) { if (binding) {
keybindings[target][keynum].str = strdup(binding); keybindings[target][keynum].str = strdup(binding);
} }
keybindings[target][keynum].restricted = restricted; keybindings[target][keynum].cbuf = cbuf_active;
} }

View file

@ -388,4 +388,6 @@ void CL_UpdateScreen (double realtime);
void CL_SetState (cactive_t state); void CL_SetState (cactive_t state);
void CL_Cmd_ForwardToServer (void);
#endif // __client_h #endif // __client_h

View file

@ -58,6 +58,8 @@ extern int host_framecount; // incremented every frame, never reset
extern double realtime; // not bounded in any way, changed at extern double realtime; // not bounded in any way, changed at
// start of every frame, never reset // start of every frame, never reset
extern struct cbuf_s *host_cbuf;
void Host_ClearMemory (void); void Host_ClearMemory (void);
void Host_ServerFrame (void); void Host_ServerFrame (void);
void Host_InitCommands (void); void Host_InitCommands (void);

View file

@ -46,12 +46,12 @@ static const char rcsid[] =
/* /*
Cmd_ForwardToServer CL_Cmd_ForwardToServer
Sends the entire command line over to the server Sends the entire command line over to the server
*/ */
void void
Cmd_ForwardToServer (void) CL_Cmd_ForwardToServer (void)
{ {
if (cls.state != ca_connected) { if (cls.state != ca_connected) {
Con_Printf ("Can't \"%s\", not connected\n", Cmd_Argv (0)); Con_Printf ("Can't \"%s\", not connected\n", Cmd_Argv (0));
@ -76,7 +76,7 @@ void
cl_Cmd_Init (void) cl_Cmd_Init (void)
{ {
// register our commands // register our commands
Cmd_AddCommand ("cmd", Cmd_ForwardToServer, "Send a command to the " Cmd_AddCommand ("cmd", CL_Cmd_ForwardToServer, "Send a command to the "
"server.\n" "server.\n"
"Commands:\n" "Commands:\n"
"download - Same as the command.\n" "download - Same as the command.\n"

View file

@ -31,6 +31,7 @@ static const char rcsid[] =
# include "config.h" # include "config.h"
#endif #endif
#include "QF/cbuf.h"
#include "QF/cmd.h" #include "QF/cmd.h"
#include "QF/console.h" #include "QF/console.h"
#include "QF/cvar.h" #include "QF/cvar.h"
@ -356,7 +357,7 @@ CL_NextDemo (void)
} }
snprintf (str, sizeof (str), "playdemo %s\n", cls.demos[cls.demonum]); snprintf (str, sizeof (str), "playdemo %s\n", cls.demos[cls.demonum]);
Cbuf_InsertText (str); Cbuf_InsertText (host_cbuf, str);
cls.demonum++; cls.demonum++;
} }

View file

@ -37,6 +37,7 @@ static const char rcsid[] =
# include <strings.h> # include <strings.h>
#endif #endif
#include "QF/cbuf.h"
#include "QF/cdaudio.h" #include "QF/cdaudio.h"
#include "QF/cmd.h" #include "QF/cmd.h"
#include "QF/console.h" #include "QF/console.h"
@ -773,7 +774,7 @@ CL_ParseServerMessage (void)
break; break;
case svc_stufftext: case svc_stufftext:
Cbuf_AddTextTo (cmd_legacybuffer, MSG_ReadString (net_message)); Cbuf_AddText (host_cbuf, MSG_ReadString (net_message));
break; break;
case svc_damage: case svc_damage:

View file

@ -31,6 +31,7 @@ static const char rcsid[] =
# include "config.h" # include "config.h"
#endif #endif
#include "QF/cbuf.h"
#include "QF/cdaudio.h" #include "QF/cdaudio.h"
#include "QF/cmd.h" #include "QF/cmd.h"
#include "QF/console.h" #include "QF/console.h"
@ -78,6 +79,8 @@ qboolean host_initialized; // true if into command execution
quakeparms_t host_parms; quakeparms_t host_parms;
cbuf_t *host_cbuf;
double host_frametime; double host_frametime;
double host_time; double host_time;
double realtime; // without any filtering or bounding double realtime; // without any filtering or bounding
@ -599,7 +602,8 @@ _Host_Frame (float time)
} }
// process console commands // process console commands
Cbuf_Execute (); cmd_source = src_command;
Cbuf_Execute (host_cbuf);
NET_Poll (); NET_Poll ();
@ -843,17 +847,19 @@ Host_Init (void)
{ {
Con_Printf ("Host_Init\n"); Con_Printf ("Host_Init\n");
host_cbuf = Cbuf_New ();
cmd_source = src_command;
Cvar_Init_Hash (); Cvar_Init_Hash ();
Cmd_Init_Hash (); Cmd_Init_Hash ();
Cvar_Init (); Cvar_Init ();
Sys_Init_Cvars (); Sys_Init_Cvars ();
Cbuf_Init ();
Cmd_Init (); Cmd_Init ();
// execute +set as early as possible // execute +set as early as possible
Cmd_StuffCmds_f (); Cmd_StuffCmds (host_cbuf);
Cbuf_Execute_Sets (); Cbuf_Execute_Sets (host_cbuf);
// execute the global configuration file if it exists // execute the global configuration file if it exists
// would have been nice if Cmd_Exec_f could have been used, but it // would have been nice if Cmd_Exec_f could have been used, but it
@ -862,20 +868,20 @@ Host_Init (void)
fs_globalcfg = Cvar_Get ("fs_globalcfg", FS_GLOBALCFG, fs_globalcfg = Cvar_Get ("fs_globalcfg", FS_GLOBALCFG,
CVAR_ROM, NULL, "global configuration file"); CVAR_ROM, NULL, "global configuration file");
Cmd_Exec_File (fs_globalcfg->string); Cmd_Exec_File (fs_globalcfg->string);
Cbuf_Execute_Sets (); Cbuf_Execute_Sets (host_cbuf);
// execute +set again to override the config file // execute +set again to override the config file
Cmd_StuffCmds_f (); Cmd_StuffCmds (host_cbuf);
Cbuf_Execute_Sets (); Cbuf_Execute_Sets (host_cbuf);
fs_usercfg = Cvar_Get ("fs_usercfg", FS_USERCFG, CVAR_ROM, NULL, fs_usercfg = Cvar_Get ("fs_usercfg", FS_USERCFG, CVAR_ROM, NULL,
"user configuration file"); "user configuration file");
Cmd_Exec_File (fs_usercfg->string); Cmd_Exec_File (fs_usercfg->string);
Cbuf_Execute_Sets (); Cbuf_Execute_Sets (host_cbuf);
// execute +set again to override the config file // execute +set again to override the config file
Cmd_StuffCmds_f (); Cmd_StuffCmds (host_cbuf);
Cbuf_Execute_Sets (); Cbuf_Execute_Sets (host_cbuf);
CL_Init_Memory (); CL_Init_Memory ();
@ -915,6 +921,7 @@ Host_Init (void)
if (con_module) { if (con_module) {
con_module->data->console->realtime = &realtime; con_module->data->console->realtime = &realtime;
con_module->data->console->quit = Host_Quit_f; con_module->data->console->quit = Host_Quit_f;
con_module->data->console->cbuf = host_cbuf;
} }
Host_InitVCR (&host_parms); Host_InitVCR (&host_parms);
@ -958,12 +965,12 @@ Host_Init (void)
Host_Skin_Init (); Host_Skin_Init ();
if (!isDedicated && cl_quakerc->int_val) if (!isDedicated && cl_quakerc->int_val)
Cbuf_InsertText ("exec quake.rc\n"); Cbuf_InsertText (host_cbuf, "exec quake.rc\n");
Cmd_Exec_File (fs_usercfg->string); Cmd_Exec_File (fs_usercfg->string);
// reparse the command line for + commands other than set // reparse the command line for + commands other than set
// (sets still done, but it doesn't matter) // (sets still done, but it doesn't matter)
if (isDedicated || (cl_quakerc->int_val && check_quakerc ())) if (isDedicated || (cl_quakerc->int_val && check_quakerc ()))
Cmd_StuffCmds_f (); Cmd_StuffCmds (host_cbuf);
Hunk_AllocName (0, "-HOST_HUNKLEVEL-"); Hunk_AllocName (0, "-HOST_HUNKLEVEL-");
host_hunklevel = Hunk_LowMark (); host_hunklevel = Hunk_LowMark ();

View file

@ -31,8 +31,8 @@ static const char rcsid[] =
# include "config.h" # include "config.h"
#endif #endif
#include "QF/cbuf.h"
#include "QF/cmd.h" #include "QF/cmd.h"
#include "compat.h"
#include "QF/cvar.h" #include "QF/cvar.h"
#include "QF/va.h" #include "QF/va.h"
#include "QF/screen.h" #include "QF/screen.h"
@ -43,6 +43,7 @@ static const char rcsid[] =
#include "QF/sys.h" #include "QF/sys.h"
#include "client.h" #include "client.h"
#include "compat.h"
#include "host.h" #include "host.h"
#include "server.h" #include "server.h"
#include "sv_progs.h" #include "sv_progs.h"
@ -80,7 +81,7 @@ Host_Status_f (void)
if (cmd_source == src_command) { if (cmd_source == src_command) {
if (!sv.active) { if (!sv.active) {
Cmd_ForwardToServer (); CL_Cmd_ForwardToServer ();
return; return;
} }
print = Con_Printf; print = Con_Printf;
@ -124,7 +125,7 @@ void
Host_God_f (void) Host_God_f (void)
{ {
if (cmd_source == src_command) { if (cmd_source == src_command) {
Cmd_ForwardToServer (); CL_Cmd_ForwardToServer ();
return; return;
} }
@ -142,7 +143,7 @@ void
Host_Notarget_f (void) Host_Notarget_f (void)
{ {
if (cmd_source == src_command) { if (cmd_source == src_command) {
Cmd_ForwardToServer (); CL_Cmd_ForwardToServer ();
return; return;
} }
@ -163,7 +164,7 @@ void
Host_Noclip_f (void) Host_Noclip_f (void)
{ {
if (cmd_source == src_command) { if (cmd_source == src_command) {
Cmd_ForwardToServer (); CL_Cmd_ForwardToServer ();
return; return;
} }
@ -190,7 +191,7 @@ void
Host_Fly_f (void) Host_Fly_f (void)
{ {
if (cmd_source == src_command) { if (cmd_source == src_command) {
Cmd_ForwardToServer (); CL_Cmd_ForwardToServer ();
return; return;
} }
@ -214,7 +215,7 @@ Host_Ping_f (void)
client_t *client; client_t *client;
if (cmd_source == src_command) { if (cmd_source == src_command) {
Cmd_ForwardToServer (); CL_Cmd_ForwardToServer ();
return; return;
} }
@ -631,7 +632,7 @@ Host_Name_f (void)
return; return;
Cvar_Set (cl_name, va ("%.15s", newName)); Cvar_Set (cl_name, va ("%.15s", newName));
if (cls.state == ca_connected) if (cls.state == ca_connected)
Cmd_ForwardToServer (); CL_Cmd_ForwardToServer ();
return; return;
} }
@ -670,7 +671,7 @@ Host_Say (qboolean teamonly)
fromServer = true; fromServer = true;
teamonly = false; teamonly = false;
} else { } else {
Cmd_ForwardToServer (); CL_Cmd_ForwardToServer ();
return; return;
} }
} }
@ -736,7 +737,7 @@ Host_Tell_f (void)
char text[64]; char text[64];
if (cmd_source == src_command) { if (cmd_source == src_command) {
Cmd_ForwardToServer (); CL_Cmd_ForwardToServer ();
return; return;
} }
@ -779,7 +780,7 @@ void
Host_Kill_f (void) Host_Kill_f (void)
{ {
if (cmd_source == src_command) { if (cmd_source == src_command) {
Cmd_ForwardToServer (); CL_Cmd_ForwardToServer ();
return; return;
} }
@ -798,7 +799,7 @@ Host_Pause_f (void)
{ {
if (cmd_source == src_command) { if (cmd_source == src_command) {
Cmd_ForwardToServer (); CL_Cmd_ForwardToServer ();
return; return;
} }
if (!pausable->int_val) if (!pausable->int_val)
@ -979,7 +980,7 @@ Host_Kick_f (void)
if (cmd_source == src_command) { if (cmd_source == src_command) {
if (!sv.active) { if (!sv.active) {
Cmd_ForwardToServer (); CL_Cmd_ForwardToServer ();
return; return;
} }
} }
@ -1051,7 +1052,7 @@ Host_Give_f (void)
int v; int v;
if (cmd_source == src_command) { if (cmd_source == src_command) {
Cmd_ForwardToServer (); CL_Cmd_ForwardToServer ();
return; return;
} }
@ -1274,7 +1275,7 @@ Host_Startdemos_f (void)
if (cls.state == ca_dedicated) { if (cls.state == ca_dedicated) {
if (!sv.active) if (!sv.active)
Cbuf_AddText ("map start\n"); Cbuf_AddText (host_cbuf, "map start\n");
return; return;
} }

View file

@ -88,7 +88,7 @@ Host_Color_f (void)
if (cmd_source == src_command) { if (cmd_source == src_command) {
Cvar_SetValue (cl_color, playercolor); Cvar_SetValue (cl_color, playercolor);
if (cls.state == ca_connected) if (cls.state == ca_connected)
Cmd_ForwardToServer (); CL_Cmd_ForwardToServer ();
return; return;
} }

View file

@ -148,7 +148,7 @@ NET_Ban_f (void)
if (cmd_source == src_command) { if (cmd_source == src_command) {
if (!sv.active) { if (!sv.active) {
Cmd_ForwardToServer (); CL_Cmd_ForwardToServer ();
return; return;
} }
print = Con_Printf; print = Con_Printf;

View file

@ -37,6 +37,7 @@ static const char rcsid[] =
# include <strings.h> # include <strings.h>
#endif #endif
#include "QF/cbuf.h"
#include "QF/cmd.h" #include "QF/cmd.h"
#include "QF/console.h" #include "QF/console.h"
#include "QF/cvar.h" #include "QF/cvar.h"
@ -45,6 +46,8 @@ static const char rcsid[] =
#include "QF/sizebuf.h" #include "QF/sizebuf.h"
#include "QF/sys.h" #include "QF/sys.h"
#include "QF/vfile.h" #include "QF/vfile.h"
#include "host.h"
#include "net.h" #include "net.h"
#include "net_vcr.h" #include "net_vcr.h"
#include "server.h" #include "server.h"
@ -246,10 +249,10 @@ MaxPlayers_f (void)
} }
if ((n == 1) && listening) if ((n == 1) && listening)
Cbuf_AddText ("listen 0\n"); Cbuf_AddText (host_cbuf, "listen 0\n");
if ((n > 1) && (!listening)) if ((n > 1) && (!listening))
Cbuf_AddText ("listen 1\n"); Cbuf_AddText (host_cbuf, "listen 1\n");
svs.maxclients = n; svs.maxclients = n;
if (n == 1) if (n == 1)
@ -280,8 +283,8 @@ NET_Port_f (void)
if (listening) { if (listening) {
// force a change to the new port // force a change to the new port
Cbuf_AddText ("listen 0\n"); Cbuf_AddText (host_cbuf, "listen 0\n");
Cbuf_AddText ("listen 1\n"); Cbuf_AddText (host_cbuf, "listen 1\n");
} }
} }

View file

@ -37,6 +37,7 @@ static const char rcsid[] =
# include <strings.h> # include <strings.h>
#endif #endif
#include "QF/cbuf.h"
#include "QF/clip_hull.h" #include "QF/clip_hull.h"
#include "QF/console.h" #include "QF/console.h"
#include "QF/cvar.h" #include "QF/cvar.h"
@ -631,7 +632,7 @@ PF_localcmd (progs_t *pr)
const char *str; const char *str;
str = P_STRING (pr, 0); str = P_STRING (pr, 0);
Cbuf_AddText (str); Cbuf_AddText (host_cbuf, str);
} }
/* /*
@ -1167,7 +1168,7 @@ PF_changelevel (progs_t *pr)
svs.changelevel_issued = true; svs.changelevel_issued = true;
s = P_STRING (pr, 0); s = P_STRING (pr, 0);
Cbuf_AddText (va ("changelevel %s\n", s)); Cbuf_AddText (host_cbuf, va ("changelevel %s\n", s));
} }

View file

@ -80,7 +80,7 @@ CL_UpdateScreen (double realtime)
} }
void void
Cmd_ForwardToServer (void) CL_Cmd_ForwardToServer (void)
{ {
} }

View file

@ -31,6 +31,7 @@ static const char rcsid[] =
# include "config.h" # include "config.h"
#endif #endif
#include "QF/cbuf.h"
#include "QF/console.h" #include "QF/console.h"
#include "QF/cmd.h" #include "QF/cmd.h"
#include "QF/cvar.h" #include "QF/cvar.h"
@ -529,7 +530,7 @@ SV_ReadClientMessage (void)
else if (strncasecmp (s, "ban", 3) == 0) else if (strncasecmp (s, "ban", 3) == 0)
ret = 1; ret = 1;
if (ret == 2) if (ret == 2)
Cbuf_InsertText (s); Cbuf_InsertText (host_cbuf, s);
else if (ret == 1) else if (ret == 1)
Cmd_ExecuteString (s, src_client); Cmd_ExecuteString (s, src_client);
else else

View file

@ -338,6 +338,8 @@ extern char *server_version; // version of server we connected to
extern double realtime; extern double realtime;
extern struct cbuf_s *cl_cbuf;
void Cvar_Info (struct cvar_s *var); void Cvar_Info (struct cvar_s *var);
@ -350,6 +352,9 @@ void V_ParseDamage (void);
void V_PrepBlend (void); void V_PrepBlend (void);
void CL_Cmd_ForwardToServer (void);
void CL_Cmd_Init (void);
#define RSSHOT_WIDTH 320 #define RSSHOT_WIDTH 320
#define RSSHOT_HEIGHT 200 #define RSSHOT_HEIGHT 200

View file

@ -420,6 +420,9 @@ extern struct progs_s sv_pr_state;
extern const char *client_info_filters[]; extern const char *client_info_filters[];
extern struct cbuf_s *sv_cbuf;
extern struct cbuf_args_s *sv_args;
//=========================================================== //===========================================================
// FIXME: declare exported functions in their own relevant .h // FIXME: declare exported functions in their own relevant .h

View file

@ -37,8 +37,9 @@ static const char rcsid[] =
# include <strings.h> # include <strings.h>
#endif #endif
#include "QF/console.h" #include "QF/cbuf.h"
#include "QF/cmd.h" #include "QF/cmd.h"
#include "QF/console.h"
#include "QF/msg.h" #include "QF/msg.h"
#include "QF/teamplay.h" #include "QF/teamplay.h"
@ -46,14 +47,14 @@ static const char rcsid[] =
/* /*
Cmd_ForwardToServer CL_Cmd_ForwardToServer
adds the current command line as a clc_stringcmd to the client message. adds the current command line as a clc_stringcmd to the client message.
things like godmode, noclip, etc, are commands directed to the server, things like godmode, noclip, etc, are commands directed to the server,
so when they are typed in at the console, they will need to be forwarded. so when they are typed in at the console, they will need to be forwarded.
*/ */
void void
Cmd_ForwardToServer (void) CL_Cmd_ForwardToServer (void)
{ {
if (cls.state == ca_disconnected) { if (cls.state == ca_disconnected) {
Con_Printf ("Can't \"%s\", not connected\n", Cmd_Argv (0)); Con_Printf ("Can't \"%s\", not connected\n", Cmd_Argv (0));
@ -91,7 +92,7 @@ Cmd_ForwardToServer (void)
// don't forward the first argument // don't forward the first argument
void void
Cmd_ForwardToServer_f (void) CL_Cmd_ForwardToServer_f (void)
{ {
if (cls.state == ca_disconnected) { if (cls.state == ca_disconnected) {
Con_Printf ("Can't \"%s\", not connected\n", Cmd_Argv (0)); Con_Printf ("Can't \"%s\", not connected\n", Cmd_Argv (0));
@ -99,7 +100,7 @@ Cmd_ForwardToServer_f (void)
} }
if (strcasecmp (Cmd_Argv (1), "snap") == 0) { if (strcasecmp (Cmd_Argv (1), "snap") == 0) {
Cbuf_InsertText ("snap\n"); Cbuf_InsertText (cl_cbuf, "snap\n");
return; return;
} }
@ -113,10 +114,10 @@ Cmd_ForwardToServer_f (void)
} }
void void
cl_Cmd_Init (void) CL_Cmd_Init (void)
{ {
// register our commands // register our commands
Cmd_AddCommand ("cmd", Cmd_ForwardToServer_f, "Send a command to the " Cmd_AddCommand ("cmd", CL_Cmd_ForwardToServer_f, "Send a command to the "
"server.\n" "server.\n"
"Commands:\n" "Commands:\n"
"download - Same as the command.\n" "download - Same as the command.\n"

View file

@ -63,6 +63,7 @@ static const char rcsid[] =
# undef model_t // allow qf to use it's model_t # undef model_t // allow qf to use it's model_t
#endif #endif
#include "QF/cbuf.h"
#include "QF/cdaudio.h" #include "QF/cdaudio.h"
#include "QF/cmd.h" #include "QF/cmd.h"
#include "QF/console.h" #include "QF/console.h"
@ -120,6 +121,8 @@ void CL_RemoveQFInfoKeys ();
qboolean noclip_anglehack; // remnant from old quake qboolean noclip_anglehack; // remnant from old quake
cbuf_t *cl_cbuf;
cvar_t *fs_globalcfg; cvar_t *fs_globalcfg;
cvar_t *fs_usercfg; cvar_t *fs_usercfg;
@ -730,7 +733,7 @@ CL_SetInfo_f (void)
(!strequal (Cmd_Argv (1), "name")) | (!strequal (Cmd_Argv (1), "name")) |
(strequal (Cmd_Argv (2), "team") << 1)); (strequal (Cmd_Argv (2), "team") << 1));
if (cls.state >= ca_connected) if (cls.state >= ca_connected)
Cmd_ForwardToServer (); CL_Cmd_ForwardToServer ();
} }
void void
@ -813,7 +816,7 @@ CL_NextDemo (void)
} }
snprintf (str, sizeof (str), "playdemo %s\n", cls.demos[cls.demonum]); snprintf (str, sizeof (str), "playdemo %s\n", cls.demos[cls.demonum]);
Cbuf_InsertText (str); Cbuf_InsertText (cl_cbuf, str);
cls.demonum++; cls.demonum++;
} }
@ -952,7 +955,7 @@ CL_ConnectionlessPacket (void)
} }
Con_Printf ("%s\n", cmdtext); Con_Printf ("%s\n", cmdtext);
Cbuf_AddText (cmdtext); Cbuf_AddText (cl_cbuf, cmdtext);
allowremotecmd = false; allowremotecmd = false;
return; return;
} }
@ -1236,13 +1239,13 @@ CL_Init (void)
Cmd_AddCommand ("force_centerview", Force_CenterView_f, "force the view " Cmd_AddCommand ("force_centerview", Force_CenterView_f, "force the view "
"to be level"); "to be level");
// forward to server commands // forward to server commands
Cmd_AddCommand ("kill", Cmd_ForwardToServer, "Suicide :)"); Cmd_AddCommand ("kill", CL_Cmd_ForwardToServer, "Suicide :)");
Cmd_AddCommand ("pause", Cmd_ForwardToServer, "Pause the game"); Cmd_AddCommand ("pause", CL_Cmd_ForwardToServer, "Pause the game");
Cmd_AddCommand ("say", Cmd_ForwardToServer, "Say something to all other " Cmd_AddCommand ("say", CL_Cmd_ForwardToServer, "Say something to all other "
"players"); "players");
Cmd_AddCommand ("say_team", Cmd_ForwardToServer, "Say something only to " Cmd_AddCommand ("say_team", CL_Cmd_ForwardToServer, "Say something only to "
"people on your team"); "people on your team");
Cmd_AddCommand ("serverinfo", Cmd_ForwardToServer, "Report the current " Cmd_AddCommand ("serverinfo", CL_Cmd_ForwardToServer, "Report the current "
"server info"); "server info");
} }
@ -1531,7 +1534,7 @@ Host_Frame (float time)
IN_Commands (); IN_Commands ();
// process console commands // process console commands
Cbuf_Execute (); Cbuf_Execute (cl_cbuf);
// fetch results from server // fetch results from server
CL_ReadPackets (); CL_ReadPackets ();
@ -1659,17 +1662,18 @@ CL_Init_Memory (void)
void void
Host_Init (void) Host_Init (void)
{ {
cl_cbuf = Cbuf_New ();
Cvar_Init_Hash (); Cvar_Init_Hash ();
Cmd_Init_Hash (); Cmd_Init_Hash ();
Cvar_Init (); Cvar_Init ();
Sys_Init_Cvars (); Sys_Init_Cvars ();
Cbuf_Init ();
Cmd_Init (); Cmd_Init ();
// execute +set as early as possible // execute +set as early as possible
Cmd_StuffCmds_f (); Cmd_StuffCmds (cl_cbuf);
Cbuf_Execute_Sets (); Cbuf_Execute_Sets (cl_cbuf);
// execute the global configuration file if it exists // execute the global configuration file if it exists
// would have been nice if Cmd_Exec_f could have been used, but it // would have been nice if Cmd_Exec_f could have been used, but it
@ -1678,20 +1682,20 @@ Host_Init (void)
fs_globalcfg = Cvar_Get ("fs_globalcfg", FS_GLOBALCFG, CVAR_ROM, NULL, fs_globalcfg = Cvar_Get ("fs_globalcfg", FS_GLOBALCFG, CVAR_ROM, NULL,
"global configuration file"); "global configuration file");
Cmd_Exec_File (fs_globalcfg->string); Cmd_Exec_File (fs_globalcfg->string);
Cbuf_Execute_Sets (); Cbuf_Execute_Sets (cl_cbuf);
// execute +set again to override the config file // execute +set again to override the config file
Cmd_StuffCmds_f (); Cmd_StuffCmds (cl_cbuf);
Cbuf_Execute_Sets (); Cbuf_Execute_Sets (cl_cbuf);
fs_usercfg = Cvar_Get ("fs_usercfg", FS_USERCFG, CVAR_ROM, NULL, fs_usercfg = Cvar_Get ("fs_usercfg", FS_USERCFG, CVAR_ROM, NULL,
"user configuration file"); "user configuration file");
Cmd_Exec_File (fs_usercfg->string); Cmd_Exec_File (fs_usercfg->string);
Cbuf_Execute_Sets (); Cbuf_Execute_Sets (cl_cbuf);
// execute +set again to override the config file // execute +set again to override the config file
Cmd_StuffCmds_f (); Cmd_StuffCmds (cl_cbuf);
Cbuf_Execute_Sets (); Cbuf_Execute_Sets (cl_cbuf);
CL_Init_Memory (); CL_Init_Memory ();
@ -1727,7 +1731,7 @@ Host_Init (void)
PR_Init (); PR_Init ();
BI_Init (); BI_Init ();
cl_Cmd_Init (); CL_Cmd_Init ();
V_Init (); V_Init ();
COM_Filesystem_Init (); COM_Filesystem_Init ();
Game_Init (); Game_Init ();
@ -1740,6 +1744,7 @@ Host_Init (void)
con_module->data->console->dl_percent = &cls.downloadpercent; con_module->data->console->dl_percent = &cls.downloadpercent;
con_module->data->console->realtime = &realtime; con_module->data->console->realtime = &realtime;
con_module->data->console->quit = CL_Quit_f; con_module->data->console->quit = CL_Quit_f;
con_module->data->console->cbuf = cl_cbuf;
} }
NET_Init (cl_port->int_val); NET_Init (cl_port->int_val);
@ -1785,12 +1790,12 @@ Host_Init (void)
Locs_Init (); Locs_Init ();
if (cl_quakerc->int_val) if (cl_quakerc->int_val)
Cbuf_InsertText ("exec quake.rc\n"); Cbuf_InsertText (cl_cbuf, "exec quake.rc\n");
Cmd_Exec_File (fs_usercfg->string); Cmd_Exec_File (fs_usercfg->string);
// Reparse the command line for + commands. // Reparse the command line for + commands.
// (Note, no non-base commands exist yet) // (Note, no non-base commands exist yet)
if (!cl_quakerc->int_val || check_quakerc ()) if (!cl_quakerc->int_val || check_quakerc ())
Cmd_StuffCmds_f (); Cmd_StuffCmds (cl_cbuf);
Hunk_AllocName (0, "-HOST_HUNKLEVEL-"); Hunk_AllocName (0, "-HOST_HUNKLEVEL-");
host_hunklevel = Hunk_LowMark (); host_hunklevel = Hunk_LowMark ();
@ -1805,9 +1810,10 @@ Host_Init (void)
CL_UpdateScreen (realtime); CL_UpdateScreen (realtime);
Cbuf_AddText ("echo Type connect <internet address> or use a server " Cbuf_AddText (cl_cbuf,
"echo Type connect <internet address> or use a server "
"browser to connect to a game.\n"); "browser to connect to a game.\n");
Cbuf_AddText ("cmd_warncmd 1\n"); Cbuf_AddText (cl_cbuf, "cmd_warncmd 1\n");
} }
void void

View file

@ -43,6 +43,7 @@ static const char rcsid[] =
# include <unistd.h> # include <unistd.h>
#endif #endif
#include "QF/cbuf.h"
#include "QF/cdaudio.h" #include "QF/cdaudio.h"
#include "QF/cmd.h" #include "QF/cmd.h"
#include "QF/console.h" #include "QF/console.h"
@ -629,14 +630,14 @@ CL_ParseServerData (void)
if (cflag) { if (cflag) {
int cmd_warncmd_val = cmd_warncmd->int_val; int cmd_warncmd_val = cmd_warncmd->int_val;
Cbuf_AddText ("cmd_warncmd 0\n"); Cbuf_AddText (cl_cbuf, "cmd_warncmd 0\n");
Cbuf_AddText ("exec config.cfg\n"); Cbuf_AddText (cl_cbuf, "exec config.cfg\n");
Cbuf_AddText ("exec frontend.cfg\n"); Cbuf_AddText (cl_cbuf, "exec frontend.cfg\n");
if (cl_autoexec->int_val) { if (cl_autoexec->int_val) {
Cbuf_AddText ("exec autoexec.cfg\n"); Cbuf_AddText (cl_cbuf, "exec autoexec.cfg\n");
} }
snprintf (fn, sizeof (fn), "cmd_warncmd %d\n", cmd_warncmd_val); snprintf (fn, sizeof (fn), "cmd_warncmd %d\n", cmd_warncmd_val);
Cbuf_AddText (fn); Cbuf_AddText (cl_cbuf, fn);
} }
// parse player slot, high bit means spectator // parse player slot, high bit means spectator
cl.playernum = MSG_ReadByte (net_message); cl.playernum = MSG_ReadByte (net_message);
@ -1187,12 +1188,12 @@ CL_ParseServerMessage (void)
if (s[strlen (s) - 1] == '\n') { if (s[strlen (s) - 1] == '\n') {
if (stuffbuf && stuffbuf->str[0]) { if (stuffbuf && stuffbuf->str[0]) {
Con_DPrintf ("stufftext: %s%s\n", stuffbuf->str, s); Con_DPrintf ("stufftext: %s%s\n", stuffbuf->str, s);
Cbuf_AddTextTo (cmd_legacybuffer, stuffbuf->str); Cbuf_AddText (cl_cbuf, stuffbuf->str);
dstring_clearstr (stuffbuf); dstring_clearstr (stuffbuf);
} else { } else {
Con_DPrintf ("stufftext: %s\n", s); Con_DPrintf ("stufftext: %s\n", s);
} }
Cbuf_AddTextTo (cmd_legacybuffer, s); Cbuf_AddText (cl_cbuf, s);
} else { } else {
Con_DPrintf ("partial stufftext: %s\n", s); Con_DPrintf ("partial stufftext: %s\n", s);
if (!stuffbuf) if (!stuffbuf)
@ -1206,7 +1207,8 @@ CL_ParseServerMessage (void)
break; break;
case svc_serverdata: case svc_serverdata:
Cbuf_Execute (); // make sure any stuffed commands are done // make sure any stuffed commands are done
Cbuf_Execute (cl_cbuf);
CL_ParseServerData (); CL_ParseServerData ();
vid.recalc_refdef = true; // leave full screen intermission vid.recalc_refdef = true; // leave full screen intermission
break; break;

View file

@ -388,6 +388,7 @@ SV_Map_f (void)
level[sizeof (level) - 1] = 0; level[sizeof (level) - 1] = 0;
// check to make sure the level exists // check to make sure the level exists
while (1) {
snprintf (expanded, sizeof (expanded), "maps/%s.bsp", level); snprintf (expanded, sizeof (expanded), "maps/%s.bsp", level);
COM_FOpenFile (expanded, &f); COM_FOpenFile (expanded, &f);
if (!f) { if (!f) {
@ -395,9 +396,10 @@ SV_Map_f (void)
// If curlevel == level, something is SCREWED! --KB // If curlevel == level, something is SCREWED! --KB
if (strcaseequal (level, curlevel)) if (strcaseequal (level, curlevel))
Sys_Error ("map: cannot restart level"); Sys_Error ("map: cannot restart level");
else strcpy (level, curlevel);
Cbuf_AddText (va ("map %s", curlevel)); } else {
return; break;
}
} }
Qclose (f); Qclose (f);

View file

@ -66,6 +66,7 @@ static const char rcsid[] =
# undef model_t // allow qf to use it's model_t # undef model_t // allow qf to use it's model_t
#endif #endif
#include "QF/cbuf.h"
#include "QF/cmd.h" #include "QF/cmd.h"
#include "QF/console.h" #include "QF/console.h"
#include "QF/cvar.h" #include "QF/cvar.h"
@ -96,6 +97,9 @@ static plugin_list_t server_plugin_list[] = {
SERVER_PLUGIN_LIST SERVER_PLUGIN_LIST
}; };
cbuf_t *sv_cbuf;
cbuf_args_t *sv_args;
client_t *host_client; // current client client_t *host_client; // current client
client_static_t cls; //FIXME needed by netchan :/ client_static_t cls; //FIXME needed by netchan :/
@ -531,7 +535,6 @@ SVC_Status (void)
return; return;
con_printf_no_log = 1; con_printf_no_log = 1;
Cmd_TokenizeString ("status", true);
SV_BeginRedirect (RD_PACKET); SV_BeginRedirect (RD_PACKET);
SV_Printf ("%s\n", Info_MakeString (svs.info, 0)); SV_Printf ("%s\n", Info_MakeString (svs.info, 0));
for (i = 0; i < MAX_CLIENTS; i++) { for (i = 0; i < MAX_CLIENTS; i++) {
@ -1044,9 +1047,10 @@ SV_ConnectionlessPacket (void)
s = MSG_ReadString (net_message); s = MSG_ReadString (net_message);
Cmd_TokenizeString (s, true); COM_TokenizeString (s, sv_args);
cmd_args = sv_args;
c = Cmd_Argv (0); c = sv_args->argv[0]->str;
if (!strcmp (c, "ping") if (!strcmp (c, "ping")
|| (c[0] == A2A_PING && (c[1] == 0 || c[1] == '\n'))) { || (c[0] == A2A_PING && (c[1] == 0 || c[1] == '\n'))) {
@ -1908,7 +1912,7 @@ SV_Frame (float time)
SV_GetConsoleCommands (); SV_GetConsoleCommands ();
// process console commands // process console commands
Cbuf_Execute (); Cbuf_Execute (sv_cbuf);
SV_CheckVars (); SV_CheckVars ();
@ -2401,6 +2405,9 @@ SV_Init (void)
// COM_AddParm ("-game"); // COM_AddParm ("-game");
// COM_AddParm ("qw"); // COM_AddParm ("qw");
sv_cbuf = Cbuf_New ();
sv_args = Cbuf_ArgsNew ();
Sys_RegisterShutdown (SV_Shutdown); Sys_RegisterShutdown (SV_Shutdown);
Cvar_Init_Hash (); Cvar_Init_Hash ();
@ -2410,12 +2417,11 @@ SV_Init (void)
Cvar_Get ("cmd_warncmd", "1", CVAR_NONE, NULL, NULL); Cvar_Get ("cmd_warncmd", "1", CVAR_NONE, NULL, NULL);
Cbuf_Init ();
Cmd_Init (); Cmd_Init ();
// execute +set as early as possible // execute +set as early as possible
Cmd_StuffCmds_f (); Cmd_StuffCmds (sv_cbuf);
Cbuf_Execute_Sets (); Cbuf_Execute_Sets (sv_cbuf);
// execute the global configuration file if it exists // execute the global configuration file if it exists
// would have been nice if Cmd_Exec_f could have been used, but it // would have been nice if Cmd_Exec_f could have been used, but it
@ -2424,20 +2430,20 @@ SV_Init (void)
fs_globalcfg = Cvar_Get ("fs_globalcfg", FS_GLOBALCFG, fs_globalcfg = Cvar_Get ("fs_globalcfg", FS_GLOBALCFG,
CVAR_ROM, 0, "global configuration file"); CVAR_ROM, 0, "global configuration file");
Cmd_Exec_File (fs_globalcfg->string); Cmd_Exec_File (fs_globalcfg->string);
Cbuf_Execute_Sets (); Cbuf_Execute_Sets (sv_cbuf);
// execute +set again to override the config file // execute +set again to override the config file
Cmd_StuffCmds_f (); Cmd_StuffCmds (sv_cbuf);
Cbuf_Execute_Sets (); Cbuf_Execute_Sets (sv_cbuf);
fs_usercfg = Cvar_Get ("fs_usercfg", FS_USERCFG, fs_usercfg = Cvar_Get ("fs_usercfg", FS_USERCFG,
CVAR_ROM, 0, "user configuration file"); CVAR_ROM, 0, "user configuration file");
Cmd_Exec_File (fs_usercfg->string); Cmd_Exec_File (fs_usercfg->string);
Cbuf_Execute_Sets (); Cbuf_Execute_Sets (sv_cbuf);
// execute +set again to override the config file // execute +set again to override the config file
Cmd_StuffCmds_f (); Cmd_StuffCmds (sv_cbuf);
Cbuf_Execute_Sets (); Cbuf_Execute_Sets (sv_cbuf);
SV_Init_Memory (); SV_Init_Memory ();
@ -2452,6 +2458,8 @@ SV_Init (void)
CVAR_ROM, 0, "Plugin used for the console"); CVAR_ROM, 0, "Plugin used for the console");
PI_RegisterPlugins (server_plugin_list); PI_RegisterPlugins (server_plugin_list);
Con_Init (sv_console_plugin->string); Con_Init (sv_console_plugin->string);
if (con_module)
con_module->data->console->cbuf = sv_cbuf;
Sys_SetStdPrintf (SV_Print); Sys_SetStdPrintf (SV_Print);
Sys_SetErrPrintf (SV_Error); Sys_SetErrPrintf (SV_Error);
@ -2465,8 +2473,8 @@ SV_Init (void)
PR_Init_Cvars (); PR_Init_Cvars ();
// and now reprocess the cmdline's sets for overrides // and now reprocess the cmdline's sets for overrides
Cmd_StuffCmds_f (); Cmd_StuffCmds (sv_cbuf);
Cbuf_Execute_Sets (); Cbuf_Execute_Sets (sv_cbuf);
COM_Filesystem_Init (); COM_Filesystem_Init ();
Game_Init (); Game_Init ();
@ -2484,7 +2492,7 @@ SV_Init (void)
Hunk_AllocName (0, "-HOST_HUNKLEVEL-"); Hunk_AllocName (0, "-HOST_HUNKLEVEL-");
host_hunklevel = Hunk_LowMark (); host_hunklevel = Hunk_LowMark ();
Cbuf_InsertText ("exec server.cfg\n"); Cbuf_InsertText (sv_cbuf, "exec server.cfg\n");
host_initialized = true; host_initialized = true;
@ -2500,8 +2508,8 @@ SV_Init (void)
// process command line arguments // process command line arguments
Cmd_Exec_File (fs_usercfg->string); Cmd_Exec_File (fs_usercfg->string);
Cmd_StuffCmds_f (); Cmd_StuffCmds (sv_cbuf);
Cbuf_Execute (); Cbuf_Execute (sv_cbuf);
// if a map wasn't specified on the command line, spawn start.map // if a map wasn't specified on the command line, spawn start.map
if (sv.state == ss_dead) if (sv.state == ss_dead)

View file

@ -37,6 +37,7 @@ static const char rcsid[] =
# include <strings.h> # include <strings.h>
#endif #endif
#include "QF/cbuf.h"
#include "QF/clip_hull.h" #include "QF/clip_hull.h"
#include "QF/cmd.h" #include "QF/cmd.h"
#include "QF/cvar.h" #include "QF/cvar.h"
@ -586,7 +587,7 @@ PF_localcmd (progs_t *pr)
const char *str; const char *str;
str = P_STRING (pr, 0); str = P_STRING (pr, 0);
Cbuf_AddText (str); Cbuf_AddText (sv_cbuf, str);
} }
/* /*
@ -1202,7 +1203,7 @@ PF_changelevel (progs_t *pr)
last_spawncount = svs.spawncount; last_spawncount = svs.spawncount;
s = P_STRING (pr, 0); s = P_STRING (pr, 0);
Cbuf_AddText (va ("map %s\n", s)); Cbuf_AddText (sv_cbuf, va ("map %s\n", s));
} }
/* /*

View file

@ -42,10 +42,12 @@ static const char rcsid[] =
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <ctype.h>
#include "QF/cbuf.h"
#include "QF/checksum.h" #include "QF/checksum.h"
#include "QF/clip_hull.h" #include "QF/clip_hull.h"
#include "QF/cmd.h" #include "QF/cmd.h"
#include "QF/cvar.h" #include "QF/cvar.h"
#include "QF/dstring.h"
#include "QF/hash.h" #include "QF/hash.h"
#include "QF/msg.h" #include "QF/msg.h"
#include "QF/sys.h" #include "QF/sys.h"
@ -1291,14 +1293,15 @@ SV_ExecuteUserCommand (const char *s)
{ {
ucmd_t *u; ucmd_t *u;
Cmd_TokenizeString (s, true); COM_TokenizeString (s, sv_args);
cmd_args = sv_args;
sv_player = host_client->edict; sv_player = host_client->edict;
u = (ucmd_t*) Hash_Find (ucmd_table, Cmd_Argv(0)); u = (ucmd_t*) Hash_Find (ucmd_table, sv_args->argv[0]->str);
if (!u) { if (!u) {
SV_BeginRedirect (RD_CLIENT); SV_BeginRedirect (RD_CLIENT);
SV_Printf ("Bad user command: %s\n", Cmd_Argv (0)); SV_Printf ("Bad user command: %s\n", sv_args->argv[0]->str);
SV_EndRedirect (); SV_EndRedirect ();
} else { } else {
if (!u->no_redirect) if (!u->no_redirect)

View file

@ -41,6 +41,7 @@ static const char rcsid[] =
#include <ctype.h> #include <ctype.h>
#include "QF/cbuf.h"
#include "QF/console.h" #include "QF/console.h"
#include "QF/cmd.h" #include "QF/cmd.h"
#include "QF/cvar.h" #include "QF/cvar.h"
@ -460,7 +461,7 @@ Team_ParseChat (const char *string)
if (!strncmp(f_replies[i].name, s, strlen(f_replies[i].name)) && cl_freply->value) { if (!strncmp(f_replies[i].name, s, strlen(f_replies[i].name)) && cl_freply->value) {
while (*s && !isspace((byte) *s)) while (*s && !isspace((byte) *s))
s++; s++;
Cbuf_AddText(f_replies[i].func(s)); Cbuf_AddText(cl_cbuf, f_replies[i].func(s));
f_replies[i].lasttime = realtime; f_replies[i].lasttime = realtime;
} }
} }

View file

@ -165,7 +165,6 @@ init_qf (void)
Cmd_Init_Hash (); Cmd_Init_Hash ();
Cvar_Init (); Cvar_Init ();
Sys_Init_Cvars (); Sys_Init_Cvars ();
Cbuf_Init ();
Cmd_Init (); Cmd_Init ();
membase = malloc (memsize); membase = malloc (memsize);

View file

@ -66,7 +66,6 @@ main ()
SYS_CHECKMEM (membase); SYS_CHECKMEM (membase);
Memory_Init (membase, memsize); Memory_Init (membase, memsize);
Cvar_Init (); Cvar_Init ();
Cbuf_Init ();
Cmd_Init (); Cmd_Init ();
Cvar_Get ("pr_debug", "1", 0, 0, 0); Cvar_Get ("pr_debug", "1", 0, 0, 0);