From f768d2873e01311a59ef6ed2b7446834547f79ca Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sun, 21 Sep 2025 01:32:16 +0200 Subject: [PATCH] Do not read from repository when loading objects --- src/openrct2/object/BannerObject.cpp | 15 ++++----------- src/openrct2/object/Object.cpp | 8 ++++++++ src/openrct2/object/Object.h | 1 + src/openrct2/object/PathAdditionObject.cpp | 15 ++++----------- 4 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/openrct2/object/BannerObject.cpp b/src/openrct2/object/BannerObject.cpp index 873b33504e..5118dfa346 100644 --- a/src/openrct2/object/BannerObject.cpp +++ b/src/openrct2/object/BannerObject.cpp @@ -44,18 +44,11 @@ namespace OpenRCT2 // Add banners to 'Signs and items for footpaths' group, rather than lumping them in the Miscellaneous tab. // Since this is already done the other way round for original items, avoid adding those to prevent duplicates. - - auto& objectRepository = context->GetObjectRepository(); - auto item = objectRepository.FindObject(GetDescriptor()); - if (item != nullptr) + auto firstSourceGame = GetFirstSourceGame(); + if (firstSourceGame == ObjectSourceGame::Custom) { - auto sourceGame = item->GetFirstSourceGame(); - if (sourceGame == ObjectSourceGame::WackyWorlds || sourceGame == ObjectSourceGame::TimeTwister - || sourceGame == ObjectSourceGame::Custom) - { - auto scgPathX = Object::GetScgPathXHeader(); - SetPrimarySceneryGroup(scgPathX); - } + auto scgPathX = Object::GetScgPathXHeader(); + SetPrimarySceneryGroup(scgPathX); } } diff --git a/src/openrct2/object/Object.cpp b/src/openrct2/object/Object.cpp index 0707764277..b4cac59e9b 100644 --- a/src/openrct2/object/Object.cpp +++ b/src/openrct2/object/Object.cpp @@ -192,6 +192,14 @@ namespace OpenRCT2 return _sourceGames; } + ObjectSourceGame Object::GetFirstSourceGame() const + { + if (_sourceGames.size() == 0) + return ObjectSourceGame::Custom; + + return _sourceGames[0]; + } + void Object::SetSourceGames(const std::vector& sourceGames) { _sourceGames = sourceGames; diff --git a/src/openrct2/object/Object.h b/src/openrct2/object/Object.h index 1143a8f42f..d8f7e5f238 100644 --- a/src/openrct2/object/Object.h +++ b/src/openrct2/object/Object.h @@ -304,6 +304,7 @@ namespace OpenRCT2 { } std::vector GetSourceGames(); + ObjectSourceGame GetFirstSourceGame() const; void SetSourceGames(const std::vector& sourceGames); const std::vector& GetAuthors() const; diff --git a/src/openrct2/object/PathAdditionObject.cpp b/src/openrct2/object/PathAdditionObject.cpp index 24f0e6c78d..144d00c1d2 100644 --- a/src/openrct2/object/PathAdditionObject.cpp +++ b/src/openrct2/object/PathAdditionObject.cpp @@ -47,18 +47,11 @@ namespace OpenRCT2 // Add path additions to 'Signs and items for footpaths' group, rather than lumping them in the Miscellaneous tab. // Since this is already done the other way round for original items, avoid adding those to prevent duplicates. - - auto& objectRepository = context->GetObjectRepository(); - auto item = objectRepository.FindObject(GetDescriptor()); - if (item != nullptr) + auto firstSourceGame = GetFirstSourceGame(); + if (firstSourceGame == ObjectSourceGame::Custom) { - auto sourceGame = item->GetFirstSourceGame(); - if (sourceGame == ObjectSourceGame::WackyWorlds || sourceGame == ObjectSourceGame::TimeTwister - || sourceGame == ObjectSourceGame::Custom) - { - auto scgPathX = Object::GetScgPathXHeader(); - SetPrimarySceneryGroup(scgPathX); - } + auto scgPathX = Object::GetScgPathXHeader(); + SetPrimarySceneryGroup(scgPathX); } }