Skip to content

Commit

Permalink
BLADERUNNER: Move shutdown() in Engine destructor
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniou79 committed Sep 10, 2019
1 parent bef3f90 commit 2003c12
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions engines/bladerunner/bladerunner.cpp
Expand Up @@ -226,6 +226,7 @@ BladeRunnerEngine::BladeRunnerEngine(OSystem *syst, const ADGameDescription *des
} }


BladeRunnerEngine::~BladeRunnerEngine() { BladeRunnerEngine::~BladeRunnerEngine() {
shutdown();
} }


bool BladeRunnerEngine::hasFeature(EngineFeature f) const { bool BladeRunnerEngine::hasFeature(EngineFeature f) const {
Expand Down Expand Up @@ -322,7 +323,7 @@ Common::Error BladeRunnerEngine::run() {
} }
missingFileStr += missingFiles[i]; missingFileStr += missingFiles[i];
} }

// shutting down
return Common::Error(Common::kNoGameDataFoundError, missingFileStr); return Common::Error(Common::kNoGameDataFoundError, missingFileStr);
} }


Expand All @@ -335,7 +336,7 @@ Common::Error BladeRunnerEngine::run() {
bool hasSavegames = !SaveFileManager::list(_targetName).empty(); bool hasSavegames = !SaveFileManager::list(_targetName).empty();


if (!startup(hasSavegames)) { if (!startup(hasSavegames)) {
shutdown(); // shutting down
return Common::Error(Common::kUnknownError, _("Failed to initialize resources")); return Common::Error(Common::kUnknownError, _("Failed to initialize resources"));
} }


Expand Down Expand Up @@ -402,8 +403,7 @@ Common::Error BladeRunnerEngine::run() {
} }
} while (_gameOver); // if main game loop ended and _gameOver == false, then shutdown } while (_gameOver); // if main game loop ended and _gameOver == false, then shutdown


shutdown(); // shutting down

return Common::kNoError; return Common::kNoError;
} }


Expand Down Expand Up @@ -798,7 +798,11 @@ void BladeRunnerEngine::shutdown() {
_playerActor = nullptr; _playerActor = nullptr;
delete _actors[kActorVoiceOver]; delete _actors[kActorVoiceOver];
_actors[kActorVoiceOver] = nullptr; _actors[kActorVoiceOver] = nullptr;
int actorCount = (int)_gameInfo->getActorCount(); int actorCount = kActorCount;
if (_gameInfo) {
actorCount = (int)_gameInfo->getActorCount();
}

for (int i = 0; i < actorCount; ++i) { for (int i = 0; i < actorCount; ++i) {
delete _actors[i]; delete _actors[i];
_actors[i] = nullptr; _actors[i] = nullptr;
Expand Down

0 comments on commit 2003c12

Please sign in to comment.