diff options
author | David Turner | 2011-12-18 18:29:05 -0800 |
---|---|---|
committer | David Turner | 2011-12-18 18:29:05 -0800 |
commit | 538d83408091e9077f451f45c1ac1127f302b47d (patch) | |
tree | a8b3ffaf9199665b41e8f990549fc267c6421b46 /engines/agi/cycle.cpp | |
parent | f0eee81d327957cddb85c5a1ffe7a308a377f636 (diff) | |
parent | f722542ceea557e906699c60b10b3ace1f41c238 (diff) | |
download | scummvm-rg350-538d83408091e9077f451f45c1ac1127f302b47d.tar.gz scummvm-rg350-538d83408091e9077f451f45c1ac1127f302b47d.tar.bz2 scummvm-rg350-538d83408091e9077f451f45c1ac1127f302b47d.zip |
Merge pull request #131 from digitall/goto_considered_harmful
Goto Considered Harmful...
The following commits should improve the ScummVM code structure by reducing the number of gotos used in various engine code.
They should implement identical functionality, but without using goto and without the result being less readable/maintainable than the version with goto.
Diffstat (limited to 'engines/agi/cycle.cpp')
-rw-r--r-- | engines/agi/cycle.cpp | 75 |
1 files changed, 39 insertions, 36 deletions
diff --git a/engines/agi/cycle.cpp b/engines/agi/cycle.cpp index 99649fb437..5daadbd1df 100644 --- a/engines/agi/cycle.cpp +++ b/engines/agi/cycle.cpp @@ -248,44 +248,47 @@ int AgiEngine::mainCycle() { if (kascii) setvar(vKey, kascii); -process_key: - - switch (_game.inputMode) { - case INPUT_NORMAL: - if (!handleController(key)) { - if (key == 0 || !_game.inputEnabled) - break; - handleKeys(key); - - // if ESC pressed, activate menu before - // accept.input from the interpreter cycle - // sets the input mode to normal again - // (closes: #540856) - if (key == KEY_ESCAPE) { - key = 0; - goto process_key; + bool restartProcessKey; + do { + restartProcessKey = false; + + switch (_game.inputMode) { + case INPUT_NORMAL: + if (!handleController(key)) { + if (key == 0 || !_game.inputEnabled) + break; + handleKeys(key); + + // if ESC pressed, activate menu before + // accept.input from the interpreter cycle + // sets the input mode to normal again + // (closes: #540856) + if (key == KEY_ESCAPE) { + key = 0; + restartProcessKey = true; + } + + // commented out to close Sarien bug #438872 + //if (key) + // _game.keypress = key; } - - // commented out to close Sarien bug #438872 - //if (key) - // _game.keypress = key; + break; + case INPUT_GETSTRING: + handleController(key); + handleGetstring(key); + setvar(vKey, 0); // clear ENTER key + break; + case INPUT_MENU: + _menu->keyhandler(key); + _gfx->doUpdate(); + return false; + case INPUT_NONE: + handleController(key); + if (key) + _game.keypress = key; + break; } - break; - case INPUT_GETSTRING: - handleController(key); - handleGetstring(key); - setvar(vKey, 0); // clear ENTER key - break; - case INPUT_MENU: - _menu->keyhandler(key); - _gfx->doUpdate(); - return false; - case INPUT_NONE: - handleController(key); - if (key) - _game.keypress = key; - break; - } + } while (restartProcessKey); _gfx->doUpdate(); if (_game.msgBoxTicks > 0) |