From cf0d5b31516596bcd5690b2a3e93ba0a88d1a7d6 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 1 Apr 2012 04:08:38 +0000 Subject: [PATCH] - Fixed: FileReader's FilePos is relative to the start of the file, not relative to the start of the lump, so r3496's change to FileReader::Gets() was only valid for lumps at the start of a wad. (This function was still incorrect before that, though, since it made FilePos relative to StartPos after it had been used once.) * On that note, I'm not sure GetsFromBuffer() is correct either, since it ignores StartPos, but I don't know when this is actually used so that I could check. SVN r3504 (trunk) --- src/files.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/files.cpp b/src/files.cpp index 26313e15b..2dbe2c778 100644 --- a/src/files.cpp +++ b/src/files.cpp @@ -145,15 +145,15 @@ long FileReader::Read (void *buffer, long len) char *FileReader::Gets(char *strbuf, int len) { - if (len <= 0 || FilePos >= Length) return NULL; + if (len <= 0 || FilePos >= StartPos + Length) return NULL; char *p = fgets(strbuf, len, File); if (p != NULL) { int old = FilePos; - FilePos = ftell(File) - StartPos; - if (FilePos > Length) + FilePos = ftell(File); + if (FilePos - StartPos > Length) { - strbuf[Length-old] = 0; + strbuf[Length - old + StartPos] = 0; } } return p;