[Scummvm-cvs-logs] scummvm master -> dc4689e4b901971448f2625a96d5708a0c6e8ddf

dreammaster dreammaster at scummvm.org
Thu Jul 2 03:12:20 CEST 2015


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:
dc4689e4b9 SHERLOCK: Split up closestZone versions for each game


Commit: dc4689e4b901971448f2625a96d5708a0c6e8ddf
    https://github.com/scummvm/scummvm/commit/dc4689e4b901971448f2625a96d5708a0c6e8ddf
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2015-07-01T21:10:57-04:00

Commit Message:
SHERLOCK: Split up closestZone versions for each game

Changed paths:
    engines/sherlock/scalpel/scalpel_scene.cpp
    engines/sherlock/scalpel/scalpel_scene.h
    engines/sherlock/scene.cpp
    engines/sherlock/scene.h
    engines/sherlock/tattoo/tattoo_scene.cpp
    engines/sherlock/tattoo/tattoo_scene.h



diff --git a/engines/sherlock/scalpel/scalpel_scene.cpp b/engines/sherlock/scalpel/scalpel_scene.cpp
index fa820d9..4e6e9e4 100644
--- a/engines/sherlock/scalpel/scalpel_scene.cpp
+++ b/engines/sherlock/scalpel/scalpel_scene.cpp
@@ -702,6 +702,25 @@ int ScalpelScene::startCAnim(int cAnimNum, int playRate) {
 	return 1;
 }
 
+int ScalpelScene::closestZone(const Common::Point &pt) {
+	int dist = 1000;
+	int zone = -1;
+
+	for (uint idx = 0; idx < _zones.size(); ++idx) {
+		Common::Point zc((_zones[idx].left + _zones[idx].right) / 2,
+			(_zones[idx].top + _zones[idx].bottom) / 2);
+		int d = ABS(zc.x - pt.x) + ABS(zc.y - pt.y);
+
+		if (d < dist) {
+			// Found a closer zone
+			dist = d;
+			zone = idx;
+		}
+	}
+
+	return zone;
+}
+
 } // End of namespace Scalpel
 
 } // End of namespace Sherlock
diff --git a/engines/sherlock/scalpel/scalpel_scene.h b/engines/sherlock/scalpel/scalpel_scene.h
index 77e86cf..fa65ecd 100644
--- a/engines/sherlock/scalpel/scalpel_scene.h
+++ b/engines/sherlock/scalpel/scalpel_scene.h
@@ -65,6 +65,11 @@ protected:
 	 * Draw all the shapes, people and NPCs in the correct order
 	 */
 	virtual void drawAllShapes();
+
+	/**
+	 * Returns the index of the closest zone to a given point.
+	 */
+	virtual int closestZone(const Common::Point &pt);
 public:
 	ScalpelScene(SherlockEngine *vm) : Scene(vm) {}
 
diff --git a/engines/sherlock/scene.cpp b/engines/sherlock/scene.cpp
index 69deede..3d406fe 100644
--- a/engines/sherlock/scene.cpp
+++ b/engines/sherlock/scene.cpp
@@ -1379,54 +1379,6 @@ int Scene::whichZone(const Common::Point &pt) {
 	return -1;
 }
 
-int Scene::closestZone(const Common::Point &pt) {
-	int zone = -1;
-	int dist = 9999;
-	int d;
-
-	for (uint idx = 0; idx < _zones.size(); ++idx) {
-		Common::Rect &r = _zones[idx];
-
-		// Check the distance from the point to the center of the zone
-		d = ABS(r.left + (r.width() / 2) - pt.x) + ABS(r.top + (r.height() / 2) - pt.y);
-		if (d < dist) {
-			dist = d;
-			zone = idx;
-		}
-
-		// Check the distance from the point to the upper left of the zone
-		d = ABS((int)(r.left - pt.x)) + ABS((int)(r.top - pt.y));
-		if (d < dist)
-		{
-			dist = d;
-			zone = idx;
-		}
-
-		// Check the distance from the point to the upper right of the zone
-		d = ABS(r.left + r.width() - pt.x) + ABS(r.top - pt.y);
-		if (d < dist) {
-			dist = d;
-			zone = idx;
-		}
-
-		// Check the distance from the point to the lower left of the zone
-		d = ABS(r.left - pt.x) + ABS(r.top + r.height() - pt.y);
-		if (d < dist) {
-			dist = d;
-			zone = idx;
-		}
-
-		// Check the distance from the point to the lower right of the zone
-		d = ABS(r.left + r.width() - pt.x) + ABS(r.top + r.height() - pt.y);
-		if (d < dist) {
-			dist = d;
-			zone = idx;
-		}
-	}
-
-	return zone;
-}
-
 void Scene::synchronize(Serializer &s) {
 	if (s.isSaving())
 		saveSceneStatus();
diff --git a/engines/sherlock/scene.h b/engines/sherlock/scene.h
index 5037b9d..4ffe1ac 100644
--- a/engines/sherlock/scene.h
+++ b/engines/sherlock/scene.h
@@ -297,7 +297,7 @@ public:
 	/**
 	 * Returns the index of the closest zone to a given point.
 	 */
-	int closestZone(const Common::Point &pt);
+	virtual int closestZone(const Common::Point &pt) = 0;
 
 	/**
 	 * Synchronize the data for a savegame
diff --git a/engines/sherlock/tattoo/tattoo_scene.cpp b/engines/sherlock/tattoo/tattoo_scene.cpp
index 0f02f3e..f19eb73 100644
--- a/engines/sherlock/tattoo/tattoo_scene.cpp
+++ b/engines/sherlock/tattoo/tattoo_scene.cpp
@@ -717,6 +717,54 @@ void TattooScene::synchronize(Serializer &s) {
 		vm._runningProlog = false;
 }
 
+int TattooScene::closestZone(const Common::Point &pt) {
+	int zone = -1;
+	int dist = 9999;
+	int d;
+
+	for (uint idx = 0; idx < _zones.size(); ++idx) {
+		Common::Rect &r = _zones[idx];
+
+		// Check the distance from the point to the center of the zone
+		d = ABS(r.left + (r.width() / 2) - pt.x) + ABS(r.top + (r.height() / 2) - pt.y);
+		if (d < dist) {
+			dist = d;
+			zone = idx;
+		}
+
+		// Check the distance from the point to the upper left of the zone
+		d = ABS((int)(r.left - pt.x)) + ABS((int)(r.top - pt.y));
+		if (d < dist)
+		{
+			dist = d;
+			zone = idx;
+		}
+
+		// Check the distance from the point to the upper right of the zone
+		d = ABS(r.left + r.width() - pt.x) + ABS(r.top - pt.y);
+		if (d < dist) {
+			dist = d;
+			zone = idx;
+		}
+
+		// Check the distance from the point to the lower left of the zone
+		d = ABS(r.left - pt.x) + ABS(r.top + r.height() - pt.y);
+		if (d < dist) {
+			dist = d;
+			zone = idx;
+		}
+
+		// Check the distance from the point to the lower right of the zone
+		d = ABS(r.left + r.width() - pt.x) + ABS(r.top + r.height() - pt.y);
+		if (d < dist) {
+			dist = d;
+			zone = idx;
+		}
+	}
+
+	return zone;
+}
+
 } // End of namespace Tattoo
 
 } // End of namespace Sherlock
diff --git a/engines/sherlock/tattoo/tattoo_scene.h b/engines/sherlock/tattoo/tattoo_scene.h
index 81d7637..c3d6e3b 100644
--- a/engines/sherlock/tattoo/tattoo_scene.h
+++ b/engines/sherlock/tattoo/tattoo_scene.h
@@ -96,6 +96,11 @@ protected:
 	 * Synchronize the data for a savegame
 	 */
 	virtual void synchronize(Serializer &s);
+
+	/**
+	 * Returns the index of the closest zone to a given point.
+	 */
+	virtual int closestZone(const Common::Point &pt);
 public:
 	StreamingImageFile _activeCAnim;
 	Common::Array<SceneTripEntry> _sceneTripCounters;






More information about the Scummvm-git-logs mailing list