Close #12270: Remove goto track_remove_station_element (#12323)

Refactored the goto statement
This commit is contained in:
0ro8lu 2020-07-20 21:55:50 +02:00 committed by GitHub
parent 0a5b75e882
commit 6e077c42ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 14 deletions

View File

@ -900,9 +900,9 @@ bool track_remove_station_element(int32_t x, int32_t y, int32_t z, Direction dir
if (stationElement != nullptr)
{
int32_t targetTrackType;
if (x == stationX1 && y == stationY1)
if ((x == stationX1 && y == stationY1)
|| (x + CoordsDirectionDelta[direction].x == removeX && y + CoordsDirectionDelta[direction].y == removeY))
{
loc_6C4BF5:;
auto stationIndex = ride_get_first_empty_station_start(ride);
if (stationIndex == STATION_INDEX_NULL)
{
@ -923,14 +923,7 @@ bool track_remove_station_element(int32_t x, int32_t y, int32_t z, Direction dir
}
else
{
if (x + CoordsDirectionDelta[direction].x == removeX && y + CoordsDirectionDelta[direction].y == removeY)
{
goto loc_6C4BF5;
}
else
{
if (x - CoordsDirectionDelta[direction].x == removeX
&& y - CoordsDirectionDelta[direction].y == removeY)
if (x - CoordsDirectionDelta[direction].x == removeX && y - CoordsDirectionDelta[direction].y == removeY)
{
targetTrackType = TRACK_ELEM_BEGIN_STATION;
}
@ -946,7 +939,6 @@ bool track_remove_station_element(int32_t x, int32_t y, int32_t z, Direction dir
}
}
}
}
stationElement->AsTrack()->SetTrackType(targetTrackType);
map_invalidate_element({ x, y }, stationElement);