From b7443d800bddcdc7f3e5feaa0130df2445af4160 Mon Sep 17 00:00:00 2001 From: truelight Date: Wed, 13 Jun 2007 16:21:11 +0000 Subject: (svn r10143) -Add: store the filename of the grfs opened and allow easy access to the name -Codechange: store the SpriteID in the spritecache too -Add: add a PNG loader for graphical files -Documentation: added a document to explain the PNG format --- src/fileio.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/fileio.cpp') diff --git a/src/fileio.cpp b/src/fileio.cpp index 171f6bfcd..f8173ab86 100644 --- a/src/fileio.cpp +++ b/src/fileio.cpp @@ -28,11 +28,12 @@ struct Fio { byte *buffer, *buffer_end; ///< position pointer in local buffer and last valid byte of buffer uint32 pos; ///< current (system) position in file FILE *cur_fh; ///< current file handle + const char *filename; ///< current filename FILE *handles[MAX_HANDLES]; ///< array of file handles we can have open byte buffer_start[FIO_BUFFER_SIZE]; ///< local buffer when read from file + const char *filenames[MAX_HANDLES]; ///< array of filenames we (should) have open #if defined(LIMITED_FDS) uint open_handles; ///< current amount of open handles - const char *filename[MAX_HANDLES]; ///< array of filenames we (should) have open uint usage_count[MAX_HANDLES]; ///< count how many times this file has been opened #endif /* LIMITED_FDS */ }; @@ -45,6 +46,11 @@ uint32 FioGetPos() return _fio.pos + (_fio.buffer - _fio.buffer_start) - FIO_BUFFER_SIZE; } +const char *FioGetFilename() +{ + return _fio.filename; +} + void FioSeekTo(uint32 pos, int mode) { if (mode == SEEK_CUR) pos += FioGetPos(); @@ -76,6 +82,7 @@ void FioSeekToFile(uint32 pos) f = _fio.handles[pos >> 24]; assert(f != NULL); _fio.cur_fh = f; + _fio.filename = _fio.filenames[pos >> 24]; FioSeekTo(GB(pos, 0, 24), SEEK_SET); } @@ -174,8 +181,8 @@ void FioOpenFile(int slot, const char *filename) FioCloseFile(slot); // if file was opened before, close it _fio.handles[slot] = f; + _fio.filenames[slot] = filename; #if defined(LIMITED_FDS) - _fio.filename[slot] = filename; _fio.usage_count[slot] = 0; _fio.open_handles++; #endif /* LIMITED_FDS */ -- cgit v1.2.3-54-g00ecf