mirror of
https://git.code.sf.net/p/quake/quakeforge-old
synced 2025-02-18 01:31:21 +00:00
Replaced every single fscking FILE and gzFile (except in quakeio.*) with QFile
and fixed up as many f* and gz* calls as gcc found (and, where sensible, grep) Unfortuanatly, demos are broken again.
This commit is contained in:
parent
e67f3dc07a
commit
a078544d38
28 changed files with 299 additions and 233 deletions
|
@ -296,7 +296,7 @@ void GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr)
|
||||||
int *cmds;
|
int *cmds;
|
||||||
trivertx_t *verts;
|
trivertx_t *verts;
|
||||||
char cache[MAX_QPATH], fullpath[MAX_OSPATH];
|
char cache[MAX_QPATH], fullpath[MAX_OSPATH];
|
||||||
gzFile *f;
|
QFile *f;
|
||||||
|
|
||||||
aliasmodel = m;
|
aliasmodel = m;
|
||||||
paliashdr = hdr; // (aliashdr_t *)Mod_Extradata (m);
|
paliashdr = hdr; // (aliashdr_t *)Mod_Extradata (m);
|
||||||
|
@ -311,11 +311,11 @@ void GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr)
|
||||||
COM_FOpenFile (cache, &f);
|
COM_FOpenFile (cache, &f);
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
gzread (f, &numcommands, 4);
|
Qread (f, &numcommands, 4);
|
||||||
gzread (f, &numorder, 4);
|
Qread (f, &numorder, 4);
|
||||||
gzread (f, commands, numcommands * sizeof(commands[0]));
|
Qread (f, commands, numcommands * sizeof(commands[0]));
|
||||||
gzread (f, vertexorder, numorder * sizeof(vertexorder[0]));
|
Qread (f, vertexorder, numorder * sizeof(vertexorder[0]));
|
||||||
gzclose (f);
|
Qclose (f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -330,24 +330,24 @@ void GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr)
|
||||||
// save out the cached version
|
// save out the cached version
|
||||||
//
|
//
|
||||||
snprintf(fullpath, sizeof(fullpath), "%s/%s", com_gamedir, cache);
|
snprintf(fullpath, sizeof(fullpath), "%s/%s", com_gamedir, cache);
|
||||||
f = gzopen (fullpath, "wb");
|
f = Qopen (fullpath, "wb");
|
||||||
#ifdef QUAKEWORLD
|
#ifdef QUAKEWORLD
|
||||||
if (!f) {
|
if (!f) {
|
||||||
char gldir[MAX_OSPATH];
|
char gldir[MAX_OSPATH];
|
||||||
|
|
||||||
snprintf(gldir, sizeof(gldir), "%s/glquake", com_gamedir);
|
snprintf(gldir, sizeof(gldir), "%s/glquake", com_gamedir);
|
||||||
Sys_mkdir (gldir);
|
Sys_mkdir (gldir);
|
||||||
f = gzopen (fullpath, "wb");
|
f = Qopen (fullpath, "wb");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
gzwrite(f, &numcommands, 4);
|
Qwrite(f, &numcommands, 4);
|
||||||
gzwrite(f, &numorder, 4);
|
Qwrite(f, &numorder, 4);
|
||||||
gzwrite(f, commands, numcommands * sizeof(commands[0]));
|
Qwrite(f, commands, numcommands * sizeof(commands[0]));
|
||||||
gzwrite(f, vertexorder, numorder * sizeof(vertexorder[0]));
|
Qwrite(f, vertexorder, numorder * sizeof(vertexorder[0]));
|
||||||
gzclose (f);
|
Qclose (f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -376,7 +376,7 @@ void VID_SetPalette (unsigned char *palette)
|
||||||
int k;
|
int k;
|
||||||
unsigned short i;
|
unsigned short i;
|
||||||
unsigned *table;
|
unsigned *table;
|
||||||
gzFile *f;
|
QFile *f;
|
||||||
char s[255];
|
char s[255];
|
||||||
float dist, bestdist;
|
float dist, bestdist;
|
||||||
static qboolean palflag = false;
|
static qboolean palflag = false;
|
||||||
|
@ -410,8 +410,8 @@ void VID_SetPalette (unsigned char *palette)
|
||||||
|
|
||||||
COM_FOpenFile("glquake/15to8.pal", &f);
|
COM_FOpenFile("glquake/15to8.pal", &f);
|
||||||
if (f) {
|
if (f) {
|
||||||
gzread(f, d_15to8table, 1<<15);
|
Qread(f, d_15to8table, 1<<15);
|
||||||
gzclose(f);
|
Qclose(f);
|
||||||
} else {
|
} else {
|
||||||
for (i=0; i < (1<<15); i++) {
|
for (i=0; i < (1<<15); i++) {
|
||||||
/* Maps
|
/* Maps
|
||||||
|
@ -439,9 +439,9 @@ void VID_SetPalette (unsigned char *palette)
|
||||||
snprintf(s, sizeof(s), "%s/glquake", com_gamedir);
|
snprintf(s, sizeof(s), "%s/glquake", com_gamedir);
|
||||||
Sys_mkdir (s);
|
Sys_mkdir (s);
|
||||||
snprintf(s, sizeof(s), "%s/glquake/15to8.pal", com_gamedir);
|
snprintf(s, sizeof(s), "%s/glquake/15to8.pal", com_gamedir);
|
||||||
if ((f = gzopen(s, "wb")) != NULL) {
|
if ((f = Qopen(s, "wb")) != NULL) {
|
||||||
gzwrite(f, d_15to8table, 1<<15);
|
Qwrite(f, d_15to8table, 1<<15);
|
||||||
gzclose(f);
|
Qclose(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ void VID_SetPalette (unsigned char *palette)
|
||||||
unsigned short i;
|
unsigned short i;
|
||||||
unsigned *table;
|
unsigned *table;
|
||||||
//#ifdef QUAKEWORLD
|
//#ifdef QUAKEWORLD
|
||||||
gzFile *f;
|
QFile *f;
|
||||||
char s[255];
|
char s[255];
|
||||||
//#endif
|
//#endif
|
||||||
float dist, bestdist;
|
float dist, bestdist;
|
||||||
|
@ -169,8 +169,8 @@ void VID_SetPalette (unsigned char *palette)
|
||||||
|
|
||||||
COM_FOpenFile("glquake/15to8.pal", &f);
|
COM_FOpenFile("glquake/15to8.pal", &f);
|
||||||
if (f) {
|
if (f) {
|
||||||
gzread(f, d_15to8table, 1<<15);
|
Qread(f, d_15to8table, 1<<15);
|
||||||
gzclose(f);
|
Qclose(f);
|
||||||
} else
|
} else
|
||||||
//#endif // QUAKEWORLD
|
//#endif // QUAKEWORLD
|
||||||
{
|
{
|
||||||
|
@ -201,9 +201,9 @@ void VID_SetPalette (unsigned char *palette)
|
||||||
snprintf(s, sizeof(s), "%s/glquake", com_gamedir);
|
snprintf(s, sizeof(s), "%s/glquake", com_gamedir);
|
||||||
Sys_mkdir (s);
|
Sys_mkdir (s);
|
||||||
snprintf(s, sizeof(s), "%s/glquake/15to8.pal", com_gamedir);
|
snprintf(s, sizeof(s), "%s/glquake/15to8.pal", com_gamedir);
|
||||||
if ((f = gzopen(s, "wb")) != NULL) {
|
if ((f = Qopen(s, "wb")) != NULL) {
|
||||||
gzwrite(f, d_15to8table, 1<<15);
|
Qwrite(f, d_15to8table, 1<<15);
|
||||||
gzclose(f);
|
Qclose(f);
|
||||||
}
|
}
|
||||||
//#endif // QUAKEWORLD
|
//#endif // QUAKEWORLD
|
||||||
}
|
}
|
||||||
|
|
|
@ -706,7 +706,7 @@ void VID_SetPalette (unsigned char *palette)
|
||||||
int j,k,l,m;
|
int j,k,l,m;
|
||||||
unsigned short i;
|
unsigned short i;
|
||||||
unsigned *table;
|
unsigned *table;
|
||||||
FILE *f;
|
QFile *f;
|
||||||
char s[255];
|
char s[255];
|
||||||
HWND hDlg, hProgress;
|
HWND hDlg, hProgress;
|
||||||
float gamma;
|
float gamma;
|
||||||
|
|
106
common/gl_warp.c
106
common/gl_warp.c
|
@ -358,7 +358,7 @@ byte *pcx_rgb;
|
||||||
LoadPCX
|
LoadPCX
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
LoadPCX (gzFile *f) {
|
LoadPCX (QFile *f) {
|
||||||
|
|
||||||
pcx_t *pcx, pcxbuf;
|
pcx_t *pcx, pcxbuf;
|
||||||
byte palette[768];
|
byte palette[768];
|
||||||
|
@ -370,7 +370,7 @@ LoadPCX (gzFile *f) {
|
||||||
/*
|
/*
|
||||||
Parse PCX file
|
Parse PCX file
|
||||||
*/
|
*/
|
||||||
gzread (f, &pcxbuf, sizeof(pcxbuf));
|
Qread (f, &pcxbuf, sizeof(pcxbuf));
|
||||||
|
|
||||||
pcx = &pcxbuf;
|
pcx = &pcxbuf;
|
||||||
|
|
||||||
|
@ -382,10 +382,10 @@ LoadPCX (gzFile *f) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// seek to palette
|
// seek to palette
|
||||||
gzseek (f, -768, SEEK_END);
|
Qseek (f, -768, SEEK_END);
|
||||||
gzread (f, palette, 768);
|
Qread (f, palette, 768);
|
||||||
|
|
||||||
gzseek (f, sizeof(pcxbuf) - 4, SEEK_SET);
|
Qseek (f, sizeof(pcxbuf) - 4, SEEK_SET);
|
||||||
|
|
||||||
count = (pcx->xmax+1) * (pcx->ymax+1);
|
count = (pcx->xmax+1) * (pcx->ymax+1);
|
||||||
pcx_rgb = malloc( count * 4);
|
pcx_rgb = malloc( count * 4);
|
||||||
|
@ -393,11 +393,11 @@ LoadPCX (gzFile *f) {
|
||||||
for (y=0 ; y<=pcx->ymax ; y++) {
|
for (y=0 ; y<=pcx->ymax ; y++) {
|
||||||
pix = pcx_rgb + 4*y*(pcx->xmax+1);
|
pix = pcx_rgb + 4*y*(pcx->xmax+1);
|
||||||
for (x=0 ; x<=pcx->ymax ; ) {
|
for (x=0 ; x<=pcx->ymax ; ) {
|
||||||
dataByte = gzgetc(f);
|
dataByte = Qgetc(f);
|
||||||
|
|
||||||
if((dataByte & 0xC0) == 0xC0) {
|
if((dataByte & 0xC0) == 0xC0) {
|
||||||
runLength = dataByte & 0x3F;
|
runLength = dataByte & 0x3F;
|
||||||
dataByte = gzgetc(f);
|
dataByte = Qgetc(f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
runLength = 1;
|
runLength = 1;
|
||||||
|
@ -430,25 +430,25 @@ TargaHeader targa_header;
|
||||||
byte *targa_rgba;
|
byte *targa_rgba;
|
||||||
|
|
||||||
int
|
int
|
||||||
gzgetLittleShort ( gzFile *f ) {
|
QgetLittleShort ( QFile *f ) {
|
||||||
|
|
||||||
byte b1, b2;
|
byte b1, b2;
|
||||||
|
|
||||||
b1 = gzgetc(f);
|
b1 = Qgetc(f);
|
||||||
b2 = gzgetc(f);
|
b2 = Qgetc(f);
|
||||||
|
|
||||||
return (short)(b1 + b2*256);
|
return (short)(b1 + b2*256);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
gzgetLittleLong (gzFile *f) {
|
QgetLittleLong (QFile *f) {
|
||||||
|
|
||||||
byte b1, b2, b3, b4;
|
byte b1, b2, b3, b4;
|
||||||
|
|
||||||
b1 = gzgetc(f);
|
b1 = Qgetc(f);
|
||||||
b2 = gzgetc(f);
|
b2 = Qgetc(f);
|
||||||
b3 = gzgetc(f);
|
b3 = Qgetc(f);
|
||||||
b4 = gzgetc(f);
|
b4 = Qgetc(f);
|
||||||
|
|
||||||
return b1 + (b2<<8) + (b3<<16) + (b4<<24);
|
return b1 + (b2<<8) + (b3<<16) + (b4<<24);
|
||||||
}
|
}
|
||||||
|
@ -457,25 +457,25 @@ gzgetLittleLong (gzFile *f) {
|
||||||
LoadTGA
|
LoadTGA
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
LoadTGA (gzFile *fin) {
|
LoadTGA (QFile *fin) {
|
||||||
|
|
||||||
int columns, rows, numPixels;
|
int columns, rows, numPixels;
|
||||||
byte *pixbuf;
|
byte *pixbuf;
|
||||||
int row, column;
|
int row, column;
|
||||||
|
|
||||||
targa_header.id_length = gzgetc(fin);
|
targa_header.id_length = Qgetc(fin);
|
||||||
targa_header.colormap_type = gzgetc(fin);
|
targa_header.colormap_type = Qgetc(fin);
|
||||||
targa_header.image_type = gzgetc(fin);
|
targa_header.image_type = Qgetc(fin);
|
||||||
|
|
||||||
targa_header.colormap_index = gzgetLittleShort(fin);
|
targa_header.colormap_index = QgetLittleShort(fin);
|
||||||
targa_header.colormap_length = gzgetLittleShort(fin);
|
targa_header.colormap_length = QgetLittleShort(fin);
|
||||||
targa_header.colormap_size = gzgetc(fin);
|
targa_header.colormap_size = Qgetc(fin);
|
||||||
targa_header.x_origin = gzgetLittleShort(fin);
|
targa_header.x_origin = QgetLittleShort(fin);
|
||||||
targa_header.y_origin = gzgetLittleShort(fin);
|
targa_header.y_origin = QgetLittleShort(fin);
|
||||||
targa_header.width = gzgetLittleShort(fin);
|
targa_header.width = QgetLittleShort(fin);
|
||||||
targa_header.height = gzgetLittleShort(fin);
|
targa_header.height = QgetLittleShort(fin);
|
||||||
targa_header.pixel_size = gzgetc(fin);
|
targa_header.pixel_size = Qgetc(fin);
|
||||||
targa_header.attributes = gzgetc(fin);
|
targa_header.attributes = Qgetc(fin);
|
||||||
|
|
||||||
if (targa_header.image_type!=2 && targa_header.image_type!=10)
|
if (targa_header.image_type!=2 && targa_header.image_type!=10)
|
||||||
Sys_Error ("LoadTGA: Only type 2 and 10 targa RGB images supported\n");
|
Sys_Error ("LoadTGA: Only type 2 and 10 targa RGB images supported\n");
|
||||||
|
@ -492,7 +492,7 @@ LoadTGA (gzFile *fin) {
|
||||||
targa_rgba = malloc (numPixels*4);
|
targa_rgba = malloc (numPixels*4);
|
||||||
|
|
||||||
if (targa_header.id_length != 0)
|
if (targa_header.id_length != 0)
|
||||||
gzseek(fin, targa_header.id_length, SEEK_CUR); // skip TARGA image comment
|
Qseek(fin, targa_header.id_length, SEEK_CUR); // skip TARGA image comment
|
||||||
|
|
||||||
if (targa_header.image_type==2) { // Uncompressed, RGB images
|
if (targa_header.image_type==2) { // Uncompressed, RGB images
|
||||||
for(row=rows-1; row>=0; row--) {
|
for(row=rows-1; row>=0; row--) {
|
||||||
|
@ -502,19 +502,19 @@ LoadTGA (gzFile *fin) {
|
||||||
switch (targa_header.pixel_size) {
|
switch (targa_header.pixel_size) {
|
||||||
case 24:
|
case 24:
|
||||||
|
|
||||||
blue = gzgetc(fin);
|
blue = Qgetc(fin);
|
||||||
green = gzgetc(fin);
|
green = Qgetc(fin);
|
||||||
red = gzgetc(fin);
|
red = Qgetc(fin);
|
||||||
*pixbuf++ = red;
|
*pixbuf++ = red;
|
||||||
*pixbuf++ = green;
|
*pixbuf++ = green;
|
||||||
*pixbuf++ = blue;
|
*pixbuf++ = blue;
|
||||||
*pixbuf++ = 255;
|
*pixbuf++ = 255;
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
blue = gzgetc(fin);
|
blue = Qgetc(fin);
|
||||||
green = gzgetc(fin);
|
green = Qgetc(fin);
|
||||||
red = gzgetc(fin);
|
red = Qgetc(fin);
|
||||||
alphabyte = gzgetc(fin);
|
alphabyte = Qgetc(fin);
|
||||||
*pixbuf++ = red;
|
*pixbuf++ = red;
|
||||||
*pixbuf++ = green;
|
*pixbuf++ = green;
|
||||||
*pixbuf++ = blue;
|
*pixbuf++ = blue;
|
||||||
|
@ -529,21 +529,21 @@ LoadTGA (gzFile *fin) {
|
||||||
for(row=rows-1; row>=0; row--) {
|
for(row=rows-1; row>=0; row--) {
|
||||||
pixbuf = targa_rgba + row*columns*4;
|
pixbuf = targa_rgba + row*columns*4;
|
||||||
for(column=0; column<columns; ) {
|
for(column=0; column<columns; ) {
|
||||||
packetHeader=gzgetc(fin);
|
packetHeader=Qgetc(fin);
|
||||||
packetSize = 1 + (packetHeader & 0x7f);
|
packetSize = 1 + (packetHeader & 0x7f);
|
||||||
if (packetHeader & 0x80) { // run-length packet
|
if (packetHeader & 0x80) { // run-length packet
|
||||||
switch (targa_header.pixel_size) {
|
switch (targa_header.pixel_size) {
|
||||||
case 24:
|
case 24:
|
||||||
blue = gzgetc(fin);
|
blue = Qgetc(fin);
|
||||||
green = gzgetc(fin);
|
green = Qgetc(fin);
|
||||||
red = gzgetc(fin);
|
red = Qgetc(fin);
|
||||||
alphabyte = 255;
|
alphabyte = 255;
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
blue = gzgetc(fin);
|
blue = Qgetc(fin);
|
||||||
green = gzgetc(fin);
|
green = Qgetc(fin);
|
||||||
red = gzgetc(fin);
|
red = Qgetc(fin);
|
||||||
alphabyte = gzgetc(fin);
|
alphabyte = Qgetc(fin);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -567,19 +567,19 @@ LoadTGA (gzFile *fin) {
|
||||||
for(j=0;j<packetSize;j++) {
|
for(j=0;j<packetSize;j++) {
|
||||||
switch (targa_header.pixel_size) {
|
switch (targa_header.pixel_size) {
|
||||||
case 24:
|
case 24:
|
||||||
blue = gzgetc(fin);
|
blue = Qgetc(fin);
|
||||||
green = gzgetc(fin);
|
green = Qgetc(fin);
|
||||||
red = gzgetc(fin);
|
red = Qgetc(fin);
|
||||||
*pixbuf++ = red;
|
*pixbuf++ = red;
|
||||||
*pixbuf++ = green;
|
*pixbuf++ = green;
|
||||||
*pixbuf++ = blue;
|
*pixbuf++ = blue;
|
||||||
*pixbuf++ = 255;
|
*pixbuf++ = 255;
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
blue = gzgetc(fin);
|
blue = Qgetc(fin);
|
||||||
green = gzgetc(fin);
|
green = Qgetc(fin);
|
||||||
red = gzgetc(fin);
|
red = Qgetc(fin);
|
||||||
alphabyte = gzgetc(fin);
|
alphabyte = Qgetc(fin);
|
||||||
*pixbuf++ = red;
|
*pixbuf++ = red;
|
||||||
*pixbuf++ = green;
|
*pixbuf++ = green;
|
||||||
*pixbuf++ = blue;
|
*pixbuf++ = blue;
|
||||||
|
@ -601,7 +601,7 @@ LoadTGA (gzFile *fin) {
|
||||||
breakOut:;
|
breakOut:;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gzclose(fin);
|
Qclose(fin);
|
||||||
// fclose(fin);
|
// fclose(fin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -614,7 +614,7 @@ void
|
||||||
R_LoadSkys ( void ) {
|
R_LoadSkys ( void ) {
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
gzFile *f;
|
QFile *f;
|
||||||
char name[64];
|
char name[64];
|
||||||
|
|
||||||
for (i=0 ; i<6 ; i++) {
|
for (i=0 ; i<6 ; i++) {
|
||||||
|
|
|
@ -1805,8 +1805,8 @@ void PF_logfrag (void)
|
||||||
|
|
||||||
SZ_Print (&svs.log[svs.logsequence&1], s);
|
SZ_Print (&svs.log[svs.logsequence&1], s);
|
||||||
if (sv_fraglogfile) {
|
if (sv_fraglogfile) {
|
||||||
fprintf (sv_fraglogfile, s);
|
Qprintf (sv_fraglogfile, s);
|
||||||
fflush (sv_fraglogfile);
|
Qflush (sv_fraglogfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ typedef struct
|
||||||
typedef struct pack_s
|
typedef struct pack_s
|
||||||
{
|
{
|
||||||
char filename[MAX_OSPATH];
|
char filename[MAX_OSPATH];
|
||||||
FILE *handle;
|
QFile *handle;
|
||||||
int numfiles;
|
int numfiles;
|
||||||
packfile_t *files;
|
packfile_t *files;
|
||||||
} pack_t;
|
} pack_t;
|
||||||
|
@ -127,24 +127,24 @@ searchpath_t *com_base_searchpaths; // without gamedirs
|
||||||
COM_filelength
|
COM_filelength
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
int COM_filelength (FILE *f)
|
int COM_filelength (QFile *f)
|
||||||
{
|
{
|
||||||
int pos;
|
int pos;
|
||||||
int end;
|
int end;
|
||||||
|
|
||||||
pos = ftell (f);
|
pos = Qtell (f);
|
||||||
fseek (f, 0, SEEK_END);
|
Qseek (f, 0, SEEK_END);
|
||||||
end = ftell (f);
|
end = Qtell (f);
|
||||||
fseek (f, pos, SEEK_SET);
|
Qseek (f, pos, SEEK_SET);
|
||||||
|
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
int COM_FileOpenRead (char *path, FILE **hndl)
|
int COM_FileOpenRead (char *path, QFile **hndl)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
|
|
||||||
f = fopen(path, "rb");
|
f = Qopen(path, "rb");
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
*hndl = NULL;
|
*hndl = NULL;
|
||||||
|
@ -186,22 +186,22 @@ The filename will be prefixed by the current game directory
|
||||||
*/
|
*/
|
||||||
void COM_WriteFile (char *filename, void *data, int len)
|
void COM_WriteFile (char *filename, void *data, int len)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
char name[MAX_OSPATH];
|
char name[MAX_OSPATH];
|
||||||
|
|
||||||
snprintf(name, sizeof(name), "%s/%s", com_gamedir, filename);
|
snprintf(name, sizeof(name), "%s/%s", com_gamedir, filename);
|
||||||
|
|
||||||
f = fopen (name, "wb");
|
f = Qopen (name, "wb");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
Sys_mkdir(com_gamedir);
|
Sys_mkdir(com_gamedir);
|
||||||
f = fopen (name, "wb");
|
f = Qopen (name, "wb");
|
||||||
if (!f)
|
if (!f)
|
||||||
Sys_Error ("Error opening %s", filename);
|
Sys_Error ("Error opening %s", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
Sys_Printf ("COM_WriteFile: %s\n", name);
|
Sys_Printf ("COM_WriteFile: %s\n", name);
|
||||||
fwrite (data, 1, len, f);
|
Qwrite (f, data, len);
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -238,13 +238,13 @@ needed. This is for the convenience of developers using ISDN from home.
|
||||||
*/
|
*/
|
||||||
void COM_CopyFile (char *netpath, char *cachepath)
|
void COM_CopyFile (char *netpath, char *cachepath)
|
||||||
{
|
{
|
||||||
FILE *in, *out;
|
QFile *in, *out;
|
||||||
int remaining, count;
|
int remaining, count;
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
|
|
||||||
remaining = COM_FileOpenRead (netpath, &in);
|
remaining = COM_FileOpenRead (netpath, &in);
|
||||||
COM_CreatePath (cachepath); // create directories up to the cache file
|
COM_CreatePath (cachepath); // create directories up to the cache file
|
||||||
out = fopen(cachepath, "wb");
|
out = Qopen(cachepath, "wb");
|
||||||
if (!out)
|
if (!out)
|
||||||
Sys_Error ("Error opening %s", cachepath);
|
Sys_Error ("Error opening %s", cachepath);
|
||||||
|
|
||||||
|
@ -254,19 +254,19 @@ void COM_CopyFile (char *netpath, char *cachepath)
|
||||||
count = remaining;
|
count = remaining;
|
||||||
else
|
else
|
||||||
count = sizeof(buf);
|
count = sizeof(buf);
|
||||||
fread (buf, 1, count, in);
|
Qread (in, buf, count);
|
||||||
fwrite (buf, 1, count, out);
|
Qwrite (out, buf, count);
|
||||||
remaining -= count;
|
remaining -= count;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (in);
|
Qclose (in);
|
||||||
fclose (out);
|
Qclose (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QFile *COM_gzOpenRead(const char *path, int offs, int len)
|
QFile *COM_OpenRead(const char *path, int offs, int len)
|
||||||
{
|
{
|
||||||
/* int fd=open(path,O_RDONLY);
|
int fd=open(path,O_RDONLY);
|
||||||
unsigned char id[2];
|
unsigned char id[2];
|
||||||
unsigned char len_bytes[4];
|
unsigned char len_bytes[4];
|
||||||
if (fd==-1) {
|
if (fd==-1) {
|
||||||
|
@ -290,7 +290,7 @@ QFile *COM_gzOpenRead(const char *path, int offs, int len)
|
||||||
}
|
}
|
||||||
lseek(fd,offs,SEEK_SET);
|
lseek(fd,offs,SEEK_SET);
|
||||||
com_filesize=len;
|
com_filesize=len;
|
||||||
return gzdopen(fd,"rb");*/
|
return Qdopen(fd,"rb");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,8 +348,8 @@ int COM_FOpenFile (char *filename, QFile **gzfile)
|
||||||
// Sys_Error ("Couldn't reopen %s", pak->filename);
|
// Sys_Error ("Couldn't reopen %s", pak->filename);
|
||||||
//fseek (*file, pak->files[i].filepos, SEEK_SET);
|
//fseek (*file, pak->files[i].filepos, SEEK_SET);
|
||||||
//com_filesize = pak->files[i].filelen;
|
//com_filesize = pak->files[i].filelen;
|
||||||
*gzfile=COM_gzOpenRead(pak->filename,pak->files[i].filepos,
|
*gzfile=COM_OpenRead(pak->filename,pak->files[i].filepos,
|
||||||
pak->files[i].filelen);
|
pak->files[i].filelen);
|
||||||
file_from_pak = 1;
|
file_from_pak = 1;
|
||||||
return com_filesize;
|
return com_filesize;
|
||||||
}
|
}
|
||||||
|
@ -377,7 +377,7 @@ int COM_FOpenFile (char *filename, QFile **gzfile)
|
||||||
|
|
||||||
//*file = fopen (netpath, "rb");
|
//*file = fopen (netpath, "rb");
|
||||||
//return COM_filelength (*file);
|
//return COM_filelength (*file);
|
||||||
*gzfile=COM_gzOpenRead(netpath,-1,-1);
|
*gzfile=COM_OpenRead(netpath,-1,-1);
|
||||||
return com_filesize;
|
return com_filesize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,13 +497,13 @@ pack_t *COM_LoadPackFile (char *packfile)
|
||||||
packfile_t *newfiles;
|
packfile_t *newfiles;
|
||||||
int numpackfiles;
|
int numpackfiles;
|
||||||
pack_t *pack;
|
pack_t *pack;
|
||||||
FILE *packhandle;
|
QFile *packhandle;
|
||||||
dpackfile_t info[MAX_FILES_IN_PACK];
|
dpackfile_t info[MAX_FILES_IN_PACK];
|
||||||
|
|
||||||
if (COM_FileOpenRead (packfile, &packhandle) == -1)
|
if (COM_FileOpenRead (packfile, &packhandle) == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
fread (&header, 1, sizeof(header), packhandle);
|
Qread (packhandle, &header, sizeof(header));
|
||||||
if (header.id[0] != 'P' || header.id[1] != 'A'
|
if (header.id[0] != 'P' || header.id[1] != 'A'
|
||||||
|| header.id[2] != 'C' || header.id[3] != 'K')
|
|| header.id[2] != 'C' || header.id[3] != 'K')
|
||||||
Sys_Error ("%s is not a packfile", packfile);
|
Sys_Error ("%s is not a packfile", packfile);
|
||||||
|
@ -517,8 +517,8 @@ pack_t *COM_LoadPackFile (char *packfile)
|
||||||
|
|
||||||
newfiles = Z_Malloc (numpackfiles * sizeof(packfile_t));
|
newfiles = Z_Malloc (numpackfiles * sizeof(packfile_t));
|
||||||
|
|
||||||
fseek (packhandle, header.dirofs, SEEK_SET);
|
Qseek (packhandle, header.dirofs, SEEK_SET);
|
||||||
fread (info, 1, header.dirlen, packhandle);
|
Qread (packhandle, info, header.dirlen);
|
||||||
|
|
||||||
|
|
||||||
// parse the directory
|
// parse the directory
|
||||||
|
@ -778,7 +778,7 @@ void COM_Gamedir (char *dir)
|
||||||
{
|
{
|
||||||
if (com_searchpaths->pack)
|
if (com_searchpaths->pack)
|
||||||
{
|
{
|
||||||
fclose (com_searchpaths->pack->handle);
|
Qclose (com_searchpaths->pack->handle);
|
||||||
Z_Free (com_searchpaths->pack->files);
|
Z_Free (com_searchpaths->pack->files);
|
||||||
Z_Free (com_searchpaths->pack);
|
Z_Free (com_searchpaths->pack);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,23 @@ QFile *Qopen(const char *path, const char *mode)
|
||||||
{
|
{
|
||||||
QFile *file;
|
QFile *file;
|
||||||
file=calloc(sizeof(*file),1);
|
file=calloc(sizeof(*file),1);
|
||||||
|
if (!file)
|
||||||
|
return 0;
|
||||||
file->file=fopen(path,mode);
|
file->file=fopen(path,mode);
|
||||||
|
if (!file->file)
|
||||||
|
return 0;
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFile *Qdopen(int fd, const char *mode)
|
||||||
|
{
|
||||||
|
QFile *file;
|
||||||
|
file=calloc(sizeof(*file),1);
|
||||||
|
if (!file)
|
||||||
|
return 0;
|
||||||
|
file->file=fdopen(fd,mode);
|
||||||
|
if (!file->file)
|
||||||
|
return 0;
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,6 +84,22 @@ char *Qgets(QFile *file, char *buf, int count)
|
||||||
return gzgets(file->gzfile,buf,count);
|
return gzgets(file->gzfile,buf,count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Qgetc(QFile *file)
|
||||||
|
{
|
||||||
|
if (file->file)
|
||||||
|
return fgetc(file->file);
|
||||||
|
else
|
||||||
|
return gzgetc(file->gzfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
int Qputc(QFile *file, int c)
|
||||||
|
{
|
||||||
|
if (file->file)
|
||||||
|
return fputc(c, file->file);
|
||||||
|
else
|
||||||
|
return gzputc(file->gzfile,c);
|
||||||
|
}
|
||||||
|
|
||||||
int Qseek(QFile *file, long offset, int whence)
|
int Qseek(QFile *file, long offset, int whence)
|
||||||
{
|
{
|
||||||
if (file->file)
|
if (file->file)
|
||||||
|
@ -91,3 +123,11 @@ int Qflush(QFile *file)
|
||||||
else
|
else
|
||||||
return gzflush(file->gzfile,Z_SYNC_FLUSH);
|
return gzflush(file->gzfile,Z_SYNC_FLUSH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Qeof(QFile *file)
|
||||||
|
{
|
||||||
|
if (file->file)
|
||||||
|
return feof(file->file);
|
||||||
|
else
|
||||||
|
return gzeof(file->gzfile);
|
||||||
|
}
|
||||||
|
|
|
@ -14,13 +14,18 @@ typedef struct {
|
||||||
} QFile;
|
} QFile;
|
||||||
|
|
||||||
QFile *Qopen(const char *path, const char *mode);
|
QFile *Qopen(const char *path, const char *mode);
|
||||||
|
QFile *Qdopen(int fd, const char *mode);
|
||||||
void Qclose(QFile *file);
|
void Qclose(QFile *file);
|
||||||
int Qread(QFile *file, void *buf, int count);
|
int Qread(QFile *file, void *buf, int count);
|
||||||
int Qwrite(QFile *file, void *buf, int count);
|
int Qwrite(QFile *file, void *buf, int count);
|
||||||
int Qprintf(QFile *file, const char *fmt, ...);
|
int Qprintf(QFile *file, const char *fmt, ...);
|
||||||
char *Qgets(QFile *file, char *buf, int count);
|
char *Qgets(QFile *file, char *buf, int count);
|
||||||
|
int Qgetc(QFile *file);
|
||||||
|
int Qputc(QFile *file, int c);
|
||||||
int Qseek(QFile *file, long offset, int whence);
|
int Qseek(QFile *file, long offset, int whence);
|
||||||
long Qtell(QFile *file);
|
long Qtell(QFile *file);
|
||||||
int Qflush(QFile *file);
|
int Qflush(QFile *file);
|
||||||
|
int Qeof(QFile *file);
|
||||||
|
|
||||||
|
|
||||||
#endif /*__quake_io_h*/
|
#endif /*__quake_io_h*/
|
||||||
|
|
|
@ -33,9 +33,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#define INI_STRING_SIZE 0x100
|
#define INI_STRING_SIZE 0x100
|
||||||
|
|
||||||
FILE *ini_fopen(const char *filename, const char *modes);
|
QFile *ini_fopen(const char *filename, const char *modes);
|
||||||
int ini_fclose(FILE *f);
|
int ini_fclose(QFile *f);
|
||||||
void ini_fgets(FILE *f, const char *section, const char *field, char *s);
|
void ini_fgets(QFile *f, const char *section, const char *field, char *s);
|
||||||
|
|
||||||
// Routines for reading from .INI files
|
// Routines for reading from .INI files
|
||||||
// The read routines are fairly efficient.
|
// The read routines are fairly efficient.
|
||||||
|
@ -61,7 +61,7 @@ struct field_buffer
|
||||||
char name[MAX_FIELD_WIDTH+1];
|
char name[MAX_FIELD_WIDTH+1];
|
||||||
};
|
};
|
||||||
|
|
||||||
static FILE *current_file=NULL;
|
static QFile *current_file=NULL;
|
||||||
static int current_section;
|
static int current_section;
|
||||||
|
|
||||||
static int current_section_buffer=0;
|
static int current_section_buffer=0;
|
||||||
|
@ -79,7 +79,7 @@ static char toupper(char c)
|
||||||
return(c);
|
return(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void reset_buffer(FILE *f)
|
static void reset_buffer(QFile *f)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ static void add_field(char *instring, int section, long offset)
|
||||||
|
|
||||||
// Identical to fgets except the string is trucated at the first ';',
|
// Identical to fgets except the string is trucated at the first ';',
|
||||||
// carriage return or line feed.
|
// carriage return or line feed.
|
||||||
static char *stripped_fgets(char *s, int n, FILE *f)
|
static char *stripped_fgets(char *s, int n, QFile *f)
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
|
|
||||||
|
@ -336,13 +336,13 @@ static char *stripped_fgets(char *s, int n, FILE *f)
|
||||||
// Externally accessable routines
|
// Externally accessable routines
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
// Opens an .INI file. Works like fopen
|
// Opens an .INI file. Works like fopen
|
||||||
FILE *ini_fopen(const char *filename, const char *modes)
|
QFile *ini_fopen(const char *filename, const char *modes)
|
||||||
{
|
{
|
||||||
return(fopen(filename,modes));
|
return(fopen(filename,modes));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Closes a .INI file. Works like fclose
|
// Closes a .INI file. Works like fclose
|
||||||
int ini_fclose(FILE *f)
|
int ini_fclose(QFile *f)
|
||||||
{
|
{
|
||||||
if (f==current_file)
|
if (f==current_file)
|
||||||
reset_buffer(NULL);
|
reset_buffer(NULL);
|
||||||
|
@ -352,7 +352,7 @@ int ini_fclose(FILE *f)
|
||||||
// Puts "field" from "section" from .ini file "f" into "s".
|
// Puts "field" from "section" from .ini file "f" into "s".
|
||||||
// If "section" does not exist or "field" does not exist in
|
// If "section" does not exist or "field" does not exist in
|
||||||
// section then s="";
|
// section then s="";
|
||||||
void ini_fgets(FILE *f, const char *section, const char *field, char *s)
|
void ini_fgets(QFile *f, const char *section, const char *field, char *s)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
long start_pos,string_start_pos;
|
long start_pos,string_start_pos;
|
||||||
|
@ -662,7 +662,7 @@ void ClearGf1Ints(void)
|
||||||
static qboolean GUS_GetIWData(void)
|
static qboolean GUS_GetIWData(void)
|
||||||
{
|
{
|
||||||
char *Interwave,s[INI_STRING_SIZE];
|
char *Interwave,s[INI_STRING_SIZE];
|
||||||
FILE *IwFile;
|
QFile *IwFile;
|
||||||
int CodecBase,CodecDma,i;
|
int CodecBase,CodecDma,i;
|
||||||
|
|
||||||
Interwave=getenv("INTERWAVE");
|
Interwave=getenv("INTERWAVE");
|
||||||
|
|
|
@ -131,7 +131,7 @@ int Sys_FileTime (char *path)
|
||||||
|
|
||||||
if (stat(path, &buf) == 0) ret = buf.st_mtime;
|
if (stat(path, &buf) == 0) ret = buf.st_mtime;
|
||||||
#else /* HAVE_STAT */
|
#else /* HAVE_STAT */
|
||||||
FILE *f;
|
QFile *f;
|
||||||
#if defined(_WIN32) && !defined(SERVERONLY)
|
#if defined(_WIN32) && !defined(SERVERONLY)
|
||||||
int t = VID_ForceUnlockedAndReturnState();
|
int t = VID_ForceUnlockedAndReturnState();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -171,7 +171,7 @@ void Sys_DebugLog(char *file, char *fmt, ...) {
|
||||||
|
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
static char data[1024];
|
static char data[1024];
|
||||||
FILE *stream;
|
QFile *stream;
|
||||||
unsigned char *p;
|
unsigned char *p;
|
||||||
//int fd;
|
//int fd;
|
||||||
|
|
||||||
|
@ -179,11 +179,11 @@ void Sys_DebugLog(char *file, char *fmt, ...) {
|
||||||
vsnprintf(data, sizeof(data), fmt, argptr);
|
vsnprintf(data, sizeof(data), fmt, argptr);
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
// fd = open(file, O_WRONLY | O_BINARY | O_CREAT | O_APPEND, 0666);
|
// fd = open(file, O_WRONLY | O_BINARY | O_CREAT | O_APPEND, 0666);
|
||||||
stream = fopen(file, "a");
|
stream = Qopen(file, "a");
|
||||||
for (p = (unsigned char *) data; *p; p++) {
|
for (p = (unsigned char *) data; *p; p++) {
|
||||||
putc(trans_table[*p], stream);
|
Qputc(stream, trans_table[*p]);
|
||||||
}
|
}
|
||||||
fclose(stream);
|
Qclose(stream);
|
||||||
/*
|
/*
|
||||||
fd = open(file, O_WRONLY | O_CREAT | O_APPEND, 0666);
|
fd = open(file, O_WRONLY | O_CREAT | O_APPEND, 0666);
|
||||||
write(fd, data, strlen(data));
|
write(fd, data, strlen(data));
|
||||||
|
|
|
@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MAX_HANDLES 10
|
#define MAX_HANDLES 10
|
||||||
FILE *sys_handles[MAX_HANDLES];
|
QFile *sys_handles[MAX_HANDLES];
|
||||||
|
|
||||||
int findhandle (void)
|
int findhandle (void)
|
||||||
{
|
{
|
||||||
|
@ -47,7 +47,7 @@ int findhandle (void)
|
||||||
filelength
|
filelength
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
int filelength (FILE *f)
|
int filelength (QFile *f)
|
||||||
{
|
{
|
||||||
int pos;
|
int pos;
|
||||||
int end;
|
int end;
|
||||||
|
@ -62,7 +62,7 @@ int filelength (FILE *f)
|
||||||
|
|
||||||
int Sys_FileOpenRead (char *path, int *hndl)
|
int Sys_FileOpenRead (char *path, int *hndl)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = findhandle ();
|
i = findhandle ();
|
||||||
|
@ -81,7 +81,7 @@ int Sys_FileOpenRead (char *path, int *hndl)
|
||||||
|
|
||||||
int Sys_FileOpenWrite (char *path)
|
int Sys_FileOpenWrite (char *path)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = findhandle ();
|
i = findhandle ();
|
||||||
|
|
|
@ -88,7 +88,7 @@ typedef struct
|
||||||
uLong crc32_wait; /* crc32 we must obtain after decompress all */
|
uLong crc32_wait; /* crc32 we must obtain after decompress all */
|
||||||
uLong rest_read_compressed; /* number of byte to be decompressed */
|
uLong rest_read_compressed; /* number of byte to be decompressed */
|
||||||
uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/
|
uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/
|
||||||
FILE* file; /* io structore of the zipfile */
|
QFile* file; /* io structore of the zipfile */
|
||||||
uLong compression_method; /* compression method (0==store) */
|
uLong compression_method; /* compression method (0==store) */
|
||||||
uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
|
uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
|
||||||
} file_in_zip_read_info_s;
|
} file_in_zip_read_info_s;
|
||||||
|
@ -98,7 +98,7 @@ typedef struct
|
||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
FILE* file; /* io structore of the zipfile */
|
QFile* file; /* io structore of the zipfile */
|
||||||
unz_global_info gi; /* public global information */
|
unz_global_info gi; /* public global information */
|
||||||
uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
|
uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
|
||||||
uLong num_file; /* number of the current file in the zipfile*/
|
uLong num_file; /* number of the current file in the zipfile*/
|
||||||
|
@ -125,7 +125,7 @@ typedef struct
|
||||||
|
|
||||||
|
|
||||||
local int unzlocal_getByte(fin,pi)
|
local int unzlocal_getByte(fin,pi)
|
||||||
FILE *fin;
|
QFile *fin;
|
||||||
int *pi;
|
int *pi;
|
||||||
{
|
{
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
|
@ -149,7 +149,7 @@ local int unzlocal_getByte(fin,pi)
|
||||||
Reads a long in LSB order from the given gz_stream. Sets
|
Reads a long in LSB order from the given gz_stream. Sets
|
||||||
*/
|
*/
|
||||||
local int unzlocal_getShort (fin,pX)
|
local int unzlocal_getShort (fin,pX)
|
||||||
FILE* fin;
|
QFile* fin;
|
||||||
uLong *pX;
|
uLong *pX;
|
||||||
{
|
{
|
||||||
uLong x ;
|
uLong x ;
|
||||||
|
@ -171,7 +171,7 @@ local int unzlocal_getShort (fin,pX)
|
||||||
}
|
}
|
||||||
|
|
||||||
local int unzlocal_getLong (fin,pX)
|
local int unzlocal_getLong (fin,pX)
|
||||||
FILE* fin;
|
QFile* fin;
|
||||||
uLong *pX;
|
uLong *pX;
|
||||||
{
|
{
|
||||||
uLong x ;
|
uLong x ;
|
||||||
|
@ -266,7 +266,7 @@ extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivit
|
||||||
the global comment)
|
the global comment)
|
||||||
*/
|
*/
|
||||||
local uLong unzlocal_SearchCentralDir(fin)
|
local uLong unzlocal_SearchCentralDir(fin)
|
||||||
FILE *fin;
|
QFile *fin;
|
||||||
{
|
{
|
||||||
unsigned char* buf;
|
unsigned char* buf;
|
||||||
uLong uSizeFile;
|
uLong uSizeFile;
|
||||||
|
@ -336,7 +336,7 @@ extern unzFile ZEXPORT unzOpen (path)
|
||||||
unz_s us;
|
unz_s us;
|
||||||
unz_s *s;
|
unz_s *s;
|
||||||
uLong central_pos,uL;
|
uLong central_pos,uL;
|
||||||
FILE * fin ;
|
QFile * fin ;
|
||||||
|
|
||||||
uLong number_disk; /* number of the current dist, used for
|
uLong number_disk; /* number of the current dist, used for
|
||||||
spaning ZIP, unsupported, always 0*/
|
spaning ZIP, unsupported, always 0*/
|
||||||
|
|
|
@ -538,7 +538,7 @@ CL_ParseServerData
|
||||||
void CL_ParseServerData (void)
|
void CL_ParseServerData (void)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
FILE *f;
|
QFile *f;
|
||||||
char fn[MAX_OSPATH];
|
char fn[MAX_OSPATH];
|
||||||
qboolean cflag = false;
|
qboolean cflag = false;
|
||||||
extern char gamedirfile[MAX_OSPATH];
|
extern char gamedirfile[MAX_OSPATH];
|
||||||
|
@ -580,8 +580,8 @@ void CL_ParseServerData (void)
|
||||||
//if it exists
|
//if it exists
|
||||||
if (cflag) {
|
if (cflag) {
|
||||||
snprintf(fn, sizeof(fn), "%s/%s", com_gamedir, "config.cfg");
|
snprintf(fn, sizeof(fn), "%s/%s", com_gamedir, "config.cfg");
|
||||||
if ((f = fopen(fn, "r")) != NULL) {
|
if ((f = Qopen(fn, "r")) != NULL) {
|
||||||
fclose(f);
|
Qclose(f);
|
||||||
Cbuf_AddText ("cl_warncmd 0\n");
|
Cbuf_AddText ("cl_warncmd 0\n");
|
||||||
Cbuf_AddText("exec config.cfg\n");
|
Cbuf_AddText("exec config.cfg\n");
|
||||||
Cbuf_AddText("exec frontend.cfg\n");
|
Cbuf_AddText("exec frontend.cfg\n");
|
||||||
|
|
|
@ -84,7 +84,7 @@ FILE IO
|
||||||
filelength
|
filelength
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
int filelength (FILE *f)
|
int filelength (QFile *f)
|
||||||
{
|
{
|
||||||
int pos;
|
int pos;
|
||||||
int end;
|
int end;
|
||||||
|
|
|
@ -189,7 +189,7 @@ typedef struct client_s
|
||||||
|
|
||||||
qboolean upgradewarn; // did we warn him?
|
qboolean upgradewarn; // did we warn him?
|
||||||
|
|
||||||
FILE *upload;
|
QFile *upload;
|
||||||
char uploadfn[MAX_QPATH];
|
char uploadfn[MAX_QPATH];
|
||||||
netadr_t snap_from;
|
netadr_t snap_from;
|
||||||
qboolean remote_snap;
|
qboolean remote_snap;
|
||||||
|
@ -355,8 +355,8 @@ extern char localmodels[MAX_MODELS][5]; // inline model names for precache
|
||||||
extern char localinfo[MAX_LOCALINFO_STRING+1];
|
extern char localinfo[MAX_LOCALINFO_STRING+1];
|
||||||
|
|
||||||
extern int host_hunklevel;
|
extern int host_hunklevel;
|
||||||
extern FILE *sv_logfile;
|
extern QFile *sv_logfile;
|
||||||
extern FILE *sv_fraglogfile;
|
extern QFile *sv_fraglogfile;
|
||||||
|
|
||||||
//===========================================================
|
//===========================================================
|
||||||
|
|
||||||
|
|
|
@ -102,14 +102,14 @@ void SV_Logfile_f (void)
|
||||||
if (sv_logfile)
|
if (sv_logfile)
|
||||||
{
|
{
|
||||||
Con_Printf ("File logging off.\n");
|
Con_Printf ("File logging off.\n");
|
||||||
fclose (sv_logfile);
|
Qclose (sv_logfile);
|
||||||
sv_logfile = NULL;
|
sv_logfile = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(name, sizeof(name), "%s/qconsole.log", com_gamedir);
|
snprintf(name, sizeof(name), "%s/qconsole.log", com_gamedir);
|
||||||
Con_Printf ("Logging text to %s.\n", name);
|
Con_Printf ("Logging text to %s.\n", name);
|
||||||
sv_logfile = fopen (name, "w");
|
sv_logfile = Qopen (name, "w");
|
||||||
if (!sv_logfile)
|
if (!sv_logfile)
|
||||||
Con_Printf ("failed.\n");
|
Con_Printf ("failed.\n");
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ void SV_Fraglogfile_f (void)
|
||||||
if (sv_fraglogfile)
|
if (sv_fraglogfile)
|
||||||
{
|
{
|
||||||
Con_Printf ("Frag file logging off.\n");
|
Con_Printf ("Frag file logging off.\n");
|
||||||
fclose (sv_fraglogfile);
|
Qclose (sv_fraglogfile);
|
||||||
sv_fraglogfile = NULL;
|
sv_fraglogfile = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -137,15 +137,15 @@ void SV_Fraglogfile_f (void)
|
||||||
for (i=0 ; i<1000 ; i++)
|
for (i=0 ; i<1000 ; i++)
|
||||||
{
|
{
|
||||||
snprintf(name, sizeof(name), "%s/frag_%i.log", com_gamedir, i);
|
snprintf(name, sizeof(name), "%s/frag_%i.log", com_gamedir, i);
|
||||||
sv_fraglogfile = fopen (name, "r");
|
sv_fraglogfile = Qopen (name, "r");
|
||||||
if (!sv_fraglogfile)
|
if (!sv_fraglogfile)
|
||||||
{ // can't read it, so create this one
|
{ // can't read it, so create this one
|
||||||
sv_fraglogfile = fopen (name, "w");
|
sv_fraglogfile = Qopen (name, "w");
|
||||||
if (!sv_fraglogfile)
|
if (!sv_fraglogfile)
|
||||||
i=1000; // give error
|
i=1000; // give error
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fclose (sv_fraglogfile);
|
Qclose (sv_fraglogfile);
|
||||||
}
|
}
|
||||||
if (i==1000)
|
if (i==1000)
|
||||||
{
|
{
|
||||||
|
@ -331,7 +331,7 @@ void SV_Map_f (void)
|
||||||
Con_Printf ("Can't find %s\n", expanded);
|
Con_Printf ("Can't find %s\n", expanded);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gzclose (f);
|
Qclose (f);
|
||||||
|
|
||||||
SV_BroadcastCommand ("changing\n");
|
SV_BroadcastCommand ("changing\n");
|
||||||
SV_SendMessagesToAll ();
|
SV_SendMessagesToAll ();
|
||||||
|
|
|
@ -83,8 +83,8 @@ cvar_t watervis = {"watervis", "0", false, true};
|
||||||
|
|
||||||
cvar_t hostname = {"hostname","unnamed", false, true};
|
cvar_t hostname = {"hostname","unnamed", false, true};
|
||||||
|
|
||||||
FILE *sv_logfile;
|
QFile *sv_logfile;
|
||||||
FILE *sv_fraglogfile;
|
QFile *sv_fraglogfile;
|
||||||
|
|
||||||
void SV_AcceptClient (netadr_t adr, int userid, char *userinfo);
|
void SV_AcceptClient (netadr_t adr, int userid, char *userinfo);
|
||||||
|
|
||||||
|
@ -108,12 +108,12 @@ void SV_Shutdown (void)
|
||||||
Shutdown_Master ();
|
Shutdown_Master ();
|
||||||
if (sv_logfile)
|
if (sv_logfile)
|
||||||
{
|
{
|
||||||
fclose (sv_logfile);
|
Qclose (sv_logfile);
|
||||||
sv_logfile = NULL;
|
sv_logfile = NULL;
|
||||||
}
|
}
|
||||||
if (sv_fraglogfile)
|
if (sv_fraglogfile)
|
||||||
{
|
{
|
||||||
fclose (sv_fraglogfile);
|
Qclose (sv_fraglogfile);
|
||||||
sv_logfile = NULL;
|
sv_logfile = NULL;
|
||||||
}
|
}
|
||||||
NET_Shutdown ();
|
NET_Shutdown ();
|
||||||
|
@ -218,12 +218,12 @@ void SV_DropClient (client_t *drop)
|
||||||
|
|
||||||
if (drop->download)
|
if (drop->download)
|
||||||
{
|
{
|
||||||
gzclose (drop->download);
|
Qclose (drop->download);
|
||||||
drop->download = NULL;
|
drop->download = NULL;
|
||||||
}
|
}
|
||||||
if (drop->upload)
|
if (drop->upload)
|
||||||
{
|
{
|
||||||
fclose (drop->upload);
|
Qclose (drop->upload);
|
||||||
drop->upload = NULL;
|
drop->upload = NULL;
|
||||||
}
|
}
|
||||||
*drop->uploadfn = 0;
|
*drop->uploadfn = 0;
|
||||||
|
@ -1010,7 +1010,7 @@ SV_WriteIP_f
|
||||||
*/
|
*/
|
||||||
void SV_WriteIP_f (void)
|
void SV_WriteIP_f (void)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
char name[MAX_OSPATH];
|
char name[MAX_OSPATH];
|
||||||
byte b[4];
|
byte b[4];
|
||||||
int i;
|
int i;
|
||||||
|
@ -1019,7 +1019,7 @@ void SV_WriteIP_f (void)
|
||||||
|
|
||||||
Con_Printf ("Writing %s.\n", name);
|
Con_Printf ("Writing %s.\n", name);
|
||||||
|
|
||||||
f = fopen (name, "wb");
|
f = Qopen (name, "wb");
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
Con_Printf ("Couldn't open %s\n", name);
|
Con_Printf ("Couldn't open %s\n", name);
|
||||||
|
@ -1029,10 +1029,10 @@ void SV_WriteIP_f (void)
|
||||||
for (i=0 ; i<numipfilters ; i++)
|
for (i=0 ; i<numipfilters ; i++)
|
||||||
{
|
{
|
||||||
*(unsigned *)b = ipfilters[i].compare;
|
*(unsigned *)b = ipfilters[i].compare;
|
||||||
fprintf (f, "addip %i.%i.%i.%i\n", b[0], b[1], b[2], b[3]);
|
Qprintf (f, "addip %i.%i.%i.%i\n", b[0], b[1], b[2], b[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -125,7 +125,7 @@ void Con_Printf (char *fmt, ...)
|
||||||
|
|
||||||
Sys_Printf ("%s", msg); // also echo to debugging console
|
Sys_Printf ("%s", msg); // also echo to debugging console
|
||||||
if (sv_logfile)
|
if (sv_logfile)
|
||||||
fprintf (sv_logfile, "%s", msg);
|
Qprintf (sv_logfile, "%s", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -533,7 +533,7 @@ void SV_NextDownload_f (void)
|
||||||
r = host_client->downloadsize - host_client->downloadcount;
|
r = host_client->downloadsize - host_client->downloadcount;
|
||||||
if (r > 768)
|
if (r > 768)
|
||||||
r = 768;
|
r = 768;
|
||||||
r = gzread (host_client->download, buffer, r);
|
r = Qread (host_client->download, buffer, r);
|
||||||
ClientReliableWrite_Begin (host_client, svc_download, 6+r);
|
ClientReliableWrite_Begin (host_client, svc_download, 6+r);
|
||||||
ClientReliableWrite_Short (host_client, r);
|
ClientReliableWrite_Short (host_client, r);
|
||||||
|
|
||||||
|
@ -548,7 +548,7 @@ void SV_NextDownload_f (void)
|
||||||
if (host_client->downloadcount != host_client->downloadsize)
|
if (host_client->downloadcount != host_client->downloadsize)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gzclose (host_client->download);
|
Qclose (host_client->download);
|
||||||
host_client->download = NULL;
|
host_client->download = NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -596,7 +596,7 @@ void SV_NextUpload (void)
|
||||||
|
|
||||||
if (!host_client->upload)
|
if (!host_client->upload)
|
||||||
{
|
{
|
||||||
host_client->upload = fopen(host_client->uploadfn, "wb");
|
host_client->upload = Qopen(host_client->uploadfn, "wb");
|
||||||
if (!host_client->upload) {
|
if (!host_client->upload) {
|
||||||
Sys_Printf("Can't create %s\n", host_client->uploadfn);
|
Sys_Printf("Can't create %s\n", host_client->uploadfn);
|
||||||
ClientReliableWrite_Begin (host_client, svc_stufftext, 8);
|
ClientReliableWrite_Begin (host_client, svc_stufftext, 8);
|
||||||
|
@ -609,7 +609,7 @@ void SV_NextUpload (void)
|
||||||
OutofBandPrintf(host_client->snap_from, "Server receiving %s from %d...\n", host_client->uploadfn, host_client->userid);
|
OutofBandPrintf(host_client->snap_from, "Server receiving %s from %d...\n", host_client->uploadfn, host_client->userid);
|
||||||
}
|
}
|
||||||
|
|
||||||
fwrite (net_message.data + msg_readcount, 1, size, host_client->upload);
|
Qwrite (host_client->upload, net_message.data + msg_readcount, size);
|
||||||
msg_readcount += size;
|
msg_readcount += size;
|
||||||
|
|
||||||
Con_DPrintf ("UPLOAD: %d received\n", size);
|
Con_DPrintf ("UPLOAD: %d received\n", size);
|
||||||
|
@ -618,7 +618,7 @@ Con_DPrintf ("UPLOAD: %d received\n", size);
|
||||||
ClientReliableWrite_Begin (host_client, svc_stufftext, 8);
|
ClientReliableWrite_Begin (host_client, svc_stufftext, 8);
|
||||||
ClientReliableWrite_String (host_client, "nextul\n");
|
ClientReliableWrite_String (host_client, "nextul\n");
|
||||||
} else {
|
} else {
|
||||||
fclose (host_client->upload);
|
Qclose (host_client->upload);
|
||||||
host_client->upload = NULL;
|
host_client->upload = NULL;
|
||||||
|
|
||||||
Sys_Printf("%s upload completed.\n", host_client->uploadfn);
|
Sys_Printf("%s upload completed.\n", host_client->uploadfn);
|
||||||
|
@ -678,7 +678,7 @@ void SV_BeginDownload_f(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (host_client->download) {
|
if (host_client->download) {
|
||||||
gzclose (host_client->download);
|
Qclose (host_client->download);
|
||||||
host_client->download = NULL;
|
host_client->download = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -700,7 +700,7 @@ void SV_BeginDownload_f(void)
|
||||||
|| (strncmp(name, "maps/", 5) == 0 && file_from_pak))
|
|| (strncmp(name, "maps/", 5) == 0 && file_from_pak))
|
||||||
{
|
{
|
||||||
if (host_client->download) {
|
if (host_client->download) {
|
||||||
gzclose(host_client->download);
|
Qclose(host_client->download);
|
||||||
host_client->download = NULL;
|
host_client->download = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ void CL_StopPlayback (void)
|
||||||
if (!cls.demoplayback)
|
if (!cls.demoplayback)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gzclose (cls.demofile);
|
Qclose (cls.demofile);
|
||||||
cls.demoplayback = false;
|
cls.demoplayback = false;
|
||||||
cls.demofile = NULL;
|
cls.demofile = NULL;
|
||||||
cls.state = ca_disconnected;
|
cls.state = ca_disconnected;
|
||||||
|
@ -80,14 +80,14 @@ void CL_WriteDemoMessage (void)
|
||||||
float f;
|
float f;
|
||||||
|
|
||||||
len = LittleLong (net_message.cursize);
|
len = LittleLong (net_message.cursize);
|
||||||
gzwrite (cls.demofile, &len, 4);
|
Qwrite (cls.demofile, &len, 4);
|
||||||
for (i=0 ; i<3 ; i++)
|
for (i=0 ; i<3 ; i++)
|
||||||
{
|
{
|
||||||
f = LittleFloat (cl.viewangles[i]);
|
f = LittleFloat (cl.viewangles[i]);
|
||||||
gzwrite (cls.demofile, &f, 4);
|
Qwrite (cls.demofile, &f, 4);
|
||||||
}
|
}
|
||||||
gzwrite (cls.demofile, net_message.data, net_message.cursize);
|
Qwrite (cls.demofile, net_message.data, net_message.cursize);
|
||||||
gzflush (cls.demofile, Z_SYNC_FLUSH);
|
Qflush (cls.demofile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -124,18 +124,18 @@ int CL_GetMessage (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the next message
|
// get the next message
|
||||||
gzread (cls.demofile, &net_message.cursize, 4);
|
Qread (cls.demofile, &net_message.cursize, 4);
|
||||||
VectorCopy (cl.mviewangles[0], cl.mviewangles[1]);
|
VectorCopy (cl.mviewangles[0], cl.mviewangles[1]);
|
||||||
for (i=0 ; i<3 ; i++)
|
for (i=0 ; i<3 ; i++)
|
||||||
{
|
{
|
||||||
r = gzread (cls.demofile, &f, 4);
|
r = Qread (cls.demofile, &f, 4);
|
||||||
cl.mviewangles[0][i] = LittleFloat (f);
|
cl.mviewangles[0][i] = LittleFloat (f);
|
||||||
}
|
}
|
||||||
|
|
||||||
net_message.cursize = LittleLong (net_message.cursize);
|
net_message.cursize = LittleLong (net_message.cursize);
|
||||||
if (net_message.cursize > MAX_MSGLEN)
|
if (net_message.cursize > MAX_MSGLEN)
|
||||||
Sys_Error ("Demo message > MAX_MSGLEN");
|
Sys_Error ("Demo message > MAX_MSGLEN");
|
||||||
r = gzread (cls.demofile, net_message.data, net_message.cursize);
|
r = Qread (cls.demofile, net_message.data, net_message.cursize);
|
||||||
if (r != net_message.cursize)
|
if (r != net_message.cursize)
|
||||||
{
|
{
|
||||||
CL_StopPlayback ();
|
CL_StopPlayback ();
|
||||||
|
@ -190,7 +190,7 @@ void CL_Stop_f (void)
|
||||||
CL_WriteDemoMessage ();
|
CL_WriteDemoMessage ();
|
||||||
|
|
||||||
// finish up
|
// finish up
|
||||||
gzclose (cls.demofile);
|
Qclose (cls.demofile);
|
||||||
cls.demofile = NULL;
|
cls.demofile = NULL;
|
||||||
cls.demorecording = false;
|
cls.demorecording = false;
|
||||||
Con_Printf ("Completed demo\n");
|
Con_Printf ("Completed demo\n");
|
||||||
|
@ -254,7 +254,7 @@ void CL_Record_f (void)
|
||||||
COM_DefaultExtension (name, ".dem");
|
COM_DefaultExtension (name, ".dem");
|
||||||
|
|
||||||
Con_Printf ("recording to %s.\n", name);
|
Con_Printf ("recording to %s.\n", name);
|
||||||
cls.demofile = gzopen (name, "wb");
|
cls.demofile = Qopen (name, "wb");
|
||||||
if (!cls.demofile)
|
if (!cls.demofile)
|
||||||
{
|
{
|
||||||
Con_Printf ("ERROR: couldn't open.\n");
|
Con_Printf ("ERROR: couldn't open.\n");
|
||||||
|
@ -262,7 +262,7 @@ void CL_Record_f (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.forcetrack = track;
|
cls.forcetrack = track;
|
||||||
gzprintf (cls.demofile, "%i\n", cls.forcetrack);
|
Qprintf (cls.demofile, "%i\n", cls.forcetrack);
|
||||||
|
|
||||||
cls.demorecording = true;
|
cls.demorecording = true;
|
||||||
}
|
}
|
||||||
|
@ -314,7 +314,7 @@ void CL_PlayDemo_f (void)
|
||||||
cls.state = ca_connected;
|
cls.state = ca_connected;
|
||||||
cls.forcetrack = 0;
|
cls.forcetrack = 0;
|
||||||
|
|
||||||
while ((c = gzgetc(cls.demofile)) != '\n')
|
while ((c = Qgetc(cls.demofile)) != '\n')
|
||||||
if (c == '-')
|
if (c == '-')
|
||||||
neg = true;
|
neg = true;
|
||||||
else
|
else
|
||||||
|
|
|
@ -579,7 +579,7 @@ Host_Loadgame_f
|
||||||
void Host_Loadgame_f (void)
|
void Host_Loadgame_f (void)
|
||||||
{
|
{
|
||||||
char name[MAX_OSPATH];
|
char name[MAX_OSPATH];
|
||||||
FILE *f;
|
QFile *f;
|
||||||
char mapname[MAX_QPATH];
|
char mapname[MAX_QPATH];
|
||||||
float time, tfloat;
|
float time, tfloat;
|
||||||
char str[32768], *start;
|
char str[32768], *start;
|
||||||
|
@ -588,6 +588,7 @@ void Host_Loadgame_f (void)
|
||||||
int entnum;
|
int entnum;
|
||||||
int version;
|
int version;
|
||||||
float spawn_parms[NUM_SPAWN_PARMS];
|
float spawn_parms[NUM_SPAWN_PARMS];
|
||||||
|
char buf[100];
|
||||||
|
|
||||||
if (cmd_source != src_command)
|
if (cmd_source != src_command)
|
||||||
return;
|
return;
|
||||||
|
@ -608,25 +609,30 @@ void Host_Loadgame_f (void)
|
||||||
// SCR_BeginLoadingPlaque ();
|
// SCR_BeginLoadingPlaque ();
|
||||||
|
|
||||||
Con_Printf ("Loading game from %s...\n", name);
|
Con_Printf ("Loading game from %s...\n", name);
|
||||||
f = fopen (name, "r");
|
f = Qopen (name, "r");
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
Con_Printf ("ERROR: couldn't open.\n");
|
Con_Printf ("ERROR: couldn't open.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fscanf (f, "%i\n", &version);
|
Qgets(f,buf,sizeof(buf));
|
||||||
|
sscanf (buf, "%i\n", &version);
|
||||||
if (version != SAVEGAME_VERSION)
|
if (version != SAVEGAME_VERSION)
|
||||||
{
|
{
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
Con_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
|
Con_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fscanf (f, "%s\n", str);
|
Qgets(f,buf,sizeof(buf));
|
||||||
for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
|
sscanf (buf, "%s\n", str);
|
||||||
fscanf (f, "%f\n", &spawn_parms[i]);
|
for (i=0 ; i<NUM_SPAWN_PARMS ; i++) {
|
||||||
|
Qgets(f,buf,sizeof(buf));
|
||||||
|
sscanf (buf, "%f\n", &spawn_parms[i]);
|
||||||
|
}
|
||||||
// this silliness is so we can load 1.06 save files, which have float skill values
|
// this silliness is so we can load 1.06 save files, which have float skill values
|
||||||
fscanf (f, "%f\n", &tfloat);
|
Qgets(f,buf,sizeof(buf));
|
||||||
|
sscanf (buf, "%f\n", &tfloat);
|
||||||
current_skill = (int)(tfloat + 0.1);
|
current_skill = (int)(tfloat + 0.1);
|
||||||
Cvar_SetValue ("skill", (float)current_skill);
|
Cvar_SetValue ("skill", (float)current_skill);
|
||||||
|
|
||||||
|
@ -636,8 +642,10 @@ void Host_Loadgame_f (void)
|
||||||
Cvar_SetValue ("teamplay", 0);
|
Cvar_SetValue ("teamplay", 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fscanf (f, "%s\n",mapname);
|
Qgets(f,buf,sizeof(buf));
|
||||||
fscanf (f, "%f\n",&time);
|
sscanf (buf, "%s\n",mapname);
|
||||||
|
Qgets(f,buf,sizeof(buf));
|
||||||
|
sscanf (buf, "%f\n",&time);
|
||||||
|
|
||||||
CL_Disconnect_f ();
|
CL_Disconnect_f ();
|
||||||
|
|
||||||
|
@ -658,18 +666,19 @@ void Host_Loadgame_f (void)
|
||||||
|
|
||||||
for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
|
for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
|
||||||
{
|
{
|
||||||
fscanf (f, "%s\n", str);
|
Qgets(f,buf,sizeof(buf));
|
||||||
|
sscanf (buf, "%s\n", str);
|
||||||
sv.lightstyles[i] = Hunk_Alloc (strlen(str)+1);
|
sv.lightstyles[i] = Hunk_Alloc (strlen(str)+1);
|
||||||
strcpy (sv.lightstyles[i], str);
|
strcpy (sv.lightstyles[i], str);
|
||||||
}
|
}
|
||||||
|
|
||||||
// load the edicts out of the savegame file
|
// load the edicts out of the savegame file
|
||||||
entnum = -1; // -1 is the globals
|
entnum = -1; // -1 is the globals
|
||||||
while (!feof(f))
|
while (!Qeof(f))
|
||||||
{
|
{
|
||||||
for (i=0 ; i<sizeof(str)-1 ; i++)
|
for (i=0 ; i<sizeof(str)-1 ; i++)
|
||||||
{
|
{
|
||||||
r = fgetc (f);
|
r = Qgetc (f);
|
||||||
if (r == EOF || !r)
|
if (r == EOF || !r)
|
||||||
break;
|
break;
|
||||||
str[i] = r;
|
str[i] = r;
|
||||||
|
@ -712,7 +721,7 @@ void Host_Loadgame_f (void)
|
||||||
sv.num_edicts = entnum;
|
sv.num_edicts = entnum;
|
||||||
sv.time = time;
|
sv.time = time;
|
||||||
|
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
|
|
||||||
for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
|
for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
|
||||||
svs.clients->spawn_parms[i] = spawn_parms[i];
|
svs.clients->spawn_parms[i] = spawn_parms[i];
|
||||||
|
@ -728,7 +737,7 @@ void Host_Loadgame_f (void)
|
||||||
void SaveGamestate()
|
void SaveGamestate()
|
||||||
{
|
{
|
||||||
char name[256];
|
char name[256];
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int i;
|
int i;
|
||||||
char comment[SAVEGAME_COMMENT_LENGTH+1];
|
char comment[SAVEGAME_COMMENT_LENGTH+1];
|
||||||
edict_t *ent;
|
edict_t *ent;
|
||||||
|
@ -772,14 +781,14 @@ void SaveGamestate()
|
||||||
ED_Write (f, ent);
|
ED_Write (f, ent);
|
||||||
fflush (f);
|
fflush (f);
|
||||||
}
|
}
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
Con_Printf ("done.\n");
|
Con_Printf ("done.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int LoadGamestate(char *level, char *startspot)
|
int LoadGamestate(char *level, char *startspot)
|
||||||
{
|
{
|
||||||
char name[MAX_OSPATH];
|
char name[MAX_OSPATH];
|
||||||
FILE *f;
|
QFile *f;
|
||||||
char mapname[MAX_QPATH];
|
char mapname[MAX_QPATH];
|
||||||
float time, sk;
|
float time, sk;
|
||||||
char str[32768], *start;
|
char str[32768], *start;
|
||||||
|
@ -799,21 +808,28 @@ int LoadGamestate(char *level, char *startspot)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fscanf (f, "%i\n", &version);
|
Qgets(f,buf,sizeof(buf));
|
||||||
|
sscanf (buf, "%i\n", &version);
|
||||||
if (version != SAVEGAME_VERSION)
|
if (version != SAVEGAME_VERSION)
|
||||||
{
|
{
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
Con_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
|
Con_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fscanf (f, "%s\n", str);
|
Qgets(f,buf,sizeof(buf));
|
||||||
// for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
|
sscanf (buf, "%s\n", str);
|
||||||
// fscanf (f, "%f\n", &spawn_parms[i]);
|
// for (i=0 ; i<NUM_SPAWN_PARMS ; i++) {
|
||||||
fscanf (f, "%f\n", &sk);
|
// Qgets(f,buf,sizeof(buf));
|
||||||
|
// sscanf (buf, "%f\n", &spawn_parms[i]);
|
||||||
|
// }
|
||||||
|
Qgets(f,buf,sizeof(buf));
|
||||||
|
sscanf (buf, "%f\n", &sk);
|
||||||
Cvar_SetValue ("skill", sk);
|
Cvar_SetValue ("skill", sk);
|
||||||
|
|
||||||
fscanf (f, "%s\n",mapname);
|
Qgets(f,buf,sizeof(buf));
|
||||||
fscanf (f, "%f\n",&time);
|
sscanf (buf, "%s\n",mapname);
|
||||||
|
Qgets(f,buf,sizeof(buf));
|
||||||
|
sscanf (buf, "%f\n",&time);
|
||||||
|
|
||||||
SV_SpawnServer (mapname, startspot);
|
SV_SpawnServer (mapname, startspot);
|
||||||
|
|
||||||
|
@ -826,7 +842,8 @@ int LoadGamestate(char *level, char *startspot)
|
||||||
// load the light styles
|
// load the light styles
|
||||||
for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
|
for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
|
||||||
{
|
{
|
||||||
fscanf (f, "%s\n", str);
|
Qgets(f,buf,sizeof(buf));
|
||||||
|
sscanf (buf, "%s\n", str);
|
||||||
sv.lightstyles[i] = Hunk_Alloc (strlen(str)+1);
|
sv.lightstyles[i] = Hunk_Alloc (strlen(str)+1);
|
||||||
strcpy (sv.lightstyles[i], str);
|
strcpy (sv.lightstyles[i], str);
|
||||||
}
|
}
|
||||||
|
@ -834,10 +851,11 @@ int LoadGamestate(char *level, char *startspot)
|
||||||
// load the edicts out of the savegame file
|
// load the edicts out of the savegame file
|
||||||
while (!feof(f))
|
while (!feof(f))
|
||||||
{
|
{
|
||||||
fscanf (f, "%i\n",&entnum);
|
Qgets(f,buf,sizeof(buf));
|
||||||
|
sscanf (buf, "%i\n",&entnum);
|
||||||
for (i=0 ; i<sizeof(str)-1 ; i++)
|
for (i=0 ; i<sizeof(str)-1 ; i++)
|
||||||
{
|
{
|
||||||
r = fgetc (f);
|
r = Qgetc (f);
|
||||||
if (r == EOF || !r)
|
if (r == EOF || !r)
|
||||||
break;
|
break;
|
||||||
str[i] = r;
|
str[i] = r;
|
||||||
|
@ -871,7 +889,7 @@ int LoadGamestate(char *level, char *startspot)
|
||||||
|
|
||||||
// sv.num_edicts = entnum;
|
// sv.num_edicts = entnum;
|
||||||
sv.time = time;
|
sv.time = time;
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
|
|
||||||
// for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
|
// for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
|
||||||
// svs.clients->spawn_parms[i] = spawn_parms[i];
|
// svs.clients->spawn_parms[i] = spawn_parms[i];
|
||||||
|
|
|
@ -473,19 +473,22 @@ void M_ScanSaves (void)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
char name[MAX_OSPATH];
|
char name[MAX_OSPATH];
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int version;
|
int version;
|
||||||
|
char buf[100];
|
||||||
|
|
||||||
for (i=0 ; i<MAX_SAVEGAMES ; i++)
|
for (i=0 ; i<MAX_SAVEGAMES ; i++)
|
||||||
{
|
{
|
||||||
strcpy (m_filenames[i], "--- UNUSED SLOT ---");
|
strcpy (m_filenames[i], "--- UNUSED SLOT ---");
|
||||||
loadable[i] = false;
|
loadable[i] = false;
|
||||||
snprintf(name, sizeof(name), "%s/s%i.sav", com_gamedir, i);
|
snprintf(name, sizeof(name), "%s/s%i.sav", com_gamedir, i);
|
||||||
f = fopen (name, "r");
|
f = Qopen (name, "r");
|
||||||
if (!f)
|
if (!f)
|
||||||
continue;
|
continue;
|
||||||
fscanf (f, "%i\n", &version);
|
Qgets(f,buf,sizeof(buf));
|
||||||
fscanf (f, "%79s\n", name);
|
sscanf (buf, "%i\n", &version);
|
||||||
|
Qgets(f,buf,sizeof(buf));
|
||||||
|
sscanf (buf, "%79s\n", name);
|
||||||
strncpy (m_filenames[i], name, sizeof(m_filenames[i])-1);
|
strncpy (m_filenames[i], name, sizeof(m_filenames[i])-1);
|
||||||
|
|
||||||
// change _ back to space
|
// change _ back to space
|
||||||
|
@ -493,7 +496,7 @@ void M_ScanSaves (void)
|
||||||
if (m_filenames[i][j] == '_')
|
if (m_filenames[i][j] == '_')
|
||||||
m_filenames[i][j] = ' ';
|
m_filenames[i][j] = ' ';
|
||||||
loadable[i] = true;
|
loadable[i] = true;
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ FILE IO
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
FILE *hFile;
|
QFile *hFile;
|
||||||
char *pMap;
|
char *pMap;
|
||||||
int nLen;
|
int nLen;
|
||||||
int nPos;
|
int nPos;
|
||||||
|
@ -84,7 +84,7 @@ int findhandle (void)
|
||||||
filelength
|
filelength
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
int filelength (FILE *f)
|
int filelength (QFile *f)
|
||||||
{
|
{
|
||||||
int pos;
|
int pos;
|
||||||
int end;
|
int end;
|
||||||
|
@ -99,7 +99,7 @@ int filelength (FILE *f)
|
||||||
|
|
||||||
int Sys_FileOpenRead (char *path, int *hndl)
|
int Sys_FileOpenRead (char *path, int *hndl)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = findhandle ();
|
i = findhandle ();
|
||||||
|
@ -127,7 +127,7 @@ int Sys_FileOpenRead (char *path, int *hndl)
|
||||||
|
|
||||||
int Sys_FileOpenWrite (char *path)
|
int Sys_FileOpenWrite (char *path)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = findhandle ();
|
i = findhandle ();
|
||||||
|
@ -188,7 +188,7 @@ void Sys_DebugLog(char *file, char *fmt, ...) {
|
||||||
|
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
static char data[1024];
|
static char data[1024];
|
||||||
FILE *stream;
|
QFile *stream;
|
||||||
unsigned char *p;
|
unsigned char *p;
|
||||||
//int fd;
|
//int fd;
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ FILE IO
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MAX_HANDLES 10
|
#define MAX_HANDLES 10
|
||||||
FILE *sys_handles[MAX_HANDLES];
|
QFile *sys_handles[MAX_HANDLES];
|
||||||
|
|
||||||
int findhandle (void)
|
int findhandle (void)
|
||||||
{
|
{
|
||||||
|
@ -116,7 +116,7 @@ int findhandle (void)
|
||||||
filelength
|
filelength
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
int filelength (FILE *f)
|
int filelength (QFile *f)
|
||||||
{
|
{
|
||||||
int pos;
|
int pos;
|
||||||
int end;
|
int end;
|
||||||
|
@ -137,7 +137,7 @@ int filelength (FILE *f)
|
||||||
|
|
||||||
int Sys_FileOpenRead (char *path, int *hndl)
|
int Sys_FileOpenRead (char *path, int *hndl)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int i, retval;
|
int i, retval;
|
||||||
int t;
|
int t;
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ int Sys_FileOpenRead (char *path, int *hndl)
|
||||||
|
|
||||||
int Sys_FileOpenWrite (char *path)
|
int Sys_FileOpenWrite (char *path)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int i;
|
int i;
|
||||||
int t;
|
int t;
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ FILE IO
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MAX_HANDLES 10
|
#define MAX_HANDLES 10
|
||||||
FILE *sys_handles[MAX_HANDLES];
|
QFile *sys_handles[MAX_HANDLES];
|
||||||
|
|
||||||
int findhandle (void)
|
int findhandle (void)
|
||||||
{
|
{
|
||||||
|
@ -53,7 +53,7 @@ int findhandle (void)
|
||||||
filelength
|
filelength
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
int filelength (FILE *f)
|
int filelength (QFile *f)
|
||||||
{
|
{
|
||||||
int pos;
|
int pos;
|
||||||
int end;
|
int end;
|
||||||
|
@ -68,7 +68,7 @@ int filelength (FILE *f)
|
||||||
|
|
||||||
int Sys_FileOpenRead (char *path, int *hndl)
|
int Sys_FileOpenRead (char *path, int *hndl)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = findhandle ();
|
i = findhandle ();
|
||||||
|
@ -87,7 +87,7 @@ int Sys_FileOpenRead (char *path, int *hndl)
|
||||||
|
|
||||||
int Sys_FileOpenWrite (char *path)
|
int Sys_FileOpenWrite (char *path)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = findhandle ();
|
i = findhandle ();
|
||||||
|
|
|
@ -97,7 +97,7 @@ FILE IO
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MAX_HANDLES 10
|
#define MAX_HANDLES 10
|
||||||
FILE *sys_handles[MAX_HANDLES];
|
QFile *sys_handles[MAX_HANDLES];
|
||||||
|
|
||||||
int findhandle (void)
|
int findhandle (void)
|
||||||
{
|
{
|
||||||
|
@ -115,7 +115,7 @@ int findhandle (void)
|
||||||
filelength
|
filelength
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
int wfilelength (FILE *f)
|
int wfilelength (QFile *f)
|
||||||
{
|
{
|
||||||
int pos;
|
int pos;
|
||||||
int end;
|
int end;
|
||||||
|
@ -135,7 +135,7 @@ int wfilelength (FILE *f)
|
||||||
|
|
||||||
int Sys_FileOpenRead (char *path, int *hndl)
|
int Sys_FileOpenRead (char *path, int *hndl)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int i, retval;
|
int i, retval;
|
||||||
int t;
|
int t;
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ int Sys_FileOpenRead (char *path, int *hndl)
|
||||||
|
|
||||||
int Sys_FileOpenWrite (char *path)
|
int Sys_FileOpenWrite (char *path)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int i;
|
int i;
|
||||||
int t;
|
int t;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue