mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #9546 from aaruel/vector-locations
Refactor #9110: Use a vector for station locations list in sub_6CB945
This commit is contained in:
commit
b32f799e21
|
@ -7114,49 +7114,46 @@ void sub_6CB945(Ride* ride)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needs room for an entrance and an exit per station, plus one position for the list terminator.
|
std::vector<TileCoordsXYZD> locations;
|
||||||
TileCoordsXYZD locations[(MAX_STATIONS * 2) + 1];
|
|
||||||
TileCoordsXYZD* locationList = locations;
|
|
||||||
for (uint8_t stationId = 0; stationId < MAX_STATIONS; ++stationId)
|
for (uint8_t stationId = 0; stationId < MAX_STATIONS; ++stationId)
|
||||||
{
|
{
|
||||||
auto entrance = ride_get_entrance_location(ride, stationId);
|
auto entrance = ride_get_entrance_location(ride, stationId);
|
||||||
if (!entrance.isNull())
|
if (!entrance.isNull())
|
||||||
{
|
{
|
||||||
*locationList++ = entrance;
|
locations.push_back(entrance);
|
||||||
ride_clear_entrance_location(ride, stationId);
|
ride_clear_entrance_location(ride, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto exit = ride_get_exit_location(ride, stationId);
|
auto exit = ride_get_exit_location(ride, stationId);
|
||||||
if (!exit.isNull())
|
if (!exit.isNull())
|
||||||
{
|
{
|
||||||
*locationList++ = exit;
|
locations.push_back(exit);
|
||||||
ride_clear_exit_location(ride, stationId);
|
ride_clear_exit_location(ride, stationId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(*locationList++).x = COORDS_NULL;
|
|
||||||
|
|
||||||
locationList = locations;
|
auto locationListIter = locations.cbegin();
|
||||||
for (; !(*locationList).isNull(); locationList++)
|
for (const TileCoordsXYZD& locationCoords : locations)
|
||||||
{
|
{
|
||||||
TileCoordsXYZD* locationList2 = locationList;
|
auto locationList = ++locationListIter;
|
||||||
locationList2++;
|
|
||||||
|
|
||||||
bool duplicateLocation = false;
|
bool duplicateLocation = false;
|
||||||
do
|
while (locationList != locations.cend())
|
||||||
{
|
{
|
||||||
if ((*locationList).x == (*locationList2).x && (*locationList).y == (*locationList2).y)
|
const TileCoordsXYZD& locationCoords2 = *locationList++;
|
||||||
|
if (locationCoords.x == locationCoords2.x && locationCoords.y == locationCoords2.y)
|
||||||
{
|
{
|
||||||
duplicateLocation = true;
|
duplicateLocation = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (!(*locationList2++).isNull());
|
}
|
||||||
|
|
||||||
if (duplicateLocation)
|
if (duplicateLocation)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoordsXY location = { (*locationList).x * 32, (*locationList).y * 32 };
|
CoordsXY location = { locationCoords.x * 32, locationCoords.y * 32 };
|
||||||
|
|
||||||
TileElement* tileElement = map_get_first_element_at(location.x >> 5, location.y >> 5);
|
TileElement* tileElement = map_get_first_element_at(location.x >> 5, location.y >> 5);
|
||||||
do
|
do
|
||||||
|
|
Loading…
Reference in New Issue