aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Snover2016-03-05 23:58:19 -0600
committerColin Snover2016-03-06 21:34:43 -0600
commit3e631ca5e3a3e19cb08be83c039ae9681a2e6cbc (patch)
treeab826fec09d5c39d16b7d26a23894db74b8f0287
parente8d6ad1d0bcfef12bdf468c9a6a80cd14ae2d8f7 (diff)
downloadscummvm-rg350-3e631ca5e3a3e19cb08be83c039ae9681a2e6cbc.tar.gz
scummvm-rg350-3e631ca5e3a3e19cb08be83c039ae9681a2e6cbc.tar.bz2
scummvm-rg350-3e631ca5e3a3e19cb08be83c039ae9681a2e6cbc.zip
SCI32: "Improve" comparison algorithm for planes and screen items
This adds a slightly more accurate comparison algorithm that will at least ensure that all the engine-generated planes and screen items with matching priorities will be sorted above script-generated planes and screen items, like in the original engine. It still does not sort script-generated items by memory handle order, so if that is ever a thing that actually happens, those may still be in the wrong order.
-rw-r--r--engines/sci/graphics/plane32.cpp15
-rw-r--r--engines/sci/graphics/plane32.h14
-rw-r--r--engines/sci/graphics/screen_item32.h11
3 files changed, 35 insertions, 5 deletions
diff --git a/engines/sci/graphics/plane32.cpp b/engines/sci/graphics/plane32.cpp
index 7d1487bd7c..0a0b0ad561 100644
--- a/engines/sci/graphics/plane32.cpp
+++ b/engines/sci/graphics/plane32.cpp
@@ -447,7 +447,20 @@ void Plane::calcLists(Plane &visiblePlane, const PlaneList &planeList, DrawList
if (j < _screenItemList.size() && sli) {
if (!sli->_updated && !sli->_deleted && !sli->_created) {
ScreenItem *item = dli->screenItem;
- if (sli->_priority > item->_priority /* TODO: || (sli->_priority == item->_priority && sli->_object > item->_object)*/) {
+
+ bool isAbove = false;
+ if (sli->_priority > item->_priority) {
+ isAbove = true;
+ }
+ else if (sli->_priority == item->_priority) {
+ if (sli->_object.isNumber() && item->_object.isNumber()) {
+ isAbove = sli->_object > item->_object;
+ } else if (sli->_object.isNumber()) {
+ isAbove = true;
+ }
+ }
+
+ if (isAbove) {
if (dli->rect.intersects(sli->_screenRect)) {
drawList.add(sli, dli->rect.findIntersectingRect(sli->_screenRect));
}
diff --git a/engines/sci/graphics/plane32.h b/engines/sci/graphics/plane32.h
index 65df19d924..c9b9d6a099 100644
--- a/engines/sci/graphics/plane32.h
+++ b/engines/sci/graphics/plane32.h
@@ -272,7 +272,19 @@ public:
// However, this whole comparison is quite ugly, and if it still
// fails, we should try to change it to something equivalent, to avoid
// adding loads of workarounds just for this
- return _priority < other._priority || (_priority == other._priority && _priority > -1 && _object.getOffset() < other._object.getOffset());
+ if (_priority < other._priority) {
+ return true;
+ }
+
+ if (_priority == other._priority) {
+ if (_object.isNumber() && other._object.isNumber()) {
+ return _object < other._object;
+ } else if (other._object.isNumber()) {
+ return true;
+ }
+ }
+
+ return false;
}
/**
diff --git a/engines/sci/graphics/screen_item32.h b/engines/sci/graphics/screen_item32.h
index e054cf32f3..1c4d87d24c 100644
--- a/engines/sci/graphics/screen_item32.h
+++ b/engines/sci/graphics/screen_item32.h
@@ -228,9 +228,14 @@ public:
}
if (_position.y + _z == other._position.y + other._z) {
- return false;
- // TODO: Failure in SQ6 room 220
-// return _object < other._object;
+ // TODO: Failure in SQ6 room 220 when using SCI logic
+ // to compare pointer and numeric memory handles
+
+ if (_object.isNumber() && other._object.isNumber()) {
+ return _object < other._object;
+ } else if (other._object.isNumber()) {
+ return true;
+ }
}
}