[Scummvm-git-logs] scummvm master -> b34e683d388bd8d7dae90aa7069bed93276dfb6a

OMGPizzaGuy noreply at scummvm.org
Sat Sep 30 18:45:42 UTC 2023


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
8ad443bfb7 ULTIMA8: Update sort item tests to use multiples of footpad calculations.
b34e683d38 ULTIMA8: Cleanup checks for X & Y flat sort items


Commit: 8ad443bfb7246db4b46b2f58232060c282154372
    https://github.com/scummvm/scummvm/commit/8ad443bfb7246db4b46b2f58232060c282154372
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-09-30T13:45:21-05:00

Commit Message:
ULTIMA8: Update sort item tests to use multiples of footpad calculations.

Changed paths:
    test/engines/ultima/ultima8/world/sort_item.h


diff --git a/test/engines/ultima/ultima8/world/sort_item.h b/test/engines/ultima/ultima8/world/sort_item.h
index addd6e2c6ba..8515e6ba681 100644
--- a/test/engines/ultima/ultima8/world/sort_item.h
+++ b/test/engines/ultima/ultima8/world/sort_item.h
@@ -42,8 +42,8 @@ class U8SortItemTestSuite : public CxxTest::TestSuite {
 		Ultima::Ultima8::SortItem si1;
 		Ultima::Ultima8::SortItem si2;
 
-		Ultima::Ultima8::Box b1(0, 10, 0, 10, 10, 10);
-		Ultima::Ultima8::Box b2(0, 20, 0, 10, 10, 10);
+		Ultima::Ultima8::Box b1(0, 32, 0, 32, 32, 8);
+		Ultima::Ultima8::Box b2(0, 64, 0, 32, 32, 8);
 		si1.setBoxBounds(b1, 0, 0);
 		si2.setBoxBounds(b2, 0, 0);
 
@@ -59,8 +59,8 @@ class U8SortItemTestSuite : public CxxTest::TestSuite {
 		Ultima::Ultima8::SortItem si1;
 		Ultima::Ultima8::SortItem si2;
 
-		Ultima::Ultima8::Box b1(10, 0, 0, 10, 10, 10);
-		Ultima::Ultima8::Box b2(20, 0, 0, 10, 10, 10);
+		Ultima::Ultima8::Box b1(32, 0, 0, 32, 32, 8);
+		Ultima::Ultima8::Box b2(64, 0, 0, 32, 32, 8);
 		si1.setBoxBounds(b1, 0, 0);
 		si2.setBoxBounds(b2, 0, 0);
 
@@ -76,8 +76,8 @@ class U8SortItemTestSuite : public CxxTest::TestSuite {
 		Ultima::Ultima8::SortItem si1;
 		Ultima::Ultima8::SortItem si2;
 
-		Ultima::Ultima8::Box b1(10, 10, 0, 10, 10, 10);
-		Ultima::Ultima8::Box b2(10, 10, 10, 10, 10, 10);
+		Ultima::Ultima8::Box b1(32, 32, 0, 32, 32, 8);
+		Ultima::Ultima8::Box b2(32, 32, 8, 32, 32, 8);
 		si1.setBoxBounds(b1, 0, 0);
 		si2.setBoxBounds(b2, 0, 0);
 
@@ -136,8 +136,8 @@ class U8SortItemTestSuite : public CxxTest::TestSuite {
 		Ultima::Ultima8::SortItem si1;
 		Ultima::Ultima8::SortItem si2;
 
-		Ultima::Ultima8::Box b1(0, 0, 0, 10, 10, 0);
-		Ultima::Ultima8::Box b2(0, 0, 0, 10, 10, 0);
+		Ultima::Ultima8::Box b1(0, 0, 0, 32, 32, 0);
+		Ultima::Ultima8::Box b2(0, 0, 0, 32, 32, 0);
 		si1.setBoxBounds(b1, 0, 0);
 		si2.setBoxBounds(b2, 0, 0);
 


Commit: b34e683d388bd8d7dae90aa7069bed93276dfb6a
    https://github.com/scummvm/scummvm/commit/b34e683d388bd8d7dae90aa7069bed93276dfb6a
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-09-30T13:45:21-05:00

Commit Message:
ULTIMA8: Cleanup checks for X & Y flat sort items

Changed paths:
    engines/ultima/ultima8/world/sort_item.cpp


diff --git a/engines/ultima/ultima8/world/sort_item.cpp b/engines/ultima/ultima8/world/sort_item.cpp
index ce659f73233..6d4f823be0d 100644
--- a/engines/ultima/ultima8/world/sort_item.cpp
+++ b/engines/ultima/ultima8/world/sort_item.cpp
@@ -71,12 +71,12 @@ bool SortItem::below(const SortItem &si2) const {
 	if (si1._flat && si2._flat) {
 		if (si1._z != si2._z)
 			return si1._z < si2._z;
-	} else {
-		// Check against z top with a tolerance based on footpad calculations
+	} else if (si1._invitem == si2._invitem) {
+		// Check with a tolerance based on footpad calculations
 		// Lower item cannot be inventory
-		if (si1._zTop - 8 < si2._z && !si1._invitem)
+		if (si1._zTop - 8 < si2._z)
 			return true;
-		if (si1._z > si2._zTop - 8 && !si2._invitem)
+		if (si1._z > si2._zTop - 8)
 			return false;
 	}
 
@@ -146,37 +146,31 @@ bool SortItem::below(const SortItem &si2) const {
 	}
 
 	// Y-flat vs non-flat handling
-	if (yFlat1 != yFlat2 && si1._fixed == si2._fixed) {
-		if (yFlat1) {
-			if (si2._y - 32 > si2._yFar) {
-			int32 yCenter2 = (si2._yFar + si2._y) / 2;
-			return si1._y <= yCenter2;
-			}
-			return false;
-		} else {
-			if (si1._y - 32 > si1._yFar) {
-			int32 yCenter1 = (si1._yFar + si1._y) / 2;
-			return yCenter1 < si2._y;
-		}
+	if (yFlat1 != yFlat2) {
+		// Check with a precision loss based on footpad calculations
+		if (si1._y / 32 <= si2._yFar / 32)
 			return true;
-		}
+		if (si1._yFar / 32 >= si2._y / 32)
+			return false;
+
+		int32 yCenter1 = (si1._yFar / 32 + si1._y / 32) / 2;
+		int32 yCenter2 = (si2._yFar / 32 + si2._y / 32) / 2;
+		if (yCenter1 != yCenter2)
+			return yCenter1 < yCenter2;
 	}
 
 	// X-flat vs non-flat handling
-	if (xFlat1 != xFlat2 && si1._fixed == si2._fixed) {
-		if (xFlat1) {
-			if (si2._x - 32 > si2._xLeft) {
-			int32 xCenter2 = (si2._xLeft + si2._x) / 2;
-			return si1._x <= xCenter2;
-			}
-			return false;
-		} else {
-			if (si1._x - 32 > si1._xLeft) {
-			int32 xCenter1 = (si1._xLeft + si1._x) / 2;
-			return xCenter1 < si2._x;
-		}
+	if (xFlat1 != xFlat2) {
+		// Check with a precision loss based on footpad calculations
+		if (si1._x / 32 <= si2._xLeft / 32)
 			return true;
-		}
+		if (si1._xLeft / 32 >= si2._x / 32)
+			return false;
+
+		int32 xCenter1 = (si1._xLeft / 32 + si1._x / 32) / 2;
+		int32 xCenter2 = (si2._xLeft / 32 + si2._x / 32) / 2;
+		if (xCenter1 != xCenter2)
+			return xCenter1 < xCenter2;
 	}
 
 	// Check z-bottom with a tolerance




More information about the Scummvm-git-logs mailing list