1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-13 17:49:10 +00:00

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:
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

@@ -363,7 +363,6 @@ protected:
if (this->num_on_x_axis == 0) return;
assert(this->num_on_x_axis > 0);
assert(this->num_dataset > 0);
/* draw text strings on the y axis */
int64_t y_label = interval.highest;
@@ -923,6 +922,8 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
return;
}
size->height = FONT_HEIGHT_SMALL + WidgetDimensions::scaled.framerect.Vertical();
for (const CargoSpec *cs : _sorted_standard_cargo_specs) {
SetDParam(0, cs->name);
Dimension d = GetStringBoundingBox(STR_GRAPH_CARGO_PAYMENT_CARGO);
@@ -1077,7 +1078,7 @@ static const NWidgetPart _nested_cargo_payment_rates_widgets[] = {
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_CPR_DISABLE_CARGOES), SetDataTip(STR_GRAPH_CARGO_DISABLE_ALL, STR_GRAPH_CARGO_TOOLTIP_DISABLE_ALL), SetFill(1, 0),
NWidget(NWID_SPACER), SetMinimalSize(0, 4),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_MATRIX, COLOUR_BROWN, WID_CPR_MATRIX), SetResize(0, 2), SetMatrixDataTip(1, 0, STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO), SetScrollbar(WID_CPR_MATRIX_SCROLLBAR),
NWidget(WWT_MATRIX, COLOUR_BROWN, WID_CPR_MATRIX), SetFill(1, 0), SetResize(0, 2), SetMatrixDataTip(1, 0, STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO), SetScrollbar(WID_CPR_MATRIX_SCROLLBAR),
NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_CPR_MATRIX_SCROLLBAR),
EndContainer(),
NWidget(NWID_SPACER), SetMinimalSize(0, 24), SetFill(0, 1),