Fix misc scenery not marked as invented

This commit is contained in:
Ted John 2021-11-21 14:49:13 +00:00 committed by Gymnasiast
parent d63b57c359
commit 915e6447f9
No known key found for this signature in database
GPG Key ID: DBFFF47AB2CA3EDD
3 changed files with 24 additions and 2 deletions

View File

@ -794,6 +794,7 @@ static void ResearchRebuildInventedTables()
research_mark_item_as_researched(item);
}
MarkAllUnrestrictedSceneryAsInvented();
}
static void ResearchAddAllMissingItems(bool isResearched)

View File

@ -370,8 +370,9 @@ std::vector<ScenerySelection>& GetRestrictedScenery()
return _restrictedScenery;
}
void RestrictAllMiscScenery()
static std::vector<ScenerySelection> GetAllMiscScenery()
{
std::vector<ScenerySelection> miscScenery;
std::vector<ScenerySelection> nonMiscScenery;
for (ObjectEntryIndex i = 0; i < MAX_SCENERY_GROUP_OBJECTS; i++)
{
@ -395,11 +396,30 @@ void RestrictAllMiscScenery()
{
if (std::find(std::begin(nonMiscScenery), std::end(nonMiscScenery), sceneryItem) == std::end(nonMiscScenery))
{
_restrictedScenery.push_back(sceneryItem);
miscScenery.push_back(sceneryItem);
}
}
}
}
return miscScenery;
}
void RestrictAllMiscScenery()
{
auto miscScenery = GetAllMiscScenery();
_restrictedScenery.insert(_restrictedScenery.begin(), miscScenery.begin(), miscScenery.end());
}
void MarkAllUnrestrictedSceneryAsInvented()
{
auto miscScenery = GetAllMiscScenery();
for (const auto& sceneryItem : miscScenery)
{
if (std::find(_restrictedScenery.begin(), _restrictedScenery.end(), sceneryItem) == _restrictedScenery.end())
{
scenery_set_invented(sceneryItem);
}
}
}
ObjectType GetObjectTypeFromSceneryType(uint8_t type)

View File

@ -300,6 +300,7 @@ bool IsSceneryAvailableToBuild(const ScenerySelection& item);
bool IsSceneryItemRestricted(const ScenerySelection& item);
void ClearRestrictedScenery();
void RestrictAllMiscScenery();
void MarkAllUnrestrictedSceneryAsInvented();
std::vector<ScenerySelection>& GetRestrictedScenery();
ObjectType GetObjectTypeFromSceneryType(uint8_t type);