From 338da9a4c8d31e755254fd51d12f3eb788e98eeb Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Wed, 28 Dec 2011 23:40:27 +0000 Subject: [PATCH] dropped CVAR_SERVERINFO flag from the cmdline cvar: sending cmdline upon CCREQ_RULE_INFO is evil... while I was there, did some whitespace clean-up in common.c. git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@568 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/common.c | 329 ++++++++++++++++++++++++------------------------- 1 file changed, 164 insertions(+), 165 deletions(-) diff --git a/Quake/common.c b/Quake/common.c index 0fe16083..5a8e20c2 100644 --- a/Quake/common.c +++ b/Quake/common.c @@ -23,17 +23,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "quakedef.h" #include -static char *largv[MAX_NUM_ARGVS + 1]; -static char argvdummy[] = " "; +static char *largv[MAX_NUM_ARGVS + 1]; +static char argvdummy[] = " "; -int safemode; +int safemode; -cvar_t registered = {"registered","0",CVAR_ROM}; -cvar_t cmdline = {"cmdline","",CVAR_ROM|CVAR_SERVERINFO}; /* sending cmdline upon CCREQ_RULE_INFO is evil... */ +cvar_t registered = {"registered","0",CVAR_ROM}; +cvar_t cmdline = {"cmdline","",CVAR_ROM/*|CVAR_SERVERINFO*/}; /* sending cmdline upon CCREQ_RULE_INFO is evil */ -qboolean com_modified; // set true if using non-id files +qboolean com_modified; // set true if using non-id files -int com_nummissionpacks; //johnfitz +int com_nummissionpacks; //johnfitz qboolean fitzmode; @@ -47,35 +47,34 @@ char com_token[1024]; int com_argc; char **com_argv; -#define CMDLINE_LENGTH 256 //johnfitz -- mirrored in cmd.c +#define CMDLINE_LENGTH 256 /* johnfitz -- mirrored in cmd.c */ char com_cmdline[CMDLINE_LENGTH]; qboolean standard_quake = true, rogue, hipnotic; // this graphic needs to be in the pak file to use registered features -unsigned short pop[] = +static unsigned short pop[] = { - 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 -,0x0000,0x0000,0x6600,0x0000,0x0000,0x0000,0x6600,0x0000 -,0x0000,0x0066,0x0000,0x0000,0x0000,0x0000,0x0067,0x0000 -,0x0000,0x6665,0x0000,0x0000,0x0000,0x0000,0x0065,0x6600 -,0x0063,0x6561,0x0000,0x0000,0x0000,0x0000,0x0061,0x6563 -,0x0064,0x6561,0x0000,0x0000,0x0000,0x0000,0x0061,0x6564 -,0x0064,0x6564,0x0000,0x6469,0x6969,0x6400,0x0064,0x6564 -,0x0063,0x6568,0x6200,0x0064,0x6864,0x0000,0x6268,0x6563 -,0x0000,0x6567,0x6963,0x0064,0x6764,0x0063,0x6967,0x6500 -,0x0000,0x6266,0x6769,0x6a68,0x6768,0x6a69,0x6766,0x6200 -,0x0000,0x0062,0x6566,0x6666,0x6666,0x6666,0x6562,0x0000 -,0x0000,0x0000,0x0062,0x6364,0x6664,0x6362,0x0000,0x0000 -,0x0000,0x0000,0x0000,0x0062,0x6662,0x0000,0x0000,0x0000 -,0x0000,0x0000,0x0000,0x0061,0x6661,0x0000,0x0000,0x0000 -,0x0000,0x0000,0x0000,0x0000,0x6500,0x0000,0x0000,0x0000 -,0x0000,0x0000,0x0000,0x0000,0x6400,0x0000,0x0000,0x0000 + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x6600,0x0000,0x0000,0x0000,0x6600,0x0000, + 0x0000,0x0066,0x0000,0x0000,0x0000,0x0000,0x0067,0x0000, + 0x0000,0x6665,0x0000,0x0000,0x0000,0x0000,0x0065,0x6600, + 0x0063,0x6561,0x0000,0x0000,0x0000,0x0000,0x0061,0x6563, + 0x0064,0x6561,0x0000,0x0000,0x0000,0x0000,0x0061,0x6564, + 0x0064,0x6564,0x0000,0x6469,0x6969,0x6400,0x0064,0x6564, + 0x0063,0x6568,0x6200,0x0064,0x6864,0x0000,0x6268,0x6563, + 0x0000,0x6567,0x6963,0x0064,0x6764,0x0063,0x6967,0x6500, + 0x0000,0x6266,0x6769,0x6a68,0x6768,0x6a69,0x6766,0x6200, + 0x0000,0x0062,0x6566,0x6666,0x6666,0x6666,0x6562,0x0000, + 0x0000,0x0000,0x0062,0x6364,0x6664,0x6362,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0062,0x6662,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0061,0x6661,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x6500,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x6400,0x0000,0x0000,0x0000 }; /* - All of Quake's data access is through a hierchal file system, but the contents of the file system can be transparently merged from several sources. @@ -180,11 +179,11 @@ void Q_memset (void *dest, int fill, size_t count) { count >>= 2; fill = fill | (fill<<8) | (fill<<16) | (fill<<24); - for (i=0 ; i>=2; - for (i=0 ; i>= 2; + for (i = 0; i < count; i++) ((int *)dest)[i] = ((int *)src)[i]; } else - for (i=0 ; i>8)&255; @@ -488,14 +490,14 @@ short ShortSwap (short l) return (b1<<8) + b2; } -short ShortNoSwap (short l) +short ShortNoSwap (short l) { return l; } -int LongSwap (int l) +int LongSwap (int l) { - byte b1,b2,b3,b4; + byte b1, b2, b3, b4; b1 = l&255; b2 = (l>>8)&255; @@ -505,7 +507,7 @@ int LongSwap (int l) return ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4; } -int LongNoSwap (int l) +int LongNoSwap (int l) { return l; } @@ -514,8 +516,8 @@ float FloatSwap (float f) { union { - float f; - byte b[4]; + float f; + byte b[4]; } dat1, dat2; @@ -547,7 +549,7 @@ Handles byte ordering and avoids alignment errors void MSG_WriteChar (sizebuf_t *sb, int c) { - byte *buf; + byte *buf; #ifdef PARANOID if (c < -128 || c > 127) @@ -560,7 +562,7 @@ void MSG_WriteChar (sizebuf_t *sb, int c) void MSG_WriteByte (sizebuf_t *sb, int c) { - byte *buf; + byte *buf; #ifdef PARANOID if (c < 0 || c > 255) @@ -573,7 +575,7 @@ void MSG_WriteByte (sizebuf_t *sb, int c) void MSG_WriteShort (sizebuf_t *sb, int c) { - byte *buf; + byte *buf; #ifdef PARANOID if (c < ((short)0x8000) || c > (short)0x7fff) @@ -587,7 +589,7 @@ void MSG_WriteShort (sizebuf_t *sb, int c) void MSG_WriteLong (sizebuf_t *sb, int c) { - byte *buf; + byte *buf; buf = (byte *) SZ_GetSpace (sb, 4); buf[0] = c&0xff; @@ -600,11 +602,10 @@ void MSG_WriteFloat (sizebuf_t *sb, float f) { union { - float f; - int l; + float f; + int l; } dat; - dat.f = f; dat.l = LittleLong (dat.l); @@ -658,8 +659,8 @@ void MSG_WriteAngle16 (sizebuf_t *sb, float f) // // reading functions // -int msg_readcount; -qboolean msg_badread; +int msg_readcount; +qboolean msg_badread; void MSG_BeginReading (void) { @@ -670,7 +671,7 @@ void MSG_BeginReading (void) // returns -1 and sets msg_badread if no more characters are available int MSG_ReadChar (void) { - int c; + int c; if (msg_readcount+1 > net_message.cursize) { @@ -686,7 +687,7 @@ int MSG_ReadChar (void) int MSG_ReadByte (void) { - int c; + int c; if (msg_readcount+1 > net_message.cursize) { @@ -702,7 +703,7 @@ int MSG_ReadByte (void) int MSG_ReadShort (void) { - int c; + int c; if (msg_readcount+2 > net_message.cursize) { @@ -720,7 +721,7 @@ int MSG_ReadShort (void) int MSG_ReadLong (void) { - int c; + int c; if (msg_readcount+4 > net_message.cursize) { @@ -742,15 +743,15 @@ float MSG_ReadFloat (void) { union { - byte b[4]; - float f; - int l; + byte b[4]; + float f; + int l; } dat; - dat.b[0] = net_message.data[msg_readcount]; - dat.b[1] = net_message.data[msg_readcount+1]; - dat.b[2] = net_message.data[msg_readcount+2]; - dat.b[3] = net_message.data[msg_readcount+3]; + dat.b[0] = net_message.data[msg_readcount]; + dat.b[1] = net_message.data[msg_readcount+1]; + dat.b[2] = net_message.data[msg_readcount+2]; + dat.b[3] = net_message.data[msg_readcount+3]; msg_readcount += 4; dat.l = LittleLong (dat.l); @@ -760,8 +761,8 @@ float MSG_ReadFloat (void) const char *MSG_ReadString (void) { - static char string[2048]; - int l,c; + static char string[2048]; + int l, c; l = 0; do @@ -814,7 +815,6 @@ float MSG_ReadAngle16 (void) //johnfitz - //=========================================================================== void SZ_Alloc (sizebuf_t *buf, int startsize) @@ -829,9 +829,9 @@ void SZ_Alloc (sizebuf_t *buf, int startsize) void SZ_Free (sizebuf_t *buf) { -// Z_Free (buf->data); -// buf->data = NULL; -// buf->maxsize = 0; +// Z_Free (buf->data); +// buf->data = NULL; +// buf->maxsize = 0; buf->cursize = 0; } @@ -842,7 +842,7 @@ void SZ_Clear (sizebuf_t *buf) void *SZ_GetSpace (sizebuf_t *buf, int length) { - void *data; + void *data; if (buf->cursize + length > buf->maxsize) { @@ -870,9 +870,9 @@ void SZ_Write (sizebuf_t *buf, const void *data, int length) void SZ_Print (sizebuf_t *buf, const char *data) { - int len; + int len; - len = Q_strlen(data)+1; + len = Q_strlen(data) + 1; // byte * cast to keep VC++ happy if (buf->data[buf->cursize-1]) @@ -1043,8 +1043,8 @@ Parse a token out of a string */ const char *COM_Parse (const char *data) { - int c; - int len; + int c; + int len; len = 0; com_token[0] = 0; @@ -1057,7 +1057,7 @@ skipwhite: while ( (c = *data) <= ' ') { if (c == 0) - return NULL; // end of file; + return NULL; // end of file; data++; } @@ -1104,9 +1104,9 @@ skipwhite: len++; c = *data; /* commented out the check for ':' so that ip:port works */ - if (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' /* || c==':' */) + if (c == '{' || c == '}'|| c == ')'|| c == '(' || c == '\'' /* || c == ':' */) break; - } while (c>32); + } while (c > 32); com_token[len] = 0; return data; @@ -1123,12 +1123,12 @@ where the given parameter apears, or 0 if not present */ int COM_CheckParm (const char *parm) { - int i; + int i; - for (i=1 ; i/game1 and // /game1 have the same id. - char filename[MAX_OSPATH]; - pack_t *pack; // only one of filename / pack will be used - struct searchpath_s *next; + char filename[MAX_OSPATH]; + pack_t *pack; // only one of filename / pack will be used + struct searchpath_s *next; } searchpath_t; -searchpath_t *com_searchpaths; +searchpath_t *com_searchpaths; /* ============ @@ -1424,10 +1424,10 @@ COM_Path_f */ 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) + for (s = com_searchpaths; s; s = s->next) { if (s->pack) { @@ -1447,8 +1447,8 @@ The filename will be prefixed by the current game directory */ void COM_WriteFile (const char *filename, const void *data, int len) { - int handle; - char name[MAX_OSPATH]; + int handle; + char name[MAX_OSPATH]; Sys_mkdir (com_gamedir); //johnfitz -- if we've switched to a nonexistant gamedir, create it now so we don't crash @@ -1471,14 +1471,14 @@ void COM_WriteFile (const char *filename, const void *data, int len) COM_CreatePath ============ */ -void COM_CreatePath (char *path) +void COM_CreatePath (char *path) { - char *ofs; + char *ofs; - for (ofs = path+1 ; *ofs ; ofs++) + for (ofs = path + 1; *ofs; ofs++) { if (*ofs == '/') - { // create the directory + { // create the directory *ofs = 0; Sys_mkdir (path); *ofs = '/'; @@ -1516,11 +1516,10 @@ can be used for detecting a file's presence. static int COM_FindFile (const char *filename, int *handle, FILE **file, unsigned int *path_id) { - 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; if (file && handle) Sys_Error ("COM_FindFile: both handle and file set"); @@ -1535,7 +1534,7 @@ static int COM_FindFile (const char *filename, int *handle, FILE **file, if (search->pack) /* look through all the pak file elements */ { pak = search->pack; - for (i=0 ; inumfiles ; i++) + for (i = 0; i < pak->numfiles; i++) { if (strcmp(pak->files[i].name, filename) != 0) continue; @@ -1658,9 +1657,9 @@ If it is a pak file handle, don't really close it */ void COM_CloseFile (int h) { - searchpath_t *s; + searchpath_t *s; - for (s = com_searchpaths ; s ; s=s->next) + for (s = com_searchpaths; s; s = s->next) if (s->pack && s->pack->handle == h) return; @@ -1689,12 +1688,12 @@ static int loadsize; byte *COM_LoadFile (const char *path, int usehunk, unsigned int *path_id) { - int h; - byte *buf; - char base[32]; - int len; + int h; + byte *buf; + char base[32]; + int len; - buf = NULL; // quiet compiler warning + buf = NULL; // quiet compiler warning // look for it in the filesystem or pack files len = COM_OpenFile (path, &h, path_id); @@ -1766,7 +1765,7 @@ void COM_LoadCacheFile (const char *path, struct cache_user_s *cu, unsigned int // uses temp hunk if larger than bufsize byte *COM_LoadStackFile (const char *path, void *buffer, int bufsize, unsigned int *path_id) { - byte *buf; + byte *buf; loadbuf = (byte *)buffer; loadsize = bufsize; @@ -1794,14 +1793,14 @@ of the list so they override previous pack files. */ pack_t *COM_LoadPackFile (const char *packfile) { - dpackheader_t header; - int i; - packfile_t *newfiles; - int numpackfiles; - pack_t *pack; - int packhandle; - dpackfile_t info[MAX_FILES_IN_PACK]; - unsigned short crc; + dpackheader_t header; + int i; + packfile_t *newfiles; + int numpackfiles; + pack_t *pack; + int packhandle; + dpackfile_t info[MAX_FILES_IN_PACK]; + unsigned short crc; if (Sys_FileOpenRead (packfile, &packhandle) == -1) return NULL; @@ -1817,7 +1816,7 @@ pack_t *COM_LoadPackFile (const char *packfile) Sys_Error ("%s has %i files", packfile, numpackfiles); if (numpackfiles != PAK0_COUNT) - com_modified = true; // not the original file + com_modified = true; // not the original file //johnfitz -- dynamic gamedir loading //Hunk_AllocName (numpackfiles * sizeof(packfile_t), "packfile"); @@ -1829,13 +1828,13 @@ pack_t *COM_LoadPackFile (const char *packfile) // crc the directory to check for modifications CRC_Init (&crc); - for (i = 0; i < header.dirlen ; i++) + for (i = 0; i < header.dirlen; i++) CRC_ProcessByte (&crc, ((byte *)info)[i]); if (crc != PAK0_CRC) com_modified = true; // parse the directory - for (i = 0; i < numpackfiles ; i++) + for (i = 0; i < numpackfiles; i++) { q_strlcpy (newfiles[i].name, info[i].name, sizeof(newfiles[i].name)); newfiles[i].filepos = LittleLong(info[i].filepos);