From f8091a462e9f7105d59db96e1513341bbed83404 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Fri, 19 Nov 2021 23:09:34 +0000 Subject: [PATCH] Fix scenery group set research status import There were a lot of small issues that compounded into making this bug occur --- src/openrct2/EditorObjectSelectionSession.cpp | 1 + src/openrct2/management/Research.cpp | 3 +-- src/openrct2/management/Research.h | 15 +++++++++++---- src/openrct2/rct1/S4Importer.cpp | 1 + 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/openrct2/EditorObjectSelectionSession.cpp b/src/openrct2/EditorObjectSelectionSession.cpp index 36d967310e..4374c22c22 100644 --- a/src/openrct2/EditorObjectSelectionSession.cpp +++ b/src/openrct2/EditorObjectSelectionSession.cpp @@ -355,6 +355,7 @@ static void remove_selected_objects_from_research(const ObjectEntryDescriptor& d ResearchItem tmp = {}; tmp.type = Research::EntryType::Scenery; tmp.entryIndex = entryIndex; + tmp.baseRideType = 0; ResearchRemove(tmp); break; } diff --git a/src/openrct2/management/Research.cpp b/src/openrct2/management/Research.cpp index 90632c1c0a..b0471647fa 100644 --- a/src/openrct2/management/Research.cpp +++ b/src/openrct2/management/Research.cpp @@ -529,8 +529,7 @@ bool research_insert_scenery_group_entry(ObjectEntryIndex entryIndex, bool resea { if (entryIndex != OBJECT_ENTRY_INDEX_NULL) { - auto tmpItem = ResearchItem( - Research::EntryType::Scenery, entryIndex, RIDE_TYPE_NULL, ResearchCategory::SceneryGroup, 0); + auto tmpItem = ResearchItem(Research::EntryType::Scenery, entryIndex, 0, ResearchCategory::SceneryGroup, 0); research_insert(std::move(tmpItem), researched); return true; } diff --git a/src/openrct2/management/Research.h b/src/openrct2/management/Research.h index 91aab67307..99a1d3c867 100644 --- a/src/openrct2/management/Research.h +++ b/src/openrct2/management/Research.h @@ -117,13 +117,20 @@ struct ResearchItem } else { - entryIndex = RCTEntryIndexToOpenRCT2EntryIndex(oldResearchItem.entryIndex); - auto* rideEntry = get_ride_entry(entryIndex); - baseRideType = rideEntry != nullptr ? RCT2RideTypeToOpenRCT2RideType(oldResearchItem.baseRideType, rideEntry) - : oldResearchItem.baseRideType; type = Research::EntryType{ oldResearchItem.type }; + entryIndex = RCTEntryIndexToOpenRCT2EntryIndex(oldResearchItem.entryIndex); flags = oldResearchItem.flags; category = static_cast(oldResearchItem.category); + if (type == Research::EntryType::Ride) + { + auto* rideEntry = get_ride_entry(entryIndex); + baseRideType = rideEntry != nullptr ? RCT2RideTypeToOpenRCT2RideType(oldResearchItem.baseRideType, rideEntry) + : oldResearchItem.baseRideType; + } + else + { + baseRideType = 0; + } } } diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 6f6bc9d4b1..56e036a7e2 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -2289,6 +2289,7 @@ namespace RCT1 dst->entryIndex = entryIndex; dst->type = Research::EntryType::Scenery; dst->category = ResearchCategory::SceneryGroup; + dst->baseRideType = 0; dst->flags = 0; } }