[Scummvm-cvs-logs] scummvm master -> 1c6316a3569173c5d5f3f52bb1226d4343deb612

dreammaster dreammaster at scummvm.org
Mon Aug 24 00:42: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:
1c6316a356 SHERLOCK: RT: Fix z-ordering when picking up Hat Pin


Commit: 1c6316a3569173c5d5f3f52bb1226d4343deb612
    https://github.com/scummvm/scummvm/commit/1c6316a3569173c5d5f3f52bb1226d4343deb612
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2015-08-23T18:41:50-04:00

Commit Message:
SHERLOCK: RT: Fix z-ordering when picking up Hat Pin

Changed paths:
    engines/sherlock/tattoo/tattoo_scene.cpp



diff --git a/engines/sherlock/tattoo/tattoo_scene.cpp b/engines/sherlock/tattoo/tattoo_scene.cpp
index b639ff8..f13d058 100644
--- a/engines/sherlock/tattoo/tattoo_scene.cpp
+++ b/engines/sherlock/tattoo/tattoo_scene.cpp
@@ -43,19 +43,21 @@ struct ShapeEntry {
 	TattooPerson *_person;
 	bool _isAnimation;
 	int _yp;
-	int _objNum;
-
-	ShapeEntry(TattooPerson *person, int yp, int npcIndex) : 
-		_shape(nullptr), _person(person), _yp(yp), _isAnimation(false), _objNum(npcIndex + 1000) {}
-	ShapeEntry(Object *shape, int yp, int objNum) :
-		_shape(shape), _person(nullptr), _yp(yp), _isAnimation(false), _objNum(objNum) {}
-	ShapeEntry(int yp) : 
-		_shape(nullptr), _person(nullptr), _yp(yp), _isAnimation(true), _objNum(-1) {}
+	int _ordering;
+
+	ShapeEntry(TattooPerson *person, int yp, int ordering) :
+		_shape(nullptr), _person(person), _yp(yp), _isAnimation(false), _ordering(ordering) {}
+	ShapeEntry(Object *shape, int yp, int ordering) :
+		_shape(shape), _person(nullptr), _yp(yp), _isAnimation(false), _ordering(ordering) {}
+	ShapeEntry(int yp, int ordering) : 
+		_shape(nullptr), _person(nullptr), _yp(yp), _isAnimation(true), _ordering(ordering) {}
 };
 typedef Common::List<ShapeEntry> ShapeList;
 
 static bool sortImagesY(const ShapeEntry &s1, const ShapeEntry &s2) {
-	return s1._yp < s2._yp || (s1._yp == s2._yp && s1._objNum < s2._objNum);
+	// Objects are order by the calculated Y position first and then, when both are equal,
+	// by the order in which the entries were added
+	return s1._yp < s2._yp || (s1._yp == s2._yp && s1._ordering < s2._ordering);
 }
 
 /*----------------------------------------------------------------*/
@@ -123,6 +125,7 @@ void TattooScene::drawAllShapes() {
 	TattooPeople &people = *(TattooPeople *)_vm->_people;
 	Screen &screen = *_vm->_screen;
 	ShapeList shapeList;
+	int ordering = 0;
 
 	// Draw all objects and animations that are set to behind
 	screen.setDisplayBounds(Common::Rect(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT));
@@ -153,10 +156,10 @@ void TattooScene::drawAllShapes() {
 		if (obj._type == ACTIVE_BG_SHAPE && (obj._misc == NORMAL_BEHIND || obj._misc == NORMAL_FORWARD)) {
 			if (obj._scaleVal == SCALE_THRESHOLD)
 				shapeList.push_back(ShapeEntry(&obj, obj._position.y + obj._imageFrame->_offset.y +
-					obj._imageFrame->_height, idx));
+					obj._imageFrame->_height, ordering++));
 			else
 				shapeList.push_back(ShapeEntry(&obj, obj._position.y + obj._imageFrame->sDrawYOffset(obj._scaleVal) +
-					obj._imageFrame->sDrawYSize(obj._scaleVal), idx));
+					obj._imageFrame->sDrawYSize(obj._scaleVal), ordering++));
 		}
 	}
 
@@ -164,16 +167,16 @@ void TattooScene::drawAllShapes() {
 	if (_activeCAnim.active() && (_activeCAnim._zPlacement == NORMAL_BEHIND || _activeCAnim._zPlacement == NORMAL_FORWARD)) {
 		if (_activeCAnim._scaleVal == SCALE_THRESHOLD)
 			shapeList.push_back(ShapeEntry(_activeCAnim._position.y + _activeCAnim._imageFrame._offset.y +
-				_activeCAnim._imageFrame._height));
+				_activeCAnim._imageFrame._height, ordering++));
 		else
 			shapeList.push_back(ShapeEntry(_activeCAnim._position.y + _activeCAnim._imageFrame.sDrawYOffset(_activeCAnim._scaleVal) +
-				_activeCAnim._imageFrame.sDrawYSize(_activeCAnim._scaleVal)));
+				_activeCAnim._imageFrame.sDrawYSize(_activeCAnim._scaleVal), ordering++));
 	}
 
 	// Queue all active characters for drawing
 	for (int idx = 0; idx < MAX_CHARACTERS; ++idx) {
 		if (people[idx]._type == CHARACTER && people[idx]._walkLoaded)
-			shapeList.push_back(ShapeEntry(&people[idx], people[idx]._position.y / FIXED_INT_MULTIPLIER, idx));
+			shapeList.push_back(ShapeEntry(&people[idx], people[idx]._position.y / FIXED_INT_MULTIPLIER, ordering++));
 	}
 
 	// Sort the list






More information about the Scummvm-git-logs mailing list