# HG changeset patch # User nenolod # Date 1165419425 28800 # Node ID d19ac60697ec05ea0a46b6e0d98409b0ad18d274 # Parent d517fc608e895f67776ba818f86e9ca610c56ce8 [svn] - implement virtual class to use VFS through binio - update the places where binio is used directly to use vfs[io]stream instead of bin[io]stream, respectively - make CFileProvider use vfsistream instead of binifstream. diff -r d517fc608e89 -r d19ac60697ec ChangeLog --- a/ChangeLog Wed Dec 06 05:09:57 2006 -0800 +++ b/ChangeLog Wed Dec 06 07:37:05 2006 -0800 @@ -1,3 +1,16 @@ +2006-12-06 13:09:57 +0000 William Pitcock + revision [740] + - some more presets + - add dynamic colourmap, a scripted colourmap basically. + + trunk/src/paranormal/builtins.c | 2 + trunk/src/paranormal/cmaps.c | 92 ++++++++++++++- + trunk/src/paranormal/presets/Makefile | 2 + trunk/src/paranormal/presets/nenolod_-_kaliedoscope.pnv | 28 ++++ + trunk/src/paranormal/presets/nenolod_-_tunnel_vision.pnv | 30 ++++ + 5 files changed, 153 insertions(+), 1 deletion(-) + + 2006-12-06 06:29:56 +0000 William Pitcock revision [738] - note that the dynamic transform is slow diff -r d517fc608e89 -r d19ac60697ec src/adplug/core/Makefile --- a/src/adplug/core/Makefile Wed Dec 06 05:09:57 2006 -0800 +++ b/src/adplug/core/Makefile Wed Dec 06 07:37:05 2006 -0800 @@ -18,8 +18,8 @@ database.h players.h xsm.h adlibemu.h kemuopl.h dro.h dmo.h s3m.h temuopl.h \ msc.h rix.h adl.h -CXXFLAGS += $(PICFLAGS) $(BINIO_CFLAGS) -I../../../../intl -I../../../.. -Dstricmp=strcasecmp -CFLAGS += $(PICFLAGS) $(BINIO_CFLAGS) -I../../../../intl -I../../../.. -Dstricmp=strcasecmp +CXXFLAGS += $(PICFLAGS) $(BINIO_CFLAGS) -I../../../../intl -I../../../.. -Dstricmp=strcasecmp $(BEEP_DEFINES) +CFLAGS += $(PICFLAGS) $(BINIO_CFLAGS) -I../../../../intl -I../../../.. -Dstricmp=strcasecmp $(BEEP_DEFINES) OBJECTS = ${SOURCES:.c=.o} ${SOURCES:.cxx=.o} diff -r d517fc608e89 -r d19ac60697ec src/adplug/core/binio_virtual.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/adplug/core/binio_virtual.h Wed Dec 06 07:37:05 2006 -0800 @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2006 William Pitcock + * This code is in the public domain. + */ + +#ifndef __BINIO_VIRTUAL__ +#define __BINIO_VIRTUAL__ + +#include +#include + +#include + +#include +#include + +class vfsistream : public binistream, virtual public binio { +private: + VFSFile *fd; + +public: + vfsistream() {}; + + vfsistream(const char *file) { + fd = vfs_fopen(file, "rb"); + }; + + vfsistream(std::string &file) { + fd = vfs_fopen(file.c_str(), "rb"); + }; + + ~vfsistream() { + if (fd != NULL) + vfs_fclose(fd); + }; + + void open(const char *file) { + fd = vfs_fopen(file, "rb"); + }; + + void open(std::string &file) { + fd = vfs_fopen(file.c_str(), "rb"); + }; + + // XXX: this sucks because binio won't let us do sanity checking + Byte getByte(void) { + return vfs_getc(fd); + }; + + void seek(long pos, Offset offs = Set) { + vfs_fseek(fd, pos, offs == Set ? SEEK_SET : SEEK_CUR); + } + + long pos(void) { + return vfs_ftell(fd); + } +}; + +// XXX: binio sucks and doesn't let us just combine the two. +class vfsostream : public binostream, virtual public binio { +private: + VFSFile *fd; + +public: + vfsostream() {}; + + vfsostream(const char *file) { + fd = vfs_fopen(file, "wb"); + }; + + vfsostream(std::string &file) { + fd = vfs_fopen(file.c_str(), "wb"); + }; + + ~vfsostream() { + if (fd != NULL) + vfs_fclose(fd); + }; + + void open(const char *file) { + fd = vfs_fopen(file, "wb"); + }; + + void open(std::string &file) { + fd = vfs_fopen(file.c_str(), "wb"); + }; + + // XXX: this sucks because binio won't let us do sanity checking + void putByte(Byte b) { + vfs_fwrite(&b, 1, 1, fd); + }; + + void seek(long pos, Offset offs = Set) { + vfs_fseek(fd, pos, offs == Set ? SEEK_SET : SEEK_CUR); + } + + long pos(void) { + return vfs_ftell(fd); + } +}; + +#endif diff -r d517fc608e89 -r d19ac60697ec src/adplug/core/database.cxx --- a/src/adplug/core/database.cxx Wed Dec 06 05:09:57 2006 -0800 +++ b/src/adplug/core/database.cxx Wed Dec 06 07:37:05 2006 -0800 @@ -21,8 +21,7 @@ * Copyright (c) 2002, 2003, 2006 Simon Peter */ -#include -#include +#include "binio_virtual.h" #include #include "database.h" @@ -55,7 +54,7 @@ bool CAdPlugDatabase::load(std::string db_name) { - binifstream f(db_name); + vfsistream f(db_name); if(f.error()) return false; return load(f); } @@ -86,7 +85,7 @@ bool CAdPlugDatabase::save(std::string db_name) { - binofstream f(db_name); + vfsostream f(db_name); if(f.error()) return false; return save(f); } diff -r d517fc608e89 -r d19ac60697ec src/adplug/core/database.h --- a/src/adplug/core/database.h Wed Dec 06 05:09:57 2006 -0800 +++ b/src/adplug/core/database.h Wed Dec 06 07:37:05 2006 -0800 @@ -26,7 +26,8 @@ #include #include -#include + +#include "binio_virtual.h" class CAdPlugDatabase { diff -r d517fc608e89 -r d19ac60697ec src/adplug/core/fprovide.cxx --- a/src/adplug/core/fprovide.cxx Wed Dec 06 05:09:57 2006 -0800 +++ b/src/adplug/core/fprovide.cxx Wed Dec 06 07:37:05 2006 -0800 @@ -52,9 +52,9 @@ /***** CProvider_Filesystem *****/ -binistream *CProvider_Filesystem::open(std::string filename) const +vfsistream *CProvider_Filesystem::open(std::string filename) const { - binifstream *f = new binifstream(filename); + vfsistream *f = new vfsistream(filename); if(!f) return 0; if(f->error()) { delete f; return 0; } @@ -67,10 +67,9 @@ void CProvider_Filesystem::close(binistream *f) const { - binifstream *ff = (binifstream *)f; + vfsistream *ff = (vfsistream *)f; if(f) { - ff->close(); delete ff; } }