diff options
author | Bastien Bouclet | 2016-08-05 08:07:02 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2017-07-03 08:50:10 +0200 |
commit | 23bbf05c9162e8126df21794b08eb953d65d057e (patch) | |
tree | 5283789bd4abc14029f156f474ccf33e443d5822 /engines/mohawk | |
parent | 1b062d1e39988388468bb13af97276d5674bbcbe (diff) | |
download | scummvm-rg350-23bbf05c9162e8126df21794b08eb953d65d057e.tar.gz scummvm-rg350-23bbf05c9162e8126df21794b08eb953d65d057e.tar.bz2 scummvm-rg350-23bbf05c9162e8126df21794b08eb953d65d057e.zip |
MOHAWK: Start converting RivenHotspot into a class
Diffstat (limited to 'engines/mohawk')
-rw-r--r-- | engines/mohawk/console.cpp | 10 | ||||
-rw-r--r-- | engines/mohawk/riven.cpp | 87 | ||||
-rw-r--r-- | engines/mohawk/riven.h | 19 | ||||
-rw-r--r-- | engines/mohawk/riven_card.cpp | 46 | ||||
-rw-r--r-- | engines/mohawk/riven_card.h | 32 | ||||
-rw-r--r-- | engines/mohawk/riven_external.cpp | 88 | ||||
-rw-r--r-- | engines/mohawk/riven_scripts.cpp | 18 |
7 files changed, 164 insertions, 136 deletions
diff --git a/engines/mohawk/console.cpp b/engines/mohawk/console.cpp index 9b4d0564e2..966929b4ef 100644 --- a/engines/mohawk/console.cpp +++ b/engines/mohawk/console.cpp @@ -510,17 +510,17 @@ bool RivenConsole::Cmd_ChangeStack(int argc, const char **argv) { } bool RivenConsole::Cmd_Hotspots(int argc, const char **argv) { - debugPrintf("Current card (%d) has %d hotspots:\n", _vm->getCurCard()->getId(), _vm->getHotspotCount()); + debugPrintf("Current card (%d) has %d hotspots:\n", _vm->getCurCard()->getId(), _vm->_hotspots.size()); - for (uint16 i = 0; i < _vm->getHotspotCount(); i++) { - debugPrintf("Hotspot %d, index %d, BLST ID %d (", i, _vm->_hotspots[i].index, _vm->_hotspots[i].blstID); + for (uint16 i = 0; i < _vm->_hotspots.size(); i++) { + debugPrintf("Hotspot %d, index %d, BLST ID %d (", i, _vm->_hotspots[i]->index, _vm->_hotspots[i]->blstID); - if (_vm->_hotspots[i].enabled) + if (_vm->_hotspots[i]->enabled) debugPrintf("enabled"); else debugPrintf("disabled"); - debugPrintf(") - (%d, %d, %d, %d)\n", _vm->_hotspots[i].rect.left, _vm->_hotspots[i].rect.top, _vm->_hotspots[i].rect.right, _vm->_hotspots[i].rect.bottom); + debugPrintf(") - (%d, %d, %d, %d)\n", _vm->_hotspots[i]->rect.left, _vm->_hotspots[i]->rect.top, _vm->_hotspots[i]->rect.right, _vm->_hotspots[i]->rect.bottom); debugPrintf(" Name = %s\n", _vm->getHotspotName(i).c_str()); } diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp index b7ff1c38ed..586c5f5f74 100644 --- a/engines/mohawk/riven.cpp +++ b/engines/mohawk/riven.cpp @@ -58,7 +58,6 @@ MohawkEngine_Riven::MohawkEngine_Riven(OSystem *syst, const MohawkGameDescriptio _ignoreNextMouseUp = false; _extrasFile = nullptr; _curStack = kStackUnknown; - _hotspots = nullptr; _gfx = nullptr; _sound = nullptr; _externalScriptHandler = nullptr; @@ -68,7 +67,6 @@ MohawkEngine_Riven::MohawkEngine_Riven(OSystem *syst, const MohawkGameDescriptio _saveLoad = nullptr; _optionsDialog = nullptr; _card = nullptr; - _hotspotCount = 0; _curHotspot = -1; removeTimer(); @@ -105,7 +103,9 @@ MohawkEngine_Riven::~MohawkEngine_Riven() { delete _scriptMan; delete _optionsDialog; delete _rnd; - delete[] _hotspots; + for (uint i = 0; i < _hotspots.size(); i++) { + delete _hotspots[i]; + } delete g_atrusJournalRect1; delete g_atrusJournalRect2; delete g_cathJournalRect2; @@ -257,8 +257,8 @@ void MohawkEngine_Riven::handleEvents() { case Common::KEYCODE_F4: _showHotspots = !_showHotspots; if (_showHotspots) { - for (uint16 i = 0; i < _hotspotCount; i++) - _gfx->drawRect(_hotspots[i].rect, _hotspots[i].enabled); + for (uint16 i = 0; i < _hotspots.size(); i++) + _gfx->drawRect(_hotspots[i]->rect, _hotspots[i]->enabled); needsUpdate = true; } else refreshCard(); @@ -414,8 +414,8 @@ void MohawkEngine_Riven::refreshCard() { _card->open(); if (_showHotspots) - for (uint16 i = 0; i < _hotspotCount; i++) - _gfx->drawRect(_hotspots[i].rect, _hotspots[i].enabled); + for (uint16 i = 0; i < _hotspots.size(); i++) + _gfx->drawRect(_hotspots[i]->rect, _hotspots[i]->enabled); // Now we need to redraw the cursor if necessary and handle mouse over scripts updateCurrentHotspot(); @@ -425,46 +425,17 @@ void MohawkEngine_Riven::refreshCard() { } void MohawkEngine_Riven::loadHotspots(uint16 id) { - // Clear old hotspots - delete[] _hotspots; - - // NOTE: The hotspot scripts are cleared by the RivenScriptManager automatically. + for (uint i = 0; i < _hotspots.size(); i++) { + delete _hotspots[i]; + } Common::SeekableReadStream *inStream = getResource(ID_HSPT, id); - _hotspotCount = inStream->readUint16BE(); - _hotspots = new RivenHotspot[_hotspotCount]; - - for (uint16 i = 0; i < _hotspotCount; i++) { - _hotspots[i].enabled = true; - - _hotspots[i].blstID = inStream->readUint16BE(); - _hotspots[i].name_resource = inStream->readSint16BE(); - - int16 left = inStream->readSint16BE(); - int16 top = inStream->readSint16BE(); - int16 right = inStream->readSint16BE(); - int16 bottom = inStream->readSint16BE(); + uint16 hotspotCount = inStream->readUint16BE(); + _hotspots.resize(hotspotCount); - // Riven has some invalid rects, disable them here - // Known weird hotspots: - // - tspit 371 (DVD: 377), hotspot 4 - if (left >= right || top >= bottom) { - warning("%s %d hotspot %d is invalid: (%d, %d, %d, %d)", getStackName(_curStack).c_str(), id, i, left, top, right, bottom); - left = top = right = bottom = 0; - _hotspots[i].enabled = 0; - } - - _hotspots[i].rect = Common::Rect(left, top, right, bottom); - - _hotspots[i].u0 = inStream->readUint16BE(); - _hotspots[i].mouse_cursor = inStream->readUint16BE(); - _hotspots[i].index = inStream->readUint16BE(); - _hotspots[i].u1 = inStream->readSint16BE(); - _hotspots[i].zipModeHotspot = inStream->readUint16BE(); - - // Read in the scripts now - _hotspots[i].scripts = _scriptMan->readScripts(inStream); + for (uint16 i = 0; i < hotspotCount; i++) { + _hotspots[i] = new RivenHotspot(this, inStream); } delete inStream; @@ -474,11 +445,11 @@ void MohawkEngine_Riven::loadHotspots(uint16 id) { void MohawkEngine_Riven::updateZipMode() { // Check if a zip mode hotspot is enabled by checking the name/id against the ZIPS records. - for (uint32 i = 0; i < _hotspotCount; i++) { - if (_hotspots[i].zipModeHotspot) { + for (uint32 i = 0; i < _hotspots.size(); i++) { + if (_hotspots[i]->zipModeHotspot) { if (_vars["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); + Common::String hotspotName = getName(HotspotNames, _hotspots[i]->name_resource); bool foundMatch = false; @@ -489,9 +460,9 @@ void MohawkEngine_Riven::updateZipMode() { break; } - _hotspots[i].enabled = foundMatch; + _hotspots[i]->enabled = foundMatch; } else // Disable the hotspot if zip mode is disabled - _hotspots[i].enabled = false; + _hotspots[i]->enabled = false; } } } @@ -499,8 +470,8 @@ void MohawkEngine_Riven::updateZipMode() { void MohawkEngine_Riven::checkHotspotChange() { uint16 hotspotIndex = 0; bool foundHotspot = false; - for (uint16 i = 0; i < _hotspotCount; i++) - if (_hotspots[i].enabled && _hotspots[i].rect.contains(_eventMan->getMousePos())) { + for (uint16 i = 0; i < _hotspots.size(); i++) + if (_hotspots[i]->enabled && _hotspots[i]->rect.contains(_eventMan->getMousePos())) { foundHotspot = true; hotspotIndex = i; } @@ -508,7 +479,7 @@ void MohawkEngine_Riven::checkHotspotChange() { if (foundHotspot) { if (_curHotspot != hotspotIndex) { _curHotspot = hotspotIndex; - _cursor->setCursor(_hotspots[_curHotspot].mouse_cursor); + _cursor->setCursor(_hotspots[_curHotspot]->mouse_cursor); _system->updateScreen(); } } else { @@ -524,12 +495,12 @@ void MohawkEngine_Riven::updateCurrentHotspot() { } Common::String MohawkEngine_Riven::getHotspotName(uint16 hotspot) { - assert(hotspot < _hotspotCount); + assert(hotspot < _hotspots.size()); - if (_hotspots[hotspot].name_resource < 0) + if (_hotspots[hotspot]->name_resource < 0) return Common::String(); - return getName(HotspotNames, _hotspots[hotspot].name_resource); + return getName(HotspotNames, _hotspots[hotspot]->name_resource); } void MohawkEngine_Riven::checkInventoryClick() { @@ -663,13 +634,7 @@ uint32 MohawkEngine_Riven::getCurCardRMAP() { } void MohawkEngine_Riven::runHotspotScript(uint16 hotspot, uint16 scriptType) { - assert(hotspot < _hotspotCount); - for (uint16 i = 0; i < _hotspots[hotspot].scripts.size(); i++) - if (_hotspots[hotspot].scripts[i].type == scriptType) { - RivenScriptPtr script = _hotspots[hotspot].scripts[i].script; - _scriptMan->runScript(script, false); - break; - } + _hotspots[hotspot]->runScript(scriptType); } void MohawkEngine_Riven::delayAndUpdate(uint32 ms) { diff --git a/engines/mohawk/riven.h b/engines/mohawk/riven.h index 55661617b0..2fa8c65906 100644 --- a/engines/mohawk/riven.h +++ b/engines/mohawk/riven.h @@ -42,6 +42,7 @@ class RivenConsole; class RivenSaveLoad; class RivenOptionsDialog; class RivenCard; +class RivenHotspot; class RivenSoundManager; // Riven Stack Types @@ -86,20 +87,6 @@ extern Common::Rect *g_cathJournalRect3; extern Common::Rect *g_trapBookRect3; extern Common::Rect *g_demoExitRect; -struct RivenHotspot { - uint16 blstID; - int16 name_resource; - Common::Rect rect; - uint16 u0; - uint16 mouse_cursor; - uint16 index; - int16 u1; - int16 zipModeHotspot; - RivenScriptList scripts; - - bool enabled; -}; - struct ZipMode { Common::String name; uint16 id; @@ -148,7 +135,6 @@ private: void handleEvents(); // Hotspot related functions and variables - uint16 _hotspotCount; void loadHotspots(uint16); void checkInventoryClick(); bool _showHotspots; @@ -180,10 +166,9 @@ public: uint32 getCurCardRMAP(); // Hotspot functions/variables - RivenHotspot *_hotspots; + Common::Array<RivenHotspot *> _hotspots; int32 _curHotspot; Common::Array<ZipMode> _zipModeData; - uint16 getHotspotCount() const { return _hotspotCount; } void runHotspotScript(uint16 hotspot, uint16 scriptType); int32 getCurHotspot() const { return _curHotspot; } Common::String getHotspotName(uint16 hotspot); diff --git a/engines/mohawk/riven_card.cpp b/engines/mohawk/riven_card.cpp index 34045faef2..9f4635ffbd 100644 --- a/engines/mohawk/riven_card.cpp +++ b/engines/mohawk/riven_card.cpp @@ -196,4 +196,50 @@ SLSTRecord RivenCard::getSound(uint16 index) const { error("Could not find sound %d in card %d", index, _id); } +RivenHotspot::RivenHotspot(MohawkEngine_Riven *vm, Common::ReadStream *stream) : + _vm(vm) { + loadFromStream(stream); +} + +void RivenHotspot::loadFromStream(Common::ReadStream *stream) { + enabled = true; + + blstID = stream->readUint16BE(); + name_resource = stream->readSint16BE(); + + int16 left = stream->readSint16BE(); + int16 top = stream->readSint16BE(); + int16 right = stream->readSint16BE(); + int16 bottom = stream->readSint16BE(); + + // Riven has some invalid rects, disable them here + // Known weird hotspots: + // - tspit 371 (DVD: 377), hotspot 4 + if (left >= right || top >= bottom) { + warning("Invalid hotspot: (%d, %d, %d, %d)", left, top, right, bottom); + left = top = right = bottom = 0; + enabled = 0; + } + + rect = Common::Rect(left, top, right, bottom); + + _u0 = stream->readUint16BE(); + mouse_cursor = stream->readUint16BE(); + index = stream->readUint16BE(); + _u1 = stream->readSint16BE(); + zipModeHotspot = stream->readUint16BE(); + + // Read in the scripts now + _scripts = _vm->_scriptMan->readScripts(stream); +} + +void RivenHotspot::runScript(uint16 scriptType) { + for (uint16 i = 0; i < _scripts.size(); i++) + if (_scripts[i].type == scriptType) { + RivenScriptPtr script = _scripts[i].script; + _vm->_scriptMan->runScript(script, false); + break; + } +} + } // End of namespace Mohawk diff --git a/engines/mohawk/riven_card.h b/engines/mohawk/riven_card.h index b83f330c79..b4e41972f5 100644 --- a/engines/mohawk/riven_card.h +++ b/engines/mohawk/riven_card.h @@ -95,6 +95,38 @@ private: Common::Array<SLSTRecord> _soundList; }; +/** + * A Card Hotspot + * + * Hotspots are named rectangular areas of the view. + * Hotspots can be interactive through their scripts. + */ +class RivenHotspot { +public: + RivenHotspot(MohawkEngine_Riven *vm, Common::ReadStream *stream); + + /** Run one of the hotspot's scripts */ + void runScript(uint16 scriptType); + + uint16 blstID; + int16 name_resource; + uint16 index; + Common::Rect rect; + uint16 mouse_cursor; + int16 zipModeHotspot; + + bool enabled; // TODO: Remove + +private: + void loadFromStream(Common::ReadStream *stream); + + MohawkEngine_Riven *_vm; + + uint16 _u0; + int16 _u1; + RivenScriptList _scripts; +}; + } // End of namespace Mohawk #endif diff --git a/engines/mohawk/riven_external.cpp b/engines/mohawk/riven_external.cpp index a7161dff7b..b0aa782669 100644 --- a/engines/mohawk/riven_external.cpp +++ b/engines/mohawk/riven_external.cpp @@ -316,19 +316,19 @@ void RivenExternal::checkDomeSliders(uint16 resetSlidersHotspot, uint16 openDome // Let's see if we're all matched up... if (_vm->_vars["adomecombo"] == _sliderState) { // Set the button hotspot to the open dome hotspot - _vm->_hotspots[resetSlidersHotspot].enabled = false; - _vm->_hotspots[openDomeHotspot].enabled = true; + _vm->_hotspots[resetSlidersHotspot]->enabled = false; + _vm->_hotspots[openDomeHotspot]->enabled = true; } else { // Set the button hotspot to the reset sliders hotspot - _vm->_hotspots[resetSlidersHotspot].enabled = true; - _vm->_hotspots[openDomeHotspot].enabled = false; + _vm->_hotspots[resetSlidersHotspot]->enabled = true; + _vm->_hotspots[openDomeHotspot]->enabled = false; } } void RivenExternal::checkSliderCursorChange(uint16 startHotspot) { // Set the cursor based on _sliderState and what hotspot we're over for (uint16 i = 0; i < kDomeSliderSlotCount; i++) { - if (_vm->_hotspots[i + startHotspot].rect.contains(_vm->_system->getEventManager()->getMousePos())) { + if (_vm->_hotspots[i + startHotspot]->rect.contains(_vm->_system->getEventManager()->getMousePos())) { if (_sliderState & (1 << (24 - i))) _vm->_cursor->setCursor(kRivenOpenHandCursor); else @@ -343,7 +343,7 @@ void RivenExternal::dragDomeSlider(uint16 soundId, uint16 resetSlidersHotspot, u int16 foundSlider = -1; for (uint16 i = 0; i < kDomeSliderSlotCount; i++) { - if (_vm->_hotspots[i + startHotspot].rect.contains(_vm->_system->getEventManager()->getMousePos())) { + if (_vm->_hotspots[i + startHotspot]->rect.contains(_vm->_system->getEventManager()->getMousePos())) { // If the slider is not at this hotspot, we can't do anything else if (!(_sliderState & (1 << (24 - i)))) return; @@ -367,7 +367,7 @@ void RivenExternal::dragDomeSlider(uint16 soundId, uint16 resetSlidersHotspot, u while (_vm->_system->getEventManager()->pollEvent(event)) { switch (event.type) { case Common::EVENT_MOUSEMOVE: - if (foundSlider < 24 && !(_sliderState & (1 << (23 - foundSlider))) && _vm->_hotspots[foundSlider + startHotspot + 1].rect.contains(event.mouse)) { + if (foundSlider < 24 && !(_sliderState & (1 << (23 - foundSlider))) && _vm->_hotspots[foundSlider + startHotspot + 1]->rect.contains(event.mouse)) { // We've moved the slider right one space _sliderState &= ~(_sliderState & (1 << (24 - foundSlider))); foundSlider++; @@ -376,7 +376,7 @@ void RivenExternal::dragDomeSlider(uint16 soundId, uint16 resetSlidersHotspot, u // Now play a click sound and redraw _vm->_sound->playSound(soundId); drawDomeSliders(startHotspot); - } else if (foundSlider > 0 && !(_sliderState & (1 << (25 - foundSlider))) && _vm->_hotspots[foundSlider + startHotspot - 1].rect.contains(event.mouse)) { + } else if (foundSlider > 0 && !(_sliderState & (1 << (25 - foundSlider))) && _vm->_hotspots[foundSlider + startHotspot - 1]->rect.contains(event.mouse)) { // We've moved the slider left one space _sliderState &= ~(_sliderState & (1 << (24 - foundSlider))); foundSlider--; @@ -414,10 +414,10 @@ void RivenExternal::drawDomeSliders(uint16 startHotspot) { uint16 bitmapId = _vm->findResourceID(ID_TBMP, "*sliders*"); for (uint16 i = 0; i < kDomeSliderSlotCount; i++) { - Common::Rect srcRect = _vm->_hotspots[startHotspot + i].rect; + Common::Rect srcRect = _vm->_hotspots[startHotspot + i]->rect; srcRect.translate(-dstAreaRect.left, -dstAreaRect.top); // Adjust the rect so it's in the destination area - Common::Rect dstRect = _vm->_hotspots[startHotspot + i].rect; + Common::Rect dstRect = _vm->_hotspots[startHotspot + i]->rect; if (_sliderState & (1 << (24 - i))) _vm->_gfx->drawImageRect(bitmapId, srcRect, dstRect); @@ -450,13 +450,13 @@ void RivenExternal::xaatrusopenbook(uint16 argc, uint16 *argv) { // Set hotspots depending on the page if (page == 1) { - _vm->_hotspots[1].enabled = false; - _vm->_hotspots[2].enabled = false; - _vm->_hotspots[3].enabled = true; + _vm->_hotspots[1]->enabled = false; + _vm->_hotspots[2]->enabled = false; + _vm->_hotspots[3]->enabled = true; } else { - _vm->_hotspots[1].enabled = true; - _vm->_hotspots[2].enabled = true; - _vm->_hotspots[3].enabled = false; + _vm->_hotspots[1]->enabled = true; + _vm->_hotspots[2]->enabled = true; + _vm->_hotspots[3]->enabled = false; } // Draw the image of the page @@ -515,13 +515,13 @@ void RivenExternal::xacathopenbook(uint16 argc, uint16 *argv) { // Set hotspots depending on the page if (page == 1) { - _vm->_hotspots[1].enabled = false; - _vm->_hotspots[2].enabled = false; - _vm->_hotspots[3].enabled = true; + _vm->_hotspots[1]->enabled = false; + _vm->_hotspots[2]->enabled = false; + _vm->_hotspots[3]->enabled = true; } else { - _vm->_hotspots[1].enabled = true; - _vm->_hotspots[2].enabled = true; - _vm->_hotspots[3].enabled = false; + _vm->_hotspots[1]->enabled = true; + _vm->_hotspots[2]->enabled = true; + _vm->_hotspots[3]->enabled = false; } // Draw the image of the page @@ -947,11 +947,11 @@ void RivenExternal::xbait(uint16 argc, uint16 *argv) { _vm->_system->updateScreen(); // Set the bait if we put it on the plate - if (_vm->_hotspots[9].rect.contains(_vm->_system->getEventManager()->getMousePos())) { + if (_vm->_hotspots[9]->rect.contains(_vm->_system->getEventManager()->getMousePos())) { _vm->_vars["bbait"] = 1; _vm->getCurCard()->drawPicture(4); - _vm->_hotspots[3].enabled = false; // Disable bait hotspot - _vm->_hotspots[9].enabled = true; // Enable baitplate hotspot + _vm->_hotspots[3]->enabled = false; // Disable bait hotspot + _vm->_hotspots[9]->enabled = true; // Enable baitplate hotspot } } @@ -1006,15 +1006,15 @@ void RivenExternal::xbaitplate(uint16 argc, uint16 *argv) { _vm->_system->updateScreen(); // Set the bait if we put it on the plate, remove otherwise - if (_vm->_hotspots[9].rect.contains(_vm->_system->getEventManager()->getMousePos())) { + if (_vm->_hotspots[9]->rect.contains(_vm->_system->getEventManager()->getMousePos())) { _vm->_vars["bbait"] = 1; _vm->getCurCard()->drawPicture(4); - _vm->_hotspots[3].enabled = false; // Disable bait hotspot - _vm->_hotspots[9].enabled = true; // Enable baitplate hotspot + _vm->_hotspots[3]->enabled = false; // Disable bait hotspot + _vm->_hotspots[9]->enabled = true; // Enable baitplate hotspot } else { _vm->_vars["bbait"] = 0; - _vm->_hotspots[3].enabled = true; // Enable bait hotspot - _vm->_hotspots[9].enabled = false; // Disable baitplate hotspot + _vm->_hotspots[3]->enabled = true; // Enable bait hotspot + _vm->_hotspots[9]->enabled = false; // Disable baitplate hotspot } } @@ -1194,8 +1194,8 @@ void RivenExternal::xgpincontrols(uint16 argc, uint16 *argv) { // Get our mouse position and adjust it to the beginning of the hotspot Common::Point mousePos = _vm->_system->getEventManager()->getMousePos(); - mousePos.x -= _vm->_hotspots[3].rect.left; - mousePos.y -= _vm->_hotspots[3].rect.top; + mousePos.x -= _vm->_hotspots[3]->rect.left; + mousePos.y -= _vm->_hotspots[3]->rect.top; // And now adjust it to which box we hit mousePos.x /= 10; @@ -1995,8 +1995,8 @@ void RivenExternal::xschool280_playwhark(uint16 argc, uint16 *argv) { } // Enable the correct hotspots for the movement now - _vm->_hotspots[2].enabled = !_vm->_hotspots[2].enabled; - _vm->_hotspots[3].enabled = !_vm->_hotspots[3].enabled; + _vm->_hotspots[2]->enabled = !_vm->_hotspots[2]->enabled; + _vm->_hotspots[3]->enabled = !_vm->_hotspots[3]->enabled; // Update the cursor _vm->updateCurrentHotspot(); @@ -2048,7 +2048,7 @@ void RivenExternal::xbookclick(uint16 argc, uint16 *argv) { // Track down our hotspot // Of course, they're not in any sane order... static const uint16 hotspotMap[] = { 1, 3, 2, 0 }; - Common::Rect hotspotRect = _vm->_hotspots[hotspotMap[argv[3] - 1]].rect; + Common::Rect hotspotRect = _vm->_hotspots[hotspotMap[argv[3] - 1]]->rect; debug(0, "xbookclick:"); debug(0, "\tVideo Code = %d", argv[0]); @@ -2157,9 +2157,9 @@ void RivenExternal::xooffice30_closebook(uint16 argc, uint16 *argv) { _vm->_video->playMovieBlockingRiven(1); // Set the hotspots into their correct states - _vm->_hotspots[2].enabled = false; - _vm->_hotspots[5].enabled = false; - _vm->_hotspots[6].enabled = true; + _vm->_hotspots[2]->enabled = false; + _vm->_hotspots[5]->enabled = false; + _vm->_hotspots[6]->enabled = true; // We now need to draw PLST 1 and refresh, but PLST 1 is // drawn when refreshing anyway, so don't worry about that. @@ -2484,7 +2484,7 @@ void RivenExternal::xtisland390_covercombo(uint16 argc, uint16 *argv) { // If we have hit the correct 5 buttons in a row, activate the hotspot to open up the // telescope cover. - _vm->_hotspots[9].enabled = (correctDigits == 5); + _vm->_hotspots[9]->enabled = (correctDigits == 5); } // Atrus' Journal and Trap Book are added to inventory @@ -2617,9 +2617,9 @@ void RivenExternal::setMarbleHotspots() { uint32 &marblePos = _vm->_vars[s_marbleNames[i]]; if (marblePos == 0) // In the receptacle - _vm->_hotspots[i + 3].rect = _marbleBaseHotspots[i]; + _vm->_hotspots[i + 3]->rect = _marbleBaseHotspots[i]; else // On the grid - _vm->_hotspots[i + 3].rect = generateMarbleGridRect(getMarbleX(marblePos), getMarbleY(marblePos)); + _vm->_hotspots[i + 3]->rect = generateMarbleGridRect(getMarbleX(marblePos), getMarbleY(marblePos)); } } @@ -2627,7 +2627,7 @@ void RivenExternal::xt7800_setup(uint16 argc, uint16 *argv) { // First, let's store the base receptacle hotspots for the marbles if (_marbleBaseHotspots.empty()) for (uint16 i = 0; i < kMarbleCount; i++) - _marbleBaseHotspots.push_back(_vm->_hotspots[i + 3].rect); + _marbleBaseHotspots.push_back(_vm->_hotspots[i + 3]->rect); // Move the marble hotspots based on their position variables setMarbleHotspots(); @@ -2640,7 +2640,7 @@ void RivenExternal::drawMarbles() { if (_vm->_vars["themarble"] - 1 == i) continue; - Common::Rect rect = _vm->_hotspots[i + 3].rect; + Common::Rect rect = _vm->_hotspots[i + 3]->rect; // Trim the rect down a bit rect.left += 3; rect.top += 3; @@ -2663,7 +2663,7 @@ void RivenExternal::xtakeit(uint16 argc, uint16 *argv) { marble = 0; for (uint32 i = 0; i < kMarbleCount; i++) - if (_vm->_hotspots[i + 3].rect.contains(_vm->_system->getEventManager()->getMousePos())) { + if (_vm->_hotspots[i + 3]->rect.contains(_vm->_system->getEventManager()->getMousePos())) { marble = i + 1; break; } diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp index bdb30bd391..35b719537b 100644 --- a/engines/mohawk/riven_scripts.cpp +++ b/engines/mohawk/riven_scripts.cpp @@ -358,10 +358,10 @@ void RivenSimpleCommand::mohawkSwitch(uint16 op, uint16 argc, uint16 *argv) { // Command 9: enable hotspot (blst_id) void RivenSimpleCommand::enableHotspot(uint16 op, uint16 argc, uint16 *argv) { - for (uint16 i = 0; i < _vm->getHotspotCount(); i++) { - if (_vm->_hotspots[i].blstID == argv[0]) { + for (uint16 i = 0; i < _vm->_hotspots.size(); i++) { + if (_vm->_hotspots[i]->blstID == argv[0]) { debug(2, "Enabling hotspot with BLST ID %d", argv[0]); - _vm->_hotspots[i].enabled = true; + _vm->_hotspots[i]->enabled = true; } } @@ -371,10 +371,10 @@ void RivenSimpleCommand::enableHotspot(uint16 op, uint16 argc, uint16 *argv) { // Command 10: disable hotspot (blst_id) void RivenSimpleCommand::disableHotspot(uint16 op, uint16 argc, uint16 *argv) { - for (uint16 i = 0; i < _vm->getHotspotCount(); i++) { - if (_vm->_hotspots[i].blstID == argv[0]) { + for (uint16 i = 0; i < _vm->_hotspots.size(); i++) { + if (_vm->_hotspots[i]->blstID == argv[0]) { debug(2, "Disabling hotspot with BLST ID %d", argv[0]); - _vm->_hotspots[i].enabled = false; + _vm->_hotspots[i]->enabled = false; } } @@ -601,9 +601,9 @@ void RivenSimpleCommand::activateBLST(uint16 op, uint16 argc, uint16 *argv) { uint16 hotspotID = blst->readUint16BE(); if (argv[0] == index) - for (uint16 j = 0; j < _vm->getHotspotCount(); j++) - if (_vm->_hotspots[j].blstID == hotspotID) - _vm->_hotspots[j].enabled = (enabled == 1); + for (uint16 j = 0; j < _vm->_hotspots.size(); j++) + if (_vm->_hotspots[j]->blstID == hotspotID) + _vm->_hotspots[j]->enabled = (enabled == 1); } delete blst; |