diff options
Diffstat (limited to 'engines/saga')
-rw-r--r-- | engines/saga/resource.cpp | 5 | ||||
-rw-r--r-- | engines/saga/resource.h | 1 | ||||
-rw-r--r-- | engines/saga/resource_rsc.cpp | 6 |
3 files changed, 7 insertions, 5 deletions
diff --git a/engines/saga/resource.cpp b/engines/saga/resource.cpp index 9590a99272..3bdd8e00db 100644 --- a/engines/saga/resource.cpp +++ b/engines/saga/resource.cpp @@ -95,7 +95,7 @@ bool Resource::loadResContext_v1(ResourceContext *context, uint32 contextOffset, resourceData->offset = contextOffset + readS1.readUint32(); resourceData->size = readS1.readUint32(); //sanity check - if ((resourceData->offset > (uint)context->file->size()) || (resourceData->size > contextSize)) { + if ((resourceData->offset > (uint)context->fileSize) || (resourceData->size > contextSize)) { result = false; break; } @@ -123,6 +123,7 @@ bool Resource::loadContext(ResourceContext *context) { return false; } + context->fileSize = context->file->size(); context->isBigEndian = _vm->isBigEndian(); if (context->fileType & GAME_SWAPENDIAN) @@ -132,7 +133,7 @@ bool Resource::loadContext(ResourceContext *context) { context->fileType &= ~GAME_MACBINARY; if (!isMacBinary) { - if (!loadResContext(context, 0, context->file->size())) { + if (!loadResContext(context, 0, context->fileSize)) { return false; } } else { diff --git a/engines/saga/resource.h b/engines/saga/resource.h index c3554cf7ce..c7d7eb9126 100644 --- a/engines/saga/resource.h +++ b/engines/saga/resource.h @@ -69,6 +69,7 @@ struct ResourceContext { const char *fileName; uint16 fileType; Common::File *file; + int32 fileSize; int serial; // IHNM speech files bool isCompressed; diff --git a/engines/saga/resource_rsc.cpp b/engines/saga/resource_rsc.cpp index 17b330ea5e..035db7723a 100644 --- a/engines/saga/resource_rsc.cpp +++ b/engines/saga/resource_rsc.cpp @@ -98,7 +98,7 @@ bool Resource_RSC::loadMacContext(ResourceContext *context) { byte macNameLen; bool notSagaContext = false; - if (context->file->size() < RSC_MIN_FILESIZE + MAC_BINARY_HEADER_SIZE) { + if (context->fileSize < RSC_MIN_FILESIZE + MAC_BINARY_HEADER_SIZE) { return false; } @@ -128,8 +128,8 @@ bool Resource_RSC::loadMacContext(ResourceContext *context) { macDataLength = context->file->readUint32BE(); macMapLength = context->file->readUint32BE(); - if (macDataOffset >= (uint)context->file->size() || macMapOffset >= (uint)context->file->size() || - macDataLength + macMapLength > (uint)context->file->size()) { + if (macDataOffset >= (uint)context->fileSize || macMapOffset >= (uint)context->fileSize || + macDataLength + macMapLength > (uint)context->fileSize) { return false; } |