aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2009-09-24 17:07:27 +0000
committerFilippos Karapetis2009-09-24 17:07:27 +0000
commit5028d5a68bba66d3b66df6c4acef3f01356cf049 (patch)
tree6348d24fa49bd1de86fb6deac8195a0a48518fee /engines
parent1ee30563cdb7492a7b5d96e8574768f96124bdcc (diff)
downloadscummvm-rg350-5028d5a68bba66d3b66df6c4acef3f01356cf049.tar.gz
scummvm-rg350-5028d5a68bba66d3b66df6c4acef3f01356cf049.tar.bz2
scummvm-rg350-5028d5a68bba66d3b66df6c4acef3f01356cf049.zip
Reverted my commit #44290 - apparently, it was a bad idea, as g_engine is a hack
svn-id: r44311
Diffstat (limited to 'engines')
-rw-r--r--engines/lure/events.cpp8
-rw-r--r--engines/lure/fights.cpp6
-rw-r--r--engines/lure/game.cpp9
-rw-r--r--engines/lure/menu.cpp6
-rw-r--r--engines/lure/scripts.cpp5
-rw-r--r--engines/lure/surface.cpp14
6 files changed, 29 insertions, 19 deletions
diff --git a/engines/lure/events.cpp b/engines/lure/events.cpp
index 3c3a4af8fa..5ca82a9be4 100644
--- a/engines/lure/events.cpp
+++ b/engines/lure/events.cpp
@@ -138,11 +138,12 @@ void Mouse::setPosition(int newX, int newY) {
void Mouse::waitForRelease() {
Events &e = Events::getReference();
+ LureEngine &engine = LureEngine::getReference();
do {
- while (e.pollEvent() && !g_engine->shouldQuit()) ;
+ while (e.pollEvent() && !engine.shouldQuit()) ;
g_system->delayMillis(20);
- } while (!g_engine->shouldQuit() && (lButton() || rButton() || mButton()));
+ } while (!engine.shouldQuit() && (lButton() || rButton() || mButton()));
}
/*--------------------------------------------------------------------------*/
@@ -206,10 +207,11 @@ void Events::waitForPress() {
bool Events::interruptableDelay(uint32 milliseconds) {
Events &events = Events::getReference();
+ LureEngine &engine = LureEngine::getReference();
uint32 delayCtr = g_system->getMillis() + milliseconds;
while (g_system->getMillis() < delayCtr) {
- if (g_engine->shouldQuit()) return true;
+ if (engine.shouldQuit()) return true;
if (events.pollEvent()) {
if (((events.type() == Common::EVENT_KEYDOWN) && (events.event().kbd.ascii != 0)) ||
diff --git a/engines/lure/fights.cpp b/engines/lure/fights.cpp
index 9f32036e5f..4a67c3df66 100644
--- a/engines/lure/fights.cpp
+++ b/engines/lure/fights.cpp
@@ -109,6 +109,7 @@ bool FightsManager::isFighting() {
}
void FightsManager::fightLoop() {
+ LureEngine &engine = LureEngine::getReference();
Resources &res = Resources::getReference();
Game &game = Game::getReference();
Room &room = Room::getReference();
@@ -116,7 +117,7 @@ void FightsManager::fightLoop() {
uint32 timerVal = g_system->getMillis();
// Loop for the duration of the battle
- while (!g_engine->shouldQuit() && (playerFight.fwhits != GENERAL_MAGIC_ID)) {
+ while (!engine.shouldQuit() && (playerFight.fwhits != GENERAL_MAGIC_ID)) {
checkEvents();
if (g_system->getMillis() > timerVal + GAME_FRAME_DELAY) {
@@ -184,6 +185,7 @@ const KeyMapping keyList[] = {
{Common::KEYCODE_INVALID, 0}};
void FightsManager::checkEvents() {
+ LureEngine &engine = LureEngine::getReference();
Game &game = Game::getReference();
Events &events = Events::getReference();
Mouse &mouse = Mouse::getReference();
@@ -196,7 +198,7 @@ void FightsManager::checkEvents() {
if (events.type() == Common::EVENT_KEYDOWN) {
switch (events.event().kbd.keycode) {
case Common::KEYCODE_ESCAPE:
- g_engine->quitGame();
+ engine.quitGame();
return;
case Common::KEYCODE_d:
diff --git a/engines/lure/game.cpp b/engines/lure/game.cpp
index 660d41eede..3dfc6a8478 100644
--- a/engines/lure/game.cpp
+++ b/engines/lure/game.cpp
@@ -151,7 +151,7 @@ void Game::execute() {
bool initialRestart = true;
- while (!g_engine->shouldQuit()) {
+ while (!engine.shouldQuit()) {
if ((_state & GS_RESTART) != 0) {
res.reset();
@@ -171,7 +171,7 @@ void Game::execute() {
mouse.cursorOn();
// Main game loop
- while (!g_engine->shouldQuit() && ((_state & GS_RESTART) == 0)) {
+ while (!engine.shouldQuit() && ((_state & GS_RESTART) == 0)) {
// If time for next frame, allow everything to update
if (system.getMillis() > timerVal + GAME_FRAME_DELAY) {
timerVal = system.getMillis();
@@ -898,7 +898,7 @@ void Game::doShowCredits() {
void Game::doQuit() {
Sound.pause();
if (getYN())
- g_engine->quitGame();
+ LureEngine::getReference().quitGame();
Sound.resume();
}
@@ -983,6 +983,7 @@ bool Game::getYN() {
Events &events = Events::getReference();
Screen &screen = Screen::getReference();
Resources &res = Resources::getReference();
+ LureEngine &engine = LureEngine::getReference();
Common::Language l = LureEngine::getReference().getLanguage();
Common::KeyCode y = Common::KEYCODE_y;
@@ -1024,7 +1025,7 @@ bool Game::getYN() {
}
g_system->delayMillis(10);
- } while (!g_engine->shouldQuit() && !breakFlag);
+ } while (!engine.shouldQuit() && !breakFlag);
screen.update();
if (!vKbdFlag)
diff --git a/engines/lure/menu.cpp b/engines/lure/menu.cpp
index 863ca33f75..5027e6967e 100644
--- a/engines/lure/menu.cpp
+++ b/engines/lure/menu.cpp
@@ -116,6 +116,7 @@ Menu &Menu::getReference() {
uint8 Menu::execute() {
OSystem &system = *g_system;
+ LureEngine &engine = LureEngine::getReference();
Mouse &mouse = Mouse::getReference();
Events &events = Events::getReference();
Screen &screen = Screen::getReference();
@@ -130,7 +131,7 @@ uint8 Menu::execute() {
while (mouse.lButton() || mouse.rButton()) {
while (events.pollEvent()) {
- if (g_engine->shouldQuit()) return MENUITEM_NONE;
+ if (engine.shouldQuit()) return MENUITEM_NONE;
if (mouse.y() < MENUBAR_Y_SIZE) {
MenuRecord *p = getMenuAt(mouse.x());
@@ -467,6 +468,7 @@ Action PopupMenu::Show(int numEntries, Action *actions) {
uint16 PopupMenu::Show(int numEntries, const char *actions[]) {
if (numEntries == 0) return 0xffff;
+ LureEngine &engine = LureEngine::getReference();
Events &e = Events::getReference();
Mouse &mouse = Mouse::getReference();
OSystem &system = *g_system;
@@ -545,7 +547,7 @@ uint16 PopupMenu::Show(int numEntries, const char *actions[]) {
}
while (e.pollEvent()) {
- if (g_engine->shouldQuit()) {
+ if (engine.shouldQuit()) {
selectedIndex = 0xffff;
goto bail_out;
diff --git a/engines/lure/scripts.cpp b/engines/lure/scripts.cpp
index f78d9b348f..9e13a0d871 100644
--- a/engines/lure/scripts.cpp
+++ b/engines/lure/scripts.cpp
@@ -192,6 +192,7 @@ void Script::addSound(uint16 soundIndex, uint16 v2, uint16 v3) {
}
void Script::endgameSequence(uint16 v1, uint16 v2, uint16 v3) {
+ LureEngine &engine = LureEngine::getReference();
Screen &screen = Screen::getReference();
Mouse &mouse = Mouse::getReference();
Events &events = Events::getReference();
@@ -221,7 +222,7 @@ void Script::endgameSequence(uint16 v1, uint16 v2, uint16 v3) {
anim->show();
if (!events.interruptableDelay(30000)) {
// No key yet pressed, so keep waiting
- while (Sound.musicInterface_CheckPlaying(6) && !g_engine->shouldQuit()) {
+ while (Sound.musicInterface_CheckPlaying(6) && !engine.shouldQuit()) {
if (events.interruptableDelay(20))
break;
}
@@ -229,7 +230,7 @@ void Script::endgameSequence(uint16 v1, uint16 v2, uint16 v3) {
delete anim;
screen.paletteFadeOut();
- g_engine->quitGame();
+ engine.quitGame();
}
// Setup the pig fight in the cave
diff --git a/engines/lure/surface.cpp b/engines/lure/surface.cpp
index e519c76995..84930661ad 100644
--- a/engines/lure/surface.cpp
+++ b/engines/lure/surface.cpp
@@ -506,6 +506,7 @@ Surface *Surface::getScreen(uint16 resourceId) {
bool Surface::getString(Common::String &line, int maxSize, bool isNumeric, bool varLength, int16 x, int16 y) {
OSystem &system = *g_system;
+ LureEngine &engine = LureEngine::getReference();
Mouse &mouse = Mouse::getReference();
Events &events = Events::getReference();
Screen &screen = Screen::getReference();
@@ -533,7 +534,7 @@ bool Surface::getString(Common::String &line, int maxSize, bool isNumeric, bool
// Loop until the input string changes
refreshFlag = false;
while (!refreshFlag && !abortFlag) {
- abortFlag = g_engine->shouldQuit();
+ abortFlag = engine.shouldQuit();
if (abortFlag) break;
while (events.pollEvent()) {
@@ -975,7 +976,7 @@ bool SaveRestoreDialog::show(bool saveDialog) {
// Provide highlighting of lines to select a save slot
while (!abortFlag && !(mouse.lButton() && (selectedLine != -1))
&& !mouse.rButton() && !mouse.mButton()) {
- abortFlag = g_engine->shouldQuit();
+ abortFlag = engine.shouldQuit();
if (abortFlag) break;
while (events.pollEvent()) {
@@ -1178,7 +1179,7 @@ bool RestartRestoreDialog::show() {
// Event loop for making selection
bool buttonPressed = false;
- while (!g_engine->shouldQuit()) {
+ while (!engine.shouldQuit()) {
// Handle events
while (events.pollEvent()) {
if ((events.type() == Common::EVENT_LBUTTONDOWN) && (highlightedButton != -1)) {
@@ -1230,7 +1231,7 @@ bool RestartRestoreDialog::show() {
Sound.killSounds();
- if (!restartFlag && !g_engine->shouldQuit()) {
+ if (!restartFlag && !engine.shouldQuit()) {
// Need to show Restore game dialog
if (!SaveRestoreDialog::show(false))
// User cancelled, so fall back on Restart
@@ -1298,6 +1299,7 @@ CopyProtectionDialog::CopyProtectionDialog() {
bool CopyProtectionDialog::show() {
Screen &screen = Screen::getReference();
Events &events = Events::getReference();
+ LureEngine &engine = LureEngine::getReference();
screen.setPaletteEmpty();
Palette p(COPY_PROTECTION_RESOURCE_ID - 1);
@@ -1348,7 +1350,7 @@ bool CopyProtectionDialog::show() {
// Clear any prior try
_charIndex = 0;
- while (!g_engine->shouldQuit()) {
+ while (!engine.shouldQuit()) {
while (events.pollEvent() && (_charIndex < 4)) {
if (events.type() == Common::EVENT_KEYDOWN) {
if ((events.event().kbd.keycode == Common::KEYCODE_BACKSPACE) && (_charIndex > 0)) {
@@ -1382,7 +1384,7 @@ bool CopyProtectionDialog::show() {
break;
}
- if (g_engine->shouldQuit())
+ if (engine.shouldQuit())
return false;
// At this point, two page numbers have been entered - validate them