added a macro for specifying all the cvar properties. This will simplify stuff for Q2.
Also added trace_endcontents and trace_surfaceflags. File system (still too selectivly) reads gz files. Fixed a buffer overflow in the http client. Made server downloads decompress zipped files to a temporary file. This should make it download them faster. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1943 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
bc1f25a11b
commit
6430b9b214
57 changed files with 931 additions and 658 deletions
|
@ -21,9 +21,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "quakedef.h"
|
||||
|
||||
cvar_t com_fs_cache = {"fs_cache", "0", NULL, CVAR_ARCHIVE};
|
||||
cvar_t rcon_level = {"rcon_level", "50"};
|
||||
cvar_t cmd_maxbuffersize = {"cmd_maxbuffersize", "65536"};
|
||||
cvar_t com_fs_cache = SCVARF("fs_cache", "0", CVAR_ARCHIVE);
|
||||
cvar_t rcon_level = SCVAR("rcon_level", "50");
|
||||
cvar_t cmd_maxbuffersize = SCVAR("cmd_maxbuffersize", "65536");
|
||||
int Cmd_ExecLevel;
|
||||
|
||||
void Cmd_ForwardToServer (void);
|
||||
|
@ -44,10 +44,10 @@ typedef struct cmdalias_s
|
|||
|
||||
cmdalias_t *cmd_alias;
|
||||
|
||||
cvar_t cl_warncmd = {"cl_warncmd", "0"};
|
||||
cvar_t cl_aliasoverlap = {"cl_aliasoverlap", "1", NULL, CVAR_NOTFROMSERVER};
|
||||
cvar_t cl_warncmd = SCVAR("cl_warncmd", "0");
|
||||
cvar_t cl_aliasoverlap = SCVARF("cl_aliasoverlap", "1", CVAR_NOTFROMSERVER);
|
||||
|
||||
cvar_t tp_disputablemacros = {"tp_disputablemacros", "1", NULL, CVAR_SEMICHEAT};
|
||||
cvar_t tp_disputablemacros = SCVARF("tp_disputablemacros", "1", CVAR_SEMICHEAT);
|
||||
|
||||
|
||||
//=============================================================================
|
||||
|
|
|
@ -42,8 +42,8 @@ static char *argvdummy = " ";
|
|||
static char *safeargvs[NUM_SAFE_ARGVS] =
|
||||
{"-stdvid", "-nolan", "-nosound", "-nocdaudio", "-nojoy", "-nomouse"};
|
||||
|
||||
cvar_t registered = {"registered","0"};
|
||||
cvar_t com_gamename = {"com_gamename", ""};
|
||||
cvar_t registered = SCVAR("registered","0");
|
||||
cvar_t com_gamename = SCVAR("com_gamename", "");
|
||||
|
||||
qboolean com_modified; // set true if using non-id files
|
||||
|
||||
|
|
|
@ -310,6 +310,7 @@ typedef struct vfsfile_s {
|
|||
unsigned long (*GetLen) (struct vfsfile_s *file); //could give some lag
|
||||
void (*Close) (struct vfsfile_s *file);
|
||||
void (*Flush) (struct vfsfile_s *file);
|
||||
qboolean seekingisabadplan;
|
||||
} vfsfile_t;
|
||||
|
||||
#define VFS_CLOSE(vf) (vf->Close(vf))
|
||||
|
@ -326,6 +327,7 @@ void FS_CreatePath(char *pname, int relativeto);
|
|||
int FS_Rename(char *oldf, char *newf, int relativeto); //0 on success, non-0 on error
|
||||
int FS_Remove(char *fname, int relativeto); //0 on success, non-0 on error
|
||||
vfsfile_t *FS_OpenVFS(char *filename, char *mode, int relativeto);
|
||||
vfsfile_t *FS_OpenTemp(void);
|
||||
enum {
|
||||
FS_GAME,
|
||||
FS_BASE,
|
||||
|
|
|
@ -616,9 +616,11 @@ cvar_t *Cvar_SetCore (cvar_t *var, const char *value, qboolean force)
|
|||
if (var->flags & CVAR_SERVEROVERRIDE && !force)
|
||||
latch = "variable %s is under server control - latched\n";
|
||||
else if (var->flags & CVAR_LATCH)
|
||||
latch = "variable %s is latched\n";
|
||||
latch = "variable %s is latched and will be applied for the start of the next map\n";
|
||||
// else if (var->flags & CVAR_LATCHFLUSH)
|
||||
// latch = "variable %s is latched (type flush)\n";
|
||||
else if (var->flags & CVAR_RENDERERLATCH && qrenderer)
|
||||
latch = "variable %s will be changed after a renderer restart\n";
|
||||
latch = "variable %s will be changed after a vid_restart\n";
|
||||
#ifndef SERVERONLY
|
||||
else if (var->flags & CVAR_CHEAT && !cls.allow_cheats && cls.state)
|
||||
latch = "variable %s is a cheat variable - latched\n";
|
||||
|
|
|
@ -66,10 +66,15 @@ typedef struct cvar_s
|
|||
|
||||
//free style :)
|
||||
char *name2;
|
||||
|
||||
char *defaultstr; //default
|
||||
qbyte restriction;
|
||||
} cvar_t;
|
||||
|
||||
#define FCVAR(ConsoleName,ConsoleName2,Value,Flags) {ConsoleName, Value, NULL, Flags, 0, 0, 0, ConsoleName2}
|
||||
#define SCVARF(ConsoleName,Value, Flags) FCVAR(ConsoleName, NULL, Value, Flags)
|
||||
#define SCVAR(ConsoleName,Value) FCVAR(ConsoleName, NULL, Value, 0)
|
||||
|
||||
typedef struct cvar_group_s
|
||||
{
|
||||
const char *name;
|
||||
|
|
|
@ -208,6 +208,28 @@ void VFSOS_Close(vfsfile_t *file)
|
|||
fclose(intfile->handle);
|
||||
Z_Free(file);
|
||||
}
|
||||
|
||||
vfsfile_t *FS_OpenTemp(void)
|
||||
{
|
||||
FILE *f;
|
||||
vfsosfile_t *file;
|
||||
|
||||
f = tmpfile();
|
||||
if (!f)
|
||||
return NULL;
|
||||
|
||||
file = Z_Malloc(sizeof(vfsosfile_t));
|
||||
file->funcs.ReadBytes = VFSOS_ReadBytes;
|
||||
file->funcs.WriteBytes = VFSOS_WriteBytes;
|
||||
file->funcs.Seek = VFSOS_Seek;
|
||||
file->funcs.Tell = VFSOS_Tell;
|
||||
file->funcs.GetLen = VFSOS_GetSize;
|
||||
file->funcs.Close = VFSOS_Close;
|
||||
file->handle = f;
|
||||
|
||||
return (vfsfile_t*)file;
|
||||
}
|
||||
|
||||
vfsfile_t *VFSOS_Open(char *osname, char *mode)
|
||||
{
|
||||
FILE *f;
|
||||
|
@ -998,6 +1020,7 @@ vfsfile_t *FSZIP_OpenVFS(void *handle, flocation_t *loc, char *mode)
|
|||
vfsz->funcs.Seek = VFSZIP_Seek;
|
||||
vfsz->funcs.Tell = VFSZIP_Tell;
|
||||
vfsz->funcs.WriteBytes = NULL;
|
||||
vfsz->funcs.seekingisabadplan = true;
|
||||
|
||||
unzLocateFileMy(vfsz->parent->handle, vfsz->index, vfsz->startpos);
|
||||
rawofs = unzGetCurrentFileUncompressedPos(zip->handle);
|
||||
|
@ -1593,6 +1616,180 @@ qboolean Sys_PathProtection(char *pattern)
|
|||
return true;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
unsigned char ident1;
|
||||
unsigned char ident2;
|
||||
unsigned char cm;
|
||||
unsigned char flags;
|
||||
unsigned int mtime;
|
||||
unsigned char xflags;
|
||||
unsigned char os;
|
||||
} gzheader_t;
|
||||
#define sizeofgzheader_t 10
|
||||
|
||||
#define GZ_FTEXT 1
|
||||
#define GZ_FHCRC 2
|
||||
#define GZ_FEXTRA 4
|
||||
#define GZ_FNAME 8
|
||||
#define GZ_FCOMMENT 16
|
||||
#define GZ_RESERVED (32|64|128)
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
vfsfile_t *FS_DecompressGZip(vfsfile_t *infile, gzheader_t *header)
|
||||
{
|
||||
char inchar;
|
||||
unsigned short inshort;
|
||||
vfsfile_t *temp;
|
||||
|
||||
if (header->flags & GZ_RESERVED)
|
||||
{ //reserved bits should be 0
|
||||
//this is probably static, so it's not a gz. doh.
|
||||
VFS_SEEK(infile, 0);
|
||||
return infile;
|
||||
}
|
||||
|
||||
if (header->flags & GZ_FEXTRA)
|
||||
{
|
||||
VFS_READ(infile, &inshort, sizeof(inshort));
|
||||
inshort = LittleShort(inshort);
|
||||
VFS_SEEK(infile, VFS_TELL(infile) + inshort);
|
||||
}
|
||||
|
||||
if (header->flags & GZ_FNAME)
|
||||
{
|
||||
Con_Printf("gzipped file name: ");
|
||||
do {
|
||||
if (VFS_READ(infile, &inchar, sizeof(inchar)) != 1)
|
||||
break;
|
||||
Con_Printf("%c", inchar);
|
||||
} while(inchar);
|
||||
Con_Printf("\n");
|
||||
}
|
||||
|
||||
if (header->flags & GZ_FCOMMENT)
|
||||
{
|
||||
Con_Printf("gzipped file comment: ");
|
||||
do {
|
||||
if (VFS_READ(infile, &inchar, sizeof(inchar)) != 1)
|
||||
break;
|
||||
Con_Printf("%c", inchar);
|
||||
} while(inchar);
|
||||
Con_Printf("\n");
|
||||
}
|
||||
|
||||
if (header->flags & GZ_FHCRC)
|
||||
{
|
||||
VFS_READ(infile, &inshort, sizeof(inshort));
|
||||
}
|
||||
|
||||
|
||||
|
||||
temp = FS_OpenTemp();
|
||||
if (!temp)
|
||||
{
|
||||
VFS_SEEK(infile, 0); //doh
|
||||
return infile;
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
char inbuffer[16384];
|
||||
char outbuffer[16384];
|
||||
int ret;
|
||||
|
||||
z_stream strm = {
|
||||
inbuffer,
|
||||
0,
|
||||
0,
|
||||
|
||||
outbuffer,
|
||||
sizeof(outbuffer),
|
||||
0,
|
||||
|
||||
NULL,
|
||||
NULL,
|
||||
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
||||
Z_UNKNOWN,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
strm.avail_in = VFS_READ(infile, inbuffer, sizeof(inbuffer));
|
||||
strm.next_in = inbuffer;
|
||||
|
||||
inflateInit2(&strm, -MAX_WBITS);
|
||||
|
||||
while ((ret=inflate(&strm, Z_SYNC_FLUSH)) != Z_STREAM_END)
|
||||
{
|
||||
if (strm.avail_in == 0 || strm.avail_out == 0)
|
||||
{
|
||||
if (strm.avail_in == 0)
|
||||
{
|
||||
strm.avail_in = VFS_READ(infile, inbuffer, sizeof(inbuffer));
|
||||
strm.next_in = inbuffer;
|
||||
}
|
||||
|
||||
if (strm.avail_out == 0)
|
||||
{
|
||||
strm.next_out = outbuffer;
|
||||
VFS_WRITE(temp, outbuffer, strm.total_out);
|
||||
strm.total_out = 0;
|
||||
strm.avail_out = sizeof(outbuffer);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
//doh, it terminated for no reason
|
||||
inflateEnd(&strm);
|
||||
if (ret != Z_STREAM_END)
|
||||
{
|
||||
Con_Printf("Couldn't decompress gz file\n");
|
||||
VFS_CLOSE(temp);
|
||||
VFS_CLOSE(infile);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
//we got to the end
|
||||
VFS_WRITE(temp, outbuffer, strm.total_out);
|
||||
|
||||
inflateEnd(&strm);
|
||||
|
||||
VFS_SEEK(temp, 0);
|
||||
}
|
||||
VFS_CLOSE(infile);
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
vfsfile_t *VFS_Filter(char *filename, vfsfile_t *handle)
|
||||
{
|
||||
// char *ext;
|
||||
|
||||
if (!handle || handle->WriteBytes || handle->seekingisabadplan) //only on readonly files
|
||||
return handle;
|
||||
|
||||
// ext = COM_FileExtension (filename);
|
||||
// if (!stricmp(ext, ".gz"))
|
||||
{
|
||||
gzheader_t gzh;
|
||||
if (VFS_READ(handle, &gzh, sizeofgzheader_t) == sizeofgzheader_t)
|
||||
{
|
||||
if (gzh.ident1 == 0x1f && gzh.ident2 == 0x8b && gzh.cm == 8)
|
||||
{ //it'll do
|
||||
return FS_DecompressGZip(handle, &gzh);
|
||||
}
|
||||
}
|
||||
VFS_SEEK(handle, 0);
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
vfsfile_t *FS_OpenVFS(char *filename, char *mode, int relativeto)
|
||||
{
|
||||
char fullname[MAX_OSPATH];
|
||||
|
@ -1659,7 +1856,7 @@ vfsfile_t *FS_OpenVFS(char *filename, char *mode, int relativeto)
|
|||
if (loc.search)
|
||||
{
|
||||
com_file_copyprotected = loc.search->copyprotected;
|
||||
return loc.search->funcs->OpenVFS(loc.search->handle, &loc, mode);
|
||||
return VFS_Filter(filename, loc.search->funcs->OpenVFS(loc.search->handle, &loc, mode));
|
||||
}
|
||||
|
||||
//if we're meant to be writing, best write to it.
|
||||
|
|
|
@ -317,10 +317,10 @@ qbyte portalopen[MAX_Q2MAP_AREAPORTALS]; //memset will work if it's a qbyte, rea
|
|||
|
||||
|
||||
static int mapisq3;
|
||||
cvar_t map_noareas = {"map_noareas", "1"}; //1 for lack of mod support.
|
||||
cvar_t map_noCurves = {"map_noCurves", "0", NULL, CVAR_CHEAT};
|
||||
cvar_t map_autoopenportals = {"map_autoopenportals", "1"}; //1 for lack of mod support.
|
||||
cvar_t r_subdivisions = {"r_subdivisions", "2"};
|
||||
cvar_t map_noareas = SCVAR("map_noareas", "1"); //1 for lack of mod support.
|
||||
cvar_t map_noCurves = SCVARF("map_noCurves", "0", CVAR_CHEAT);
|
||||
cvar_t map_autoopenportals = SCVAR("map_autoopenportals", "1"); //1 for lack of mod support.
|
||||
cvar_t r_subdivisions = SCVAR("r_subdivisions", "2");
|
||||
|
||||
int CM_NumInlineModels (model_t *model);
|
||||
q2cmodel_t *CM_InlineModel (char *name);
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
|
||||
// cvars
|
||||
#define CONLOGGROUP "Console logging"
|
||||
cvar_t log_name = {"log_name", "", NULL, CVAR_NOTFROMSERVER};
|
||||
cvar_t log_dir = {"log_dir", "", NULL, CVAR_NOTFROMSERVER};
|
||||
cvar_t log_readable = {"log_readable", "0", NULL, CVAR_NOTFROMSERVER};
|
||||
cvar_t log_enable = {"log_enable", "0", NULL, CVAR_NOTFROMSERVER};
|
||||
cvar_t log_developer = {"log_developer", "0", NULL, CVAR_NOTFROMSERVER};
|
||||
cvar_t log_rotate_files = {"log_rotate_files", "0", NULL, CVAR_NOTFROMSERVER};
|
||||
cvar_t log_rotate_size = {"log_rotate_size", "131072", NULL, CVAR_NOTFROMSERVER};
|
||||
cvar_t log_dosformat = {"log_dosformat", "0", NULL, CVAR_NOTFROMSERVER};
|
||||
cvar_t log_name = SCVARF("log_name", "", CVAR_NOTFROMSERVER);
|
||||
cvar_t log_dir = SCVARF("log_dir", "", CVAR_NOTFROMSERVER);
|
||||
cvar_t log_readable = SCVARF("log_readable", "0", CVAR_NOTFROMSERVER);
|
||||
cvar_t log_enable = SCVARF("log_enable", "0", CVAR_NOTFROMSERVER);
|
||||
cvar_t log_developer = SCVARF("log_developer", "0", CVAR_NOTFROMSERVER);
|
||||
cvar_t log_rotate_files = SCVARF("log_rotate_files", "0", CVAR_NOTFROMSERVER);
|
||||
cvar_t log_rotate_size = SCVARF("log_rotate_size", "131072", CVAR_NOTFROMSERVER);
|
||||
cvar_t log_dosformat = SCVARF("log_dosformat", "0", CVAR_NOTFROMSERVER);
|
||||
|
||||
// externals
|
||||
int COM_FileSize(char *path);
|
||||
|
|
|
@ -78,9 +78,9 @@ to the new value before sending out any replies.
|
|||
*/
|
||||
|
||||
int net_drop;
|
||||
cvar_t showpackets = {"showpackets", "0"};
|
||||
cvar_t showdrop = {"showdrop", "0"};
|
||||
cvar_t qport = {"qport", "0"};
|
||||
cvar_t showpackets = SCVAR("showpackets", "0");
|
||||
cvar_t showdrop = SCVAR("showdrop", "0");
|
||||
cvar_t qport = SCVAR("qport", "0");
|
||||
|
||||
/*
|
||||
===============
|
||||
|
|
|
@ -95,8 +95,8 @@ qboolean Init_GNUTLS(void) {return true;}
|
|||
#endif
|
||||
|
||||
|
||||
cvar_t plug_sbar = {"plug_sbar", "1"};
|
||||
cvar_t plug_loaddefault = {"plug_loaddefault", "1"};
|
||||
cvar_t plug_sbar = SCVAR("plug_sbar", "1");
|
||||
cvar_t plug_loaddefault = SCVAR("plug_loaddefault", "1");
|
||||
|
||||
#ifdef RGLQUAKE
|
||||
#include "glquake.h"
|
||||
|
|
|
@ -273,7 +273,7 @@ static char *defaultlanguagetext =
|
|||
|
||||
|
||||
|
||||
cvar_t language = {"language", "uk"};
|
||||
cvar_t language = SCVAR("language", "uk");
|
||||
char lastlang[9];
|
||||
|
||||
typedef struct trans_s {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue