[Scummvm-cvs-logs] scummvm master -> cc55cb13d3a673b21691c0fab58cf1385c7998e8

m-kiewitz m_kiewitz at users.sourceforge.net
Wed Feb 3 03:08:13 CET 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
cc55cb13d3 AGI: Remove _game.state, not needed anymore


Commit: cc55cb13d3a673b21691c0fab58cf1385c7998e8
    https://github.com/scummvm/scummvm/commit/cc55cb13d3a673b21691c0fab58cf1385c7998e8
Author: Martin Kiewitz (m_kiewitz at users.sourceforge.net)
Date: 2016-02-03T03:07:50+01:00

Commit Message:
AGI: Remove _game.state, not needed anymore

Changed paths:
    engines/agi/agi.cpp
    engines/agi/agi.h
    engines/agi/cycle.cpp
    engines/agi/saveload.cpp



diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index 401c42a..79047b0 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;
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index 5d14850..ca539c9 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -394,12 +394,6 @@ enum CycleInnerLoopType {
 	CYCLE_INNERLOOP_HAVEKEY                      = 7
 };
 
-enum State {
-	STATE_INIT      = 0x00,
-	STATE_LOADED    = 0x01,
-	STATE_RUNNING   = 0x02
-};
-
 typedef Common::Array<int16> SavedGameSlotIdArray;
 
 /**
@@ -410,8 +404,6 @@ typedef Common::Array<int16> SavedGameSlotIdArray;
 struct AgiGame {
 	AgiEngine *_vm;
 
-	State state;    /**< state of the interpreter */
-
 	// TODO: Check whether adjMouseX and adjMouseY must be saved and loaded when using savegames.
 	//       If they must be then loading and saving is partially broken at the moment.
 	int adjMouseX;  /**< last given adj.ego.move.to.x.y-command's 1st parameter */
@@ -734,6 +726,8 @@ public:
 	void adjustPosToGameScreen(int16 &x, int16 &y);
 
 private:
+	bool initialized;
+
 	int _keyQueue[KEY_QUEUE_SIZE];
 	int _keyQueueStart;
 	int _keyQueueEnd;
diff --git a/engines/agi/cycle.cpp b/engines/agi/cycle.cpp
index 630a91a..2758e52 100644
--- a/engines/agi/cycle.cpp
+++ b/engines/agi/cycle.cpp
@@ -440,9 +440,7 @@ int AgiEngine::runGame() {
 		setVar(VM_VAR_MAX_INPUT_CHARACTERS, 38);
 		_text->promptDisable();
 
-		_game.state = STATE_RUNNING;
 		ec = playGame();
-		_game.state = STATE_LOADED;
 		agiDeinit();
 	} while (_restartGame);
 
diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp
index b39f1c7..c2d9de8 100644
--- a/engines/agi/saveload.cpp
+++ b/engines/agi/saveload.cpp
@@ -110,8 +110,7 @@ int AgiEngine::saveGame(const Common::String &fileName, const Common::String &de
 	out->writeUint32BE(playTime);
 	debugC(5, kDebugLevelMain | kDebugLevelSavegame, "Writing play time (%d)", playTime);
 
-	out->writeByte(_game.state);
-	debugC(5, kDebugLevelMain | kDebugLevelSavegame, "Writing game state (%d)", _game.state);
+	out->writeByte(2); // was _game.state, 2 = STATE_RUNNING
 
 	strcpy(gameIDstring, _game.id);
 	out->write(gameIDstring, 8);
@@ -387,7 +386,7 @@ int AgiEngine::loadGame(const Common::String &fileName, bool checkId) {
 		}
 	}
 
-	_game.state = (State)in->readByte();
+	in->readByte(); // was _game.state, not needed anymore
 
 	in->read(loadId, 8);
 	if (strcmp(loadId, _game.id) != 0 && checkId) {






More information about the Scummvm-git-logs mailing list