1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 20:43:04 +01:00

Refactor station locations array to vector

This commit is contained in:
aaruel
2019-07-09 03:04:56 -04:00
parent b7b846c0d5
commit 899b5c136a

View File

@@ -7114,42 +7114,38 @@ void sub_6CB945(Ride* ride)
}
}
// Needs room for an entrance and an exit per station, plus one position for the list terminator.
TileCoordsXYZD locations[(MAX_STATIONS * 2) + 1];
TileCoordsXYZD* locationList = locations;
std::vector<TileCoordsXYZD> locations;
for (uint8_t stationId = 0; stationId < MAX_STATIONS; ++stationId)
{
auto entrance = ride_get_entrance_location(ride, stationId);
if (!entrance.isNull())
{
*locationList++ = entrance;
locations.push_back(entrance);
ride_clear_entrance_location(ride, stationId);
}
auto exit = ride_get_exit_location(ride, stationId);
if (!exit.isNull())
{
*locationList++ = exit;
locations.push_back(exit);
ride_clear_exit_location(ride, stationId);
}
}
(*locationList++).x = COORDS_NULL;
locationList = locations;
for (; !(*locationList).isNull(); locationList++)
for (auto locationList = locations.cbegin(); locationList != locations.cend(); locationList++)
{
TileCoordsXYZD* locationList2 = locationList;
auto locationList2 = locationList;
locationList2++;
bool duplicateLocation = false;
do
for (; locationList2 != locations.cend(); locationList2++)
{
if ((*locationList).x == (*locationList2).x && (*locationList).y == (*locationList2).y)
{
duplicateLocation = true;
break;
}
} while (!(*locationList2++).isNull());
}
if (duplicateLocation)
{