From 445a805238fc667177d6fc0cc8bc9694cf4aa2d8 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sat, 21 Jun 2003 15:10:30 +0000 Subject: Fixed bug #758167. Cleanup. svn-id: r8577 --- scumm/actor.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scumm/actor.cpp b/scumm/actor.cpp index 42db57b271..5f50d21c50 100644 --- a/scumm/actor.cpp +++ b/scumm/actor.cpp @@ -807,16 +807,24 @@ void Scumm::playActorSounds() { } } - -#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() { -- cgit v1.2.3