[Scummvm-cvs-logs] CVS: scummvm/scumm actor.cpp,1.128,1.129

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Sat Jun 21 08:11:03 CEST 2003


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv20442

Modified Files:
	actor.cpp 
Log Message:
Fixed bug #758167. Cleanup.


Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.cpp,v
retrieving revision 1.128
retrieving revision 1.129
diff -u -d -r1.128 -r1.129
--- actor.cpp	14 Jun 2003 13:38:21 -0000	1.128
+++ actor.cpp	21 Jun 2003 15:10:30 -0000	1.129
@@ -807,16 +807,24 @@
 	}
 }
 
-
-#define DRAW_ORDER(x)	((x)->y - ((x)->layer << 11))
 inline int32 drawOrder (const Actor* x) { return (x)->y - ((x)->layer << 11); }
 
 int sortByDrawOrder (const void* a, const void* b)
 {
 	const Actor* actor1 = *(const Actor *const*)a;
 	const Actor* actor2 = *(const Actor *const*)b;
-	assert (DRAW_ORDER (actor1)==drawOrder (actor1) && DRAW_ORDER (actor1)==drawOrder (actor1));
-	return drawOrder (actor1)-drawOrder (actor2);
+	int32 order1 = drawOrder(actor1);
+	int32 order2 = drawOrder(actor2);
+
+	// The qsort() function is apparently not guaranteed to be stable (i.e.
+	// it may re-order actors with the same draw order value). Use the
+	// actor number as tie-breaker. This is needed for the Sam & Max intro,
+	// and possibly other cases as well. See bug #758167.
+
+	if (order1 == order2)
+		return actor1->number - actor2->number;
+
+	return order1 - order2;
 }
 
 void Scumm::processActors() {





More information about the Scummvm-git-logs mailing list