aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2014-06-06 20:04:46 -0400
committerPaul Gilbert2014-06-06 20:04:46 -0400
commit17cc86d1721d275d56845754b9a32710b0e0d2f0 (patch)
tree7787620f8779c8ca0664df608df7111d94de0a37
parent3c1c080c3a236ca9aac40d7f04f82b57ec879cbe (diff)
downloadscummvm-rg350-17cc86d1721d275d56845754b9a32710b0e0d2f0.tar.gz
scummvm-rg350-17cc86d1721d275d56845754b9a32710b0e0d2f0.tar.bz2
scummvm-rg350-17cc86d1721d275d56845754b9a32710b0e0d2f0.zip
MADS: Refactoring and cleanup of the game startup code
-rw-r--r--engines/mads/dragonsphere/game_dragonsphere.cpp18
-rw-r--r--engines/mads/dragonsphere/game_dragonsphere.h2
-rw-r--r--engines/mads/game.cpp39
-rw-r--r--engines/mads/game.h8
-rw-r--r--engines/mads/nebular/dialogs_nebular.cpp10
-rw-r--r--engines/mads/nebular/game_nebular.cpp42
-rw-r--r--engines/mads/nebular/game_nebular.h9
-rw-r--r--engines/mads/phantom/game_phantom.cpp18
-rw-r--r--engines/mads/phantom/game_phantom.h2
9 files changed, 67 insertions, 81 deletions
diff --git a/engines/mads/dragonsphere/game_dragonsphere.cpp b/engines/mads/dragonsphere/game_dragonsphere.cpp
index c6097125b1..9d9b48dd66 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 5147f75178..7869dc87b4 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 b42408f934..fe4dae82cb 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 8b16590503..08cd7e7843 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 3fb61990e2..fdf3ee1392 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 8289437c73..d6d7a07e52 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 6620deaea6..da607d47ee 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 15ac241d8c..b0b1bf7836 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 7a84ee1c72..99cc2c1230 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();