aboutsummaryrefslogtreecommitdiff
path: root/engines/mads/hotspots.cpp
diff options
context:
space:
mode:
authorFilippos Karapetis2019-08-04 14:03:47 +0300
committerFilippos Karapetis2019-08-04 14:05:09 +0300
commit913229f9dbce3dc4b3670ffe5d7f7c4405d1a820 (patch)
treeef6c34ec09188c8cf1bb0eebcd52aa298967854c /engines/mads/hotspots.cpp
parent8940601413012ab0c2e1423415c4a9cfd4bcf7fa (diff)
downloadscummvm-rg350-913229f9dbce3dc4b3670ffe5d7f7c4405d1a820.tar.gz
scummvm-rg350-913229f9dbce3dc4b3670ffe5d7f7c4405d1a820.tar.bz2
scummvm-rg350-913229f9dbce3dc4b3670ffe5d7f7c4405d1a820.zip
MADS: Implement V2 DynamicHotspots::add()
Diffstat (limited to 'engines/mads/hotspots.cpp')
-rw-r--r--engines/mads/hotspots.cpp41
1 files changed, 36 insertions, 5 deletions
diff --git a/engines/mads/hotspots.cpp b/engines/mads/hotspots.cpp
index 098313eca4..06d5756cec 100644
--- a/engines/mads/hotspots.cpp
+++ b/engines/mads/hotspots.cpp
@@ -31,7 +31,9 @@ DynamicHotspot::DynamicHotspot() {
_facing = FACING_NONE;
_descId = 0;
_verbId = 0;
+ _valid = false; // V2
_articleNumber = 0;
+ _syntax = 0; // V2
_cursor = CURSOR_NONE;
_active = false;
}
@@ -53,9 +55,36 @@ DynamicHotspots::DynamicHotspots(MADSEngine *vm) : _vm(vm) {
_count = 0;
}
-int DynamicHotspots::add(int descId, int verbId, int syntax, int seqIndex, const Common::Rect &bounds) {
- warning("TODO: DynamicHotspots::add(5 params))");
- return add(descId, verbId, seqIndex, bounds);
+int DynamicHotspots::add(int descId, int verbId, byte syntax, int seqIndex, const Common::Rect &bounds) {
+ // Find a free slot
+ uint idx = 0;
+ while ((idx < _entries.size()) && _entries[idx]._active)
+ ++idx;
+ if (idx == _entries.size())
+ error("DynamicHotspots overflow");
+
+ _entries[idx]._active = true;
+ _entries[idx]._descId = descId;
+ _entries[idx]._seqIndex = seqIndex;
+ _entries[idx]._bounds = bounds;
+ _entries[idx]._feetPos = Common::Point(-3, 0);
+ _entries[idx]._facing = FACING_NONE;
+ _entries[idx]._verbId = verbId;
+ _entries[idx]._articleNumber = PREP_IN;
+ _entries[idx]._syntax = syntax;
+ _entries[idx]._cursor = CURSOR_NONE;
+ _entries[idx]._valid = true;
+ _entries[idx]._animIndex = -1;
+
+ ++_count;
+ _changed = true;
+
+ if (seqIndex >= 0) {
+ _vm->_game->_scene._sequences[seqIndex]._dynamicHotspotIndex = idx;
+ _entries[idx]._valid = false;
+ }
+
+ return idx;
}
int DynamicHotspots::add(int descId, int verbId, int seqIndex, const Common::Rect &bounds) {
@@ -138,11 +167,13 @@ void DynamicHotspots::refresh() {
ScreenObjects &scrObjects = _vm->_game->_screenObjects;
scrObjects.resize(scrObjects._uiCount);
+ bool isV2 = (_vm->getGameID() != GType_RexNebular);
+
// Loop through adding hotspots
for (uint i = 0; i < _entries.size(); ++i) {
DynamicHotspot &dh = (*this)[i];
- if ((*this)[i]._active) {
+ if ((*this)[i]._active && (!isV2 || (*this)[i]._valid)) {
switch (scrObjects._inputMode) {
case kInputBuildingSentences:
case kInputLimitedSentences:
@@ -203,7 +234,7 @@ Hotspot::Hotspot(Common::SeekableReadStream &f, bool isV2) {
_cursor = (CursorType)f.readByte();
if (isV2) {
f.skip(1); // cursor
- f.skip(1); // syntax
+ _syntax = f.readByte();
}
_vocabId = f.readUint16LE();
_verbId = f.readUint16LE();