summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarkvater <Darkvater@openttd.org>2006-07-31 22:26:11 +0000
committerDarkvater <Darkvater@openttd.org>2006-07-31 22:26:11 +0000
commit6d396f3e1754ca8e4679e860328048ceac6eb175 (patch)
treea39ade19400dca23bbdadc7e1d59c76d50625eb3
parentba77f85bed8d46c9eef9ed26322d9de5aa321372 (diff)
downloadopenttd-6d396f3e1754ca8e4679e860328048ceac6eb175.tar.xz
(svn r5687) - Cleanup: Some cleanup and commentarizing.
-rw-r--r--fileio.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/fileio.c b/fileio.c
index 3925d7566..912e72be6 100644
--- a/fileio.c
+++ b/fileio.c
@@ -15,11 +15,11 @@
#define FIO_BUFFER_SIZE 512
typedef struct {
- byte *buffer, *buffer_end;
- uint32 pos;
- FILE *cur_fh;
- FILE *handles[64];
- byte buffer_start[512];
+ 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
+ FILE *handles[64]; ///< array of file handles we can have open
+ byte buffer_start[FIO_BUFFER_SIZE]; ///< local buffer when read from file
} Fio;
static Fio _fio;
@@ -34,7 +34,8 @@ void FioSeekTo(uint32 pos, int mode)
{
if (mode == SEEK_CUR) pos += FioGetPos();
_fio.buffer = _fio.buffer_end = _fio.buffer_start + FIO_BUFFER_SIZE;
- fseek(_fio.cur_fh, (_fio.pos=pos), SEEK_SET);
+ _fio.pos = pos;
+ fseek(_fio.cur_fh, _fio.pos, SEEK_SET);
}
// Seek to a file and a position
@@ -43,7 +44,7 @@ void FioSeekToFile(uint32 pos)
FILE *f = _fio.handles[pos >> 24];
assert(f != NULL);
_fio.cur_fh = f;
- FioSeekTo(pos & 0xFFFFFF, SEEK_SET);
+ FioSeekTo(GB(pos, 0, 24), SEEK_SET);
}
byte FioReadByte(void)