[Scummvm-git-logs] scummvm master -> 8b9cb4e63c91d9fdaeb641c23549640c353fb19b

OMGPizzaGuy noreply at scummvm.org
Sat Oct 21 19:35:24 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:
8b9cb4e63c ULTIMA8: Add Box::isBelow for position checking


Commit: 8b9cb4e63c91d9fdaeb641c23549640c353fb19b
    https://github.com/scummvm/scummvm/commit/8b9cb4e63c91d9fdaeb641c23549640c353fb19b
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-10-21T14:35:03-05:00

Commit Message:
ULTIMA8: Add Box::isBelow for position checking

Changed paths:
    engines/ultima/ultima8/misc/box.h
    engines/ultima/ultima8/world/current_map.cpp


diff --git a/engines/ultima/ultima8/misc/box.h b/engines/ultima/ultima8/misc/box.h
index fe0667197f4..d73ad0d44f1 100644
--- a/engines/ultima/ultima8/misc/box.h
+++ b/engines/ultima/ultima8/misc/box.h
@@ -52,9 +52,17 @@ struct Box {
 	}
 
 	// Check to see if a point is within the Box
-	bool contains(int px, int py, int pz) const {
-		return (px > (_x - _xd) && py > (_y - _yd) && pz >= _z &&
-		        px <= _x && py <= _y && pz < (_z + _zd));
+	bool contains(int32 px, int32 py, int32 pz) const {
+		return px > _x - _xd && px <= _x &&
+			   py > _y - _yd && py <= _y &&
+			   pz >= _z && pz < _z + _zd;
+	}
+
+	// Check to see if the box is below a point
+	bool isBelow(int32 px, int32 py, int32 pz) const {
+		return px > _x - _xd && px <= _x &&
+			   py > _y - _yd && py <= _y &&
+			   pz >= _z + _zd;
 	}
 
 	// Move the Box (Relative)
diff --git a/engines/ultima/ultima8/world/current_map.cpp b/engines/ultima/ultima8/world/current_map.cpp
index 85c8c8a5fd1..d683e92bfe5 100644
--- a/engines/ultima/ultima8/world/current_map.cpp
+++ b/engines/ultima/ultima8/world/current_map.cpp
@@ -776,10 +776,10 @@ PositionInfo CurrentMap::getPositionInfo(const Box &target, const Box &start, ui
 					}
 				}
 
-				// check xy center
-				if (midx >= ib._x - ib._xd && midx <= ib._x && midy >= ib._y - ib._yd && midy <= ib._y) {
+				// check bottom center
+				if (ib.isBelow(midx, midy, target._z)) {
 					// check land
-					if (si->_flags & landmask && ib._z + ib._zd > landz && ib._z + ib._zd <= target._z) {
+					if (si->_flags & landmask && ib._z + ib._zd > landz) {
 						info.land = item;
 						landz = ib._z + ib._zd;
 					}




More information about the Scummvm-git-logs mailing list