From 889e888ac35675c653b66e901ca9aa0c88923969 Mon Sep 17 00:00:00 2001 From: Ted John Date: Tue, 1 Oct 2019 21:30:11 +0100 Subject: [PATCH] Fix output result of remove_unused_objects (#10029) --- src/openrct2/EditorObjectSelectionSession.cpp | 25 +++++++++++-------- src/openrct2/peep/Staff.cpp | 2 ++ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/openrct2/EditorObjectSelectionSession.cpp b/src/openrct2/EditorObjectSelectionSession.cpp index 54a30733578e..14a4bf90ba66 100644 --- a/src/openrct2/EditorObjectSelectionSession.cpp +++ b/src/openrct2/EditorObjectSelectionSession.cpp @@ -530,20 +530,23 @@ int32_t editor_remove_unused_objects() int32_t numUnselectedObjects = 0; for (int32_t i = 0; i < numObjects; i++) { - if (!(_objectSelectionFlags[i] & OBJECT_SELECTION_FLAG_IN_USE) - && !(_objectSelectionFlags[i] & OBJECT_SELECTION_FLAG_ALWAYS_REQUIRED)) + if (_objectSelectionFlags[i] & OBJECT_SELECTION_FLAG_SELECTED) { - const ObjectRepositoryItem* item = &items[i]; - uint8_t objectType = object_entry_get_type(&item->ObjectEntry); - - if (objectType >= OBJECT_TYPE_SCENERY_GROUP) + if (!(_objectSelectionFlags[i] & OBJECT_SELECTION_FLAG_IN_USE) + && !(_objectSelectionFlags[i] & OBJECT_SELECTION_FLAG_ALWAYS_REQUIRED)) { - continue; - } + const ObjectRepositoryItem* item = &items[i]; + uint8_t objectType = object_entry_get_type(&item->ObjectEntry); - _numSelectedObjectsForType[objectType]--; - _objectSelectionFlags[i] &= ~OBJECT_SELECTION_FLAG_SELECTED; - numUnselectedObjects++; + if (objectType >= OBJECT_TYPE_SCENERY_GROUP) + { + continue; + } + + _numSelectedObjectsForType[objectType]--; + _objectSelectionFlags[i] &= ~OBJECT_SELECTION_FLAG_SELECTED; + numUnselectedObjects++; + } } } unload_unselected_objects(); diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index bbbb63fbbff3..63769dd5fcc2 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -1714,6 +1714,8 @@ static int32_t peep_update_patrolling_find_bin(Peep* peep) if (!tileElement->AsPath()->HasAddition()) return 0; rct_scenery_entry* sceneryEntry = tileElement->AsPath()->GetAdditionEntry(); + if (sceneryEntry == nullptr) + return 0; if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BIN)) return 0;