From a524b2d5ba2d1009a9d24df88d7354357c452169 Mon Sep 17 00:00:00 2001 From: Helio Santos Date: Thu, 9 Jul 2020 08:02:45 -0700 Subject: [PATCH] Part of #12165: Use CoordsXYZ on vehicle_check_collision Updated vehicle_check_collision function prototype to use CoordsXYZ. Updated caller(s) accordingly. --- src/openrct2/ride/Vehicle.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 9eea88950a..9c6d9005f6 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -5130,34 +5130,34 @@ void Vehicle::UpdateDoingCircusShow() * rct2: 0x0068B8BD * @returns the map element that the vehicle will collide with or NULL if no collisions. */ -static TileElement* vehicle_check_collision(int16_t x, int16_t y, int16_t z) +static TileElement* vehicle_check_collision(const CoordsXYZ& vehiclePosition) { - TileElement* tileElement = map_get_first_element_at({ x, y }); + TileElement* tileElement = map_get_first_element_at(vehiclePosition); if (tileElement == nullptr) { return nullptr; } uint8_t quadrant; - if ((x & 0x1F) >= 16) + if ((vehiclePosition.x & 0x1F) >= 16) { quadrant = 1; - if ((y & 0x1F) < 16) + if ((vehiclePosition.y & 0x1F) < 16) quadrant = 2; } else { quadrant = 4; - if ((y & 0x1F) >= 16) + if ((vehiclePosition.y & 0x1F) >= 16) quadrant = 8; } do { - if (z < tileElement->GetBaseZ()) + if (vehiclePosition.z < tileElement->GetBaseZ()) continue; - if (z >= tileElement->GetClearanceZ()) + if (vehiclePosition.z >= tileElement->GetClearanceZ()) continue; if (tileElement->GetOccupiedQuadrants() & quadrant) @@ -5398,7 +5398,7 @@ void Vehicle::UpdateCrash() continue; } - TileElement* collideElement = vehicle_check_collision(curVehicle->x, curVehicle->y, curVehicle->z); + TileElement* collideElement = vehicle_check_collision({ curVehicle->x, curVehicle->y, curVehicle->z }); if (collideElement == nullptr) { curVehicle->sub_state = 1;