summaryrefslogtreecommitdiff
path: root/src/vehicle_gui.cpp
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2011-04-22 21:51:34 +0000
committeryexo <yexo@openttd.org>2011-04-22 21:51:34 +0000
commitd30a9ea6a22f5da5c3be49a454012279730af91a (patch)
treec3cd44f3f08ee0ee0a175d689154b0084e19a5bf /src/vehicle_gui.cpp
parent380d4b277b84e3205d557d289bc8ca5bdd22dafc (diff)
downloadopenttd-d30a9ea6a22f5da5c3be49a454012279730af91a.tar.xz
(svn r22373) -Fix (r19955) (r20041) [FS#4592]: crash when clicking a removed company in the vehiclelist dropdowns
Diffstat (limited to 'src/vehicle_gui.cpp')
-rw-r--r--src/vehicle_gui.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 211c0611a..af325a917 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -1635,16 +1635,7 @@ static WindowDesc _vehicle_list_desc(
static void ShowVehicleListWindowLocal(CompanyID company, VehicleListType vlt, VehicleType vehicle_type, uint16 unique_number)
{
- if (!Company::IsValidID(company)) {
- 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;
- }
+ if (!Company::IsValidID(company)) return;
_vehicle_list_desc.cls = GetWindowClassForVehicleType(vehicle_type);
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)
{
+ 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);
}