mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 15:52:55 +01:00
Merge pull request #13938 from janisozaur/nullptr_check
Add nullptr check in get_loaded_object_entry
This commit is contained in:
@@ -138,8 +138,13 @@ const rct_object_entry* get_loaded_object_entry(size_t index)
|
||||
ObjectType objectType;
|
||||
ObjectEntryIndex entryIndex;
|
||||
get_type_entry_index(index, &objectType, &entryIndex);
|
||||
auto obj = object_entry_get_object(objectType, entryIndex);
|
||||
if (obj == nullptr)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return object_entry_get_object(objectType, entryIndex)->GetObjectEntry();
|
||||
return obj->GetObjectEntry();
|
||||
}
|
||||
|
||||
void* get_loaded_object_chunk(size_t index)
|
||||
|
||||
@@ -168,7 +168,7 @@ void S6Exporter::Export()
|
||||
const rct_object_entry* entry = get_loaded_object_entry(i);
|
||||
void* entryData = get_loaded_object_chunk(i);
|
||||
// RCT2 uses (void *)-1 to mark NULL. Make sure it's written in a vanilla-compatible way.
|
||||
if (entryData == nullptr || entryData == reinterpret_cast<void*>(-1))
|
||||
if (entry == nullptr || entryData == nullptr || entryData == reinterpret_cast<void*>(-1))
|
||||
{
|
||||
std::memset(&_s6.objects[i], 0xFF, sizeof(rct_object_entry));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user