1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-29 09:44:52 +01:00

Use CoordsXY on footpath_bridge_get_info_from_pos()

This commit is contained in:
Tulio Leao
2020-01-12 22:27:30 -03:00
parent 201d13577e
commit 89edde6a3c
4 changed files with 21 additions and 35 deletions

View File

@@ -788,15 +788,15 @@ static void window_footpath_set_provisional_path_at_point(ScreenCoordsXY screenC
*/
static void window_footpath_set_selection_start_bridge_at_point(ScreenCoordsXY screenCoords)
{
int32_t x, y, direction;
int32_t direction;
TileElement* tileElement;
map_invalidate_selection_rect();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
footpath_bridge_get_info_from_pos(screenCoords, &x, &y, &direction, &tileElement);
if (x == LOCATION_NULL)
auto mapCoords = footpath_bridge_get_info_from_pos(screenCoords, &direction, &tileElement);
if (mapCoords.isNull())
{
return;
}
@@ -804,10 +804,8 @@ static void window_footpath_set_selection_start_bridge_at_point(ScreenCoordsXY s
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectType = MAP_SELECT_TYPE_FULL;
gMapSelectPositionA.x = x;
gMapSelectPositionB.x = x;
gMapSelectPositionA.y = y;
gMapSelectPositionB.y = y;
gMapSelectPositionA = mapCoords;
gMapSelectPositionB = mapCoords;
int32_t z = tileElement->GetBaseZ();
@@ -822,7 +820,7 @@ static void window_footpath_set_selection_start_bridge_at_point(ScreenCoordsXY s
z += PATH_HEIGHT_STEP; // Add another 2 for a steep slope
}
gMapSelectArrowPosition = CoordsXYZ{ x, y, z };
gMapSelectArrowPosition = CoordsXYZ{ mapCoords, z };
gMapSelectArrowDirection = direction;
map_invalidate_selection_rect();
@@ -903,11 +901,11 @@ static void window_footpath_place_path_at_point(ScreenCoordsXY screenCoords)
*/
static void window_footpath_start_bridge_at_point(ScreenCoordsXY screenCoords)
{
int32_t x, y, z, direction;
int32_t z, direction;
TileElement* tileElement;
footpath_bridge_get_info_from_pos(screenCoords, &x, &y, &direction, &tileElement);
if (x == LOCATION_NULL)
auto mapCoords = footpath_bridge_get_info_from_pos(screenCoords, &direction, &tileElement);
if (mapCoords.isNull())
{
return;
}
@@ -945,9 +943,7 @@ static void window_footpath_start_bridge_at_point(ScreenCoordsXY screenCoords)
}
tool_cancel();
gFootpathConstructFromPosition.x = x;
gFootpathConstructFromPosition.y = y;
gFootpathConstructFromPosition.z = z;
gFootpathConstructFromPosition = { mapCoords, z };
gFootpathConstructDirection = direction;
gFootpathProvisionalFlags = 0;
_window_footpath_provisional_path_arrow_timer = 0;

View File

@@ -1269,14 +1269,14 @@ static void window_map_place_park_entrance_tool_update(ScreenCoordsXY screenCoor
*/
static void window_map_set_peep_spawn_tool_update(ScreenCoordsXY screenCoords)
{
int32_t mapX, mapY, mapZ, direction;
int32_t mapZ, direction;
TileElement* tileElement;
map_invalidate_selection_rect();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
footpath_bridge_get_info_from_pos(screenCoords, &mapX, &mapY, &direction, &tileElement);
if ((mapX & 0xFFFF) == 0x8000)
auto mapCoords = footpath_bridge_get_info_from_pos(screenCoords, &direction, &tileElement);
if (mapCoords.isNull())
return;
mapZ = tileElement->GetBaseZ();
@@ -1291,11 +1291,9 @@ static void window_map_set_peep_spawn_tool_update(ScreenCoordsXY screenCoords)
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW;
gMapSelectType = MAP_SELECT_TYPE_FULL;
gMapSelectPositionA.x = mapX;
gMapSelectPositionA.y = mapY;
gMapSelectPositionB.x = mapX;
gMapSelectPositionB.y = mapY;
gMapSelectArrowPosition = CoordsXYZ{ mapX, mapY, mapZ };
gMapSelectPositionA = mapCoords;
gMapSelectPositionB = mapCoords;
gMapSelectArrowPosition = CoordsXYZ{ mapCoords, mapZ };
gMapSelectArrowDirection = direction_reverse(direction);
map_invalidate_selection_rect();
}

View File

@@ -339,8 +339,7 @@ CoordsXY footpath_get_coordinates_from_pos(ScreenCoordsXY screenCoords, int32_t*
* direction: cl
* tileElement: edx
*/
void footpath_bridge_get_info_from_pos(
ScreenCoordsXY screenCoords, int32_t* x, int32_t* y, int32_t* direction, TileElement** tileElement)
CoordsXY footpath_bridge_get_info_from_pos(ScreenCoordsXY screenCoords, int32_t* direction, TileElement** tileElement)
{
// First check if we point at an entrance or exit. In that case, we would want the path coming from the entrance/exit.
int32_t interactionType;
@@ -349,8 +348,6 @@ void footpath_bridge_get_info_from_pos(
CoordsXY map_pos = {};
get_map_coordinates_from_pos(
screenCoords, VIEWPORT_INTERACTION_MASK_RIDE, map_pos, &interactionType, tileElement, &viewport);
*x = map_pos.x;
*y = map_pos.y;
if (interactionType == VIEWPORT_INTERACTION_ITEM_RIDE
&& viewport->flags & (VIEWPORT_FLAG_UNDERGROUND_INSIDE | VIEWPORT_FLAG_HIDE_BASE | VIEWPORT_FLAG_HIDE_VERTICAL)
@@ -364,15 +361,13 @@ void footpath_bridge_get_info_from_pos(
bx &= 3;
if (direction != nullptr)
*direction = bx;
return;
return map_pos;
}
}
get_map_coordinates_from_pos(
screenCoords, VIEWPORT_INTERACTION_MASK_RIDE & VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_TERRAIN,
map_pos, &interactionType, tileElement, &viewport);
*x = map_pos.x;
*y = map_pos.y;
if (interactionType == VIEWPORT_INTERACTION_ITEM_RIDE && (*tileElement)->GetType() == TILE_ELEMENT_TYPE_ENTRANCE)
{
int32_t directions = entrance_get_directions(*tileElement);
@@ -381,14 +376,12 @@ void footpath_bridge_get_info_from_pos(
int32_t bx = (*tileElement)->GetDirectionWithOffset(bitscanforward(directions));
if (direction != nullptr)
*direction = bx;
return;
return map_pos;
}
}
// We point at something else
auto coords = footpath_get_coordinates_from_pos(screenCoords, direction, tileElement);
*x = coords.x;
*y = coords.y;
return footpath_get_coordinates_from_pos(screenCoords, direction, tileElement);
}
/**

View File

@@ -184,8 +184,7 @@ money32 footpath_provisional_set(int32_t type, CoordsXYZ footpathLoc, int32_t sl
void footpath_provisional_remove();
void footpath_provisional_update();
CoordsXY footpath_get_coordinates_from_pos(ScreenCoordsXY screenCoords, int32_t* direction, TileElement** tileElement);
void footpath_bridge_get_info_from_pos(
ScreenCoordsXY screenCoords, int32_t* x, int32_t* y, int32_t* direction, TileElement** tileElement);
CoordsXY footpath_bridge_get_info_from_pos(ScreenCoordsXY screenCoords, int32_t* direction, TileElement** tileElement);
void footpath_remove_litter(const CoordsXYZ& footpathPos);
void footpath_connect_edges(const CoordsXY& footpathPos, TileElement* tileElement, int32_t flags);
void footpath_update_queue_chains();