1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Merge pull request #22717 from tupaschoal/only_patch_scenarios

Fix #22596: Only apply .parkpatch when starting scenarios
This commit is contained in:
Michael Steenbeek
2024-09-08 17:22:20 +02:00
committed by GitHub
48 changed files with 21 additions and 75 deletions

View File

@@ -3,7 +3,6 @@
"sha256": "020ed74dd726324c043c4663cc9a9230ede7cd23aa0ec6947277874bde9ed301",
"land_ownership": {
"construction_rights_owned": {
"cannot_downgrade": true,
"coordinates": [
[ 44, 51 ],
[ 47, 50 ],

View File

@@ -14,7 +14,6 @@
]
},
"construction_rights_owned": {
"cannot_downgrade": true,
"coordinates": [
[ 86, 69 ], [ 86, 70 ]
]

View File

@@ -3,7 +3,6 @@
"sha256": "0d53bdc076d75d86b31b6b3e6948e3d45671cf5aeff6b2b3c07a7618923223f5",
"land_ownership": {
"construction_rights_available": {
"cannot_downgrade": true,
"coordinates": [
[ 147, 132 ],
[ 82, 110 ], [ 83, 110 ],
@@ -23,7 +22,6 @@
]
},
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 45, 151 ],
[ 55, 137 ],

View File

@@ -9,7 +9,6 @@
]
},
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 63, 97 ],
[ 64, 97 ]

View File

@@ -8,7 +8,6 @@
]
},
"construction_rights_owned": {
"cannot_downgrade": true,
"coordinates": [
[ 11, 64 ], [ 11, 65 ], [ 11, 66 ],
[ 13, 68 ], [ 13, 69 ],

View File

@@ -20,14 +20,12 @@
]
},
"construction_rights_owned": {
"cannot_downgrade": true,
"coordinates": [
[ 2, 30 ], [ 3, 30 ], [ 4, 30 ],
[ 25, 23 ]
]
},
"construction_rights_available": {
"cannot_downgrade": true,
"coordinates": [
[ 26, 116 ],
[ 61, 110 ],
@@ -35,7 +33,6 @@
]
},
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 6, 100 ], [ 7, 100 ], [ 8, 100 ], [ 9, 100 ], [ 10, 100 ], [ 15, 100 ], [ 16, 100 ],
[ 6, 101 ], [ 7, 101 ], [ 8, 101 ], [ 9, 101 ], [ 10, 101 ], [ 15, 101 ], [ 16, 101 ],

View File

@@ -9,7 +9,6 @@
]
},
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 90, 8 ],
[ 2, 26 ], [ 2, 27 ],

View File

@@ -3,7 +3,6 @@
"sha256": "229cf5777d1b90034f3b711eed45c4d6ab9a368a466fd4db758a1eac21632a35",
"land_ownership": {
"construction_rights_owned": {
"cannot_downgrade": true,
"coordinates": [
[ 85, 80 ],
[ 86, 79 ],

View File

@@ -13,7 +13,6 @@
]
},
"construction_rights_owned": {
"cannot_downgrade": true,
"coordinates": [
[ 140, 58 ], [ 141, 58 ], [ 142, 58 ], [ 143, 58 ], [ 144, 58 ], [ 145, 58 ], [ 146, 58 ], [ 147, 58 ],
[ 140, 74 ], [ 141, 74 ], [ 142, 74 ], [ 143, 74 ], [ 144, 74 ], [ 145, 74 ], [ 146, 74 ], [ 147, 74 ]

View File

@@ -3,7 +3,6 @@
"sha256": "32716c025704bdb8ccae3e595ed7b6b3da06896bea9c2a5f739cda36c0600385",
"land_ownership": {
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 42, 147 ],
[ 58, 122 ],
@@ -11,7 +10,6 @@
]
},
"construction_rights_available": {
"cannot_downgrade": true,
"coordinates": [
[ 128, 90 ],
[ 135, 91 ], [ 136, 91 ],
@@ -23,7 +21,6 @@
]
},
"construction_rights_owned": {
"cannot_downgrade": true,
"coordinates": [
[ 98, 64 ], [ 98, 65 ], [ 98, 66 ],
[ 96, 84 ]

View File

@@ -3,7 +3,6 @@
"sha256": "33bac63d13aa7513ac8536d865cbc6fa4a2189c79e3943869e6380072e71bce7",
"land_ownership": {
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 58, 77 ],
[ 62, 81 ], [ 63, 81 ], [ 64, 81 ],

View File

@@ -3,7 +3,6 @@
"sha256": "4ec6b381faf6b576f38c59a16ee441b9ed680e4bb38a9320e58e65dfd3f12c94",
"land_ownership": {
"construction_rights_owned": {
"cannot_downgrade": true,
"coordinates": [
[ 28, 95 ]
]

View File

@@ -3,7 +3,6 @@
"sha256": "59aea26b8fe26a4154114be8514ee70a6f31d981c5b07429572021d6ce5e69ad",
"land_ownership": {
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 43, 65 ],
[ 69, 41 ],

View File

@@ -3,7 +3,6 @@
"sha256": "62268223a1539c92b7494973263457c9e9bf386c1e68eef21d377854f0ac0e38",
"land_ownership": {
"construction_rights_owned": {
"cannot_downgrade": true,
"coordinates": [
[ 85, 80 ],
[ 86, 79 ],

View File

@@ -3,7 +3,6 @@
"sha256": "6633d176c5614ed4cae8e4f83d4328f87fa73979d6fcf81378ba836185e815ba",
"land_ownership": {
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 103, 24 ],
[ 104, 25 ],

View File

@@ -3,7 +3,6 @@
"sha256": "6ce84b809471ba539d94d4198832b848b47d81316f5c8cc1297d8328299b4c52",
"land_ownership": {
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 42, 147 ],
[ 58, 122 ],
@@ -11,7 +10,6 @@
]
},
"construction_rights_available": {
"cannot_downgrade": true,
"coordinates": [
[ 128, 90 ],
[ 135, 91 ], [ 136, 91 ],
@@ -23,7 +21,6 @@
]
},
"construction_rights_owned": {
"cannot_downgrade": true,
"coordinates": [
[ 98, 64 ], [ 98, 65 ], [ 98, 66 ],
[ 96, 84 ]

View File

@@ -8,7 +8,6 @@
]
},
"construction_rights_owned": {
"cannot_downgrade": true,
"coordinates": [
[ 11, 64 ], [ 11, 65 ], [ 11, 66 ],
[ 13, 68 ], [ 13, 69 ],

View File

@@ -20,7 +20,6 @@
]
},
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 49, 99 ],
[ 50, 99 ],

View File

@@ -3,7 +3,6 @@
"sha256": "7f38f1bf88c2d583aa795f0d0abbbe6cf9cccb7872ff8017f1c5d83ad95886df",
"land_ownership": {
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 104, 190 ], [ 105, 190 ], [ 108, 197 ],
[ 75, 167 ],

View File

@@ -3,7 +3,6 @@
"sha256": "7ffdb448eccc8e24026e820f5e1d5649459b5ee5d469afdaa73e87d31475f2b0",
"land_ownership": {
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 104, 190 ], [ 105, 190 ], [ 108, 197 ],
[ 75, 167 ],

View File

@@ -20,14 +20,12 @@
]
},
"construction_rights_owned": {
"cannot_downgrade": true,
"coordinates": [
[ 2, 30 ], [ 3, 30 ], [ 4, 30 ],
[ 25, 23 ]
]
},
"construction_rights_available": {
"cannot_downgrade": true,
"coordinates": [
[ 26, 116 ],
[ 61, 110 ],
@@ -35,7 +33,6 @@
]
},
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 6, 100 ], [ 7, 100 ], [ 8, 100 ], [ 9, 100 ], [ 10, 100 ], [ 15, 100 ], [ 16, 100 ],
[ 6, 101 ], [ 7, 101 ], [ 8, 101 ], [ 9, 101 ], [ 10, 101 ], [ 15, 101 ], [ 16, 101 ],

View File

@@ -3,7 +3,6 @@
"sha256": "825134aad8365e12efba50b58f67e96b729640e6ff4007dfe5dffe99c167531f",
"land_ownership": {
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 104, 64 ],
[ 111, 114 ], [ 112, 114 ]

View File

@@ -13,7 +13,6 @@
]
},
"construction_rights_owned": {
"cannot_downgrade": true,
"coordinates": [
[ 140, 58 ], [ 141, 58 ], [ 142, 58 ], [ 143, 58 ], [ 144, 58 ], [ 145, 58 ], [ 146, 58 ], [ 147, 58 ],
[ 141, 74 ], [ 142, 74 ], [ 143, 74 ], [ 144, 74 ], [ 145, 74 ], [ 146, 74 ], [ 147, 74 ]

View File

@@ -3,7 +3,6 @@
"sha256": "8965a5c3b498dec016e6ac317616426ed84b0e9145f6c1d752c9942479758cce",
"land_ownership": {
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 112, 33 ], [ 112, 34 ],
[ 113, 117 ], [ 114, 117 ], [ 115, 117 ], [ 116, 117 ], [ 117, 117 ],

View File

@@ -14,7 +14,6 @@
]
},
"construction_rights_owned": {
"cannot_downgrade": true,
"coordinates": [
[ 86, 69 ], [ 86, 70 ]
]

View File

@@ -3,7 +3,6 @@
"sha256": "a04b536d83b556f5af116e967f7a5759c9cdc5dd2172da9ceffbd00458f13fef",
"land_ownership": {
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 104, 64 ],
[ 111, 114 ], [ 112, 114 ]

View File

@@ -20,7 +20,6 @@
]
},
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 49, 99 ],
[ 50, 99 ],

View File

@@ -3,7 +3,6 @@
"sha256": "b43b07e47f2e6cb762a86760ac0242595617aa59bfd9811cec7e2dcc121ae367",
"land_ownership": {
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 58, 77 ],
[ 62, 81 ], [ 63, 81 ], [ 64, 81 ],

View File

@@ -9,7 +9,6 @@
]
},
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 63, 97 ],
[ 64, 97 ]

View File

@@ -3,7 +3,6 @@
"sha256": "c1d405642b698e0af9d23d3a23afe42f0c7d138c1398254a1c581608f79a3db3",
"land_ownership": {
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 104, 190 ], [ 105, 190 ], [ 108, 197 ],
[ 75, 167 ],

View File

@@ -3,7 +3,6 @@
"sha256": "c82272a1e966e54863b3b90ba4c90e37ed8ef8b99253d284bb7cc56f9590d97a",
"land_ownership": {
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 104, 190 ], [ 105, 190 ], [ 108, 197 ],
[ 75, 167 ],

View File

@@ -3,7 +3,6 @@
"sha256": "d0553271f6fe9ff7bb6a5e7e5735c553340dfcdfb103d5ff3e332d4841938ddd",
"land_ownership": {
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 112, 33 ], [ 112, 34 ],
[ 113, 117 ], [ 114, 117 ], [ 115, 117 ], [ 116, 117 ], [ 117, 117 ],

View File

@@ -9,7 +9,6 @@
]
},
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 90, 8 ],
[ 2, 26 ], [ 2, 27 ],

View File

@@ -3,7 +3,6 @@
"sha256": "d48bbfe4833347dfbf5befe63eb3795df3bce36cdc9152048ee7851e36d45ad9",
"land_ownership": {
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 13, 95 ],
[ 80, 31 ],

View File

@@ -3,7 +3,6 @@
"sha256": "e57112f58a7710d3e80242e867fb65d720e0cd3b67bebfd6b7df8b404fc7ea2b",
"land_ownership": {
"construction_rights_available": {
"cannot_downgrade": true,
"coordinates": [
[ 147, 132 ],
[ 82, 110 ], [ 83, 110 ],
@@ -23,7 +22,6 @@
]
},
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 45, 151 ],
[ 55, 137 ],

View File

@@ -3,7 +3,6 @@
"sha256": "ef0c0202510d84cf4f1ad198ae43b6bc00d5af2d664c60cdb38de632ea25db51",
"land_ownership": {
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 103, 24 ],
[ 104, 25 ],

View File

@@ -3,7 +3,6 @@
"sha256": "f4b1675c8ccb31d422c1b7b8bd5336b2bfefa94d702aeae1859ea95ecda2c29d",
"land_ownership": {
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 43, 65 ],
[ 69, 41 ],

View File

@@ -3,7 +3,6 @@
"sha256": "f71c9788ab40ac591d5c96397fad8b12d9d3ac7830eac53f6ee5dc024c8c2bcf",
"land_ownership": {
"available": {
"cannot_downgrade": true,
"coordinates": [
[ 13, 95 ],
[ 80, 31 ],

View File

@@ -3,7 +3,6 @@
"sha256": "f9762d2189a29f2f3dea2a2ec1503d8aa91567c0d604d2775d493d4b7dee3ba2",
"land_ownership": {
"construction_rights_owned": {
"cannot_downgrade": true,
"coordinates": [
[ 28, 95 ]
]

View File

@@ -3,7 +3,6 @@
"sha256": "ff52987c70ea89deb5c1b8445b7a689c8b83e22b5aef18bb4bbd07375b27f47e",
"land_ownership": {
"construction_rights_owned": {
"cannot_downgrade": true,
"coordinates": [
[ 44, 51 ],
[ 47, 50 ],

View File

@@ -1,6 +1,7 @@
0.4.15 (in development)
------------------------------------------------------------------------
- Feature: [#15642] Track design placement can now use contruction modifier keys (ctrl/shift).
- Change: [#22596] Land ownership fixes described by .parkpatch files are now only considered on scenarios.
- Fix: [#2614] The colour tab of the ride window does not hide invisible cars (original bug).
- Fix: [#21959] “Save this before...?” message does not appear when selecting “New Game”.
- Fix: [#22231] Invalid object version can cause a crash.

View File

@@ -193,7 +193,10 @@ namespace OpenRCT2::RCT1
ImportScenarioObjective(gameState);
ImportSavedView(gameState);
RCT12::FetchAndApplyScenarioPatch(_s4Path, _isScenario);
if (_isScenario)
{
RCT12::FetchAndApplyScenarioPatch(_s4Path);
}
FixNextGuestNumber(gameState);
CountBlockSections();
SetDefaultNames();

View File

@@ -43,7 +43,6 @@ static const std::string s_fullSHAKey = "sha256";
static const std::string s_coordinatesKey = "coordinates";
// Land Ownership Keys
static const std::string s_cannotDowngradeKey = "cannot_downgrade";
static const std::string s_landOwnershipKey = "land_ownership";
// Water fix keys
@@ -132,15 +131,12 @@ static void ApplyLandOwnershipFixes(const json_t& landOwnershipFixes, int owners
}
auto ownershipParameters = landOwnershipFixes[ownershipTypeKey];
const bool cannotDowngrade = ownershipParameters.contains(s_cannotDowngradeKey)
? OpenRCT2::Json::GetBoolean(ownershipParameters[s_cannotDowngradeKey], false)
: false;
auto coordinatesVector = getCoordinates(ownershipParameters);
if (s_dryRun)
{
return;
}
FixLandOwnershipTilesWithOwnership(coordinatesVector, ownershipType, cannotDowngrade);
FixLandOwnershipTilesWithOwnership(coordinatesVector, ownershipType);
}
static void ApplyLandOwnershipFixes(const json_t& scenarioPatch)
@@ -457,7 +453,7 @@ static bool ValidateSHA256(const json_t& scenarioPatch, u8string_view scenarioHa
return scenarioSHA == scenarioHash;
}
void OpenRCT2::RCT12::ApplyScenarioPatch(u8string_view scenarioPatchFile, u8string scenarioSHA, bool isScenario)
void OpenRCT2::RCT12::ApplyScenarioPatch(u8string_view scenarioPatchFile, u8string scenarioSHA)
{
auto scenarioPatch = OpenRCT2::Json::ReadFromFile(scenarioPatchFile);
if (!ValidateSHA256(scenarioPatch, scenarioSHA))
@@ -465,17 +461,13 @@ void OpenRCT2::RCT12::ApplyScenarioPatch(u8string_view scenarioPatchFile, u8stri
OpenRCT2::Guard::Assert(0, "Invalid full SHA256. Check for shortened SHA collision");
return;
}
// TODO: Land ownership is applied even when loading saved scenario. Should it?
ApplyLandOwnershipFixes(scenarioPatch);
if (isScenario)
{
ApplyWaterFixes(scenarioPatch);
ApplyTileFixes(scenarioPatch);
ApplyRideFixes(scenarioPatch);
}
ApplyWaterFixes(scenarioPatch);
ApplyTileFixes(scenarioPatch);
ApplyRideFixes(scenarioPatch);
}
void OpenRCT2::RCT12::FetchAndApplyScenarioPatch(u8string_view scenarioPath, bool isScenario)
void OpenRCT2::RCT12::FetchAndApplyScenarioPatch(u8string_view scenarioPath)
{
if (scenarioPath.empty())
{
@@ -486,7 +478,7 @@ void OpenRCT2::RCT12::FetchAndApplyScenarioPatch(u8string_view scenarioPath, boo
auto patchPath = GetPatchFileName(scenarioSHA);
if (OpenRCT2::File::Exists(patchPath))
{
ApplyScenarioPatch(patchPath, scenarioSHA, isScenario);
ApplyScenarioPatch(patchPath, scenarioSHA);
}
}

View File

@@ -13,8 +13,8 @@
namespace OpenRCT2::RCT12
{
void FetchAndApplyScenarioPatch(u8string_view scenarioPath, bool isScenario);
void ApplyScenarioPatch(u8string_view scenarioPatchFile, u8string scenarioSHA, bool isScenario);
void FetchAndApplyScenarioPatch(u8string_view scenarioPath);
void ApplyScenarioPatch(u8string_view scenarioPatchFile, u8string scenarioSHA);
/*SetDryRun should be used only for testing*/
void SetDryRun(bool enable);
} // namespace OpenRCT2::RCT12

View File

@@ -578,7 +578,10 @@ namespace OpenRCT2::RCT2
gameState.Park.Name = GetUserString(_s6.ParkName);
OpenRCT2::RCT12::FetchAndApplyScenarioPatch(_s6Path, _isScenario);
if (_isScenario)
{
OpenRCT2::RCT12::FetchAndApplyScenarioPatch(_s6Path);
}
ResearchDetermineFirstOfType();
UpdateConsolidatedPatrolAreas();

View File

@@ -2159,16 +2159,13 @@ uint16_t CheckMaxAllowableLandRightsForTile(const CoordsXYZ& tileMapPos)
return destOwnership;
}
void FixLandOwnershipTilesWithOwnership(std::vector<TileCoordsXY> tiles, uint8_t ownership, bool doNotDowngrade)
void FixLandOwnershipTilesWithOwnership(std::vector<TileCoordsXY> tiles, uint8_t ownership)
{
for (const auto& tile : tiles)
{
auto surfaceElement = MapGetSurfaceElementAt(tile);
if (surfaceElement != nullptr)
{
if (doNotDowngrade && surfaceElement->GetOwnership() == OWNERSHIP_OWNED)
continue;
surfaceElement->SetOwnership(ownership);
Park::UpdateFencesAroundTile(tile.ToCoordsXY());
}

View File

@@ -235,6 +235,6 @@ bool MapIsLocationAtEdge(const CoordsXY& loc);
uint16_t CheckMaxAllowableLandRightsForTile(const CoordsXYZ& tileMapPos);
void FixLandOwnershipTilesWithOwnership(std::vector<TileCoordsXY> tiles, uint8_t ownership, bool doNotDowngrade = false);
void FixLandOwnershipTilesWithOwnership(std::vector<TileCoordsXY> tiles, uint8_t ownership);
MapRange ClampRangeWithinMap(const MapRange& range);
void ShiftMap(const TileCoordsXY& amount);

View File

@@ -42,7 +42,7 @@ TEST(FetchAndApplyScenarioPatch, expected_json_format)
auto path = entry.path().u8string();
if (OpenRCT2::String::EndsWith(path, ".parkpatch"))
{
OpenRCT2::RCT12::ApplyScenarioPatch(path, dummySHA, true);
OpenRCT2::RCT12::ApplyScenarioPatch(path, dummySHA);
}
}
SUCCEED();