aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk/riven_card.cpp
diff options
context:
space:
mode:
authorBastien Bouclet2016-08-05 08:07:02 +0200
committerEugene Sandulenko2017-07-03 08:50:10 +0200
commit23bbf05c9162e8126df21794b08eb953d65d057e (patch)
tree5283789bd4abc14029f156f474ccf33e443d5822 /engines/mohawk/riven_card.cpp
parent1b062d1e39988388468bb13af97276d5674bbcbe (diff)
downloadscummvm-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/riven_card.cpp')
-rw-r--r--engines/mohawk/riven_card.cpp46
1 files changed, 46 insertions, 0 deletions
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