1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-20 21:43:06 +01:00

Create constructor for ResearchItem

This commit is contained in:
Gymnasiast
2020-04-30 12:34:00 +02:00
parent 73671bbeeb
commit 7bda0c5fd9
2 changed files with 21 additions and 14 deletions

View File

@@ -538,13 +538,9 @@ void research_populate_list_researched()
bool research_insert_ride_entry(uint8_t rideType, ObjectEntryIndex entryIndex, uint8_t category, bool researched)
{
if (rideType != RIDE_TYPE_NULL)
if (rideType != RIDE_TYPE_NULL && entryIndex != OBJECT_ENTRY_INDEX_NULL)
{
ResearchItem tmpItem = {};
tmpItem.type = RESEARCH_ENTRY_TYPE_RIDE;
tmpItem.baseRideType = rideType;
tmpItem.entryIndex = entryIndex;
tmpItem.category = category;
auto tmpItem = ResearchItem(RESEARCH_ENTRY_TYPE_RIDE, entryIndex, rideType, category, 0);
research_insert(tmpItem, researched);
return true;
}
@@ -562,13 +558,16 @@ void research_insert_ride_entry(ObjectEntryIndex entryIndex, bool researched)
}
}
void research_insert_scenery_group_entry(ObjectEntryIndex entryIndex, bool researched)
bool research_insert_scenery_group_entry(ObjectEntryIndex entryIndex, bool researched)
{
ResearchItem tmpItem = {};
tmpItem.type = RESEARCH_ENTRY_TYPE_SCENERY;
tmpItem.entryIndex = entryIndex;
tmpItem.category = RESEARCH_CATEGORY_SCENERY_GROUP;
research_insert(tmpItem, researched);
if (entryIndex != OBJECT_ENTRY_INDEX_NULL)
{
auto tmpItem = ResearchItem(
RESEARCH_ENTRY_TYPE_SCENERY, entryIndex, RIDE_TYPE_NULL, RESEARCH_CATEGORY_SCENERY_GROUP, 0);
research_insert(tmpItem, researched);
return true;
}
return false;
}
bool ride_type_is_invented(uint32_t rideType)

View File

@@ -40,12 +40,20 @@ struct ResearchItem
rct_string_id GetName() const;
ResearchItem() = default;
constexpr ResearchItem(uint32_t _rawValue, uint8_t _flags, uint8_t _category)
constexpr ResearchItem(uint32_t _rawValue, uint8_t _category, uint8_t _flags)
: rawValue(_rawValue)
, flags(_flags)
, category(_category)
{
}
ResearchItem(uint8_t _type, ObjectEntryIndex _entryIndex, uint8_t _baseRideType, uint8_t _category, uint8_t _flags)
: entryIndex(_entryIndex)
, baseRideType(_baseRideType)
, type(_type)
, flags(_flags)
, category(_category)
{
}
RCT12ResearchItem ToRCT12ResearchItem() const
{
@@ -161,7 +169,7 @@ void research_remove(ResearchItem* researchItem);
bool research_insert_ride_entry(uint8_t rideType, ObjectEntryIndex entryIndex, uint8_t category, bool researched);
void research_insert_ride_entry(ObjectEntryIndex entryIndex, bool researched);
void research_insert_scenery_group_entry(ObjectEntryIndex entryIndex, bool researched);
bool research_insert_scenery_group_entry(ObjectEntryIndex entryIndex, bool researched);
void ride_type_set_invented(uint32_t rideType);
void ride_entry_set_invented(int32_t rideEntryIndex);