(svn r16936) -Fix [FS#3053]: Rail station build window with NewGRFs could crash due to uninitialized string parameter.

pull/155/head
alberth 15 years ago
parent d9cdf0f9b7
commit 8c29d9ee54

@ -1050,7 +1050,6 @@ public:
}
}
SetDParam(0, GetStationClassName(_railstation.station_class));
this->DrawWidgets();
/* 'Accepts' and 'Supplies' texts. */
@ -1066,6 +1065,21 @@ public:
}
}
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *resize)
{
if (widget != BRSW_NEWST_DROPDOWN) return;
Dimension d = {0, 0};
for (uint i = 0; i < GetNumStationClasses(); i++) {
if (i == STAT_CLASS_WAYP) continue;
SetDParam(0, GetStationClassName((StationClassID)i));
d = maxdim(d, GetStringBoundingBox(STR_BLACK_STRING));
}
d.width += padding.width;
d.height += padding.height;
*size = maxdim(*size, d);
}
virtual void DrawWidget(const Rect &r, int widget) const
{
DrawPixelInfo tmp_dpi;
@ -1114,6 +1128,11 @@ public:
}
break;
}
case BRSW_NEWST_DROPDOWN:
SetDParam(0, GetStationClassName(_railstation.station_class));
DrawString(r.left + WD_DROPDOWNTEXT_LEFT, r.right - WD_DROPDOWNTEXT_RIGHT, r.top + WD_DROPDOWNTEXT_TOP, STR_BLACK_STRING, TC_BLACK);
break;
}
}
@ -1353,7 +1372,7 @@ static const NWidgetPart _nested_newstation_builder_widgets[] = {
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BRSW_BACKGROUND),
/* begin newstations gui additions. */
NWidget(NWID_SPACER), SetMinimalSize(0, 3),
NWidget(WWT_DROPDOWN, COLOUR_GREY, BRSW_NEWST_DROPDOWN), SetMinimalSize(134, 12), SetPadding(0, 7, 0, 7), SetDataTip(STR_BLACK_STRING, STR_SELECT_STATION_CLASS_TIP),
NWidget(WWT_DROPDOWN, COLOUR_GREY, BRSW_NEWST_DROPDOWN), SetMinimalSize(134, 12), SetPadding(0, 7, 0, 7), SetDataTip(STR_EMPTY, STR_SELECT_STATION_CLASS_TIP),
NWidget(NWID_SPACER), SetMinimalSize(0, 3),
NWidget(NWID_HORIZONTAL), SetPIP(7, 0, 7),
NWidget(WWT_MATRIX, COLOUR_GREY, BRSW_NEWST_LIST), SetMinimalSize(122, 71), SetDataTip(0x501, STR_SELECT_STATION_TYPE_TIP),

Loading…
Cancel
Save