[Scummvm-cvs-logs] scummvm master -> 17cc86d1721d275d56845754b9a32710b0e0d2f0

dreammaster dreammaster at scummvm.org
Sat Jun 7 02:05:24 CEST 2014


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:
17cc86d172 MADS: Refactoring and cleanup of the game startup code


Commit: 17cc86d1721d275d56845754b9a32710b0e0d2f0
    https://github.com/scummvm/scummvm/commit/17cc86d1721d275d56845754b9a32710b0e0d2f0
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-06-06T20:04:46-04:00

Commit Message:
MADS: Refactoring and cleanup of the game startup code

Changed paths:
    engines/mads/dragonsphere/game_dragonsphere.cpp
    engines/mads/dragonsphere/game_dragonsphere.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/game_nebular.h
    engines/mads/phantom/game_phantom.cpp
    engines/mads/phantom/game_phantom.h



diff --git a/engines/mads/dragonsphere/game_dragonsphere.cpp b/engines/mads/dragonsphere/game_dragonsphere.cpp
index c609712..9d9b48d 100644
--- a/engines/mads/dragonsphere/game_dragonsphere.cpp
+++ b/engines/mads/dragonsphere/game_dragonsphere.cpp
@@ -41,22 +41,8 @@ GameDragonsphere::GameDragonsphere(MADSEngine *vm)
 	_storyMode = STORYMODE_NAUGHTY;
 }
 
-ProtectionResult GameDragonsphere::checkCopyProtection() {
-	/*
-	// DEBUG: Flag copy protection failure
-	_globals[5] = -1;
-
-	if (!ConfMan.getBool("copy_protection"))
-		return true;
-
-	* DEBUG: Disabled for now
-	CopyProtectionDialog *dlg = new CopyProtectionDialog(_vm, false);
-	dlg->show();
-	delete dlg;
-	*/
-
-	// DEBUG: Return that copy protection failed
-	return PROTECTION_SUCCEED;
+void GameDragonsphere::startGame() {
+	initializeGlobals();
 }
 
 void GameDragonsphere::initializeGlobals() {
diff --git a/engines/mads/dragonsphere/game_dragonsphere.h b/engines/mads/dragonsphere/game_dragonsphere.h
index 5147f75..7869dc8 100644
--- a/engines/mads/dragonsphere/game_dragonsphere.h
+++ b/engines/mads/dragonsphere/game_dragonsphere.h
@@ -102,7 +102,7 @@ class GameDragonsphere : public Game {
 protected:
 	GameDragonsphere(MADSEngine *vm);
 
-	virtual ProtectionResult checkCopyProtection();
+	virtual void startGame();
 
 	virtual void initializeGlobals();
 
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index b42408f..fe4dae8 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -108,49 +108,16 @@ void Game::run() {
 	}
 
 	_statusFlag = true;
-	int protectionResult = -1;
+	int startResult = -1;
 
 	if (_loadGameSlot == -1) {
-		protectionResult = checkCopyProtection();
-		switch (protectionResult) {
-		case PROTECTION_FAIL:
-			// Copy protection failed
-			_scene._nextSceneId = 804;
-			break;
-		case PROTECTION_ESCAPE:
-			// User escaped out of copy protection dialog
-			_vm->quitGame();
-			break;
-		default:
-			// Copy protection check succeeded
-			_scene._nextSceneId = 101;
-			_scene._priorSceneId = -1;
-			break;
-		}
+		startGame();
 	}
 
 	// Get the initial starting time for the first scene
 	_scene._frameStartTime = _vm->_events->getFrameCounter();
 
-	if (_saveFile == nullptr && protectionResult != -1 && protectionResult != -2) {
-		initSection(_sectionNumber);
-		_statusFlag = true;
-
-		_vm->_dialogs->_pendingDialog = DIALOG_DIFFICULTY;
-		_vm->_dialogs->showDialog();
-		_vm->_dialogs->_pendingDialog = DIALOG_NONE;
-
-		_priorSectionNumber = 0;
-		_priorSectionNumber = -1;
-		_scene._priorSceneId = 0;
-		_scene._currentSceneId = -1;
-	}
-
-	if (protectionResult != 1 && protectionResult != 2) {
-		initializeGlobals();
-	}
-
-	if (_statusFlag)
+	if (!_vm->shouldQuit())
 		gameLoop();
 }
 
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 8b16590..08cd7e7 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -44,10 +44,6 @@ enum KernelMode {
 	KERNEL_ROOM_PRELOAD = 3, KERNEL_ROOM_INIT = 4, KERNEL_ACTIVE_CODE = 5
 };
 
-enum ProtectionResult {
-	PROTECTION_SUCCEED = 0, PROTECTION_FAIL = 1, PROTECTION_ESCAPE = 2
-};
-
 #define MADS_SAVEGAME_VERSION 1
 
 struct MADSSavegameHeader {
@@ -101,9 +97,9 @@ protected:
 	/** @name Virtual Method list */
 
 	/**
-	 * Perform any copy protection check
+	 * Perform any game-specifcic startup
 	 */
-	virtual ProtectionResult checkCopyProtection() = 0;
+	virtual void startGame() = 0;
 
 	/**
 	 * Initializes global variables for a new game
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 3fb6199..fdf3ee1 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -269,6 +269,14 @@ void DialogsNebular::showDialog() {
 	case DIALOG_GAME_MENU:
 		//GameMenuDialog::show();
 		break;
+	case DIALOG_DIFFICULTY: {
+/*
+		DifficultyDialog *dlg = new DifficultyDialog(_vm);
+		dlg->show();
+		delete dlg;
+		break;
+*/
+	}
 	default:
 		break;
 	}
@@ -712,7 +720,7 @@ void ScreenDialog::setFrame(int frameNumber, int depth) {
 void ScreenDialog::show() {
 	Scene &scene = _vm->_game->_scene;
 
-	while (_selectedLine < 1) {
+	while (_selectedLine < 1 && !_vm->shouldQuit()) {
 		handleEvents();
 		if (_v3) {
 			if (!_v1)
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 8289437..d6d7a07 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -48,18 +48,54 @@ ProtectionResult GameNebular::checkCopyProtection() {
 	_globals[kCopyProtectFailed] = -1;
 
 	if (!ConfMan.getBool("copy_protection"))
-		return true;
+	return true;
 
 	* DEBUG: Disabled for now
 	CopyProtectionDialog *dlg = new CopyProtectionDialog(_vm, false);
 	dlg->show();
 	delete dlg;
 	*/
-
-	// DEBUG: Return that copy protection failed
 	return PROTECTION_SUCCEED;
 }
 
+void GameNebular::startGame() {
+	// Show the main menu
+	// TODO: Show the main menu here
+
+	// Check copy protection
+	ProtectionResult protectionResult = checkCopyProtection();
+	switch (protectionResult) {
+	case PROTECTION_FAIL:
+		// Copy protection failed
+		_scene._nextSceneId = 804;
+		initializeGlobals();
+		_globals[kCopyProtectFailed] = true;
+		return;
+	case PROTECTION_ESCAPE:
+		// User escaped out of copy protection dialog
+		_vm->quitGame();
+		return;
+	default:
+		// Copy protection check succeeded
+		break;
+	}
+
+	initSection(_sectionNumber);
+	_statusFlag = true;
+
+	_vm->_dialogs->_pendingDialog = DIALOG_DIFFICULTY;
+	_vm->_dialogs->showDialog();
+	_vm->_dialogs->_pendingDialog = DIALOG_NONE;
+
+	_priorSectionNumber = 0;
+	_priorSectionNumber = -1;
+	_scene._priorSceneId = 0;
+	_scene._currentSceneId = -1;
+	_scene._nextSceneId = 101;
+
+	initializeGlobals();
+}
+
 void GameNebular::initializeGlobals() {
 	int count, count2;
 	int bad;
diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index 6620dea..da607d4 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -38,6 +38,11 @@ enum Difficulty {
 	DIFFICULTY_HARD = 1, DIFFICULTY_MEDIUM = 2, DIFFICULTY_EASY = 3
 };
 
+
+enum ProtectionResult {
+	PROTECTION_SUCCEED = 0, PROTECTION_FAIL = 1, PROTECTION_ESCAPE = 2
+};
+
 enum InventoryObject {
 	OBJ_NONE = -1,
 	OBJ_BINOCULARS = 0,
@@ -98,10 +103,12 @@ enum InventoryObject {
 
 class GameNebular : public Game {
 	friend class Game;
+private:
+	ProtectionResult checkCopyProtection();
 protected:
 	GameNebular(MADSEngine *vm);
 
-	virtual ProtectionResult checkCopyProtection();
+	virtual void startGame();
 
 	virtual void initializeGlobals();
 
diff --git a/engines/mads/phantom/game_phantom.cpp b/engines/mads/phantom/game_phantom.cpp
index 15ac241..b0b1bf7 100644
--- a/engines/mads/phantom/game_phantom.cpp
+++ b/engines/mads/phantom/game_phantom.cpp
@@ -41,22 +41,8 @@ GamePhantom::GamePhantom(MADSEngine *vm)
 	_storyMode = STORYMODE_NAUGHTY;
 }
 
-ProtectionResult GamePhantom::checkCopyProtection() {
-	/*
-	// DEBUG: Flag copy protection failure
-	_globals[5] = -1;
-
-	if (!ConfMan.getBool("copy_protection"))
-		return true;
-
-	* DEBUG: Disabled for now
-	CopyProtectionDialog *dlg = new CopyProtectionDialog(_vm, false);
-	dlg->show();
-	delete dlg;
-	*/
-
-	// DEBUG: Return that copy protection failed
-	return PROTECTION_SUCCEED;
+void GamePhantom::startGame() {
+	initializeGlobals();
 }
 
 void GamePhantom::initializeGlobals() {
diff --git a/engines/mads/phantom/game_phantom.h b/engines/mads/phantom/game_phantom.h
index 7a84ee1..99cc2c1 100644
--- a/engines/mads/phantom/game_phantom.h
+++ b/engines/mads/phantom/game_phantom.h
@@ -78,7 +78,7 @@ class GamePhantom : public Game {
 protected:
 	GamePhantom(MADSEngine *vm);
 
-	virtual ProtectionResult checkCopyProtection();
+	virtual void startGame();
 
 	virtual void initializeGlobals();
 






More information about the Scummvm-git-logs mailing list