MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / FootpathIsConnectedToMapEdgeHelper

Function FootpathIsConnectedToMapEdgeHelper

src/openrct2/world/Footpath.cpp:1087–1283  ·  view source on GitHub ↗

* * rct2: 0x0069AC1A * @param flags (1 << 0): Ignore queues * (1 << 5): Unown * (1 << 7): Ignore no entry signs */

Source from the content-addressed store, hash-verified

1085 * (1 << 7): Ignore no entry signs
1086 */
1087 static int32_t FootpathIsConnectedToMapEdgeHelper(CoordsXYZ footpathPos, int32_t direction, int32_t flags)
1088 {
1089 int32_t returnVal = FOOTPATH_SEARCH_INCOMPLETE;
1090
1091 struct TileState
1092 {
1093 bool processed = false;
1094 CoordsXYZ footpathPos;
1095 int32_t direction;
1096 int32_t level;
1097 int32_t distanceFromJunction;
1098 int32_t junctionTolerance;
1099 };
1100
1101 // Vector of all of the child tile elements for us to explore
1102 std::vector<TileState> tiles;
1103 TileElement* tileElement = nullptr;
1104 int numPendingTiles = 0;
1105
1106 TileState currentTile = { false, footpathPos, direction, 0, 0, 16 };
1107
1108 // Captures the current state of the variables and stores them in tiles vector for iteration later
1109 auto CaptureCurrentTileState = [&tiles, &numPendingTiles](TileState t_currentTile) -> void {
1110 // Search for an entry of this tile in our list already
1111 for (const TileState& tile : tiles)
1112 {
1113 if (tile.footpathPos == t_currentTile.footpathPos && tile.direction == t_currentTile.direction)
1114 return;
1115 }
1116
1117 // If we get here we did not find it, so insert the tile into our list
1118 tiles.push_back(t_currentTile);
1119 ++numPendingTiles;
1120 };
1121
1122 // Loads the next tile to visit into our variables
1123 auto LoadNextTileElement = [&tiles, &numPendingTiles](TileState& t_currentTile) -> void {
1124 // Do not continue if there are no tiles in the list
1125 if (tiles.empty())
1126 return;
1127
1128 // Find the next unprocessed tile
1129 for (size_t tileIndex = tiles.size() - 1; tileIndex > 0; --tileIndex)
1130 {
1131 if (tiles[tileIndex].processed)
1132 continue;
1133 --numPendingTiles;
1134 t_currentTile = tiles[tileIndex];
1135 tiles[tileIndex].processed = true;
1136 return;
1137 }
1138 // Default to tile 0
1139 --numPendingTiles;
1140 t_currentTile = tiles[0];
1141 tiles[0].processed = true;
1142 };
1143
1144 // Encapsulate the tile skipping logic to make do-while more readable

Callers 1

Calls 15

DirectionReverseFunction · 0.85
MapIsEdgeFunction · 0.85
MapGetFirstElementAtFunction · 0.85
FootpathFixOwnershipFunction · 0.85
GetNextDirectionFunction · 0.85
push_backMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
getTypeMethod · 0.45
IsSlopedMethod · 0.45
asPathMethod · 0.45
GetSlopeDirectionMethod · 0.45

Tested by

no test coverage detected