Skip to content

Commit

Permalink
SCI32: Always sort kernel-generated screen items above script-generat…
Browse files Browse the repository at this point in the history
…ed screen items in last-ditch sort

Fixes Trac#10257. Fixes Trac#10261.
  • Loading branch information
csnover committed Oct 3, 2017
1 parent 2c79c25 commit 8985f8f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions engines/sci/graphics/screen_item32.h
Expand Up @@ -256,6 +256,16 @@ class ScreenItem {
}

if (_position.y + _z == other._position.y + other._z) {
// Synthetic object IDs (numeric IDs) are used for screen items
// generated by the kernel, like the screen items generated by
// plane pics. In SSCI, these synthetic IDs started at 20000 so
// would deterministically always sort higher than any
// script-generated view in SSCI at the same position and
// priority.
if (other._object.isNumber() && !_object.isNumber()) {
return true;
}

// SSCI's last resort comparison here is to compare the _object
// IDs, but this is wrong and randomly breaks (at least):
//
Expand Down Expand Up @@ -295,6 +305,10 @@ class ScreenItem {
}

if (_position.y + _z == other._position.y + other._z) {
if (_object.isNumber() && !other._object.isNumber()) {
return true;
}

// This is different than SSCI; see ScreenItem::operator< for an
// explanation
return _creationId > other._creationId;
Expand All @@ -310,6 +324,10 @@ class ScreenItem {
}

if (_priority == other._priority) {
if (_object.isNumber() && !other._object.isNumber()) {
return true;
}

// This is different than SSCI; see ScreenItem::operator< for an
// explanation
return _creationId > other._creationId;
Expand Down

0 comments on commit 8985f8f

Please sign in to comment.