Change: Invalidate build toolbars when NewGRFs are changed.

If NewGRFs are changed while a rail or road toolbar is open, the toolbar could refer to an invalid rail/road type. If so, close it.
This commit is contained in:
Peter Nelson
2024-10-22 23:48:43 +01:00
committed by Peter Nelson
parent 6d2b93d3b3
commit db1a1c5dd9
3 changed files with 15 additions and 0 deletions
+7
View File
@@ -377,6 +377,13 @@ struct BuildRoadToolbarWindow : Window {
void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
{
if (!gui_scope) return;
if (!ValParamRoadType(this->roadtype)) {
/* Close toolbar if road type is not available. */
this->Close();
return;
}
RoadTramType rtt = GetRoadTramType(this->roadtype);
bool can_build = CanBuildVehicleInfrastructure(VEH_ROAD, rtt);