mirror of https://github.com/OpenTTD/OpenTTD
(svn r14097) -Fix [FS#2085]: one couldn't get a list of vehicles sharing an order when the number of orders was 0; you could see that the vehicles had a shared order though.
parent
abd9f74871
commit
99efe9aaae
|
@ -596,25 +596,6 @@ static CommandCost DecloneOrder(Vehicle *dst, uint32 flags)
|
||||||
return CommandCost();
|
return CommandCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove the VehicleList that shows all the vehicles with the same shared
|
|
||||||
* orders.
|
|
||||||
*/
|
|
||||||
void RemoveSharedOrderVehicleList(Vehicle *v)
|
|
||||||
{
|
|
||||||
assert(v->orders != NULL);
|
|
||||||
WindowClass window_class = WC_NONE;
|
|
||||||
|
|
||||||
switch (v->type) {
|
|
||||||
default: NOT_REACHED();
|
|
||||||
case VEH_TRAIN: window_class = WC_TRAINS_LIST; break;
|
|
||||||
case VEH_ROAD: window_class = WC_ROADVEH_LIST; break;
|
|
||||||
case VEH_SHIP: window_class = WC_SHIPS_LIST; break;
|
|
||||||
case VEH_AIRCRAFT: window_class = WC_AIRCRAFT_LIST; break;
|
|
||||||
}
|
|
||||||
DeleteWindowById(window_class, (v->orders->index << 16) | (v->type << 11) | VLW_SHARED_ORDERS | v->owner);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Delete an order from the orderlist of a vehicle.
|
/** Delete an order from the orderlist of a vehicle.
|
||||||
* @param tile unused
|
* @param tile unused
|
||||||
* @param flags operation to perform
|
* @param flags operation to perform
|
||||||
|
@ -650,10 +631,6 @@ CommandCost CmdDeleteOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
order = GetVehicleOrder(v, sel_ord + 1);
|
order = GetVehicleOrder(v, sel_ord + 1);
|
||||||
SwapOrders(v->orders, order);
|
SwapOrders(v->orders, order);
|
||||||
} else {
|
} else {
|
||||||
/* XXX -- The system currently can't handle a shared-order vehicle list
|
|
||||||
* open when there aren't any orders in the list, so close the window
|
|
||||||
* in this case. Of course it needs a better fix later */
|
|
||||||
RemoveSharedOrderVehicleList(v);
|
|
||||||
/* Last item, so clean the list */
|
/* Last item, so clean the list */
|
||||||
v->orders = NULL;
|
v->orders = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -654,7 +654,7 @@ public:
|
||||||
this->SetWidgetDisabledState(ORDER_WIDGET_UNLOAD, order == NULL || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) != 0); // unload
|
this->SetWidgetDisabledState(ORDER_WIDGET_UNLOAD, order == NULL || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) != 0); // unload
|
||||||
this->SetWidgetDisabledState(ORDER_WIDGET_UNLOAD_DROPDOWN, this->IsWidgetDisabled(ORDER_WIDGET_UNLOAD));
|
this->SetWidgetDisabledState(ORDER_WIDGET_UNLOAD_DROPDOWN, this->IsWidgetDisabled(ORDER_WIDGET_UNLOAD));
|
||||||
/* Disable list of vehicles with the same shared orders if there is no list */
|
/* Disable list of vehicles with the same shared orders if there is no list */
|
||||||
this->SetWidgetDisabledState(ORDER_WIDGET_SHARED_ORDER_LIST, !shared_orders || this->vehicle->orders == NULL);
|
this->SetWidgetDisabledState(ORDER_WIDGET_SHARED_ORDER_LIST, !shared_orders);
|
||||||
this->SetWidgetDisabledState(ORDER_WIDGET_REFIT, order == NULL); // Refit
|
this->SetWidgetDisabledState(ORDER_WIDGET_REFIT, order == NULL); // Refit
|
||||||
this->SetWidgetDisabledState(ORDER_WIDGET_SERVICE, order == NULL); // Refit
|
this->SetWidgetDisabledState(ORDER_WIDGET_SERVICE, order == NULL); // Refit
|
||||||
this->HideWidget(ORDER_WIDGET_REFIT); // Refit
|
this->HideWidget(ORDER_WIDGET_REFIT); // Refit
|
||||||
|
|
|
@ -2614,11 +2614,15 @@ void Vehicle::RemoveFromShared()
|
||||||
|
|
||||||
if (this->next_shared != NULL) this->next_shared->previous_shared = this->previous_shared;
|
if (this->next_shared != NULL) this->next_shared->previous_shared = this->previous_shared;
|
||||||
|
|
||||||
|
uint32 old_window_number = (this->FirstShared()->index << 16) | (this->type << 11) | VLW_SHARED_ORDERS | this->owner;
|
||||||
|
|
||||||
if (new_first->NextShared() == NULL) {
|
if (new_first->NextShared() == NULL) {
|
||||||
/* When there is only one vehicle, remove the shared order list window. */
|
/* When there is only one vehicle, remove the shared order list window. */
|
||||||
extern void RemoveSharedOrderVehicleList(Vehicle *v);
|
DeleteWindowById(GetWindowClassForVehicleType(this->type), old_window_number);
|
||||||
if (new_first->orders != NULL) RemoveSharedOrderVehicleList(new_first);
|
|
||||||
InvalidateVehicleOrder(new_first);
|
InvalidateVehicleOrder(new_first);
|
||||||
|
} else if (this->FirstShared() == this) {
|
||||||
|
/* If we were the first one, update to the new first one. */
|
||||||
|
InvalidateWindowData(GetWindowClassForVehicleType(this->type), old_window_number, (new_first->index << 16) | (1 << 15));
|
||||||
}
|
}
|
||||||
|
|
||||||
this->first_shared = this;
|
this->first_shared = this;
|
||||||
|
|
|
@ -1074,6 +1074,12 @@ struct VehicleListWindow : public Window, public VehicleListBase {
|
||||||
|
|
||||||
virtual void OnInvalidateData(int data)
|
virtual void OnInvalidateData(int data)
|
||||||
{
|
{
|
||||||
|
if (HasBit(data, 15) && (this->window_number & VLW_MASK) == VLW_SHARED_ORDERS) {
|
||||||
|
SB(this->window_number, 16, 16, GB(data, 16, 16));
|
||||||
|
this->vehicles.ForceRebuild();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (data == 0) {
|
if (data == 0) {
|
||||||
this->vehicles.ForceRebuild();
|
this->vehicles.ForceRebuild();
|
||||||
} else {
|
} else {
|
||||||
|
@ -1163,8 +1169,7 @@ void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type)
|
||||||
|
|
||||||
void ShowVehicleListWindow(const Vehicle *v)
|
void ShowVehicleListWindow(const Vehicle *v)
|
||||||
{
|
{
|
||||||
if (v->orders == NULL) return; // no shared list to show
|
ShowVehicleListWindowLocal(v->owner, VLW_SHARED_ORDERS, v->type, v->FirstShared()->index);
|
||||||
ShowVehicleListWindowLocal(v->owner, VLW_SHARED_ORDERS, v->type, v->orders->index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, StationID station)
|
void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, StationID station)
|
||||||
|
|
|
@ -93,15 +93,9 @@ void GenerateVehicleSortList(VehicleList *list, VehicleType type, PlayerID owner
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VLW_SHARED_ORDERS:
|
case VLW_SHARED_ORDERS:
|
||||||
FOR_ALL_VEHICLES(v) {
|
/* Add all vehicles from this vehicle's shared order list */
|
||||||
/* Find a vehicle with the order in question */
|
for (v = GetVehicle(index); v != NULL; v = v->NextShared()) {
|
||||||
if (v->orders != NULL && v->orders->index == index) {
|
*list->Append() = v;
|
||||||
/* Add all vehicles from this vehicle's shared order list */
|
|
||||||
for (v = v->FirstShared(); v != NULL; v = v->NextShared()) {
|
|
||||||
*list->Append() = v;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue