mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 15:52:55 +01:00
Use CoordsXY for footpath_get_coordinates_from_pos()
This commit is contained in:
@@ -1230,16 +1230,13 @@ void window_guest_overview_tool_update(rct_window* w, rct_widgetindex widgetInde
|
||||
|
||||
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
|
||||
|
||||
int32_t map_x, map_y;
|
||||
footpath_get_coordinates_from_pos({ screenCoords.x, screenCoords.y + 16 }, &map_x, &map_y, nullptr, nullptr);
|
||||
if (map_x != LOCATION_NULL)
|
||||
auto mapCoords = footpath_get_coordinates_from_pos({ screenCoords.x, screenCoords.y + 16 }, nullptr, nullptr);
|
||||
if (!mapCoords.isNull())
|
||||
{
|
||||
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
|
||||
gMapSelectType = MAP_SELECT_TYPE_FULL;
|
||||
gMapSelectPositionA.x = map_x;
|
||||
gMapSelectPositionB.x = map_x;
|
||||
gMapSelectPositionA.y = map_y;
|
||||
gMapSelectPositionB.y = map_y;
|
||||
gMapSelectPositionA = mapCoords;
|
||||
gMapSelectPositionB = mapCoords;
|
||||
map_invalidate_selection_rect();
|
||||
}
|
||||
|
||||
@@ -1281,15 +1278,14 @@ void window_guest_overview_tool_down(rct_window* w, rct_widgetindex widgetIndex,
|
||||
if (widgetIndex != WIDX_PICKUP)
|
||||
return;
|
||||
|
||||
int32_t dest_x, dest_y;
|
||||
TileElement* tileElement;
|
||||
footpath_get_coordinates_from_pos({ screenCoords.x, screenCoords.y + 16 }, &dest_x, &dest_y, nullptr, &tileElement);
|
||||
auto destCoords = footpath_get_coordinates_from_pos({ screenCoords.x, screenCoords.y + 16 }, nullptr, &tileElement);
|
||||
|
||||
if (dest_x == LOCATION_NULL)
|
||||
if (destCoords.isNull())
|
||||
return;
|
||||
|
||||
PeepPickupAction pickupAction{
|
||||
PeepPickupType::Place, w->number, { dest_x, dest_y, tileElement->base_height }, network_get_current_player_id()
|
||||
PeepPickupType::Place, w->number, { destCoords, tileElement->base_height }, network_get_current_player_id()
|
||||
};
|
||||
pickupAction.SetCallback([](const GameAction* ga, const GameActionResult* result) {
|
||||
if (result->Error != GA_ERROR::OK)
|
||||
|
||||
@@ -1327,16 +1327,16 @@ static void window_map_place_park_entrance_tool_down(ScreenCoordsXY screenCoords
|
||||
static void window_map_set_peep_spawn_tool_down(ScreenCoordsXY screenCoords)
|
||||
{
|
||||
TileElement* tileElement;
|
||||
int32_t mapX, mapY, mapZ, direction;
|
||||
int32_t mapZ, direction;
|
||||
|
||||
// Verify footpath exists at location, and retrieve coordinates
|
||||
footpath_get_coordinates_from_pos(screenCoords, &mapX, &mapY, &direction, &tileElement);
|
||||
if (mapX == LOCATION_NULL)
|
||||
auto mapCoords = footpath_get_coordinates_from_pos(screenCoords, &direction, &tileElement);
|
||||
if (mapCoords.isNull())
|
||||
return;
|
||||
|
||||
mapZ = tileElement->GetBaseZ();
|
||||
|
||||
auto gameAction = PlacePeepSpawnAction({ mapX, mapY, mapZ, static_cast<Direction>(direction) });
|
||||
auto gameAction = PlacePeepSpawnAction({ mapCoords, mapZ, static_cast<Direction>(direction) });
|
||||
auto result = GameActions::Execute(&gameAction);
|
||||
if (result->Error == GA_ERROR::OK)
|
||||
{
|
||||
|
||||
@@ -1146,16 +1146,13 @@ void window_staff_overview_tool_update(rct_window* w, rct_widgetindex widgetInde
|
||||
|
||||
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
|
||||
|
||||
int32_t map_x, map_y;
|
||||
footpath_get_coordinates_from_pos({ screenCoords.x, screenCoords.y + 16 }, &map_x, &map_y, nullptr, nullptr);
|
||||
if (map_x != LOCATION_NULL)
|
||||
auto mapCoords = footpath_get_coordinates_from_pos({ screenCoords.x, screenCoords.y + 16 }, nullptr, nullptr);
|
||||
if (!mapCoords.isNull())
|
||||
{
|
||||
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
|
||||
gMapSelectType = MAP_SELECT_TYPE_FULL;
|
||||
gMapSelectPositionA.x = map_x;
|
||||
gMapSelectPositionB.x = map_x;
|
||||
gMapSelectPositionA.y = map_y;
|
||||
gMapSelectPositionB.y = map_y;
|
||||
gMapSelectPositionA = mapCoords;
|
||||
gMapSelectPositionB = mapCoords;
|
||||
map_invalidate_selection_rect();
|
||||
}
|
||||
|
||||
@@ -1196,15 +1193,14 @@ void window_staff_overview_tool_down(rct_window* w, rct_widgetindex widgetIndex,
|
||||
{
|
||||
if (widgetIndex == WIDX_PICKUP)
|
||||
{
|
||||
int32_t dest_x, dest_y;
|
||||
TileElement* tileElement;
|
||||
footpath_get_coordinates_from_pos({ screenCoords.x, screenCoords.y + 16 }, &dest_x, &dest_y, nullptr, &tileElement);
|
||||
auto destCoords = footpath_get_coordinates_from_pos({ screenCoords.x, screenCoords.y + 16 }, nullptr, &tileElement);
|
||||
|
||||
if (dest_x == LOCATION_NULL)
|
||||
if (destCoords.isNull())
|
||||
return;
|
||||
|
||||
PeepPickupAction pickupAction{
|
||||
PeepPickupType::Place, w->number, { dest_x, dest_y, tileElement->base_height }, network_get_current_player_id()
|
||||
PeepPickupType::Place, w->number, { destCoords, tileElement->base_height }, network_get_current_player_id()
|
||||
};
|
||||
pickupAction.SetCallback([](const GameAction* ga, const GameActionResult* result) {
|
||||
if (result->Error != GA_ERROR::OK)
|
||||
@@ -1216,10 +1212,9 @@ void window_staff_overview_tool_down(rct_window* w, rct_widgetindex widgetIndex,
|
||||
}
|
||||
else if (widgetIndex == WIDX_PATROL)
|
||||
{
|
||||
int32_t dest_x, dest_y;
|
||||
footpath_get_coordinates_from_pos(screenCoords, &dest_x, &dest_y, nullptr, nullptr);
|
||||
auto destCoords = footpath_get_coordinates_from_pos(screenCoords, nullptr, nullptr);
|
||||
|
||||
if (dest_x == LOCATION_NULL)
|
||||
if (destCoords.isNull())
|
||||
return;
|
||||
|
||||
rct_sprite* sprite = try_get_sprite(w->number);
|
||||
@@ -1231,7 +1226,7 @@ void window_staff_overview_tool_down(rct_window* w, rct_widgetindex widgetIndex,
|
||||
return;
|
||||
|
||||
auto staff = peep.AsStaff();
|
||||
if (staff->IsPatrolAreaSet({ dest_x, dest_y }))
|
||||
if (staff->IsPatrolAreaSet(destCoords))
|
||||
{
|
||||
_staffPatrolAreaPaintValue = PatrolAreaValue::UNSET;
|
||||
}
|
||||
@@ -1239,7 +1234,7 @@ void window_staff_overview_tool_down(rct_window* w, rct_widgetindex widgetIndex,
|
||||
{
|
||||
_staffPatrolAreaPaintValue = PatrolAreaValue::SET;
|
||||
}
|
||||
auto staffSetPatrolAreaAction = StaffSetPatrolAreaAction(w->number, { dest_x, dest_y });
|
||||
auto staffSetPatrolAreaAction = StaffSetPatrolAreaAction(w->number, destCoords);
|
||||
GameActions::Execute(&staffSetPatrolAreaAction);
|
||||
}
|
||||
}
|
||||
@@ -1258,10 +1253,9 @@ void window_staff_overview_tool_drag(rct_window* w, rct_widgetindex widgetIndex,
|
||||
if (_staffPatrolAreaPaintValue == PatrolAreaValue::NONE)
|
||||
return; // Do nothing if we do not have a paintvalue(this should never happen)
|
||||
|
||||
int32_t dest_x, dest_y;
|
||||
footpath_get_coordinates_from_pos(screenCoords, &dest_x, &dest_y, nullptr, nullptr);
|
||||
auto destCoords = footpath_get_coordinates_from_pos(screenCoords, nullptr, nullptr);
|
||||
|
||||
if (dest_x == LOCATION_NULL)
|
||||
if (destCoords.isNull())
|
||||
return;
|
||||
|
||||
rct_sprite* sprite = try_get_sprite(w->number);
|
||||
@@ -1272,13 +1266,13 @@ void window_staff_overview_tool_drag(rct_window* w, rct_widgetindex widgetIndex,
|
||||
if (peep.type != PEEP_TYPE_STAFF)
|
||||
return;
|
||||
|
||||
bool patrolAreaValue = peep.AsStaff()->IsPatrolAreaSet({ dest_x, dest_y });
|
||||
bool patrolAreaValue = peep.AsStaff()->IsPatrolAreaSet(destCoords);
|
||||
if (_staffPatrolAreaPaintValue == PatrolAreaValue::SET && patrolAreaValue)
|
||||
return; // Since area is already the value we want, skip...
|
||||
if (_staffPatrolAreaPaintValue == PatrolAreaValue::UNSET && !patrolAreaValue)
|
||||
return; // Since area is already the value we want, skip...
|
||||
|
||||
auto staffSetPatrolAreaAction = StaffSetPatrolAreaAction(w->number, { dest_x, dest_y });
|
||||
auto staffSetPatrolAreaAction = StaffSetPatrolAreaAction(w->number, destCoords);
|
||||
GameActions::Execute(&staffSetPatrolAreaAction);
|
||||
}
|
||||
|
||||
|
||||
@@ -342,8 +342,7 @@ static void window_staff_list_tooldown(rct_window* w, rct_widgetindex widgetInde
|
||||
|
||||
int32_t direction;
|
||||
TileElement* tileElement;
|
||||
CoordsXY footpathCoords;
|
||||
footpath_get_coordinates_from_pos(screenCoords, &footpathCoords.x, &footpathCoords.y, &direction, &tileElement);
|
||||
auto footpathCoords = footpath_get_coordinates_from_pos(screenCoords, &direction, &tileElement);
|
||||
if (footpathCoords.isNull())
|
||||
return;
|
||||
|
||||
|
||||
@@ -244,8 +244,7 @@ void footpath_provisional_update()
|
||||
* direction: ecx
|
||||
* tileElement: edx
|
||||
*/
|
||||
void footpath_get_coordinates_from_pos(
|
||||
ScreenCoordsXY screenCoords, int32_t* x, int32_t* y, int32_t* direction, TileElement** tileElement)
|
||||
CoordsXY footpath_get_coordinates_from_pos(ScreenCoordsXY screenCoords, int32_t* direction, TileElement** tileElement)
|
||||
{
|
||||
int32_t z = 0, interactionType;
|
||||
TileElement* myTileElement;
|
||||
@@ -262,9 +261,8 @@ void footpath_get_coordinates_from_pos(
|
||||
&myTileElement, &viewport);
|
||||
if (interactionType == VIEWPORT_INTERACTION_ITEM_NONE)
|
||||
{
|
||||
if (x != nullptr)
|
||||
*x = LOCATION_NULL;
|
||||
return;
|
||||
position.setNull();
|
||||
return position;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,14 +321,12 @@ void footpath_get_coordinates_from_pos(
|
||||
|
||||
position = position.ToTileStart();
|
||||
|
||||
if (x != nullptr)
|
||||
*x = position.x;
|
||||
if (y != nullptr)
|
||||
*y = position.y;
|
||||
if (direction != nullptr)
|
||||
*direction = myDirection;
|
||||
if (tileElement != nullptr)
|
||||
*tileElement = myTileElement;
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -390,7 +386,9 @@ void footpath_bridge_get_info_from_pos(
|
||||
}
|
||||
|
||||
// We point at something else
|
||||
footpath_get_coordinates_from_pos(screenCoords, x, y, direction, tileElement);
|
||||
auto coords = footpath_get_coordinates_from_pos(screenCoords, direction, tileElement);
|
||||
*x = coords.x;
|
||||
*y = coords.y;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -183,8 +183,7 @@ money32 footpath_remove(CoordsXYZ footpathLoc, int32_t flags);
|
||||
money32 footpath_provisional_set(int32_t type, CoordsXYZ footpathLoc, int32_t slope);
|
||||
void footpath_provisional_remove();
|
||||
void footpath_provisional_update();
|
||||
void footpath_get_coordinates_from_pos(
|
||||
ScreenCoordsXY screenCoords, int32_t* x, int32_t* y, int32_t* direction, TileElement** tileElement);
|
||||
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);
|
||||
void footpath_remove_litter(const CoordsXYZ& footpathPos);
|
||||
|
||||
Reference in New Issue
Block a user