From abc67f09e68b4cf85602a6dccd9abf56132b6947 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 21 May 2023 01:23:58 +0100 Subject: [PATCH 01/15] Add ability to shift map --- distribution/openrct2.d.ts | 2 + src/openrct2/actions/MapChangeSizeAction.cpp | 12 ++ src/openrct2/actions/MapChangeSizeAction.h | 2 + src/openrct2/world/Map.cpp | 143 +++++++++++++++++++ src/openrct2/world/Map.h | 1 + 5 files changed, 160 insertions(+) diff --git a/distribution/openrct2.d.ts b/distribution/openrct2.d.ts index b764a2faf8..fbf1071cd9 100644 --- a/distribution/openrct2.d.ts +++ b/distribution/openrct2.d.ts @@ -939,6 +939,8 @@ declare global { interface MapChangeSizeArgs extends GameActionArgs { targetSizeX: number; targetSizeY: number; + shiftX: number; + shiftY: number; } interface MazePlaceTrackArgs extends GameActionArgs { diff --git a/src/openrct2/actions/MapChangeSizeAction.cpp b/src/openrct2/actions/MapChangeSizeAction.cpp index 04e28ac200..18f4d86c2c 100644 --- a/src/openrct2/actions/MapChangeSizeAction.cpp +++ b/src/openrct2/actions/MapChangeSizeAction.cpp @@ -18,7 +18,13 @@ #include "../world/Park.h" MapChangeSizeAction::MapChangeSizeAction(const TileCoordsXY& targetSize) + : MapChangeSizeAction(targetSize, TileCoordsXY()) +{ +} + +MapChangeSizeAction::MapChangeSizeAction(const TileCoordsXY& targetSize, const TileCoordsXY& shift) : _targetSize(targetSize) + , _shift(shift) { } @@ -31,6 +37,7 @@ void MapChangeSizeAction::Serialise(DataSerialiser& stream) { GameAction::Serialise(stream); stream << DS_TAG(_targetSize); + stream << DS_TAG(_shift); } GameActions::Result MapChangeSizeAction::Query() const @@ -63,6 +70,9 @@ GameActions::Result MapChangeSizeAction::Execute() const MapExtendBoundarySurfaceY(); } + // Shift the map (allows increasing the map at the 0,0 position + ShiftMap(_shift); + // Shrink map if (_targetSize.x < gameState.MapSize.x || _targetSize.y < gameState.MapSize.y) { @@ -84,4 +94,6 @@ void MapChangeSizeAction::AcceptParameters(GameActionParameterVisitor& visitor) { visitor.Visit("targetSizeX", _targetSize.x); visitor.Visit("targetSizeY", _targetSize.y); + visitor.Visit("shiftX", _shift.x); + visitor.Visit("shiftY", _shift.y); } diff --git a/src/openrct2/actions/MapChangeSizeAction.h b/src/openrct2/actions/MapChangeSizeAction.h index 81e8db3e64..e46bae208a 100644 --- a/src/openrct2/actions/MapChangeSizeAction.h +++ b/src/openrct2/actions/MapChangeSizeAction.h @@ -17,6 +17,7 @@ class MapChangeSizeAction final : public GameActionBase(); + for (int32_t y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++) + { + for (int32_t x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++) + { + auto srcX = x - amount.x; + auto srcY = y - amount.y; + if (x >= 0 && y >= 0 && x < gMapSize.x && y < gMapSize.y && srcX >= 0 && srcY >= 0 && srcX < gMapSize.x + && srcY < gMapSize.y) + { + auto srcTile = _tileIndex.GetFirstElementAt(TileCoordsXY(srcX, srcY)); + do + { + newElements.push_back(*srcTile); + } while (!(srcTile++)->IsLastForTile()); + } + else if (x == 0 || y == 0 || x == gMapSize.x - 1 || y == gMapSize.y - 1) + { + auto surface = GetDefaultSurfaceElement(); + surface.SetBaseZ(MINIMUM_LAND_HEIGHT_BIG); + surface.SetClearanceZ(MINIMUM_LAND_HEIGHT_BIG); + surface.AsSurface()->SetSlope(0); + surface.AsSurface()->SetWaterHeight(0); + newElements.push_back(surface); + } + else + { + newElements.push_back(GetDefaultSurfaceElement()); + } + } + } + SetTileElements(std::move(newElements)); + MapRemoveOutOfRangeElements(); + + for (auto& spawn : gPeepSpawns) + spawn += amountToMove; + + for (auto& entrance : gParkEntrances) + entrance += amountToMove; + + // Entities + for (auto i = 0; i < EnumValue(EntityType::Count); i++) + { + auto entityType = static_cast(i); + auto& list = GetEntityList(entityType); + for (const auto& entityId : list) + { + auto entity = GetEntity(entityId); + auto location = entity->GetLocation(); + location += amountToMove; + entity->MoveTo(location); + + switch (entityType) + { + case EntityType::Guest: + case EntityType::Staff: + { + auto peep = entity->As(); + peep->NextLoc += amountToMove; + peep->DestinationX += amountToMove.x; + peep->DestinationY += amountToMove.y; + peep->PathfindGoal += amount; + for (auto& h : peep->PathfindHistory) + h += amount; + break; + } + case EntityType::Vehicle: + { + auto vehicle = entity->As(); + vehicle->TrackLocation += amountToMove; + vehicle->BoatLocation += amountToMove; + break; + } + case EntityType::Duck: + { + auto duck = entity->As(); + duck->target_x += amountToMove.x; + duck->target_y += amountToMove.y; + break; + } + } + if (entityType == EntityType::Staff) + { + auto staff = entity->As(); + auto patrol = staff->PatrolInfo; + if (patrol != nullptr) + { + auto positions = patrol->ToVector(); + for (auto& p : positions) + p += amount; + patrol->Clear(); + patrol->Union(positions); + } + } + } + } + + // Rides + for (auto& ride : GetRideManager()) + { + auto& stations = ride.GetStations(); + for (auto& station : stations) + { + station.Start += amountToMove; + station.Entrance += amount; + station.Exit += amount; + } + + ride.overall_view += amountToMove; + ride.boat_hire_return_position += amount; + ride.CurTestTrackLocation += amount; + ride.ChairliftBullwheelLocation[0] += amount; + ride.ChairliftBullwheelLocation[1] += amount; + ride.CableLiftLoc += amountToMove; + } + + // Banners + auto numBanners = GetNumBanners(); + auto id = BannerIndex::FromUnderlying(0); + size_t count = 0; + while (count < numBanners) + { + auto* banner = GetBanner(id); + if (banner != nullptr) + { + banner->position += amount; + count++; + } + } +} diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index ab9ac02c85..f1bc156f22 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -246,3 +246,4 @@ void FixLandOwnershipTiles(std::initializer_list tiles); void FixLandOwnershipTilesWithOwnership( std::initializer_list tiles, uint8_t ownership, bool doNotDowngrade = false); MapRange ClampRangeWithinMap(const MapRange& range); +void ShiftMap(const TileCoordsXY& amount); From 776fa71a4fcb33765dccbf4007911a064b33c851 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 21 May 2023 15:11:16 +0100 Subject: [PATCH 02/15] Use edge as template for new tiles --- src/openrct2/world/Map.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 3a7ca50e23..c47852e1b4 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -2251,8 +2251,8 @@ void ShiftMap(const TileCoordsXY& amount) { auto srcX = x - amount.x; auto srcY = y - amount.y; - if (x >= 0 && y >= 0 && x < gMapSize.x && y < gMapSize.y && srcX >= 0 && srcY >= 0 && srcX < gMapSize.x - && srcY < gMapSize.y) + if (x > 0 && y > 0 && x < gMapSize.x - 1 && y < gMapSize.y - 1 && srcX > 0 && srcY > 0 && srcX < gMapSize.x - 1 + && srcY < gMapSize.y - 1) { auto srcTile = _tileIndex.GetFirstElementAt(TileCoordsXY(srcX, srcY)); do @@ -2271,7 +2271,21 @@ void ShiftMap(const TileCoordsXY& amount) } else { - newElements.push_back(GetDefaultSurfaceElement()); + auto copyX = std::clamp(srcX, 1, gMapSize.x - 2); + auto copyY = std::clamp(srcY, 1, gMapSize.y - 2); + auto srcTile = MapGetSurfaceElementAt(TileCoordsXY(copyX, copyY)); + if (srcTile != nullptr) + { + auto tileEl = *srcTile; + tileEl.SetOwner(OWNERSHIP_UNOWNED); + tileEl.SetParkFences(0); + tileEl.SetLastForTile(true); + newElements.push_back(*reinterpret_cast(&tileEl)); + } + else + { + newElements.push_back(GetDefaultSurfaceElement()); + } } } } @@ -2324,6 +2338,8 @@ void ShiftMap(const TileCoordsXY& amount) duck->target_y += amountToMove.y; break; } + default: + break; } if (entityType == EntityType::Staff) { From 774a8a382f9a420e114a5becce7389b6573978a2 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 21 May 2023 15:20:37 +0100 Subject: [PATCH 03/15] Increment network version --- distribution/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index d7b8eaf4b0..75b5205ef6 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -42,6 +42,7 @@ 0.4.10 (2024-04-02) ------------------------------------------------------------------------ - Feature: [#18171] Add port of the RCT1 Stand-Up Roller Coaster. +- Feature: [#20263] Ability to increase the size of the map in the (0, 0) direction. - Feature: [#21590] [Plugin] Plugins can now read and write banner properties of tile elements. - Feature: [#21636] Add shortcut key for sorting tile elements. - Feature: [objects#294] Add scenery versions of wooden truss supports. From 13c4ee52133f573e1fefb5f436b0fd25f57d49e2 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 21 May 2023 15:34:38 +0100 Subject: [PATCH 04/15] Do not tween entities when shifting them --- src/openrct2/world/Map.cpp | 51 +++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index c47852e1b4..4c49d53743 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -22,6 +22,7 @@ #include "../audio/audio.h" #include "../core/Guard.hpp" #include "../entity/Duck.h" +#include "../entity/EntityTweener.h" #include "../entity/PatrolArea.h" #include "../entity/Staff.h" #include "../interface/Cursors.h" @@ -2306,6 +2307,10 @@ void ShiftMap(const TileCoordsXY& amount) for (const auto& entityId : list) { auto entity = GetEntity(entityId); + + // Do not tween the entity + EntityTweener::Get().RemoveEntity(entity); + auto location = entity->GetLocation(); location += amountToMove; entity->MoveTo(location); @@ -2316,26 +2321,35 @@ void ShiftMap(const TileCoordsXY& amount) case EntityType::Staff: { auto peep = entity->As(); - peep->NextLoc += amountToMove; - peep->DestinationX += amountToMove.x; - peep->DestinationY += amountToMove.y; - peep->PathfindGoal += amount; - for (auto& h : peep->PathfindHistory) - h += amount; + if (peep != nullptr) + { + peep->NextLoc += amountToMove; + peep->DestinationX += amountToMove.x; + peep->DestinationY += amountToMove.y; + peep->PathfindGoal += amount; + for (auto& h : peep->PathfindHistory) + h += amount; + } break; } case EntityType::Vehicle: { auto vehicle = entity->As(); - vehicle->TrackLocation += amountToMove; - vehicle->BoatLocation += amountToMove; + if (vehicle != nullptr) + { + vehicle->TrackLocation += amountToMove; + vehicle->BoatLocation += amountToMove; + } break; } case EntityType::Duck: { auto duck = entity->As(); - duck->target_x += amountToMove.x; - duck->target_y += amountToMove.y; + if (duck != nullptr) + { + duck->target_x += amountToMove.x; + duck->target_y += amountToMove.y; + } break; } default: @@ -2344,14 +2358,17 @@ void ShiftMap(const TileCoordsXY& amount) if (entityType == EntityType::Staff) { auto staff = entity->As(); - auto patrol = staff->PatrolInfo; - if (patrol != nullptr) + if (staff != nullptr) { - auto positions = patrol->ToVector(); - for (auto& p : positions) - p += amount; - patrol->Clear(); - patrol->Union(positions); + auto patrol = staff->PatrolInfo; + if (patrol != nullptr) + { + auto positions = patrol->ToVector(); + for (auto& p : positions) + p += amount; + patrol->Clear(); + patrol->Union(positions); + } } } } From 641d8f70aa4ba5c520d39efedd427e7628c1174a Mon Sep 17 00:00:00 2001 From: Ted John Date: Mon, 22 May 2023 18:45:28 +0100 Subject: [PATCH 05/15] Get the entity tweener outside the loop --- src/openrct2/world/Map.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 4c49d53743..8ba8450048 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -576,7 +576,7 @@ int16_t TileElementHeight(const CoordsXYZ& loc, uint8_t slope) int8_t quad = 0, quad_extra = 0; // which quadrant the element is in? // quad_extra is for extra height tiles - uint8_t xl, yl; // coordinates across this tile + uint8_t xl, yl; // coordinates across this tile uint8_t TILE_SIZE = 32; @@ -2300,6 +2300,7 @@ void ShiftMap(const TileCoordsXY& amount) entrance += amountToMove; // Entities + auto& entityTweener = EntityTweener::Get(); for (auto i = 0; i < EnumValue(EntityType::Count); i++) { auto entityType = static_cast(i); @@ -2309,7 +2310,7 @@ void ShiftMap(const TileCoordsXY& amount) auto entity = GetEntity(entityId); // Do not tween the entity - EntityTweener::Get().RemoveEntity(entity); + entityTweener.RemoveEntity(entity); auto location = entity->GetLocation(); location += amountToMove; From 58292caf222b58e1afda459c6928189627f03e59 Mon Sep 17 00:00:00 2001 From: Ted John Date: Fri, 23 Jun 2023 18:06:08 +0100 Subject: [PATCH 06/15] Fix code formatting for Map.cpp --- src/openrct2/world/Map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 8ba8450048..3e31c229ed 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -576,7 +576,7 @@ int16_t TileElementHeight(const CoordsXYZ& loc, uint8_t slope) int8_t quad = 0, quad_extra = 0; // which quadrant the element is in? // quad_extra is for extra height tiles - uint8_t xl, yl; // coordinates across this tile + uint8_t xl, yl; // coordinates across this tile uint8_t TILE_SIZE = 32; From e887662d1594816a565229d07407b8dd88fa28d8 Mon Sep 17 00:00:00 2001 From: Ted John Date: Tue, 27 Jun 2023 00:04:22 +0100 Subject: [PATCH 07/15] Fix shifting of banner positions --- src/openrct2/world/Map.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 3e31c229ed..9516139003 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -2406,5 +2406,6 @@ void ShiftMap(const TileCoordsXY& amount) banner->position += amount; count++; } + id = BannerIndex::FromUnderlying(id.ToUnderlying() + 1); } } From 1c2bc82456f115922360be0aab4a56371b7d41a4 Mon Sep 17 00:00:00 2001 From: Ted John Date: Tue, 27 Jun 2023 18:35:41 +0100 Subject: [PATCH 08/15] Fix ShiftMap when x or y is 0 but not both --- src/openrct2/world/Map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 9516139003..09f2574ee4 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -2239,7 +2239,7 @@ MapRange ClampRangeWithinMap(const MapRange& range) void ShiftMap(const TileCoordsXY& amount) { - if (amount.x == 0 || amount.y == 0) + if (amount.x == 0 && amount.y == 0) return; auto amountToMove = amount.ToCoordsXY(); From 4f41734dc53b4c4c0102b78c929751e1f294e023 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sun, 31 Mar 2024 00:00:30 +0100 Subject: [PATCH 09/15] Update for changes on develop --- src/openrct2/world/Map.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 09f2574ee4..0f2315c8a0 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -2243,17 +2243,18 @@ void ShiftMap(const TileCoordsXY& amount) return; auto amountToMove = amount.ToCoordsXY(); + auto& gameState = GetGameState(); // Tile elements auto newElements = std::vector(); - for (int32_t y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++) + for (int32_t y = 0; y < kMaximumMapSizeTechnical; y++) { - for (int32_t x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++) + for (int32_t x = 0; x < kMaximumMapSizeTechnical; x++) { auto srcX = x - amount.x; auto srcY = y - amount.y; - if (x > 0 && y > 0 && x < gMapSize.x - 1 && y < gMapSize.y - 1 && srcX > 0 && srcY > 0 && srcX < gMapSize.x - 1 - && srcY < gMapSize.y - 1) + if (x > 0 && y > 0 && x < gameState.MapSize.x - 1 && y < gameState.MapSize.y - 1 && srcX > 0 && srcY > 0 + && srcX < gameState.MapSize.x - 1 && srcY < gameState.MapSize.y - 1) { auto srcTile = _tileIndex.GetFirstElementAt(TileCoordsXY(srcX, srcY)); do @@ -2261,19 +2262,19 @@ void ShiftMap(const TileCoordsXY& amount) newElements.push_back(*srcTile); } while (!(srcTile++)->IsLastForTile()); } - else if (x == 0 || y == 0 || x == gMapSize.x - 1 || y == gMapSize.y - 1) + else if (x == 0 || y == 0 || x == gameState.MapSize.x - 1 || y == gameState.MapSize.y - 1) { auto surface = GetDefaultSurfaceElement(); - surface.SetBaseZ(MINIMUM_LAND_HEIGHT_BIG); - surface.SetClearanceZ(MINIMUM_LAND_HEIGHT_BIG); + surface.SetBaseZ(kMinimumLandZ); + surface.SetClearanceZ(kMinimumLandZ); surface.AsSurface()->SetSlope(0); surface.AsSurface()->SetWaterHeight(0); newElements.push_back(surface); } else { - auto copyX = std::clamp(srcX, 1, gMapSize.x - 2); - auto copyY = std::clamp(srcY, 1, gMapSize.y - 2); + auto copyX = std::clamp(srcX, 1, gameState.MapSize.x - 2); + auto copyY = std::clamp(srcY, 1, gameState.MapSize.y - 2); auto srcTile = MapGetSurfaceElementAt(TileCoordsXY(copyX, copyY)); if (srcTile != nullptr) { @@ -2293,10 +2294,10 @@ void ShiftMap(const TileCoordsXY& amount) SetTileElements(std::move(newElements)); MapRemoveOutOfRangeElements(); - for (auto& spawn : gPeepSpawns) + for (auto& spawn : gameState.PeepSpawns) spawn += amountToMove; - for (auto& entrance : gParkEntrances) + for (auto& entrance : gameState.ParkEntrances) entrance += amountToMove; // Entities From 86f80faca80a5ea03dd07b4910e88ca748d94f21 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sun, 31 Mar 2024 00:32:36 +0100 Subject: [PATCH 10/15] Also shift jumping fountains and map animations --- src/openrct2/world/Map.cpp | 12 ++++++++++++ src/openrct2/world/MapAnimation.cpp | 11 +++++++++++ src/openrct2/world/MapAnimation.h | 1 + 3 files changed, 24 insertions(+) diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 0f2315c8a0..a490e39f7f 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -23,6 +23,7 @@ #include "../core/Guard.hpp" #include "../entity/Duck.h" #include "../entity/EntityTweener.h" +#include "../entity/Fountain.h" #include "../entity/PatrolArea.h" #include "../entity/Staff.h" #include "../interface/Cursors.h" @@ -2354,6 +2355,15 @@ void ShiftMap(const TileCoordsXY& amount) } break; } + case EntityType::JumpingFountain: + { + auto fountain = entity->As(); + if (fountain != nullptr) + { + fountain->TargetX += amountToMove.x; + fountain->TargetY += amountToMove.y; + } + } default: break; } @@ -2409,4 +2419,6 @@ void ShiftMap(const TileCoordsXY& amount) } id = BannerIndex::FromUnderlying(id.ToUnderlying() + 1); } + + ShiftAllMapAnimations(amountToMove); } diff --git a/src/openrct2/world/MapAnimation.cpp b/src/openrct2/world/MapAnimation.cpp index 9c1751d48b..690c62f779 100644 --- a/src/openrct2/world/MapAnimation.cpp +++ b/src/openrct2/world/MapAnimation.cpp @@ -709,3 +709,14 @@ void MapAnimationAutoCreateAtTileElement(TileCoordsXY coords, TileElement* el) break; } } + +void ShiftAllMapAnimations(CoordsXY amount) +{ + if (amount.x == 0 && amount.y == 0) + return; + + for (auto& a : _mapAnimations) + { + a.location += amount; + } +} diff --git a/src/openrct2/world/MapAnimation.h b/src/openrct2/world/MapAnimation.h index ddbdabe18e..fff54969c5 100644 --- a/src/openrct2/world/MapAnimation.h +++ b/src/openrct2/world/MapAnimation.h @@ -46,3 +46,4 @@ void MapAnimationInvalidateAll(); const std::vector& GetMapAnimations(); void MapAnimationAutoCreate(); void MapAnimationAutoCreateAtTileElement(TileCoordsXY coords, TileElement* el); +void ShiftAllMapAnimations(CoordsXY amount); From 308912b8ceef5fc74559c08eb2cea9060bfe8009 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Tue, 23 Apr 2024 19:29:35 +0200 Subject: [PATCH 11/15] Fix rebase error --- src/openrct2/world/Map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index a490e39f7f..316bcb2544 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -2298,7 +2298,7 @@ void ShiftMap(const TileCoordsXY& amount) for (auto& spawn : gameState.PeepSpawns) spawn += amountToMove; - for (auto& entrance : gameState.ParkEntrances) + for (auto& entrance : gameState.Park.Entrances) entrance += amountToMove; // Entities From dde7a8270ac9e3e0b747d72fbe7597027664fa8b Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Tue, 23 Apr 2024 19:34:20 +0200 Subject: [PATCH 12/15] Only shift ride locations if they are not null --- src/openrct2/world/Map.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 316bcb2544..792ba5d38f 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -2238,6 +2238,18 @@ MapRange ClampRangeWithinMap(const MapRange& range) return validRange; } +static inline void shiftIfNotNull(TileCoordsXY& coords, const TileCoordsXY& amount) +{ + if (!coords.IsNull()) + coords += amount; +} + +static inline void shiftIfNotNull(CoordsXY& coords, const CoordsXY& amount) +{ + if (!coords.IsNull()) + coords += amount; +} + void ShiftMap(const TileCoordsXY& amount) { if (amount.x == 0 && amount.y == 0) @@ -2392,17 +2404,17 @@ void ShiftMap(const TileCoordsXY& amount) auto& stations = ride.GetStations(); for (auto& station : stations) { - station.Start += amountToMove; - station.Entrance += amount; - station.Exit += amount; + shiftIfNotNull(station.Start, amountToMove); + shiftIfNotNull(station.Entrance, amount); + shiftIfNotNull(station.Exit, amount); } - ride.overall_view += amountToMove; - ride.boat_hire_return_position += amount; - ride.CurTestTrackLocation += amount; - ride.ChairliftBullwheelLocation[0] += amount; - ride.ChairliftBullwheelLocation[1] += amount; - ride.CableLiftLoc += amountToMove; + shiftIfNotNull(ride.overall_view, amountToMove); + shiftIfNotNull(ride.boat_hire_return_position, amount); + shiftIfNotNull(ride.CurTestTrackLocation, amount); + shiftIfNotNull(ride.ChairliftBullwheelLocation[0], amount); + shiftIfNotNull(ride.ChairliftBullwheelLocation[1], amount); + shiftIfNotNull(ride.CableLiftLoc, amountToMove); } // Banners From 3bb1f8e18aae69252201d091bf7f57605cc215a3 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Fri, 17 May 2024 23:30:07 +0200 Subject: [PATCH 13/15] Guard more moves with null check --- src/openrct2/world/Map.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 792ba5d38f..c7c8e82a5f 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -2308,10 +2308,10 @@ void ShiftMap(const TileCoordsXY& amount) MapRemoveOutOfRangeElements(); for (auto& spawn : gameState.PeepSpawns) - spawn += amountToMove; + shiftIfNotNull(spawn, amountToMove); for (auto& entrance : gameState.Park.Entrances) - entrance += amountToMove; + shiftIfNotNull(entrance, amountToMove); // Entities auto& entityTweener = EntityTweener::Get(); @@ -2327,7 +2327,7 @@ void ShiftMap(const TileCoordsXY& amount) entityTweener.RemoveEntity(entity); auto location = entity->GetLocation(); - location += amountToMove; + shiftIfNotNull(location, amountToMove); entity->MoveTo(location); switch (entityType) @@ -2338,12 +2338,12 @@ void ShiftMap(const TileCoordsXY& amount) auto peep = entity->As(); if (peep != nullptr) { - peep->NextLoc += amountToMove; + shiftIfNotNull(peep->NextLoc, amountToMove); peep->DestinationX += amountToMove.x; peep->DestinationY += amountToMove.y; - peep->PathfindGoal += amount; + shiftIfNotNull(peep->PathfindGoal, amount); for (auto& h : peep->PathfindHistory) - h += amount; + shiftIfNotNull(h, amount); } break; } @@ -2352,8 +2352,8 @@ void ShiftMap(const TileCoordsXY& amount) auto vehicle = entity->As(); if (vehicle != nullptr) { - vehicle->TrackLocation += amountToMove; - vehicle->BoatLocation += amountToMove; + shiftIfNotNull(vehicle->TrackLocation, amountToMove); + shiftIfNotNull(vehicle->BoatLocation, amountToMove); } break; } @@ -2389,7 +2389,7 @@ void ShiftMap(const TileCoordsXY& amount) { auto positions = patrol->ToVector(); for (auto& p : positions) - p += amount; + shiftIfNotNull(p, amount); patrol->Clear(); patrol->Union(positions); } @@ -2426,7 +2426,7 @@ void ShiftMap(const TileCoordsXY& amount) auto* banner = GetBanner(id); if (banner != nullptr) { - banner->position += amount; + shiftIfNotNull(banner->position, amount); count++; } id = BannerIndex::FromUnderlying(id.ToUnderlying() + 1); From a3a09577be0790f1db91f9e942497dfe38190270 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Fri, 17 May 2024 23:32:32 +0200 Subject: [PATCH 14/15] Fix outdated patrol areas showing up after map shift --- src/openrct2/world/Map.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index c7c8e82a5f..23bf9028fb 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -2397,6 +2397,7 @@ void ShiftMap(const TileCoordsXY& amount) } } } + UpdateConsolidatedPatrolAreas(); // Rides for (auto& ride : GetRideManager()) From 0311f4b875437e25dff36b0b7981ca1cf260adf2 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sat, 18 May 2024 21:11:27 +0200 Subject: [PATCH 15/15] Update changelog --- distribution/changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 75b5205ef6..f57bd9fa57 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -1,6 +1,7 @@ 0.4.12 (in development) ------------------------------------------------------------------------ - Feature: [#622] Add option to align the top toolbar buttons horizontally centred (off by default). +- Feature: [#20263] Ability to increase the size of the map in the (0, 0) direction. - Feature: [#21714] [Plugin] Costume assignment is now tailored to each staff type. - Feature: [#21893] On launch, the game now indicates what system is being initialised. - Feature: [#21913] [Plugin] Allow precise and safe control of peep animations. @@ -42,7 +43,6 @@ 0.4.10 (2024-04-02) ------------------------------------------------------------------------ - Feature: [#18171] Add port of the RCT1 Stand-Up Roller Coaster. -- Feature: [#20263] Ability to increase the size of the map in the (0, 0) direction. - Feature: [#21590] [Plugin] Plugins can now read and write banner properties of tile elements. - Feature: [#21636] Add shortcut key for sorting tile elements. - Feature: [objects#294] Add scenery versions of wooden truss supports.