aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWalter van Niftrik2016-03-06 13:36:35 +0100
committerWalter van Niftrik2016-03-09 10:03:13 +0100
commita73dcdf224ae88c7bcf73d754781052835af4cd0 (patch)
tree32cbc11bc95fb795c6df90eca3183cf0f464a281
parentaf42795ffa9331a16c1c6fa819f5c3960fd3cfe1 (diff)
downloadscummvm-rg350-a73dcdf224ae88c7bcf73d754781052835af4cd0.tar.gz
scummvm-rg350-a73dcdf224ae88c7bcf73d754781052835af4cd0.tar.bz2
scummvm-rg350-a73dcdf224ae88c7bcf73d754781052835af4cd0.zip
ADL: Move functionality into base class
-rw-r--r--engines/adl/adl.cpp51
-rw-r--r--engines/adl/adl.h3
-rw-r--r--engines/adl/hires1.cpp52
-rw-r--r--engines/adl/hires1.h2
4 files changed, 54 insertions, 54 deletions
diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp
index c395fbb81b..701f902ade 100644
--- a/engines/adl/adl.cpp
+++ b/engines/adl/adl.cpp
@@ -72,6 +72,8 @@ bool AdlEngine::hasFeature(EngineFeature f) const {
Common::Error AdlEngine::run() {
_display = new Display();
+ loadData();
+
int saveSlot = ConfMan.getInt("save_slot");
if (saveSlot >= 0) {
if (loadGameState(saveSlot).getCode() != Common::kNoError)
@@ -83,7 +85,54 @@ Common::Error AdlEngine::run() {
initState();
}
- runGame();
+ _display->setMode(DISPLAY_MODE_MIXED);
+ printASCIIString("\r\r\r\r\r");
+
+ while (1) {
+ uint verb = 0, noun = 0;
+
+ // When restoring from the launcher, we don't read
+ // input on the first iteration. This is needed to
+ // ensure that restoring from the launcher and
+ // restoring in-game brings us to the same game state.
+ // (Also see comment below.)
+ if (!_isRestoring) {
+ clearScreen();
+ showRoom();
+
+ _canSaveNow = _canRestoreNow = true;
+ getInput(verb, noun);
+ _canSaveNow = _canRestoreNow = false;
+
+ if (shouldQuit())
+ break;
+
+ if (!doOneCommand(_roomCommands, verb, noun))
+ printEngineMessage(IDI_MSG_DONT_UNDERSTAND);
+ }
+
+ if (_isRestoring) {
+ // We restored from the GMM or launcher. As restoring
+ // with "RESTORE GAME" does not end command processing,
+ // we don't break it off here either. This essentially
+ // means that restoring a game will always run through
+ // the global commands and increase the move counter
+ // before the first user input.
+ printASCIIString("\r");
+ _isRestoring = false;
+ verb = _restoreVerb;
+ noun = _restoreNoun;
+ }
+
+ // Restarting does end command processing
+ if (_isRestarting) {
+ _isRestarting = false;
+ continue;
+ }
+
+ doAllCommands(_globalCommands, verb, noun);
+ _state.moves++;
+ }
return Common::kNoError;
}
diff --git a/engines/adl/adl.h b/engines/adl/adl.h
index 84b9214161..66a539547b 100644
--- a/engines/adl/adl.h
+++ b/engines/adl/adl.h
@@ -180,7 +180,8 @@ protected:
typedef Common::HashMap<Common::String, uint> WordMap;
virtual void runIntro() { }
- virtual void runGame() = 0;
+ virtual void loadData() = 0;
+ void runGame();
virtual void initState() = 0;
virtual void restartGame() = 0;
virtual uint getEngineMessage(EngineMessage msg) = 0;
diff --git a/engines/adl/hires1.cpp b/engines/adl/hires1.cpp
index 91407808eb..11d576b217 100644
--- a/engines/adl/hires1.cpp
+++ b/engines/adl/hires1.cpp
@@ -312,9 +312,7 @@ void HiRes1Engine::restartGame() {
printASCIIString("\r\r\r\r\r");
}
-void HiRes1Engine::runGame() {
- _display->setMode(DISPLAY_MODE_MIXED);
-
+void HiRes1Engine::loadData() {
Common::File f;
if (!f.open(IDS_HR1_MESSAGES))
@@ -385,54 +383,6 @@ void HiRes1Engine::runGame() {
f.seek(IDI_HR1_OFS_NOUNS);
loadNouns(f);
-
- printASCIIString("\r\r\r\r\r");
-
- while (1) {
- uint verb = 0, noun = 0;
-
- // When restoring from the launcher, we don't read
- // input on the first iteration. This is needed to
- // ensure that restoring from the launcher and
- // restoring in-game brings us to the same game state.
- // (Also see comment below.)
- if (!_isRestoring) {
- clearScreen();
- showRoom();
-
- _canSaveNow = _canRestoreNow = true;
- getInput(verb, noun);
- _canSaveNow = _canRestoreNow = false;
-
- if (shouldQuit())
- return;
-
- if (!doOneCommand(_roomCommands, verb, noun))
- printMessage(IDI_HR1_MSG_DONT_UNDERSTAND);
- }
-
- if (_isRestoring) {
- // We restored from the GMM or launcher. As restoring
- // with "RESTORE GAME" does not end command processing,
- // we don't break it off here either. This essentially
- // means that restoring a game will always run through
- // the global commands and increase the move counter
- // before the first user input.
- printASCIIString("\r");
- _isRestoring = false;
- verb = _restoreVerb;
- noun = _restoreNoun;
- }
-
- // Restarting does end command processing
- if (_isRestarting) {
- _isRestarting = false;
- continue;
- }
-
- doAllCommands(_globalCommands, verb, noun);
- _state.moves++;
- }
}
void HiRes1Engine::printMessage(uint idx, bool wait) {
diff --git a/engines/adl/hires1.h b/engines/adl/hires1.h
index 64cf8f35f7..f72093a92a 100644
--- a/engines/adl/hires1.h
+++ b/engines/adl/hires1.h
@@ -43,7 +43,7 @@ private:
void initState();
void runIntro();
- void runGame();
+ void loadData();
void drawPic(Common::ReadStream &stream, const Common::Point &pos);
void drawItems();
void drawLine(const Common::Point &p1, const Common::Point &p2, byte color);