aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2007-08-01 09:02:28 +0000
committerFilippos Karapetis2007-08-01 09:02:28 +0000
commite68624e7893f34dcf2d25df6ee536daf46d2f993 (patch)
tree8034055e3bbe53d50b120d50b39ea7a1a8dd4246
parentb58d259f7ee00f6cff86afc48f713979db8a31a0 (diff)
downloadscummvm-rg350-e68624e7893f34dcf2d25df6ee536daf46d2f993.tar.gz
scummvm-rg350-e68624e7893f34dcf2d25df6ee536daf46d2f993.tar.bz2
scummvm-rg350-e68624e7893f34dcf2d25df6ee536daf46d2f993.zip
Patch files are no longer left open the whole time, but are only opened when needed. This fixes the strange bug where BBM files didn't appear in the ITE demos that have substitute scenes when using MSVC compiled executables, as too many files were open at the same time
svn-id: r28381
-rw-r--r--engines/saga/rscfile.cpp3
-rw-r--r--engines/saga/rscfile.h2
-rw-r--r--engines/saga/saga.cpp24
3 files changed, 5 insertions, 24 deletions
diff --git a/engines/saga/rscfile.cpp b/engines/saga/rscfile.cpp
index 126cb58344..0aa7e2eafe 100644
--- a/engines/saga/rscfile.cpp
+++ b/engines/saga/rscfile.cpp
@@ -330,6 +330,7 @@ bool Resource::loadContext(ResourceContext *context) {
if (resourceData->patchData->_patchFile->open(patchDescription->fileName)) {
resourceData->offset = 0;
resourceData->size = resourceData->patchData->_patchFile->size();
+ resourceData->patchData->_patchFile->close();
} else {
delete resourceData->patchData;
resourceData->patchData = NULL;
@@ -544,6 +545,8 @@ void Resource::loadResource(ResourceContext *context, uint32 resourceId, byte*&r
if (file->read(resourceBuffer, resourceSize) != resourceSize) {
error("Resource::loadResource() failed to read");
}
+ if (resourceData->patchData != NULL)
+ file->close();
}
static int metaResourceTable[] = { 0, 326, 517, 677, 805, 968, 1165, 0, 1271 };
diff --git a/engines/saga/rscfile.h b/engines/saga/rscfile.h
index f8b6ddc3be..2df3b2eb7c 100644
--- a/engines/saga/rscfile.h
+++ b/engines/saga/rscfile.h
@@ -83,6 +83,8 @@ struct ResourceContext {
Common::File *getFile(ResourceData *resourceData) const {
if (resourceData->patchData != NULL) {
+ if (!resourceData->patchData->_patchFile->isOpen())
+ resourceData->patchData->_patchFile->open(resourceData->patchData->_patchDescription->fileName);
return resourceData->patchData->_patchFile;
} else {
return file;
diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp
index 35cb8b2647..76731c201a 100644
--- a/engines/saga/saga.cpp
+++ b/engines/saga/saga.cpp
@@ -233,30 +233,6 @@ int SagaEngine::init() {
_voicesEnabled = true;
}
- // WORKAROUND for a weird bug that I haven't been able to understand.
- // In some ITE demos, scenes are substituted with pictures, which are
- // loaded instead of the actual scene in Scene::changeScene(). The
- // weird phenomenon is that NO files can be opened or found in that
- // function. However, file existence works in other parts of the engine.
- // The strange thing is that if we add a dummy file existence check here
- // (or in any part of init() or go()) for a file that exists (it doesn't
- // work if the file doesn't exist), files are opened correctly in the
- // function. I don't know if this is a bug of the Common::File class or
- // of the SAGA engine itself (or perhaps of a clashing definition?), but
- // still, it's very strange that a file existence check fixes things. In
- // both cases (with and without this dummy check here), the Common::File
- // open function called from Scene::changeScene() finds the file through
- // the _filesMap, but without this dummy check here, the handle returned
- // is 0
- // To reproduce: run any of the ITE demos that has scene substitutes like,
- // for example, the ITE demo from Wyrmkeep's site. Enter the game, and
- // exit the faire (to speed things up, open the debug console and type
- // "scene_change 1", close the console and visit any place other than
- // the faire)
- // Since the files we need are BBM files, just check for the existence
- // of one file of them here
- if (Common::File::exists("tycho.bbm")) {}
-
// FIXME: This is the ugly way of reducing redraw overhead. It works
// well for 320x200 but it's unclear how well it will work for
// 640x480.