From 68d4304bbc95cd86494e9abde8c9b4c25f38a794 Mon Sep 17 00:00:00 2001 From: mrmbernardi Date: Thu, 29 Jun 2023 22:50:06 +0200 Subject: [PATCH] Fix #19878: Pre-built rides respect scenery research (#20472) --- distribution/changelog.txt | 1 + src/openrct2/management/Research.cpp | 6 +++++- src/openrct2/ride/TrackDesign.cpp | 7 ++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 3a00a894af..7e61026db1 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -8,6 +8,7 @@ - Fix: [#6152] Camera and UI are no longer locked at 40 Hz, providing a smoother experience. - Fix: [#9534] Screams no longer cut-off on steep diagonal drops - Fix: [#19823] Parkobj: disallow overriding objects of different object types. +- Fix: [#19878] Unresearched scenery can be placed via prebuilt rides. - Fix: [#20083] Cannot use terrain surfaces with ID > 32 and terrain edges with ID > 16. - Fix: [#20089] Potential crash when a window is closed from another window. - Fix: [#20103] [Plugin] Crash when custom plugin actions fail due to immutable state. diff --git a/src/openrct2/management/Research.cpp b/src/openrct2/management/Research.cpp index 3c03c40100..4e9acc2bd4 100644 --- a/src/openrct2/management/Research.cpp +++ b/src/openrct2/management/Research.cpp @@ -537,11 +537,15 @@ bool ResearchIsInvented(ObjectType objectType, ObjectEntryIndex index) case ObjectType::SceneryGroup: return SceneryGroupIsInvented(index); case ObjectType::SmallScenery: + return SceneryIsInvented({ SCENERY_TYPE_SMALL, index }); case ObjectType::LargeScenery: + return SceneryIsInvented({ SCENERY_TYPE_LARGE, index }); case ObjectType::Walls: + return SceneryIsInvented({ SCENERY_TYPE_WALL, index }); case ObjectType::Banners: + return SceneryIsInvented({ SCENERY_TYPE_BANNER, index }); case ObjectType::PathAdditions: - return SceneryIsInvented({ static_cast(objectType), index }); + return SceneryIsInvented({ SCENERY_TYPE_PATH_ITEM, index }); default: return true; } diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 78e4a14def..12a7782b1d 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -757,12 +757,17 @@ static std::optional TrackDesignPlaceSceneryElementGetEntry(c else { auto obj = objectMgr.GetLoadedObject(scenery.scenery_object); + bool objectUnavailable = obj == nullptr; if (obj != nullptr) { result.Type = obj->GetObjectType(); result.Index = objectMgr.GetLoadedObjectEntryIndex(obj); + if (!gCheatsIgnoreResearchStatus) + { + objectUnavailable = !ResearchIsInvented(result.Type, result.Index); + } } - else + if (objectUnavailable) { _trackDesignPlaceStateSceneryUnavailable = true; return {};