aboutsummaryrefslogtreecommitdiff
path: root/engines/agi/agi.cpp
diff options
context:
space:
mode:
authorMartin Kiewitz2016-02-03 03:07:50 +0100
committerMartin Kiewitz2016-02-03 03:07:50 +0100
commitcc55cb13d3a673b21691c0fab58cf1385c7998e8 (patch)
tree1f604bc78b3807a8c1038a54611c756086e58ff2 /engines/agi/agi.cpp
parent34117170f2955e854a93925a652af37575361b44 (diff)
downloadscummvm-rg350-cc55cb13d3a673b21691c0fab58cf1385c7998e8.tar.gz
scummvm-rg350-cc55cb13d3a673b21691c0fab58cf1385c7998e8.tar.bz2
scummvm-rg350-cc55cb13d3a673b21691c0fab58cf1385c7998e8.zip
AGI: Remove _game.state, not needed anymore
Diffstat (limited to 'engines/agi/agi.cpp')
-rw-r--r--engines/agi/agi.cpp45
1 files changed, 18 insertions, 27 deletions
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index 401c42a76a..79047b0b84 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -207,6 +207,9 @@ void AgiEngine::agiUnloadResources() {
int AgiEngine::agiDeinit() {
int ec;
+ if (!_loader)
+ return errOK;
+
_words->clearEgoWords(); // remove all words from memory
agiUnloadResources(); // unload resources in memory
_loader->unloadResource(RESOURCETYPE_LOGIC, 0);
@@ -332,7 +335,6 @@ const byte *AgiBase::getFontData() {
}
AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBase(syst, gameDesc) {
-
// Setup mixer
syncSoundSettings();
@@ -365,8 +367,6 @@ AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBas
_game.gfxMode = true;
- _game.state = STATE_INIT;
-
_keyQueueStart = 0;
_keyQueueEnd = 0;
@@ -391,14 +391,17 @@ AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBas
memset(_keyQueue, 0, sizeof(_keyQueue));
- _text = NULL;
- _sprites = NULL;
- _picture = NULL;
- _loader = NULL;
- _console = NULL;
- _menu = NULL;
- _gfx = NULL;
- _systemUI = NULL;
+ _console = nullptr;
+ _font = nullptr;
+ _gfx = nullptr;
+ _sound = nullptr;
+ _picture = nullptr;
+ _sprites = nullptr;
+ _text = nullptr;
+ _loader = nullptr;
+ _menu = nullptr;
+ _systemUI = nullptr;
+ _inventory = nullptr;
_egoHoldKey = false;
}
@@ -467,7 +470,6 @@ void AgiEngine::initialize() {
debugC(2, kDebugLevelMain, "Detect game");
if (agiDetectGame() == errOK) {
- _game.state = STATE_LOADED;
debugC(2, kDebugLevelMain, "game loaded");
} else {
warning("Could not open AGI game");
@@ -504,19 +506,14 @@ void AgiEngine::adjustPosToGameScreen(int16 &x, int16 &y) {
}
AgiEngine::~AgiEngine() {
- // If the engine hasn't been initialized yet via
- // AgiEngine::initialize(), don't attempt to free any resources, as
- // they haven't been allocated. Fixes bug #1742432 - AGI: Engine
- // crashes if no game is detected
- if (_game.state == STATE_INIT) {
- return;
- }
-
agiDeinit();
delete _loader;
- _gfx->deinitVideo();
+ if (_gfx) {
+ _gfx->deinitVideo();
+ }
delete _inventory;
delete _systemUI;
+ delete _menu;
delete _text;
delete _sprites;
delete _picture;
@@ -540,12 +537,6 @@ Common::Error AgiEngine::go() {
}
inGameTimerReset();
- if (_game.state < STATE_LOADED) {
- do {
- processAGIEvents();
- } while (_game.state < STATE_RUNNING);
- }
-
runGame();
return Common::kNoError;