From 34f570419ad49550c6a7790e2a97a7d88d02fbac Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sun, 5 Sep 2010 00:48:38 +0000 Subject: MOHAWK: Cleanup - Split the main Riven event loop into a separate function for readability and for use in the sunner external functions eventually - Some minor function signature changes (const!) - Rename matchVarToString() to getVar() (I have no idea where that original name came from, considering it takes a string and returns a variable - Use solely Common::String in getVar() svn-id: r52538 --- engines/mohawk/console.cpp | 10 +- engines/mohawk/dialogs.cpp | 8 +- engines/mohawk/graphics.cpp | 6 +- engines/mohawk/riven.cpp | 203 +++++++++++++++++++------------------- engines/mohawk/riven.h | 16 +-- engines/mohawk/riven_external.cpp | 202 ++++++++++++++++++------------------- engines/mohawk/riven_saveload.cpp | 6 +- engines/mohawk/riven_vars.cpp | 55 +++++------ 8 files changed, 254 insertions(+), 252 deletions(-) diff --git a/engines/mohawk/console.cpp b/engines/mohawk/console.cpp index 446d957109..0116167df1 100644 --- a/engines/mohawk/console.cpp +++ b/engines/mohawk/console.cpp @@ -350,7 +350,7 @@ bool RivenConsole::Cmd_Var(int argc, const char **argv) { return true; } - uint32 *globalVar = _vm->matchVarToString(argv[1]); + uint32 *globalVar = _vm->getVar(argv[1]); if (!globalVar) { DebugPrintf("Unknown variable \'%s\'\n", argv[1]); @@ -479,7 +479,7 @@ bool RivenConsole::Cmd_Hotspots(int argc, const char **argv) { } bool RivenConsole::Cmd_ZipMode(int argc, const char **argv) { - uint32 *zipModeActive = _vm->matchVarToString("azip"); + uint32 *zipModeActive = _vm->getVar("azip"); *zipModeActive = !(*zipModeActive); DebugPrintf("Zip Mode is "); @@ -622,9 +622,9 @@ bool RivenConsole::Cmd_Combos(int argc, const char **argv) { // You'll need to look up the Rebel Tunnel puzzle on your own; the // solution is constant. - uint32 teleCombo = *_vm->matchVarToString("tcorrectorder"); - uint32 prisonCombo = *_vm->matchVarToString("pcorrectorder"); - uint32 domeCombo = *_vm->matchVarToString("adomecombo"); + uint32 teleCombo = *_vm->getVar("tcorrectorder"); + uint32 prisonCombo = *_vm->getVar("pcorrectorder"); + uint32 domeCombo = *_vm->getVar("adomecombo"); DebugPrintf("Telescope Combo:\n "); for (int i = 0; i < 5; i++) diff --git a/engines/mohawk/dialogs.cpp b/engines/mohawk/dialogs.cpp index c09763cbb3..a7369b4825 100644 --- a/engines/mohawk/dialogs.cpp +++ b/engines/mohawk/dialogs.cpp @@ -125,17 +125,17 @@ RivenOptionsDialog::~RivenOptionsDialog() { void RivenOptionsDialog::open() { Dialog::open(); - _zipModeCheckbox->setState(*_vm->matchVarToString("azip") != 0); - _waterEffectCheckbox->setState(*_vm->matchVarToString("waterenabled") != 0); + _zipModeCheckbox->setState(*_vm->getVar("azip") != 0); + _waterEffectCheckbox->setState(*_vm->getVar("waterenabled") != 0); } void RivenOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) { switch (cmd) { case kZipCmd: - *_vm->matchVarToString("azip") = _zipModeCheckbox->getState() ? 1 : 0; + *_vm->getVar("azip") = _zipModeCheckbox->getState() ? 1 : 0; break; case kWaterCmd: - *_vm->matchVarToString("waterenabled") = _waterEffectCheckbox->getState() ? 1 : 0; + *_vm->getVar("waterenabled") = _waterEffectCheckbox->getState() ? 1 : 0; break; case GUI::kCloseCmd: close(); diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp index fb0bf86f42..64629f949d 100644 --- a/engines/mohawk/graphics.cpp +++ b/engines/mohawk/graphics.cpp @@ -399,7 +399,7 @@ void RivenGraphics::clearWaterEffects() { bool RivenGraphics::runScheduledWaterEffects() { // Don't run the effect if it's disabled - if (*_vm->matchVarToString("waterenabled") == 0) + if (*_vm->getVar("waterenabled") == 0) return false; Graphics::Surface *screen = NULL; @@ -613,8 +613,8 @@ void RivenGraphics::showInventory() { // you get Catherine's journal and the trap book. Near the end, // you lose the trap book and have just the two journals. - bool hasCathBook = *_vm->matchVarToString("acathbook") != 0; - bool hasTrapBook = *_vm->matchVarToString("atrapbook") != 0; + bool hasCathBook = *_vm->getVar("acathbook") != 0; + bool hasTrapBook = *_vm->getVar("atrapbook") != 0; if (!hasCathBook) { drawInventoryImage(101, g_atrusJournalRect1); diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp index d79f017c32..c7428a92fb 100644 --- a/engines/mohawk/riven.cpp +++ b/engines/mohawk/riven.cpp @@ -101,7 +101,6 @@ GUI::Debugger *MohawkEngine_Riven::getDebugger() { return _console; } - Common::Error MohawkEngine_Riven::run() { MohawkEngine::run(); @@ -142,102 +141,108 @@ Common::Error MohawkEngine_Riven::run() { changeToCard(1); } + + while (!_gameOver && !shouldQuit()) + handleEvents(); + + return Common::kNoError; +} + +void MohawkEngine_Riven::handleEvents() { Common::Event event; - while (!_gameOver && !shouldQuit()) { - bool needsUpdate = _gfx->runScheduledWaterEffects(); - needsUpdate |= _video->updateBackgroundMovies(); - while (_eventMan->pollEvent(event)) { - switch (event.type) { - case Common::EVENT_MOUSEMOVE: - checkHotspotChange(); - - if (!(getFeatures() & GF_DEMO)) { - // Check to show the inventory, but it is always "showing" in the demo - if (_eventMan->getMousePos().y >= 392) - _gfx->showInventory(); - else - _gfx->hideInventory(); - } + // Update background videos and the water effect + bool needsUpdate = _gfx->runScheduledWaterEffects(); + needsUpdate |= _video->updateBackgroundMovies(); + + while (_eventMan->pollEvent(event)) { + switch (event.type) { + case Common::EVENT_MOUSEMOVE: + checkHotspotChange(); + + if (!(getFeatures() & GF_DEMO)) { + // Check to show the inventory, but it is always "showing" in the demo + if (_eventMan->getMousePos().y >= 392) + _gfx->showInventory(); + else + _gfx->hideInventory(); + } - needsUpdate = true; - break; - case Common::EVENT_LBUTTONDOWN: + needsUpdate = true; + break; + case Common::EVENT_LBUTTONDOWN: + if (_curHotspot >= 0) + runHotspotScript(_curHotspot, kMouseDownScript); + break; + case Common::EVENT_LBUTTONUP: + // See RivenScript::switchCard() for more information on why we sometimes + // disable the next up event. + if (!_ignoreNextMouseUp) { if (_curHotspot >= 0) - runHotspotScript(_curHotspot, kMouseDownScript); + runHotspotScript(_curHotspot, kMouseUpScript); + else + checkInventoryClick(); + } + _ignoreNextMouseUp = false; + break; + case Common::EVENT_KEYDOWN: + switch (event.kbd.keycode) { + case Common::KEYCODE_d: + if (event.kbd.flags & Common::KBD_CTRL) { + _console->attach(); + _console->onFrame(); + } + break; + case Common::KEYCODE_SPACE: + pauseGame(); + break; + case Common::KEYCODE_F4: + _showHotspots = !_showHotspots; + if (_showHotspots) { + for (uint16 i = 0; i < _hotspotCount; i++) + _gfx->drawRect(_hotspots[i].rect, _hotspots[i].enabled); + needsUpdate = true; + } else + refreshCard(); + break; + case Common::KEYCODE_F5: + runDialog(*_optionsDialog); + updateZipMode(); break; - case Common::EVENT_LBUTTONUP: - // See RivenScript::switchCard() for more information on why we sometimes - // disable the next up event. - if (!_ignoreNextMouseUp) { - if (_curHotspot >= 0) - runHotspotScript(_curHotspot, kMouseUpScript); - else - checkInventoryClick(); + case Common::KEYCODE_r: + // Return to the main menu in the demo on ctrl+r + if (event.kbd.flags & Common::KBD_CTRL && getFeatures() & GF_DEMO) { + if (_curStack != aspit) + changeToStack(aspit); + changeToCard(1); } - _ignoreNextMouseUp = false; break; - case Common::EVENT_KEYDOWN: - switch (event.kbd.keycode) { - case Common::KEYCODE_d: - if (event.kbd.flags & Common::KBD_CTRL) { - _console->attach(); - _console->onFrame(); - } - break; - case Common::KEYCODE_SPACE: - pauseGame(); - break; - case Common::KEYCODE_F4: - _showHotspots = !_showHotspots; - if (_showHotspots) { - for (uint16 i = 0; i < _hotspotCount; i++) - _gfx->drawRect(_hotspots[i].rect, _hotspots[i].enabled); - needsUpdate = true; - } else - refreshCard(); - break; - case Common::KEYCODE_F5: - runDialog(*_optionsDialog); - updateZipMode(); - break; - case Common::KEYCODE_r: - // Return to the main menu in the demo on ctrl+r - if (event.kbd.flags & Common::KBD_CTRL && getFeatures() & GF_DEMO) { - if (_curStack != aspit) - changeToStack(aspit); - changeToCard(1); - } - break; - case Common::KEYCODE_p: - // Play the intro videos in the demo on ctrl+p - if (event.kbd.flags & Common::KBD_CTRL && getFeatures() & GF_DEMO) { - if (_curStack != aspit) - changeToStack(aspit); - changeToCard(6); - } - break; - default: - break; + case Common::KEYCODE_p: + // Play the intro videos in the demo on ctrl+p + if (event.kbd.flags & Common::KBD_CTRL && getFeatures() & GF_DEMO) { + if (_curStack != aspit) + changeToStack(aspit); + changeToCard(6); } break; default: break; } + break; + default: + break; } + } - if (_curHotspot >= 0) - runHotspotScript(_curHotspot, kMouseInsideScript); - - // Update the screen if we need to - if (needsUpdate) - _system->updateScreen(); + if (_curHotspot >= 0) + runHotspotScript(_curHotspot, kMouseInsideScript); - // Cut down on CPU usage - _system->delayMillis(10); - } + // Update the screen if we need to + if (needsUpdate) + _system->updateScreen(); - return Common::kNoError; + // Cut down on CPU usage + _system->delayMillis(10); } // Stack/Card-Related Functions @@ -431,7 +436,7 @@ void MohawkEngine_Riven::updateZipMode() { for (uint32 i = 0; i < _hotspotCount; i++) { if (_hotspots[i].zipModeHotspot) { - if (*matchVarToString("azip") != 0) { + if (*getVar("azip") != 0) { // Check if a zip mode hotspot is enabled by checking the name/id against the ZIPS records. Common::String hotspotName = getName(HotspotNames, _hotspots[i].name_resource); @@ -511,13 +516,13 @@ void MohawkEngine_Riven::checkInventoryClick() { return; // Set the return stack/card id's. - *matchVarToString("returnstackid") = _curStack; - *matchVarToString("returncardid") = _curCard; + *getVar("returnstackid") = _curStack; + *getVar("returncardid") = _curCard; // See RivenGraphics::showInventory() for an explanation // of the variables' meanings. - bool hasCathBook = *matchVarToString("acathbook") != 0; - bool hasTrapBook = *matchVarToString("atrapbook") != 0; + bool hasCathBook = *getVar("acathbook") != 0; + bool hasTrapBook = *getVar("atrapbook") != 0; // Go to the book if a hotspot contains the mouse if (!hasCathBook) { @@ -675,19 +680,19 @@ Common::Error MohawkEngine_Riven::saveGameState(int slot, const char *desc) { return _saveLoad->saveGame(Common::String(desc)) ? Common::kNoError : Common::kUnknownError; } -static const char *rivenStackNames[] = { - "aspit", - "bspit", - "gspit", - "jspit", - "ospit", - "pspit", - "rspit", - "tspit" -}; - -Common::String MohawkEngine_Riven::getStackName(uint16 stack) { - return Common::String(rivenStackNames[stack]); +Common::String MohawkEngine_Riven::getStackName(uint16 stack) const { + static const char *rivenStackNames[] = { + "aspit", + "bspit", + "gspit", + "jspit", + "ospit", + "pspit", + "rspit", + "tspit" + }; + + return rivenStackNames[stack]; } bool ZipMode::operator== (const ZipMode &z) const { diff --git a/engines/mohawk/riven.h b/engines/mohawk/riven.h index 98135bd861..13818810f1 100644 --- a/engines/mohawk/riven.h +++ b/engines/mohawk/riven.h @@ -136,6 +136,7 @@ private: uint16 _curCard; uint16 _curStack; void loadCard(uint16); + void handleEvents(); // Hotspot related functions and variables uint16 _hotspotCount; @@ -159,11 +160,11 @@ public: void changeToStack(uint16); void refreshCard(); Common::String getName(uint16 nameResource, uint16 nameID); - Common::String getStackName(uint16 stack); + Common::String getStackName(uint16 stack) const; void runCardScript(uint16 scriptType); void runUpdateScreenScript() { runCardScript(kCardUpdateScript); } - uint16 getCurCard() { return _curCard; } - uint16 getCurStack() { return _curStack; } + uint16 getCurCard() const { return _curCard; } + uint16 getCurStack() const { return _curStack; } uint16 matchRMAPToCard(uint32); uint32 getCurCardRMAP(); @@ -171,19 +172,18 @@ public: RivenHotspot *_hotspots; int32 _curHotspot; Common::Array _zipModeData; - uint16 getHotspotCount() { return _hotspotCount; } + uint16 getHotspotCount() const { return _hotspotCount; } void runHotspotScript(uint16 hotspot, uint16 scriptType); - int32 getCurHotspot() { return _curHotspot; } + int32 getCurHotspot() const { return _curHotspot; } Common::String getHotspotName(uint16 hotspot); // Variable functions void initVars(); - uint32 getVarCount() { return _varCount; } + uint32 getVarCount() const { return _varCount; } uint32 getGlobalVar(uint32 index); Common::String getGlobalVarName(uint32 index); uint32 *getLocalVar(uint32 index); - uint32 *matchVarToString(Common::String varName); - uint32 *matchVarToString(const char *varName); + uint32 *getVar(const Common::String &varName); // Miscellaneous void setGameOver() { _gameOver = true; } diff --git a/engines/mohawk/riven_external.cpp b/engines/mohawk/riven_external.cpp index 6d492df33a..5a2321a07a 100644 --- a/engines/mohawk/riven_external.cpp +++ b/engines/mohawk/riven_external.cpp @@ -254,7 +254,7 @@ void RivenExternal::runDomeCheck() { // frame that is the magic one is the one with the golden symbol) but we // give a 3 frame leeway in either direction. if (frameCount - curFrame < 3 || curFrame < 3) - *_vm->matchVarToString("domecheck") = 1; + *_vm->getVar("domecheck") = 1; } void RivenExternal::resetDomeSliders(uint16 bitmapId, uint16 soundId, uint16 startHotspot) { @@ -292,7 +292,7 @@ void RivenExternal::resetDomeSliders(uint16 bitmapId, uint16 soundId, uint16 sta void RivenExternal::checkDomeSliders(uint16 resetSlidersHotspot, uint16 openDomeHotspot) { // Let's see if we're all matched up... - if (*_vm->matchVarToString("adomecombo") == _sliderState) { + if (*_vm->getVar("adomecombo") == _sliderState) { // Set the button hotspot to the open dome hotspot _vm->_hotspots[resetSlidersHotspot].enabled = false; _vm->_hotspots[openDomeHotspot].enabled = true; @@ -419,7 +419,7 @@ void RivenExternal::xasetupcomplete(uint16 argc, uint16 *argv) { void RivenExternal::xaatrusopenbook(uint16 argc, uint16 *argv) { // Get the variable - uint32 page = *_vm->matchVarToString("aatruspage"); + uint32 page = *_vm->getVar("aatruspage"); // Set hotspots depending on the page if (page == 1) { @@ -438,13 +438,13 @@ void RivenExternal::xaatrusopenbook(uint16 argc, uint16 *argv) { void RivenExternal::xaatrusbookback(uint16 argc, uint16 *argv) { // Return to where we were before entering the book - _vm->changeToStack(*_vm->matchVarToString("returnstackid")); - _vm->changeToCard(*_vm->matchVarToString("returncardid")); + _vm->changeToStack(*_vm->getVar("returnstackid")); + _vm->changeToCard(*_vm->getVar("returncardid")); } void RivenExternal::xaatrusbookprevpage(uint16 argc, uint16 *argv) { // Get the page variable - uint32 *page = _vm->matchVarToString("aatruspage"); + uint32 *page = _vm->getVar("aatruspage"); // Decrement the page if it's not the first page if (*page == 1) @@ -464,7 +464,7 @@ void RivenExternal::xaatrusbookprevpage(uint16 argc, uint16 *argv) { void RivenExternal::xaatrusbooknextpage(uint16 argc, uint16 *argv) { // Get the page variable - uint32 *page = _vm->matchVarToString("aatruspage"); + uint32 *page = _vm->getVar("aatruspage"); // Increment the page if it's not the last page if (((_vm->getFeatures() & GF_DEMO) && *page == 6) || *page == 10) @@ -484,7 +484,7 @@ void RivenExternal::xaatrusbooknextpage(uint16 argc, uint16 *argv) { void RivenExternal::xacathopenbook(uint16 argc, uint16 *argv) { // Get the variable - uint32 page = *_vm->matchVarToString("acathpage"); + uint32 page = *_vm->getVar("acathpage"); // Set hotspots depending on the page if (page == 1) { @@ -510,7 +510,7 @@ void RivenExternal::xacathopenbook(uint16 argc, uint16 *argv) { // Draw the telescope combination // The images for the numbers are tBMP's 13 through 17. // The start point is at (156, 247) - uint32 teleCombo = *_vm->matchVarToString("tcorrectorder"); + uint32 teleCombo = *_vm->getVar("tcorrectorder"); static const uint16 kNumberWidth = 32; static const uint16 kNumberHeight = 25; static const uint16 kDstX = 156; @@ -527,13 +527,13 @@ void RivenExternal::xacathopenbook(uint16 argc, uint16 *argv) { void RivenExternal::xacathbookback(uint16 argc, uint16 *argv) { // Return to where we were before entering the book - _vm->changeToStack(*_vm->matchVarToString("returnstackid")); - _vm->changeToCard(*_vm->matchVarToString("returncardid")); + _vm->changeToStack(*_vm->getVar("returnstackid")); + _vm->changeToCard(*_vm->getVar("returncardid")); } void RivenExternal::xacathbookprevpage(uint16 argc, uint16 *argv) { // Get the variable - uint32 *page = _vm->matchVarToString("acathpage"); + uint32 *page = _vm->getVar("acathpage"); // Increment the page if it's not the first page if (*page == 1) @@ -550,7 +550,7 @@ void RivenExternal::xacathbookprevpage(uint16 argc, uint16 *argv) { void RivenExternal::xacathbooknextpage(uint16 argc, uint16 *argv) { // Get the variable - uint32 *page = _vm->matchVarToString("acathpage"); + uint32 *page = _vm->getVar("acathpage"); // Increment the page if it's not the last page if (*page == 49) @@ -567,14 +567,14 @@ void RivenExternal::xacathbooknextpage(uint16 argc, uint16 *argv) { void RivenExternal::xtrapbookback(uint16 argc, uint16 *argv) { // Return to where we were before entering the book - *_vm->matchVarToString("atrap") = 0; - _vm->changeToStack(*_vm->matchVarToString("returnstackid")); - _vm->changeToCard(*_vm->matchVarToString("returncardid")); + *_vm->getVar("atrap") = 0; + _vm->changeToStack(*_vm->getVar("returnstackid")); + _vm->changeToCard(*_vm->getVar("returncardid")); } void RivenExternal::xatrapbookclose(uint16 argc, uint16 *argv) { // Close the trap book - *_vm->matchVarToString("atrap") = 0; + *_vm->getVar("atrap") = 0; // Play the page turning sound _vm->_sound->playSound(8, false); @@ -584,7 +584,7 @@ void RivenExternal::xatrapbookclose(uint16 argc, uint16 *argv) { void RivenExternal::xatrapbookopen(uint16 argc, uint16 *argv) { // Open the trap book - *_vm->matchVarToString("atrap") = 1; + *_vm->getVar("atrap") = 1; // Play the page turning sound _vm->_sound->playSound(9, false); @@ -658,7 +658,7 @@ void RivenExternal::xaenablemenuintro(uint16 argc, uint16 *argv) { void RivenExternal::xblabopenbook(uint16 argc, uint16 *argv) { // Get the variable - uint32 page = *_vm->matchVarToString("blabbook"); + uint32 page = *_vm->getVar("blabbook"); // Draw the image of the page based on the blabbook variable _vm->_gfx->drawPLST(page); @@ -667,7 +667,7 @@ void RivenExternal::xblabopenbook(uint16 argc, uint16 *argv) { // Draw the dome combination // The images for the numbers are tBMP's 364 through 368 // The start point is at (240, 82) - uint32 domeCombo = *_vm->matchVarToString("adomecombo"); + uint32 domeCombo = *_vm->getVar("adomecombo"); static const uint16 kNumberWidth = 32; static const uint16 kNumberHeight = 24; static const uint16 kDstX = 240; @@ -690,7 +690,7 @@ void RivenExternal::xblabopenbook(uint16 argc, uint16 *argv) { void RivenExternal::xblabbookprevpage(uint16 argc, uint16 *argv) { // Get the page variable - uint32 *page = _vm->matchVarToString("blabbook"); + uint32 *page = _vm->getVar("blabbook"); // Decrement the page if it's not the first page if (*page == 1) @@ -707,7 +707,7 @@ void RivenExternal::xblabbookprevpage(uint16 argc, uint16 *argv) { void RivenExternal::xblabbooknextpage(uint16 argc, uint16 *argv) { // Get the page variable - uint32 *page = _vm->matchVarToString("blabbook"); + uint32 *page = _vm->getVar("blabbook"); // Increment the page if it's not the last page if (*page == 22) @@ -723,8 +723,8 @@ void RivenExternal::xblabbooknextpage(uint16 argc, uint16 *argv) { } void RivenExternal::xsoundplug(uint16 argc, uint16 *argv) { - uint32 heat = *_vm->matchVarToString("bheat"); - uint32 boilerInactive = *_vm->matchVarToString("bcratergg"); + uint32 heat = *_vm->getVar("bheat"); + uint32 boilerInactive = *_vm->getVar("bcratergg"); if (heat != 0) _vm->_sound->playSLST(1, _vm->getCurCard()); @@ -735,9 +735,9 @@ void RivenExternal::xsoundplug(uint16 argc, uint16 *argv) { } void RivenExternal::xbchangeboiler(uint16 argc, uint16 *argv) { - uint32 heat = *_vm->matchVarToString("bheat"); - uint32 water = *_vm->matchVarToString("bblrwtr"); - uint32 platform = *_vm->matchVarToString("bblrgrt"); + uint32 heat = *_vm->getVar("bheat"); + uint32 water = *_vm->getVar("bblrwtr"); + uint32 platform = *_vm->getVar("bblrgrt"); if (argv[0] == 1) { if (water == 0) { @@ -799,8 +799,8 @@ void RivenExternal::xbchangeboiler(uint16 argc, uint16 *argv) { } void RivenExternal::xbupdateboiler(uint16 argc, uint16 *argv) { - uint32 heat = *_vm->matchVarToString("bheat"); - uint32 platform = *_vm->matchVarToString("bblrgrt"); + uint32 heat = *_vm->getVar("bheat"); + uint32 platform = *_vm->getVar("bblrgrt"); if (heat) { if (platform == 0) { @@ -851,7 +851,7 @@ void RivenExternal::xbait(uint16 argc, uint16 *argv) { // Set the bait if we put it on the plate if (_vm->_hotspots[9].rect.contains(_vm->_system->getEventManager()->getMousePos())) { - *_vm->matchVarToString("bbait") = 1; + *_vm->getVar("bbait") = 1; _vm->_gfx->drawPLST(4); _vm->_gfx->updateScreen(); _vm->_hotspots[3].enabled = false; // Disable bait hotspot @@ -890,13 +890,13 @@ void RivenExternal::xbaitplate(uint16 argc, uint16 *argv) { // Set the bait if we put it on the plate, remove otherwise if (_vm->_hotspots[9].rect.contains(_vm->_system->getEventManager()->getMousePos())) { - *_vm->matchVarToString("bbait") = 1; + *_vm->getVar("bbait") = 1; _vm->_gfx->drawPLST(4); _vm->_gfx->updateScreen(); _vm->_hotspots[3].enabled = false; // Disable bait hotspot _vm->_hotspots[9].enabled = true; // Enable baitplate hotspot } else { - *_vm->matchVarToString("bbait") = 0; + *_vm->getVar("bbait") = 0; _vm->_hotspots[3].enabled = true; // Enable bait hotspot _vm->_hotspots[9].enabled = false; // Disable baitplate hotspot } @@ -930,7 +930,7 @@ void RivenExternal::xvalvecontrol(uint16 argc, uint16 *argv) { Common::Point startPos = _vm->_system->getEventManager()->getMousePos(); // Get the variable for the valve - uint32 *valve = _vm->matchVarToString("bvalve"); + uint32 *valve = _vm->getVar("bvalve"); int changeX = 0; int changeY = 0; @@ -986,26 +986,26 @@ void RivenExternal::xvalvecontrol(uint16 argc, uint16 *argv) { // If we changed state and the new state is that the valve is flowing to // the boiler, we need to update the boiler state. if (*valve == 1) { - if (*_vm->matchVarToString("bidvlv") == 1) { // Check which way the water is going at the boiler - if (*_vm->matchVarToString("bblrarm") == 1) { + if (*_vm->getVar("bidvlv") == 1) { // Check which way the water is going at the boiler + if (*_vm->getVar("bblrarm") == 1) { // If the pipe is open, make sure the water is drained out - *_vm->matchVarToString("bheat") = 0; - *_vm->matchVarToString("bblrwtr") = 0; + *_vm->getVar("bheat") = 0; + *_vm->getVar("bblrwtr") = 0; } else { // If the pipe is closed, fill the boiler again - *_vm->matchVarToString("bheat") = *_vm->matchVarToString("bblrvalve"); - *_vm->matchVarToString("bblrwtr") = 1; + *_vm->getVar("bheat") = *_vm->getVar("bblrvalve"); + *_vm->getVar("bblrwtr") = 1; } } else { // Have the grating inside the boiler match the switch outside - *_vm->matchVarToString("bblrgrt") = (*_vm->matchVarToString("bblrsw") == 1) ? 0 : 1; + *_vm->getVar("bblrgrt") = (*_vm->getVar("bblrsw") == 1) ? 0 : 1; } } } void RivenExternal::xbchipper(uint16 argc, uint16 *argv) { // Why is this an external command....? - if (*_vm->matchVarToString("bvalve") == 2) + if (*_vm->getVar("bvalve") == 2) _vm->_video->playMovieBlocking(2); } @@ -1055,13 +1055,13 @@ void RivenExternal::xgplateau3160_dopools(uint16 argc, uint16 *argv) { void RivenExternal::xgwt200_scribetime(uint16 argc, uint16 *argv) { // Get the current time - *_vm->matchVarToString("gscribetime") = _vm->_system->getMillis(); + *_vm->getVar("gscribetime") = _vm->_system->getMillis(); } void RivenExternal::xgwt900_scribe(uint16 argc, uint16 *argv) { - uint32 *scribeVar = _vm->matchVarToString("gscribe"); + uint32 *scribeVar = _vm->getVar("gscribe"); - if (*scribeVar == 1 && _vm->_system->getMillis() > *_vm->matchVarToString("gscribetime") + 40000) + if (*scribeVar == 1 && _vm->_system->getMillis() > *_vm->getVar("gscribetime") + 40000) *scribeVar = 2; } @@ -1103,9 +1103,9 @@ void RivenExternal::xglview_villageon(uint16 argc, uint16 *argv) { void RivenExternal::xreseticons(uint16 argc, uint16 *argv) { // Reset the icons when going to Tay (rspit) - *_vm->matchVarToString("jicons") = 0; - *_vm->matchVarToString("jiconorder") = 0; - *_vm->matchVarToString("jrbook") = 0; + *_vm->getVar("jicons") = 0; + *_vm->getVar("jiconorder") = 0; + *_vm->getVar("jrbook") = 0; } // Count up how many icons are pressed @@ -1126,30 +1126,30 @@ static byte countDepressedIcons(uint32 iconOrderVar) { void RivenExternal::xicon(uint16 argc, uint16 *argv) { // Set atemp as the status of whether or not the icon can be depressed. - if (*_vm->matchVarToString("jicons") & (1 << (argv[0] - 1))) { + if (*_vm->getVar("jicons") & (1 << (argv[0] - 1))) { // This icon is depressed. Allow depression only if the last depressed icon was this one. - if ((*_vm->matchVarToString("jiconorder") & 0x1f) == argv[0]) - *_vm->matchVarToString("atemp") = 1; + if ((*_vm->getVar("jiconorder") & 0x1f) == argv[0]) + *_vm->getVar("atemp") = 1; else - *_vm->matchVarToString("atemp") = 2; + *_vm->getVar("atemp") = 2; } else - *_vm->matchVarToString("atemp") = 0; + *_vm->getVar("atemp") = 0; } void RivenExternal::xcheckicons(uint16 argc, uint16 *argv) { // Reset the icons if this is the sixth icon - uint32 *iconOrderVar = _vm->matchVarToString("jiconorder"); + uint32 *iconOrderVar = _vm->getVar("jiconorder"); if (countDepressedIcons(*iconOrderVar) == 5) { *iconOrderVar = 0; - *_vm->matchVarToString("jicons") = 0; + *_vm->getVar("jicons") = 0; _vm->_sound->playSound(46, false); } } void RivenExternal::xtoggleicon(uint16 argc, uint16 *argv) { // Get the variables - uint32 *iconsDepressed = _vm->matchVarToString("jicons"); - uint32 *iconOrderVar = _vm->matchVarToString("jiconorder"); + uint32 *iconsDepressed = _vm->getVar("jicons"); + uint32 *iconOrderVar = _vm->getVar("jiconorder"); if (*iconsDepressed & (1 << (argv[0] - 1))) { // The icon is depressed, now unpress it @@ -1162,13 +1162,13 @@ void RivenExternal::xtoggleicon(uint16 argc, uint16 *argv) { } // Check if the puzzle is complete now and assign 1 to jrbook if the puzzle is complete. - if (*iconOrderVar == *_vm->matchVarToString("jiconcorrectorder")) - *_vm->matchVarToString("jrbook") = 1; + if (*iconOrderVar == *_vm->getVar("jiconcorrectorder")) + *_vm->getVar("jrbook") = 1; } void RivenExternal::xjtunnel103_pictfix(uint16 argc, uint16 *argv) { // Get the jicons variable which contains which of the stones are depressed in the rebel tunnel puzzle - uint32 iconsDepressed = *_vm->matchVarToString("jicons"); + uint32 iconsDepressed = *_vm->getVar("jicons"); // Now, draw which icons are depressed based on the bits of the variable if (iconsDepressed & (1 << 0)) @@ -1189,7 +1189,7 @@ void RivenExternal::xjtunnel103_pictfix(uint16 argc, uint16 *argv) { void RivenExternal::xjtunnel104_pictfix(uint16 argc, uint16 *argv) { // Get the jicons variable which contains which of the stones are depressed in the rebel tunnel puzzle - uint32 iconsDepressed = *_vm->matchVarToString("jicons"); + uint32 iconsDepressed = *_vm->getVar("jicons"); // Now, draw which icons are depressed based on the bits of the variable if (iconsDepressed & (1 << 9)) @@ -1212,7 +1212,7 @@ void RivenExternal::xjtunnel104_pictfix(uint16 argc, uint16 *argv) { void RivenExternal::xjtunnel105_pictfix(uint16 argc, uint16 *argv) { // Get the jicons variable which contains which of the stones are depressed in the rebel tunnel puzzle - uint32 iconsDepressed = *_vm->matchVarToString("jicons"); + uint32 iconsDepressed = *_vm->getVar("jicons"); // Now, draw which icons are depressed based on the bits of the variable if (iconsDepressed & (1 << 3)) @@ -1233,7 +1233,7 @@ void RivenExternal::xjtunnel105_pictfix(uint16 argc, uint16 *argv) { void RivenExternal::xjtunnel106_pictfix(uint16 argc, uint16 *argv) { // Get the jicons variable which contains which of the stones are depressed in the rebel tunnel puzzle - uint32 iconsDepressed = *_vm->matchVarToString("jicons"); + uint32 iconsDepressed = *_vm->getVar("jicons"); // Now, draw which icons are depressed based on the bits of the variable if (iconsDepressed & (1 << 16)) @@ -1267,7 +1267,7 @@ void RivenExternal::xvga1300_carriage(uint16 argc, uint16 *argv) { _vm->changeToCard(_vm->matchRMAPToCard(0x183a9)); // Change to card looking straight again _vm->_video->playMovieBlocking(2); - uint32 *gallows = _vm->matchVarToString("jgallows"); + uint32 *gallows = _vm->getVar("jgallows"); if (*gallows == 1) { // If the gallows is open, play the up movie and return _vm->_video->playMovieBlocking(3); @@ -1399,7 +1399,7 @@ void RivenExternal::xhandlecontrolmid(uint16 argc, uint16 *argv) { _vm->_video->playMovieBlocking(6); // If the whark's mouth is open, close it - uint32 *mouthVar = _vm->matchVarToString("jwmouth"); + uint32 *mouthVar = _vm->getVar("jwmouth"); if (*mouthVar == 1) { _vm->_video->playMovieBlocking(3); _vm->_video->playMovieBlocking(8); @@ -1418,27 +1418,27 @@ void RivenExternal::xhandlecontrolmid(uint16 argc, uint16 *argv) { void RivenExternal::xjplaybeetle_550(uint16 argc, uint16 *argv) { // Play a beetle animation 25% of the time - *_vm->matchVarToString("jplaybeetle") = (_vm->_rnd->getRandomNumberRng(0, 3) == 0) ? 1 : 0; + *_vm->getVar("jplaybeetle") = (_vm->_rnd->getRandomNumberRng(0, 3) == 0) ? 1 : 0; } void RivenExternal::xjplaybeetle_600(uint16 argc, uint16 *argv) { // Play a beetle animation 25% of the time - *_vm->matchVarToString("jplaybeetle") = (_vm->_rnd->getRandomNumberRng(0, 3) == 0) ? 1 : 0; + *_vm->getVar("jplaybeetle") = (_vm->_rnd->getRandomNumberRng(0, 3) == 0) ? 1 : 0; } void RivenExternal::xjplaybeetle_950(uint16 argc, uint16 *argv) { // Play a beetle animation 25% of the time - *_vm->matchVarToString("jplaybeetle") = (_vm->_rnd->getRandomNumberRng(0, 3) == 0) ? 1 : 0; + *_vm->getVar("jplaybeetle") = (_vm->_rnd->getRandomNumberRng(0, 3) == 0) ? 1 : 0; } void RivenExternal::xjplaybeetle_1050(uint16 argc, uint16 *argv) { // Play a beetle animation 25% of the time - *_vm->matchVarToString("jplaybeetle") = (_vm->_rnd->getRandomNumberRng(0, 3) == 0) ? 1 : 0; + *_vm->getVar("jplaybeetle") = (_vm->_rnd->getRandomNumberRng(0, 3) == 0) ? 1 : 0; } void RivenExternal::xjplaybeetle_1450(uint16 argc, uint16 *argv) { // Play a beetle animation 25% of the time as long as the girl is not present - *_vm->matchVarToString("jplaybeetle") = (_vm->_rnd->getRandomNumberRng(0, 3) == 0 && *_vm->matchVarToString("jgirl") != 1) ? 1 : 0; + *_vm->getVar("jplaybeetle") = (_vm->_rnd->getRandomNumberRng(0, 3) == 0 && *_vm->getVar("jgirl") != 1) ? 1 : 0; } void RivenExternal::xjlagoon700_alert(uint16 argc, uint16 *argv) { @@ -1451,7 +1451,7 @@ void RivenExternal::xjlagoon800_alert(uint16 argc, uint16 *argv) { void RivenExternal::xjlagoon1500_alert(uint16 argc, uint16 *argv) { // Have the sunners move a bit as you get closer ;) - uint32 *sunners = _vm->matchVarToString("jsunners"); + uint32 *sunners = _vm->getVar("jsunners"); if (*sunners == 0) { _vm->_video->playMovieBlocking(3); } else if (*sunners == 1) { @@ -1476,14 +1476,14 @@ void RivenExternal::xorollcredittime(uint16 argc, uint16 *argv) { // WORKAROUND: The special change stuff only handles one destination and it would // be messy to modify the way that currently works. If we use the trap book on Tay, // we should be using the Tay end game sequences. - if (*_vm->matchVarToString("returnstackid") == rspit) { + if (*_vm->getVar("returnstackid") == rspit) { _vm->changeToStack(rspit); _vm->changeToCard(2); return; } // You used the trap book... why? What were you thinking? - uint32 *gehnState = _vm->matchVarToString("agehn"); + uint32 *gehnState = _vm->getVar("agehn"); if (*gehnState == 0) // Gehn who? runEndGame(1); @@ -1565,8 +1565,8 @@ void RivenExternal::xbookclick(uint16 argc, uint16 *argv) { _vm->_sound->playSound(0, false); // Play the link sound _vm->_video->activateMLST(7, _vm->getCurCard()); // Activate Gehn Link Video _vm->_video->playMovieBlocking(1); // Play Gehn Link Video - *_vm->matchVarToString("agehn") = 4; // Set Gehn to the trapped state - *_vm->matchVarToString("atrapbook") = 1; // We've got the trap book again + *_vm->getVar("agehn") = 4; // Set Gehn to the trapped state + *_vm->getVar("atrapbook") = 1; // We've got the trap book again _vm->_sound->playSound(0, false); // Play the link sound again _vm->changeToCard(_vm->matchRMAPToCard(0x2885)); // Link out! (TODO: Shouldn't this card change?) return; @@ -1593,7 +1593,7 @@ void RivenExternal::xbookclick(uint16 argc, uint16 *argv) { // If there was no click and this is the third time Gehn asks us to // use the trap book, he will shoot the player. Dead on arrival. // Run the credits from here. - if (*_vm->matchVarToString("agehn") == 3) { + if (*_vm->getVar("agehn") == 3) { _vm->_scriptMan->stopAllScripts(); runCredits(argv[0]); return; @@ -1614,7 +1614,7 @@ void RivenExternal::xbookclick(uint16 argc, uint16 *argv) { void RivenExternal::xooffice30_closebook(uint16 argc, uint16 *argv) { // Close the blank linking book if it's open - uint32 *book = _vm->matchVarToString("odeskbook"); + uint32 *book = _vm->getVar("odeskbook"); if (*book != 1) return; @@ -1637,16 +1637,16 @@ void RivenExternal::xooffice30_closebook(uint16 argc, uint16 *argv) { void RivenExternal::xobedroom5_closedrawer(uint16 argc, uint16 *argv) { // Close the drawer if open when clicking on the journal. _vm->_video->playMovieBlocking(2); - *_vm->matchVarToString("ostanddrawer") = 0; + *_vm->getVar("ostanddrawer") = 0; } void RivenExternal::xogehnopenbook(uint16 argc, uint16 *argv) { - _vm->_gfx->drawPLST(*_vm->matchVarToString("ogehnpage")); + _vm->_gfx->drawPLST(*_vm->getVar("ogehnpage")); } void RivenExternal::xogehnbookprevpage(uint16 argc, uint16 *argv) { // Get the page variable - uint32 *page = _vm->matchVarToString("ogehnpage"); + uint32 *page = _vm->getVar("ogehnpage"); // Decrement the page if it's not the first page if (*page == 1) @@ -1663,7 +1663,7 @@ void RivenExternal::xogehnbookprevpage(uint16 argc, uint16 *argv) { void RivenExternal::xogehnbooknextpage(uint16 argc, uint16 *argv) { // Get the page variable - uint32 *page = _vm->matchVarToString("ogehnpage"); + uint32 *page = _vm->getVar("ogehnpage"); // Increment the page if it's not the last page if (*page == 13) @@ -1687,7 +1687,7 @@ void RivenExternal::xgwatch(uint16 argc, uint16 *argv) { // Hide the cursor _vm->_gfx->changeCursor(kRivenHideCursor); - uint32 *prisonCombo = _vm->matchVarToString("pcorrectorder"); + uint32 *prisonCombo = _vm->getVar("pcorrectorder"); uint32 soundTime = _vm->_system->getMillis() - 500; // Start the first sound instantly byte curSound = 0; @@ -1729,14 +1729,14 @@ void RivenExternal::xpisland990_elevcombo(uint16 argc, uint16 *argv) { // It is impossible to get here if Gehn is not trapped. However, // the original also disallows brute forcing the ending if you have // not yet trapped Gehn. - if (*_vm->matchVarToString("agehn") != 4) + if (*_vm->getVar("agehn") != 4) return; - uint32 *correctDigits = _vm->matchVarToString("pelevcombo"); + uint32 *correctDigits = _vm->getVar("pelevcombo"); // pelevcombo keeps count of how many buttons we have pressed in the correct order. // When pelevcombo is 5, clicking the handle will show the video freeing Catherine. - if (*correctDigits < 5 && argv[0] == getComboDigit(*_vm->matchVarToString("pcorrectorder"), *correctDigits)) + if (*correctDigits < 5 && argv[0] == getComboDigit(*_vm->getVar("pcorrectorder"), *correctDigits)) *correctDigits += 1; else *correctDigits = 0; @@ -1783,8 +1783,8 @@ void RivenExternal::xrcredittime(uint16 argc, uint16 *argv) { void RivenExternal::xrshowinventory(uint16 argc, uint16 *argv) { // Give the trap book and Catherine's journal to the player - *_vm->matchVarToString("atrapbook") = 1; - *_vm->matchVarToString("acathbook") = 1; + *_vm->getVar("atrapbook") = 1; + *_vm->getVar("acathbook") = 1; _vm->_gfx->showInventory(); } @@ -1805,29 +1805,29 @@ void RivenExternal::xtexterior300_telescopedown(uint16 argc, uint16 *argv) { _vm->_video->playMovieBlocking(3); // Don't do anything else if the telescope power is off - if (*_vm->matchVarToString("ttelevalve") == 0) + if (*_vm->getVar("ttelevalve") == 0) return; - uint32 *telescopePos = _vm->matchVarToString("ttelescope"); - uint32 *telescopeCover = _vm->matchVarToString("ttelecover"); + uint32 *telescopePos = _vm->getVar("ttelescope"); + uint32 *telescopeCover = _vm->getVar("ttelecover"); if (*telescopePos == 1) { // We're at the bottom, which means one of two things can happen... - if (*telescopeCover == 1 && *_vm->matchVarToString("ttelepin") == 1) { + if (*telescopeCover == 1 && *_vm->getVar("ttelepin") == 1) { // ...if the cover is open and the pin is up, the game is now over. - if (*_vm->matchVarToString("pcage") == 2) { + if (*_vm->getVar("pcage") == 2) { // The best ending: Catherine is free, Gehn is trapped, Atrus comes to rescue you. // And now we fall back to Earth... all the way... warning("xtexterior300_telescopedown: Good ending"); _vm->_video->activateMLST(8, _vm->getCurCard()); runEndGame(8); - } else if (*_vm->matchVarToString("agehn") == 4) { + } else if (*_vm->getVar("agehn") == 4) { // The ok ending: Catherine is still trapped, Gehn is trapped, Atrus comes to rescue you. // Nice going! Catherine and the islanders are all dead now! Just go back to your home... warning("xtexterior300_telescopedown: OK ending"); _vm->_video->activateMLST(9, _vm->getCurCard()); runEndGame(9); - } else if (*_vm->matchVarToString("atrapbook") == 1) { + } else if (*_vm->getVar("atrapbook") == 1) { // The bad ending: Catherine is trapped, Gehn is free, Atrus gets shot by Gehn, // And then you get shot by Cho. Nice going! Catherine and the islanders are dead // and you have just set Gehn free from Riven, not to mention you're dead. @@ -1863,10 +1863,10 @@ void RivenExternal::xtexterior300_telescopeup(uint16 argc, uint16 *argv) { _vm->_video->playMovieBlocking(3); // Don't do anything else if the telescope power is off - if (*_vm->matchVarToString("ttelevalve") == 0) + if (*_vm->getVar("ttelevalve") == 0) return; - uint32 *telescopePos = _vm->matchVarToString("ttelescope"); + uint32 *telescopePos = _vm->getVar("ttelescope"); // Check if we can't move up anymore if (*telescopePos == 5) { @@ -1883,9 +1883,9 @@ void RivenExternal::xtexterior300_telescopeup(uint16 argc, uint16 *argv) { void RivenExternal::xtisland390_covercombo(uint16 argc, uint16 *argv) { // Called when clicking the telescope cover buttons. argv[0] is the button number (1...5). - uint32 *correctDigits = _vm->matchVarToString("tcovercombo"); + uint32 *correctDigits = _vm->getVar("tcovercombo"); - if (*correctDigits < 5 && argv[0] == getComboDigit(*_vm->matchVarToString("tcorrectorder"), *correctDigits)) + if (*correctDigits < 5 && argv[0] == getComboDigit(*_vm->getVar("tcorrectorder"), *correctDigits)) *correctDigits += 1; else *correctDigits = 0; @@ -1901,8 +1901,8 @@ void RivenExternal::xtisland390_covercombo(uint16 argc, uint16 *argv) { // Atrus' Journal and Trap Book are added to inventory void RivenExternal::xtatrusgivesbooks(uint16 argc, uint16 *argv) { // Give the player Atrus' Journal and the Trap book - *_vm->matchVarToString("aatrusbook") = 1; - *_vm->matchVarToString("atrapbook") = 1; + *_vm->getVar("aatrusbook") = 1; + *_vm->getVar("atrapbook") = 1; } // Trap Book is removed from inventory @@ -1910,7 +1910,7 @@ void RivenExternal::xtchotakesbook(uint16 argc, uint16 *argv) { // And now Cho takes the trap book. Sure, this isn't strictly // necessary to add and them remove the trap book... but it // seems better to do this ;) - *_vm->matchVarToString("atrapbook") = 0; + *_vm->getVar("atrapbook") = 0; } void RivenExternal::xthideinventory(uint16 argc, uint16 *argv) { @@ -1922,7 +1922,7 @@ void RivenExternal::xt7500_checkmarbles(uint16 argc, uint16 *argv) { // marble position and set apower based on that. The game handles the video playing // so we don't have to. For the purposes of making the game progress further, we'll // just turn the power on for now. - *_vm->matchVarToString("apower") = 1; + *_vm->getVar("apower") = 1; } void RivenExternal::xt7600_setupmarbles(uint16 argc, uint16 *argv) { diff --git a/engines/mohawk/riven_saveload.cpp b/engines/mohawk/riven_saveload.cpp index d73b4ec0dc..c055eb51a8 100644 --- a/engines/mohawk/riven_saveload.cpp +++ b/engines/mohawk/riven_saveload.cpp @@ -161,7 +161,7 @@ bool RivenSaveLoad::loadGame(Common::String filename) { if (name == "dropLeftStart" || name == "dropRightStart") continue; - uint32 *var = _vm->matchVarToString(name); + uint32 *var = _vm->getVar(name); *var = rawVariables[i]; @@ -272,8 +272,8 @@ bool RivenSaveLoad::saveGame(Common::String filename) { filename += ".rvn"; // Convert class variables to variable numbers - *_vm->matchVarToString("currentstackid") = mapNewStackIDToOld(_vm->getCurStack()); - *_vm->matchVarToString("currentcardid") = _vm->getCurCard(); + *_vm->getVar("currentstackid") = mapNewStackIDToOld(_vm->getCurStack()); + *_vm->getVar("currentcardid") = _vm->getCurCard(); Common::OutSaveFile *saveFile = _saveFileMan->openForSaving(filename); if (!saveFile) diff --git a/engines/mohawk/riven_vars.cpp b/engines/mohawk/riven_vars.cpp index b6d2dff315..ae06afef01 100644 --- a/engines/mohawk/riven_vars.cpp +++ b/engines/mohawk/riven_vars.cpp @@ -271,7 +271,7 @@ static const char *variableNames[] = { }; uint32 *MohawkEngine_Riven::getLocalVar(uint32 index) { - return matchVarToString(getName(VariableNames, index)); + return getVar(getName(VariableNames, index)); } uint32 MohawkEngine_Riven::getGlobalVar(uint32 index) { @@ -279,18 +279,15 @@ uint32 MohawkEngine_Riven::getGlobalVar(uint32 index) { } Common::String MohawkEngine_Riven::getGlobalVarName(uint32 index) { - return Common::String(variableNames[index]); + return variableNames[index]; } -uint32 *MohawkEngine_Riven::matchVarToString(Common::String varName) { - return matchVarToString(varName.c_str()); -} - -uint32 *MohawkEngine_Riven::matchVarToString(const char *varName) { +uint32 *MohawkEngine_Riven::getVar(const Common::String &varName) { for (uint32 i = 0; i < _varCount; i++) - if (!scumm_stricmp(varName, variableNames[i])) + if (varName.equalsIgnoreCase(variableNames[i])) return &_vars[i]; - error ("Unknown variable: \'%s\'", varName); + + error ("Unknown variable: '%s'", varName.c_str()); return NULL; } @@ -304,33 +301,33 @@ void MohawkEngine_Riven::initVars() { _vars[i] = 0; // Init Variables to their correct starting state. - *matchVarToString("ttelescope") = 5; - *matchVarToString("tgatestate") = 1; - *matchVarToString("jbridge1") = 1; - *matchVarToString("jbridge4") = 1; - *matchVarToString("jgallows") = 1; - *matchVarToString("jiconcorrectorder") = 12068577; - *matchVarToString("bblrvalve") = 1; - *matchVarToString("bblrwtr") = 1; - *matchVarToString("bfans") = 1; - *matchVarToString("bytrap") = 2; - *matchVarToString("aatruspage") = 1; - *matchVarToString("acathpage") = 1; - *matchVarToString("bheat") = 1; - *matchVarToString("waterenabled") = 1; - *matchVarToString("ogehnpage") = 1; - *matchVarToString("bblrsw") = 1; - *matchVarToString("ocage") = 1; + *getVar("ttelescope") = 5; + *getVar("tgatestate") = 1; + *getVar("jbridge1") = 1; + *getVar("jbridge4") = 1; + *getVar("jgallows") = 1; + *getVar("jiconcorrectorder") = 12068577; + *getVar("bblrvalve") = 1; + *getVar("bblrwtr") = 1; + *getVar("bfans") = 1; + *getVar("bytrap") = 2; + *getVar("aatruspage") = 1; + *getVar("acathpage") = 1; + *getVar("bheat") = 1; + *getVar("waterenabled") = 1; + *getVar("ogehnpage") = 1; + *getVar("bblrsw") = 1; + *getVar("ocage") = 1; // Randomize the telescope combination - uint32 *teleCombo = matchVarToString("tcorrectorder"); + uint32 *teleCombo = getVar("tcorrectorder"); for (byte i = 0; i < 5; i++) { *teleCombo *= 10; *teleCombo += _rnd->getRandomNumberRng(1, 5); // 5 buttons } // Randomize the prison combination - uint32 *prisonCombo = matchVarToString("pcorrectorder"); + uint32 *prisonCombo = getVar("pcorrectorder"); for (byte i = 0; i < 5; i++) { *prisonCombo *= 10; *prisonCombo += _rnd->getRandomNumberRng(1, 3); // 3 buttons/sounds @@ -338,7 +335,7 @@ void MohawkEngine_Riven::initVars() { // Randomize the dome combination -- each bit represents a slider position, // the highest bit (1 << 24) represents 1, (1 << 23) represents 2, etc. - uint32 *domeCombo = matchVarToString("adomecombo"); + uint32 *domeCombo = getVar("adomecombo"); for (byte bitsSet = 0; bitsSet < 5;) { uint32 randomBit = 1 << (24 - _rnd->getRandomNumber(24)); -- cgit v1.2.3