SWORD25: Fix running with non-extracted files

After loading or saving a game, the engine believed it was running
with extracted files, when then cause a crash when looking for
files in the PackageManager.

This fixes bug #12173
This commit is contained in:
Thierry Crozat 2021-02-21 21:06:57 +00:00
parent 3e814bcf09
commit e0d3b05730
3 changed files with 12 additions and 4 deletions

View File

@ -156,9 +156,6 @@ bool PackageManager::loadDirectoryAsPackage(const Common::String &directoryName,
_archiveList.push_front(new ArchiveEntry(folderArchive, mountPosition));
_extractedFiles = true;
_directoryName = directoryName;
return true;
}
}

View File

@ -104,6 +104,15 @@ public:
FT_FILE = (1 << 1)
};
/**
*
* Set the PackageManager to run on extracted game files.s
*/
void setRunWithExtractedFiles(const Common::String &directoryName) {
_extractedFiles = true;
_directoryName = directoryName;
}
/**
* Mounts the contents of a package in the directory specified in the directory tree.
* @param FileName The filename of the package to mount

View File

@ -109,7 +109,9 @@ Common::Error Sword25Engine::appStart() {
// Load packages
PackageManager *packageManagerPtr = Kernel::getInstance()->getPackage();
if (getGameFlags() & GF_EXTRACTED) {
if (!packageManagerPtr->loadDirectoryAsPackage(ConfMan.get("path"), "/"))
Common::String gameDirectory = ConfMan.get("path");
packageManagerPtr->setRunWithExtractedFiles(gameDirectory);
if (!packageManagerPtr->loadDirectoryAsPackage(gameDirectory, "/"))
return Common::kUnknownError;
} else {
if (!loadPackages())