aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk
diff options
context:
space:
mode:
Diffstat (limited to 'engines/mohawk')
-rw-r--r--engines/mohawk/console.cpp9
-rw-r--r--engines/mohawk/riven.cpp46
-rw-r--r--engines/mohawk/riven.h7
-rw-r--r--engines/mohawk/riven_external.cpp4
4 files changed, 29 insertions, 37 deletions
diff --git a/engines/mohawk/console.cpp b/engines/mohawk/console.cpp
index 966929b4ef..95a2064f48 100644
--- a/engines/mohawk/console.cpp
+++ b/engines/mohawk/console.cpp
@@ -513,15 +513,16 @@ bool RivenConsole::Cmd_Hotspots(int argc, const char **argv) {
debugPrintf("Current card (%d) has %d hotspots:\n", _vm->getCurCard()->getId(), _vm->_hotspots.size());
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);
+ RivenHotspot *hotspot = _vm->_hotspots[i];
+ debugPrintf("Hotspot %d, index %d, BLST ID %d (", i, hotspot->index, hotspot->blstID);
- if (_vm->_hotspots[i]->enabled)
+ if (hotspot->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(" Name = %s\n", _vm->getHotspotName(i).c_str());
+ debugPrintf(") - (%d, %d, %d, %d)\n", hotspot->rect.left, hotspot->rect.top, hotspot->rect.right, hotspot->rect.bottom);
+ debugPrintf(" Name = %s\n", _vm->getHotspotName(hotspot).c_str());
}
return true;
diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index 586c5f5f74..50140f50fb 100644
--- a/engines/mohawk/riven.cpp
+++ b/engines/mohawk/riven.cpp
@@ -67,7 +67,7 @@ MohawkEngine_Riven::MohawkEngine_Riven(OSystem *syst, const MohawkGameDescriptio
_saveLoad = nullptr;
_optionsDialog = nullptr;
_card = nullptr;
- _curHotspot = -1;
+ _curHotspot = nullptr;
removeTimer();
// NOTE: We can never really support CD swapping. All of the music files
@@ -227,17 +227,17 @@ void MohawkEngine_Riven::handleEvents() {
needsUpdate = true;
break;
case Common::EVENT_LBUTTONDOWN:
- if (_curHotspot >= 0) {
+ if (_curHotspot) {
checkSunnerAlertClick();
- runHotspotScript(_curHotspot, kMouseDownScript);
+ _curHotspot->runScript(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, kMouseUpScript);
+ if (_curHotspot)
+ _curHotspot->runScript(kMouseUpScript);
else
checkInventoryClick();
}
@@ -294,8 +294,8 @@ void MohawkEngine_Riven::handleEvents() {
}
}
- if (_curHotspot >= 0)
- runHotspotScript(_curHotspot, kMouseInsideScript);
+ if (_curHotspot)
+ _curHotspot->runScript(kMouseInsideScript);
// Update the screen if we need to
if (needsUpdate)
@@ -468,39 +468,35 @@ void MohawkEngine_Riven::updateZipMode() {
}
void MohawkEngine_Riven::checkHotspotChange() {
- uint16 hotspotIndex = 0;
- bool foundHotspot = false;
+ RivenHotspot *hotspot = nullptr;
for (uint16 i = 0; i < _hotspots.size(); i++)
if (_hotspots[i]->enabled && _hotspots[i]->rect.contains(_eventMan->getMousePos())) {
- foundHotspot = true;
- hotspotIndex = i;
+ hotspot = _hotspots[i];
}
- if (foundHotspot) {
- if (_curHotspot != hotspotIndex) {
- _curHotspot = hotspotIndex;
- _cursor->setCursor(_hotspots[_curHotspot]->mouse_cursor);
+ if (hotspot) {
+ if (_curHotspot != hotspot) {
+ _curHotspot = hotspot;
+ _cursor->setCursor(hotspot->mouse_cursor);
_system->updateScreen();
}
} else {
- _curHotspot = -1;
+ _curHotspot = nullptr;
_cursor->setCursor(kRivenMainCursor);
_system->updateScreen();
}
}
void MohawkEngine_Riven::updateCurrentHotspot() {
- _curHotspot = -1;
+ _curHotspot = nullptr;
checkHotspotChange();
}
-Common::String MohawkEngine_Riven::getHotspotName(uint16 hotspot) {
- assert(hotspot < _hotspots.size());
-
- if (_hotspots[hotspot]->name_resource < 0)
+Common::String MohawkEngine_Riven::getHotspotName(const RivenHotspot *hotspot) {
+ if (hotspot->name_resource < 0)
return Common::String();
- return getName(HotspotNames, _hotspots[hotspot]->name_resource);
+ return getName(HotspotNames, hotspot->name_resource);
}
void MohawkEngine_Riven::checkInventoryClick() {
@@ -633,10 +629,6 @@ uint32 MohawkEngine_Riven::getCurCardRMAP() {
return rmapCode;
}
-void MohawkEngine_Riven::runHotspotScript(uint16 hotspot, uint16 scriptType) {
- _hotspots[hotspot]->runScript(scriptType);
-}
-
void MohawkEngine_Riven::delayAndUpdate(uint32 ms) {
uint32 startTime = _system->getMillis();
@@ -935,7 +927,7 @@ void MohawkEngine_Riven::checkSunnerAlertClick() {
return;
// Only set the sunners variable on the forward hotspot
- if ((rmapCode == 0x79bd && _curHotspot != 1) || (rmapCode == 0x7beb && _curHotspot != 2))
+ if ((rmapCode == 0x79bd && _curHotspot->index != 2) || (rmapCode == 0x7beb && _curHotspot->index != 3))
return;
// If the alert video is no longer playing, we have nothing left to do
diff --git a/engines/mohawk/riven.h b/engines/mohawk/riven.h
index 2fa8c65906..e4f0803578 100644
--- a/engines/mohawk/riven.h
+++ b/engines/mohawk/riven.h
@@ -167,11 +167,10 @@ public:
// Hotspot functions/variables
Common::Array<RivenHotspot *> _hotspots;
- int32 _curHotspot;
+ RivenHotspot *_curHotspot;
Common::Array<ZipMode> _zipModeData;
- void runHotspotScript(uint16 hotspot, uint16 scriptType);
- int32 getCurHotspot() const { return _curHotspot; }
- Common::String getHotspotName(uint16 hotspot);
+ RivenHotspot *getCurHotspot() const { return _curHotspot; }
+ Common::String getHotspotName(const RivenHotspot *hotspot);
void updateCurrentHotspot();
void addZipVisitedCard(uint16 cardId, uint16 cardNameId);
diff --git a/engines/mohawk/riven_external.cpp b/engines/mohawk/riven_external.cpp
index b0aa782669..86c58ff05c 100644
--- a/engines/mohawk/riven_external.cpp
+++ b/engines/mohawk/riven_external.cpp
@@ -1342,7 +1342,7 @@ void RivenExternal::xgrviewer(uint16 argc, uint16 *argv) {
// Calculate how much we're moving
static const uint16 hotspotPositions[] = { 2, 1, 5, 4, 3 };
uint32 &curPos = _vm->_vars["grviewpos"];
- uint32 newPos = curPos + hotspotPositions[_vm->_curHotspot - 1];
+ uint32 newPos = curPos + hotspotPositions[_vm->_curHotspot->index - 2];
// Now play the movie
VideoHandle handle = _vm->_video->playMovieRiven(1);
@@ -1411,7 +1411,7 @@ void RivenExternal::xglviewer(uint16 argc, uint16 *argv) {
// Calculate how much we're moving
static const uint16 hotspotPositions[] = { 1, 5, 4, 2, 0, 0, 3 };
uint32 &curPos = _vm->_vars["glviewpos"];
- uint32 newPos = curPos + hotspotPositions[_vm->_curHotspot - 1];
+ uint32 newPos = curPos + hotspotPositions[_vm->_curHotspot->index - 2];
// Now play the movie
VideoHandle handle = _vm->_video->playMovieRiven(1);