From 8b17453170f424def0f8cc2bdb2dd12c5d978df0 Mon Sep 17 00:00:00 2001 From: lahm86 <33758420+lahm86@users.noreply.github.com> Date: Sat, 11 Jan 2025 18:41:05 +0000 Subject: [PATCH] tr2/los: fix smashable bounds testing The original approach relied on the layout of BOUNDS_16 to check smashables, so this updates the checks to use exactly the properties we need. --- src/tr2/game/los.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/tr2/game/los.c b/src/tr2/game/los.c index efaddd37f..e231cfdf1 100644 --- a/src/tr2/game/los.c +++ b/src/tr2/game/los.c @@ -310,23 +310,27 @@ int32_t LOS_CheckSmashable( const DIRECTION direction = Math_GetDirection(item->rot.y); const BOUNDS_16 *const bounds = Item_GetBoundsAccurate(item); - const int16_t *x_extent; - const int16_t *z_extent = NULL; + int16_t x_extent[2]; + int16_t z_extent[2]; switch (direction) { case DIR_EAST: case DIR_WEST: - x_extent = &bounds->min.z; - z_extent = &bounds->min.x; + x_extent[0] = bounds->min.z; + x_extent[1] = bounds->max.z; + z_extent[0] = bounds->min.x; + z_extent[1] = bounds->max.x; break; case DIR_NORTH: case DIR_SOUTH: - x_extent = &bounds->min.x; - z_extent = &bounds->min.z; + x_extent[0] = bounds->min.x; + x_extent[1] = bounds->max.x; + z_extent[0] = bounds->min.z; + z_extent[1] = bounds->max.z; break; default: + ASSERT_FAIL(); break; } - ASSERT(z_extent != NULL); int32_t failure = 0; if (ABS(dz) > ABS(dx)) {