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

Function MapRemoveOutOfRangeElements

src/openrct2/world/Map.cpp:1239–1272  ·  view source on GitHub ↗

* Removes elements that are out of the map size range and crops the park perimeter. * rct2: 0x0068ADBC */

Source from the content-addressed store, hash-verified

1237 * rct2: 0x0068ADBC
1238 */
1239 void MapRemoveOutOfRangeElements()
1240 {
1241 auto mapSizeMax = GetMapSizeMaxXY();
1242
1243 // Ensure that we can remove elements
1244 //
1245 // NOTE: This is only a workaround for non-networked games.
1246 // Map resize has to become its own Game Action to properly solve this issue.
1247 //
1248 auto& gameState = getGameState();
1249 bool buildState = gameState.cheats.buildInPauseMode;
1250 gameState.cheats.buildInPauseMode = true;
1251
1252 for (int32_t y = kMaximumMapSizeBig - kCoordsXYStep; y >= 0; y -= kCoordsXYStep)
1253 {
1254 for (int32_t x = kMaximumMapSizeBig - kCoordsXYStep; x >= 0; x -= kCoordsXYStep)
1255 {
1256 if (x == 0 || y == 0 || x >= mapSizeMax.x || y >= mapSizeMax.y)
1257 {
1258 // Note this purposely does not use LandSetRightsAction as X Y coordinates are outside of normal range.
1259 auto surfaceElement = MapGetSurfaceElementAt(CoordsXY{ x, y });
1260 if (surfaceElement != nullptr)
1261 {
1262 surfaceElement->SetOwnership(OWNERSHIP_UNOWNED);
1263 Park::UpdateFencesAroundTile({ x, y });
1264 }
1265 ClearElementsAt({ x, y });
1266 }
1267 }
1268 }
1269
1270 // Reset cheat state
1271 gameState.cheats.buildInPauseMode = buildState;
1272 }
1273
1274 static void MapExtendBoundarySurfaceExtendTile(
1275 const SurfaceElement& sourceTile, SurfaceElement& destTile, const Direction direction)

Callers 3

ExecuteMethod · 0.85
MapInitFunction · 0.85
ShiftMapFunction · 0.85

Calls 5

GetMapSizeMaxXYFunction · 0.85
MapGetSurfaceElementAtFunction · 0.85
UpdateFencesAroundTileFunction · 0.85
ClearElementsAtFunction · 0.85
SetOwnershipMethod · 0.80

Tested by

no test coverage detected