Changeset - r28090:e7e6257eec3d
[Not reviewed]
master
0 2 0
Peter Nelson - 13 months ago 2023-11-04 14:42:47
peter1138@openttd.org
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.
2 files changed with 5 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/graph_gui.cpp
Show inline comments
 
@@ -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 : BaseGra
 
			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_p
 
				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),
src/linkgraph/linkgraph_gui.cpp
Show inline comments
 
@@ -501,7 +501,8 @@ NWidgetBase *MakeCargoesLegendLinkGraphG
 
		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;
 
}
0 comments (0 inline, 0 general)