[Scummvm-cvs-logs] scummvm master -> 8c00644cf269d788ee7ebfc291373e049257ba23

dreammaster dreammaster at scummvm.org
Fri Jul 10 14:24:19 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:
8c00644cf2 SHERLOCK: RT: Fix interacting with characters


Commit: 8c00644cf269d788ee7ebfc291373e049257ba23
    https://github.com/scummvm/scummvm/commit/8c00644cf269d788ee7ebfc291373e049257ba23
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2015-07-10T08:23:12-04:00

Commit Message:
SHERLOCK: RT: Fix interacting with characters

Changed paths:
    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/scene.cpp b/engines/sherlock/scene.cpp
index 2f8762e..e56561f 100644
--- a/engines/sherlock/scene.cpp
+++ b/engines/sherlock/scene.cpp
@@ -1338,7 +1338,7 @@ Exit *Scene::checkForExit(const Common::Rect &r) {
 	return nullptr;
 }
 
-int Scene::findBgShape(const Common::Rect &r) {
+int Scene::findBgShape(const Common::Point &pt) {
 	if (!_doBgAnimDone)
 		// New frame hasn't been drawn yet
 		return -1;
@@ -1347,10 +1347,10 @@ int Scene::findBgShape(const Common::Rect &r) {
 		Object &o = _bgShapes[idx];
 		if (o._type != INVALID && o._type != NO_SHAPE && o._type != HIDDEN
 			&& o._aType <= PERSON) {
-			if (r.intersects(o.getNewBounds()))
+			if (o.getNewBounds().contains(pt))
 				return idx;
 		} else if (o._type == NO_SHAPE) {
-			if (r.intersects(o.getNoShapeBounds()))
+			if (o.getNoShapeBounds().contains(pt))
 				return idx;
 		}
 	}
@@ -1358,10 +1358,6 @@ int Scene::findBgShape(const Common::Rect &r) {
 	return -1;
 }
 
-int Scene::findBgShape(const Common::Point &pt) {
-	return findBgShape(Common::Rect(pt.x, pt.y, pt.x + 1, pt.y + 1));
-}
-
 int Scene::checkForZones(const Common::Point &pt, int zoneType) {
 	int matches = 0;
 
diff --git a/engines/sherlock/scene.h b/engines/sherlock/scene.h
index 8ae6327..0fbda38 100644
--- a/engines/sherlock/scene.h
+++ b/engines/sherlock/scene.h
@@ -270,18 +270,6 @@ public:
 	int toggleObject(const Common::String &name);
 
 	/**
-	 * Attempts to find a background shape within the passed bounds. If found,
-	 * it will return the shape number, or -1 on failure.
-	 */
-	int findBgShape(const Common::Rect &r);
-
-	/**
-	 * Attempts to find a background shape within the passed bounds. If found,
-	 * it will return the shape number, or -1 on failure.
-	 */
-	int findBgShape(const Common::Point &pt);
-
-	/**
 	 * Checks to see if the given position in the scene belongs to a given zone type.
 	 * If it is, the zone is activated and used just like a TAKL zone or aFLAG_SET zone.
 	 */
@@ -298,6 +286,12 @@ public:
 	virtual int closestZone(const Common::Point &pt) = 0;
 
 	/**
+	 * Attempts to find a background shape within the passed bounds. If found,
+	 * it will return the shape number, or -1 on failure.
+	 */
+	virtual int findBgShape(const Common::Point &pt);
+
+	/**
 	 * Synchronize the data for a savegame
 	 */
 	virtual void synchronize(Serializer &s);
diff --git a/engines/sherlock/tattoo/tattoo_scene.cpp b/engines/sherlock/tattoo/tattoo_scene.cpp
index f8ca265..badc58d 100644
--- a/engines/sherlock/tattoo/tattoo_scene.cpp
+++ b/engines/sherlock/tattoo/tattoo_scene.cpp
@@ -708,6 +708,39 @@ void TattooScene::setNPCPath(int npc) {
 	talk.talkTo(pathFile);
 }
 
+int TattooScene::findBgShape(const Common::Point &pt) {
+	People &people = *_vm->_people;
+
+	if (!_doBgAnimDone)
+		// New frame hasn't been drawn yet
+		return -1;
+
+	int result = Scene::findBgShape(pt);
+	if (result == -1) {
+		// No shape found, so check whether a character is highlighted
+		for (int idx = 1; idx < MAX_CHARACTERS && result == -1; ++idx) {
+			Person &person = people[idx];
+
+			if (person._type == CHARACTER) {
+				int scaleVal = getScaleVal(person._position);
+				Common::Rect charRect;
+
+				if (scaleVal == SCALE_THRESHOLD)
+					charRect = Common::Rect(person.frameWidth(), person.frameHeight());
+				else
+					charRect = Common::Rect(person._imageFrame->sDrawXSize(scaleVal), person._imageFrame->sDrawYSize(scaleVal));
+				charRect.moveTo(person._position.x / FIXED_INT_MULTIPLIER, person._position.y / FIXED_INT_MULTIPLIER
+					- charRect.height());
+
+				if (charRect.contains(pt))
+					result = 1000 + idx;
+			}
+		}
+	}
+
+	return result;
+}
+
 void TattooScene::synchronize(Serializer &s) {
 	TattooEngine &vm = *(TattooEngine *)_vm;
 	Scene::synchronize(s);
diff --git a/engines/sherlock/tattoo/tattoo_scene.h b/engines/sherlock/tattoo/tattoo_scene.h
index 695fef3..432233f 100644
--- a/engines/sherlock/tattoo/tattoo_scene.h
+++ b/engines/sherlock/tattoo/tattoo_scene.h
@@ -132,6 +132,12 @@ public:
 	 *		A negative playRate can also be specified to play the animation in reverse
 	 */
 	virtual int startCAnim(int cAnimNum, int playRate = 1);
+
+	/**
+	 * Attempts to find a background shape within the passed bounds. If found,
+	 * it will return the shape number, or -1 on failure.
+	 */
+	virtual int findBgShape(const Common::Point &pt);
 };
 
 } // End of namespace Tattoo






More information about the Scummvm-git-logs mailing list