mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r25041) -Remove [FS#3764-ish]: ordered refit with subtypes, since the cases where it worked were corner cases rather than the general case.
This commit is contained in:
parent
205543f727
commit
22bb015f3d
|
@ -1441,7 +1441,6 @@ static void LoadUnloadVehicle(Vehicle *front)
|
|||
(v->type != VEH_AIRCRAFT || (Aircraft::From(v)->IsNormalAircraft() && v->Next()->cargo.Count() == 0))) {
|
||||
Vehicle *v_start = v->GetFirstEnginePart();
|
||||
CargoID new_cid = front->current_order.GetRefitCargo();
|
||||
byte new_subtype = front->current_order.GetRefitSubtype();
|
||||
|
||||
/* Remove old capacity from consist capacity */
|
||||
consist_capleft[v_start->cargo_type] -= v_start->cargo_cap;
|
||||
|
@ -1471,8 +1470,7 @@ static void LoadUnloadVehicle(Vehicle *front)
|
|||
if ((int)st->goods[cid].cargo.Count() > (int)consist_capleft[cid] + amount) {
|
||||
/* Try to find out if auto-refitting would succeed. In case the refit is allowed,
|
||||
* the returned refit capacity will be greater than zero. */
|
||||
new_subtype = GetBestFittingSubType(v, v, cid);
|
||||
DoCommand(v_start->tile, v_start->index, cid | 1U << 6 | new_subtype << 8 | 1U << 16, DC_QUERY_COST, GetCmdRefitVeh(v_start)); // Auto-refit and only this vehicle including artic parts.
|
||||
DoCommand(v_start->tile, v_start->index, cid | 1U << 6 | 0xFF << 8 | 1U << 16, DC_QUERY_COST, GetCmdRefitVeh(v_start)); // Auto-refit and only this vehicle including artic parts.
|
||||
if (_returned_refit_capacity > 0) {
|
||||
amount = st->goods[cid].cargo.Count() - consist_capleft[cid];
|
||||
new_cid = cid;
|
||||
|
@ -1483,7 +1481,7 @@ static void LoadUnloadVehicle(Vehicle *front)
|
|||
|
||||
/* Refit if given a valid cargo. */
|
||||
if (new_cid < NUM_CARGO) {
|
||||
CommandCost cost = DoCommand(v_start->tile, v_start->index, new_cid | 1U << 6 | new_subtype << 8 | 1U << 16, DC_EXEC, GetCmdRefitVeh(v_start)); // Auto-refit and only this vehicle including artic parts.
|
||||
CommandCost cost = DoCommand(v_start->tile, v_start->index, new_cid | 1U << 6 | 0xFF << 8 | 1U << 16, DC_EXEC, GetCmdRefitVeh(v_start)); // Auto-refit and only this vehicle including artic parts.
|
||||
if (cost.Succeeded()) front->profit_this_year -= cost.GetCost() << 8;
|
||||
ge = &st->goods[v->cargo_type];
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ private:
|
|||
DestinationID dest; ///< The destination of the order.
|
||||
|
||||
CargoID refit_cargo; ///< Refit CargoID
|
||||
byte refit_subtype; ///< Refit subtype
|
||||
|
||||
public:
|
||||
Order *next; ///< Pointer to next order. If NULL, end of list
|
||||
|
@ -72,7 +71,7 @@ public:
|
|||
void Free();
|
||||
|
||||
void MakeGoToStation(StationID destination);
|
||||
void MakeGoToDepot(DepotID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type = ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS, OrderDepotActionFlags action = ODATF_SERVICE_ONLY, CargoID cargo = CT_NO_REFIT, byte subtype = 0);
|
||||
void MakeGoToDepot(DepotID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type = ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS, OrderDepotActionFlags action = ODATF_SERVICE_ONLY, CargoID cargo = CT_NO_REFIT);
|
||||
void MakeGoToWaypoint(StationID destination);
|
||||
void MakeLoading(bool ordered);
|
||||
void MakeLeaveStation();
|
||||
|
@ -124,14 +123,7 @@ public:
|
|||
*/
|
||||
inline CargoID GetRefitCargo() const { return this->refit_cargo; }
|
||||
|
||||
/**
|
||||
* Get the cargo subtype to to refit to.
|
||||
* @pre IsType(OT_GOTO_DEPOT) || IsType(OT_GOTO_STATION)
|
||||
* @return the cargo subtype.
|
||||
*/
|
||||
inline byte GetRefitSubtype() const { return this->refit_subtype; }
|
||||
|
||||
void SetRefit(CargoID cargo, byte subtype = 0);
|
||||
void SetRefit(CargoID cargo);
|
||||
|
||||
/** How must the consist be loaded? */
|
||||
inline OrderLoadFlags GetLoadType() const { return (OrderLoadFlags)GB(this->flags, 4, 4); }
|
||||
|
|
|
@ -83,16 +83,15 @@ void Order::MakeGoToStation(StationID destination)
|
|||
* @param non_stop_type how to get to the depot?
|
||||
* @param action what to do in the depot?
|
||||
* @param cargo the cargo type to change to.
|
||||
* @param subtype the subtype to change to.
|
||||
*/
|
||||
void Order::MakeGoToDepot(DepotID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type, OrderDepotActionFlags action, CargoID cargo, byte subtype)
|
||||
void Order::MakeGoToDepot(DepotID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type, OrderDepotActionFlags action, CargoID cargo)
|
||||
{
|
||||
this->type = OT_GOTO_DEPOT;
|
||||
this->SetDepotOrderType(order);
|
||||
this->SetDepotActionType(action);
|
||||
this->SetNonStopType(non_stop_type);
|
||||
this->dest = destination;
|
||||
this->SetRefit(cargo, subtype);
|
||||
this->SetRefit(cargo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -158,13 +157,11 @@ void Order::MakeImplicit(StationID destination)
|
|||
/**
|
||||
* Make this depot/station order also a refit order.
|
||||
* @param cargo the cargo type to change to.
|
||||
* @param subtype the subtype to change to.
|
||||
* @pre IsType(OT_GOTO_DEPOT) || IsType(OT_GOTO_STATION).
|
||||
*/
|
||||
void Order::SetRefit(CargoID cargo, byte subtype)
|
||||
void Order::SetRefit(CargoID cargo)
|
||||
{
|
||||
this->refit_cargo = cargo;
|
||||
this->refit_subtype = subtype;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -238,7 +235,6 @@ Order::Order(uint32 packed)
|
|||
this->dest = GB(packed, 16, 16);
|
||||
this->next = NULL;
|
||||
this->refit_cargo = CT_NO_REFIT;
|
||||
this->refit_subtype = 0;
|
||||
this->wait_time = 0;
|
||||
this->travel_time = 0;
|
||||
this->max_speed = UINT16_MAX;
|
||||
|
@ -278,7 +274,6 @@ void Order::AssignOrder(const Order &other)
|
|||
this->dest = other.dest;
|
||||
|
||||
this->refit_cargo = other.refit_cargo;
|
||||
this->refit_subtype = other.refit_subtype;
|
||||
|
||||
this->wait_time = other.wait_time;
|
||||
this->travel_time = other.travel_time;
|
||||
|
@ -1587,7 +1582,6 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
|||
* @param p1 VehicleIndex of the vehicle having the order
|
||||
* @param p2 bitmask
|
||||
* - bit 0-7 CargoID
|
||||
* - bit 8-15 Cargo subtype
|
||||
* - bit 16-23 number of order to modify
|
||||
* @param text unused
|
||||
* @return the cost of this operation or an error
|
||||
|
@ -1597,7 +1591,6 @@ CommandCost CmdOrderRefit(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
|||
VehicleID veh = GB(p1, 0, 20);
|
||||
VehicleOrderID order_number = GB(p2, 16, 8);
|
||||
CargoID cargo = GB(p2, 0, 8);
|
||||
byte subtype = GB(p2, 8, 8);
|
||||
|
||||
if (cargo >= NUM_CARGO && cargo != CT_NO_REFIT && cargo != CT_AUTO_REFIT) return CMD_ERROR;
|
||||
|
||||
|
@ -1616,7 +1609,7 @@ CommandCost CmdOrderRefit(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
|||
if (order->GetLoadType() & OLFB_NO_LOAD) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
order->SetRefit(cargo, subtype);
|
||||
order->SetRefit(cargo);
|
||||
|
||||
/* Make the depot order an 'always go' order. */
|
||||
if (cargo != CT_NO_REFIT && order->IsType(OT_GOTO_DEPOT)) {
|
||||
|
@ -1630,7 +1623,7 @@ CommandCost CmdOrderRefit(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
|||
|
||||
/* If the vehicle already got the current depot set as current order, then update current order as well */
|
||||
if (u->cur_real_order_index == order_number && (u->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS)) {
|
||||
u->current_order.SetRefit(cargo, subtype);
|
||||
u->current_order.SetRefit(cargo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1932,7 +1925,7 @@ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth, bool
|
|||
if (pbs_look_ahead && reverse) return false;
|
||||
|
||||
v->dest_tile = location;
|
||||
v->current_order.MakeGoToDepot(destination, v->current_order.GetDepotOrderType(), v->current_order.GetNonStopType(), (OrderDepotActionFlags)(v->current_order.GetDepotActionType() & ~ODATFB_NEAREST_DEPOT), v->current_order.GetRefitCargo(), v->current_order.GetRefitSubtype());
|
||||
v->current_order.MakeGoToDepot(destination, v->current_order.GetDepotOrderType(), v->current_order.GetNonStopType(), (OrderDepotActionFlags)(v->current_order.GetDepotActionType() & ~ODATFB_NEAREST_DEPOT), v->current_order.GetRefitCargo());
|
||||
|
||||
/* If there is no depot in front, reverse automatically (trains only) */
|
||||
if (v->type == VEH_TRAIN && reverse) DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_REVERSE_TRAIN_DIRECTION);
|
||||
|
|
|
@ -107,7 +107,7 @@ const SaveLoad *GetOrderDescription()
|
|||
SLE_VAR(Order, dest, SLE_UINT16),
|
||||
SLE_REF(Order, next, REF_ORDER),
|
||||
SLE_CONDVAR(Order, refit_cargo, SLE_UINT8, 36, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Order, refit_subtype, SLE_UINT8, 36, SL_MAX_VERSION),
|
||||
SLE_CONDNULL(1, 36, 181), // refit_subtype
|
||||
SLE_CONDVAR(Order, wait_time, SLE_UINT16, 67, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Order, travel_time, SLE_UINT16, 67, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Order, max_speed, SLE_UINT16, 172, SL_MAX_VERSION),
|
||||
|
|
|
@ -639,7 +639,7 @@ const SaveLoad *GetVehicleDescription(VehicleType vt)
|
|||
|
||||
/* Refit in current order */
|
||||
SLE_CONDVAR(Vehicle, current_order.refit_cargo, SLE_UINT8, 36, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Vehicle, current_order.refit_subtype, SLE_UINT8, 36, SL_MAX_VERSION),
|
||||
SLE_CONDNULL(1, 36, 181), // refit_subtype
|
||||
|
||||
/* Timetable in current order */
|
||||
SLE_CONDVAR(Vehicle, current_order.wait_time, SLE_UINT16, 67, SL_MAX_VERSION),
|
||||
|
|
|
@ -1367,7 +1367,7 @@ void VehicleEnterDepot(Vehicle *v)
|
|||
|
||||
if (t.IsRefit()) {
|
||||
Backup<CompanyByte> cur_company(_current_company, v->owner, FILE_LINE);
|
||||
CommandCost cost = DoCommand(v->tile, v->index, t.GetRefitCargo() | t.GetRefitSubtype() << 8, DC_EXEC, GetCmdRefitVeh(v));
|
||||
CommandCost cost = DoCommand(v->tile, v->index, t.GetRefitCargo() | 0xFF << 8, DC_EXEC, GetCmdRefitVeh(v));
|
||||
cur_company.Restore();
|
||||
|
||||
if (cost.Failed()) {
|
||||
|
|
|
@ -405,8 +405,11 @@ struct RefitWindow : public Window {
|
|||
continue;
|
||||
}
|
||||
|
||||
/* Check the vehicle's callback mask for cargo suffixes */
|
||||
if (HasBit(callback_mask, CBM_VEHICLE_CARGO_SUFFIX)) {
|
||||
/* Check the vehicle's callback mask for cargo suffixes.
|
||||
* This is not supported for ordered refits, since subtypes only have a meaning
|
||||
* for a specific vehicle at a specific point in time, which conflicts with shared orders,
|
||||
* autoreplace, autorenew, clone, order restoration, ... */
|
||||
if (this->order == INVALID_VEH_ORDER_ID && HasBit(callback_mask, CBM_VEHICLE_CARGO_SUFFIX)) {
|
||||
/* Make a note of the original cargo type. It has to be
|
||||
* changed to test the cargo & subtype... */
|
||||
CargoID temp_cargo = v->cargo_type;
|
||||
|
@ -487,6 +490,7 @@ struct RefitWindow : public Window {
|
|||
{
|
||||
this->sel = -1;
|
||||
this->auto_refit = auto_refit;
|
||||
this->order = order;
|
||||
this->CreateNestedTree(desc);
|
||||
|
||||
this->vscroll = this->GetScrollbar(WID_VR_SCROLLBAR);
|
||||
|
@ -502,7 +506,6 @@ struct RefitWindow : public Window {
|
|||
this->FinishInitNested(desc, v->index);
|
||||
this->owner = v->owner;
|
||||
|
||||
this->order = order;
|
||||
this->SetWidgetDisabledState(WID_VR_REFIT, this->sel == -1);
|
||||
}
|
||||
|
||||
|
@ -847,7 +850,7 @@ struct RefitWindow : public Window {
|
|||
bool delete_window = this->selected_vehicle == v->index && this->num_vehicles == UINT8_MAX;
|
||||
if (DoCommandP(v->tile, this->selected_vehicle, this->cargo->cargo | this->cargo->subtype << 8 | this->num_vehicles << 16, GetCmdRefitVeh(v)) && delete_window) delete this;
|
||||
} else {
|
||||
if (DoCommandP(v->tile, v->index, this->cargo->cargo | this->cargo->subtype << 8 | this->order << 16, CMD_ORDER_REFIT)) delete this;
|
||||
if (DoCommandP(v->tile, v->index, this->cargo->cargo | this->order << 16, CMD_ORDER_REFIT)) delete this;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -924,7 +927,7 @@ static const WindowDesc _vehicle_refit_desc(
|
|||
/**
|
||||
* Show the refit window for a vehicle
|
||||
* @param *v The vehicle to show the refit window for
|
||||
* @param order of the vehicle ( ? )
|
||||
* @param order of the vehicle to assign refit to, or INVALID_VEH_ORDER_ID to refit the vehicle now
|
||||
* @param parent the parent window of the refit window
|
||||
* @param auto_refit Choose cargo for auto-refitting
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue