GLK: ALAN2: Set up main game loop for restarting game
This commit is contained in:
parent
9aadb27267
commit
3683e74d65
3 changed files with 33 additions and 19 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1415,29 +1415,31 @@ 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
|
||||||
|
g_vm->setRestart(false);
|
||||||
|
init();
|
||||||
|
|
||||||
init(); /* Load, initialise and start the adventure */
|
Context ctx;
|
||||||
|
while (!g_vm->shouldQuit()) {
|
||||||
|
if (!ctx._break) {
|
||||||
|
if (dbgflg)
|
||||||
|
debug();
|
||||||
|
|
||||||
Context ctx;
|
eventchk();
|
||||||
for (;;) {
|
cur.tick++;
|
||||||
if (!ctx._break) {
|
}
|
||||||
if (dbgflg)
|
|
||||||
debug();
|
|
||||||
|
|
||||||
eventchk();
|
// Execution ends up here after calls to the error method
|
||||||
cur.tick++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Execution ends up here after calls to the error method
|
// Move all characters
|
||||||
|
ctx._break = false;
|
||||||
|
for (cur.act = ACTMIN; cur.act <= (int)ACTMAX && !ctx._break; cur.act++) {
|
||||||
|
movactor(ctx);
|
||||||
|
|
||||||
// Move all characters
|
if (g_vm->shouldQuit())
|
||||||
ctx._break = false;
|
return;
|
||||||
for (cur.act = ACTMIN; cur.act <= (int)ACTMAX && !ctx._break; cur.act++) {
|
}
|
||||||
movactor(ctx);
|
|
||||||
|
|
||||||
if (g_vm->shouldQuit())
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue