1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-21 13:39:09 +00:00

(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
This commit is contained in:
truelight
2007-06-13 16:21:11 +00:00
parent 4185c4afcd
commit b7443d800b
12 changed files with 298 additions and 8 deletions

View File

@@ -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 */