Fix #9545: Crash when all cargo types are disabled. (#11432)

This is not a very useful state, but it's nice to not crash.

Some parts of the game don't (yet) check for cargo types being redefined, that is out-of-scope here.
This commit is contained in:
Peter Nelson
2023-11-04 14:42:47 +00:00
committed by GitHub
parent c059ce0c97
commit bbd64bbe2b
2 changed files with 5 additions and 3 deletions

View File

@@ -501,7 +501,8 @@ NWidgetBase *MakeCargoesLegendLinkGraphGUI(int *biggest_index)
spc->SetResize(0, 0);
col->Add(spc);
}
panel->Add(col);
/* If there are no cargo specs defined, then col won't have been created so don't add it. */
if (col != nullptr) panel->Add(col);
*biggest_index = WID_LGL_CARGO_LAST;
return panel;
}