mirror of https://github.com/OpenTTD/OpenTTD
(svn r22373) -Fix (r19955) (r20041) [FS#4592]: crash when clicking a removed company in the vehiclelist dropdowns
parent
380d4b277b
commit
d30a9ea6a2
|
@ -1635,16 +1635,7 @@ static WindowDesc _vehicle_list_desc(
|
||||||
|
|
||||||
static void ShowVehicleListWindowLocal(CompanyID company, VehicleListType vlt, VehicleType vehicle_type, uint16 unique_number)
|
static void ShowVehicleListWindowLocal(CompanyID company, VehicleListType vlt, VehicleType vehicle_type, uint16 unique_number)
|
||||||
{
|
{
|
||||||
if (!Company::IsValidID(company)) {
|
if (!Company::IsValidID(company)) return;
|
||||||
company = _local_company;
|
|
||||||
/* This can happen when opening the vehicle list as a spectator.
|
|
||||||
* While it would be cleaner to check this somewhere else, having
|
|
||||||
* it here reduces code duplication */
|
|
||||||
if (!Company::IsValidID(company)) return;
|
|
||||||
_vehicle_list_desc.flags |= WDF_CONSTRUCTION;
|
|
||||||
} else {
|
|
||||||
_vehicle_list_desc.flags &= ~WDF_CONSTRUCTION;
|
|
||||||
}
|
|
||||||
|
|
||||||
_vehicle_list_desc.cls = GetWindowClassForVehicleType(vehicle_type);
|
_vehicle_list_desc.cls = GetWindowClassForVehicleType(vehicle_type);
|
||||||
AllocateWindowDescFront<VehicleListWindow>(&_vehicle_list_desc, VehicleListIdentifier(vlt, vehicle_type, company, unique_number).Pack());
|
AllocateWindowDescFront<VehicleListWindow>(&_vehicle_list_desc, VehicleListIdentifier(vlt, vehicle_type, company, unique_number).Pack());
|
||||||
|
@ -1671,6 +1662,15 @@ void ShowVehicleListWindow(const Vehicle *v)
|
||||||
|
|
||||||
void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, StationID station)
|
void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, StationID station)
|
||||||
{
|
{
|
||||||
|
if (!Company::IsValidID(company)) {
|
||||||
|
company = _local_company;
|
||||||
|
/* This can happen when opening the vehicle list as a spectator. */
|
||||||
|
if (!Company::IsValidID(company)) return;
|
||||||
|
_vehicle_list_desc.flags |= WDF_CONSTRUCTION;
|
||||||
|
} else {
|
||||||
|
_vehicle_list_desc.flags &= ~WDF_CONSTRUCTION;
|
||||||
|
}
|
||||||
|
|
||||||
ShowVehicleListWindowLocal(company, VL_STATION_LIST, vehicle_type, station);
|
ShowVehicleListWindowLocal(company, VL_STATION_LIST, vehicle_type, station);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue