summaryrefslogtreecommitdiff
path: root/src/fileio.cpp
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-09-13 18:22:34 +0000
committertruelight <truelight@openttd.org>2007-09-13 18:22:34 +0000
commit8cd9ab9b7eb684737321cb09a875e41b1632a609 (patch)
tree0593f8ece7aec74da5da2ff346539cd1698e6ec4 /src/fileio.cpp
parent1970e657a353cb5a86a4d1f101595039eadf6f29 (diff)
downloadopenttd-8cd9ab9b7eb684737321cb09a875e41b1632a609.tar.xz
(svn r11095) -Codechange: don't abuse 'file_pos' by storing the file_slot in it too, but use a nice seperate variable for it
-Note: on a side-note, this allows files bigger than 16+ MiB, needed for tar-support
Diffstat (limited to 'src/fileio.cpp')
-rw-r--r--src/fileio.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/fileio.cpp b/src/fileio.cpp
index a8cf964a0..ad278e15f 100644
--- a/src/fileio.cpp
+++ b/src/fileio.cpp
@@ -74,18 +74,18 @@ static void FioRestoreFile(int slot)
#endif /* LIMITED_FDS */
/* Seek to a file and a position */
-void FioSeekToFile(uint32 pos)
+void FioSeekToFile(uint8 slot, uint32 pos)
{
FILE *f;
#if defined(LIMITED_FDS)
/* Make sure we have this file open */
- FioRestoreFile(pos >> 24);
+ FioRestoreFile(slot);
#endif /* LIMITED_FDS */
- f = _fio.handles[pos >> 24];
+ f = _fio.handles[slot];
assert(f != NULL);
_fio.cur_fh = f;
- _fio.filename = _fio.filenames[pos >> 24];
- FioSeekTo(GB(pos, 0, 24), SEEK_SET);
+ _fio.filename = _fio.filenames[slot];
+ FioSeekTo(pos, SEEK_SET);
}
byte FioReadByte()
@@ -180,6 +180,7 @@ void FioOpenFile(int slot, const char *filename)
#endif /* LIMITED_FDS */
f = FioFOpenFile(filename);
if (f == NULL) error("Cannot open file '%s'", filename);
+ uint32 pos = ftell(f);
FioCloseFile(slot); // if file was opened before, close it
_fio.handles[slot] = f;
@@ -188,7 +189,7 @@ void FioOpenFile(int slot, const char *filename)
_fio.usage_count[slot] = 0;
_fio.open_handles++;
#endif /* LIMITED_FDS */
- FioSeekToFile(slot << 24);
+ FioSeekToFile(slot, pos);
}
const char *_subdirs[NUM_SUBDIRS] = {