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

Function ShiftMap

src/openrct2/world/Map.cpp:2192–2367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2190 }
2191
2192 void ShiftMap(const TileCoordsXY& amount)
2193 {
2194 if (amount.x == 0 && amount.y == 0)
2195 return;
2196
2197 auto amountToMove = amount.ToCoordsXY();
2198 auto& gameState = getGameState();
2199
2200 // Tile elements
2201 auto newElements = std::vector<TileElement>();
2202 for (int32_t y = 0; y < kMaximumMapSizeTechnical; y++)
2203 {
2204 for (int32_t x = 0; x < kMaximumMapSizeTechnical; x++)
2205 {
2206 auto srcX = x - amount.x;
2207 auto srcY = y - amount.y;
2208 if (x > 0 && y > 0 && x < gameState.mapSize.x - 1 && y < gameState.mapSize.y - 1 && srcX > 0 && srcY > 0
2209 && srcX < gameState.mapSize.x - 1 && srcY < gameState.mapSize.y - 1)
2210 {
2211 auto srcTile = _tileIndex.GetFirstElementAt(TileCoordsXY(srcX, srcY));
2212 do
2213 {
2214 newElements.push_back(*srcTile);
2215 } while (!(srcTile++)->isLastForTile());
2216 }
2217 else if (x == 0 || y == 0 || x == gameState.mapSize.x - 1 || y == gameState.mapSize.y - 1)
2218 {
2219 auto surface = GetDefaultSurfaceElement();
2220 surface.setBaseZ(kMinimumLandZ);
2221 surface.setClearanceZ(kMinimumLandZ);
2222 surface.asSurface()->SetSlope(0);
2223 surface.asSurface()->SetWaterHeight(0);
2224 newElements.push_back(surface);
2225 }
2226 else
2227 {
2228 newElements.push_back(GetDefaultSurfaceElement());
2229 }
2230 }
2231 }
2232
2233 SetTileElements(gameState, std::move(newElements));
2234 MapRemoveOutOfRangeElements();
2235
2236 MapExtendBoundarySurfaceShiftX(amount.x, gameState.mapSize.y);
2237 MapExtendBoundarySurfaceShiftY(amount.y, gameState.mapSize.x);
2238
2239 for (auto& spawn : gameState.peepSpawns)
2240 shiftIfNotNull(spawn, amountToMove);
2241
2242 for (auto& entrance : gameState.park.entrances)
2243 shiftIfNotNull(entrance, amountToMove);
2244
2245 // Entities
2246 auto& entityTweener = EntityTweener::Get();
2247 for (auto i = 0; i < EnumValue(EntityType::count); i++)
2248 {
2249 auto entityType = static_cast<EntityType>(i);

Callers 1

ExecuteMethod · 0.85

Calls 15

GetDefaultSurfaceElementFunction · 0.85
SetTileElementsFunction · 0.85
shiftIfNotNullFunction · 0.85
EnumValueFunction · 0.85
RideManagerClass · 0.85
GetNumBannersFunction · 0.85
GetBannerFunction · 0.85
ToCoordsXYMethod · 0.80

Tested by

no test coverage detected