summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-05-16 22:08:46 +0000
committerfrosch <frosch@openttd.org>2012-05-16 22:08:46 +0000
commitdb09f6767465aebe8e90bbe8dd65aa50aafcbc94 (patch)
tree4efa361cae2e7ddc074b5c04de63b6e0b37d274b
parentc94a2d52896964f16f3f972c115bbb687861ab1c (diff)
downloadopenttd-db09f6767465aebe8e90bbe8dd65aa50aafcbc94.tar.xz
(svn r24260) -Change [FS#5126]: Make the oilrig-vehicle list accessible to specators and colour it's caption neutrally grey.
-rw-r--r--src/station_gui.cpp8
-rw-r--r--src/vehicle_gui.cpp14
-rw-r--r--src/vehiclelist.cpp8
3 files changed, 12 insertions, 18 deletions
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index 6d758fdcf..6ebbfaaac 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -854,8 +854,6 @@ struct StationViewWindow : public Window {
~StationViewWindow()
{
Owner owner = Station::Get(this->window_number)->owner;
- if (!Company::IsValidID(owner)) owner = _local_company;
- if (!Company::IsValidID(owner)) return; // Spectators
DeleteWindowById(WC_TRAINS_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_TRAIN, owner, this->window_number).Pack(), false);
DeleteWindowById(WC_ROADVEH_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_ROAD, owner, this->window_number).Pack(), false);
DeleteWindowById(WC_SHIPS_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_SHIP, owner, this->window_number).Pack(), false);
@@ -1162,9 +1160,11 @@ struct StationViewWindow : public Window {
case WID_SV_TRAINS: // Show list of scheduled trains to this station
case WID_SV_ROADVEHS: // Show list of scheduled road-vehicles to this station
case WID_SV_SHIPS: // Show list of scheduled ships to this station
- case WID_SV_PLANES: // Show list of scheduled aircraft to this station
- ShowVehicleListWindow(this->owner, (VehicleType)(widget - WID_SV_TRAINS), (StationID)this->window_number);
+ case WID_SV_PLANES: { // Show list of scheduled aircraft to this station
+ Owner owner = Station::Get(this->window_number)->owner;
+ ShowVehicleListWindow(owner, (VehicleType)(widget - WID_SV_TRAINS), (StationID)this->window_number);
break;
+ }
}
}
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 81f85f534..353d710b0 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -1358,7 +1358,7 @@ public:
}
this->FinishInitNested(desc, window_number);
- this->owner = this->vli.company;
+ if (this->vli.company != OWNER_NONE) this->owner = this->vli.company;
if (this->vli.vtype == VEH_TRAIN) ResizeWindow(this, 65, 0);
}
@@ -1609,7 +1609,7 @@ static WindowDesc _vehicle_list_desc(
static void ShowVehicleListWindowLocal(CompanyID company, VehicleListType vlt, VehicleType vehicle_type, uint16 unique_number)
{
- if (!Company::IsValidID(company)) return;
+ if (!Company::IsValidID(company) && company != OWNER_NONE) return;
_vehicle_list_desc.cls = GetWindowClassForVehicleType(vehicle_type);
AllocateWindowDescFront<VehicleListWindow>(&_vehicle_list_desc, VehicleListIdentifier(vlt, vehicle_type, company, unique_number).Pack());
@@ -1636,15 +1636,7 @@ 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;
- }
-
+ _vehicle_list_desc.flags &= ~WDF_CONSTRUCTION;
ShowVehicleListWindowLocal(company, VL_STATION_LIST, vehicle_type, station);
}
diff --git a/src/vehiclelist.cpp b/src/vehiclelist.cpp
index 4fc0f9ff3..b099d7a84 100644
--- a/src/vehiclelist.cpp
+++ b/src/vehiclelist.cpp
@@ -19,12 +19,13 @@
*/
uint32 VehicleListIdentifier::Pack()
{
- assert(this->company < (1 << 4));
+ byte c = this->company == OWNER_NONE ? 0xF : (byte)this->company;
+ assert(c < (1 << 4));
assert(this->type < (1 << 3));
assert(this->vtype < (1 << 2));
assert(this->index < (1 << 20));
- return this->company << 28 | this->type << 23 | this->vtype << 26 | this->index;
+ return c << 28 | this->type << 23 | this->vtype << 26 | this->index;
}
/**
@@ -34,7 +35,8 @@ uint32 VehicleListIdentifier::Pack()
*/
bool VehicleListIdentifier::Unpack(uint32 data)
{
- this->company = (CompanyID)GB(data, 28, 4);
+ byte c = GB(data, 28, 4);
+ this->company = c == 0xF ? OWNER_NONE : (CompanyID)c;
this->type = (VehicleListType)GB(data, 23, 3);
this->vtype = (VehicleType)GB(data, 26, 2);
this->index = GB(data, 0, 20);