From 6e077c42eadd2931705b2a4aef764720a05ff240 Mon Sep 17 00:00:00 2001 From: 0ro8lu <43352234+0ro8lu@users.noreply.github.com> Date: Mon, 20 Jul 2020 21:55:50 +0200 Subject: [PATCH] Close #12270: Remove goto track_remove_station_element (#12323) Refactored the goto statement --- src/openrct2/ride/Track.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/openrct2/ride/Track.cpp b/src/openrct2/ride/Track.cpp index 777277f1ed..e53d06dd63 100644 --- a/src/openrct2/ride/Track.cpp +++ b/src/openrct2/ride/Track.cpp @@ -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,27 +923,19 @@ 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) + if (x - CoordsDirectionDelta[direction].x == removeX && y - CoordsDirectionDelta[direction].y == removeY) { - goto loc_6C4BF5; + targetTrackType = TRACK_ELEM_BEGIN_STATION; } else { - if (x - CoordsDirectionDelta[direction].x == removeX - && y - CoordsDirectionDelta[direction].y == removeY) + if (x == stationX0 && y == stationY0) { targetTrackType = TRACK_ELEM_BEGIN_STATION; } else { - if (x == stationX0 && y == stationY0) - { - targetTrackType = TRACK_ELEM_BEGIN_STATION; - } - else - { - targetTrackType = TRACK_ELEM_MIDDLE_STATION; - } + targetTrackType = TRACK_ELEM_MIDDLE_STATION; } } }