diff options
Diffstat (limited to 'engines/sci/graphics/screen_item32.h')
-rw-r--r-- | engines/sci/graphics/screen_item32.h | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/engines/sci/graphics/screen_item32.h b/engines/sci/graphics/screen_item32.h index 009b608f18..c2c4e43358 100644 --- a/engines/sci/graphics/screen_item32.h +++ b/engines/sci/graphics/screen_item32.h @@ -61,6 +61,13 @@ private: */ static uint16 _nextObjectId; + /** + * A serial used to identify the creation order of + * screen items, to ensure a stable sort order for + * screen items with identical priorities and z-indexes. + */ + static uint32 _nextCreationId; + public: /** * The parent plane of this screen item. @@ -120,6 +127,13 @@ private: public: /** + * The creation order number, which ensures a stable + * sort when screen items with identical priorities and + * z-indexes are added to the screen item list. + */ + uint32 _creationId; + + /** * A descriptor for the cel object represented by the * screen item. */ @@ -242,7 +256,26 @@ public: } if (_position.y + _z == other._position.y + other._z) { - return _object < other._object; + // SSCI's last resort comparison here is to compare the _object + // IDs, but this is wrong and randomly breaks (at least): + // + // (1) the death dialog at the end of Phant1, where the ID of + // the text is often higher than the ID of the border; + // (2) text-based buttons and dialogues in Hoyle5, where the ID + // of the text is often lower than the ID of the + // button/dialogue background. + // + // This occurs because object IDs (in both ScummVM and SSCI) are + // reused, so objects created later may receive a lower ID, + // which makes them sort lower when the programmer intended them + // to sort higher. + // + // To fix this problem, we give each ScreenItem a monotonically + // increasing insertion ID at construction time, and compare + // 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. + return _creationId < other._creationId; } } @@ -260,7 +293,9 @@ public: } if (_position.y + _z == other._position.y + other._z) { - return _object > other._object; + // This is different than SSCI; see ScreenItem::operator< for an + // explanation + return _creationId > other._creationId; } } |