mirror of https://github.com/OpenRCT2/OpenRCT2.git
Protect against Sources being null
This commit is contained in:
parent
8ff6831c57
commit
edaebd5163
|
@ -1090,7 +1090,7 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf
|
|||
y += 12;
|
||||
|
||||
// Draw object source
|
||||
stringId = object_manager_get_source_game_string(listItem->repositoryItem->Sources[0]);
|
||||
stringId = object_manager_get_source_game_string(listItem->repositoryItem->GetFirstSourceGame());
|
||||
gfx_draw_string_right(dpi, stringId, nullptr, COLOUR_WHITE, w->x + w->width - 5, y);
|
||||
y += 12;
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ void BannerObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
|
|||
auto item = objectRepository.FindObject(identifier);
|
||||
if (item != nullptr)
|
||||
{
|
||||
auto sourceGame = item->Sources[0];
|
||||
auto sourceGame = item->GetFirstSourceGame();
|
||||
if (sourceGame == OBJECT_SOURCE_WACKY_WORLDS
|
||||
|| sourceGame == OBJECT_SOURCE_TIME_TWISTER
|
||||
|| sourceGame == OBJECT_SOURCE_CUSTOM)
|
||||
|
|
|
@ -51,7 +51,7 @@ void FootpathItemObject::ReadLegacy(IReadObjectContext* context, IStream* stream
|
|||
auto item = objectRepository.FindObject(identifier);
|
||||
if (item != nullptr)
|
||||
{
|
||||
auto sourceGame = item->Sources[0];
|
||||
auto sourceGame = item->GetFirstSourceGame();
|
||||
if (sourceGame == OBJECT_SOURCE_WACKY_WORLDS || sourceGame == OBJECT_SOURCE_TIME_TWISTER
|
||||
|| sourceGame == OBJECT_SOURCE_CUSTOM)
|
||||
{
|
||||
|
|
|
@ -49,6 +49,14 @@ struct ObjectRepositoryItem
|
|||
{
|
||||
std::vector<rct_object_entry> Entries;
|
||||
} SceneryGroupInfo;
|
||||
|
||||
OBJECT_SOURCE_GAME GetFirstSourceGame() const
|
||||
{
|
||||
if (Sources.empty())
|
||||
return OBJECT_SOURCE_CUSTOM;
|
||||
else
|
||||
return (OBJECT_SOURCE_GAME)Sources[0];
|
||||
}
|
||||
};
|
||||
|
||||
interface IObjectRepository
|
||||
|
|
Loading…
Reference in New Issue