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

OMGPizzaGuy noreply at scummvm.org
Sat Oct 21 17:25:00 UTC 2023


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

Summary:
9e45e7b31f ULTIMA8: Add overlapsXY to box similar to item class.
02c5a49090 ULTIMA8: Fix logical OR usage in ChunkOnScreen
f74b687969 ULTIMA8: Remove unneeded version of surface search


Commit: 9e45e7b31ff7fc139250f0b5c823c4f8db80b754
    https://github.com/scummvm/scummvm/commit/9e45e7b31ff7fc139250f0b5c823c4f8db80b754
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-10-21T12:24:25-05:00

Commit Message:
ULTIMA8: Add overlapsXY to box similar to item class.

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 fe4fb4ed8ce..fe0667197f4 100644
--- a/engines/ultima/ultima8/misc/box.h
+++ b/engines/ultima/ultima8/misc/box.h
@@ -88,6 +88,14 @@ struct Box {
 		return true;
 	}
 
+	bool overlapsXY(const Box& o) const {
+		if (_x <= o._x - o._xd || o._x <= _x - _xd)
+			return false;
+		if (_y <= o._y - o._yd || o._y <= _y - _yd)
+			return false;
+		return true;
+	}
+
 	void extend(const Box &o) {
 		int32 x2 = MIN(_x - _xd, o._x - o._xd);
 		int32 y2 = MIN(_y - _yd, o._y - o._yd);
diff --git a/engines/ultima/ultima8/world/current_map.cpp b/engines/ultima/ultima8/world/current_map.cpp
index 80013ad2717..7120a67cc30 100644
--- a/engines/ultima/ultima8/world/current_map.cpp
+++ b/engines/ultima/ultima8/world/current_map.cpp
@@ -600,9 +600,7 @@ void CurrentMap::areaSearch(UCList *itemlist, const uint8 *loopscript,
 
 				// check if item is in range
 				const Box ib = item->getWorldBox();
-				if (searchrange._x > ib._x - ib._xd && searchrange._x - searchrange._xd < ib._x &&
-					searchrange._y > ib._y - ib._yd && searchrange._y - searchrange._yd < ib._y) {
-
+				if (searchrange.overlapsXY(ib)) {
 					// check item against loopscript
 					if (item->checkLoopScript(loopscript, scriptsize)) {
 						assert(itemlist->getElementSize() == 2);
@@ -660,9 +658,7 @@ void CurrentMap::surfaceSearch(UCList *itemlist, const uint8 *loopscript,
 
 				// check if item is in range?
 				const Box ib = item->getWorldBox();
-				if (searchrange._x > ib._x - ib._xd && searchrange._x - searchrange._xd < ib._x &&
-					searchrange._y > ib._y - ib._yd && searchrange._y - searchrange._yd < ib._y) {
-
+				if (searchrange.overlapsXY(ib)) {
 					bool ok = false;
 
 					if (above && ib._z == (searchrange._z + searchrange._zd)) {
@@ -775,9 +771,7 @@ PositionInfo CurrentMap::getPositionInfo(const Box &target, const Box &start, ui
 					}
 				}
 
-				// check xy overlap
-				if (target._x > ib._x - ib._xd && target._x - target._xd < ib._x &&
-					target._y > ib._y - ib._yd && target._y - target._yd < ib._y) {
+				if (target.overlapsXY(ib)) {
 					// check support
 					if (si->_flags & supportmask && ib._z + ib._zd > supportz && ib._z + ib._zd <= target._z) {
 						supportz = ib._z + ib._zd;


Commit: 02c5a49090ac16af3c3cbfec0d2f70c3c1b4d500
    https://github.com/scummvm/scummvm/commit/02c5a49090ac16af3c3cbfec0d2f70c3c1b4d500
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-10-21T12:24:25-05:00

Commit Message:
ULTIMA8: Fix logical OR usage in ChunkOnScreen

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


diff --git a/engines/ultima/ultima8/world/current_map.cpp b/engines/ultima/ultima8/world/current_map.cpp
index 7120a67cc30..6adf3192e68 100644
--- a/engines/ultima/ultima8/world/current_map.cpp
+++ b/engines/ultima/ultima8/world/current_map.cpp
@@ -435,7 +435,7 @@ static inline bool ChunkOnScreen(int32 cx, int32 cy, int32 sleft, int32 stop, in
 	const bool top_clear = cytop >= sbot;
 	const bool bot_clear = cybot <= stop;
 
-	const bool clear = right_clear | left_clear | top_clear | bot_clear;
+	const bool clear = right_clear || left_clear || top_clear || bot_clear;
 
 	return !clear;
 }


Commit: f74b6879693d9090e987da6d4264925b22285704
    https://github.com/scummvm/scummvm/commit/f74b6879693d9090e987da6d4264925b22285704
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-10-21T12:24:25-05:00

Commit Message:
ULTIMA8: Remove unneeded version of surface search

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


diff --git a/engines/ultima/ultima8/world/current_map.cpp b/engines/ultima/ultima8/world/current_map.cpp
index 6adf3192e68..85c8c8a5fd1 100644
--- a/engines/ultima/ultima8/world/current_map.cpp
+++ b/engines/ultima/ultima8/world/current_map.cpp
@@ -623,24 +623,16 @@ void CurrentMap::areaSearch(UCList *itemlist, const uint8 *loopscript,
 void CurrentMap::surfaceSearch(UCList *itemlist, const uint8 *loopscript,
 							   uint32 scriptsize, const Item *check,
 							   bool above, bool below, bool recurse) const {
-	int32 origin[3];
-	int32 dims[3];
-	check->getLocationAbsolute(origin[0], origin[1], origin[2]);
-	check->getFootpadWorld(dims[0], dims[1], dims[2]);
-	surfaceSearch(itemlist, loopscript, scriptsize, check->getObjId(),
-	              origin, dims, above, below, recurse);
-}
-
-void CurrentMap::surfaceSearch(UCList *itemlist, const uint8 *loopscript,
-							   uint32 scriptsize, ObjId check,
-							   int32 origin[3], int32 dims[3],
-							   bool above, bool below, bool recurse) const {
-	const Box searchrange(origin[0], origin[1], origin[2], dims[0], dims[1], dims[2]);
+	int32 x, y, z;
+	int32 xd, yd, zd;
+	check->getLocationAbsolute(x, y, z);
+	check->getFootpadWorld(xd, yd, zd);
+	const Box searchrange(x, y, z, xd, yd, zd);
 
-	int minx = ((origin[0] - dims[0]) / _mapChunkSize) - 1;
-	int maxx = ((origin[0]) / _mapChunkSize) + 1;
-	int miny = ((origin[1] - dims[1]) / _mapChunkSize) - 1;
-	int maxy = ((origin[1]) / _mapChunkSize) + 1;
+	int minx = ((x - xd) / _mapChunkSize) - 1;
+	int maxx = (x / _mapChunkSize) + 1;
+	int miny = ((y - yd) / _mapChunkSize) - 1;
+	int maxy = (y / _mapChunkSize) + 1;
 	clipMapChunks(minx, maxx, miny, maxy);
 
 	for (int cy = miny; cy <= maxy; cy++) {
@@ -651,7 +643,7 @@ void CurrentMap::surfaceSearch(UCList *itemlist, const uint8 *loopscript,
 
 				const Item *item = *iter;
 
-				if (item->getObjId() == check)
+				if (item->getObjId() == check->getObjId())
 					continue;
 				if (item->hasExtFlags(Item::EXT_SPRITE))
 					continue;
diff --git a/engines/ultima/ultima8/world/current_map.h b/engines/ultima/ultima8/world/current_map.h
index b0e5bea0baa..c9196731aa7 100644
--- a/engines/ultima/ultima8/world/current_map.h
+++ b/engines/ultima/ultima8/world/current_map.h
@@ -101,12 +101,6 @@ public:
 	                   uint32 scriptsize, const Item *item, bool above,
 					   bool below, bool recurse = false) const;
 
-	// Surface search: Search above and below an item.
-	void surfaceSearch(UCList *itemlist, const uint8 *loopscript,
-	                   uint32 scriptsize, ObjId id,
-	                   int32 origin[3], int32 dims[2],
-	                   bool above, bool below, bool recurse = false) const;
-
 	// Collision detection. Returns position information with valid being true
 	// when the target box does not collide with any solid items.
 	// Ignores collisions when overlapping with the start box.




More information about the Scummvm-git-logs mailing list