GLK: ALAN2: Set up main game loop for restarting game

This commit is contained in:
Paul Gilbert 2019-06-22 21:04:39 -07:00
parent 9aadb27267
commit 3683e74d65
3 changed files with 33 additions and 19 deletions

View file

@ -39,7 +39,7 @@ namespace Alan2 {
Alan2 *g_vm = nullptr; Alan2 *g_vm = nullptr;
Alan2::Alan2(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, gameDesc), Alan2::Alan2(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, gameDesc),
vm_exited_cleanly(false) { vm_exited_cleanly(false), _restartFlag(false) {
g_vm = this; g_vm = this;
} }

View file

@ -35,6 +35,8 @@ namespace Alan2 {
* Alan2 game interpreter * Alan2 game interpreter
*/ */
class Alan2 : public GlkAPI { class Alan2 : public GlkAPI {
private:
bool _restartFlag;
public: public:
bool vm_exited_cleanly; bool vm_exited_cleanly;
Common::String _advName; Common::String _advName;
@ -64,6 +66,16 @@ public:
*/ */
void runGame(); void runGame();
/**
* Flag for the game to restart
*/
void setRestart(bool flag) { _restartFlag = flag; }
/**
* Returns whether the game should restart
*/
bool shouldRestart() const { return _restartFlag; }
/** /**
* Returns the running interpreter type * Returns the running interpreter type
*/ */

View file

@ -1415,12 +1415,13 @@ void run() {
// Set default line and column // Set default line and column
col = lin = 1; col = lin = 1;
//setjmp(restart_label); /* Return here if he wanted to restart */ while (!g_vm->shouldQuit()) {
// Load, initialise and start the adventure
init(); /* Load, initialise and start the adventure */ g_vm->setRestart(false);
init();
Context ctx; Context ctx;
for (;;) { while (!g_vm->shouldQuit()) {
if (!ctx._break) { if (!ctx._break) {
if (dbgflg) if (dbgflg)
debug(); debug();
@ -1441,6 +1442,7 @@ void run() {
} }
} }
} }
}
} // End of namespace Alan2 } // End of namespace Alan2
} // End of namespace Glk } // End of namespace Glk