1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 09:32:29 +01:00

Fix #22654: Port element removal fixes from #19740 into parkpatch (#22761)

This commit is contained in:
Tulio Leao
2024-09-15 08:26:05 -03:00
committed by GitHub
parent 9fe063923a
commit 2b36d59bf9
10 changed files with 124 additions and 1 deletions

View File

@@ -35,5 +35,20 @@
[ 47, 54 ], [ 47, 55 ], [ 47, 56 ], [ 47, 57 ]
]
}
],
"elements_to_delete": [
{
"element_index": 1,
"coordinates": [
[ 39, 51 ],
[ 40, 54 ],
[ 41, 52 ], [ 41, 53 ],
[ 42, 54 ],
[ 43, 55 ],
[ 44, 51 ], [ 44, 54 ], [ 44, 54 ],
[ 45, 55 ], [ 45, 56 ],
[ 46, 56 ], [ 46, 57 ]
]
}
]
}

View File

@@ -15,5 +15,14 @@
[ 86, 24 ], [ 86, 25 ], [ 87, 23 ], [ 87, 24 ], [ 87, 25 ], [ 88, 22 ], [ 88, 23 ], [ 88, 24 ], [ 89, 22 ], [ 89, 23 ]
]
}
],
"elements_to_delete": [
{
"element_index": 1,
"coordinates": [
[ 86, 25 ],
[ 87, 23 ], [ 87, 25 ]
]
}
]
}

View File

@@ -35,5 +35,20 @@
[ 47, 54 ], [ 47, 55 ], [ 47, 56 ], [ 47, 57 ]
]
}
],
"elements_to_delete": [
{
"element_index": 1,
"coordinates": [
[ 39, 51 ],
[ 40, 54 ],
[ 41, 52 ], [ 41, 53 ],
[ 42, 54 ],
[ 43, 55 ],
[ 44, 51 ], [ 44, 54 ], [ 44, 54 ],
[ 45, 55 ], [ 45, 56 ],
[ 46, 56 ], [ 46, 57 ]
]
}
]
}

View File

@@ -8,5 +8,14 @@
[ 81, 8 ], [ 82, 7 ], [ 82, 8 ], [ 82, 9 ], [ 83, 8 ], [ 83, 9 ]
]
}
],
"elements_to_delete": [
{
"element_index": 1,
"coordinates": [
[ 82, 7 ], [ 82, 8 ],
[ 83, 9 ]
]
}
]
}

View File

@@ -8,5 +8,14 @@
[ 81, 8 ], [ 82, 7 ], [ 82, 8 ], [ 82, 9 ], [ 83, 8 ], [ 83, 9 ]
]
}
],
"elements_to_delete": [
{
"element_index": 1,
"coordinates": [
[ 82, 7 ], [ 82, 8 ],
[ 83, 9 ]
]
}
]
}

View File

@@ -20,5 +20,14 @@
[ 86, 24 ], [ 86, 25 ], [ 87, 23 ], [ 87, 24 ], [ 87, 25 ], [ 88, 22 ], [ 88, 23 ], [ 88, 24 ], [ 89, 22 ], [ 89, 23 ]
]
}
],
"elements_to_delete": [
{
"element_index": 1,
"coordinates": [
[ 86, 25 ],
[ 87, 23 ], [ 87, 25 ]
]
}
]
}

View File

@@ -9,6 +9,7 @@
- Fix: [#21959] “Save this before...?” message does not appear when selecting “New Game”.
- Fix: [#22231] Invalid object version can cause a crash.
- Fix: [#22653] Add several .parkpatch files for missing water tiles in RCT1 and RCT2 scenarios.
- Fix: [#22654] Improve several .parkpatch files to remove misplaced scenario elements in RCT1 and RCT2 scenarios.
- Fix: [#22655] Fix surface style of Botany Breakers around missing water tiles.
- Fix: [#22734] Support clearance above steep Side-Friction track is too low.

View File

@@ -62,6 +62,10 @@ static const std::string _typeKey = "type";
static const std::string _surfacesKey = "surfaces";
static const std::string _destinationSurface = "to_surface";
// Elements to be removed keys
static const std::string _elementsToDelete = "elements_to_delete";
static const std::string _element_index = "element_index";
// Ride fix keys
static const std::string _ridesKey = "rides";
static const std::string _rideIdKey = "id";
@@ -364,6 +368,56 @@ static void ApplySurfaceFixes(const json_t& scenarioPatch)
}
}
static void RemoveTileElements(const json_t& scenarioPatch)
{
if (!scenarioPatch.contains(_elementsToDelete))
{
return;
}
if (!scenarioPatch[_elementsToDelete].is_array())
{
OpenRCT2::Guard::Assert(0, "Elements to delete should be an array");
return;
}
auto elementsToDelete = OpenRCT2::Json::AsArray(scenarioPatch[_elementsToDelete]);
if (elementsToDelete.empty())
{
OpenRCT2::Guard::Assert(0, "Elements to delete should not be empty");
return;
}
for (size_t i = 0; i < elementsToDelete.size(); ++i)
{
if (!elementsToDelete[i].contains(_element_index))
{
OpenRCT2::Guard::Assert(0, "Elements to delete sub-array should set an element_index");
return;
}
auto elementIndex = elementsToDelete[i][_element_index];
auto coordinatesVector = getCoordinates(elementsToDelete[i]);
if (_dryRun)
{
return;
}
for (const auto& tile : coordinatesVector)
{
auto tileElement = MapGetNthElementAt(tile.ToCoordsXY(), elementIndex);
if (tileElement == nullptr)
{
OpenRCT2::Guard::Assert(0, "Invalid Nth element at tile");
return;
}
else
{
ClearElementAt(tile.ToCoordsXY(), &tileElement);
}
}
}
}
static void SwapRideEntranceAndExit(RideId rideId)
{
auto ride = GetRide(rideId);
@@ -522,6 +576,7 @@ void OpenRCT2::RCT12::ApplyScenarioPatch(u8string_view scenarioPatchFile, u8stri
ApplyWaterFixes(scenarioPatch);
ApplyTileFixes(scenarioPatch);
ApplySurfaceFixes(scenarioPatch);
RemoveTileElements(scenarioPatch);
ApplyRideFixes(scenarioPatch);
}

View File

@@ -1414,7 +1414,7 @@ void MapExtendBoundarySurfaceX()
* Clears the provided element properly from a certain tile, and updates
* the pointer (when needed) passed to this function to point to the next element.
*/
static void ClearElementAt(const CoordsXY& loc, TileElement** elementPtr)
void ClearElementAt(const CoordsXY& loc, TileElement** elementPtr)
{
TileElement* element = *elementPtr;
switch (element->GetType())

View File

@@ -217,6 +217,7 @@ int32_t MapGetCornerHeight(int32_t z, int32_t slope, int32_t direction);
int32_t TileElementGetCornerHeight(const SurfaceElement* surfaceElement, int32_t direction);
void MapClearAllElements();
void ClearElementAt(const CoordsXY& loc, TileElement** elementPtr);
LargeSceneryElement* MapGetLargeScenerySegment(const CoordsXYZD& sceneryPos, int32_t sequence);
std::optional<CoordsXYZ> MapLargeSceneryGetOrigin(