summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2010-07-02 09:09:40 +0000
committersmatz <smatz@openttd.org>2010-07-02 09:09:40 +0000
commitd7a6ba47810f3b283eb57f4efec4e8ee64325304 (patch)
treebea01d0a0725c8f8b29682fcfe18afffed0729b4
parent7062bb0bd7b1654567b54d55f401fa693d4ff018 (diff)
downloadopenttd-d7a6ba47810f3b283eb57f4efec4e8ee64325304.tar.xz
(svn r20041) -Fix [FS#3892](r19955): crash when spectator tried to open a vehicle list without selecting any company
-rw-r--r--src/vehicle_gui.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 7d9e13e4a..8eb3d66b9 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -1275,8 +1275,12 @@ static WindowDesc _vehicle_list_desc(
static void ShowVehicleListWindowLocal(CompanyID company, uint16 VLW_flag, VehicleType vehicle_type, uint16 unique_number)
{
if (!Company::IsValidID(company)) {
- _vehicle_list_desc.flags |= WDF_CONSTRUCTION;
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;
}