change cfopen to use buffers (speeding it up), and use cfopen instead of PHYSFS_openRead/PHYSFS_openWrite where appropriate
This commit is contained in:
parent
b94ff52b6c
commit
4fe04c1d9d
|
@ -9,6 +9,7 @@
|
|||
only on last level of built-in mission.
|
||||
* main/gauges.c: fix bug #2110: redraw energy/afterburner gauges
|
||||
whenever necessary
|
||||
* change cfopen to use buffers (speeding it up), and use cfopen instead of PHYSFS_openRead/PHYSFS_openWrite where appropriate
|
||||
|
||||
2005-01-10 Chris Taylor <c.taylor@student.curtin.edu.au>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: gr.c,v 1.39 2005-01-23 13:48:35 schaffner Exp $ */
|
||||
/* $Id: gr.c,v 1.40 2005-01-23 14:38:04 schaffner Exp $ */
|
||||
/*
|
||||
*
|
||||
* OGL video functions. - Added 9/15/99 Matthew Mueller
|
||||
|
@ -730,7 +730,7 @@ void gr_palette_read(ubyte * pal)
|
|||
void write_bmp(char *savename,int w,int h,unsigned char *buf){
|
||||
PHYSFS_file *f;
|
||||
|
||||
f = PHYSFS_openWrite(savename);
|
||||
f = cfopen(savename, "wb");
|
||||
|
||||
if (f>=0){
|
||||
GLubyte targaMagic[12] = { 0, //no identification field
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: cfile.h,v 1.15 2004-12-04 04:07:16 btb Exp $ */
|
||||
/* $Id: cfile.h,v 1.16 2005-01-23 14:38:04 schaffner Exp $ */
|
||||
/*
|
||||
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
||||
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
||||
|
@ -29,6 +29,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|||
#include "maths.h"
|
||||
#include "vecmat.h"
|
||||
#include "physfsx.h"
|
||||
#include "strutil.h"
|
||||
|
||||
#define CFILE PHYSFS_file
|
||||
#define cfread(p,s,n,fp) PHYSFS_read(fp,p,s,n)
|
||||
|
@ -37,24 +38,32 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|||
#define cfexist PHYSFS_exists
|
||||
#define cfilelength PHYSFS_fileLength
|
||||
|
||||
//Open a file, set up a read buffer
|
||||
//Open a file, set up a buffer
|
||||
static inline PHYSFS_file *cfopen(char *filename, char *mode)
|
||||
{
|
||||
PHYSFS_file *fp;
|
||||
PHYSFS_uint64 bufSize;
|
||||
PHYSFS_uint64 bufSize = 1024*1024;
|
||||
|
||||
mode = mode; // no warning
|
||||
|
||||
if (filename[0] == '\x01')
|
||||
{
|
||||
//FIXME: don't look in dir, only in hogfile
|
||||
filename++;
|
||||
}
|
||||
fp = PHYSFS_openRead(filename);
|
||||
if (!fp)
|
||||
return NULL;
|
||||
|
||||
bufSize = PHYSFS_fileLength(fp);
|
||||
if (!stricmp(mode, "rb"))
|
||||
{
|
||||
fp = PHYSFS_openRead(filename);
|
||||
if (!fp)
|
||||
return NULL;
|
||||
bufSize = PHYSFS_fileLength(fp);
|
||||
}
|
||||
else if (!stricmp(mode, "wb"))
|
||||
{
|
||||
fp = PHYSFS_openWrite(filename);
|
||||
if (!fp)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (!PHYSFS_setBuffer(fp, bufSize) && bufSize)
|
||||
bufSize /= 2; // even if the error isn't memory full, for a 20MB file it'll only do this 8 times
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: config.c,v 1.14 2004-12-01 12:48:13 btb Exp $ */
|
||||
/* $Id: config.c,v 1.15 2005-01-23 14:38:04 schaffner Exp $ */
|
||||
/*
|
||||
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
||||
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
||||
|
@ -59,7 +59,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|||
|
||||
|
||||
#ifdef RCS
|
||||
static char rcsid[] = "$Id: config.c,v 1.14 2004-12-01 12:48:13 btb Exp $";
|
||||
static char rcsid[] = "$Id: config.c,v 1.15 2005-01-23 14:38:04 schaffner Exp $";
|
||||
#endif
|
||||
|
||||
ubyte Config_digi_volume = 8;
|
||||
|
@ -237,7 +237,7 @@ int ReadConfigFile()
|
|||
SaveMovieHires = MovieHires;
|
||||
save_redbook_enabled = Redbook_enabled;
|
||||
|
||||
infile = PHYSFS_openRead("descent.cfg");
|
||||
infile = cfopen("descent.cfg", "rb");
|
||||
if (infile == NULL) {
|
||||
WIN(CheckMovieAttributes());
|
||||
return 1;
|
||||
|
@ -413,7 +413,7 @@ int ReadConfigFile()
|
|||
} else
|
||||
digi_driver_board = digi_driver_board;
|
||||
#else
|
||||
infile = PHYSFS_openRead("descentw.cfg");
|
||||
infile = cfopen("descentw.cfg", "rb");
|
||||
if (infile) {
|
||||
while (!PHYSFS_eof(infile))
|
||||
{
|
||||
|
@ -463,7 +463,7 @@ int WriteConfigFile()
|
|||
}
|
||||
#endif
|
||||
|
||||
infile = PHYSFS_openWrite("descent.cfg");
|
||||
infile = cfopen("descent.cfg", "wb");
|
||||
if (infile == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -589,7 +589,7 @@ int WriteConfigFile()
|
|||
#endif
|
||||
|
||||
#ifdef RCS
|
||||
static char rcsid[] = "$Id: config.c,v 1.14 2004-12-01 12:48:13 btb Exp $";
|
||||
static char rcsid[] = "$Id: config.c,v 1.15 2005-01-23 14:38:04 schaffner Exp $";
|
||||
#endif
|
||||
|
||||
#define MAX_CTB_LEN 512
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: newdemo.c,v 1.18 2004-12-01 12:48:13 btb Exp $ */
|
||||
/* $Id: newdemo.c,v 1.19 2005-01-23 14:38:04 schaffner Exp $ */
|
||||
/*
|
||||
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
||||
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
||||
|
@ -2958,7 +2958,7 @@ void newdemo_start_recording()
|
|||
Newdemo_num_written = 0;
|
||||
Newdemo_no_space=0;
|
||||
Newdemo_state = ND_STATE_RECORDING;
|
||||
outfile = PHYSFS_openWrite(DEMO_FILENAME);
|
||||
outfile = cfopen(DEMO_FILENAME, "wb");
|
||||
|
||||
#if !defined(MACINTOSH) && !defined(_WIN32_WCE)
|
||||
if (outfile == NULL && errno == ENOENT) { //dir doesn't exist?
|
||||
|
@ -2966,7 +2966,7 @@ void newdemo_start_recording()
|
|||
if (outfile == NULL) { //dir doesn't exist and no errno on mac!
|
||||
#endif
|
||||
PHYSFS_mkdir(DEMO_DIR); //try making directory
|
||||
outfile = PHYSFS_openWrite(DEMO_FILENAME);
|
||||
outfile = cfopen(DEMO_FILENAME, "wb");
|
||||
}
|
||||
|
||||
if (outfile == NULL)
|
||||
|
@ -3196,7 +3196,7 @@ void newdemo_start_playback(char * filename)
|
|||
return;
|
||||
}
|
||||
|
||||
infile = PHYSFS_openRead(filename2);
|
||||
infile = cfopen(filename2, "rb");
|
||||
|
||||
if (infile==NULL) {
|
||||
mprintf( (0, "Error reading '%s'\n", filename ));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: playsave.c,v 1.21 2004-12-01 12:48:13 btb Exp $ */
|
||||
/* $Id: playsave.c,v 1.22 2005-01-23 14:38:04 schaffner Exp $ */
|
||||
/*
|
||||
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
||||
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
||||
|
@ -329,7 +329,7 @@ int read_player_file()
|
|||
if (!PHYSFS_exists(filename))
|
||||
return ENOENT;
|
||||
|
||||
file = PHYSFS_openRead(filename);
|
||||
file = cfopen(filename, "rb");
|
||||
|
||||
#if 0
|
||||
#ifndef MACINTOSH
|
||||
|
@ -654,7 +654,7 @@ int write_player_file()
|
|||
#else
|
||||
sprintf(filename, ":Players:%.8s.plr",Players[Player_num].callsign);
|
||||
#endif
|
||||
file = PHYSFS_openWrite(filename);
|
||||
file = cfopen(filename, "wb");
|
||||
|
||||
#if 0 //ndef MACINTOSH
|
||||
//check filename
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: state.c,v 1.20 2005-01-07 22:34:33 btb Exp $ */
|
||||
/* $Id: state.c,v 1.21 2005-01-23 14:38:04 schaffner Exp $ */
|
||||
/*
|
||||
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
||||
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
||||
|
@ -1083,7 +1083,7 @@ int state_restore_all_sub(char *filename, int multi, int secret_restore)
|
|||
Int3();
|
||||
#endif
|
||||
|
||||
fp = PHYSFS_openRead(filename);
|
||||
fp = cfopen(filename, "rb");
|
||||
if ( !fp ) return 0;
|
||||
|
||||
//Read id
|
||||
|
|
11
misc/args.c
11
misc/args.c
|
@ -1,4 +1,4 @@
|
|||
/* $Id: args.c,v 1.15 2004-12-01 12:48:13 btb Exp $ */
|
||||
/* $Id: args.c,v 1.16 2005-01-23 14:38:04 schaffner Exp $ */
|
||||
/*
|
||||
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
||||
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
||||
|
@ -23,14 +23,13 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|||
#endif
|
||||
|
||||
#ifdef RCS
|
||||
static char rcsid[] = "$Id: args.c,v 1.15 2004-12-01 12:48:13 btb Exp $";
|
||||
static char rcsid[] = "$Id: args.c,v 1.16 2005-01-23 14:38:04 schaffner Exp $";
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <physfs.h>
|
||||
|
||||
#include "cfile.h"
|
||||
#include "args.h"
|
||||
#include "u_mem.h"
|
||||
#include "strio.h"
|
||||
|
@ -112,9 +111,9 @@ void AppendArgs(void)
|
|||
int i;
|
||||
|
||||
if((i=FindArg("-ini")))
|
||||
f = PHYSFS_openRead(Args[i+1]);
|
||||
f = cfopen(Args[i+1], "rb");
|
||||
else
|
||||
f = PHYSFS_openRead("d2x.ini");
|
||||
f = cfopen("d2x.ini", "rb");
|
||||
|
||||
if(f) {
|
||||
while(!PHYSFS_eof(f) && Num_args < MAX_ARGS)
|
||||
|
|
Loading…
Reference in a new issue