aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk
diff options
context:
space:
mode:
authorBastien Bouclet2016-08-05 19:53:34 +0200
committerEugene Sandulenko2017-07-03 08:50:10 +0200
commit17f1903833491d1e80cb2091a0a0bd7dfe4280de (patch)
treeb6da57fefb1434427e794d503f138a8ff990d0c2 /engines/mohawk
parent6b988670e89b01c554495058f9992bc7b8e25a2d (diff)
downloadscummvm-rg350-17f1903833491d1e80cb2091a0a0bd7dfe4280de.tar.gz
scummvm-rg350-17f1903833491d1e80cb2091a0a0bd7dfe4280de.tar.bz2
scummvm-rg350-17f1903833491d1e80cb2091a0a0bd7dfe4280de.zip
MOHAWK: Remove the RivenHotspot enabled field
Diffstat (limited to 'engines/mohawk')
-rw-r--r--engines/mohawk/console.cpp2
-rw-r--r--engines/mohawk/riven.cpp12
-rw-r--r--engines/mohawk/riven_card.cpp22
-rw-r--r--engines/mohawk/riven_card.h18
-rw-r--r--engines/mohawk/riven_external.cpp56
-rw-r--r--engines/mohawk/riven_scripts.cpp6
6 files changed, 72 insertions, 44 deletions
diff --git a/engines/mohawk/console.cpp b/engines/mohawk/console.cpp
index 95a2064f48..06c058ebcb 100644
--- a/engines/mohawk/console.cpp
+++ b/engines/mohawk/console.cpp
@@ -516,7 +516,7 @@ bool RivenConsole::Cmd_Hotspots(int argc, const char **argv) {
RivenHotspot *hotspot = _vm->_hotspots[i];
debugPrintf("Hotspot %d, index %d, BLST ID %d (", i, hotspot->index, hotspot->blstID);
- if (hotspot->enabled)
+ if (hotspot->isEnabled())
debugPrintf("enabled");
else
debugPrintf("disabled");
diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index 50140f50fb..417d2718b6 100644
--- a/engines/mohawk/riven.cpp
+++ b/engines/mohawk/riven.cpp
@@ -258,7 +258,7 @@ void MohawkEngine_Riven::handleEvents() {
_showHotspots = !_showHotspots;
if (_showHotspots) {
for (uint16 i = 0; i < _hotspots.size(); i++)
- _gfx->drawRect(_hotspots[i]->rect, _hotspots[i]->enabled);
+ _gfx->drawRect(_hotspots[i]->rect, _hotspots[i]->isEnabled());
needsUpdate = true;
} else
refreshCard();
@@ -415,7 +415,7 @@ void MohawkEngine_Riven::refreshCard() {
if (_showHotspots)
for (uint16 i = 0; i < _hotspots.size(); i++)
- _gfx->drawRect(_hotspots[i]->rect, _hotspots[i]->enabled);
+ _gfx->drawRect(_hotspots[i]->rect, _hotspots[i]->isEnabled());
// Now we need to redraw the cursor if necessary and handle mouse over scripts
updateCurrentHotspot();
@@ -446,7 +446,7 @@ 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 < _hotspots.size(); i++) {
- if (_hotspots[i]->zipModeHotspot) {
+ if (_hotspots[i]->isZip()) {
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);
@@ -460,9 +460,9 @@ void MohawkEngine_Riven::updateZipMode() {
break;
}
- _hotspots[i]->enabled = foundMatch;
+ _hotspots[i]->enable(foundMatch);
} else // Disable the hotspot if zip mode is disabled
- _hotspots[i]->enabled = false;
+ _hotspots[i]->enable(false);
}
}
}
@@ -470,7 +470,7 @@ void MohawkEngine_Riven::updateZipMode() {
void MohawkEngine_Riven::checkHotspotChange() {
RivenHotspot *hotspot = nullptr;
for (uint16 i = 0; i < _hotspots.size(); i++)
- if (_hotspots[i]->enabled && _hotspots[i]->rect.contains(_eventMan->getMousePos())) {
+ if (_hotspots[i]->isEnabled() && _hotspots[i]->rect.contains(_eventMan->getMousePos())) {
hotspot = _hotspots[i];
}
diff --git a/engines/mohawk/riven_card.cpp b/engines/mohawk/riven_card.cpp
index 9f4635ffbd..32eb63c72b 100644
--- a/engines/mohawk/riven_card.cpp
+++ b/engines/mohawk/riven_card.cpp
@@ -202,7 +202,7 @@ RivenHotspot::RivenHotspot(MohawkEngine_Riven *vm, Common::ReadStream *stream) :
}
void RivenHotspot::loadFromStream(Common::ReadStream *stream) {
- enabled = true;
+ _flags = kFlagEnabled;
blstID = stream->readUint16BE();
name_resource = stream->readSint16BE();
@@ -218,7 +218,7 @@ void RivenHotspot::loadFromStream(Common::ReadStream *stream) {
if (left >= right || top >= bottom) {
warning("Invalid hotspot: (%d, %d, %d, %d)", left, top, right, bottom);
left = top = right = bottom = 0;
- enabled = 0;
+ enable(false);
}
rect = Common::Rect(left, top, right, bottom);
@@ -227,7 +227,7 @@ void RivenHotspot::loadFromStream(Common::ReadStream *stream) {
mouse_cursor = stream->readUint16BE();
index = stream->readUint16BE();
_u1 = stream->readSint16BE();
- zipModeHotspot = stream->readUint16BE();
+ _flags |= stream->readUint16BE();
// Read in the scripts now
_scripts = _vm->_scriptMan->readScripts(stream);
@@ -242,4 +242,20 @@ void RivenHotspot::runScript(uint16 scriptType) {
}
}
+bool RivenHotspot::isEnabled() const {
+ return (_flags & kFlagEnabled) != 0;
+}
+
+void RivenHotspot::enable(bool e) {
+ if (e) {
+ _flags |= kFlagEnabled;
+ } else {
+ _flags &= ~kFlagEnabled;
+ }
+}
+
+bool RivenHotspot::isZip() const {
+ return (_flags & kFlagZip) != 0;
+}
+
} // End of namespace Mohawk
diff --git a/engines/mohawk/riven_card.h b/engines/mohawk/riven_card.h
index b4e41972f5..935ac05bc6 100644
--- a/engines/mohawk/riven_card.h
+++ b/engines/mohawk/riven_card.h
@@ -108,22 +108,34 @@ public:
/** Run one of the hotspot's scripts */
void runScript(uint16 scriptType);
+ /** Enable or disable the hotspot */
+ void enable(bool e);
+
+ /** Can the hotspot be interacted with? */
+ bool isEnabled() const;
+
+ /** Is the hotspot's purpose to zip to another card */
+ bool isZip() const;
+
uint16 blstID;
int16 name_resource;
uint16 index;
Common::Rect rect;
uint16 mouse_cursor;
- int16 zipModeHotspot;
-
- bool enabled; // TODO: Remove
private:
+ enum {
+ kFlagZip = 1,
+ kFlagEnabled = 2
+ };
+
void loadFromStream(Common::ReadStream *stream);
MohawkEngine_Riven *_vm;
uint16 _u0;
int16 _u1;
+ uint16 _flags;
RivenScriptList _scripts;
};
diff --git a/engines/mohawk/riven_external.cpp b/engines/mohawk/riven_external.cpp
index 86c58ff05c..0bc3a86dc7 100644
--- a/engines/mohawk/riven_external.cpp
+++ b/engines/mohawk/riven_external.cpp
@@ -316,12 +316,12 @@ 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]->enable(false);
+ _vm->_hotspots[openDomeHotspot]->enable(true);
} else {
// Set the button hotspot to the reset sliders hotspot
- _vm->_hotspots[resetSlidersHotspot]->enabled = true;
- _vm->_hotspots[openDomeHotspot]->enabled = false;
+ _vm->_hotspots[resetSlidersHotspot]->enable(true);
+ _vm->_hotspots[openDomeHotspot]->enable(false);
}
}
@@ -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]->enable(false);
+ _vm->_hotspots[2]->enable(false);
+ _vm->_hotspots[3]->enable(true);
} else {
- _vm->_hotspots[1]->enabled = true;
- _vm->_hotspots[2]->enabled = true;
- _vm->_hotspots[3]->enabled = false;
+ _vm->_hotspots[1]->enable(true);
+ _vm->_hotspots[2]->enable(true);
+ _vm->_hotspots[3]->enable(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]->enable(false);
+ _vm->_hotspots[2]->enable(false);
+ _vm->_hotspots[3]->enable(true);
} else {
- _vm->_hotspots[1]->enabled = true;
- _vm->_hotspots[2]->enabled = true;
- _vm->_hotspots[3]->enabled = false;
+ _vm->_hotspots[1]->enable(true);
+ _vm->_hotspots[2]->enable(true);
+ _vm->_hotspots[3]->enable(false);
}
// Draw the image of the page
@@ -950,8 +950,8 @@ void RivenExternal::xbait(uint16 argc, uint16 *argv) {
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]->enable(false); // Disable bait hotspot
+ _vm->_hotspots[9]->enable(true); // Enable baitplate hotspot
}
}
@@ -1009,12 +1009,12 @@ void RivenExternal::xbaitplate(uint16 argc, uint16 *argv) {
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]->enable(false); // Disable bait hotspot
+ _vm->_hotspots[9]->enable(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]->enable(true); // Enable bait hotspot
+ _vm->_hotspots[9]->enable(false); // Disable baitplate hotspot
}
}
@@ -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]->enable(!_vm->_hotspots[2]->isEnabled());
+ _vm->_hotspots[3]->enable(!_vm->_hotspots[3]->isEnabled());
// Update the cursor
_vm->updateCurrentHotspot();
@@ -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]->enable(false);
+ _vm->_hotspots[5]->enable(false);
+ _vm->_hotspots[6]->enable(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]->enable(correctDigits == 5);
}
// Atrus' Journal and Trap Book are added to inventory
diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp
index 35b719537b..6e26fc6723 100644
--- a/engines/mohawk/riven_scripts.cpp
+++ b/engines/mohawk/riven_scripts.cpp
@@ -361,7 +361,7 @@ void RivenSimpleCommand::enableHotspot(uint16 op, uint16 argc, uint16 *argv) {
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]->enable(true);
}
}
@@ -374,7 +374,7 @@ void RivenSimpleCommand::disableHotspot(uint16 op, uint16 argc, uint16 *argv) {
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]->enable(false);
}
}
@@ -603,7 +603,7 @@ void RivenSimpleCommand::activateBLST(uint16 op, uint16 argc, uint16 *argv) {
if (argv[0] == index)
for (uint16 j = 0; j < _vm->_hotspots.size(); j++)
if (_vm->_hotspots[j]->blstID == hotspotID)
- _vm->_hotspots[j]->enabled = (enabled == 1);
+ _vm->_hotspots[j]->enable(enabled == 1);
}
delete blst;