diff options
author | Paul Gilbert | 2014-06-01 14:43:26 -0400 |
---|---|---|
committer | Paul Gilbert | 2014-06-01 14:43:26 -0400 |
commit | 69d6e72f849786de672144bd7367761df89d242e (patch) | |
tree | 55fa9cd3a55b1f6e32ac04dbe92f71c733349359 /engines/mads | |
parent | d42317b35cd18a963798e0a81582b8b184107297 (diff) | |
download | scummvm-rg350-69d6e72f849786de672144bd7367761df89d242e.tar.gz scummvm-rg350-69d6e72f849786de672144bd7367761df89d242e.tar.bz2 scummvm-rg350-69d6e72f849786de672144bd7367761df89d242e.zip |
MADS: Fix dynamic hotspots in scenes with multiple such hotspots
Diffstat (limited to 'engines/mads')
-rw-r--r-- | engines/mads/action.cpp | 10 | ||||
-rw-r--r-- | engines/mads/hotspots.cpp | 9 | ||||
-rw-r--r-- | engines/mads/hotspots.h | 6 |
3 files changed, 20 insertions, 5 deletions
diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp index 80480cbdfd..d0b4583d92 100644 --- a/engines/mads/action.cpp +++ b/engines/mads/action.cpp @@ -190,7 +190,7 @@ void MADSAction::set() { verbId = scene._hotspots[_hotspotId]._verbId; } else { // Get the verb Id from the scene object - verbId = scene._dynamicHotspots[_hotspotId - scene._hotspots.size()]._verbId; + verbId = scene._dynamicHotspots.get(_hotspotId - scene._hotspots.size())._verbId; } if (verbId > 0) { @@ -213,7 +213,7 @@ void MADSAction::set() { _action._objectNameId = scene._hotspots[_hotspotId]._vocabId; } else { // Get name from temporary scene hotspot - _action._objectNameId = scene._dynamicHotspots[_hotspotId - scene._hotspots.size()]._descId; + _action._objectNameId = scene._dynamicHotspots.get(_hotspotId - scene._hotspots.size())._descId; } appendVocab(_action._objectNameId); } @@ -226,7 +226,7 @@ void MADSAction::set() { } else if (_secondObject < (int)scene._hotspots.size()) { _action._indirectObjectId = scene._hotspots[_secondObject]._vocabId; } else { - _action._indirectObjectId = scene._dynamicHotspots[_secondObject - scene._hotspots.size()]._descId; + _action._indirectObjectId = scene._dynamicHotspots.get(_secondObject - scene._hotspots.size())._descId; } } @@ -241,7 +241,7 @@ void MADSAction::set() { } else if (_hotspotId < (int)scene._hotspots.size()) { articleNum = scene._hotspots[_hotspotId]._articleNumber; } else { - articleNum = scene._dynamicHotspots[_hotspotId - scene._hotspots.size()]._articleNumber; + articleNum = scene._dynamicHotspots.get(_hotspotId - scene._hotspots.size())._articleNumber; } _statusText += kArticleList[articleNum]; @@ -344,7 +344,7 @@ void MADSAction::startAction() { hotspotId = _savedFields._secondObject; if (hotspotId >= (int)hotspots.size()) { - DynamicHotspot &hs = dynHotspots[hotspotId - hotspots.size()]; + DynamicHotspot &hs = dynHotspots.get(hotspotId - hotspots.size()); if ((hs._feetPos.x == -1) || (hs._feetPos.x == -3)) { startWalkingDirectly(hs._feetPos.x); } else if (hs._feetPos.x == 0) { diff --git a/engines/mads/hotspots.cpp b/engines/mads/hotspots.cpp index 365f30985b..d75d7ae13e 100644 --- a/engines/mads/hotspots.cpp +++ b/engines/mads/hotspots.cpp @@ -150,6 +150,15 @@ void DynamicHotspots::refresh() { _changed = false; } +DynamicHotspot &DynamicHotspots::get(int index) { + for (uint i = 0; i < _entries.size(); ++i) { + if (_entries[i]._active && index-- == 0) + return _entries[i]; + } + + error("Could not find dynamic hotspot"); +} + void DynamicHotspots::synchronize(Common::Serializer &s) { int count = _entries.size(); s.syncAsSint16LE(count); diff --git a/engines/mads/hotspots.h b/engines/mads/hotspots.h index 5fd910e1aa..f9334eace8 100644 --- a/engines/mads/hotspots.h +++ b/engines/mads/hotspots.h @@ -77,6 +77,12 @@ public: void refresh(); /** + * Get an active dynamic hotspot + * @param index Active index + */ + DynamicHotspot &get(int index); + + /** * Synchronize the data */ void synchronize(Common::Serializer &s); |