void KeyDown (kbutton_t *b)
{
- int k;
- char *c;
+ int k;
+ const char *c;
c = Cmd_Argv(1);
if (c[0])
Con_Printf ("Three keys down for a button!\n");
return;
}
-
+
if (b->state & 1)
return; // still down
b->state |= 1 + 2; // down + impulse down
void KeyUp (kbutton_t *b)
{
- int k;
- char *c;
-
+ int k;
+ const char *c;
+
c = Cmd_Argv(1);
if (c[0])
k = atoi(c);
void CL_ParseEntityLump(char *entdata)
{
- char *data;
+ const char *data;
char key[128], value[4096];
FOG_clear(); // LordHavoc: no fog until set
R_SetSkyBox(""); // LordHavoc: no environment mapped sky until set
data = entdata;
if (!data)
return;
- data = COM_Parse(data);
- if (!data)
+ if (!COM_ParseToken(&data))
return; // error
if (com_token[0] != '{')
return; // error
while (1)
{
- data = COM_Parse(data);
- if (!data)
+ if (!COM_ParseToken(&data))
return; // error
if (com_token[0] == '}')
break; // end of worldspawn
strcpy(key, com_token);
while (key[strlen(key)-1] == ' ') // remove trailing spaces
key[strlen(key)-1] = 0;
- data = COM_Parse(data);
- if (!data)
+ if (!COM_ParseToken(&data))
return; // error
strcpy(value, com_token);
if (!strcmp("sky", key))
typedef struct cmdalias_s
{
- struct cmdalias_s *next;
- char name[MAX_ALIAS_NAME];
- char *value;
+ struct cmdalias_s *next;
+ char name[MAX_ALIAS_NAME];
+ char *value;
} cmdalias_t;
static cmdalias_t *cmd_alias;
Adds command text at the end of the buffer
============
*/
-void Cbuf_AddText (char *text)
+void Cbuf_AddText (const char *text)
{
int l;
FIXME: actually change the command buffer to do less copying
============
*/
-void Cbuf_InsertText (char *text)
+void Cbuf_InsertText (const char *text)
{
char *temp;
int templen;
*/
void Cbuf_Execute (void)
{
- int i;
- char *text;
- char line[1024];
- int quotes;
+ int i;
+ char *text;
+ char line[1024];
+ int quotes;
while (cmd_text.cursize)
{
*/
static void Cmd_Exec_f (void)
{
- char *f;
+ char *f;
if (Cmd_Argc () != 2)
{
Creates a new command that executes a command string (possibly ; seperated)
===============
*/
-
static char *CopyString (char *in)
{
- char *out;
+ char *out;
out = Z_Malloc (strlen(in)+1);
strcpy (out, in);
cmdalias_t *a;
char cmd[1024];
int i, c;
- char *s;
+ const char *s;
if (Cmd_Argc() == 1)
{
typedef struct cmd_function_s
{
- struct cmd_function_s *next;
- char *name;
- xcommand_t function;
+ struct cmd_function_s *next;
+ const char *name;
+ xcommand_t function;
} cmd_function_t;
#define MAX_ARGS 80
static int cmd_argc;
-static char *cmd_argv[MAX_ARGS];
-static char *cmd_null_string = "";
-static char *cmd_args = NULL;
+static const char *cmd_argv[MAX_ARGS];
+static const char *cmd_null_string = "";
+static const char *cmd_args = NULL;
cmd_source_t cmd_source;
*/
static void Cmd_List_f (void)
{
- cmd_function_t *cmd;
- char *partial;
- int len;
- int count;
+ cmd_function_t *cmd;
+ const char *partial;
+ int len, count;
- if (Cmd_Argc() > 1) {
+ if (Cmd_Argc() > 1)
+ {
partial = Cmd_Argv (1);
len = strlen(partial);
- } else {
+ }
+ else
+ {
partial = NULL;
len = 0;
}
count = 0;
- for (cmd = cmd_functions; cmd; cmd = cmd->next) {
+ for (cmd = cmd_functions; cmd; cmd = cmd->next)
+ {
if (partial && strncmp(partial, cmd->name, len))
continue;
Con_Printf ("%s\n", cmd->name);
Cmd_Argv
============
*/
-char *Cmd_Argv (int arg)
+const char *Cmd_Argv (int arg)
{
if (arg >= cmd_argc )
return cmd_null_string;
Cmd_Args
============
*/
-char *Cmd_Args (void)
+const char *Cmd_Args (void)
{
return cmd_args;
}
Parses the given string into command line tokens.
============
*/
-static void Cmd_TokenizeString (char *text)
+static void Cmd_TokenizeString (const char *text)
{
int l;
int pos;
if (cmd_argc == 1)
cmd_args = text;
- text = COM_Parse (text);
- if (!text)
+ if (!COM_ParseToken (&text))
return;
if (cmd_argc < MAX_ARGS)
l = strlen(com_token) + 1;
if (pos + l > CMD_TOKENIZELENGTH)
Sys_Error("Cmd_TokenizeString: ran out of %i character buffer space for command arguements\n", CMD_TOKENIZELENGTH);
+ strcpy (cmd_tokenizebuffer + pos, com_token);
cmd_argv[cmd_argc] = cmd_tokenizebuffer + pos;
pos += l;
- strcpy (cmd_argv[cmd_argc], com_token);
cmd_argc++;
}
}
Cmd_AddCommand
============
*/
-void Cmd_AddCommand (char *cmd_name, xcommand_t function)
+void Cmd_AddCommand (const char *cmd_name, xcommand_t function)
{
- cmd_function_t *cmd;
+ cmd_function_t *cmd;
// fail if the command is a variable name
if (Cvar_VariableString(cmd_name)[0])
Cmd_Exists
============
*/
-qboolean Cmd_Exists (char *cmd_name)
+qboolean Cmd_Exists (const char *cmd_name)
{
cmd_function_t *cmd;
Cmd_CompleteCommand
============
*/
-char *Cmd_CompleteCommand (char *partial)
+const char *Cmd_CompleteCommand (const char *partial)
{
- cmd_function_t *cmd;
- int len;
+ cmd_function_t *cmd;
+ int len;
len = strlen(partial);
Thanks to taniwha
*/
-int Cmd_CompleteCountPossible (char *partial)
+int Cmd_CompleteCountPossible (const char *partial)
{
- cmd_function_t *cmd;
- int len;
- int h;
+ cmd_function_t *cmd;
+ int len, h;
h = 0;
len = strlen(partial);
Thanks to taniwha
*/
-char **Cmd_CompleteBuildList (char *partial)
+const char **Cmd_CompleteBuildList (const char *partial)
{
- cmd_function_t *cmd;
- int len = 0;
- int bpos = 0;
- int sizeofbuf = (Cmd_CompleteCountPossible (partial) + 1) * sizeof (char *);
- char **buf;
+ cmd_function_t *cmd;
+ int len = 0;
+ int bpos = 0;
+ int sizeofbuf = (Cmd_CompleteCountPossible (partial) + 1) * sizeof (const char *);
+ const char **buf;
len = strlen(partial);
- buf = Mem_Alloc(tempmempool, sizeofbuf + sizeof (char *));
+ buf = Mem_Alloc(tempmempool, sizeofbuf + sizeof (const char *));
// Loop through the alias list and print all matches
for (cmd = cmd_functions; cmd; cmd = cmd->next)
if (!strncasecmp(partial, cmd->name, len))
Thanks to taniwha
*/
-char *Cmd_CompleteAlias (char * partial)
+const char *Cmd_CompleteAlias (const char *partial)
{
- cmdalias_t *alias;
- int len;
+ cmdalias_t *alias;
+ int len;
len = strlen(partial);
Thanks to taniwha
*/
-int Cmd_CompleteAliasCountPossible (char *partial)
+int Cmd_CompleteAliasCountPossible (const char *partial)
{
cmdalias_t *alias;
int len;
Thanks to taniwha
*/
-char **Cmd_CompleteAliasBuildList (char *partial)
+const char **Cmd_CompleteAliasBuildList (const char *partial)
{
- cmdalias_t *alias;
- int len = 0;
- int bpos = 0;
- int sizeofbuf = (Cmd_CompleteAliasCountPossible (partial) + 1) * sizeof (char *);
- char **buf;
+ cmdalias_t *alias;
+ int len = 0;
+ int bpos = 0;
+ int sizeofbuf = (Cmd_CompleteAliasCountPossible (partial) + 1) * sizeof (const char *);
+ const char **buf;
len = strlen(partial);
- buf = Mem_Alloc(tempmempool, sizeofbuf + sizeof (char *));
+ buf = Mem_Alloc(tempmempool, sizeofbuf + sizeof (const char *));
// Loop through the alias list and print all matches
for (alias = cmd_alias; alias; alias = alias->next)
if (!strncasecmp(partial, alias->name, len))
FIXME: lookupnoadd the token to speed search?
============
*/
-void Cmd_ExecuteString (char *text, cmd_source_t src)
+void Cmd_ExecuteString (const char *text, cmd_source_t src)
{
- cmd_function_t *cmd;
- cmdalias_t *a;
+ cmd_function_t *cmd;
+ cmdalias_t *a;
cmd_source = src;
Cmd_TokenizeString (text);
================
*/
-int Cmd_CheckParm (char *parm)
+int Cmd_CheckParm (const char *parm)
{
int i;
void Cbuf_Init (void);
// allocates an initial text buffer that will grow as needed
-void Cbuf_AddText (char *text);
+void Cbuf_AddText (const char *text);
// as new commands are generated from the console or keybindings,
// the text is added to the end of the command buffer.
-void Cbuf_InsertText (char *text);
+void Cbuf_InsertText (const char *text);
// when a command wants to issue other commands immediately, the text is
// inserted at the beginning of the buffer, before any remaining unexecuted
// commands.
void Cmd_Init (void);
-void Cmd_AddCommand (char *cmd_name, xcommand_t function);
+void Cmd_AddCommand (const char *cmd_name, xcommand_t function);
// 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
-qboolean Cmd_Exists (char *cmd_name);
+qboolean Cmd_Exists (const char *cmd_name);
// used by the cvar code to check for cvar / command name overlap
-char *Cmd_CompleteCommand (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_CompleteAliasCountPossible (char *partial);
+int Cmd_CompleteAliasCountPossible (const char *partial);
-char **Cmd_CompleteAliasBuildList (char *partial);
+const char **Cmd_CompleteAliasBuildList (const char *partial);
-int Cmd_CompleteCountPossible (char *partial);
+int Cmd_CompleteCountPossible (const char *partial);
-char **Cmd_CompleteBuildList (char *partial);
+const char **Cmd_CompleteBuildList (const char *partial);
-char *Cmd_CompleteAlias (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);
-char *Cmd_Argv (int arg);
-char *Cmd_Args (void);
+const char *Cmd_Argv (int arg);
+const char *Cmd_Args (void);
// 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_CheckParm (char *parm);
+int Cmd_CheckParm (const char *parm);
// Returns the position (1 to argc-1) in the command's argument list
// where the given parameter apears, or 0 if not present
// Takes a null terminated string. Does not need to be /n terminated.
// breaks the string up into arg tokens.
-void Cmd_ExecuteString (char *text, cmd_source_t src);
+void Cmd_ExecuteString (const char *text, cmd_source_t src);
// Parses a single line of text into arguments and tries to execute it.
// The text can come from the command buffer, a remote client, or stdin.
// 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_Print (char *text);
+void Cmd_Print (const char *text);
// used by command functions to send output to either the graphics console or
// passed as a print message to the client
char com_token[1024];
char com_basedir[MAX_OSPATH];
int com_argc;
-char **com_argv;
+const char **com_argv;
// LordHavoc: made commandline 1024 characters instead of 256
#define CMDLINE_LENGTH 1024
============================================================================
*/
-int Q_strncasecmp (char *s1, char *s2, int n)
+int Q_strncasecmp (const char *s1, const char *s2, int n)
{
int c1, c2;
return -1;
}
-int Q_strcasecmp (char *s1, char *s2)
+int Q_strcasecmp (const char *s1, const char *s2)
{
return Q_strncasecmp (s1, s2, 99999);
}
SZ_Write (sb, &dat.l, 4);
}
-void MSG_WriteString (sizebuf_t *sb, char *s)
+void MSG_WriteString (sizebuf_t *sb, const char *s)
{
if (!s)
SZ_Write (sb, "", 1);
//
// reading functions
//
-int msg_readcount;
-qboolean msg_badread;
+int msg_readcount;
+qboolean msg_badread;
void MSG_BeginReading (void)
{
int MSG_ReadShort (void)
{
- int c;
+ int c;
if (msg_readcount+2 > net_message.cursize)
{
int MSG_ReadLong (void)
{
- int c;
+ int c;
if (msg_readcount+4 > net_message.cursize)
{
{
union
{
- qbyte b[4];
- float f;
- int l;
+ qbyte b[4];
+ float f;
+ int l;
} dat;
dat.b[0] = net_message.data[msg_readcount];
char *MSG_ReadString (void)
{
- static char string[2048];
- int l,c;
+ static char string[2048];
+ int l,c;
l = 0;
do
//===========================================================================
-void SZ_Alloc (sizebuf_t *buf, int startsize, char *name)
+void SZ_Alloc (sizebuf_t *buf, int startsize, const char *name)
{
if (startsize < 256)
startsize = 256;
void *SZ_GetSpace (sizebuf_t *buf, int length)
{
- void *data;
+ void *data;
if (buf->cursize + length > buf->maxsize)
{
data = buf->data + buf->cursize;
buf->cursize += length;
-
+
return data;
}
-void SZ_Write (sizebuf_t *buf, void *data, int length)
+void SZ_Write (sizebuf_t *buf, const void *data, int length)
{
- memcpy (SZ_GetSpace(buf,length),data,length);
+ memcpy (SZ_GetSpace(buf,length),data,length);
}
-void SZ_Print (sizebuf_t *buf, char *data)
+void SZ_Print (sizebuf_t *buf, const char *data)
{
- int len;
-
+ int len;
len = strlen(data)+1;
// byte * cast to keep VC++ happy
}
static char *hexchar = "0123456789ABCDEF";
-void SZ_HexDumpToConsole(sizebuf_t *buf)
+void SZ_HexDumpToConsole(const sizebuf_t *buf)
{
int i;
char text[1024];
//============================================================================
-/*
-============
-COM_SkipPath
-============
-*/
-char *COM_SkipPath (char *pathname)
-{
- char *last;
-
- last = pathname;
- while (*pathname)
- {
- if (*pathname=='/')
- last = pathname+1;
- pathname++;
- }
- return last;
-}
-
/*
============
COM_StripExtension
============
*/
// LordHavoc: replacement for severely broken COM_StripExtension that was used in original quake.
-void COM_StripExtension (char *in, char *out)
+void COM_StripExtension (const char *in, char *out)
{
char *last = NULL;
while (*in)
COM_FileExtension
============
*/
-char *COM_FileExtension (char *in)
+char *COM_FileExtension (const char *in)
{
static char exten[8];
- int i;
+ int i;
while (*in && *in != '.')
in++;
COM_FileBase
============
*/
-void COM_FileBase (char *in, char *out)
+void COM_FileBase (const char *in, char *out)
{
- char *slash, *dot;
- char *s;
+ const char *slash, *dot, *s;
slash = in;
dot = NULL;
COM_DefaultExtension
==================
*/
-void COM_DefaultExtension (char *path, char *extension)
+void COM_DefaultExtension (char *path, const char *extension)
{
- char *src;
+ const char *src;
//
// if path doesn't have a .EXT, append extension
// (extension should include the .)
/*
==============
-COM_Parse
+COM_ParseToken
Parse a token out of a string
==============
*/
-char *COM_Parse (char *data)
+int COM_ParseToken (const char **datapointer)
{
- int c;
- int len;
-
+ int c;
+ int len;
+ const char *data = *datapointer;
+
len = 0;
com_token[0] = 0;
-
+
if (!data)
- return NULL;
-
+ {
+ *datapointer = NULL;
+ return false;
+ }
+
// skip whitespace
skipwhite:
- while ( (c = *data) <= ' ')
+ while ((c = *data) <= ' ')
{
if (c == 0)
- return NULL; // end of file;
+ {
+ // end of file
+ *datapointer = NULL;
+ return false;
+ }
data++;
}
data++;
goto skipwhite;
}
-
+
// handle quoted strings specially
if (c == '\"')
if (c=='\"' || !c)
{
com_token[len] = 0;
- return data;
+ *datapointer = data;
+ return true;
}
com_token[len] = c;
len++;
com_token[len] = c;
len++;
com_token[len] = 0;
- return data+1;
+ *datapointer = data+1;
+ return true;
}
// parse a regular word
data++;
len++;
c = *data;
- if (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c==':')
+ if (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c==':')
break;
} while (c>32);
-
+
com_token[len] = 0;
- return data;
+ *datapointer = data;
+ return true;
}
where the given parameter apears, or 0 if not present
================
*/
-int COM_CheckParm (char *parm)
+int COM_CheckParm (const char *parm)
{
- int i;
-
+ int i;
+
for (i=1 ; i<com_argc ; i++)
{
if (!com_argv[i])
if (!strcmp (parm,com_argv[i]))
return i;
}
-
+
return 0;
}
void COM_Init (void)
{
#if !defined(ENDIAN_LITTLE) && !defined(ENDIAN_BIG)
- qbyte swaptest[2] = {1,0};
+ qbyte swaptest[2] = {1,0};
// set the byte swapping variables in a portable manner
if ( *(short *)swaptest == 1)
COM_InitFilesystem ();
COM_CheckRegistered ();
+
+ COM_InitGameType();
}
FIXME: make this buffer size safe someday
============
*/
-char *va(char *format, ...)
+char *va(const char *format, ...)
{
va_list argptr;
// LordHavoc: now cycles through 8 buffers to avoid problems in most cases
=============================================================================
*/
-int com_filesize;
+int com_filesize;
//
// LordHavoc: was 2048, increased to 65536 and changed info[MAX_PACK_FILES] to a temporary alloc
#define MAX_FILES_IN_PACK 65536
-pack_t *packlist = NULL;
+pack_t *packlist = NULL;
#if CACHEENABLE
-char com_cachedir[MAX_OSPATH];
+char com_cachedir[MAX_OSPATH];
#endif
-char com_gamedir[MAX_OSPATH];
+char com_gamedir[MAX_OSPATH];
typedef struct searchpath_s
{
+ // only one of filename / pack will be used
char filename[MAX_OSPATH];
- pack_t *pack; // only one of filename / pack will be used
+ pack_t *pack;
struct searchpath_s *next;
} searchpath_t;
-searchpath_t *com_searchpaths;
+searchpath_t *com_searchpaths;
/*
============
*/
void COM_Path_f (void)
{
- searchpath_t *s;
+ searchpath_t *s;
Con_Printf ("Current search path:\n");
for (s=com_searchpaths ; s ; s=s->next)
*/
void COM_CreatePath (char *path)
{
- char *ofs, save;
+ char *ofs, save;
for (ofs = path+1 ; *ofs ; ofs++)
{
The filename will be prefixed by the current game directory
============
*/
-qboolean COM_WriteFile (char *filename, void *data, int len)
+qboolean COM_WriteFile (const char *filename, void *data, int len)
{
- int handle;
- char name[MAX_OSPATH];
+ int handle;
+ char name[MAX_OSPATH];
sprintf (name, "%s/%s", com_gamedir, filename);
// LordHavoc: added this
- COM_CreatePath (name); // create directories up to the file
+ // create directories up to the file
+ COM_CreatePath (name);
handle = Sys_FileOpenWrite (name);
if (handle == -1)
*/
void COM_CopyFile (char *netpath, char *cachepath)
{
- int in, out;
- int remaining, count;
- char buf[4096];
+ int in, out, remaining, count;
+ char buf[4096];
- remaining = Sys_FileOpenRead (netpath, &in);
+ remaining = Sys_FileOpenRead (netpath, &in);
COM_CreatePath (cachepath); // create directories up to the cache file
out = Sys_FileOpenWrite (cachepath);
-
+
while (remaining)
{
if (remaining < sizeof(buf))
}
Sys_FileClose (in);
- Sys_FileClose (out);
+ Sys_FileClose (out);
}
/*
*/
QFile * COM_OpenRead (const char *path, int offs, int len, qboolean zip)
{
- int fd = open (path, O_RDONLY);
- unsigned char id[2];
- unsigned char len_bytes[4];
+ int fd = open (path, O_RDONLY);
+ unsigned char id[2], len_bytes[4];
if (fd == -1)
{
Sets com_filesize and one of handle or file
===========
*/
-int COM_FindFile (char *filename, QFile **file, qboolean quiet, qboolean zip)
+int COM_FindFile (const char *filename, QFile **file, qboolean quiet, qboolean zip)
{
- searchpath_t *search;
- char netpath[MAX_OSPATH];
+ searchpath_t *search;
+ char netpath[MAX_OSPATH];
#if CACHEENABLE
- char cachepath[MAX_OSPATH];
- int cachetime;
+ char cachepath[MAX_OSPATH];
+ int cachetime;
#endif
- pack_t *pak;
- int i;
- int findtime;
- char gzfilename[MAX_OSPATH];
- int filenamelen;
+ pack_t *pak;
+ int i, findtime, filenamelen;
+ char gzfilename[MAX_OSPATH];
filenamelen = strlen (filename);
sprintf (gzfilename, "%s.gz", filename);
if (!file)
Sys_Error ("COM_FindFile: file not set");
-
+
//
// search through the path, one element at a time
//
}
}
else
- {
+ {
sprintf (netpath, "%s/%s",search->filename, filename);
-
+
findtime = Sys_FileTime (netpath);
if (findtime == -1)
continue;
-
+
#if CACHEENABLE
// see if the file needs to be updated in the cache
if (com_cachedir[0])
- {
+ {
#if defined(_WIN32)
if ((strlen(netpath) < 2) || (netpath[1] != ':'))
sprintf (cachepath,"%s%s", com_cachedir, netpath);
if (cachetime < findtime)
COM_CopyFile (netpath, cachepath);
strcpy (netpath, cachepath);
- }
+ }
#endif
-
if (!quiet)
Sys_Printf ("FindFile: %s\n",netpath);
*file = COM_OpenRead (netpath, -1, -1, zip);
return com_filesize;
}
-
}
-
+
if (!quiet)
Sys_Printf ("FindFile: can't find %s\n", filename);
-
+
*file = NULL;
com_filesize = -1;
return -1;
into the file.
===========
*/
-int COM_FOpenFile (char *filename, QFile **file, qboolean quiet, qboolean zip)
+int COM_FOpenFile (const char *filename, QFile **file, qboolean quiet, qboolean zip)
{
return COM_FindFile (filename, file, quiet, zip);
}
*/
qbyte *loadbuf;
int loadsize;
-qbyte *COM_LoadFile (char *path, qboolean quiet)
+qbyte *COM_LoadFile (const char *path, qboolean quiet)
{
QFile *h;
qbyte *buf;
of the list so they override previous pack files.
=================
*/
-pack_t *COM_LoadPackFile (char *packfile)
+pack_t *COM_LoadPackFile (const char *packfile)
{
- dpackheader_t header;
- int i;
- int numpackfiles;
- pack_t *pack;
- int packhandle;
+ dpackheader_t header;
+ int i, numpackfiles, packhandle;
+ pack_t *pack;
// LordHavoc: changed from stack array to temporary alloc, allowing huge pack directories
- dpackfile_t *info;
+ dpackfile_t *info;
if (Sys_FileOpenRead (packfile, &packhandle) == -1)
return NULL;
}
}
-int COM_FileExists(char *filename)
+int COM_FileExists(const char *filename)
{
- searchpath_t *search;
- char netpath[MAX_OSPATH];
- pack_t *pak;
- int i;
- int findtime;
+ searchpath_t *search;
+ char netpath[MAX_OSPATH];
+ pack_t *pak;
+ int i, findtime;
for (search = com_searchpaths;search;search = search->next)
{
findtime = Sys_FileTime (netpath);
if (findtime != -1)
return true;
- }
+ }
}
return false;
//======================================
// LordHavoc: added these because they are useful
-void COM_ToLowerString(char *in, char *out)
+void COM_ToLowerString(const char *in, char *out)
{
while (*in)
{
}
}
-void COM_ToUpperString(char *in, char *out)
+void COM_ToUpperString(const char *in, char *out)
{
while (*in)
{
return false;
return true;
}
-
int cursize;
} sizebuf_t;
-void SZ_Alloc (sizebuf_t *buf, int startsize, char *name);
+void SZ_Alloc (sizebuf_t *buf, int startsize, const char *name);
void SZ_Free (sizebuf_t *buf);
void SZ_Clear (sizebuf_t *buf);
void *SZ_GetSpace (sizebuf_t *buf, int length);
-void SZ_Write (sizebuf_t *buf, void *data, int length);
-void SZ_Print (sizebuf_t *buf, char *data); // strcats onto the sizebuf
-void SZ_HexDumpToConsole(sizebuf_t *buf);
+void SZ_Write (sizebuf_t *buf, const void *data, int length);
+void SZ_Print (sizebuf_t *buf, const char *data); // strcats onto the sizebuf
+void SZ_HexDumpToConsole(const sizebuf_t *buf);
//============================================================================
#if !defined(ENDIAN_LITTLE) && !defined(ENDIAN_BIG)
void MSG_WriteShort (sizebuf_t *sb, int c);
void MSG_WriteLong (sizebuf_t *sb, int c);
void MSG_WriteFloat (sizebuf_t *sb, float f);
-void MSG_WriteString (sizebuf_t *sb, char *s);
+void MSG_WriteString (sizebuf_t *sb, const char *s);
void MSG_WriteCoord (sizebuf_t *sb, float f);
void MSG_WriteAngle (sizebuf_t *sb, float f);
void MSG_WritePreciseAngle (sizebuf_t *sb, float f);
//============================================================================
-int Q_strcasecmp (char *s1, char *s2);
-int Q_strncasecmp (char *s1, char *s2, int n);
+int Q_strcasecmp (const char *s1, const char *s2);
+int Q_strncasecmp (const char *s1, const char *s2, int n);
//============================================================================
-extern char com_token[1024];
-extern qboolean com_eof;
+extern char com_token[1024];
+extern qboolean com_eof;
-char *COM_Parse (char *data);
+int COM_ParseToken (const char **data);
extern char com_basedir[MAX_OSPATH];
extern int com_argc;
-extern char **com_argv;
+extern const char **com_argv;
-int COM_CheckParm (char *parm);
+int COM_CheckParm (const char *parm);
void COM_Init (void);
void COM_InitArgv (void);
void COM_InitGameType (void);
-char *COM_SkipPath (char *pathname);
-void COM_StripExtension (char *in, char *out);
-void COM_FileBase (char *in, char *out);
-void COM_DefaultExtension (char *path, char *extension);
+void COM_StripExtension (const char *in, char *out);
+void COM_FileBase (const char *in, char *out);
+void COM_DefaultExtension (char *path, const char *extension);
-char *va(char *format, ...);
+char *va(const char *format, ...);
// does a varargs printf into a temp buffer
extern char com_gamedir[MAX_OSPATH];
-qboolean COM_WriteFile (char *filename, void *data, int len);
-int COM_FOpenFile (char *filename, QFile **file, qboolean quiet, qboolean zip);
+qboolean COM_WriteFile (const char *filename, void *data, int len);
+int COM_FOpenFile (const char *filename, QFile **file, qboolean quiet, qboolean zip);
// set by COM_LoadFile functions
extern int loadsize;
-qbyte *COM_LoadFile (char *path, qboolean quiet);
+qbyte *COM_LoadFile (const char *path, qboolean quiet);
-int COM_FileExists(char *filename);
+int COM_FileExists(const char *filename);
extern struct cvar_s registered;
extern char *gamename;
// LordHavoc: useful...
-void COM_ToLowerString(char *in, char *out);
-void COM_ToUpperString(char *in, char *out);
+void COM_ToLowerString(const char *in, char *out);
+void COM_ToUpperString(const char *in, char *out);
int COM_StringBeginsWith(const char *s, const char *match);
typedef struct stringlist_s
#include <fcntl.h>
#include "quakedef.h"
-int con_linewidth;
+int con_linewidth;
-float con_cursorspeed = 4;
+float con_cursorspeed = 4;
#define CON_TEXTSIZE 131072
-int con_totallines; // total lines in console scrollback
-int con_backscroll; // lines up from bottom to display
-int con_current; // where next message will be printed
-int con_x; // offset in current line for next print
-char *con_text = 0;
+// total lines in console scrollback
+int con_totallines;
+// lines up from bottom to display
+int con_backscroll;
+// where next message will be printed
+int con_current;
+// offset in current line for next print
+int con_x;
+char *con_text = 0;
-cvar_t con_notifytime = {CVAR_SAVE, "con_notifytime","3"}; //seconds
-cvar_t logfile = {0, "logfile","0"};
+//seconds
+cvar_t con_notifytime = {CVAR_SAVE, "con_notifytime","3"};
+cvar_t logfile = {0, "logfile","0"};
#define NUM_CON_TIMES 4
-float con_times[NUM_CON_TIMES]; // realtime time the line was generated
- // for transparent notify lines
+// realtime time the line was generated for transparent notify lines
+float con_times[NUM_CON_TIMES];
-int con_vislines;
+int con_vislines;
-qboolean con_debuglog;
+qboolean con_debuglog;
-#define MAXCMDLINE 256
-extern char key_lines[32][MAXCMDLINE];
-extern int edit_line;
-extern int key_linepos;
-extern int key_insert;
+#define MAXCMDLINE 256
+extern char key_lines[32][MAXCMDLINE];
+extern int edit_line;
+extern int key_linepos;
+extern int key_insert;
-qboolean con_initialized;
+qboolean con_initialized;
-mempool_t *console_mempool;
+mempool_t *console_mempool;
-int con_notifylines; // scan lines to clear for notify lines
+// scan lines to clear for notify lines
+int con_notifylines;
extern void M_Menu_Main_f (void);
*/
void Con_ClearNotify (void)
{
- int i;
+ int i;
for (i=0 ; i<NUM_CON_TIMES ; i++)
con_times[i] = 0;
*/
void Con_CheckResize (void)
{
- int i, j, width, oldwidth, oldtotallines, numlines, numchars;
- char tbuf[CON_TEXTSIZE];
+ int i, j, width, oldwidth, oldtotallines, numlines, numchars;
+ char tbuf[CON_TEXTSIZE];
width = (vid.conwidth >> 3);
*/
void Con_Init (void)
{
-#define MAXGAMEDIRLEN 1000
- char temp[MAXGAMEDIRLEN+1];
- char *t2 = "/qconsole.log";
+#define MAXGAMEDIRLEN 1000
+ char temp[MAXGAMEDIRLEN+1];
+ char *t2 = "/qconsole.log";
Cvar_RegisterVariable(&logfile);
con_debuglog = COM_CheckParm("-condebug");
If no console is visible, the notify window will pop up.
================
*/
-void Con_Print (char *txt)
+void Con_Print (const char *txt)
{
- int y;
- int c, l;
- static int cr;
- int mask;
+ int y, c, l, mask;
+ static int cr;
con_backscroll = 0;
Con_DebugLog
================
*/
-void Con_DebugLog(char *file, char *fmt, ...)
+void Con_DebugLog(const char *file, const char *fmt, ...)
{
va_list argptr;
FILE* fd;
// LordHavoc: increased from 4096 to 16384
#define MAXPRINTMSG 16384
// FIXME: make a buffer size safe vsprintf?
-void Con_Printf (char *fmt, ...)
+void Con_Printf (const char *fmt, ...)
{
- va_list argptr;
- char msg[MAXPRINTMSG];
+ va_list argptr;
+ char msg[MAXPRINTMSG];
va_start (argptr,fmt);
vsprintf (msg,fmt,argptr);
A Con_Printf that only shows up if the "developer" cvar is set
================
*/
-void Con_DPrintf (char *fmt, ...)
+void Con_DPrintf (const char *fmt, ...)
{
- va_list argptr;
- char msg[MAXPRINTMSG];
+ va_list argptr;
+ char msg[MAXPRINTMSG];
if (!developer.integer)
return; // don't confuse non-developers with techie stuff...
Okay to call even when the screen can't be updated
==================
*/
-void Con_SafePrintf (char *fmt, ...)
+void Con_SafePrintf (const char *fmt, ...)
{
va_list argptr;
char msg[1024];
extern char engineversion[40];
void Con_DrawConsole (int lines)
{
- int i, y;
- int rows;
- char *text;
- int j;
+ int i, y, rows, j;
+ char *text;
if (lines <= 0)
return;
MEGA Thanks to Taniwha
*/
-void
-Con_DisplayList(char **list)
+void Con_DisplayList(const char **list)
{
- int i = 0;
- int pos = 0;
- int len = 0;
- int maxlen = 0;
- int width = (con_linewidth - 4);
- char **walk = list;
+ int i = 0, pos = 0, len = 0, maxlen = 0, width = (con_linewidth - 4);
+ const char **walk = list;
while (*walk) {
len = strlen(*walk);
Thanks to taniwha
*/
-void
-Con_CompleteCommandLine (void)
+void Con_CompleteCommandLine (void)
{
- char *cmd = "";
- char *s;
- int c, v, a, i;
- int cmd_len;
- char **list[3] = {0, 0, 0};
+ const char *cmd = "", *s;
+ const char **list[3] = {0, 0, 0};
+ int c, v, a, i, cmd_len;
s = key_lines[edit_line] + 1;
// Count number of possible matches
do {
for (i = 0; i < 3; i++) {
char ch = cmd[cmd_len];
- char **l = list[i];
+ const char **l = list[i];
if (l) {
while (*l && (*l)[cmd_len] == ch)
l++;
extern qbyte *con_chars;
extern int con_notifylines; // scan lines to clear for notify lines
-void Con_DrawCharacter (int cx, int line, int num);
-
void Con_CheckResize (void);
void Con_Init (void);
void Con_DrawConsole (int lines);
-void Con_Print (char *txt);
-void Con_Printf (char *fmt, ...);
-void Con_DPrintf (char *fmt, ...);
-void Con_SafePrintf (char *fmt, ...);
+void Con_Print (const char *txt);
+void Con_Printf (const char *fmt, ...);
+void Con_DPrintf (const char *fmt, ...);
+void Con_SafePrintf (const char *fmt, ...);
void Con_Clear_f (void);
void Con_DrawNotify (void);
void Con_ClearNotify (void);
// Generic libs/util/console.c function to display a list
// formatted in columns on the console
-void Con_DisplayList(char **list);
+void Con_DisplayList(const char **list);
#endif
#include "quakedef.h"
-cvar_t *cvar_vars = NULL;
-char *cvar_null_string = "";
+cvar_t *cvar_vars = NULL;
+char *cvar_null_string = "";
/*
============
Cvar_FindVar
============
*/
-cvar_t *Cvar_FindVar (char *var_name)
+cvar_t *Cvar_FindVar (const char *var_name)
{
cvar_t *var;
return NULL;
}
-cvar_t *Cvar_FindVarAfter (char *prev_var_name, int neededflags)
+cvar_t *Cvar_FindVarAfter (const char *prev_var_name, int neededflags)
{
cvar_t *var;
Cvar_VariableValue
============
*/
-float Cvar_VariableValue (char *var_name)
+float Cvar_VariableValue (const char *var_name)
{
- cvar_t *var;
+ cvar_t *var;
var = Cvar_FindVar (var_name);
if (!var)
Cvar_VariableString
============
*/
-char *Cvar_VariableString (char *var_name)
+const char *Cvar_VariableString (const char *var_name)
{
cvar_t *var;
Cvar_CompleteVariable
============
*/
-char *Cvar_CompleteVariable (char *partial)
+const char *Cvar_CompleteVariable (const char *partial)
{
cvar_t *cvar;
int len;
Thanks to Fett erich@heintz.com
*/
-int
-Cvar_CompleteCountPossible (char *partial)
+int Cvar_CompleteCountPossible (const char *partial)
{
cvar_t *cvar;
int len;
Thanks to taniwha
*/
-char **
-Cvar_CompleteBuildList (char *partial)
+const char **Cvar_CompleteBuildList (const char *partial)
{
- cvar_t *cvar;
- int len = 0;
- int bpos = 0;
- int sizeofbuf = (Cvar_CompleteCountPossible (partial) + 1) * sizeof (char *);
- char **buf;
+ const cvar_t *cvar;
+ int len = 0;
+ int bpos = 0;
+ int sizeofbuf = (Cvar_CompleteCountPossible (partial) + 1) * sizeof (const char *);
+ const char **buf;
len = strlen(partial);
- buf = Mem_Alloc(tempmempool, sizeofbuf + sizeof (char *));
+ buf = Mem_Alloc(tempmempool, sizeofbuf + sizeof (const char *));
// Loop through the alias list and print all matches
for (cvar = cvar_vars; cvar; cvar = cvar->next)
if (!strncasecmp(partial, cvar->name, len))
Cvar_Set
============
*/
-void Cvar_SetQuick (cvar_t *var, char *value)
+void Cvar_SetQuick (cvar_t *var, const char *value)
{
qboolean changed;
}
}
-void Cvar_Set (char *var_name, char *value)
+void Cvar_Set (const char *var_name, const char *value)
{
cvar_t *var;
var = Cvar_FindVar (var_name);
Cvar_SetQuick (var, val);
}
-void Cvar_SetValue (char *var_name, float value)
+void Cvar_SetValue (const char *var_name, float value)
{
char val[32];
*/
void Cvar_List_f (void)
{
- cvar_t *cvar;
- char *partial;
- int len;
- int count;
+ cvar_t *cvar;
+ const char *partial;
+ int len, count;
- if (Cmd_Argc() > 1) {
+ if (Cmd_Argc() > 1)
+ {
partial = Cmd_Argv (1);
len = strlen(partial);
- } else {
+ }
+ else
+ {
partial = NULL;
len = 0;
}
count = 0;
- for (cvar = cvar_vars; cvar; cvar = cvar->next) {
+ for (cvar = cvar_vars; cvar; cvar = cvar->next)
+ {
if (partial && strncmp (partial,cvar->name,len))
continue;
#define CVAR_SAVE 1
#define CVAR_NOTIFY 2
+/*
// type of a cvar for menu purposes
#define CVARMENUTYPE_FLOAT 1
#define CVARMENUTYPE_INTEGER 2
typedef struct
{
int value;
- char *name;
+ const char *name;
}
cvaroption_t;
typedef struct
{
- int type;
- float valuemin, valuemax, valuestep;
- int numoptions;
- cvaroption_t optionlist[MAX_CVAROPTIONS];
+ int type;
+ float valuemin, valuemax, valuestep;
+ int numoptions;
+ cvaroption_t optionlist[MAX_CVAROPTIONS];
}
menucvar_t;
+*/
typedef struct cvar_s
{
- int flags;
- char *name;
- char *string;
- int integer;
- float value;
- float vector[3];
- menucvar_t menuinfo;
- struct cvar_s *next;
+ int flags;
+ char *name;
+ char *string;
+ int integer;
+ float value;
+ float vector[3];
+ //menucvar_t menuinfo;
+ struct cvar_s *next;
} cvar_t;
-void Cvar_MenuSlider(cvar_t *variable, int menu, float slider_min, float slider_max, float slider_step);
-void Cvar_MenuBool(cvar_t *variable, int menu, char *name_false, char *name_true);
-void Cvar_MenuFloat(cvar_t *variable, int menu, float range_min, float range_max);
-void Cvar_MenuInteger(cvar_t *variable, int menu, int range_min, int range_max);
-void Cvar_MenuString(cvar_t *variable, int menu);
-void Cvar_MenuOption(cvar_t *variable, int menu, int value[16], char *name[16]);
+/*
+void Cvar_MenuSlider(cvar_t *variable, int menu, float slider_min, float slider_max, float slider_step);
+void Cvar_MenuBool(cvar_t *variable, int menu, const char *name_false, const char *name_true);
+void Cvar_MenuFloat(cvar_t *variable, int menu, float range_min, float range_max);
+void Cvar_MenuInteger(cvar_t *variable, int menu, int range_min, int range_max);
+void Cvar_MenuString(cvar_t *variable, int menu);
+void Cvar_MenuOption(cvar_t *variable, int menu, int value[16], const char *name[16]);
+*/
-void Cvar_RegisterVariable (cvar_t *variable);
+void Cvar_RegisterVariable (cvar_t *variable);
// registers a cvar that already has the name, string, and optionally the
// archive elements set.
-void Cvar_Set (char *var_name, char *value);
+void Cvar_Set (const char *var_name, const char *value);
// equivelant to "<name> <variable>" typed at the console
-void Cvar_SetValue (char *var_name, float value);
+void Cvar_SetValue (const char *var_name, float value);
// expands value to a string and calls Cvar_Set
-void Cvar_SetQuick (cvar_t *var, char *value);
-void Cvar_SetValueQuick (cvar_t *var, float value);
+void Cvar_SetQuick (cvar_t *var, const char *value);
+void Cvar_SetValueQuick (cvar_t *var, float value);
-float Cvar_VariableValue (char *var_name);
+float Cvar_VariableValue (const char *var_name);
// returns 0 if not defined or non numeric
-char *Cvar_VariableString (char *var_name);
+const char *Cvar_VariableString (const char *var_name);
// returns an empty string if not defined
-char *Cvar_CompleteVariable (char *partial);
+const char *Cvar_CompleteVariable (const char *partial);
// attempts to match a partial variable name for command line completion
// returns NULL if nothing fits
// command. Returns true if the command was a variable reference that
// was handled. (print or change)
-void Cvar_WriteVariables (QFile *f);
+void Cvar_WriteVariables (QFile *f);
// Writes lines containing "set variable value" for all variables
// with the archive flag set to true.
-cvar_t *Cvar_FindVar (char *var_name);
-cvar_t *Cvar_FindVarAfter (char *prev_var_name, int neededflags);
+cvar_t *Cvar_FindVar (const char *var_name);
+cvar_t *Cvar_FindVarAfter (const char *prev_var_name, int neededflags);
-int Cvar_CompleteCountPossible (char *partial);
-char **Cvar_CompleteBuildList (char *partial);
+int Cvar_CompleteCountPossible (const char *partial);
+const char **Cvar_CompleteBuildList (const char *partial);
// Added by EvilTypeGuy - functions for tab completion system
// Thanks to Fett erich@heintz.com
// Thanks to taniwha
-void Cvar_List_f (void);
+void Cvar_List_f (void);
// Prints a list of Cvars including a count of them to the user console
// Referenced in cmd.c in Cmd_Init hence it's inclusion here
// Added by EvilTypeGuy eviltypeguy@qeradiant.com
*/
-qboolean host_initialized; // true if into command execution
-qboolean host_loopactive = false; // LordHavoc: used to turn Host_Error into Sys_Error if starting up or shutting down
-qboolean host_shuttingdown = false; // LordHavoc: set when quit is executed
+// true if into command execution
+qboolean host_initialized;
+// LordHavoc: used to turn Host_Error into Sys_Error if starting up or shutting down
+qboolean host_loopactive = false;
+// LordHavoc: set when quit is executed
+qboolean host_shuttingdown = false;
-double host_frametime;
-double host_realframetime; // LordHavoc: the real frametime, before slowmo and clamping are applied (used for console scrolling)
-double realtime; // without any filtering or bounding
-double oldrealtime; // last frame run
-int host_framecount;
+double host_frametime;
+// LordHavoc: the real frametime, before slowmo and clamping are applied (used for console scrolling)
+double host_realframetime;
+// the real time, without any slowmo or clamping
+double realtime;
+// realtime from previous frame
+double oldrealtime;
+// how many frames have occurred
+int host_framecount;
-int forcedeveloper; // used for -developer commandline parameter, hacky hacky
+// used for -developer commandline parameter, hacky hacky
+int forcedeveloper;
-client_t *host_client; // current client
+// current client
+client_t *host_client;
-jmp_buf host_abortserver;
+jmp_buf host_abortserver;
-cvar_t host_framerate = {0, "host_framerate","0"}; // set for slow motion
-cvar_t host_speeds = {0, "host_speeds","0"}; // set for running times
-cvar_t slowmo = {0, "slowmo", "1.0"}; // LordHavoc: framerate independent slowmo
-cvar_t host_minfps = {CVAR_SAVE, "host_minfps", "10"}; // LordHavoc: game logic lower cap on framerate (if framerate is below this is, it pretends it is this, so game logic will run normally)
-cvar_t host_maxfps = {CVAR_SAVE, "host_maxfps", "1000"}; // LordHavoc: framerate upper cap
+// pretend frames take this amount of time (in seconds), 0 = realtime
+cvar_t host_framerate = {0, "host_framerate","0"};
+// shows time used by certain subsystems
+cvar_t host_speeds = {0, "host_speeds","0"};
+// LordHavoc: framerate independent slowmo
+cvar_t slowmo = {0, "slowmo", "1.0"};
+// LordHavoc: game logic lower cap on framerate (if framerate is below this is, it pretends it is this, so game logic will run normally)
+cvar_t host_minfps = {CVAR_SAVE, "host_minfps", "10"};
+// LordHavoc: framerate upper cap
+cvar_t host_maxfps = {CVAR_SAVE, "host_maxfps", "1000"};
-cvar_t sv_echobprint = {CVAR_SAVE, "sv_echobprint", "1"}; // print broadcast messages in dedicated mode
+// print broadcast messages in dedicated mode
+cvar_t sv_echobprint = {CVAR_SAVE, "sv_echobprint", "1"};
-cvar_t sys_ticrate = {CVAR_SAVE, "sys_ticrate","0.05"};
-cvar_t serverprofile = {0, "serverprofile","0"};
+cvar_t sys_ticrate = {CVAR_SAVE, "sys_ticrate","0.05"};
+cvar_t serverprofile = {0, "serverprofile","0"};
-cvar_t fraglimit = {CVAR_NOTIFY, "fraglimit","0"};
-cvar_t timelimit = {CVAR_NOTIFY, "timelimit","0"};
-cvar_t teamplay = {CVAR_NOTIFY, "teamplay","0"};
+cvar_t fraglimit = {CVAR_NOTIFY, "fraglimit","0"};
+cvar_t timelimit = {CVAR_NOTIFY, "timelimit","0"};
+cvar_t teamplay = {CVAR_NOTIFY, "teamplay","0"};
-cvar_t samelevel = {0, "samelevel","0"};
-cvar_t noexit = {CVAR_NOTIFY, "noexit","0"};
+cvar_t samelevel = {0, "samelevel","0"};
+cvar_t noexit = {CVAR_NOTIFY, "noexit","0"};
-cvar_t developer = {0, "developer","0"};
+cvar_t developer = {0, "developer","0"};
-cvar_t skill = {0, "skill","1"}; // 0 - 3
-cvar_t deathmatch = {0, "deathmatch","0"}; // 0, 1, or 2
-cvar_t coop = {0, "coop","0"}; // 0 or 1
+cvar_t skill = {0, "skill","1"};
+cvar_t deathmatch = {0, "deathmatch","0"};
+cvar_t coop = {0, "coop","0"};
-cvar_t pausable = {0, "pausable","1"};
+cvar_t pausable = {0, "pausable","1"};
-cvar_t temp1 = {0, "temp1","0"};
+cvar_t temp1 = {0, "temp1","0"};
-cvar_t timestamps = {CVAR_SAVE, "timestamps", "0"};
-cvar_t timeformat = {CVAR_SAVE, "timeformat", "[%b %e %X] "};
+cvar_t timestamps = {CVAR_SAVE, "timestamps", "0"};
+cvar_t timeformat = {CVAR_SAVE, "timeformat", "[%b %e %X] "};
/*
================
Host_EndGame
================
*/
-void Host_EndGame (char *message, ...)
+void Host_EndGame (const char *format, ...)
{
- va_list argptr;
- char string[1024];
+ va_list argptr;
+ char string[1024];
- va_start (argptr,message);
- vsprintf (string,message,argptr);
+ va_start (argptr,format);
+ vsprintf (string,format,argptr);
va_end (argptr);
Con_DPrintf ("Host_EndGame: %s\n",string);
================
*/
char hosterrorstring[4096];
-void Host_Error (char *error, ...)
+void Host_Error (const char *error, ...)
{
- va_list argptr;
- static qboolean inerror = false;
+ va_list argptr;
+ static qboolean inerror = false;
// LordHavoc: if first frame has not been shown, or currently shutting
// down, do Sys_Error instead
*/
void Host_WriteConfiguration (void)
{
- QFile *f;
+ QFile *f;
// dedicated servers initialize the host but don't parse and set the
// config.cfg cvars
Con_Printf ("Couldn't write config.cfg.\n");
return;
}
-
+
Key_WriteBindings (f);
Cvar_WriteVariables (f);
FIXME: make this just a stuffed echo?
=================
*/
-void SV_ClientPrintf (char *fmt, ...)
+void SV_ClientPrintf (const char *fmt, ...)
{
- va_list argptr;
- char string[1024];
-
+ va_list argptr;
+ char string[1024];
+
va_start (argptr,fmt);
vsprintf (string, fmt,argptr);
va_end (argptr);
-
+
MSG_WriteByte (&host_client->message, svc_print);
MSG_WriteString (&host_client->message, string);
}
Sends text to all active clients
=================
*/
-void SV_BroadcastPrintf (char *fmt, ...)
+void SV_BroadcastPrintf (const char *fmt, ...)
{
- va_list argptr;
- char string[1024];
- int i;
-
+ va_list argptr;
+ char string[1024];
+ int i;
+
va_start (argptr,fmt);
vsprintf (string, fmt,argptr);
va_end (argptr);
-
+
for (i=0 ; i<svs.maxclients ; i++)
if (svs.clients[i].active && svs.clients[i].spawned)
{
Send text over to the client to be executed
=================
*/
-void Host_ClientCommands (char *fmt, ...)
+void Host_ClientCommands (const char *fmt, ...)
{
- va_list argptr;
- char string[1024];
-
+ va_list argptr;
+ char string[1024];
+
va_start (argptr,fmt);
vsprintf (string, fmt,argptr);
va_end (argptr);
*/
void SV_DropClient (qboolean crash)
{
- int saveSelf;
- int i;
+ int saveSelf;
+ int i;
client_t *client;
if (!crash)
MSG_WriteByte (&host_client->message, svc_disconnect);
NET_SendMessage (host_client->netconnection, &host_client->message);
}
-
+
if (sv.active && host_client->edict && host_client->spawned) // LordHavoc: don't call QC if server is dead (avoids recursive Host_Error in some mods when they run out of edicts)
{
// call the prog function for removing a client
*/
void Host_ShutdownServer(qboolean crash)
{
- int i;
- int count;
- sizebuf_t buf;
- char message[4];
- double start;
+ int i, count;
+ sizebuf_t buf;
+ char message[4];
+ double start;
if (!sv.active)
return;
*/
void Host_GetConsoleCommands (void)
{
- char *cmd;
+ char *cmd;
while (1)
{
*/
void _Host_Frame (float time)
{
- static double time1 = 0;
- static double time2 = 0;
- static double time3 = 0;
- int pass1, pass2, pass3;
+ static double time1 = 0;
+ static double time2 = 0;
+ static double time3 = 0;
+ int pass1, pass2, pass3;
if (setjmp (host_abortserver) )
return; // something bad happened, or the server disconnected
void Host_Frame (float time)
{
- double time1, time2;
- static double timetotal;
- static int timecount;
- int i, c, m;
+ double time1, time2;
+ static double timetotal;
+ static int timecount;
+ int i, c, m;
if (!serverprofile.integer)
{
*/
void Host_Status_f (void)
{
- client_t *client;
- int seconds;
- int minutes;
- int hours = 0;
- int j;
- void (*print) (char *fmt, ...);
+ client_t *client;
+ int seconds, minutes, hours = 0, j;
+ void (*print) (const char *fmt, ...);
if (cmd_source == src_command)
{
*/
void Host_Loadgame_f (void)
{
- char name[MAX_OSPATH];
- QFile *f;
- char mapname[MAX_QPATH];
- float time, tfloat;
- char buf[32768], *start;
- char *str;
- int i, r;
- edict_t *ent;
- int entnum;
- int version;
- float spawn_parms[NUM_SPAWN_PARMS];
+ char name[MAX_OSPATH];
+ QFile *f;
+ char mapname[MAX_QPATH];
+ float time, tfloat;
+ char buf[32768];
+ const char *start;
+ char *str;
+ int i, r;
+ edict_t *ent;
+ int entnum;
+ int version;
+ float spawn_parms[NUM_SPAWN_PARMS];
if (cmd_source != src_command)
return;
}
// load the edicts out of the savegame file
- entnum = -1; // -1 is the globals
+ // -1 is the globals
+ entnum = -1;
while (!Qeof(f))
{
for (i=0 ; i<sizeof(buf)-1 ; i++)
}
}
if (i == sizeof(buf)-1)
- Sys_Error ("Loadgame buffer overflow");
+ Host_Error ("Loadgame buffer overflow");
buf[i] = 0;
start = buf;
- start = COM_Parse(buf);
- if (!com_token[0])
- break; // end of file
+ if (!COM_ParseToken(&start))
+ {
+ // end of file
+ break;
+ }
if (strcmp(com_token,"{"))
- Sys_Error ("First token isn't a brace");
-
+ Host_Error ("First token isn't a brace");
+
if (entnum == -1)
- { // parse the global vars
+ {
+ // parse the global vars
ED_ParseGlobals (start);
}
else
- { // parse an edict
-
+ {
+ // parse an edict
ent = EDICT_NUM(entnum);
memset (&ent->v, 0, progs->entityfields * 4);
ent->free = false;
ED_ParseEdict (start, ent);
-
- // link it into the bsp tree
+
+ // link it into the bsp tree
if (!ent->free)
SV_LinkEdict (ent, false);
}
entnum++;
}
-
+
sv.num_edicts = entnum;
sv.time = time;
MSG_WriteString (&sv.reliable_datagram, host_client->name);
}
-
+
void Host_Version_f (void)
{
Con_Printf ("Version: %s build %s\n", gamename, buildstring);
{
client_t *client;
client_t *save;
- int j;
- char *p;
+ int j;
+ const char *p1, *p2;
// LordHavoc: 256 char say messages
- unsigned char text[256];
- qboolean fromServer = false;
+ unsigned char text[256];
+ qboolean fromServer = false;
if (cmd_source == src_command)
{
if (Cmd_Argc () < 2)
return;
- save = host_client;
-
- p = Cmd_Args();
-// remove quotes if present
- if (*p == '"')
- {
- p++;
- p[strlen(p)-1] = 0;
- }
-
// turn on color set 1
if (!fromServer)
- sprintf (text, "%c%s: ", 1, save->name);
+ sprintf (text, "%c%s: ", 1, host_client->name);
else
sprintf (text, "%c<%s> ", 1, hostname.string);
- j = sizeof(text) - 2 - strlen(text); // -2 for /n and null terminator
- if (strlen(p) > j)
- p[j] = 0;
+ save = host_client;
- strcat (text, p);
- strcat (text, "\n");
+ p1 = Cmd_Args();
+ p2 = p1 + strlen(p1);
+ // remove trailing newlines
+ while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
+ p2--;
+ // remove quotes if present
+ if (*p1 == '"')
+ {
+ p1++;
+ if (p2[-1] == '"')
+ p2--;
+ else
+ Con_Printf("Host_Say: missing end quote\n");
+ }
+ while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
+ p2--;
+ for (j = strlen(text);j < (sizeof(text) - 2) && p1 < p2;)
+ text[j++] = *p1++;
+ text[j++] = '\n';
+ text[j++] = 0;
for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
{
{
client_t *client;
client_t *save;
- int j;
- char *p;
- char text[1024]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
+ int j;
+ const char *p1, *p2;
+ char text[1024]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
+ qboolean fromServer = false;
if (cmd_source == src_command)
{
- Cmd_ForwardToServer ();
- return;
+ if (cls.state == ca_dedicated)
+ fromServer = true;
+ else
+ {
+ Cmd_ForwardToServer ();
+ return;
+ }
}
if (Cmd_Argc () < 3)
return;
- strcpy(text, host_client->name);
- strcat(text, ": ");
-
- p = Cmd_Args();
-
-// remove quotes if present
- if (*p == '"')
- {
- p++;
- p[strlen(p)-1] = 0;
+ if (!fromServer)
+ sprintf (text, "%s: ", host_client->name);
+ else
+ sprintf (text, "<%s> ", hostname.string);
+
+ p1 = Cmd_Args();
+ p2 = p1 + strlen(p1);
+ // remove the target name
+ while (p1 < p2 && *p1 != ' ')
+ p1++;
+ while (p1 < p2 && *p1 == ' ')
+ p1++;
+ // remove trailing newlines
+ while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
+ p2--;
+ // remove quotes if present
+ if (*p1 == '"')
+ {
+ p1++;
+ if (p2[-1] == '"')
+ p2--;
+ else
+ Con_Printf("Host_Say: missing end quote\n");
}
-
-// check length & truncate if necessary
- j = sizeof(text) - 2 - strlen(text); // -2 for /n and null terminator
- if (strlen(p) > j)
- p[j] = 0;
-
- strcat (text, p);
- strcat (text, "\n");
+ while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
+ p2--;
+ for (j = strlen(text);j < (sizeof(text) - 2) && p1 < p2;)
+ text[j++] = *p1++;
+ text[j++] = '\n';
+ text[j++] = 0;
save = host_client;
for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
top = atoi(Cmd_Argv(1));
bottom = atoi(Cmd_Argv(2));
}
-
+
top &= 15;
// LordHavoc: allow skin colormaps 14 and 15 (was 13)
if (top > 15)
SV_ClientPrintf ("Can't suicide -- already dead!\n");
return;
}
-
+
pr_global_struct->time = sv.time;
pr_global_struct->self = EDICT_TO_PROG(sv_player);
PR_ExecuteProgram (pr_global_struct->ClientKill, "QC function ClientKill is missing");
*/
void Host_Kick_f (void)
{
- char *who;
- char *message = NULL;
- client_t *save;
- int i;
- qboolean byNumber = false;
+ char *who;
+ const char *message = NULL;
+ client_t *save;
+ int i;
+ qboolean byNumber = false;
if (cmd_source == src_command)
{
if (i < svs.maxclients)
{
if (cmd_source == src_command)
+ {
if (cls.state == ca_dedicated)
who = "Console";
else
who = cl_name.string;
+ }
else
who = save->name;
if (Cmd_Argc() > 2)
{
- message = COM_Parse(Cmd_Args());
+ message = Cmd_Args();
+ COM_ParseToken(&message);
if (byNumber)
{
message++; // skip the #
*/
void Host_Give_f (void)
{
- char *t;
- int v;
- eval_t *val;
+ const char *t;
+ int v;
+ eval_t *val;
if (cmd_source == src_command)
{
}
// used only for HalfLife maps
-void Mod_ParseWadsFromEntityLump(char *data)
+void Mod_ParseWadsFromEntityLump(const char *data)
{
char key[128], value[4096];
char wadname[128];
int i, j, k;
if (!data)
return;
- data = COM_Parse(data);
- if (!data)
+ if (!COM_ParseToken(&data))
return; // error
if (com_token[0] != '{')
return; // error
while (1)
{
- data = COM_Parse(data);
- if (!data)
+ if (!COM_ParseToken(&data))
return; // error
if (com_token[0] == '}')
break; // end of worldspawn
strcpy(key, com_token);
while (key[strlen(key)-1] == ' ') // remove trailing spaces
key[strlen(key)-1] = 0;
- data = COM_Parse(data);
- if (!data)
+ if (!COM_ParseToken(&data))
return; // error
strcpy(value, com_token);
if (!strcmp("wad", key)) // for HalfLife maps
==================
*/
-model_t *Mod_FindName (char *name)
+model_t *Mod_FindName (const char *name)
{
int i;
model_t *mod, *freemod;
==================
*/
-void Mod_TouchModel (char *name)
+void Mod_TouchModel (const char *name)
{
model_t *mod;
Loads in a model for the given name
==================
*/
-model_t *Mod_ForName (char *name, qboolean crash, qboolean checkdisk, qboolean isworldmodel)
+model_t *Mod_ForName (const char *name, qboolean crash, qboolean checkdisk, qboolean isworldmodel)
{
return Mod_LoadModel (Mod_FindName (name), crash, checkdisk, isworldmodel);
}
void Mod_Init (void);
void Mod_CheckLoaded (model_t *mod);
void Mod_ClearAll (void);
-model_t *Mod_ForName (char *name, qboolean crash, qboolean checkdisk, qboolean isworldmodel);
-void Mod_TouchModel (char *name);
+model_t *Mod_FindName (const char *name);
+model_t *Mod_ForName (const char *name, qboolean crash, qboolean checkdisk, qboolean isworldmodel);
+void Mod_TouchModel (const char *name);
void Mod_UnloadModel (model_t *mod);
void Mod_ClearUsed(void);
extern model_t *loadmodel;
extern char loadname[32]; // for hunk tags
-extern model_t *Mod_FindName (char *name);
-
#endif // __MODEL__
struct qsockaddr addr;
char address[NET_NAMELEN];
-
} qsocket_t;
extern qsocket_t *net_activeSockets;
int (*Write) (int socket, qbyte *buf, int len, struct qsockaddr *addr);
int (*Broadcast) (int socket, qbyte *buf, int len);
char * (*AddrToString) (struct qsockaddr *addr);
- int (*StringToAddr) (char *string, struct qsockaddr *addr);
+ int (*StringToAddr) (const char *string, struct qsockaddr *addr);
int (*GetSocketAddr) (int socket, struct qsockaddr *addr);
int (*GetNameFromAddr) (struct qsockaddr *addr, char *name);
- int (*GetAddrFromName) (char *name, struct qsockaddr *addr);
+ int (*GetAddrFromName) (const char *name, struct qsockaddr *addr);
int (*AddrCompare) (struct qsockaddr *addr1, struct qsockaddr *addr2);
int (*GetSocketPort) (struct qsockaddr *addr);
int (*SetSocketPort) (struct qsockaddr *addr, int port);
{
char addrStr [32];
char maskStr [32];
- void (*print) (char *fmt, ...);
+ void (*print) (const char *fmt, ...);
if (cmd_source == src_command)
{
static void Test_f (void)
{
- char *host;
- int n;
- int max = MAX_SCOREBOARD;
+ const char *host;
+ int n, max = MAX_SCOREBOARD;
struct qsockaddr sendaddr;
if (testInProgress)
static void Test2_f (void)
{
- char *host;
- int n;
+ const char *host;
+ int n;
struct qsockaddr sendaddr;
if (test2InProgress)
the local network components to fill in the rest
============
*/
-static int PartialIPAddress (char *in, struct qsockaddr *hostaddr)
+static int PartialIPAddress (const char *in, struct qsockaddr *hostaddr)
{
char buff[256];
char *b;
//=============================================================================
-int UDP_StringToAddr (char *string, struct qsockaddr *addr)
+int UDP_StringToAddr (const char *string, struct qsockaddr *addr)
{
int ha1, ha2, ha3, ha4, hp;
int ipaddr;
//=============================================================================
-int UDP_GetAddrFromName(char *name, struct qsockaddr *addr)
+int UDP_GetAddrFromName(const char *name, struct qsockaddr *addr)
{
struct hostent *hostentry;
int UDP_Write (int socket, qbyte *buf, int len, struct qsockaddr *addr);
int UDP_Broadcast (int socket, qbyte *buf, int len);
char *UDP_AddrToString (struct qsockaddr *addr);
-int UDP_StringToAddr (char *string, struct qsockaddr *addr);
+int UDP_StringToAddr (const char *string, struct qsockaddr *addr);
int UDP_GetSocketAddr (int socket, struct qsockaddr *addr);
int UDP_GetNameFromAddr (struct qsockaddr *addr, char *name);
-int UDP_GetAddrFromName (char *name, struct qsockaddr *addr);
+int UDP_GetAddrFromName (const char *name, struct qsockaddr *addr);
int UDP_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2);
int UDP_GetSocketPort (struct qsockaddr *addr);
int UDP_SetSocketPort (struct qsockaddr *addr, int port);
int type_size[8] = {1,sizeof(string_t)/4,1,3,1,1,sizeof(func_t)/4,sizeof(void *)/4};
ddef_t *ED_FieldAtOfs (int ofs);
-qboolean ED_ParseEpair (void *base, ddef_t *key, char *s);
+qboolean ED_ParseEpair (void *base, ddef_t *key, const char *s);
cvar_t pr_checkextension = {0, "pr_checkextension", "1"};
cvar_t nomonsters = {0, "nomonsters", "0"};
static gefv_cache gefvCache[GEFV_CACHESIZE] = {{NULL, ""}, {NULL, ""}};
-ddef_t *ED_FindField (char *name);
-dfunction_t *ED_FindFunction (char *name);
+ddef_t *ED_FindField (const char *name);
+dfunction_t *ED_FindFunction (const char *name);
// LordHavoc: in an effort to eliminate time wasted on GetEdictFieldValue... these are defined as externs in progs.h
int eval_gravity;
dfunction_t *SV_PlayerPhysicsQC;
dfunction_t *EndFrameQC;
-int FindFieldOffset(char *field)
+int FindFieldOffset(const char *field)
{
ddef_t *d;
d = ED_FindField(field);
ED_FindField
============
*/
-ddef_t *ED_FindField (char *name)
+ddef_t *ED_FindField (const char *name)
{
- ddef_t *def;
- int i;
+ ddef_t *def;
+ int i;
for (i=0 ; i<progs->numfielddefs ; i++)
{
ED_FindGlobal
============
*/
-ddef_t *ED_FindGlobal (char *name)
+ddef_t *ED_FindGlobal (const char *name)
{
- ddef_t *def;
- int i;
-
+ ddef_t *def;
+ int i;
+
for (i=0 ; i<progs->numglobaldefs ; i++)
{
def = &pr_globaldefs[i];
ED_FindFunction
============
*/
-dfunction_t *ED_FindFunction (char *name)
+dfunction_t *ED_FindFunction (const char *name)
{
dfunction_t *func;
int i;
-
+
for (i=0 ; i<progs->numfunctions ; i++)
{
func = &pr_functions[i];
ED_ParseGlobals
=============
*/
-void ED_ParseGlobals (char *data)
+void ED_ParseGlobals (const char *data)
{
- char keyname[1024]; // LordHavoc: good idea? bad idea? was 64
- ddef_t *key;
+ char keyname[1024]; // LordHavoc: good idea? bad idea? was 64
+ ddef_t *key;
while (1)
{
- // parse key
- data = COM_Parse (data);
+ // parse key
+ if (!COM_ParseToken (&data))
+ Host_Error ("ED_ParseEntity: EOF without closing brace");
if (com_token[0] == '}')
break;
- if (!data)
- Host_Error ("ED_ParseEntity: EOF without closing brace");
strcpy (keyname, com_token);
- // parse value
- data = COM_Parse (data);
- if (!data)
+ // parse value
+ if (!COM_ParseToken (&data))
Host_Error ("ED_ParseEntity: EOF without closing brace");
if (com_token[0] == '}')
ED_NewString
=============
*/
-char *ED_NewString (char *string)
+char *ED_NewString (const char *string)
{
- char *new, *new_p;
- int i,l;
+ char *new, *new_p;
+ int i,l;
l = strlen(string) + 1;
new = Mem_Alloc(edictstring_mempool, l);
returns false if error
=============
*/
-qboolean ED_ParseEpair (void *base, ddef_t *key, char *s)
+qboolean ED_ParseEpair (void *base, ddef_t *key, const char *s)
{
int i;
char string[128];
Used for initial level load and for savegames.
====================
*/
-char *ED_ParseEdict (char *data, edict_t *ent)
+const char *ED_ParseEdict (const char *data, edict_t *ent)
{
- ddef_t *key;
- qboolean anglehack;
- qboolean init;
- char keyname[256];
- int n;
+ ddef_t *key;
+ qboolean anglehack;
+ qboolean init;
+ char keyname[256];
+ int n;
init = false;
while (1)
{
// parse key
- data = COM_Parse (data);
+ if (!COM_ParseToken (&data))
+ Host_Error ("ED_ParseEntity: EOF without closing brace");
if (com_token[0] == '}')
break;
- if (!data)
- Host_Error ("ED_ParseEntity: EOF without closing brace");
// anglehack is to allow QuakeEd to write single scalar angles
// and allow them to be turned into vectors. (FIXME...)
}
// parse value
- data = COM_Parse (data);
- if (!data)
+ if (!COM_ParseToken (&data))
Host_Error ("ED_ParseEntity: EOF without closing brace");
if (com_token[0] == '}')
to call ED_CallSpawnFunctions () to let the objects initialize themselves.
================
*/
-void ED_LoadFromFile (char *data)
-{
- edict_t *ent;
- int inhibit;
- dfunction_t *func;
+void ED_LoadFromFile (const char *data)
+{
+ edict_t *ent;
+ int inhibit;
+ dfunction_t *func;
ent = NULL;
inhibit = 0;
while (1)
{
// parse the opening brace
- data = COM_Parse (data);
- if (!data)
+ if (!COM_ParseToken (&data))
break;
if (com_token[0] != '{')
Host_Error ("ED_LoadFromFile: found %s when expecting {",com_token);
#define OPB ((eval_t *)&pr_globals[(unsigned short) st->b])
#define OPC ((eval_t *)&pr_globals[(unsigned short) st->c])
extern cvar_t pr_boundscheck;
-void PR_ExecuteProgram (func_t fnum, char *errormessage)
+void PR_ExecuteProgram (func_t fnum, const char *errormessage)
{
dstatement_t *st;
dfunction_t *f, *newf;
void PR_Init (void);
-void PR_ExecuteProgram (func_t fnum, char *errormessage);
+void PR_ExecuteProgram (func_t fnum, const char *errormessage);
void PR_LoadProgs (void);
void PR_Profile_f (void);
edict_t *ED_Alloc (void);
void ED_Free (edict_t *ed);
-char *ED_NewString (char *string);
+char *ED_NewString (const char *string);
// returns a copy of the string allocated from the server's string heap
void ED_Print (edict_t *ed);
void ED_Write (QFile *f, edict_t *ed);
-char *ED_ParseEdict (char *data, edict_t *ent);
+const char *ED_ParseEdict (const char *data, edict_t *ent);
void ED_WriteGlobals (QFile *f);
-void ED_ParseGlobals (char *data);
+void ED_ParseGlobals (const char *data);
-void ED_LoadFromFile (char *data);
+void ED_LoadFromFile (const char *data);
edict_t *EDICT_NUM_ERROR(int n);
#define EDICT_NUM(n) (n >= 0 ? (n < sv.max_edicts ? (edict_t *)((qbyte *)sv.edicts + (n) * pr_edict_size) : EDICT_NUM_ERROR(n)) : EDICT_NUM_ERROR(n))
//
// host
//
-extern cvar_t sys_ticrate;
-extern cvar_t developer;
-
-extern qboolean host_initialized; // true if into command execution
-extern double host_frametime;
-extern double host_realframetime; // LordHavoc: the real frametime, before slowmo and clamping are applied (used for console scrolling)
-extern int host_framecount; // incremented every frame, never reset
-extern double realtime; // not bounded in any way, changed at
- // start of every frame, never reset
+extern cvar_t sys_ticrate;
+extern cvar_t developer;
+
+// true if into command execution
+extern qboolean host_initialized;
+extern double host_frametime;
+// LordHavoc: the real frametime, before slowmo and clamping are applied (used for console scrolling)
+extern double host_realframetime;
+// incremented every frame, never reset
+extern int host_framecount;
+// not bounded in any way, changed at start of every frame, never reset
+extern double realtime;
void Host_ClearMemory (void);
void Host_ServerFrame (void);
void Host_InitCommands (void);
void Host_Init (void);
void Host_Shutdown(void);
-void Host_Error (char *error, ...);
-void Host_EndGame (char *message, ...);
+void Host_Error (const char *error, ...);
+void Host_EndGame (const char *message, ...);
void Host_Frame (float time);
void Host_Quit_f (void);
-void Host_ClientCommands (char *fmt, ...);
+void Host_ClientCommands (const char *fmt, ...);
void Host_ShutdownServer (qboolean crash);
-extern qboolean msg_suppress_1; // suppresses resolution and cache size console output
- // an fullscreen DIB focus gain/loss
-extern int current_skill; // skill level for currently loaded level (in case
- // the user changes the cvar while the level is
- // running, this reflects the level actually in use)
+// suppresses resolution and cache size console output and fullscreen DIB focus gain/loss
+extern qboolean msg_suppress_1;
+// skill level for currently loaded level (in case the user changes the cvar while the level is running, this reflects the level actually in use)
+extern int current_skill;
-extern int minimum_memory;
+extern int minimum_memory;
//
// chase
//
-extern cvar_t chase_active;
+extern cvar_t chase_active;
void Chase_Init (void);
void Chase_Reset (void);
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
typedef struct
{
- int maxclients;
- struct client_s *clients; // [maxclients]
- int serverflags; // episode completion information
- qboolean changelevel_issued; // cleared when at SV_SpawnServer
+ int maxclients;
+ // [maxclients]
+ struct client_s *clients;
+ // episode completion information
+ int serverflags;
+ // cleared when at SV_SpawnServer
+ qboolean changelevel_issued;
} server_static_t;
//=============================================================================
typedef struct
{
- qboolean active; // false if only a net client
-
- qboolean paused;
- qboolean loadgame; // handle connections specially
-
- double time;
-
- double frametime;
-
- int lastcheck; // used by PF_checkclient
- double lastchecktime;
-
- char name[64]; // map name
- char modelname[64]; // maps/<name>.bsp, for model_precache[0]
- struct model_s *worldmodel;
- char *model_precache[MAX_MODELS]; // NULL terminated
- struct model_s *models[MAX_MODELS];
- char *sound_precache[MAX_SOUNDS]; // NULL terminated
- char *lightstyles[MAX_LIGHTSTYLES];
- int num_edicts;
- int max_edicts;
- edict_t *edicts; // can NOT be array indexed, because
- // edict_t is variable sized, but can
- // be used to reference the world ent
- server_state_t state; // some actions are only valid during load
-
- sizebuf_t datagram;
- qbyte datagram_buf[MAX_DATAGRAM];
-
- sizebuf_t reliable_datagram; // copied to all clients at end of frame
- qbyte reliable_datagram_buf[MAX_DATAGRAM];
-
- sizebuf_t signon;
- qbyte signon_buf[32768]; // LordHavoc: increased signon message buffer from 8192 to 32768
+ // false if only a net client
+ qboolean active;
+
+ qboolean paused;
+ // handle connections specially
+ qboolean loadgame;
+
+ double time;
+
+ double frametime;
+
+ // used by PF_checkclient
+ int lastcheck;
+ double lastchecktime;
+
+ // map name
+ char name[64];
+ // maps/<name>.bsp, for model_precache[0]
+ char modelname[64];
+ struct model_s *worldmodel;
+ // NULL terminated
+ char *model_precache[MAX_MODELS];
+ struct model_s *models[MAX_MODELS];
+ // NULL terminated
+ char *sound_precache[MAX_SOUNDS];
+ char *lightstyles[MAX_LIGHTSTYLES];
+ int num_edicts;
+ int max_edicts;
+ // can NOT be array indexed, because edict_t is variable sized, but can be used to reference the world ent
+ edict_t *edicts;
+ // some actions are only valid during load
+ server_state_t state;
+
+ sizebuf_t datagram;
+ qbyte datagram_buf[MAX_DATAGRAM];
+
+ // copied to all clients at end of frame
+ sizebuf_t reliable_datagram;
+ qbyte reliable_datagram_buf[MAX_DATAGRAM];
+
+ sizebuf_t signon;
+ // LordHavoc: increased signon message buffer from 8192 to 32768
+ qbyte signon_buf[32768];
} server_t;
-#define NUM_PING_TIMES 16
-#define NUM_SPAWN_PARMS 16
+#define NUM_PING_TIMES 16
+#define NUM_SPAWN_PARMS 16
typedef struct client_s
{
- qboolean active; // false = client is free
- qboolean spawned; // false = don't send datagrams
- qboolean dropasap; // has been told to go to another level
- qboolean sendsignon; // only valid before spawned
+ // false = client is free
+ qboolean active;
+ // false = don't send datagrams
+ qboolean spawned;
+ // has been told to go to another level
+ qboolean dropasap;
+ // only valid before spawned
+ qboolean sendsignon;
#ifndef NOROUTINGFIX
// LordHavoc: to make netquake protocol get through NAT routers, have to wait for client to ack
- qboolean waitingforconnect; // waiting for connect from client (stage 1)
- qboolean sendserverinfo; // send server info in next datagram (stage 2)
+ // waiting for connect from client (stage 1)
+ qboolean waitingforconnect;
+ // send server info in next datagram (stage 2)
+ qboolean sendserverinfo;
#endif
- double last_message; // reliable messages must be sent
- // periodically
-
- struct qsocket_s *netconnection; // communications handle
-
- usercmd_t cmd; // movement
- vec3_t wishdir; // intended motion calced from cmd
-
- sizebuf_t message; // can be added to at any time,
- // copied and clear once per frame
- qbyte msgbuf[MAX_MSGLEN];
- edict_t *edict; // EDICT_NUM(clientnum+1)
- char name[32]; // for printing to other people
- int colors;
-
- float ping_times[NUM_PING_TIMES];
- int num_pings; // ping_times[num_pings%NUM_PING_TIMES]
- float ping; // LordHavoc: can be used for prediction or whatever...
- float latency; // LordHavoc: specifically used for prediction, accounts for sys_ticrate too
+ // reliable messages must be sent periodically
+ double last_message;
+
+ // communications handle
+ struct qsocket_s *netconnection;
+
+ // movement
+ usercmd_t cmd;
+ // intended motion calced from cmd
+ vec3_t wishdir;
+
+ // can be added to at any time, copied and clear once per frame
+ sizebuf_t message;
+ qbyte msgbuf[MAX_MSGLEN];
+ // EDICT_NUM(clientnum+1)
+ edict_t *edict;
+ // for printing to other people
+ char name[32];
+ int colors;
+
+ float ping_times[NUM_PING_TIMES];
+ // ping_times[num_pings%NUM_PING_TIMES]
+ int num_pings;
+ // LordHavoc: can be used for prediction or whatever...
+ float ping;
+ // LordHavoc: specifically used for prediction, accounts for sys_ticrate too
+ float latency;
// spawn parms are carried from level to level
- float spawn_parms[NUM_SPAWN_PARMS];
+ float spawn_parms[NUM_SPAWN_PARMS];
// client known data for deltas
- int old_frags;
- int pmodel;
+ int old_frags;
+ int pmodel;
#ifdef QUAKEENTITIES
// delta compression state
- float nextfullupdate[MAX_EDICTS];
+ float nextfullupdate[MAX_EDICTS];
#endif
// visibility state
- float visibletime[MAX_EDICTS];
+ float visibletime[MAX_EDICTS];
#ifndef QUAKEENTITIES
entity_database_t entitydatabase;
- int entityframenumber; // incremented each time an entity frame is sent
+ int entityframenumber; // incremented each time an entity frame is sent
#endif
} client_t;
extern cvar_t sv_stepheight;
extern cvar_t sv_jumpstep;
-extern server_static_t svs; // persistant server info
-extern server_t sv; // local server
+// persistant server info
+extern server_static_t svs;
+// local server
+extern server_t sv;
extern client_t *host_client;
void SV_SendClientMessages (void);
void SV_ClearDatagram (void);
-int SV_ModelIndex (char *name);
+int SV_ModelIndex (const char *name);
void SV_SetIdealPitch (void);
void SV_ClientThink (void);
void SV_AddClientToServer (struct qsocket_s *ret);
-void SV_ClientPrintf (char *fmt, ...);
-void SV_BroadcastPrintf (char *fmt, ...);
+void SV_ClientPrintf (const char *fmt, ...);
+void SV_BroadcastPrintf (const char *fmt, ...);
void SV_Physics (void);
void SV_CheckForNewClients (void);
void SV_RunClients (void);
void SV_SaveSpawnparms (void);
-void SV_SpawnServer (char *server);
+void SV_SpawnServer (const char *server);
void SV_SetMaxClients(int n);
================
*/
-int SV_ModelIndex (char *name)
+int SV_ModelIndex (const char *name)
{
- int i;
+ int i;
if (!name || !name[0])
return 0;
*/
extern float scr_centertime_off;
-void SV_SpawnServer (char *server)
+void SV_SpawnServer (const char *server)
{
edict_t *ent;
int i;
usleep(1);
}
-int main (int argc, char **argv)
+int main (int argc, const char **argv)
{
double frameoldtime, framenewtime;
mempool_t *poolchain = NULL;
-void *_Mem_Alloc(mempool_t *pool, int size, char *filename, int fileline)
+void *_Mem_Alloc(mempool_t *pool, int size, const char *filename, int fileline)
{
#if MEMCLUMPING
int i, j, k, needed, endbit, largest;
return (void *)((qbyte *) mem + sizeof(memheader_t));
}
-void _Mem_Free(void *data, char *filename, int fileline)
+void _Mem_Free(void *data, const char *filename, int fileline)
{
#if MEMCLUMPING
int i, firstblock, endblock;
#endif
}
-mempool_t *_Mem_AllocPool(char *name, char *filename, int fileline)
+mempool_t *_Mem_AllocPool(const char *name, const char *filename, int fileline)
{
mempool_t *pool;
pool = malloc(sizeof(mempool_t));
return pool;
}
-void _Mem_FreePool(mempool_t **pool, char *filename, int fileline)
+void _Mem_FreePool(mempool_t **pool, const char *filename, int fileline)
{
mempool_t **chainaddress;
if (*pool)
}
}
-void _Mem_EmptyPool(mempool_t *pool, char *filename, int fileline)
+void _Mem_EmptyPool(mempool_t *pool, const char *filename, int fileline)
{
if (pool == NULL)
Sys_Error("Mem_EmptyPool: pool == NULL (emptypool at %s:%i)", filename, fileline);
Mem_Free((void *)((qbyte *) pool->chain + sizeof(memheader_t)));
}
-void _Mem_CheckSentinels(void *data, char *filename, int fileline)
+void _Mem_CheckSentinels(void *data, const char *filename, int fileline)
{
memheader_t *mem;
}
#if MEMCLUMPING
-static void _Mem_CheckClumpSentinels(memclump_t *clump, char *filename, int fileline)
+static void _Mem_CheckClumpSentinels(memclump_t *clump, const char *filename, int fileline)
{
// this isn't really very useful
if (clump->sentinel1 != MEMCLUMP_SENTINEL)
}
#endif
-void _Mem_CheckSentinelsGlobal(char *filename, int fileline)
+void _Mem_CheckSentinelsGlobal(const char *filename, int fileline)
{
memheader_t *mem;
#if MEMCLUMPING
// size of the memory after the header (excluding header and sentinel2)
int size;
// file name and line where Mem_Alloc was called
- char *filename;
+ const char *filename;
int fileline;
// should always be MEMHEADER_SENTINEL1
int sentinel1;
// linked into global mempool list
struct mempool_s *next;
// file name and line where Mem_AllocPool was called
- char *filename;
+ const char *filename;
int fileline;
// should always be MEMHEADER_SENTINEL1
int sentinel2;
#define Mem_FreePool(pool) _Mem_FreePool(pool, __FILE__, __LINE__)
#define Mem_EmptyPool(pool) _Mem_EmptyPool(pool, __FILE__, __LINE__)
-void *_Mem_Alloc(mempool_t *pool, int size, char *filename, int fileline);
-void _Mem_Free(void *data, char *filename, int fileline);
-mempool_t *_Mem_AllocPool(char *name, char *filename, int fileline);
-void _Mem_FreePool(mempool_t **pool, char *filename, int fileline);
-void _Mem_EmptyPool(mempool_t *pool, char *filename, int fileline);
-void _Mem_CheckSentinels(void *data, char *filename, int fileline);
-void _Mem_CheckSentinelsGlobal(char *filename, int fileline);
+void *_Mem_Alloc(mempool_t *pool, int size, const char *filename, int fileline);
+void _Mem_Free(void *data, const char *filename, int fileline);
+mempool_t *_Mem_AllocPool(const char *name, const char *filename, int fileline);
+void _Mem_FreePool(mempool_t **pool, const char *filename, int fileline);
+void _Mem_EmptyPool(mempool_t *pool, const char *filename, int fileline);
+void _Mem_CheckSentinels(void *data, const char *filename, int fileline);
+void _Mem_CheckSentinelsGlobal(const char *filename, int fileline);
// used for temporary allocations
mempool_t *tempmempool;