From a663ab6cd2b9f8218cf8809194c9f8ea4a30d0cf Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Mon, 13 Nov 2017 19:28:37 +0100 Subject: [PATCH] Add extra NULL checks --- src/openrct2/object/BannerObject.cpp | 5 ++--- src/openrct2/object/FootpathItemObject.cpp | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/openrct2/object/BannerObject.cpp b/src/openrct2/object/BannerObject.cpp index 6e4fc1f184..fdb8264964 100644 --- a/src/openrct2/object/BannerObject.cpp +++ b/src/openrct2/object/BannerObject.cpp @@ -46,11 +46,10 @@ void BannerObject::ReadLegacy(IReadObjectContext * context, IStream * stream) // Add banners to 'Signs and items for footpaths' group, rather than lumping them in the Miscellaneous tab. // Since this is already done the other way round for original items, avoid adding those to prevent duplicates. const std::string identifier = GetIdentifier(); - uint8 source = object_entry_get_source_game(object_list_find_by_name(identifier.c_str())); - + const rct_object_entry * objectEntry = object_list_find_by_name(identifier.c_str()); static const rct_object_entry * scgPathX = object_list_find_by_name("SCGPATHX"); - if (scgPathX != nullptr && source != OBJECT_SOURCE_RCT2) + if (objectEntry != nullptr && scgPathX != nullptr && object_entry_get_source_game(objectEntry) != OBJECT_SOURCE_RCT2) { SetPrimarySceneryGroup((rct_object_entry *)scgPathX); } diff --git a/src/openrct2/object/FootpathItemObject.cpp b/src/openrct2/object/FootpathItemObject.cpp index aeeb21b06e..33b1fa2656 100644 --- a/src/openrct2/object/FootpathItemObject.cpp +++ b/src/openrct2/object/FootpathItemObject.cpp @@ -47,11 +47,10 @@ void FootpathItemObject::ReadLegacy(IReadObjectContext * context, IStream * stre // Add path bits to 'Signs and items for footpaths' group, rather than lumping them in the Miscellaneous tab. // Since this is already done the other way round for original items, avoid adding those to prevent duplicates. const std::string identifier = GetIdentifier(); - uint8 source = object_entry_get_source_game(object_list_find_by_name(identifier.c_str())); - + const rct_object_entry * objectEntry = object_list_find_by_name(identifier.c_str()); static const rct_object_entry * scgPathX = object_list_find_by_name("SCGPATHX"); - if (scgPathX != nullptr && source != OBJECT_SOURCE_RCT2) + if (objectEntry != nullptr && scgPathX != nullptr && object_entry_get_source_game(objectEntry) != OBJECT_SOURCE_RCT2) { SetPrimarySceneryGroup((rct_object_entry *)scgPathX); }