From 7543bd444d46b2a8d4a2c79967c0a8d45a0874d1 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Thu, 13 Jul 2017 17:03:34 -0500 Subject: SCI32: Move priority comparison of ScreenItems into its own function Rendering bugs in ScummVM are often caused by buggy game scripts relying on the last ditch sort, which is not the same in ScummVM as in SSCI (since the SSCI last ditch sort relies on a different memory architecture and is super buggy). However, these bugs do not show up very frequently these days, so it is easy to forget all the places that need to be checked when debugging a rendering problem that appears to be caused by sorting failure. This commit breaks out the last ditch comparison formerly in Plane::calcLists to hopefully make it more visible to future programmers. Refs Trac#9957. --- engines/sci/graphics/screen_item32.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'engines/sci/graphics/screen_item32.h') diff --git a/engines/sci/graphics/screen_item32.h b/engines/sci/graphics/screen_item32.h index c2c4e43358..ef29609da6 100644 --- a/engines/sci/graphics/screen_item32.h +++ b/engines/sci/graphics/screen_item32.h @@ -275,6 +275,8 @@ public: // these insertion IDs instead. They are more stable and cause // objects with identical priority and z-index to be rendered in // the order that they were created. + // + // This also applies to ScreenItem::hasPriorityAbove. return _creationId < other._creationId; } } @@ -302,6 +304,20 @@ public: return false; } + inline bool hasPriorityAbove(const ScreenItem &other) const { + if (_priority > other._priority) { + return true; + } + + if (_priority == other._priority) { + // This is different than SSCI; see ScreenItem::operator< for an + // explanation + return _creationId > other._creationId; + } + + return false; + } + /** * Calculates the dimensions and scaling parameters for * the screen item, using the given plane as the parent -- cgit v1.2.3