Use CoordsXY on footpath_remove_edges_at()

This commit is contained in:
Tulio Leao 2020-01-04 08:33:19 -03:00
parent 2b1101d320
commit 7cf03d3e41
10 changed files with 22 additions and 14 deletions

View File

@ -182,7 +182,7 @@ private:
if (!(GetFlags() & GAME_COMMAND_FLAG_PATH_SCENERY))
{
footpath_remove_edges_at(_loc.x, _loc.y, (TileElement*)pathElement);
footpath_remove_edges_at(_loc, reinterpret_cast<TileElement*>(pathElement));
}
pathElement->SetPathEntryIndex(_type);
@ -358,7 +358,7 @@ private:
if (!(GetFlags() & GAME_COMMAND_FLAG_PATH_SCENERY))
{
footpath_remove_edges_at(_loc.x, _loc.y, tileElement);
footpath_remove_edges_at(_loc, tileElement);
}
if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !(GetFlags() & GAME_COMMAND_FLAG_GHOST))
{

View File

@ -91,7 +91,7 @@ public:
{
res->Cost += bannerRes->Cost;
}
footpath_remove_edges_at(_loc.x, _loc.y, footpathElement);
footpath_remove_edges_at(_loc, footpathElement);
map_invalidate_tile_full(_loc);
tile_element_remove(footpathElement);
footpath_update_queue_chains();

View File

@ -172,7 +172,7 @@ public:
footpath_queue_chain_reset();
maze_entrance_hedge_replacement(_loc.x, _loc.y, tileElement);
footpath_remove_edges_at(_loc.x, _loc.y, tileElement);
footpath_remove_edges_at(_loc, tileElement);
tile_element_remove(tileElement);

View File

@ -434,7 +434,7 @@ public:
footpath_queue_chain_reset();
if (!gCheatsDisableClearanceChecks || !(tileElement->IsGhost()))
{
footpath_remove_edges_at(mapLoc.x, mapLoc.y, tileElement);
footpath_remove_edges_at(mapLoc, tileElement);
}
tile_element_remove(tileElement);
sub_6CB945(ride);

View File

@ -7089,7 +7089,7 @@ void sub_6CB945(Ride* ride)
{
footpath_queue_chain_reset();
maze_entrance_hedge_replacement(location.x, location.y, tileElement);
footpath_remove_edges_at(location.x, location.y, tileElement);
footpath_remove_edges_at(location, tileElement);
footpath_update_queue_chains();
map_invalidate_tile_full(location);
tile_element_remove(tileElement);

View File

@ -1192,7 +1192,7 @@ static bool TrackDesignPlaceSceneryElement(
}
footpath_queue_chain_reset();
footpath_remove_edges_at(mapCoord.x, mapCoord.y, reinterpret_cast<TileElement*>(pathElement));
footpath_remove_edges_at(mapCoord, reinterpret_cast<TileElement*>(pathElement));
flags = GAME_COMMAND_FLAG_APPLY;
if (_trackDesignPlaceOperation == PTD_OPERATION_PLACE_TRACK_PREVIEW)

View File

@ -2130,7 +2130,7 @@ static void footpath_fix_corners_around(int32_t x, int32_t y, TileElement* pathE
* @param x x-coordinate in units (not tiles)
* @param y y-coordinate in units (not tiles)
*/
void footpath_remove_edges_at(int32_t x, int32_t y, TileElement* tileElement)
void footpath_remove_edges_at(const CoordsXY& footpathPos, TileElement* tileElement)
{
if (tileElement->GetType() == TILE_ELEMENT_TYPE_TRACK)
{
@ -2140,7 +2140,7 @@ void footpath_remove_edges_at(int32_t x, int32_t y, TileElement* tileElement)
return;
}
footpath_update_queue_entrance_banner({ x, y }, tileElement);
footpath_update_queue_entrance_banner(footpathPos, tileElement);
bool fixCorners = false;
for (uint8_t direction = 0; direction < 4; direction++)
@ -2163,12 +2163,13 @@ void footpath_remove_edges_at(int32_t x, int32_t y, TileElement* tileElement)
// When clearance checks were disabled a neighbouring path can be connected to both the path-ghost and to something
// else, so before removing edges from neighbouring paths we have to make sure there is nothing else they are connected
// to.
if (!tile_element_wants_path_connection_towards({ x / 32, y / 32, z1, direction }, tileElement))
if (!tile_element_wants_path_connection_towards({ TileCoordsXY{ footpathPos }, z1, direction }, tileElement))
{
bool isQueue = tileElement->GetType() == TILE_ELEMENT_TYPE_PATH ? tileElement->AsPath()->IsQueue() : false;
int32_t z0 = z1 - 2;
footpath_remove_edges_towards(
x + CoordsDirectionDelta[direction].x, y + CoordsDirectionDelta[direction].y, z0, z1, direction, isQueue);
footpathPos.x + CoordsDirectionDelta[direction].x, footpathPos.y + CoordsDirectionDelta[direction].y, z0, z1,
direction, isQueue);
}
else
{
@ -2180,7 +2181,8 @@ void footpath_remove_edges_at(int32_t x, int32_t y, TileElement* tileElement)
// Only fix corners when needed, to avoid changing corners that have been set for its looks.
if (fixCorners && tileElement->IsGhost())
{
footpath_fix_corners_around(x / 32, y / 32, tileElement);
auto tileFootpathPos = TileCoordsXY{ footpathPos };
footpath_fix_corners_around(tileFootpathPos.x, tileFootpathPos.y, tileElement);
}
if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH)

View File

@ -197,7 +197,7 @@ void footpath_update_path_wide_flags(int32_t x, int32_t y);
bool footpath_is_blocked_by_vehicle(const TileCoordsXYZ& position);
int32_t footpath_is_connected_to_map_edge(int32_t x, int32_t y, int32_t z, int32_t direction, int32_t flags);
void footpath_remove_edges_at(int32_t x, int32_t y, TileElement* tileElement);
void footpath_remove_edges_at(const CoordsXY& footpathPos, TileElement* tileElement);
int32_t entrance_get_directions(const TileElement* tileElement);
PathSurfaceEntry* get_path_surface_entry(int32_t entryIndex);

View File

@ -475,6 +475,12 @@ struct TileCoordsXYZD : public TileCoordsXYZ
{
}
TileCoordsXYZD(TileCoordsXY t_, int32_t z_, Direction d_)
: TileCoordsXYZ(t_, z_)
, direction(d_)
{
}
TileCoordsXYZD(CoordsXY c_, int32_t z_, Direction d_)
: TileCoordsXYZ(c_, z_)
, direction(d_)

View File

@ -964,7 +964,7 @@ void map_remove_all_rides()
[[fallthrough]];
case TILE_ELEMENT_TYPE_TRACK:
footpath_queue_chain_reset();
footpath_remove_edges_at(it.x * 32, it.y * 32, it.element);
footpath_remove_edges_at(TileCoordsXY{ it.x, it.y }.ToCoordsXY(), it.element);
tile_element_remove(it.element);
tile_element_iterator_restart_for_tile(&it);
break;