mirror of
https://git.code.sf.net/p/quake/nuq
synced 2024-11-22 04:01:11 +00:00
first steps to getting zlib support in
This commit is contained in:
parent
dd3b346d4f
commit
279d332373
33 changed files with 498 additions and 301 deletions
2
TODO
2
TODO
|
@ -3,3 +3,5 @@
|
|||
too slow due to overdraw
|
||||
areas that should be black are greenish
|
||||
o make alsa support more generic for odd hw (eg gus)
|
||||
<LordHavoc> you must support skyboxes (in software and GL), transparency (in software and GL), colored lighting (at least in GL, and if you're doing the others, you might as well do it in software as well), two protocols (DarkPlaces for netplay compatibility, and the ancient neh_gl protocol for the movies, which is much simpler than DP protocol and very bloated), the menus (including the map list and all in the server setup)
|
||||
<LordHavoc> here's some stuff you'll find amusing to try to support then: interpolated animations, DP protocol, DP particles (Nehahra uses the same particle engine, albeit an older version), mod music (honestly I skipped this myself, but nehahra uses 2 tunes), dzip support (I skipped this, and mindcrime seems to be in no hurry to actually use it)Z
|
||||
|
|
|
@ -151,7 +151,7 @@ typedef struct
|
|||
qboolean demoplayback;
|
||||
qboolean timedemo;
|
||||
int forcetrack; // -1 = use normal cd track
|
||||
FILE *demofile;
|
||||
QFile *demofile;
|
||||
int td_lastframe; // to meter out one message a frame
|
||||
int td_startframe; // host_framecount at start
|
||||
float td_starttime; // realtime at second frame of timedemo
|
||||
|
|
|
@ -114,7 +114,7 @@ qboolean Cvar_Command (void);
|
|||
|
||||
// Writes lines containing "set variable value" for all variables
|
||||
// with the archive flag set to true.
|
||||
void Cvar_WriteVariables (FILE *f);
|
||||
void Cvar_WriteVariables (QFile *f);
|
||||
|
||||
// Returns a pointer to the Cvar, NULL if not found
|
||||
cvar_t *Cvar_FindVar (char *var_name);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
void GIB_Module_Load (char *name, FILE *f);
|
||||
void GIB_Module_Load (char *name, QFile *f);
|
||||
gib_module_t *GIB_Create_Module (char *name);
|
||||
gib_sub_t *GIB_Create_Sub (gib_module_t *mod, char *name);
|
||||
void GIB_Read_Sub (gib_sub_t *sub, FILE *f);
|
||||
void GIB_Read_Sub (gib_sub_t *sub, QFile *f);
|
||||
gib_module_t *GIB_Find_Module (char *name);
|
||||
gib_sub_t *GIB_Find_Sub (gib_module_t *mod, char *name);
|
||||
void GIB_Stats_f (void);
|
||||
|
|
|
@ -176,7 +176,7 @@ extern qboolean chat_team;
|
|||
|
||||
void Key_Event (int key, qboolean down);
|
||||
void Key_Init (void);
|
||||
void Key_WriteBindings (FILE *f);
|
||||
void Key_WriteBindings (QFile *f);
|
||||
void Key_SetBinding (int keynum, char *binding);
|
||||
void Key_ClearStates (void);
|
||||
|
||||
|
|
|
@ -93,10 +93,10 @@ char *ED_NewString (char *string);
|
|||
// returns a copy of the string allocated from the server's string heap
|
||||
|
||||
void ED_Print (edict_t *ed);
|
||||
void ED_Write (FILE *f, edict_t *ed);
|
||||
void ED_Write (QFile *f, edict_t *ed);
|
||||
char *ED_ParseEdict (char *data, edict_t *ent);
|
||||
|
||||
void ED_WriteGlobals (FILE *f);
|
||||
void ED_WriteGlobals (QFile *f);
|
||||
void ED_ParseGlobals (char *data);
|
||||
|
||||
void ED_LoadFromFile (char *data);
|
||||
|
|
|
@ -49,9 +49,9 @@ extern char com_gamedir[MAX_OSPATH];
|
|||
extern char gamedirfile[MAX_OSPATH];
|
||||
|
||||
void COM_WriteFile (char *filename, void *data, int len);
|
||||
int COM_FOpenFile (char *filename, FILE **gzfile);
|
||||
void COM_CloseFile (FILE *h);
|
||||
int COM_filelength (FILE *f);
|
||||
int COM_FOpenFile (char *filename, QFile **gzfile);
|
||||
void COM_CloseFile (QFile *h);
|
||||
int COM_filelength (QFile *f);
|
||||
void COM_FileBase (char *in, char *out);
|
||||
void COM_DefaultExtension (char *path, char *extension);
|
||||
char *COM_SkipPath (char *pathname);
|
||||
|
|
|
@ -30,26 +30,41 @@
|
|||
#ifndef _QUAKEIO_H
|
||||
#define _QUAKEIO_H
|
||||
|
||||
#include "gcc_attr.h"
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#ifdef HAS_ZLIB
|
||||
#include <zlib.h>
|
||||
#endif
|
||||
|
||||
#include "gcc_attr.h"
|
||||
|
||||
typedef struct {
|
||||
FILE *file;
|
||||
#ifdef HAS_ZLIB
|
||||
gzFile *gzfile;
|
||||
#endif
|
||||
} QFile;
|
||||
|
||||
void Qexpand_squiggle(const char *path, char *dest);
|
||||
int Qrename(const char *old, const char *new);
|
||||
FILE *Qopen(const char *path, const char *mode);
|
||||
FILE *Qdopen(int fd, const char *mode);
|
||||
void Qclose(FILE *file);
|
||||
int Qread(FILE *file, void *buf, int count);
|
||||
int Qwrite(FILE *file, void *buf, int count);
|
||||
int Qprintf(FILE *file, const char *fmt, ...) __attribute__((format(printf,2,3)));
|
||||
char *Qgets(FILE *file, char *buf, int count);
|
||||
int Qgetc(FILE *file);
|
||||
int Qputc(FILE *file, int c);
|
||||
int Qseek(FILE *file, long offset, int whence);
|
||||
long Qtell(FILE *file);
|
||||
int Qflush(FILE *file);
|
||||
int Qeof(FILE *file);
|
||||
QFile *Qopen(const char *path, const char *mode);
|
||||
QFile *Qdopen(int fd, const char *mode);
|
||||
void Qclose(QFile *file);
|
||||
int Qread(QFile *file, void *buf, int count);
|
||||
int Qwrite(QFile *file, void *buf, int count);
|
||||
int Qprintf(QFile *file, const char *fmt, ...) __attribute__((format(printf,2,3)));
|
||||
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);
|
||||
long Qtell(QFile *file);
|
||||
int Qflush(QFile *file);
|
||||
int Qeof(QFile *file);
|
||||
|
||||
int Qgetpos(QFile *file, fpos_t *pos);
|
||||
int Qsetpos(QFile *file, fpos_t *pos);
|
||||
|
||||
#endif /*_QUAKEIO_H*/
|
||||
|
|
|
@ -67,7 +67,7 @@ void CL_StopPlayback (void)
|
|||
if (!cls.demoplayback)
|
||||
return;
|
||||
|
||||
fclose (cls.demofile);
|
||||
Qclose (cls.demofile);
|
||||
cls.demoplayback = false;
|
||||
cls.demofile = NULL;
|
||||
cls.state = ca_disconnected;
|
||||
|
@ -90,14 +90,14 @@ void CL_WriteDemoMessage (void)
|
|||
float f;
|
||||
|
||||
len = LittleLong (net_message.cursize);
|
||||
fwrite (&len, 4, 1, cls.demofile);
|
||||
Qwrite (cls.demofile, &len, 4);
|
||||
for (i=0 ; i<3 ; i++)
|
||||
{
|
||||
f = LittleFloat (cl.viewangles[i]);
|
||||
fwrite (&f, 4, 1, cls.demofile);
|
||||
Qwrite (cls.demofile, &f, 4);
|
||||
}
|
||||
fwrite (net_message.data, net_message.cursize, 1, cls.demofile);
|
||||
fflush (cls.demofile);
|
||||
Qwrite (cls.demofile, net_message.data, net_message.cursize);
|
||||
Qflush (cls.demofile);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -134,19 +134,19 @@ int CL_GetMessage (void)
|
|||
}
|
||||
|
||||
// get the next message
|
||||
fread (&net_message.cursize, 4, 1, cls.demofile);
|
||||
Qread (cls.demofile, &net_message.cursize, 4);
|
||||
VectorCopy (cl.mviewangles[0], cl.mviewangles[1]);
|
||||
for (i=0 ; i<3 ; i++)
|
||||
{
|
||||
r = fread (&f, 4, 1, cls.demofile);
|
||||
r = Qread (cls.demofile, &f, 4);
|
||||
cl.mviewangles[0][i] = LittleFloat (f);
|
||||
}
|
||||
|
||||
net_message.cursize = LittleLong (net_message.cursize);
|
||||
if (net_message.cursize > MAX_MSGLEN)
|
||||
Sys_Error ("Demo message > MAX_MSGLEN");
|
||||
r = fread (net_message.data, net_message.cursize, 1, cls.demofile);
|
||||
if (r != 1)
|
||||
r = Qread (cls.demofile, net_message.data, net_message.cursize);
|
||||
if (r != net_message.cursize)
|
||||
{
|
||||
CL_StopPlayback ();
|
||||
return 0;
|
||||
|
@ -200,7 +200,7 @@ void CL_Stop_f (void)
|
|||
CL_WriteDemoMessage ();
|
||||
|
||||
// finish up
|
||||
fclose (cls.demofile);
|
||||
Qclose (cls.demofile);
|
||||
cls.demofile = NULL;
|
||||
cls.demorecording = false;
|
||||
Con_Printf ("Completed demo\n");
|
||||
|
@ -264,7 +264,7 @@ void CL_Record_f (void)
|
|||
COM_DefaultExtension (name, ".dem");
|
||||
|
||||
Con_Printf ("recording to %s.\n", name);
|
||||
cls.demofile = fopen (name, "wb");
|
||||
cls.demofile = Qopen (name, "wb");
|
||||
if (!cls.demofile)
|
||||
{
|
||||
Con_Printf ("ERROR: couldn't open.\n");
|
||||
|
@ -272,7 +272,7 @@ void CL_Record_f (void)
|
|||
}
|
||||
|
||||
cls.forcetrack = track;
|
||||
fprintf (cls.demofile, "%i\n", cls.forcetrack);
|
||||
Qprintf (cls.demofile, "%i\n", cls.forcetrack);
|
||||
|
||||
cls.demorecording = true;
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ void CL_PlayDemo_f (void)
|
|||
cls.state = ca_connected;
|
||||
cls.forcetrack = 0;
|
||||
|
||||
while ((c = getc(cls.demofile)) != '\n')
|
||||
while ((c = Qgetc(cls.demofile)) != '\n')
|
||||
if (c == '-')
|
||||
neg = true;
|
||||
else
|
||||
|
|
|
@ -342,9 +342,9 @@ Cmd_Exec_File (char *path)
|
|||
int mark;
|
||||
int len;
|
||||
char base[32];
|
||||
FILE *file;
|
||||
QFile *file;
|
||||
|
||||
if ((file = fopen (path, "r")) != NULL) {
|
||||
if ((file = Qopen (path, "r")) != NULL) {
|
||||
// extract the filename base name for hunk tag
|
||||
COM_FileBase (path, base);
|
||||
len = COM_filelength (file);
|
||||
|
@ -352,8 +352,8 @@ Cmd_Exec_File (char *path)
|
|||
f = (char *)Hunk_AllocName (len+1, base);
|
||||
if (f) {
|
||||
f[len] = 0;
|
||||
fread (f, 1, len, file);
|
||||
fclose (file);
|
||||
Qread (file, f, len);
|
||||
Qclose (file);
|
||||
Cbuf_InsertText (f);
|
||||
}
|
||||
Hunk_FreeToLowMark (mark);
|
||||
|
|
|
@ -52,7 +52,7 @@ being registered.
|
|||
*/
|
||||
void COM_CheckRegistered (void)
|
||||
{
|
||||
FILE *h;
|
||||
QFile *h;
|
||||
unsigned short check[128];
|
||||
|
||||
COM_FOpenFile("gfx/pop.lmp", &h);
|
||||
|
@ -60,8 +60,8 @@ void COM_CheckRegistered (void)
|
|||
|
||||
if (h) {
|
||||
static_registered = 1;
|
||||
fread (check, 1, sizeof(check), h);
|
||||
fclose (h);
|
||||
Qread (h, check, sizeof(check));
|
||||
Qclose (h);
|
||||
}
|
||||
|
||||
if (static_registered) {
|
||||
|
|
|
@ -289,13 +289,13 @@ Writes lines containing "set variable value" for all variables
|
|||
with the archive flag set to true.
|
||||
============
|
||||
*/
|
||||
void Cvar_WriteVariables (FILE *f)
|
||||
void Cvar_WriteVariables (QFile *f)
|
||||
{
|
||||
cvar_t *var;
|
||||
|
||||
for (var = cvar_vars ; var ; var = var->next)
|
||||
if (var->flags&CVAR_ARCHIVE)
|
||||
fprintf (f, "%s \"%s\"\n", var->name, var->string);
|
||||
Qprintf (f, "%s \"%s\"\n", var->name, var->string);
|
||||
}
|
||||
|
||||
void Cvar_Set_f(void)
|
||||
|
|
|
@ -55,14 +55,14 @@ void GIB_Gib_f (void)
|
|||
void GIB_Load_f (void)
|
||||
{
|
||||
char filename[256];
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
|
||||
sprintf(filename, "%s/%s.gib", com_gamedir, Cmd_Argv(1));
|
||||
f = fopen(filename, "r");
|
||||
f = Qopen(filename, "r");
|
||||
if (f)
|
||||
{
|
||||
GIB_Module_Load(Cmd_Argv(1), f);
|
||||
fclose(f);
|
||||
Qclose(f);
|
||||
}
|
||||
else
|
||||
Con_Printf("gibload: File not found.\n");
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
static gib_module_t *gibmodules;
|
||||
|
||||
void GIB_Module_Load (char *name, FILE *f)
|
||||
void GIB_Module_Load (char *name, QFile *f)
|
||||
{
|
||||
char line[1024];
|
||||
gib_module_t *newmod;
|
||||
|
@ -31,7 +31,7 @@ void GIB_Module_Load (char *name, FILE *f)
|
|||
|
||||
newmod = GIB_Create_Module(name);
|
||||
|
||||
while (fgets(line, 1024, f))
|
||||
while (Qgets(f, line, 1024))
|
||||
{
|
||||
if (strncmp("sub", line, 3) == 0)
|
||||
{
|
||||
|
@ -78,14 +78,14 @@ gib_sub_t *GIB_Create_Sub(gib_module_t *mod, char *name)
|
|||
return new;
|
||||
}
|
||||
|
||||
void GIB_Read_Sub(gib_sub_t *sub, FILE *f)
|
||||
void GIB_Read_Sub(gib_sub_t *sub, QFile *f)
|
||||
{
|
||||
char line[1024];
|
||||
fpos_t begin;
|
||||
int sublen = 0;
|
||||
int insub = 0;
|
||||
|
||||
while (fgets(line, 1024, f))
|
||||
while (Qgets(f, line, 1024))
|
||||
{
|
||||
if (strncmp("}}", line, 2) == 0 && insub == 1)
|
||||
{
|
||||
|
@ -98,14 +98,14 @@ void GIB_Read_Sub(gib_sub_t *sub, FILE *f)
|
|||
}
|
||||
if (strncmp("{{", line, 2) == 0)
|
||||
{
|
||||
fgetpos(f, &begin);
|
||||
Qgetpos(f, &begin);
|
||||
insub = 1;
|
||||
}
|
||||
}
|
||||
|
||||
sub->code = malloc(sublen + 1);
|
||||
fsetpos(f, &begin);
|
||||
fread(sub->code, 1, sublen, f);
|
||||
Qsetpos(f, &begin);
|
||||
Qread(f, sub->code, sublen);
|
||||
sub->code[sublen] = 0;
|
||||
Con_Printf("Loaded sub %s\n", sub->name);
|
||||
}
|
||||
|
|
|
@ -318,7 +318,7 @@ void GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr)
|
|||
int *cmds;
|
||||
trivertx_t *verts;
|
||||
char cache[MAX_QPATH], fullpath[MAX_OSPATH];
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
|
||||
aliasmodel = m;
|
||||
paliashdr = hdr; // (aliashdr_t *)Mod_Extradata (m);
|
||||
|
@ -333,11 +333,11 @@ void GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr)
|
|||
COM_FOpenFile (cache, &f);
|
||||
if (f)
|
||||
{
|
||||
fread (&numcommands, 4, 1, f);
|
||||
fread (&numorder, 4, 1, f);
|
||||
fread (&commands, numcommands * sizeof(commands[0]), 1, f);
|
||||
fread (&vertexorder, numorder * sizeof(vertexorder[0]), 1, f);
|
||||
fclose (f);
|
||||
Qread (f, &numcommands, 4);
|
||||
Qread (f, &numorder, 4);
|
||||
Qread (f, &commands, numcommands * sizeof(commands[0]));
|
||||
Qread (f, &vertexorder, numorder * sizeof(vertexorder[0]));
|
||||
Qclose (f);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -352,22 +352,22 @@ void GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr)
|
|||
// save out the cached version
|
||||
//
|
||||
snprintf (fullpath, sizeof(fullpath), "%s/%s", com_gamedir, cache);
|
||||
f = fopen (fullpath, "wb");
|
||||
f = Qopen (fullpath, "wb");
|
||||
if (!f) {
|
||||
char gldir[MAX_OSPATH];
|
||||
|
||||
snprintf (gldir, sizeof(gldir), "%s/glquake", com_gamedir);
|
||||
Sys_mkdir (gldir);
|
||||
f = fopen (fullpath, "wb");
|
||||
f = Qopen (fullpath, "wb");
|
||||
}
|
||||
|
||||
if (f)
|
||||
{
|
||||
fwrite (&numcommands, 4, 1, f);
|
||||
fwrite (&numorder, 4, 1, f);
|
||||
fwrite (&commands, numcommands * sizeof(commands[0]), 1, f);
|
||||
fwrite (&vertexorder, numorder * sizeof(vertexorder[0]), 1, f);
|
||||
fclose (f);
|
||||
Qwrite (f, &numcommands, 4);
|
||||
Qwrite (f, &numorder, 4);
|
||||
Qwrite (f, &commands, numcommands * sizeof(commands[0]));
|
||||
Qwrite (f, &vertexorder, numorder * sizeof(vertexorder[0]));
|
||||
Qclose (f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -286,24 +286,24 @@ typedef struct _TargaHeader {
|
|||
TargaHeader targa_header;
|
||||
byte *targa_rgba;
|
||||
|
||||
int fgetLittleShort (FILE *f)
|
||||
int fgetLittleShort (QFile *f)
|
||||
{
|
||||
byte b1, b2;
|
||||
|
||||
b1 = fgetc(f);
|
||||
b2 = fgetc(f);
|
||||
b1 = Qgetc(f);
|
||||
b2 = Qgetc(f);
|
||||
|
||||
return (short)(b1 + b2*256);
|
||||
}
|
||||
|
||||
int fgetLittleLong (FILE *f)
|
||||
int fgetLittleLong (QFile *f)
|
||||
{
|
||||
byte b1, b2, b3, b4;
|
||||
|
||||
b1 = fgetc(f);
|
||||
b2 = fgetc(f);
|
||||
b3 = fgetc(f);
|
||||
b4 = fgetc(f);
|
||||
b1 = Qgetc(f);
|
||||
b2 = Qgetc(f);
|
||||
b3 = Qgetc(f);
|
||||
b4 = Qgetc(f);
|
||||
|
||||
return b1 + (b2<<8) + (b3<<16) + (b4<<24);
|
||||
}
|
||||
|
@ -314,26 +314,26 @@ int fgetLittleLong (FILE *f)
|
|||
LoadTGA
|
||||
=============
|
||||
*/
|
||||
void LoadTGA (FILE *fin)
|
||||
void LoadTGA (QFile *fin)
|
||||
{
|
||||
int columns, rows, numPixels;
|
||||
byte *pixbuf;
|
||||
int row, column;
|
||||
unsigned char red = 0, green = 0, blue = 0, alphabyte = 0;
|
||||
|
||||
targa_header.id_length = fgetc(fin);
|
||||
targa_header.colormap_type = fgetc(fin);
|
||||
targa_header.image_type = fgetc(fin);
|
||||
targa_header.id_length = Qgetc(fin);
|
||||
targa_header.colormap_type = Qgetc(fin);
|
||||
targa_header.image_type = Qgetc(fin);
|
||||
|
||||
targa_header.colormap_index = fgetLittleShort(fin);
|
||||
targa_header.colormap_length = fgetLittleShort(fin);
|
||||
targa_header.colormap_size = fgetc(fin);
|
||||
targa_header.colormap_size = Qgetc(fin);
|
||||
targa_header.x_origin = fgetLittleShort(fin);
|
||||
targa_header.y_origin = fgetLittleShort(fin);
|
||||
targa_header.width = fgetLittleShort(fin);
|
||||
targa_header.height = fgetLittleShort(fin);
|
||||
targa_header.pixel_size = fgetc(fin);
|
||||
targa_header.attributes = fgetc(fin);
|
||||
targa_header.pixel_size = Qgetc(fin);
|
||||
targa_header.attributes = Qgetc(fin);
|
||||
|
||||
if (targa_header.image_type!=2
|
||||
&& targa_header.image_type!=10)
|
||||
|
@ -350,7 +350,7 @@ void LoadTGA (FILE *fin)
|
|||
targa_rgba = malloc (numPixels*4);
|
||||
|
||||
if (targa_header.id_length != 0)
|
||||
fseek(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
|
||||
for(row=rows-1; row>=0; row--) {
|
||||
|
@ -359,19 +359,19 @@ void LoadTGA (FILE *fin)
|
|||
switch (targa_header.pixel_size) {
|
||||
case 24:
|
||||
|
||||
blue = getc(fin);
|
||||
green = getc(fin);
|
||||
red = getc(fin);
|
||||
blue = Qgetc(fin);
|
||||
green = Qgetc(fin);
|
||||
red = Qgetc(fin);
|
||||
*pixbuf++ = red;
|
||||
*pixbuf++ = green;
|
||||
*pixbuf++ = blue;
|
||||
*pixbuf++ = 255;
|
||||
break;
|
||||
case 32:
|
||||
blue = getc(fin);
|
||||
green = getc(fin);
|
||||
red = getc(fin);
|
||||
alphabyte = getc(fin);
|
||||
blue = Qgetc(fin);
|
||||
green = Qgetc(fin);
|
||||
red = Qgetc(fin);
|
||||
alphabyte = Qgetc(fin);
|
||||
*pixbuf++ = red;
|
||||
*pixbuf++ = green;
|
||||
*pixbuf++ = blue;
|
||||
|
@ -386,21 +386,21 @@ void LoadTGA (FILE *fin)
|
|||
for(row=rows-1; row>=0; row--) {
|
||||
pixbuf = targa_rgba + row*columns*4;
|
||||
for(column=0; column<columns; ) {
|
||||
packetHeader=getc(fin);
|
||||
packetHeader=Qgetc(fin);
|
||||
packetSize = 1 + (packetHeader & 0x7f);
|
||||
if (packetHeader & 0x80) { // run-length packet
|
||||
switch (targa_header.pixel_size) {
|
||||
case 24:
|
||||
blue = getc(fin);
|
||||
green = getc(fin);
|
||||
red = getc(fin);
|
||||
blue = Qgetc(fin);
|
||||
green = Qgetc(fin);
|
||||
red = Qgetc(fin);
|
||||
alphabyte = 255;
|
||||
break;
|
||||
case 32:
|
||||
blue = getc(fin);
|
||||
green = getc(fin);
|
||||
red = getc(fin);
|
||||
alphabyte = getc(fin);
|
||||
blue = Qgetc(fin);
|
||||
green = Qgetc(fin);
|
||||
red = Qgetc(fin);
|
||||
alphabyte = Qgetc(fin);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -424,19 +424,19 @@ void LoadTGA (FILE *fin)
|
|||
for(j=0;j<packetSize;j++) {
|
||||
switch (targa_header.pixel_size) {
|
||||
case 24:
|
||||
blue = getc(fin);
|
||||
green = getc(fin);
|
||||
red = getc(fin);
|
||||
blue = Qgetc(fin);
|
||||
green = Qgetc(fin);
|
||||
red = Qgetc(fin);
|
||||
*pixbuf++ = red;
|
||||
*pixbuf++ = green;
|
||||
*pixbuf++ = blue;
|
||||
*pixbuf++ = 255;
|
||||
break;
|
||||
case 32:
|
||||
blue = getc(fin);
|
||||
green = getc(fin);
|
||||
red = getc(fin);
|
||||
alphabyte = getc(fin);
|
||||
blue = Qgetc(fin);
|
||||
green = Qgetc(fin);
|
||||
red = Qgetc(fin);
|
||||
alphabyte = Qgetc(fin);
|
||||
*pixbuf++ = red;
|
||||
*pixbuf++ = green;
|
||||
*pixbuf++ = blue;
|
||||
|
@ -459,7 +459,7 @@ void LoadTGA (FILE *fin)
|
|||
}
|
||||
}
|
||||
|
||||
fclose(fin);
|
||||
Qclose(fin);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -471,7 +471,7 @@ char *suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"};
|
|||
void R_LoadSkys (char * skyname)
|
||||
{
|
||||
int i;
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
char name[64];
|
||||
|
||||
if (stricmp (skyname, "none") == 0)
|
||||
|
|
|
@ -276,13 +276,13 @@ Writes key bindings and archived cvars to config.cfg
|
|||
*/
|
||||
void Host_WriteConfiguration (void)
|
||||
{
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
|
||||
// dedicated servers initialize the host but don't parse and set the
|
||||
// config.cfg cvars
|
||||
if (host_initialized & !isDedicated)
|
||||
{
|
||||
f = fopen (va("%s/config.cfg",com_gamedir), "w");
|
||||
f = Qopen (va("%s/config.cfg",com_gamedir), "w");
|
||||
if (!f)
|
||||
{
|
||||
Con_Printf ("Couldn't write config.cfg.\n");
|
||||
|
@ -292,7 +292,7 @@ void Host_WriteConfiguration (void)
|
|||
Key_WriteBindings (f);
|
||||
Cvar_WriteVariables (f);
|
||||
|
||||
fclose (f);
|
||||
Qclose (f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -486,7 +486,7 @@ Host_Savegame_f
|
|||
void Host_Savegame_f (void)
|
||||
{
|
||||
char name[256];
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
int i;
|
||||
char comment[SAVEGAME_COMMENT_LENGTH+1];
|
||||
|
||||
|
@ -536,30 +536,30 @@ void Host_Savegame_f (void)
|
|||
COM_DefaultExtension (name, ".sav");
|
||||
|
||||
Con_Printf ("Saving game to %s...\n", name);
|
||||
f = fopen (name, "w");
|
||||
f = Qopen (name, "w");
|
||||
if (!f)
|
||||
{
|
||||
Con_Printf ("ERROR: couldn't open.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf (f, "%i\n", SAVEGAME_VERSION);
|
||||
Qprintf (f, "%i\n", SAVEGAME_VERSION);
|
||||
Host_SavegameComment (comment);
|
||||
fprintf (f, "%s\n", comment);
|
||||
Qprintf (f, "%s\n", comment);
|
||||
for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
|
||||
fprintf (f, "%f\n", svs.clients->spawn_parms[i]);
|
||||
fprintf (f, "%d\n", current_skill);
|
||||
fprintf (f, "%s\n", sv.name);
|
||||
fprintf (f, "%f\n",sv.time);
|
||||
Qprintf (f, "%f\n", svs.clients->spawn_parms[i]);
|
||||
Qprintf (f, "%d\n", current_skill);
|
||||
Qprintf (f, "%s\n", sv.name);
|
||||
Qprintf (f, "%f\n",sv.time);
|
||||
|
||||
// write the light styles
|
||||
|
||||
for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
|
||||
{
|
||||
if (sv.lightstyles[i])
|
||||
fprintf (f, "%s\n", sv.lightstyles[i]);
|
||||
Qprintf (f, "%s\n", sv.lightstyles[i]);
|
||||
else
|
||||
fprintf (f,"m\n");
|
||||
Qprintf (f,"m\n");
|
||||
}
|
||||
|
||||
|
||||
|
@ -567,9 +567,9 @@ void Host_Savegame_f (void)
|
|||
for (i=0 ; i<sv.num_edicts ; i++)
|
||||
{
|
||||
ED_Write (f, EDICT_NUM(i));
|
||||
fflush (f);
|
||||
Qflush (f);
|
||||
}
|
||||
fclose (f);
|
||||
Qclose (f);
|
||||
Con_Printf ("done.\n");
|
||||
}
|
||||
|
||||
|
@ -582,7 +582,7 @@ Host_Loadgame_f
|
|||
void Host_Loadgame_f (void)
|
||||
{
|
||||
char name[MAX_OSPATH];
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
char mapname[MAX_QPATH];
|
||||
float time, tfloat;
|
||||
char str[32768], *start;
|
||||
|
@ -590,7 +590,8 @@ void Host_Loadgame_f (void)
|
|||
edict_t *ent;
|
||||
int entnum;
|
||||
int version;
|
||||
float spawn_parms[NUM_SPAWN_PARMS];
|
||||
float spawn_parms[NUM_SPAWN_PARMS];
|
||||
char buf[100];
|
||||
|
||||
if (cmd_source != src_command)
|
||||
return;
|
||||
|
@ -611,25 +612,30 @@ void Host_Loadgame_f (void)
|
|||
// SCR_BeginLoadingPlaque ();
|
||||
|
||||
Con_Printf ("Loading game from %s...\n", name);
|
||||
f = fopen (name, "r");
|
||||
f = Qopen (name, "r");
|
||||
if (!f)
|
||||
{
|
||||
Con_Printf ("ERROR: couldn't open.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
fscanf (f, "%i\n", &version);
|
||||
Qgets(f,buf,sizeof(buf));
|
||||
sscanf (buf, "%i\n", &version);
|
||||
if (version != SAVEGAME_VERSION)
|
||||
{
|
||||
fclose (f);
|
||||
Qclose (f);
|
||||
Con_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
|
||||
return;
|
||||
}
|
||||
fscanf (f, "%s\n", str);
|
||||
for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
|
||||
fscanf (f, "%f\n", &spawn_parms[i]);
|
||||
Qgets(f,buf,sizeof(buf));
|
||||
sscanf (buf, "%s\n", str);
|
||||
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
|
||||
fscanf (f, "%f\n", &tfloat);
|
||||
Qgets(f,buf,sizeof(buf));
|
||||
sscanf (buf, "%f\n", &tfloat);
|
||||
current_skill = (int)(tfloat + 0.1);
|
||||
Cvar_SetValue(skill, (float)current_skill);
|
||||
|
||||
|
@ -639,8 +645,10 @@ void Host_Loadgame_f (void)
|
|||
Cvar_SetValue(teamplay, 0);
|
||||
#endif
|
||||
|
||||
fscanf (f, "%s\n",mapname);
|
||||
fscanf (f, "%f\n",&time);
|
||||
Qgets(f,buf,sizeof(buf));
|
||||
sscanf (buf, "%s\n",mapname);
|
||||
Qgets(f,buf,sizeof(buf));
|
||||
sscanf (buf, "%f\n",&time);
|
||||
|
||||
CL_Disconnect_f ();
|
||||
|
||||
|
@ -661,18 +669,19 @@ void Host_Loadgame_f (void)
|
|||
|
||||
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);
|
||||
strcpy (sv.lightstyles[i], str);
|
||||
}
|
||||
|
||||
// load the edicts out of the savegame file
|
||||
entnum = -1; // -1 is the globals
|
||||
while (!feof(f))
|
||||
while (!Qeof(f))
|
||||
{
|
||||
for (i=0 ; i<sizeof(str)-1 ; i++)
|
||||
{
|
||||
r = fgetc (f);
|
||||
r = Qgetc (f);
|
||||
if (r == EOF || !r)
|
||||
break;
|
||||
str[i] = r;
|
||||
|
@ -715,7 +724,7 @@ void Host_Loadgame_f (void)
|
|||
sv.num_edicts = entnum;
|
||||
sv.time = time;
|
||||
|
||||
fclose (f);
|
||||
Qclose (f);
|
||||
|
||||
for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
|
||||
svs.clients->spawn_parms[i] = spawn_parms[i];
|
||||
|
@ -731,7 +740,7 @@ void Host_Loadgame_f (void)
|
|||
void SaveGamestate()
|
||||
{
|
||||
char name[256];
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
int i;
|
||||
char comment[SAVEGAME_COMMENT_LENGTH+1];
|
||||
edict_t *ent;
|
||||
|
@ -746,23 +755,23 @@ void SaveGamestate()
|
|||
return;
|
||||
}
|
||||
|
||||
fprintf (f, "%i\n", SAVEGAME_VERSION);
|
||||
Qprintf (f, "%i\n", SAVEGAME_VERSION);
|
||||
Host_SavegameComment (comment);
|
||||
fprintf (f, "%s\n", comment);
|
||||
Qprintf (f, "%s\n", comment);
|
||||
// for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
|
||||
// fprintf (f, "%f\n", svs.clients->spawn_parms[i]);
|
||||
fprintf (f, "%f\n", skill->value);
|
||||
fprintf (f, "%s\n", sv.name);
|
||||
fprintf (f, "%f\n", sv.time);
|
||||
// Qprintf (f, "%f\n", svs.clients->spawn_parms[i]);
|
||||
Qprintf (f, "%f\n", skill->value);
|
||||
Qprintf (f, "%s\n", sv.name);
|
||||
Qprintf (f, "%f\n", sv.time);
|
||||
|
||||
// write the light styles
|
||||
|
||||
for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
|
||||
{
|
||||
if (sv.lightstyles[i])
|
||||
fprintf (f, "%s\n", sv.lightstyles[i]);
|
||||
Qprintf (f, "%s\n", sv.lightstyles[i]);
|
||||
else
|
||||
fprintf (f,"m\n");
|
||||
Qprintf (f,"m\n");
|
||||
}
|
||||
|
||||
|
||||
|
@ -771,18 +780,18 @@ void SaveGamestate()
|
|||
ent = EDICT_NUM(i);
|
||||
if ((int)ent->v.flags & FL_ARCHIVE_OVERRIDE)
|
||||
continue;
|
||||
fprintf (f, "%i\n",i);
|
||||
Qprintf (f, "%i\n",i);
|
||||
ED_Write (f, ent);
|
||||
fflush (f);
|
||||
Qflush (f);
|
||||
}
|
||||
fclose (f);
|
||||
Qclose (f);
|
||||
Con_Printf ("done.\n");
|
||||
}
|
||||
|
||||
int LoadGamestate(char *level, char *startspot)
|
||||
{
|
||||
char name[MAX_OSPATH];
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
char mapname[MAX_QPATH];
|
||||
float time, sk;
|
||||
char str[32768], *start;
|
||||
|
@ -802,21 +811,26 @@ int LoadGamestate(char *level, char *startspot)
|
|||
return -1;
|
||||
}
|
||||
|
||||
fscanf (f, "%i\n", &version);
|
||||
Qgets(f,buf,sizeof(buf));
|
||||
sscanf (buf, "%i\n", &version);
|
||||
if (version != SAVEGAME_VERSION)
|
||||
{
|
||||
fclose (f);
|
||||
Qclose (f);
|
||||
Con_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
|
||||
return -1;
|
||||
}
|
||||
fscanf (f, "%s\n", str);
|
||||
Qgets(f,buf,sizeof(buf));
|
||||
sscanf (buf, "%s\n", str);
|
||||
// for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
|
||||
// fscanf (f, "%f\n", &spawn_parms[i]);
|
||||
fscanf (f, "%f\n", &sk);
|
||||
Qgets(f,buf,sizeof(buf));
|
||||
sscanf (buf, "%f\n", &sk);
|
||||
Cvar_SetValue(skill, sk);
|
||||
|
||||
fscanf (f, "%s\n",mapname);
|
||||
fscanf (f, "%f\n",&time);
|
||||
Qgets(f,buf,sizeof(buf));
|
||||
sscanf (buf, "%s\n",mapname);
|
||||
Qgets(f,buf,sizeof(buf));
|
||||
sscanf (buf, "%f\n",&time);
|
||||
|
||||
SV_SpawnServer (mapname, startspot);
|
||||
|
||||
|
@ -829,7 +843,8 @@ int LoadGamestate(char *level, char *startspot)
|
|||
// load the light styles
|
||||
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);
|
||||
strcpy (sv.lightstyles[i], str);
|
||||
}
|
||||
|
@ -837,7 +852,8 @@ int LoadGamestate(char *level, char *startspot)
|
|||
// load the edicts out of the savegame file
|
||||
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++)
|
||||
{
|
||||
r = fgetc (f);
|
||||
|
@ -874,7 +890,7 @@ int LoadGamestate(char *level, char *startspot)
|
|||
|
||||
// sv.num_edicts = entnum;
|
||||
sv.time = time;
|
||||
fclose (f);
|
||||
Qclose (f);
|
||||
|
||||
// for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
|
||||
// svs.clients->spawn_parms[i] = spawn_parms[i];
|
||||
|
|
|
@ -561,14 +561,14 @@ Key_WriteBindings
|
|||
Writes lines containing "bind key value"
|
||||
============
|
||||
*/
|
||||
void Key_WriteBindings (FILE *f)
|
||||
void Key_WriteBindings (QFile *f)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0 ; i<256 ; i++)
|
||||
if (keybindings[i])
|
||||
if (*keybindings[i])
|
||||
fprintf (f, "bind \"%s\" \"%s\"\n", Key_KeynumToString(i), keybindings[i]);
|
||||
Qprintf (f, "bind \"%s\" \"%s\"\n", Key_KeynumToString(i), keybindings[i]);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -473,19 +473,23 @@ void M_ScanSaves (void)
|
|||
{
|
||||
int i, j;
|
||||
char name[MAX_OSPATH];
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
int version;
|
||||
char buf[100];
|
||||
|
||||
for (i=0 ; i<MAX_SAVEGAMES ; i++)
|
||||
{
|
||||
strcpy (m_filenames[i], "--- UNUSED SLOT ---");
|
||||
loadable[i] = false;
|
||||
snprintf (name, sizeof(name), "%s/s%i.sav", com_gamedir, i);
|
||||
f = fopen (name, "r");
|
||||
f = Qopen (name, "r");
|
||||
if (!f)
|
||||
continue;
|
||||
fscanf (f, "%i\n", &version);
|
||||
fscanf (f, "%79s\n", name);
|
||||
Qgets(f,buf,sizeof(buf));
|
||||
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);
|
||||
|
||||
// change _ back to space
|
||||
|
@ -493,7 +497,7 @@ void M_ScanSaves (void)
|
|||
if (m_filenames[i][j] == '_')
|
||||
m_filenames[i][j] = ' ';
|
||||
loadable[i] = true;
|
||||
fclose (f);
|
||||
Qclose (f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -501,7 +501,7 @@ ED_Write
|
|||
For savegames
|
||||
=============
|
||||
*/
|
||||
void ED_Write (FILE *f, edict_t *ed)
|
||||
void ED_Write (QFile *f, edict_t *ed)
|
||||
{
|
||||
ddef_t *d;
|
||||
int *v;
|
||||
|
@ -509,11 +509,11 @@ void ED_Write (FILE *f, edict_t *ed)
|
|||
char *name;
|
||||
int type;
|
||||
|
||||
fprintf (f, "{\n");
|
||||
Qprintf (f, "{\n");
|
||||
|
||||
if (ed->free)
|
||||
{
|
||||
fprintf (f, "}\n");
|
||||
Qprintf (f, "}\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -534,11 +534,11 @@ void ED_Write (FILE *f, edict_t *ed)
|
|||
if (j == type_size[type])
|
||||
continue;
|
||||
|
||||
fprintf (f,"\"%s\" ",name);
|
||||
fprintf (f,"\"%s\"\n", PR_UglyValueString(d->type, (eval_t *)v));
|
||||
Qprintf (f,"\"%s\" ",name);
|
||||
Qprintf (f,"\"%s\"\n", PR_UglyValueString(d->type, (eval_t *)v));
|
||||
}
|
||||
|
||||
fprintf (f, "}\n");
|
||||
Qprintf (f, "}\n");
|
||||
}
|
||||
|
||||
void ED_PrintNum (int ent)
|
||||
|
@ -632,14 +632,14 @@ FIXME: need to tag constants, doesn't really work
|
|||
ED_WriteGlobals
|
||||
=============
|
||||
*/
|
||||
void ED_WriteGlobals (FILE *f)
|
||||
void ED_WriteGlobals (QFile *f)
|
||||
{
|
||||
ddef_t *def;
|
||||
int i;
|
||||
char *name;
|
||||
int type;
|
||||
|
||||
fprintf (f,"{\n");
|
||||
Qprintf (f,"{\n");
|
||||
for (i=0 ; i<progs->numglobaldefs ; i++)
|
||||
{
|
||||
def = &pr_globaldefs[i];
|
||||
|
@ -654,10 +654,10 @@ void ED_WriteGlobals (FILE *f)
|
|||
continue;
|
||||
|
||||
name = pr_strings + def->s_name;
|
||||
fprintf (f,"\"%s\" ", name);
|
||||
fprintf (f,"\"%s\"\n", PR_UglyValueString(type, (eval_t *)&pr_globals[def->ofs]));
|
||||
Qprintf (f,"\"%s\" ", name);
|
||||
Qprintf (f,"\"%s\"\n", PR_UglyValueString(type, (eval_t *)&pr_globals[def->ofs]));
|
||||
}
|
||||
fprintf (f,"}\n");
|
||||
Qprintf (f,"}\n");
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -127,7 +127,7 @@ typedef struct
|
|||
typedef struct pack_s
|
||||
{
|
||||
char filename[MAX_OSPATH];
|
||||
FILE *handle;
|
||||
QFile *handle;
|
||||
int numfiles;
|
||||
packfile_t *files;
|
||||
} pack_t;
|
||||
|
@ -192,15 +192,15 @@ COM_FileBase (char *in, char *out)
|
|||
COM_filelength
|
||||
*/
|
||||
int
|
||||
COM_filelength (FILE *f)
|
||||
COM_filelength (QFile *f)
|
||||
{
|
||||
int pos;
|
||||
int end;
|
||||
|
||||
pos = ftell (f);
|
||||
fseek (f, 0, SEEK_END);
|
||||
end = ftell (f);
|
||||
fseek (f, pos, SEEK_SET);
|
||||
pos = Qtell (f);
|
||||
Qseek (f, 0, SEEK_END);
|
||||
end = Qtell (f);
|
||||
Qseek (f, pos, SEEK_SET);
|
||||
|
||||
return end;
|
||||
}
|
||||
|
@ -209,11 +209,11 @@ COM_filelength (FILE *f)
|
|||
COM_FileOpenRead
|
||||
*/
|
||||
int
|
||||
COM_FileOpenRead (char *path, FILE **hndl)
|
||||
COM_FileOpenRead (char *path, QFile **hndl)
|
||||
{
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
|
||||
f = fopen(path, "rb");
|
||||
f = Qopen(path, "rb");
|
||||
if (!f)
|
||||
{
|
||||
*hndl = NULL;
|
||||
|
@ -291,22 +291,22 @@ COM_Maplist_f ( void )
|
|||
void
|
||||
COM_WriteFile ( char *filename, void *data, int len )
|
||||
{
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
char name[MAX_OSPATH];
|
||||
|
||||
snprintf(name, sizeof(name), "%s/%s", com_gamedir, filename);
|
||||
|
||||
f = fopen (name, "wb");
|
||||
f = Qopen (name, "wb");
|
||||
if (!f) {
|
||||
Sys_mkdir(com_gamedir);
|
||||
f = fopen (name, "wb");
|
||||
f = Qopen (name, "wb");
|
||||
if (!f)
|
||||
Sys_Error ("Error opening %s", filename);
|
||||
}
|
||||
|
||||
Sys_Printf ("COM_WriteFile: %s\n", name);
|
||||
fwrite (data, 1, len, f);
|
||||
fclose (f);
|
||||
Qwrite (f, data, len);
|
||||
Qclose (f);
|
||||
}
|
||||
|
||||
|
||||
|
@ -344,13 +344,13 @@ COM_CreatePath ( char *path )
|
|||
void
|
||||
COM_CopyFile (char *netpath, char *cachepath)
|
||||
{
|
||||
FILE *in, *out;
|
||||
QFile *in, *out;
|
||||
int remaining, count;
|
||||
char buf[4096];
|
||||
|
||||
remaining = COM_FileOpenRead (netpath, &in);
|
||||
COM_CreatePath (cachepath); // create directories up to the cache file
|
||||
out = fopen(cachepath, "wb");
|
||||
out = Qopen(cachepath, "wb");
|
||||
if (!out)
|
||||
Sys_Error ("Error opening %s", cachepath);
|
||||
|
||||
|
@ -360,19 +360,19 @@ COM_CopyFile (char *netpath, char *cachepath)
|
|||
count = remaining;
|
||||
else
|
||||
count = sizeof(buf);
|
||||
fread (buf, 1, count, in);
|
||||
fwrite (buf, 1, count, out);
|
||||
Qread (in, buf, count);
|
||||
Qwrite (out, buf, count);
|
||||
remaining -= count;
|
||||
}
|
||||
|
||||
fclose (in);
|
||||
fclose (out);
|
||||
Qclose (in);
|
||||
Qclose (out);
|
||||
}
|
||||
|
||||
/*
|
||||
COM_OpenRead
|
||||
*/
|
||||
FILE *
|
||||
QFile *
|
||||
COM_OpenRead (const char *path, int offs, int len)
|
||||
{
|
||||
int fd=open(path,O_RDONLY);
|
||||
|
@ -403,7 +403,7 @@ COM_OpenRead (const char *path, int offs, int len)
|
|||
#ifdef WIN32
|
||||
setmode(fd,O_BINARY);
|
||||
#endif
|
||||
return fdopen(fd,"rb");
|
||||
return Qdopen(fd,"rb");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -416,7 +416,7 @@ int file_from_pak; // global indicating file came from pack file ZOID
|
|||
Sets com_filesize and one of handle or file
|
||||
*/
|
||||
int
|
||||
COM_FOpenFile (char *filename, FILE **gzfile)
|
||||
COM_FOpenFile (char *filename, QFile **gzfile)
|
||||
{
|
||||
searchpath_t *search;
|
||||
char netpath[MAX_OSPATH];
|
||||
|
@ -492,7 +492,7 @@ int loadsize;
|
|||
byte *
|
||||
COM_LoadFile (char *path, int usehunk)
|
||||
{
|
||||
FILE *h;
|
||||
QFile *h;
|
||||
byte *buf;
|
||||
char base[32];
|
||||
int len;
|
||||
|
@ -532,8 +532,8 @@ COM_LoadFile (char *path, int usehunk)
|
|||
//if (!is_server) {
|
||||
Draw_BeginDisc();
|
||||
//}
|
||||
fread (buf, 1, len, h);
|
||||
fclose (h);
|
||||
Qread (h, buf, len);
|
||||
Qclose (h);
|
||||
//if (!is_server) {
|
||||
Draw_EndDisc();
|
||||
//}
|
||||
|
@ -589,13 +589,13 @@ COM_LoadPackFile (char *packfile)
|
|||
packfile_t *newfiles;
|
||||
int numpackfiles;
|
||||
pack_t *pack;
|
||||
FILE *packhandle;
|
||||
QFile *packhandle;
|
||||
dpackfile_t info[MAX_FILES_IN_PACK];
|
||||
|
||||
if (COM_FileOpenRead (packfile, &packhandle) == -1)
|
||||
return NULL;
|
||||
|
||||
fread (&header, 1, sizeof(header), packhandle);
|
||||
Qread (packhandle, &header, sizeof(header));
|
||||
if (header.id[0] != 'P' || header.id[1] != 'A'
|
||||
|| header.id[2] != 'C' || header.id[3] != 'K')
|
||||
Sys_Error ("%s is not a packfile", packfile);
|
||||
|
@ -609,8 +609,8 @@ COM_LoadPackFile (char *packfile)
|
|||
|
||||
newfiles = calloc (1, numpackfiles * sizeof(packfile_t));
|
||||
|
||||
fseek (packhandle, header.dirofs, SEEK_SET);
|
||||
fread (info, 1, header.dirlen, packhandle);
|
||||
Qseek (packhandle, header.dirofs, SEEK_SET);
|
||||
Qread (packhandle, info, header.dirlen);
|
||||
|
||||
|
||||
// parse the directory
|
||||
|
@ -822,7 +822,7 @@ COM_Gamedir (char *dir)
|
|||
{
|
||||
if (com_searchpaths->pack)
|
||||
{
|
||||
fclose (com_searchpaths->pack->handle);
|
||||
Qclose (com_searchpaths->pack->handle);
|
||||
free (com_searchpaths->pack->files);
|
||||
free (com_searchpaths->pack);
|
||||
}
|
||||
|
|
223
source/quakeio.c
223
source/quakeio.c
|
@ -91,103 +91,260 @@ Qrename(const char *old, const char *new)
|
|||
return rename (e_old, e_new);
|
||||
}
|
||||
|
||||
FILE *
|
||||
QFile *
|
||||
Qopen(const char *path, const char *mode)
|
||||
{
|
||||
FILE *file;
|
||||
QFile *file;
|
||||
char m[80],*p;
|
||||
int zip=0;
|
||||
char e_path[PATH_MAX];
|
||||
|
||||
Qexpand_squiggle (path, e_path);
|
||||
path = e_path;
|
||||
|
||||
file=fopen(path,mode);
|
||||
for (p=m; *mode && p-m<(sizeof(m)-1); mode++) {
|
||||
if (*mode=='z') {
|
||||
zip=1;
|
||||
continue;
|
||||
}
|
||||
*p++=*mode;
|
||||
}
|
||||
*p=0;
|
||||
|
||||
file=calloc(sizeof(*file),1);
|
||||
if (!file)
|
||||
return 0;
|
||||
#ifdef HAS_ZLIB
|
||||
if (zip) {
|
||||
file->gzfile=gzopen(path,m);
|
||||
if (!file->gzfile) {
|
||||
free(file);
|
||||
return 0;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
file->file=fopen(path,m);
|
||||
if (!file->file) {
|
||||
free(file);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
FILE *
|
||||
QFile *
|
||||
Qdopen(int fd, const char *mode)
|
||||
{
|
||||
FILE *file;
|
||||
QFile *file;
|
||||
char m[80],*p;
|
||||
int zip=0;
|
||||
|
||||
file=fdopen(fd,mode);
|
||||
for (p=m; *mode && p-m<(sizeof(m)-1); mode++) {
|
||||
if (*mode=='z') {
|
||||
zip=1;
|
||||
continue;
|
||||
}
|
||||
*p++=*mode;
|
||||
}
|
||||
|
||||
*p=0;
|
||||
|
||||
file=calloc(sizeof(*file),1);
|
||||
if (!file)
|
||||
return 0;
|
||||
#ifdef HAS_ZLIB
|
||||
if (zip) {
|
||||
file->gzfile=gzdopen(fd,m);
|
||||
if (!file->gzfile) {
|
||||
free(file);
|
||||
return 0;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
file->file=fdopen(fd,m);
|
||||
if (!file->file) {
|
||||
free(file);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#ifdef WIN32
|
||||
# ifdef __BORLANDC__
|
||||
setmode(_fileno(file),O_BINARY);
|
||||
# else
|
||||
_setmode(_fileno(file),_O_BINARY);
|
||||
# endif
|
||||
#ifdef __BORLANDC__
|
||||
setmode(_fileno(file->file),O_BINARY);
|
||||
#else
|
||||
_setmode(_fileno(file->file),_O_BINARY);
|
||||
#endif
|
||||
#endif
|
||||
return file;
|
||||
}
|
||||
|
||||
void
|
||||
Qclose(FILE *file)
|
||||
Qclose(QFile *file)
|
||||
{
|
||||
fclose(file);
|
||||
if (file->file)
|
||||
fclose(file->file);
|
||||
#ifdef HAS_ZLIB
|
||||
else
|
||||
gzclose(file->gzfile);
|
||||
#endif
|
||||
free(file);
|
||||
}
|
||||
|
||||
int
|
||||
Qread(FILE *file, void *buf, int count)
|
||||
Qread(QFile *file, void *buf, int count)
|
||||
{
|
||||
return fread(buf, 1, count, file);
|
||||
if (file->file)
|
||||
return fread(buf, 1, count, file->file);
|
||||
#ifdef HAS_ZLIB
|
||||
else
|
||||
return gzread(file->gzfile,buf,count);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
Qwrite(FILE *file, void *buf, int count)
|
||||
Qwrite (QFile *file, void *buf, int count)
|
||||
{
|
||||
return fwrite(buf, 1, count, file);
|
||||
if (file->file)
|
||||
return fwrite(buf, 1, count, file->file);
|
||||
#ifdef HAS_ZLIB
|
||||
else
|
||||
return gzwrite(file->gzfile,buf,count);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
Qprintf(FILE *file, const char *fmt, ...)
|
||||
Qprintf(QFile *file, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
int ret=-1;
|
||||
|
||||
va_start(args,fmt);
|
||||
ret=vfprintf(file, fmt, args);
|
||||
if (file->file)
|
||||
ret=vfprintf(file->file, fmt, args);
|
||||
#ifdef HAS_ZLIB
|
||||
else {
|
||||
char buf[4096];
|
||||
va_start(args, fmt);
|
||||
#ifdef HAVE_VSNPRINTF
|
||||
(void)vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
#else
|
||||
(void)vsprintf(buf, fmt, args);
|
||||
#endif
|
||||
va_end(args);
|
||||
ret = strlen(buf); /* some *sprintf don't return the nb of bytes written */
|
||||
if (ret>0)
|
||||
ret=gzwrite(file, buf, (unsigned)ret);
|
||||
}
|
||||
#endif
|
||||
va_end(args);
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *
|
||||
Qgets(FILE *file, char *buf, int count)
|
||||
Qgets(QFile *file, char *buf, int count)
|
||||
{
|
||||
return fgets(buf, count, file);
|
||||
if (file->file)
|
||||
return fgets(buf, count, file->file);
|
||||
#ifdef HAS_ZLIB
|
||||
else
|
||||
return gzgets(file->gzfile,buf,count);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
Qgetc(FILE *file)
|
||||
Qgetc(QFile *file)
|
||||
{
|
||||
return fgetc(file);
|
||||
if (file->file)
|
||||
return fgetc(file->file);
|
||||
#ifdef HAS_ZLIB
|
||||
else
|
||||
return gzgetc(file->gzfile);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
Qputc(FILE *file, int c)
|
||||
Qputc(QFile *file, int c)
|
||||
{
|
||||
return fputc(c, file);
|
||||
if (file->file)
|
||||
return fputc(c, file->file);
|
||||
#ifdef HAS_ZLIB
|
||||
else
|
||||
return gzputc(file->gzfile,c);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
Qseek(FILE *file, long offset, int whence)
|
||||
Qseek(QFile *file, long offset, int whence)
|
||||
{
|
||||
return fseek(file, offset, whence);
|
||||
if (file->file)
|
||||
return fseek(file->file, offset, whence);
|
||||
#ifdef HAS_ZLIB
|
||||
else
|
||||
return gzseek(file->gzfile,offset,whence);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
long
|
||||
Qtell(FILE *file)
|
||||
Qtell(QFile *file)
|
||||
{
|
||||
return ftell(file);
|
||||
if (file->file)
|
||||
return ftell(file->file);
|
||||
#ifdef HAS_ZLIB
|
||||
else
|
||||
return gztell(file->gzfile);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
Qflush(FILE *file)
|
||||
Qflush(QFile *file)
|
||||
{
|
||||
return fflush(file);
|
||||
if (file->file)
|
||||
return fflush(file->file);
|
||||
#ifdef HAS_ZLIB
|
||||
else
|
||||
return gzflush(file->gzfile,Z_SYNC_FLUSH);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
Qeof(FILE *file)
|
||||
Qeof(QFile *file)
|
||||
{
|
||||
return feof(file);
|
||||
if (file->file)
|
||||
return feof(file->file);
|
||||
#ifdef HAS_ZLIB
|
||||
else
|
||||
return gzeof(file->gzfile);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
Qgetpos(QFile *file, fpos_t *pos)
|
||||
{
|
||||
*pos = Qtell(file);
|
||||
return *pos==-1?-1:0;
|
||||
}
|
||||
|
||||
int
|
||||
Qsetpos(QFile *file, fpos_t *pos)
|
||||
{
|
||||
return Qseek(file, *pos, 0);
|
||||
}
|
||||
|
|
|
@ -211,12 +211,13 @@ void R_ClearParticles (void)
|
|||
|
||||
void R_ReadPointFile_f (void)
|
||||
{
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
vec3_t org;
|
||||
int r;
|
||||
int c;
|
||||
particle_t *p;
|
||||
char name[MAX_OSPATH];
|
||||
char buf[256];
|
||||
|
||||
snprintf (name, sizeof(name), "maps/%s.pts", sv.name);
|
||||
|
||||
|
@ -231,7 +232,9 @@ void R_ReadPointFile_f (void)
|
|||
c = 0;
|
||||
for ( ;; )
|
||||
{
|
||||
r = fscanf (f,"%f %f %f\n", &org[0], &org[1], &org[2]);
|
||||
if (!Qgets(f,buf,sizeof(buf)))
|
||||
break;
|
||||
r = sscanf (buf,"%f %f %f\n", &org[0], &org[1], &org[2]);
|
||||
if (r != 3)
|
||||
break;
|
||||
c++;
|
||||
|
@ -253,7 +256,7 @@ void R_ReadPointFile_f (void)
|
|||
VectorCopy (org, p->org);
|
||||
}
|
||||
|
||||
fclose (f);
|
||||
Qclose (f);
|
||||
Con_Printf ("%i points read\n", c);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,9 +37,9 @@
|
|||
|
||||
#define INI_STRING_SIZE 0x100
|
||||
|
||||
FILE *ini_fopen(const char *filename, const char *modes);
|
||||
int ini_fclose(FILE *f);
|
||||
void ini_fgets(FILE *f, const char *section, const char *field, char *s);
|
||||
QFile *ini_fopen(const char *filename, const char *modes);
|
||||
int ini_fclose(QFile *f);
|
||||
void ini_fgets(QFile *f, const char *section, const char *field, char *s);
|
||||
|
||||
// Routines for reading from .INI files
|
||||
// The read routines are fairly efficient.
|
||||
|
@ -65,7 +65,7 @@ struct field_buffer
|
|||
char name[MAX_FIELD_WIDTH+1];
|
||||
};
|
||||
|
||||
static FILE *current_file=NULL;
|
||||
static QFile *current_file=NULL;
|
||||
static int current_section;
|
||||
|
||||
static int current_section_buffer=0;
|
||||
|
@ -83,7 +83,7 @@ static char toupper(char c)
|
|||
return(c);
|
||||
}
|
||||
|
||||
static void reset_buffer(FILE *f)
|
||||
static void reset_buffer(QFile *f)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -322,7 +322,7 @@ static void add_field(char *instring, int section, long offset)
|
|||
|
||||
// Identical to fgets except the string is trucated at the first ';',
|
||||
// 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;
|
||||
|
||||
|
@ -340,13 +340,13 @@ static char *stripped_fgets(char *s, int n, FILE *f)
|
|||
// Externally accessable routines
|
||||
//***************************************************************************
|
||||
// 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));
|
||||
}
|
||||
|
||||
// Closes a .INI file. Works like fclose
|
||||
int ini_fclose(FILE *f)
|
||||
int ini_fclose(QFile *f)
|
||||
{
|
||||
if (f==current_file)
|
||||
reset_buffer(NULL);
|
||||
|
@ -356,7 +356,7 @@ int ini_fclose(FILE *f)
|
|||
// Puts "field" from "section" from .ini file "f" into "s".
|
||||
// If "section" does not exist or "field" does not exist in
|
||||
// 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;
|
||||
long start_pos,string_start_pos;
|
||||
|
@ -666,7 +666,7 @@ void ClearGf1Ints(void)
|
|||
static qboolean GUS_GetIWData(void)
|
||||
{
|
||||
char *Interwave,s[INI_STRING_SIZE];
|
||||
FILE *IwFile;
|
||||
QFile *IwFile;
|
||||
int CodecBase,CodecDma,i;
|
||||
|
||||
Interwave=getenv("INTERWAVE");
|
||||
|
|
|
@ -35,13 +35,13 @@
|
|||
/*
|
||||
===============================================================================
|
||||
|
||||
FILE IO
|
||||
QFile IO
|
||||
|
||||
===============================================================================
|
||||
*/
|
||||
|
||||
#define MAX_HANDLES 10
|
||||
FILE *sys_handles[MAX_HANDLES];
|
||||
QFile *sys_handles[MAX_HANDLES];
|
||||
|
||||
int findhandle (void)
|
||||
{
|
||||
|
@ -59,7 +59,7 @@ int findhandle (void)
|
|||
filelength
|
||||
================
|
||||
*/
|
||||
int filelength (FILE *f)
|
||||
int filelength (QFile *f)
|
||||
{
|
||||
int pos;
|
||||
int end;
|
||||
|
@ -74,7 +74,7 @@ int filelength (FILE *f)
|
|||
|
||||
int Sys_FileOpenRead (char *path, int *hndl)
|
||||
{
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
int i;
|
||||
|
||||
i = findhandle ();
|
||||
|
@ -93,7 +93,7 @@ int Sys_FileOpenRead (char *path, int *hndl)
|
|||
|
||||
int Sys_FileOpenWrite (char *path)
|
||||
{
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
int i;
|
||||
|
||||
i = findhandle ();
|
||||
|
@ -129,7 +129,7 @@ int Sys_FileWrite (int handle, void *data, int count)
|
|||
|
||||
int Sys_FileTime (char *path)
|
||||
{
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
|
||||
f = fopen(path, "rb");
|
||||
if (f)
|
||||
|
|
|
@ -57,7 +57,7 @@ FILE IO
|
|||
|
||||
typedef struct
|
||||
{
|
||||
FILE *hFile;
|
||||
QFile *hFile;
|
||||
char *pMap;
|
||||
int nLen;
|
||||
int nPos;
|
||||
|
@ -81,7 +81,7 @@ int findhandle (void)
|
|||
filelength
|
||||
================
|
||||
*/
|
||||
int filelength (FILE *f)
|
||||
int filelength (QFile *f)
|
||||
{
|
||||
int pos;
|
||||
int end;
|
||||
|
@ -96,7 +96,7 @@ int filelength (FILE *f)
|
|||
|
||||
int Sys_FileOpenRead (char *path, int *hndl)
|
||||
{
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
int i;
|
||||
|
||||
i = findhandle ();
|
||||
|
@ -124,7 +124,7 @@ int Sys_FileOpenRead (char *path, int *hndl)
|
|||
|
||||
int Sys_FileOpenWrite (char *path)
|
||||
{
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
int i;
|
||||
|
||||
i = findhandle ();
|
||||
|
@ -183,7 +183,7 @@ int Sys_FileWrite (int handle, void *data, int count)
|
|||
|
||||
int Sys_FileTime (char *path)
|
||||
{
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
|
||||
f = fopen(path, "rb");
|
||||
if (f)
|
||||
|
|
|
@ -105,7 +105,7 @@ FILE IO
|
|||
*/
|
||||
|
||||
#define MAX_HANDLES 10
|
||||
FILE *sys_handles[MAX_HANDLES];
|
||||
QFile *sys_handles[MAX_HANDLES];
|
||||
|
||||
int findhandle (void)
|
||||
{
|
||||
|
@ -123,7 +123,7 @@ int findhandle (void)
|
|||
filelength
|
||||
================
|
||||
*/
|
||||
int filelength (FILE *f)
|
||||
int filelength (QFile *f)
|
||||
{
|
||||
int pos;
|
||||
int end;
|
||||
|
@ -143,7 +143,7 @@ int filelength (FILE *f)
|
|||
|
||||
int Sys_FileOpenRead (char *path, int *hndl)
|
||||
{
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
int i, retval;
|
||||
int t;
|
||||
|
||||
|
@ -172,7 +172,7 @@ int Sys_FileOpenRead (char *path, int *hndl)
|
|||
|
||||
int Sys_FileOpenWrite (char *path)
|
||||
{
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
int i;
|
||||
int t;
|
||||
|
||||
|
@ -231,7 +231,7 @@ int Sys_FileWrite (int handle, void *data, int count)
|
|||
|
||||
int Sys_FileTime (char *path)
|
||||
{
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
int t, retval;
|
||||
|
||||
t = VID_ForceUnlockedAndReturnState ();
|
||||
|
|
|
@ -45,7 +45,7 @@ FILE IO
|
|||
*/
|
||||
|
||||
#define MAX_HANDLES 10
|
||||
FILE *sys_handles[MAX_HANDLES];
|
||||
QFile *sys_handles[MAX_HANDLES];
|
||||
|
||||
int findhandle (void)
|
||||
{
|
||||
|
@ -63,7 +63,7 @@ int findhandle (void)
|
|||
filelength
|
||||
================
|
||||
*/
|
||||
int filelength (FILE *f)
|
||||
int filelength (QFile *f)
|
||||
{
|
||||
int pos;
|
||||
int end;
|
||||
|
@ -78,7 +78,7 @@ int filelength (FILE *f)
|
|||
|
||||
int Sys_FileOpenRead (char *path, int *hndl)
|
||||
{
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
int i;
|
||||
|
||||
i = findhandle ();
|
||||
|
@ -97,7 +97,7 @@ int Sys_FileOpenRead (char *path, int *hndl)
|
|||
|
||||
int Sys_FileOpenWrite (char *path)
|
||||
{
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
int i;
|
||||
|
||||
i = findhandle ();
|
||||
|
@ -133,7 +133,7 @@ int Sys_FileWrite (int handle, void *data, int count)
|
|||
|
||||
int Sys_FileTime (char *path)
|
||||
{
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
|
||||
f = fopen(path, "rb");
|
||||
if (f)
|
||||
|
|
|
@ -161,7 +161,7 @@ void VID_SetPalette (unsigned char *palette)
|
|||
int k;
|
||||
unsigned short i;
|
||||
unsigned *table;
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
char s[255];
|
||||
//#endif
|
||||
float dist, bestdist;
|
||||
|
@ -198,8 +198,8 @@ void VID_SetPalette (unsigned char *palette)
|
|||
|
||||
COM_FOpenFile("glquake/15to8.pal", &f);
|
||||
if (f) {
|
||||
fread(d_15to8table, 1<<15, 1, f);
|
||||
fclose(f);
|
||||
Qread(f, d_15to8table, 1<<15);
|
||||
Qclose(f);
|
||||
} else
|
||||
{
|
||||
for (i=0; i < (1<<15); i++) {
|
||||
|
@ -229,8 +229,8 @@ void VID_SetPalette (unsigned char *palette)
|
|||
Sys_mkdir (s);
|
||||
snprintf(s, sizeof(s), "%s/glquake/15to8.pal", com_gamedir);
|
||||
if ((f = fopen(s, "wb")) != NULL) {
|
||||
fwrite(d_15to8table, 1<<15, 1, f);
|
||||
fclose(f);
|
||||
Qwrite(f, d_15to8table, 1<<15);
|
||||
Qclose(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ void VID_SetPalette (unsigned char *palette)
|
|||
int k;
|
||||
unsigned short i;
|
||||
unsigned *table;
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
char s[255];
|
||||
float dist, bestdist;
|
||||
static qboolean palflag = false;
|
||||
|
@ -239,8 +239,8 @@ void VID_SetPalette (unsigned char *palette)
|
|||
|
||||
COM_FOpenFile("glquake/15to8.pal", &f);
|
||||
if (f) {
|
||||
fread(d_15to8table, 1<<15, 1, f);
|
||||
fclose(f);
|
||||
Qread(f, d_15to8table, 1<<15);
|
||||
Qclose(f);
|
||||
} else {
|
||||
for (i=0; i < (1<<15); i++) {
|
||||
/* Maps
|
||||
|
@ -268,9 +268,9 @@ void VID_SetPalette (unsigned char *palette)
|
|||
snprintf(s, sizeof(s), "%s/glquake", com_gamedir);
|
||||
Sys_mkdir (s);
|
||||
snprintf(s, sizeof(s), "%s/glquake/15to8.pal", com_gamedir);
|
||||
if ((f = fopen(s, "wb")) != NULL) {
|
||||
fwrite(d_15to8table, 1<<15, 1, f);
|
||||
fclose(f);
|
||||
if ((f = Qopen(s, "wb")) != NULL) {
|
||||
Qwrite(f, d_15to8table, 1<<15);
|
||||
Qclose(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ VID_SetPalette (unsigned char *palette)
|
|||
int k;
|
||||
unsigned short i;
|
||||
unsigned *table;
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
char s[256];
|
||||
float dist, bestdist;
|
||||
static qboolean palflag = false;
|
||||
|
@ -191,8 +191,8 @@ VID_SetPalette (unsigned char *palette)
|
|||
|
||||
COM_FOpenFile("glquake/15to8.pal", &f);
|
||||
if (f) {
|
||||
fread(d_15to8table, 1<<15, 1, f);
|
||||
fclose(f);
|
||||
Qread(f, d_15to8table, 1<<15);
|
||||
Qclose(f);
|
||||
} else {
|
||||
for (i=0; i < (1<<15); i++) {
|
||||
/* Maps
|
||||
|
@ -220,9 +220,9 @@ VID_SetPalette (unsigned char *palette)
|
|||
snprintf (s, sizeof (s), "%s/glquake", com_gamedir);
|
||||
Sys_mkdir (s);
|
||||
snprintf(s, sizeof (s), "%s/glquake/15to8.pal", com_gamedir);
|
||||
if ((f = fopen (s, "wb")) != NULL) {
|
||||
fwrite (d_15to8table, 1<<15, 1, f);
|
||||
fclose (f);
|
||||
if ((f = Qopen (s, "wb")) != NULL) {
|
||||
Qwrite (f, d_15to8table, 1<<15);
|
||||
Qclose (f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -721,7 +721,7 @@ void VID_SetPalette (unsigned char *palette)
|
|||
int k;
|
||||
unsigned short i;
|
||||
unsigned *table;
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
char s[255];
|
||||
float dist, bestdist;
|
||||
static qboolean palflag = false;
|
||||
|
@ -755,8 +755,8 @@ void VID_SetPalette (unsigned char *palette)
|
|||
|
||||
COM_FOpenFile("glquake/15to8.pal", &f);
|
||||
if (f) {
|
||||
fread(d_15to8table, 1<<15, 1, f);
|
||||
fclose(f);
|
||||
Qread(f, d_15to8table, 1<<15);
|
||||
Qclose(f);
|
||||
} else {
|
||||
for (i=0; i < (1<<15); i++) {
|
||||
/* Maps
|
||||
|
@ -785,8 +785,8 @@ void VID_SetPalette (unsigned char *palette)
|
|||
Sys_mkdir (s);
|
||||
snprintf(s, sizeof(s), "%s/glquake/15to8.pal", com_gamedir);
|
||||
if ((f = fopen(s, "wb")) != NULL) {
|
||||
fwrite(d_15to8table, 1<<15, 1, f);
|
||||
fclose(f);
|
||||
Qwrite(f, d_15to8table, 1<<15);
|
||||
Qclose(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue