revert back to using f* for file io. I hope this fixes the catapult, but I wouldn't be suprised if it doesn't.

This commit is contained in:
Bill Currie 2000-05-23 22:43:36 +00:00
parent 02eaf75b18
commit e98edd5f5f
15 changed files with 113 additions and 115 deletions

View file

@ -69,7 +69,7 @@ void CL_StopPlayback (void)
if (!cls.demoplayback) if (!cls.demoplayback)
return; return;
Qclose (cls.demofile); fclose (cls.demofile);
cls.demofile = NULL; cls.demofile = NULL;
cls.state = ca_disconnected; cls.state = ca_disconnected;
cls.demoplayback = 0; cls.demoplayback = 0;
@ -99,10 +99,10 @@ void CL_WriteDemoCmd (usercmd_t *pcmd)
//Con_Printf("write: %ld bytes, %4.4f\n", msg->cursize, realtime); //Con_Printf("write: %ld bytes, %4.4f\n", msg->cursize, realtime);
fl = LittleFloat((float)realtime); fl = LittleFloat((float)realtime);
Qwrite (cls.demofile, &fl, sizeof(fl)); fwrite (&fl, sizeof(fl), 1, cls.demofile);
c = dem_cmd; c = dem_cmd;
Qwrite (cls.demofile, &c, sizeof(c)); fwrite (&c, sizeof(c), 1, cls.demofile);
// correct for byte order, bytes don't matter // correct for byte order, bytes don't matter
cmd = *pcmd; cmd = *pcmd;
@ -113,15 +113,15 @@ void CL_WriteDemoCmd (usercmd_t *pcmd)
cmd.sidemove = LittleShort(cmd.sidemove); cmd.sidemove = LittleShort(cmd.sidemove);
cmd.upmove = LittleShort(cmd.upmove); cmd.upmove = LittleShort(cmd.upmove);
Qwrite(cls.demofile, &cmd, sizeof(cmd)); fwrite(&cmd, sizeof(cmd), 1, cls.demofile);
for (i=0 ; i<3 ; i++) for (i=0 ; i<3 ; i++)
{ {
fl = LittleFloat (cl.viewangles[i]); fl = LittleFloat (cl.viewangles[i]);
Qwrite (cls.demofile, &fl, 4); fwrite (&fl, 4, 1, cls.demofile);
} }
Qflush (cls.demofile); fflush (cls.demofile);
} }
/* /*
@ -143,16 +143,16 @@ void CL_WriteDemoMessage (sizebuf_t *msg)
return; return;
fl = LittleFloat((float)realtime); fl = LittleFloat((float)realtime);
Qwrite (cls.demofile, &fl, sizeof(fl)); fwrite (&fl, sizeof(fl), 1, cls.demofile);
c = dem_read; c = dem_read;
Qwrite (cls.demofile, &c, sizeof(c)); fwrite (&c, sizeof(c), 1, cls.demofile);
len = LittleLong (msg->cursize); len = LittleLong (msg->cursize);
Qwrite (cls.demofile, &len, 4); fwrite (&len, 4, 1, cls.demofile);
Qwrite (cls.demofile, msg->data, msg->cursize); fwrite (msg->data, msg->cursize, 1, cls.demofile);
Qflush (cls.demofile); fflush (cls.demofile);
} }
/* /*
@ -171,7 +171,7 @@ qboolean CL_GetDemoMessage (void)
usercmd_t *pcmd; usercmd_t *pcmd;
// read the time from the packet // read the time from the packet
Qread(cls.demofile, &demotime, sizeof(demotime)); fread(&demotime, sizeof(demotime), 1, cls.demofile);
demotime = LittleFloat(demotime); demotime = LittleFloat(demotime);
// decide if it is time to grab the next message // decide if it is time to grab the next message
@ -181,7 +181,7 @@ qboolean CL_GetDemoMessage (void)
else if (demotime > cls.td_lastframe) { else if (demotime > cls.td_lastframe) {
cls.td_lastframe = demotime; cls.td_lastframe = demotime;
// rewind back to time // rewind back to time
Qseek(cls.demofile, Qtell(cls.demofile) - sizeof(demotime), fseek(cls.demofile, ftell(cls.demofile) - sizeof(demotime),
SEEK_SET); SEEK_SET);
return 0; // allready read this frame's message return 0; // allready read this frame's message
} }
@ -195,12 +195,12 @@ qboolean CL_GetDemoMessage (void)
// too far back // too far back
realtime = demotime - 1.0; realtime = demotime - 1.0;
// rewind back to time // rewind back to time
Qseek(cls.demofile, Qtell(cls.demofile) - sizeof(demotime), fseek(cls.demofile, ftell(cls.demofile) - sizeof(demotime),
SEEK_SET); SEEK_SET);
return 0; return 0;
} else if (realtime < demotime) { } else if (realtime < demotime) {
// rewind back to time // rewind back to time
Qseek(cls.demofile, Qtell(cls.demofile) - sizeof(demotime), fseek(cls.demofile, ftell(cls.demofile) - sizeof(demotime),
SEEK_SET); SEEK_SET);
return 0; // don't need another message yet return 0; // don't need another message yet
} }
@ -211,14 +211,14 @@ qboolean CL_GetDemoMessage (void)
Host_Error ("CL_GetDemoMessage: cls.state != ca_active"); Host_Error ("CL_GetDemoMessage: cls.state != ca_active");
// get the msg type // get the msg type
Qread (cls.demofile, &c, sizeof(c)); fread (&c, sizeof(c), 1, cls.demofile);
switch (c) { switch (c) {
case dem_cmd : case dem_cmd :
// user sent input // user sent input
i = cls.netchan.outgoing_sequence & UPDATE_MASK; i = cls.netchan.outgoing_sequence & UPDATE_MASK;
pcmd = &cl.frames[i].cmd; pcmd = &cl.frames[i].cmd;
r = Qread (cls.demofile, pcmd, sizeof(*pcmd)); r = fread (pcmd, sizeof(*pcmd), 1, cls.demofile);
if (r != 1) if (r != 1)
{ {
CL_StopPlayback (); CL_StopPlayback ();
@ -235,19 +235,19 @@ qboolean CL_GetDemoMessage (void)
cls.netchan.outgoing_sequence++; cls.netchan.outgoing_sequence++;
for (i=0 ; i<3 ; i++) for (i=0 ; i<3 ; i++)
{ {
r = Qread (cls.demofile, &f, 4); r = fread (&f, 4, 1, cls.demofile);
cl.viewangles[i] = LittleFloat (f); cl.viewangles[i] = LittleFloat (f);
} }
break; break;
case dem_read: case dem_read:
// get the next message // get the next message
Qread (cls.demofile, &net_message.cursize, 4); fread (&net_message.cursize, 4, 1, cls.demofile);
net_message.cursize = LittleLong (net_message.cursize); net_message.cursize = LittleLong (net_message.cursize);
//Con_Printf("read: %ld bytes\n", net_message.cursize); //Con_Printf("read: %ld bytes\n", 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 = Qread (cls.demofile, net_message.data, net_message.cursize); r = fread (net_message.data, net_message.cursize, 1, cls.demofile);
if (r != 1) if (r != 1)
{ {
CL_StopPlayback (); CL_StopPlayback ();
@ -256,9 +256,9 @@ qboolean CL_GetDemoMessage (void)
break; break;
case dem_set : case dem_set :
Qread (cls.demofile, &i, 4); fread (&i, 4, 1, cls.demofile);
cls.netchan.outgoing_sequence = LittleLong(i); cls.netchan.outgoing_sequence = LittleLong(i);
Qread (cls.demofile, &i, 4); fread (&i, 4, 1, cls.demofile);
cls.netchan.incoming_sequence = LittleLong(i); cls.netchan.incoming_sequence = LittleLong(i);
break; break;
@ -315,7 +315,7 @@ void CL_Stop_f (void)
CL_WriteDemoMessage (&net_message); CL_WriteDemoMessage (&net_message);
// finish up // finish up
Qclose (cls.demofile); fclose (cls.demofile);
cls.demofile = NULL; cls.demofile = NULL;
cls.demorecording = false; cls.demorecording = false;
Con_Printf ("Completed demo\n"); Con_Printf ("Completed demo\n");
@ -342,21 +342,21 @@ void CL_WriteRecordDemoMessage (sizebuf_t *msg, int seq)
return; return;
fl = LittleFloat((float)realtime); fl = LittleFloat((float)realtime);
Qwrite (cls.demofile, &fl, sizeof(fl)); fwrite (&fl, sizeof(fl), 1, cls.demofile);
c = dem_read; c = dem_read;
Qwrite (cls.demofile, &c, sizeof(c)); fwrite (&c, sizeof(c), 1, cls.demofile);
len = LittleLong (msg->cursize + 8); len = LittleLong (msg->cursize + 8);
Qwrite (cls.demofile, &len, 4); fwrite (&len, 4, 1, cls.demofile);
i = LittleLong(seq); i = LittleLong(seq);
Qwrite (cls.demofile, &i, 4); fwrite (&i, 4, 1, cls.demofile);
Qwrite (cls.demofile, &i, 4); fwrite (&i, 4, 1, cls.demofile);
Qwrite (cls.demofile, msg->data, msg->cursize); fwrite (msg->data, msg->cursize, 1, cls.demofile);
Qflush (cls.demofile); fflush (cls.demofile);
} }
@ -372,17 +372,17 @@ void CL_WriteSetDemoMessage (void)
return; return;
fl = LittleFloat((float)realtime); fl = LittleFloat((float)realtime);
Qwrite (cls.demofile, &fl, sizeof(fl)); fwrite (&fl, sizeof(fl), 1, cls.demofile);
c = dem_set; c = dem_set;
Qwrite (cls.demofile, &c, sizeof(c)); fwrite (&c, sizeof(c), 1, cls.demofile);
len = LittleLong(cls.netchan.outgoing_sequence); len = LittleLong(cls.netchan.outgoing_sequence);
Qwrite (cls.demofile, &len, 4); fwrite (&len, 4, 1, cls.demofile);
len = LittleLong(cls.netchan.incoming_sequence); len = LittleLong(cls.netchan.incoming_sequence);
Qwrite (cls.demofile, &len, 4); fwrite (&len, 4, 1, cls.demofile);
Qflush (cls.demofile); fflush (cls.demofile);
} }
@ -431,7 +431,7 @@ void CL_Record_f (void)
// //
COM_DefaultExtension (name, ".qwd"); COM_DefaultExtension (name, ".qwd");
cls.demofile = Qopen (name, "wb"); cls.demofile = fopen (name, "wb");
if (!cls.demofile) if (!cls.demofile)
{ {
Con_Printf ("ERROR: couldn't open.\n"); Con_Printf ("ERROR: couldn't open.\n");
@ -717,7 +717,7 @@ void CL_ReRecord_f (void)
// //
COM_DefaultExtension (name, ".qwd"); COM_DefaultExtension (name, ".qwd");
cls.demofile = Qopen (name, "wb"); cls.demofile = fopen (name, "wb");
if (!cls.demofile) if (!cls.demofile)
{ {
Con_Printf ("ERROR: couldn't open.\n"); Con_Printf ("ERROR: couldn't open.\n");

View file

@ -548,7 +548,7 @@ void CL_Disconnect (void)
Cam_Reset(); Cam_Reset();
if (cls.download) { if (cls.download) {
Qclose(cls.download); fclose(cls.download);
cls.download = NULL; cls.download = NULL;
} }
@ -1158,7 +1158,7 @@ void CL_Download_f (void)
} }
strncpy (cls.downloadtempname, cls.downloadname, sizeof(cls.downloadtempname)); strncpy (cls.downloadtempname, cls.downloadname, sizeof(cls.downloadtempname));
cls.download = Qopen (cls.downloadname, "wb"); cls.download = fopen (cls.downloadname, "wb");
cls.downloadtype = dl_single; cls.downloadtype = dl_single;
MSG_WriteByte (&cls.netchan.message, clc_stringcmd); MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
@ -1207,9 +1207,9 @@ void CL_Init (void)
CL_InitCam (); CL_InitCam ();
Pmove_Init (); Pmove_Init ();
if ((servlist = Qopen(va("%s/servers.txt",fs_userpath->string),"r"))) { if ((servlist = fopen(va("%s/servers.txt",fs_userpath->string),"r"))) {
slist = Server_List_LoadF(servlist,slist); slist = Server_List_LoadF(servlist,slist);
Qclose(servlist); fclose(servlist);
} }
@ -1488,7 +1488,7 @@ void Host_WriteConfiguration (void)
if (host_initialized) if (host_initialized)
{ {
f = Qopen (va("%s/config.cfg",com_gamedir), "w"); f = fopen (va("%s/config.cfg",com_gamedir), "w");
if (!f) if (!f)
{ {
Con_Printf ("Couldn't write config.cfg.\n"); Con_Printf ("Couldn't write config.cfg.\n");
@ -1498,7 +1498,7 @@ void Host_WriteConfiguration (void)
Key_WriteBindings (f); Key_WriteBindings (f);
Cvar_WriteVariables (f); Cvar_WriteVariables (f);
Qclose (f); fclose (f);
} }
} }

View file

@ -190,7 +190,7 @@ qboolean CL_CheckOrDownloadFile (char *filename)
COM_FOpenFile (filename, &f); COM_FOpenFile (filename, &f);
if (f) if (f)
{ // it exists, no need to download { // it exists, no need to download
Qclose (f); fclose (f);
return true; return true;
} }
@ -378,7 +378,7 @@ void CL_ParseDownload (void)
if (cls.download) if (cls.download)
{ {
Con_Printf ("cls.download shouldn't have been set\n"); Con_Printf ("cls.download shouldn't have been set\n");
Qclose (cls.download); fclose (cls.download);
cls.download = NULL; cls.download = NULL;
} }
CL_RequestNextDownload (); CL_RequestNextDownload ();
@ -395,7 +395,7 @@ void CL_ParseDownload (void)
COM_CreatePath (name); COM_CreatePath (name);
cls.download = Qopen (name, "wb"); cls.download = fopen (name, "wb");
if (!cls.download) if (!cls.download)
{ {
msg_readcount += size; msg_readcount += size;
@ -405,7 +405,7 @@ void CL_ParseDownload (void)
} }
} }
Qwrite (cls.download, net_message.data + msg_readcount, size); fwrite (net_message.data + msg_readcount, 1, size, cls.download);
msg_readcount += size; msg_readcount += size;
if (percent != 100) if (percent != 100)
@ -434,7 +434,7 @@ void CL_ParseDownload (void)
Con_Printf ("100%%\n"); Con_Printf ("100%%\n");
#endif #endif
Qclose (cls.download); fclose (cls.download);
// rename the temp file to it's final name // rename the temp file to it's final name
if (strcmp(cls.downloadtempname, cls.downloadname)) { if (strcmp(cls.downloadtempname, cls.downloadname)) {
@ -586,21 +586,21 @@ void CL_ParseServerData (void)
if (cflag) { if (cflag) {
int cl_warncmd_val = cl_warncmd->value; int cl_warncmd_val = cl_warncmd->value;
snprintf(fn, sizeof(fn), "%s/%s", com_gamedir, "config.cfg"); snprintf(fn, sizeof(fn), "%s/%s", com_gamedir, "config.cfg");
if ((f = Qopen(fn, "r")) != NULL) { if ((f = fopen(fn, "r")) != NULL) {
Qclose(f); fclose(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");
} }
snprintf(fn, sizeof(fn), "%s/%s", com_gamedir, "frontend.cfg"); snprintf(fn, sizeof(fn), "%s/%s", com_gamedir, "frontend.cfg");
if ((f = Qopen(fn, "r")) != NULL) { if ((f = fopen(fn, "r")) != NULL) {
Qclose(f); fclose(f);
Cbuf_AddText ("cl_warncmd 0\n"); Cbuf_AddText ("cl_warncmd 0\n");
Cbuf_AddText ("exec frontend.cfg\n"); Cbuf_AddText ("exec frontend.cfg\n");
} }
if (cl_autoexec->value) { if (cl_autoexec->value) {
snprintf(fn, sizeof(fn), "%s/%s", com_gamedir, "autoexec.cfg"); snprintf(fn, sizeof(fn), "%s/%s", com_gamedir, "autoexec.cfg");
if ((f = Qopen(fn, "r")) != NULL) { if ((f = fopen(fn, "r")) != NULL) {
Qclose(f); fclose(f);
Cbuf_AddText ("cl_warncmd 0\n"); Cbuf_AddText ("cl_warncmd 0\n");
Cbuf_AddText ("exec autoexec.cfg\n"); Cbuf_AddText ("exec autoexec.cfg\n");
} }

View file

@ -151,7 +151,7 @@ server_entry_t *Server_List_LoadF (FILE *f,server_entry_t *start) { // This coul
i = 0; i = 0;
c = ' '; c = ' ';
while (c != '\n' && c != EOF) { while (c != '\n' && c != EOF) {
c = Qgetc(f); c = getc(f);
if (i < 255) { if (i < 255) {
line[i] = c; line[i] = c;
i++; i++;
@ -177,7 +177,7 @@ server_entry_t *Server_List_LoadF (FILE *f,server_entry_t *start) { // This coul
void Server_List_SaveF (FILE *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); fprintf(f,"%s %s\n",start->server,start->desc);
start = start->next; start = start->next;
} while (start); } while (start);
@ -186,9 +186,9 @@ server_entry_t *Server_List_LoadF (FILE *f,server_entry_t *start) { // This coul
void Server_List_Shutdown (server_entry_t *start) { void Server_List_Shutdown (server_entry_t *start) {
FILE *f; FILE *f;
if (start) { if (start) {
if ((f = Qopen(va("%s/servers.txt",fs_userpath->string),"w"))) { if ((f = fopen(va("%s/servers.txt",fs_userpath->string),"w"))) {
Server_List_SaveF(f,start); Server_List_SaveF(f,start);
Qclose(f); fclose(f);
} }
Server_List_Del_All (start); Server_List_Del_All (start);
} }

View file

@ -307,7 +307,7 @@ Cmd_Exec_File (char *path)
char base[32]; char base[32];
FILE *file; FILE *file;
if ((file = Qopen (path, "r")) != NULL) { if ((file = fopen (path, "r")) != NULL) {
// extract the filename base name for hunk tag // extract the filename base name for hunk tag
COM_FileBase (path, base); COM_FileBase (path, base);
len = COM_filelength (file); len = COM_filelength (file);
@ -315,8 +315,8 @@ Cmd_Exec_File (char *path)
f = (char *)Hunk_AllocName (len+1, base); f = (char *)Hunk_AllocName (len+1, base);
if (f) { if (f) {
f[len] = 0; f[len] = 0;
Qread (file, f, len); fread (f, 1, len, file);
Qclose (file); fclose (file);
Cbuf_InsertText (f); Cbuf_InsertText (f);
} }
Hunk_FreeToLowMark (mark); Hunk_FreeToLowMark (mark);

View file

@ -70,8 +70,8 @@ void COM_CheckRegistered (void)
if (h) { if (h) {
static_registered = 1; static_registered = 1;
Qread (h, check, sizeof(check)); fread (check, 1, sizeof(check), h);
Qclose (h); fclose (h);
} }
if (static_registered) { if (static_registered) {

View file

@ -275,7 +275,7 @@ void Cvar_WriteVariables (FILE *f)
for (var = cvar_vars ; var ; var = var->next) for (var = cvar_vars ; var ; var = var->next)
if (var->flags&CVAR_ARCHIVE) if (var->flags&CVAR_ARCHIVE)
Qprintf (f, "%s \"%s\"\n", var->name, var->string); fprintf (f, "%s \"%s\"\n", var->name, var->string);
} }
void Cvar_Set_f(void) void Cvar_Set_f(void)

View file

@ -673,7 +673,7 @@ void Key_WriteBindings (FILE *f)
for (i=0 ; i<256 ; i++) for (i=0 ; i<256 ; i++)
if (keybindings[i]) if (keybindings[i])
Qprintf (f, "bind %s \"%s\"\n", Key_KeynumToString(i), keybindings[i]); fprintf (f, "bind %s \"%s\"\n", Key_KeynumToString(i), keybindings[i]);
} }

View file

@ -1576,8 +1576,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) {
Qprintf (sv_fraglogfile, s); fprintf (sv_fraglogfile, s);
Qflush (sv_fraglogfile); fflush (sv_fraglogfile);
} }
} }

View file

@ -191,10 +191,10 @@ COM_filelength (FILE *f)
int pos; int pos;
int end; int end;
pos = Qtell (f); pos = ftell (f);
Qseek (f, 0, SEEK_END); fseek (f, 0, SEEK_END);
end = Qtell (f); end = ftell (f);
Qseek (f, pos, SEEK_SET); fseek (f, pos, SEEK_SET);
return end; return end;
} }
@ -207,7 +207,7 @@ COM_FileOpenRead (char *path, FILE **hndl)
{ {
FILE *f; FILE *f;
f = Qopen(path, "rbz"); f = fopen(path, "rbz");
if (!f) if (!f)
{ {
*hndl = NULL; *hndl = NULL;
@ -290,17 +290,17 @@ COM_WriteFile ( char *filename, void *data, int len )
snprintf(name, sizeof(name), "%s/%s", com_gamedir, filename); snprintf(name, sizeof(name), "%s/%s", com_gamedir, filename);
f = Qopen (name, "wb"); f = fopen (name, "wb");
if (!f) { if (!f) {
Sys_mkdir(com_gamedir); Sys_mkdir(com_gamedir);
f = Qopen (name, "wb"); f = fopen (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);
Qwrite (f, data, len); fwrite (data, 1, len, f);
Qclose (f); fclose (f);
} }
@ -344,7 +344,7 @@ COM_CopyFile (char *netpath, char *cachepath)
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 = Qopen(cachepath, "wb"); out = fopen(cachepath, "wb");
if (!out) if (!out)
Sys_Error ("Error opening %s", cachepath); Sys_Error ("Error opening %s", cachepath);
@ -354,13 +354,13 @@ COM_CopyFile (char *netpath, char *cachepath)
count = remaining; count = remaining;
else else
count = sizeof(buf); count = sizeof(buf);
Qread (in, buf, count); fread (buf, 1, count, in);
Qwrite (out, buf, count); fwrite (buf, 1, count, out);
remaining -= count; remaining -= count;
} }
Qclose (in); fclose (in);
Qclose (out); fclose (out);
} }
/* /*
@ -393,7 +393,7 @@ COM_OpenRead (const char *path, int offs, int len)
} }
lseek(fd,offs,SEEK_SET); lseek(fd,offs,SEEK_SET);
com_filesize=len; com_filesize=len;
return Qdopen(fd,"rbz"); return fdopen(fd,"rbz");
return 0; return 0;
} }
@ -522,8 +522,8 @@ COM_LoadFile (char *path, int usehunk)
if (!is_server) { if (!is_server) {
Draw_BeginDisc(); Draw_BeginDisc();
} }
Qread (h, buf, len); fread (buf, 1, len, h);
Qclose (h); fclose (h);
if (!is_server) { if (!is_server) {
Draw_EndDisc(); Draw_EndDisc();
} }
@ -585,7 +585,7 @@ COM_LoadPackFile (char *packfile)
if (COM_FileOpenRead (packfile, &packhandle) == -1) if (COM_FileOpenRead (packfile, &packhandle) == -1)
return NULL; return NULL;
Qread (packhandle, &header, sizeof(header)); fread (&header, 1, sizeof(header), packhandle);
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);
@ -599,8 +599,8 @@ COM_LoadPackFile (char *packfile)
newfiles = Z_Malloc (numpackfiles * sizeof(packfile_t)); newfiles = Z_Malloc (numpackfiles * sizeof(packfile_t));
Qseek (packhandle, header.dirofs, SEEK_SET); fseek (packhandle, header.dirofs, SEEK_SET);
Qread (packhandle, info, header.dirlen); fread (info, 1, header.dirlen, packhandle);
// parse the directory // parse the directory
@ -812,7 +812,7 @@ COM_Gamedir (char *dir)
{ {
if (com_searchpaths->pack) if (com_searchpaths->pack)
{ {
Qclose (com_searchpaths->pack->handle); fclose (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);
} }

View file

@ -107,7 +107,6 @@ void R_ReadPointFile_f (void)
int c; int c;
particle_t *p; particle_t *p;
char name[MAX_OSPATH]; char name[MAX_OSPATH];
char buf[256];
// FIXME sprintf (name,"maps/%s.pts", sv.name); // FIXME sprintf (name,"maps/%s.pts", sv.name);
@ -122,9 +121,7 @@ void R_ReadPointFile_f (void)
c = 0; c = 0;
for ( ;; ) for ( ;; )
{ {
if (!Qgets(f,buf,sizeof(buf))) r = fscanf (f,"%f %f %f\n", &org[0], &org[1], &org[2]);
break;
r = sscanf (buf,"%f %f %f\n", &org[0], &org[1], &org[2]);
if (r != 3) if (r != 3)
break; break;
c++; c++;
@ -146,7 +143,7 @@ void R_ReadPointFile_f (void)
VectorCopy (org, p->org); VectorCopy (org, p->org);
} }
Qclose (f); fclose (f);
Con_Printf ("%i points read\n", c); Con_Printf ("%i points read\n", c);
} }

View file

@ -127,14 +127,14 @@ void SV_Logfile_f (void)
if (sv_logfile) if (sv_logfile)
{ {
Con_Printf ("File logging off.\n"); Con_Printf ("File logging off.\n");
Qclose (sv_logfile); fclose (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 = Qopen (name, "w"); sv_logfile = fopen (name, "w");
if (!sv_logfile) if (!sv_logfile)
Con_Printf ("failed.\n"); Con_Printf ("failed.\n");
} }
@ -153,7 +153,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");
Qclose (sv_fraglogfile); fclose (sv_fraglogfile);
sv_fraglogfile = NULL; sv_fraglogfile = NULL;
return; return;
} }
@ -162,15 +162,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 = Qopen (name, "r"); sv_fraglogfile = fopen (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 = Qopen (name, "w"); sv_fraglogfile = fopen (name, "w");
if (!sv_fraglogfile) if (!sv_fraglogfile)
i=1000; // give error i=1000; // give error
break; break;
} }
Qclose (sv_fraglogfile); fclose (sv_fraglogfile);
} }
if (i==1000) if (i==1000)
{ {
@ -354,7 +354,7 @@ void SV_Map_f (void)
Cbuf_AddText (va("map %s", curlevel)); Cbuf_AddText (va("map %s", curlevel));
return; return;
} }
Qclose (f); fclose (f);
SV_BroadcastCommand ("changing\n"); SV_BroadcastCommand ("changing\n");
SV_SendMessagesToAll (); SV_SendMessagesToAll ();

View file

@ -188,12 +188,12 @@ void SV_Shutdown (void)
Master_Shutdown (); Master_Shutdown ();
if (sv_logfile) if (sv_logfile)
{ {
Qclose (sv_logfile); fclose (sv_logfile);
sv_logfile = NULL; sv_logfile = NULL;
} }
if (sv_fraglogfile) if (sv_fraglogfile)
{ {
Qclose (sv_fraglogfile); fclose (sv_fraglogfile);
sv_logfile = NULL; sv_logfile = NULL;
} }
NET_Shutdown (); NET_Shutdown ();
@ -298,12 +298,12 @@ void SV_DropClient (client_t *drop)
if (drop->download) if (drop->download)
{ {
Qclose (drop->download); fclose (drop->download);
drop->download = NULL; drop->download = NULL;
} }
if (drop->upload) if (drop->upload)
{ {
Qclose (drop->upload); fclose (drop->upload);
drop->upload = NULL; drop->upload = NULL;
} }
*drop->uploadfn = 0; *drop->uploadfn = 0;
@ -1119,7 +1119,7 @@ void SV_WriteIP_f (void)
Con_Printf ("Writing %s.\n", name); Con_Printf ("Writing %s.\n", name);
f = Qopen (name, "wb"); f = fopen (name, "wb");
if (!f) if (!f)
{ {
Con_Printf ("Couldn't open %s\n", name); Con_Printf ("Couldn't open %s\n", name);
@ -1129,10 +1129,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;
Qprintf (f, "addip %i.%i.%i.%i\n", b[0], b[1], b[2], b[3]); fprintf (f, "addip %i.%i.%i.%i\n", b[0], b[1], b[2], b[3]);
} }
Qclose (f); fclose (f);
} }
/* /*

View file

@ -147,7 +147,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)
Qprintf (sv_logfile, "%s", msg); fprintf (sv_logfile, "%s", msg);
} }
/* /*

View file

@ -595,7 +595,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 = Qread (host_client->download, buffer, r); r = fread (buffer, 1, r, host_client->download);
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);
@ -610,7 +610,7 @@ void SV_NextDownload_f (void)
if (host_client->downloadcount != host_client->downloadsize) if (host_client->downloadcount != host_client->downloadsize)
return; return;
Qclose (host_client->download); fclose (host_client->download);
host_client->download = NULL; host_client->download = NULL;
} }
@ -658,7 +658,7 @@ void SV_NextUpload (void)
if (!host_client->upload) if (!host_client->upload)
{ {
host_client->upload = Qopen(host_client->uploadfn, "wb"); host_client->upload = fopen(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);
@ -671,7 +671,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);
} }
Qwrite (host_client->upload, net_message.data + msg_readcount, size); fwrite (net_message.data + msg_readcount, 1, size, host_client->upload);
msg_readcount += size; msg_readcount += size;
Con_DPrintf ("UPLOAD: %d received\n", size); Con_DPrintf ("UPLOAD: %d received\n", size);
@ -680,7 +680,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 {
Qclose (host_client->upload); fclose (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);
@ -760,7 +760,7 @@ void SV_BeginDownload_f(void)
} }
if (host_client->download) { if (host_client->download) {
Qclose (host_client->download); fclose (host_client->download);
host_client->download = NULL; host_client->download = NULL;
} }
@ -772,6 +772,7 @@ void SV_BeginDownload_f(void)
*p = tolower((int)*p); *p = tolower((int)*p);
} }
host_client->downloadsize = COM_FOpenFile (name, &host_client->download); host_client->downloadsize = COM_FOpenFile (name, &host_client->download);
host_client->downloadcount = 0; host_client->downloadcount = 0;
@ -781,7 +782,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) {
Qclose(host_client->download); fclose(host_client->download);
host_client->download = NULL; host_client->download = NULL;
} }