aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/core/project_item.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2016-03-08 18:48:26 -0500
committerPaul Gilbert2016-03-08 18:48:26 -0500
commit0645a3dbde92fe4fbd46895cf24470535b7245aa (patch)
tree09ab6dab848c07baa28defbb2e94d3ce8f27d36d /engines/titanic/core/project_item.cpp
parent3103c9aaa9d14a5f6ad360eab2637c0be3141428 (diff)
downloadscummvm-rg350-0645a3dbde92fe4fbd46895cf24470535b7245aa.tar.gz
scummvm-rg350-0645a3dbde92fe4fbd46895cf24470535b7245aa.tar.bz2
scummvm-rg350-0645a3dbde92fe4fbd46895cf24470535b7245aa.zip
TITANIC: Fix crash when compressed newgame.st file was closed
Diffstat (limited to 'engines/titanic/core/project_item.cpp')
-rw-r--r--engines/titanic/core/project_item.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/engines/titanic/core/project_item.cpp b/engines/titanic/core/project_item.cpp
index e759b87e9f..2fa65f9e33 100644
--- a/engines/titanic/core/project_item.cpp
+++ b/engines/titanic/core/project_item.cpp
@@ -134,18 +134,20 @@ void CProjectItem::resetGameManager() {
void CProjectItem::loadGame(int slotId) {
CompressedFile file;
- Common::InSaveFile *saveFile = nullptr;
// Clear any existing project contents
clear();
// Open either an existing savegame slot or the new game template
if (slotId >= 0) {
- saveFile = g_system->getSavefileManager()->openForLoading(
+ Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(
Common::String::format("slot%d.gam", slotId));
file.open(saveFile);
} else {
- file.open("newgame.st");
+ Common::File *newFile = new Common::File();
+ if (!newFile->open("newgame.st"))
+ error("Could not open newgame.st");
+ file.open(newFile);
}
// Load the contents in
@@ -165,6 +167,7 @@ void CProjectItem::loadGame(int slotId) {
item->detach();
item->addUnder(this);
}
+
// Loaded project instance is no longer needed
newProject->destroyAll();