[Scummvm-git-logs] scummvm master -> 5d13b0831b0827c88c76dbe2b205a77fbd33dcd6
OMGPizzaGuy
noreply at scummvm.org
Sat Jan 14 00:58:25 UTC 2023
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
5d13b0831b ULTIMA8: Add item sort rules for land and roof.
Commit: 5d13b0831b0827c88c76dbe2b205a77fbd33dcd6
https://github.com/scummvm/scummvm/commit/5d13b0831b0827c88c76dbe2b205a77fbd33dcd6
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-01-13T18:57:58-06:00
Commit Message:
ULTIMA8: Add item sort rules for land and roof.
This fixes Pentagram bug #276.
Changed paths:
engines/ultima/ultima8/world/sort_item.h
test/engines/ultima/ultima8/world/sort_item.h
diff --git a/engines/ultima/ultima8/world/sort_item.h b/engines/ultima/ultima8/world/sort_item.h
index b85aada37dd..d538ace0bd2 100644
--- a/engines/ultima/ultima8/world/sort_item.h
+++ b/engines/ultima/ultima8/world/sort_item.h
@@ -352,7 +352,7 @@ inline bool SortItem::below(const SortItem &si2) const {
}
// Mixed, or non flat
else {
- // Inv items always drawn first if their z-bottom is equal or higher.
+ // Inv items always drawn first if their z-bottom is equal or higher.
// This is a bit of a hack as 2 places in Crusader there are keycards
// on tables but their z position is the bottom z of the table.
if (si1._invitem) {
@@ -377,6 +377,18 @@ inline bool SortItem::below(const SortItem &si2) const {
if (si1._z != si2._z)
return si1._z < si2._z;
+ // Land always gets drawn first
+ if (si1._land != si2._land)
+ return si1._land > si2._land;
+
+ // Land always gets drawn before roof
+ if (si1._land && si2._land && si1._roof != si2._roof)
+ return si1._roof < si2._roof;
+
+ // Roof always gets drawn first
+ if (si1._roof != si2._roof)
+ return si1._roof > si2._roof;
+
// Partial in X + Y front
if (si1._x + si1._y != si2._x + si2._y)
return (si1._x + si1._y < si2._x + si2._y);
diff --git a/test/engines/ultima/ultima8/world/sort_item.h b/test/engines/ultima/ultima8/world/sort_item.h
index 2c87e6296f1..9ef0eb2dae2 100644
--- a/test/engines/ultima/ultima8/world/sort_item.h
+++ b/test/engines/ultima/ultima8/world/sort_item.h
@@ -127,4 +127,31 @@ class U8SortItemTestSuite : public CxxTest::TestSuite {
si1._fbigsq = false;
}
+ /* Overlapping non-flat items also follow a set of rules */
+ void test_non_flat_sort() {
+ Ultima::Ultima8::SortItem si1(nullptr);
+ Ultima::Ultima8::SortItem si2(nullptr);
+
+ // Land always gets drawn below
+ // MainActor::teleport 6 7642 19776 48
+ si1._x = 128;
+ si1._y = 32;
+ si1._z = 0;
+ si1._xLeft = 0;
+ si1._yFar = 0;
+ si1._zTop = 8;
+ si1._occl = true;
+ si1._roof = true;
+ si1._land = true;
+
+ si2._x = 92;
+ si2._y = 64;
+ si2._z = 0;
+ si2._xLeft = 28;
+ si2._yFar = 0;
+ si2._zTop = 40;
+ si2._solid = true;
+ TS_ASSERT(si1.below(si2));
+ TS_ASSERT(!si2.below(si1));
+ }
};
More information about the Scummvm-git-logs
mailing list