Improve bound checking on scenery invention (#11171)

This commit is contained in:
Tulio Leao authored and GitHub committed 2020-04-03 13:31:13 +02:00
1 parent 08d38f3d24
commit 6cf113ae6f
1 file changed
+25 -6
+25 -6
View File
@@ -601,20 +601,39 @@ void ride_entry_set_invented(int32_t rideEntryIndex)
bool scenery_is_invented(const ScenerySelection& sceneryItem)
{
assert(sceneryItem.SceneryType < SCENERY_TYPE_COUNT);
return _researchedSceneryItems[sceneryItem.SceneryType][sceneryItem.EntryIndex];
if (sceneryItem.SceneryType < SCENERY_TYPE_COUNT)
{
return _researchedSceneryItems[sceneryItem.SceneryType][sceneryItem.EntryIndex];
}
else
{
log_warning("Invalid Scenery Type");
return false;
}
}
void scenery_set_invented(const ScenerySelection& sceneryItem)
{
assert(sceneryItem.SceneryType < SCENERY_TYPE_COUNT);
_researchedSceneryItems[sceneryItem.SceneryType][sceneryItem.EntryIndex] = true;
if (sceneryItem.SceneryType < SCENERY_TYPE_COUNT)
{
_researchedSceneryItems[sceneryItem.SceneryType][sceneryItem.EntryIndex] = true;
}
else
{
log_warning("Invalid Scenery Type");
}
}
void scenery_set_not_invented(const ScenerySelection& sceneryItem)
{
assert(sceneryItem.SceneryType < SCENERY_TYPE_COUNT);
_researchedSceneryItems[sceneryItem.SceneryType][sceneryItem.EntryIndex] = false;
if (sceneryItem.SceneryType < SCENERY_TYPE_COUNT)
{
_researchedSceneryItems[sceneryItem.SceneryType][sceneryItem.EntryIndex] = false;
}
else
{
log_warning("Invalid Scenery Type");
}
}
bool scenery_group_is_invented(int32_t sgIndex)