[Scummvm-cvs-logs] scummvm master -> 69d6e72f849786de672144bd7367761df89d242e

dreammaster dreammaster at scummvm.org
Sun Jun 1 20:44:07 CEST 2014


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
69d6e72f84 MADS: Fix dynamic hotspots in scenes with multiple such hotspots


Commit: 69d6e72f849786de672144bd7367761df89d242e
    https://github.com/scummvm/scummvm/commit/69d6e72f849786de672144bd7367761df89d242e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-06-01T14:43:26-04:00

Commit Message:
MADS: Fix dynamic hotspots in scenes with multiple such hotspots

Changed paths:
    engines/mads/action.cpp
    engines/mads/hotspots.cpp
    engines/mads/hotspots.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index 80480cb..d0b4583 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 365f309..d75d7ae 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 5fd910e..f9334ea 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);






More information about the Scummvm-git-logs mailing list