diff --git a/src/openrct2-ui/windows/EditorInventionsList.cpp b/src/openrct2-ui/windows/EditorInventionsList.cpp index b377b53ae1..07d214f55c 100644 --- a/src/openrct2-ui/windows/EditorInventionsList.cpp +++ b/src/openrct2-ui/windows/EditorInventionsList.cpp @@ -127,7 +127,7 @@ static void MoveResearchItem(ResearchItem* beforeItem, int32_t scrollIndex); static void ResearchRidesSetup() { // Reset all objects to not required - for (ObjectType objectType = ObjectType::Ride; objectType < ObjectType::Count; objectType++) + for (auto objectType : TransientObjectTypes) { auto maxObjects = object_entry_group_counts[EnumValue(objectType)]; for (int32_t i = 0; i < maxObjects; i++) diff --git a/src/openrct2/Editor.cpp b/src/openrct2/Editor.cpp index 2d62c7055c..fa639cbc58 100644 --- a/src/openrct2/Editor.cpp +++ b/src/openrct2/Editor.cpp @@ -72,13 +72,15 @@ namespace Editor // Unload objects first, the repository is re-populated which owns the objects. auto& objectManager = context->GetObjectManager(); - objectManager.UnloadAllTransient(); + objectManager.UnloadAll(); // Scan objects if necessary const auto& localisationService = context->GetLocalisationService(); auto& objectRepository = context->GetObjectRepository(); objectRepository.LoadOrConstruct(localisationService.GetCurrentLanguage()); + Audio::LoadAudioObjects(); + // Reset loaded objects to just defaults // Load minimum required objects (like surface and edge) for (const auto& entry : MinimumRequiredObjects) diff --git a/src/openrct2/EditorObjectSelectionSession.cpp b/src/openrct2/EditorObjectSelectionSession.cpp index 29f600fe1e..49d48ea11d 100644 --- a/src/openrct2/EditorObjectSelectionSession.cpp +++ b/src/openrct2/EditorObjectSelectionSession.cpp @@ -113,9 +113,9 @@ void setup_in_use_selection_flags() { auto& objectMgr = OpenRCT2::GetContext()->GetObjectManager(); - for (uint8_t objectType = 0; objectType < EnumValue(ObjectType::Count); objectType++) + for (auto objectType : TransientObjectTypes) { - for (int32_t i = 0; i < object_entry_group_counts[objectType]; i++) + for (int32_t i = 0; i < object_entry_group_counts[EnumValue(objectType)]; i++) { Editor::ClearSelectedObject(static_cast(objectType), i, ObjectSelectionFlags::AllFlags); @@ -374,8 +374,11 @@ void unload_unselected_objects() if (!(_objectSelectionFlags[i] & ObjectSelectionFlags::Selected)) { auto descriptor = ObjectEntryDescriptor(items[i]); - remove_selected_objects_from_research(descriptor); - objectsToUnload.push_back(descriptor); + if (!IsIntransientObjectType(items[i].Type)) + { + remove_selected_objects_from_research(descriptor); + objectsToUnload.push_back(descriptor); + } } } object_manager_unload_objects(objectsToUnload); diff --git a/src/openrct2/audio/Audio.cpp b/src/openrct2/audio/Audio.cpp index 3b94d53d2e..b82d2dfd9c 100644 --- a/src/openrct2/audio/Audio.cpp +++ b/src/openrct2/audio/Audio.cpp @@ -88,7 +88,11 @@ namespace OpenRCT2::Audio } } } + LoadAudioObjects(); + } + void LoadAudioObjects() + { auto& objManager = GetContext()->GetObjectManager(); auto* baseAudio = objManager.LoadObject(AudioObjectIdentifiers::Rct2Base); if (baseAudio != nullptr) diff --git a/src/openrct2/audio/audio.h b/src/openrct2/audio/audio.h index f79f062fa1..7c6d13503e 100644 --- a/src/openrct2/audio/audio.h +++ b/src/openrct2/audio/audio.h @@ -175,6 +175,8 @@ namespace OpenRCT2::Audio */ void Init(); + void LoadAudioObjects(); + /** * Loads the ride sounds and info. * rct2: 0x006BA8E0