mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 07:21:58 +00:00
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: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@568 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
3d4901410c
commit
175a348297
1 changed files with 164 additions and 165 deletions
329
Quake/common.c
329
Quake/common.c
|
@ -23,17 +23,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "quakedef.h"
|
||||
#include <errno.h>
|
||||
|
||||
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<count ; i++)
|
||||
for (i = 0; i < count; i++)
|
||||
((int *)dest)[i] = fill;
|
||||
}
|
||||
else
|
||||
for (i=0 ; i<count ; i++)
|
||||
for (i = 0; i < count; i++)
|
||||
((byte *)dest)[i] = fill;
|
||||
}
|
||||
|
||||
|
@ -194,12 +193,12 @@ void Q_memcpy (void *dest, const void *src, size_t count)
|
|||
|
||||
if (( ( (size_t)dest | (size_t)src | count) & 3) == 0 )
|
||||
{
|
||||
count>>=2;
|
||||
for (i=0 ; i<count ; i++)
|
||||
count >>= 2;
|
||||
for (i = 0; i < count; i++)
|
||||
((int *)dest)[i] = ((int *)src)[i];
|
||||
}
|
||||
else
|
||||
for (i=0 ; i<count ; i++)
|
||||
for (i = 0; i < count; i++)
|
||||
((byte *)dest)[i] = ((byte *)src)[i];
|
||||
}
|
||||
|
||||
|
@ -235,7 +234,7 @@ void Q_strncpy (char *dest, const char *src, int count)
|
|||
|
||||
int Q_strlen (const char *str)
|
||||
{
|
||||
int count;
|
||||
int count;
|
||||
|
||||
count = 0;
|
||||
while (str[count])
|
||||
|
@ -246,11 +245,14 @@ int Q_strlen (const char *str)
|
|||
|
||||
char *Q_strrchr(const char *s, char c)
|
||||
{
|
||||
int len = Q_strlen(s);
|
||||
s += len;
|
||||
while (len--)
|
||||
if (*--s == c) return (char *)s;
|
||||
return NULL;
|
||||
int len = Q_strlen(s);
|
||||
s += len;
|
||||
while (len--)
|
||||
{
|
||||
if (*--s == c)
|
||||
return (char *)s;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Q_strcat (char *dest, const char *src)
|
||||
|
@ -264,9 +266,9 @@ int Q_strcmp (const char *s1, const char *s2)
|
|||
while (1)
|
||||
{
|
||||
if (*s1 != *s2)
|
||||
return -1; // strings not equal
|
||||
return -1; // strings not equal
|
||||
if (!*s1)
|
||||
return 0; // strings are equal
|
||||
return 0; // strings are equal
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
|
@ -281,9 +283,9 @@ int Q_strncmp (const char *s1, const char *s2, int count)
|
|||
if (!count--)
|
||||
return 0;
|
||||
if (*s1 != *s2)
|
||||
return -1; // strings not equal
|
||||
return -1; // strings not equal
|
||||
if (!*s1)
|
||||
return 0; // strings are equal
|
||||
return 0; // strings are equal
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
|
@ -293,7 +295,7 @@ int Q_strncmp (const char *s1, const char *s2, int count)
|
|||
|
||||
int Q_strncasecmp (const char *s1, const char *s2, int n)
|
||||
{
|
||||
int c1, c2;
|
||||
int c1, c2;
|
||||
|
||||
if (s1 == s2 || n <= 0)
|
||||
return 0;
|
||||
|
@ -304,7 +306,7 @@ int Q_strncasecmp (const char *s1, const char *s2, int n)
|
|||
c2 = *s2++;
|
||||
|
||||
if (!n--)
|
||||
return 0; // strings are equal until end point
|
||||
return 0; // strings are equal until end point
|
||||
|
||||
if (c1 != c2)
|
||||
{
|
||||
|
@ -329,9 +331,9 @@ int Q_strcasecmp (const char *s1, const char *s2)
|
|||
|
||||
int Q_atoi (const char *str)
|
||||
{
|
||||
int val;
|
||||
int sign;
|
||||
int c;
|
||||
int val;
|
||||
int sign;
|
||||
int c;
|
||||
|
||||
if (*str == '-')
|
||||
{
|
||||
|
@ -388,10 +390,10 @@ int Q_atoi (const char *str)
|
|||
|
||||
float Q_atof (const char *str)
|
||||
{
|
||||
double val;
|
||||
int sign;
|
||||
int c;
|
||||
int decimal, total;
|
||||
double val;
|
||||
int sign;
|
||||
int c;
|
||||
int decimal, total;
|
||||
|
||||
if (*str == '-')
|
||||
{
|
||||
|
@ -471,16 +473,16 @@ float Q_atof (const char *str)
|
|||
|
||||
qboolean host_bigendian;
|
||||
|
||||
short (*BigShort) (short l);
|
||||
short (*LittleShort) (short l);
|
||||
int (*BigLong) (int l);
|
||||
int (*LittleLong) (int l);
|
||||
float (*BigFloat) (float l);
|
||||
float (*LittleFloat) (float l);
|
||||
short (*BigShort) (short l);
|
||||
short (*LittleShort) (short l);
|
||||
int (*BigLong) (int l);
|
||||
int (*LittleLong) (int l);
|
||||
float (*BigFloat) (float l);
|
||||
float (*LittleFloat) (float l);
|
||||
|
||||
short ShortSwap (short l)
|
||||
short ShortSwap (short l)
|
||||
{
|
||||
byte b1,b2;
|
||||
byte b1, b2;
|
||||
|
||||
b1 = l&255;
|
||||
b2 = (l>>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<com_argc ; i++)
|
||||
for (i = 1; i < com_argc; i++)
|
||||
{
|
||||
if (!com_argv[i])
|
||||
continue; // NEXTSTEP sometimes clears appkit vars.
|
||||
continue; // NEXTSTEP sometimes clears appkit vars.
|
||||
if (!Q_strcmp (parm,com_argv[i]))
|
||||
return i;
|
||||
}
|
||||
|
@ -1148,16 +1148,16 @@ being registered.
|
|||
*/
|
||||
void COM_CheckRegistered (void)
|
||||
{
|
||||
int h;
|
||||
unsigned short check[128];
|
||||
int i;
|
||||
int h;
|
||||
unsigned short check[128];
|
||||
int i;
|
||||
|
||||
COM_OpenFile("gfx/pop.lmp", &h, NULL);
|
||||
|
||||
if (h == -1)
|
||||
{
|
||||
#if WINDED
|
||||
Sys_Error ("This dedicated server requires a full registered copy of Quake");
|
||||
Sys_Error ("This dedicated server requires a full registered copy of Quake");
|
||||
#endif
|
||||
Con_Printf ("Playing shareware version.\n");
|
||||
if (com_modified)
|
||||
|
@ -1168,7 +1168,7 @@ void COM_CheckRegistered (void)
|
|||
Sys_FileRead (h, check, sizeof(check));
|
||||
COM_CloseFile (h);
|
||||
|
||||
for (i=0 ; i<128 ; i++)
|
||||
for (i = 0; i < 128; i++)
|
||||
if (pop[i] != (unsigned short)BigShort (check[i]))
|
||||
Sys_Error ("Corrupted data file.");
|
||||
|
||||
|
@ -1188,12 +1188,12 @@ COM_InitArgv
|
|||
*/
|
||||
void COM_InitArgv (int argc, char **argv)
|
||||
{
|
||||
int i, j, n;
|
||||
int i, j, n;
|
||||
|
||||
// reconstitute the command line for the cmdline externally visible cvar
|
||||
n = 0;
|
||||
|
||||
for (j=0 ; (j<MAX_NUM_ARGVS) && (j< argc) ; j++)
|
||||
for (j = 0; (j<MAX_NUM_ARGVS) && (j< argc); j++)
|
||||
{
|
||||
i = 0;
|
||||
|
||||
|
@ -1213,7 +1213,7 @@ void COM_InitArgv (int argc, char **argv)
|
|||
|
||||
Con_Printf("Command line: %s\n", com_cmdline);
|
||||
|
||||
for (com_argc=0 ; (com_argc<MAX_NUM_ARGVS) && (com_argc < argc) ; com_argc++)
|
||||
for (com_argc = 0; (com_argc < MAX_NUM_ARGVS) && (com_argc < argc); com_argc++)
|
||||
{
|
||||
largv[com_argc] = argv[com_argc];
|
||||
if (!Q_strcmp ("-safe", argv[com_argc]))
|
||||
|
@ -1344,11 +1344,11 @@ char *va (const char *format, ...)
|
|||
|
||||
|
||||
/// just for debugging
|
||||
int memsearch (byte *start, int count, int search)
|
||||
int memsearch (byte *start, int count, int search)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i=0 ; i<count ; i++)
|
||||
for (i = 0; i < count; i++)
|
||||
if (start[i] == search)
|
||||
return i;
|
||||
return -1;
|
||||
|
@ -1362,7 +1362,7 @@ QUAKE FILESYSTEM
|
|||
=============================================================================
|
||||
*/
|
||||
|
||||
int com_filesize;
|
||||
int com_filesize;
|
||||
|
||||
|
||||
//
|
||||
|
@ -1371,16 +1371,16 @@ int com_filesize;
|
|||
|
||||
typedef struct
|
||||
{
|
||||
char name[MAX_QPATH];
|
||||
int filepos, filelen;
|
||||
char name[MAX_QPATH];
|
||||
int filepos, filelen;
|
||||
} packfile_t;
|
||||
|
||||
typedef struct pack_s
|
||||
{
|
||||
char filename[MAX_OSPATH];
|
||||
int handle;
|
||||
int numfiles;
|
||||
packfile_t *files;
|
||||
char filename[MAX_OSPATH];
|
||||
int handle;
|
||||
int numfiles;
|
||||
packfile_t *files;
|
||||
} pack_t;
|
||||
|
||||
//
|
||||
|
@ -1388,34 +1388,34 @@ typedef struct pack_s
|
|||
//
|
||||
typedef struct
|
||||
{
|
||||
char name[56];
|
||||
int filepos, filelen;
|
||||
char name[56];
|
||||
int filepos, filelen;
|
||||
} dpackfile_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char id[4];
|
||||
int dirofs;
|
||||
int dirlen;
|
||||
char id[4];
|
||||
int dirofs;
|
||||
int dirlen;
|
||||
} dpackheader_t;
|
||||
|
||||
#define MAX_FILES_IN_PACK 2048
|
||||
#define MAX_FILES_IN_PACK 2048
|
||||
|
||||
char com_gamedir[MAX_OSPATH];
|
||||
char com_basedir[MAX_OSPATH];
|
||||
int file_from_pak; // ZOID: global indicating that file came from a pak
|
||||
char com_gamedir[MAX_OSPATH];
|
||||
char com_basedir[MAX_OSPATH];
|
||||
int file_from_pak; // ZOID: global indicating that file came from a pak
|
||||
|
||||
typedef struct searchpath_s
|
||||
{
|
||||
unsigned int path_id; // identifier assigned to the game directory
|
||||
// Note that <install_dir>/game1 and
|
||||
// <userdir>/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 ; i<pak->numfiles ; 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);
|
||||
|
|
Loading…
Reference in a new issue