Close #12252: remove of goto in function wall_remove_at (#12279)

* Removed use of goto in function wall_remove_at
* Implemented overload of function map_get_wall_element_at
This commit is contained in:
Helio Nunes Santos 2020-07-16 13:52:45 -07:00 committed by GitHub
parent 79ae0786c0
commit 2812be8c9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 19 deletions

View File

@ -2396,6 +2396,25 @@ TileElement* map_get_track_element_at_with_direction_from_ride(const CoordsXYZD&
return nullptr;
};
WallElement* map_get_wall_element_at(const CoordsXYRangedZ& coords)
{
auto tileElement = map_get_first_element_at(coords);
if (tileElement != nullptr)
{
do
{
if (tileElement->GetType() == TILE_ELEMENT_TYPE_WALL && coords.baseZ < tileElement->GetClearanceZ()
&& coords.clearanceZ > tileElement->GetBaseZ())
{
return tileElement->AsWall();
}
} while (!(tileElement++)->IsLastForTile());
}
return nullptr;
}
WallElement* map_get_wall_element_at(const CoordsXYZD& wallCoords)
{
auto tileWallCoords = TileCoordsXYZ(wallCoords);

View File

@ -157,6 +157,7 @@ BannerElement* map_get_banner_element_at(const CoordsXYZ& bannerPos, uint8_t dir
SurfaceElement* map_get_surface_element_at(const CoordsXY& coords);
PathElement* map_get_path_element_at(const TileCoordsXYZ& loc);
WallElement* map_get_wall_element_at(const CoordsXYZD& wallCoords);
WallElement* map_get_wall_element_at(const CoordsXYRangedZ& coords);
SmallSceneryElement* map_get_small_scenery_element_at(const CoordsXYZ& sceneryCoords, int32_t type, uint8_t quadrant);
EntranceElement* map_get_park_entrance_element_at(const CoordsXYZ& entranceCoords, bool ghost);
EntranceElement* map_get_ride_entrance_element_at(const CoordsXYZ& entranceCoords, bool ghost);

View File

@ -35,26 +35,13 @@
*/
void wall_remove_at(const CoordsXYRangedZ& wallPos)
{
TileElement* tileElement;
repeat:
tileElement = map_get_first_element_at(wallPos);
if (tileElement == nullptr)
return;
do
for (auto wallElement = map_get_wall_element_at(wallPos); wallElement != nullptr;
wallElement = map_get_wall_element_at(wallPos))
{
if (tileElement->GetType() != TILE_ELEMENT_TYPE_WALL)
continue;
if (wallPos.baseZ >= tileElement->GetClearanceZ())
continue;
if (wallPos.clearanceZ <= tileElement->GetBaseZ())
continue;
tile_element_remove_banner_entry(tileElement);
map_invalidate_tile_zoom1({ wallPos, tileElement->GetBaseZ(), tileElement->GetBaseZ() + 72 });
tile_element_remove(tileElement);
goto repeat;
} while (!(tileElement++)->IsLastForTile());
tile_element_remove_banner_entry(reinterpret_cast<TileElement*>(wallElement));
map_invalidate_tile_zoom1({ wallPos, wallElement->GetBaseZ(), wallElement->GetBaseZ() + 72 });
tile_element_remove(reinterpret_cast<TileElement*>(wallElement));
}
}
/**