mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-05-09 22:00:52 +00:00
Before I can fix the (MANY!) problems with newtree, I have to fix the
little problem of mixed QFile and FILE. Since we're not using ZLib in this tree, QFile makes no real sense. That didn't fix the real problem I am having though.
This commit is contained in:
parent
08b551f7ae
commit
3d59dfed98
24 changed files with 127 additions and 280 deletions
|
@ -49,8 +49,8 @@ void Server_List_Swap(server_entry_t *swap1, server_entry_t *swap2);
|
||||||
server_entry_t *Server_List_Get_By_Num(server_entry_t *start, int n);
|
server_entry_t *Server_List_Get_By_Num(server_entry_t *start, int n);
|
||||||
int Server_List_Len(server_entry_t *start);
|
int Server_List_Len(server_entry_t *start);
|
||||||
|
|
||||||
server_entry_t *Server_List_LoadF(QFile *f, server_entry_t *start);
|
server_entry_t *Server_List_LoadF(FILE *f, server_entry_t *start);
|
||||||
void Server_List_SaveF(QFile *f, server_entry_t *start);
|
void Server_List_SaveF(FILE *f, server_entry_t *start);
|
||||||
|
|
||||||
void Server_List_Del_All(server_entry_t *start);
|
void Server_List_Del_All(server_entry_t *start);
|
||||||
void Server_List_Shutdown(server_entry_t *start);
|
void Server_List_Shutdown(server_entry_t *start);
|
||||||
|
|
|
@ -199,7 +199,7 @@ typedef struct
|
||||||
|
|
||||||
int qport;
|
int qport;
|
||||||
|
|
||||||
QFile *download; // file transfer from server
|
FILE *download; // file transfer from server
|
||||||
char downloadtempname[MAX_OSPATH];
|
char downloadtempname[MAX_OSPATH];
|
||||||
char downloadname[MAX_OSPATH];
|
char downloadname[MAX_OSPATH];
|
||||||
int downloadnumber;
|
int downloadnumber;
|
||||||
|
@ -215,7 +215,7 @@ typedef struct
|
||||||
qboolean demorecording;
|
qboolean demorecording;
|
||||||
qboolean demoplayback;
|
qboolean demoplayback;
|
||||||
qboolean timedemo;
|
qboolean timedemo;
|
||||||
QFile *demofile;
|
FILE *demofile;
|
||||||
float td_lastframe; // to meter out one message a frame
|
float td_lastframe; // to meter out one message a frame
|
||||||
int td_startframe; // host_framecount at start
|
int td_startframe; // host_framecount at start
|
||||||
float td_starttime; // realtime at second frame of timedemo
|
float td_starttime; // realtime at second frame of timedemo
|
||||||
|
|
|
@ -100,7 +100,7 @@ qboolean Cvar_Command (void);
|
||||||
// command. Returns true if the command was a variable reference that
|
// command. Returns true if the command was a variable reference that
|
||||||
// was handled. (print or change)
|
// was handled. (print or change)
|
||||||
|
|
||||||
void Cvar_WriteVariables (QFile *f);
|
void Cvar_WriteVariables (FILE *f);
|
||||||
// Writes lines containing "set variable value" for all variables
|
// Writes lines containing "set variable value" for all variables
|
||||||
// with the archive flag set to true.
|
// with the archive flag set to true.
|
||||||
|
|
||||||
|
|
|
@ -175,7 +175,7 @@ extern qboolean chat_team;
|
||||||
|
|
||||||
void Key_Event (int key, qboolean down);
|
void Key_Event (int key, qboolean down);
|
||||||
void Key_Init (void);
|
void Key_Init (void);
|
||||||
void Key_WriteBindings (QFile *f);
|
void Key_WriteBindings (FILE *f);
|
||||||
void Key_SetBinding (int keynum, char *binding);
|
void Key_SetBinding (int keynum, char *binding);
|
||||||
void Key_ClearStates (void);
|
void Key_ClearStates (void);
|
||||||
|
|
||||||
|
|
|
@ -49,9 +49,9 @@ extern char com_gamedir[MAX_OSPATH];
|
||||||
extern char gamedirfile[MAX_OSPATH];
|
extern char gamedirfile[MAX_OSPATH];
|
||||||
|
|
||||||
void COM_WriteFile (char *filename, void *data, int len);
|
void COM_WriteFile (char *filename, void *data, int len);
|
||||||
int COM_FOpenFile (char *filename, QFile **gzfile);
|
int COM_FOpenFile (char *filename, FILE **gzfile);
|
||||||
void COM_CloseFile (QFile *h);
|
void COM_CloseFile (FILE *h);
|
||||||
int COM_filelength (QFile *f);
|
int COM_filelength (FILE *f);
|
||||||
void COM_FileBase (char *in, char *out);
|
void COM_FileBase (char *in, char *out);
|
||||||
void COM_DefaultExtension (char *path, char *extension);
|
void COM_DefaultExtension (char *path, char *extension);
|
||||||
char *COM_SkipPath (char *pathname);
|
char *COM_SkipPath (char *pathname);
|
||||||
|
|
|
@ -33,32 +33,22 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#ifdef HAS_ZLIB
|
|
||||||
#include <zlib.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
FILE *file;
|
|
||||||
#ifdef HAS_ZLIB
|
|
||||||
gzFile *gzfile;
|
|
||||||
#endif
|
|
||||||
} QFile;
|
|
||||||
|
|
||||||
void Qexpand_squiggle(const char *path, char *dest);
|
void Qexpand_squiggle(const char *path, char *dest);
|
||||||
int Qrename(const char *old, const char *new);
|
int Qrename(const char *old, const char *new);
|
||||||
QFile *Qopen(const char *path, const char *mode);
|
FILE *Qopen(const char *path, const char *mode);
|
||||||
QFile *Qdopen(int fd, const char *mode);
|
FILE *Qdopen(int fd, const char *mode);
|
||||||
void Qclose(QFile *file);
|
void Qclose(FILE *file);
|
||||||
int Qread(QFile *file, void *buf, int count);
|
int Qread(FILE *file, void *buf, int count);
|
||||||
int Qwrite(QFile *file, void *buf, int count);
|
int Qwrite(FILE *file, void *buf, int count);
|
||||||
int Qprintf(QFile *file, const char *fmt, ...);
|
int Qprintf(FILE *file, const char *fmt, ...);
|
||||||
char *Qgets(QFile *file, char *buf, int count);
|
char *Qgets(FILE *file, char *buf, int count);
|
||||||
int Qgetc(QFile *file);
|
int Qgetc(FILE *file);
|
||||||
int Qputc(QFile *file, int c);
|
int Qputc(FILE *file, int c);
|
||||||
int Qseek(QFile *file, long offset, int whence);
|
int Qseek(FILE *file, long offset, int whence);
|
||||||
long Qtell(QFile *file);
|
long Qtell(FILE *file);
|
||||||
int Qflush(QFile *file);
|
int Qflush(FILE *file);
|
||||||
int Qeof(QFile *file);
|
int Qeof(FILE *file);
|
||||||
|
|
||||||
|
|
||||||
#endif /*_QUAKEIO_H*/
|
#endif /*_QUAKEIO_H*/
|
||||||
|
|
|
@ -187,7 +187,7 @@ typedef struct client_s
|
||||||
|
|
||||||
client_frame_t frames[UPDATE_BACKUP]; // updates can be deltad from here
|
client_frame_t frames[UPDATE_BACKUP]; // updates can be deltad from here
|
||||||
|
|
||||||
QFile *download; // file being downloaded
|
FILE *download; // file being downloaded
|
||||||
int downloadsize; // total bytes
|
int downloadsize; // total bytes
|
||||||
int downloadcount; // bytes sent
|
int downloadcount; // bytes sent
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ typedef struct client_s
|
||||||
|
|
||||||
qboolean upgradewarn; // did we warn him?
|
qboolean upgradewarn; // did we warn him?
|
||||||
|
|
||||||
QFile *upload;
|
FILE *upload;
|
||||||
char uploadfn[MAX_QPATH];
|
char uploadfn[MAX_QPATH];
|
||||||
netadr_t snap_from;
|
netadr_t snap_from;
|
||||||
qboolean remote_snap;
|
qboolean remote_snap;
|
||||||
|
@ -363,8 +363,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 QFile *sv_logfile;
|
extern FILE *sv_logfile;
|
||||||
extern QFile *sv_fraglogfile;
|
extern FILE *sv_fraglogfile;
|
||||||
|
|
||||||
//===========================================================
|
//===========================================================
|
||||||
// FIXME: declare exported functions in their own relevant .h
|
// FIXME: declare exported functions in their own relevant .h
|
||||||
|
|
|
@ -1186,7 +1186,7 @@ CL_Init
|
||||||
*/
|
*/
|
||||||
void CL_Init (void)
|
void CL_Init (void)
|
||||||
{
|
{
|
||||||
QFile *servlist;
|
FILE *servlist;
|
||||||
char st[80];
|
char st[80];
|
||||||
|
|
||||||
cls.state = ca_disconnected;
|
cls.state = ca_disconnected;
|
||||||
|
@ -1484,7 +1484,7 @@ Writes key bindings and archived cvars to config.cfg
|
||||||
*/
|
*/
|
||||||
void Host_WriteConfiguration (void)
|
void Host_WriteConfiguration (void)
|
||||||
{
|
{
|
||||||
QFile *f;
|
FILE *f;
|
||||||
|
|
||||||
if (host_initialized)
|
if (host_initialized)
|
||||||
{
|
{
|
||||||
|
|
|
@ -178,7 +178,7 @@ to start a download from the server.
|
||||||
*/
|
*/
|
||||||
qboolean CL_CheckOrDownloadFile (char *filename)
|
qboolean CL_CheckOrDownloadFile (char *filename)
|
||||||
{
|
{
|
||||||
QFile *f;
|
FILE *f;
|
||||||
|
|
||||||
if (strstr (filename, ".."))
|
if (strstr (filename, ".."))
|
||||||
{
|
{
|
||||||
|
@ -548,7 +548,7 @@ CL_ParseServerData
|
||||||
void CL_ParseServerData (void)
|
void CL_ParseServerData (void)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
QFile *f;
|
FILE *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];
|
||||||
|
|
|
@ -138,7 +138,7 @@ int Server_List_Len (server_entry_t *start) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
server_entry_t *Server_List_LoadF (QFile *f,server_entry_t *start) { // This could get messy
|
server_entry_t *Server_List_LoadF (FILE *f,server_entry_t *start) { // This could get messy
|
||||||
char line[256]; /* Long lines get truncated. */
|
char line[256]; /* Long lines get truncated. */
|
||||||
int c = ' '; /* int so it can be compared to EOF properly*/
|
int c = ' '; /* int so it can be compared to EOF properly*/
|
||||||
int len;
|
int len;
|
||||||
|
@ -175,7 +175,7 @@ server_entry_t *Server_List_LoadF (QFile *f,server_entry_t *start) { // This cou
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server_List_SaveF (QFile *f,server_entry_t *start) {
|
void Server_List_SaveF (FILE *f,server_entry_t *start) {
|
||||||
do {
|
do {
|
||||||
Qprintf(f,"%s %s\n",start->server,start->desc);
|
Qprintf(f,"%s %s\n",start->server,start->desc);
|
||||||
start = start->next;
|
start = start->next;
|
||||||
|
@ -184,7 +184,7 @@ server_entry_t *Server_List_LoadF (QFile *f,server_entry_t *start) { // This cou
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server_List_Shutdown (server_entry_t *start) {
|
void Server_List_Shutdown (server_entry_t *start) {
|
||||||
QFile *f;
|
FILE *f;
|
||||||
if (start) {
|
if (start) {
|
||||||
if ((f = Qopen(va("%s/servers.txt",fs_userpath->string),"w"))) {
|
if ((f = Qopen(va("%s/servers.txt",fs_userpath->string),"w"))) {
|
||||||
Server_List_SaveF(f,start);
|
Server_List_SaveF(f,start);
|
||||||
|
|
|
@ -305,7 +305,7 @@ Cmd_Exec_File (char *path)
|
||||||
int mark;
|
int mark;
|
||||||
int len;
|
int len;
|
||||||
char base[32];
|
char base[32];
|
||||||
QFile *file;
|
FILE *file;
|
||||||
|
|
||||||
if ((file = Qopen (path, "r")) != NULL) {
|
if ((file = Qopen (path, "r")) != NULL) {
|
||||||
// extract the filename base name for hunk tag
|
// extract the filename base name for hunk tag
|
||||||
|
|
|
@ -62,7 +62,7 @@ being registered.
|
||||||
*/
|
*/
|
||||||
void COM_CheckRegistered (void)
|
void COM_CheckRegistered (void)
|
||||||
{
|
{
|
||||||
QFile *h;
|
FILE *h;
|
||||||
unsigned short check[128];
|
unsigned short check[128];
|
||||||
|
|
||||||
COM_FOpenFile("gfx/pop.lmp", &h);
|
COM_FOpenFile("gfx/pop.lmp", &h);
|
||||||
|
|
|
@ -247,7 +247,7 @@ Writes lines containing "set variable value" for all variables
|
||||||
with the archive flag set to true.
|
with the archive flag set to true.
|
||||||
============
|
============
|
||||||
*/
|
*/
|
||||||
void Cvar_WriteVariables (QFile *f)
|
void Cvar_WriteVariables (FILE *f)
|
||||||
{
|
{
|
||||||
cvar_t *var;
|
cvar_t *var;
|
||||||
|
|
||||||
|
|
|
@ -320,7 +320,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];
|
||||||
QFile *f;
|
FILE *f;
|
||||||
|
|
||||||
aliasmodel = m;
|
aliasmodel = m;
|
||||||
paliashdr = hdr; // (aliashdr_t *)Mod_Extradata (m);
|
paliashdr = hdr; // (aliashdr_t *)Mod_Extradata (m);
|
||||||
|
|
|
@ -120,7 +120,7 @@ void R_ClearParticles (void)
|
||||||
|
|
||||||
void R_ReadPointFile_f (void)
|
void R_ReadPointFile_f (void)
|
||||||
{
|
{
|
||||||
QFile *f;
|
FILE *f;
|
||||||
vec3_t org;
|
vec3_t org;
|
||||||
int r;
|
int r;
|
||||||
int c;
|
int c;
|
||||||
|
|
|
@ -357,7 +357,7 @@ byte *pcx_rgb;
|
||||||
LoadPCX
|
LoadPCX
|
||||||
============
|
============
|
||||||
*/
|
*/
|
||||||
void LoadPCX (QFile *f)
|
void LoadPCX (FILE *f)
|
||||||
{
|
{
|
||||||
pcx_t *pcx, pcxbuf;
|
pcx_t *pcx, pcxbuf;
|
||||||
byte palette[768];
|
byte palette[768];
|
||||||
|
@ -441,7 +441,7 @@ typedef struct _TargaHeader {
|
||||||
TargaHeader targa_header;
|
TargaHeader targa_header;
|
||||||
byte *targa_rgba;
|
byte *targa_rgba;
|
||||||
|
|
||||||
int fgetLittleShort (QFile *f)
|
int fgetLittleShort (FILE *f)
|
||||||
{
|
{
|
||||||
byte b1, b2;
|
byte b1, b2;
|
||||||
|
|
||||||
|
@ -451,7 +451,7 @@ int fgetLittleShort (QFile *f)
|
||||||
return (short)(b1 + b2*256);
|
return (short)(b1 + b2*256);
|
||||||
}
|
}
|
||||||
|
|
||||||
int fgetLittleLong (QFile *f)
|
int fgetLittleLong (FILE *f)
|
||||||
{
|
{
|
||||||
byte b1, b2, b3, b4;
|
byte b1, b2, b3, b4;
|
||||||
|
|
||||||
|
@ -469,7 +469,7 @@ int fgetLittleLong (QFile *f)
|
||||||
LoadTGA
|
LoadTGA
|
||||||
=============
|
=============
|
||||||
*/
|
*/
|
||||||
void LoadTGA (QFile *fin)
|
void LoadTGA (FILE *fin)
|
||||||
{
|
{
|
||||||
int columns, rows, numPixels;
|
int columns, rows, numPixels;
|
||||||
byte *pixbuf;
|
byte *pixbuf;
|
||||||
|
@ -626,7 +626,7 @@ char *suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"};
|
||||||
void R_LoadSkys (char * skyname)
|
void R_LoadSkys (char * skyname)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
QFile *f;
|
FILE *f;
|
||||||
char name[64];
|
char name[64];
|
||||||
|
|
||||||
if (stricmp (skyname, "none") == 0)
|
if (stricmp (skyname, "none") == 0)
|
||||||
|
|
|
@ -667,7 +667,7 @@ Key_WriteBindings
|
||||||
Writes lines containing "bind key value"
|
Writes lines containing "bind key value"
|
||||||
============
|
============
|
||||||
*/
|
*/
|
||||||
void Key_WriteBindings (QFile *f)
|
void Key_WriteBindings (FILE *f)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
|
@ -1317,33 +1317,33 @@ void M_Quit_Draw (void)
|
||||||
{
|
{
|
||||||
#define VSTR(x) #x
|
#define VSTR(x) #x
|
||||||
#define VSTR2(x) VSTR(x)
|
#define VSTR2(x) VSTR(x)
|
||||||
char *cmsg[] = {
|
// char *cmsg[] = {
|
||||||
// 0123456789012345678901234567890123456789
|
// 0123456789012345678901234567890123456789
|
||||||
"0 QuakeWorld",
|
// "0 QuakeWorld",
|
||||||
"1 version " VSTR2(VERSION) " by id Software",
|
// "1 version " VSTR2(VERSION) " by id Software",
|
||||||
"0Programming",
|
// "0Programming",
|
||||||
"1 John Carmack Michael Abrash",
|
// "1 John Carmack Michael Abrash",
|
||||||
"1 John Cash Christian Antkow",
|
// "1 John Cash Christian Antkow",
|
||||||
"0Additional Programming",
|
// "0Additional Programming",
|
||||||
"1 Dave 'Zoid' Kirsch",
|
// "1 Dave 'Zoid' Kirsch",
|
||||||
"1 Jack 'morbid' Mathews",
|
// "1 Jack 'morbid' Mathews",
|
||||||
"0Id Software is not responsible for",
|
// "0Id Software is not responsible for",
|
||||||
"0providing technical support for",
|
// "0providing technical support for",
|
||||||
"0QUAKEWORLD(tm). (c)1996 Id Software,",
|
// "0QUAKEWORLD(tm). (c)1996 Id Software,",
|
||||||
"0Inc. All Rights Reserved.",
|
// "0Inc. All Rights Reserved.",
|
||||||
"0QUAKEWORLD(tm) is a trademark of Id",
|
// "0QUAKEWORLD(tm) is a trademark of Id",
|
||||||
"0Software, Inc.",
|
// "0Software, Inc.",
|
||||||
"1NOTICE: THE COPYRIGHT AND TRADEMARK",
|
// "1NOTICE: THE COPYRIGHT AND TRADEMARK",
|
||||||
"1NOTICES APPEARING IN YOUR COPY OF",
|
// "1NOTICES APPEARING IN YOUR COPY OF",
|
||||||
"1QUAKE(r) ARE NOT MODIFIED BY THE USE",
|
// "1QUAKE(r) ARE NOT MODIFIED BY THE USE",
|
||||||
"1OF QUAKEWORLD(tm) AND REMAIN IN FULL",
|
// "1OF QUAKEWORLD(tm) AND REMAIN IN FULL",
|
||||||
"1FORCE.",
|
// "1FORCE.",
|
||||||
"0NIN(r) is a registered trademark",
|
// "0NIN(r) is a registered trademark",
|
||||||
"0licensed to Nothing Interactive, Inc.",
|
// "0licensed to Nothing Interactive, Inc.",
|
||||||
"0All rights reserved. Press y to exit",
|
// "0All rights reserved. Press y to exit",
|
||||||
NULL };
|
// NULL };
|
||||||
char **p;
|
// char **p;
|
||||||
int y;
|
// int y;
|
||||||
|
|
||||||
if (wasInMenus)
|
if (wasInMenus)
|
||||||
{
|
{
|
||||||
|
@ -1352,7 +1352,7 @@ void M_Quit_Draw (void)
|
||||||
M_Draw ();
|
M_Draw ();
|
||||||
m_state = m_quit;
|
m_state = m_quit;
|
||||||
}
|
}
|
||||||
#if 1
|
#if 0
|
||||||
M_DrawTextBox (0, 0, 38, 23);
|
M_DrawTextBox (0, 0, 38, 23);
|
||||||
y = 12;
|
y = 12;
|
||||||
for (p = cmsg; *p; p++, y += 8) {
|
for (p = cmsg; *p; p++, y += 8) {
|
||||||
|
|
|
@ -121,7 +121,7 @@ typedef struct
|
||||||
typedef struct pack_s
|
typedef struct pack_s
|
||||||
{
|
{
|
||||||
char filename[MAX_OSPATH];
|
char filename[MAX_OSPATH];
|
||||||
QFile *handle;
|
FILE *handle;
|
||||||
int numfiles;
|
int numfiles;
|
||||||
packfile_t *files;
|
packfile_t *files;
|
||||||
} pack_t;
|
} pack_t;
|
||||||
|
@ -186,7 +186,7 @@ COM_FileBase (char *in, char *out)
|
||||||
COM_filelength
|
COM_filelength
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
COM_filelength (QFile *f)
|
COM_filelength (FILE *f)
|
||||||
{
|
{
|
||||||
int pos;
|
int pos;
|
||||||
int end;
|
int end;
|
||||||
|
@ -203,9 +203,9 @@ COM_filelength (QFile *f)
|
||||||
COM_FileOpenRead
|
COM_FileOpenRead
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
COM_FileOpenRead (char *path, QFile **hndl)
|
COM_FileOpenRead (char *path, FILE **hndl)
|
||||||
{
|
{
|
||||||
QFile *f;
|
FILE *f;
|
||||||
|
|
||||||
f = Qopen(path, "rbz");
|
f = Qopen(path, "rbz");
|
||||||
if (!f)
|
if (!f)
|
||||||
|
@ -285,7 +285,7 @@ COM_Maplist_f ( void )
|
||||||
void
|
void
|
||||||
COM_WriteFile ( char *filename, void *data, int len )
|
COM_WriteFile ( char *filename, void *data, int len )
|
||||||
{
|
{
|
||||||
QFile *f;
|
FILE *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);
|
||||||
|
@ -338,7 +338,7 @@ COM_CreatePath ( char *path )
|
||||||
void
|
void
|
||||||
COM_CopyFile (char *netpath, char *cachepath)
|
COM_CopyFile (char *netpath, char *cachepath)
|
||||||
{
|
{
|
||||||
QFile *in, *out;
|
FILE *in, *out;
|
||||||
int remaining, count;
|
int remaining, count;
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
|
|
||||||
|
@ -366,7 +366,7 @@ COM_CopyFile (char *netpath, char *cachepath)
|
||||||
/*
|
/*
|
||||||
COM_OpenRead
|
COM_OpenRead
|
||||||
*/
|
*/
|
||||||
QFile *
|
FILE *
|
||||||
COM_OpenRead (const char *path, int offs, int len)
|
COM_OpenRead (const char *path, int offs, int len)
|
||||||
{
|
{
|
||||||
int fd=open(path,O_RDONLY);
|
int fd=open(path,O_RDONLY);
|
||||||
|
@ -406,7 +406,7 @@ int file_from_pak; // global indicating file came from pack file ZOID
|
||||||
Sets com_filesize and one of handle or file
|
Sets com_filesize and one of handle or file
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
COM_FOpenFile (char *filename, QFile **gzfile)
|
COM_FOpenFile (char *filename, FILE **gzfile)
|
||||||
{
|
{
|
||||||
searchpath_t *search;
|
searchpath_t *search;
|
||||||
char netpath[MAX_OSPATH];
|
char netpath[MAX_OSPATH];
|
||||||
|
@ -482,7 +482,7 @@ int loadsize;
|
||||||
byte *
|
byte *
|
||||||
COM_LoadFile (char *path, int usehunk)
|
COM_LoadFile (char *path, int usehunk)
|
||||||
{
|
{
|
||||||
QFile *h;
|
FILE *h;
|
||||||
byte *buf;
|
byte *buf;
|
||||||
char base[32];
|
char base[32];
|
||||||
int len;
|
int len;
|
||||||
|
@ -579,7 +579,7 @@ COM_LoadPackFile (char *packfile)
|
||||||
packfile_t *newfiles;
|
packfile_t *newfiles;
|
||||||
int numpackfiles;
|
int numpackfiles;
|
||||||
pack_t *pack;
|
pack_t *pack;
|
||||||
QFile *packhandle;
|
FILE *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)
|
||||||
|
|
221
source/quakeio.c
221
source/quakeio.c
|
@ -32,24 +32,24 @@
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_MALLOC_H
|
#ifdef HAVE_MALLOC_H
|
||||||
#include <malloc.h>
|
# include <malloc.h>
|
||||||
#endif
|
#endif
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <quakeio.h>
|
#include <quakeio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <io.h>
|
# include <io.h>
|
||||||
#include <fcntl.h>
|
# include <fcntl.h>
|
||||||
#else
|
#else
|
||||||
#include <pwd.h>
|
# include <pwd.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define _POSIX_
|
# define _POSIX_
|
||||||
#endif
|
#endif
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
@ -91,247 +91,104 @@ Qrename(const char *old, const char *new)
|
||||||
return rename (e_old, e_new);
|
return rename (e_old, e_new);
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile *
|
FILE *
|
||||||
Qopen(const char *path, const char *mode)
|
Qopen(const char *path, const char *mode)
|
||||||
{
|
{
|
||||||
QFile *file;
|
FILE *file;
|
||||||
char m[80],*p;
|
|
||||||
int zip=0;
|
|
||||||
char e_path[PATH_MAX];
|
char e_path[PATH_MAX];
|
||||||
|
|
||||||
Qexpand_squiggle (path, e_path);
|
Qexpand_squiggle (path, e_path);
|
||||||
path = e_path;
|
path = e_path;
|
||||||
|
|
||||||
for (p=m; *mode && p-m<(sizeof(m)-1); mode++) {
|
file=fopen(path,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;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile *
|
FILE *
|
||||||
Qdopen(int fd, const char *mode)
|
Qdopen(int fd, const char *mode)
|
||||||
{
|
{
|
||||||
QFile *file;
|
FILE *file;
|
||||||
char m[80],*p;
|
|
||||||
int zip=0;
|
|
||||||
|
|
||||||
for (p=m; *mode && p-m<(sizeof(m)-1); mode++) {
|
file=fdopen(fd,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 WIN32
|
||||||
#ifdef __BORLANDC__
|
# ifdef __BORLANDC__
|
||||||
setmode(_fileno(file->file),O_BINARY);
|
setmode(_fileno(file),O_BINARY);
|
||||||
#else
|
# else
|
||||||
_setmode(_fileno(file->file),_O_BINARY);
|
_setmode(_fileno(file),_O_BINARY);
|
||||||
#endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Qclose(QFile *file)
|
Qclose(FILE *file)
|
||||||
{
|
{
|
||||||
if (file->file)
|
fclose(file);
|
||||||
fclose(file->file);
|
|
||||||
#ifdef HAS_ZLIB
|
|
||||||
else
|
|
||||||
gzclose(file->gzfile);
|
|
||||||
#endif
|
|
||||||
free(file);
|
free(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Qread(QFile *file, void *buf, int count)
|
Qread(FILE *file, void *buf, int count)
|
||||||
{
|
{
|
||||||
if (file->file)
|
return fread(buf, 1, count, file);
|
||||||
return fread(buf, 1, count, file->file);
|
|
||||||
#ifdef HAS_ZLIB
|
|
||||||
else
|
|
||||||
return gzread(file->gzfile,buf,count);
|
|
||||||
#else
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Qwrite(QFile *file, void *buf, int count)
|
Qwrite(FILE *file, void *buf, int count)
|
||||||
{
|
{
|
||||||
if (file->file)
|
return fwrite(buf, 1, count, file);
|
||||||
return fwrite(buf, 1, count, file->file);
|
|
||||||
#ifdef HAS_ZLIB
|
|
||||||
else
|
|
||||||
return gzwrite(file->gzfile,buf,count);
|
|
||||||
#else
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Qprintf(QFile *file, const char *fmt, ...)
|
Qprintf(FILE *file, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
int ret=-1;
|
int ret=-1;
|
||||||
|
|
||||||
va_start(args,fmt);
|
va_start(args,fmt);
|
||||||
if (file->file)
|
ret=vfprintf(file, fmt, args);
|
||||||
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);
|
va_end(args);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
Qgets(QFile *file, char *buf, int count)
|
Qgets(FILE *file, char *buf, int count)
|
||||||
{
|
{
|
||||||
if (file->file)
|
return fgets(buf, count, file);
|
||||||
return fgets(buf, count, file->file);
|
|
||||||
#ifdef HAS_ZLIB
|
|
||||||
else
|
|
||||||
return gzgets(file->gzfile,buf,count);
|
|
||||||
#else
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Qgetc(QFile *file)
|
Qgetc(FILE *file)
|
||||||
{
|
{
|
||||||
if (file->file)
|
return fgetc(file);
|
||||||
return fgetc(file->file);
|
|
||||||
#ifdef HAS_ZLIB
|
|
||||||
else
|
|
||||||
return gzgetc(file->gzfile);
|
|
||||||
#else
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Qputc(QFile *file, int c)
|
Qputc(FILE *file, int c)
|
||||||
{
|
{
|
||||||
if (file->file)
|
return fputc(c, file);
|
||||||
return fputc(c, file->file);
|
|
||||||
#ifdef HAS_ZLIB
|
|
||||||
else
|
|
||||||
return gzputc(file->gzfile,c);
|
|
||||||
#else
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Qseek(QFile *file, long offset, int whence)
|
Qseek(FILE *file, long offset, int whence)
|
||||||
{
|
{
|
||||||
if (file->file)
|
return fseek(file, offset, whence);
|
||||||
return fseek(file->file, offset, whence);
|
|
||||||
#ifdef HAS_ZLIB
|
|
||||||
else
|
|
||||||
return gzseek(file->gzfile,offset,whence);
|
|
||||||
#else
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long
|
long
|
||||||
Qtell(QFile *file)
|
Qtell(FILE *file)
|
||||||
{
|
{
|
||||||
if (file->file)
|
return ftell(file);
|
||||||
return ftell(file->file);
|
|
||||||
#ifdef HAS_ZLIB
|
|
||||||
else
|
|
||||||
return gztell(file->gzfile);
|
|
||||||
#else
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Qflush(QFile *file)
|
Qflush(FILE *file)
|
||||||
{
|
{
|
||||||
if (file->file)
|
return fflush(file);
|
||||||
return fflush(file->file);
|
|
||||||
#ifdef HAS_ZLIB
|
|
||||||
else
|
|
||||||
return gzflush(file->gzfile,Z_SYNC_FLUSH);
|
|
||||||
#else
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Qeof(QFile *file)
|
Qeof(FILE *file)
|
||||||
{
|
{
|
||||||
if (file->file)
|
return feof(file);
|
||||||
return feof(file->file);
|
|
||||||
#ifdef HAS_ZLIB
|
|
||||||
else
|
|
||||||
return gzeof(file->gzfile);
|
|
||||||
#else
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ void R_ClearParticles (void)
|
||||||
|
|
||||||
void R_ReadPointFile_f (void)
|
void R_ReadPointFile_f (void)
|
||||||
{
|
{
|
||||||
QFile *f;
|
FILE *f;
|
||||||
vec3_t org;
|
vec3_t org;
|
||||||
int r;
|
int r;
|
||||||
int c;
|
int c;
|
||||||
|
|
|
@ -332,7 +332,7 @@ void SV_Map_f (void)
|
||||||
{
|
{
|
||||||
char level[MAX_QPATH];
|
char level[MAX_QPATH];
|
||||||
char expanded[MAX_QPATH];
|
char expanded[MAX_QPATH];
|
||||||
QFile *f;
|
FILE *f;
|
||||||
|
|
||||||
if (Cmd_Argc() != 2)
|
if (Cmd_Argc() != 2)
|
||||||
{
|
{
|
||||||
|
|
|
@ -163,8 +163,8 @@ cvar_t *watervis;
|
||||||
CVAR_FIXME */
|
CVAR_FIXME */
|
||||||
cvar_t *hostname;
|
cvar_t *hostname;
|
||||||
|
|
||||||
QFile *sv_logfile;
|
FILE *sv_logfile;
|
||||||
QFile *sv_fraglogfile;
|
FILE *sv_fraglogfile;
|
||||||
|
|
||||||
void SV_AcceptClient (netadr_t adr, int userid, char *userinfo);
|
void SV_AcceptClient (netadr_t adr, int userid, char *userinfo);
|
||||||
void Master_Shutdown (void);
|
void Master_Shutdown (void);
|
||||||
|
@ -1110,7 +1110,7 @@ SV_WriteIP_f
|
||||||
*/
|
*/
|
||||||
void SV_WriteIP_f (void)
|
void SV_WriteIP_f (void)
|
||||||
{
|
{
|
||||||
QFile *f;
|
FILE *f;
|
||||||
char name[MAX_OSPATH];
|
char name[MAX_OSPATH];
|
||||||
byte b[4];
|
byte b[4];
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -480,7 +480,7 @@ void VID_SetPalette (unsigned char *palette)
|
||||||
int k;
|
int k;
|
||||||
unsigned short i;
|
unsigned short i;
|
||||||
unsigned *table;
|
unsigned *table;
|
||||||
QFile *f;
|
FILE *f;
|
||||||
char s[255];
|
char s[255];
|
||||||
float dist, bestdist;
|
float dist, bestdist;
|
||||||
static qboolean palflag = false;
|
static qboolean palflag = false;
|
||||||
|
|
Loading…
Reference in a new issue