aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/mortevielle/actions.cpp20
-rw-r--r--engines/mortevielle/actions.h4
-rw-r--r--engines/mortevielle/mor2.cpp5
-rw-r--r--engines/mortevielle/mortevielle.cpp39
-rw-r--r--engines/mortevielle/mortevielle.h14
-rw-r--r--engines/mortevielle/prog.cpp18
-rw-r--r--engines/mortevielle/prog.h1
-rw-r--r--engines/mortevielle/saveload.cpp2
-rw-r--r--engines/mortevielle/var_mor.cpp2
-rw-r--r--engines/mortevielle/var_mor.h3
10 files changed, 65 insertions, 43 deletions
diff --git a/engines/mortevielle/actions.cpp b/engines/mortevielle/actions.cpp
index 7e5143328d..fe0e8f4d89 100644
--- a/engines/mortevielle/actions.cpp
+++ b/engines/mortevielle/actions.cpp
@@ -602,7 +602,8 @@ L2:
repon(2, 167);
parole(7, 9, 1);
quel = do_alert(stouinon, 1);
- if (quel == 1) solu = true;
+ if (quel == 1)
+ g_vm->_endGame = true;
else crep = 168;
}
if ((s.mlieu == 17) && (s.ivier == 143)) {
@@ -1186,9 +1187,12 @@ L2:
num = 0;
}
-/* NIVEAU 2 */
-/* overlay */ void tmaj1() { /* Le jeu est termin‚ !!! */ //Translation: The game is over!!!
- arret = true;
+/**
+ * The game is over
+ * @remarks Originally called 'tmaj1'
+ */
+void MortevielleEngine::endGame() {
+ _quitGame = true;
tlu(13, 152);
maivid();
clsf1();
@@ -1218,7 +1222,11 @@ L2:
inzon();
}
-/* overlay */ void tencore() { /* Perdu !!! */ //Translation: You lost!
+/**
+ * You lost!
+ * @remarks Originally called 'tencore'
+ */
+void MortevielleEngine::loseGame() {
int quel;
clsf2();
@@ -1235,7 +1243,7 @@ L2:
jou = 0;
repon(2, 180);
quel = do_alert(stouinon, 1);
- arret = (quel != 1);
+ _quitGame = (quel != 1);
}
} // End of namespace Mortevielle
diff --git a/engines/mortevielle/actions.h b/engines/mortevielle/actions.h
index 904a58d87c..196e5a5de6 100644
--- a/engines/mortevielle/actions.h
+++ b/engines/mortevielle/actions.h
@@ -61,8 +61,8 @@ extern void tparler();
extern void tsentir();
extern void tgratter();
/* NIVEAU 2 */
-extern void tmaj1();
-extern void tencore();
+extern void endGame();
+extern void loseGame();
} // End of namespace Mortevielle
#endif
diff --git a/engines/mortevielle/mor2.cpp b/engines/mortevielle/mor2.cpp
index 10fe6e9937..c71c850286 100644
--- a/engines/mortevielle/mor2.cpp
+++ b/engines/mortevielle/mor2.cpp
@@ -290,8 +290,9 @@ void tperd() {
iouv = 0;
mchai = 0;
mfouen();
- if (! blo) t11(21, cx);
- perdu = true;
+ if (!blo)
+ t11(21, cx);
+ g_vm->_loseGame = true;
clsf1();
boite(60, 35, 400, 50, 15);
repon(9, crep);
diff --git a/engines/mortevielle/mortevielle.cpp b/engines/mortevielle/mortevielle.cpp
index cbe2613716..eed4b5156b 100644
--- a/engines/mortevielle/mortevielle.cpp
+++ b/engines/mortevielle/mortevielle.cpp
@@ -56,6 +56,7 @@ MortevielleEngine::MortevielleEngine(OSystem *system, const ADGameDescription *g
_lastGameFrame = 0;
_mouseClick = false;
_inMainGameLoop = false;
+ _quitGame = false;
}
MortevielleEngine::~MortevielleEngine() {
@@ -150,7 +151,6 @@ Common::ErrorCode MortevielleEngine::initialise() {
init_mouse();
init_lieu();
- arret = false;
sonoff = false;
f2_all = false;
textcolor(9);
@@ -464,7 +464,8 @@ void MortevielleEngine::divers(int np, bool b) {
}
/**
- * Main game loop
+ * Main game loop. Handles potentially playing the game multiple times, such as if the player
+ * loses, and chooses to start playing the game again.
*/
void MortevielleEngine::mainGame() {
if (rech_cfiec) charge_cfiec();
@@ -478,31 +479,37 @@ void MortevielleEngine::mainGame() {
hirs();
dessine_rouleau();
show_mouse();
+
+ // Loop to play the game
do {
- tjouer();
+ playGame();
CHECK_QUIT;
- } while (!arret);
+ } while (!_quitGame);
}
/**
- * This method handles repeatedly calling a sub-method to wait for a user action and then handling it
+ * This method handles playing a loaded game
+ * @remarks Originally called tojouer
*/
-void MortevielleEngine::tjouer() {
- antegame();
+void MortevielleEngine::playGame() {
+ gameLoaded();
+
+ // Loop handling actions until the game has to be quit, or show the lose or end sequence
do {
- tecran();
+ handleAction();
CHECK_QUIT;
- } while (!((arret) || (solu) || (perdu)));
- if (solu)
- tmaj1();
- else if (perdu)
- tencore();
+ } while (!((_quitGame) || (_endGame) || (_loseGame)));
+ if (_endGame)
+ endGame();
+ else if (_loseGame)
+ loseGame();
}
/**
* Waits for the user to select an action, and then handles it
+ * @remarks Originally called tecran
*/
-void MortevielleEngine::tecran() {
+void MortevielleEngine::handleAction() {
const char idem[] = "Idem";
const int lim = 20000;
int temps = 0;
@@ -556,7 +563,7 @@ void MortevielleEngine::tecran() {
}
}
if (inkey == '\73') {
- arret = true;
+ _quitGame = true;
tmaj3();
} else {
if ((funct) && (inkey != '\77')) return;
@@ -582,7 +589,7 @@ void MortevielleEngine::tecran() {
}
do {
if (! oo) tsitu();
- if ((ctrm == 0) && (! perdu) && (! solu)) {
+ if ((ctrm == 0) && (! _loseGame) && (! _endGame)) {
taffich();
if (okdes) {
okdes = false;
diff --git a/engines/mortevielle/mortevielle.h b/engines/mortevielle/mortevielle.h
index 6dad5a0a79..9ca8258b8d 100644
--- a/engines/mortevielle/mortevielle.h
+++ b/engines/mortevielle/mortevielle.h
@@ -57,7 +57,7 @@ private:
uint32 _lastGameFrame;
bool _mouseClick;
Common::Point _mousePos;
- bool _inMainGameLoop;
+ bool _inMainGameLoop; // Flag when the main game loop is active
Common::ErrorCode initialise();
Common::ErrorCode loadMortDat();
@@ -67,8 +67,8 @@ private:
void initMouse();
void showIntroduction();
void mainGame();
- void tjouer();
- void tecran();
+ void playGame();
+ void handleAction();
void divers(int np, bool b);
public:
ScreenSurface _screenSurface;
@@ -77,6 +77,10 @@ public:
Common::RandomSource _randomSource;
SoundManager _soundManager;
SavegameManager _savegameManager;
+
+ bool _quitGame; // Quit game flag. Originally called 'arret'
+ bool _endGame; // End game flag. Originally called 'solu'
+ bool _loseGame; // Lose game flag. Originally called 'perdu'
public:
MortevielleEngine(OSystem *system, const ADGameDescription *gameDesc);
~MortevielleEngine();
@@ -95,6 +99,10 @@ public:
bool getMouseClick() const { return _mouseClick; }
void setMouseClick(bool v) { _mouseClick = v; }
void delay(int amount);
+
+ void endGame();
+ void loseGame();
+ void gameLoaded();
};
extern MortevielleEngine *g_vm;
diff --git a/engines/mortevielle/prog.cpp b/engines/mortevielle/prog.cpp
index ba2c4ded91..9d8b8f91a1 100644
--- a/engines/mortevielle/prog.cpp
+++ b/engines/mortevielle/prog.cpp
@@ -57,7 +57,11 @@ namespace Mortevielle {
menu_aff();
}
-/* overlay */ void antegame() {
+/**
+ * Called when a savegame has been loaded.
+ * @remarks Originally called 'antegame'
+ */
+void MortevielleEngine::gameLoaded() {
int k;
bool test[3];
char g[8];
@@ -66,7 +70,7 @@ namespace Mortevielle {
hide_mouse();
imen = false;
g[1] = 'M';
- perdu = true;
+ _loseGame = true;
anyone = false;
okdes = true;
test[0] = false;
@@ -112,8 +116,8 @@ namespace Mortevielle {
test[k] = true;
okdes = false;
- solu = true;
- perdu = false;
+ _endGame = true;
+ _loseGame = false;
fouil = false;
}
person();
@@ -122,7 +126,7 @@ namespace Mortevielle {
afdes(0);
repon(2, crep);
clsf3();
- solu = false;
+ _endGame = false;
tmlieu(s.mlieu);
modinv();
if (s.derobj != 0) modobj2(s.derobj + 400, test[1], test[2]);
@@ -201,7 +205,7 @@ L1:
if ((((h == 12) || (h == 13) || (h == 19)) && (s.mlieu != 10)) ||
((h > 0) && (h < 6) && (s.mlieu != 0))) s.conf = s.conf + 1;
if (((s.mlieu < 16) || (s.mlieu > 19)) && (s.mlieu != 23)
- && (s.mlieu != 0) && (s.derobj != 152) && (! perdu)) {
+ && (s.mlieu != 0) && (s.derobj != 152) && (!g_vm->_loseGame)) {
if ((s.conf > 99) && (h > 8) && (h < 16)) {
crep = 1501;
tperd();
@@ -210,7 +214,7 @@ L1:
crep = 1508;
tperd();
}
- if ((j > 1) && (h > 8) && (! perdu)) {
+ if ((j > 1) && (h > 8) && (!g_vm->_loseGame)) {
crep = 1502;
tperd();
}
diff --git a/engines/mortevielle/prog.h b/engines/mortevielle/prog.h
index f51b2214b7..e88b943307 100644
--- a/engines/mortevielle/prog.h
+++ b/engines/mortevielle/prog.h
@@ -31,7 +31,6 @@
namespace Mortevielle {
extern void change_gd(int ngd);
-extern void antegame();
/* NIVEAU 3 */
/* procedure PROGRAMME */
diff --git a/engines/mortevielle/saveload.cpp b/engines/mortevielle/saveload.cpp
index d0cd603845..4f37c2839b 100644
--- a/engines/mortevielle/saveload.cpp
+++ b/engines/mortevielle/saveload.cpp
@@ -125,7 +125,7 @@ Common::Error SavegameManager::loadGame(int n) {
/* Initialization */
theure();
dprog();
- antegame();
+ g_vm->gameLoaded();
show_mouse();
return Common::kNoError;
}
diff --git a/engines/mortevielle/var_mor.cpp b/engines/mortevielle/var_mor.cpp
index bd432124db..5ace0614bb 100644
--- a/engines/mortevielle/var_mor.cpp
+++ b/engines/mortevielle/var_mor.cpp
@@ -112,7 +112,6 @@ bool blo,
imen,
cache,
iesc,
- perdu,
col,
syn,
fouil,
@@ -120,7 +119,6 @@ bool blo,
tesok,
obpart,
okdes,
- solu,
arret,
anyone,
brt,
diff --git a/engines/mortevielle/var_mor.h b/engines/mortevielle/var_mor.h
index 5d62e77a1c..eea89947b4 100644
--- a/engines/mortevielle/var_mor.h
+++ b/engines/mortevielle/var_mor.h
@@ -281,7 +281,6 @@ extern bool blo,
imen,
cache,
iesc,
- perdu,
col,
syn,
fouil,
@@ -289,8 +288,6 @@ extern bool blo,
tesok,
obpart,
okdes,
- solu,
- arret,
anyone,
brt,
rect,