Import cargo type orders patch
https://www.tt-forums.net/viewtopic.php?p=1047749#p1047749 Port to current trunk, resolve various conflicts, etc. Adjust bit allocations for CmdModifyOrder. Use save_ext framework for added order flags.
This commit is contained in:
@@ -1240,6 +1240,35 @@ Money CargoPayment::PayTransfer(const CargoPacket *cp, uint count)
|
||||
return profit; // account for the (virtual) profit already made for the cargo packet
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the load type of a vehicle.
|
||||
* In case of cargo type order, the load type returned depends of the cargo carriable by the vehicle.
|
||||
* @pre v != NULL
|
||||
* @param v A pointer to a vehicle.
|
||||
* @return the load type of this vehicle.
|
||||
*/
|
||||
static OrderLoadFlags GetLoadType(const Vehicle *v)
|
||||
{
|
||||
const Vehicle *front = v->First();
|
||||
OrderLoadFlags olf = front->current_order.GetLoadType();
|
||||
if (olf == OLFB_CARGO_TYPE_LOAD) olf = front->current_order.GetLoadType(v->cargo_type);
|
||||
return olf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unload type of a vehicle.
|
||||
* In case of cargo type order, the unload type returned depends of the cargo carriable be the vehicle.
|
||||
* @param v A pointer to a vehicle.
|
||||
* @return The unload type of this vehicle.
|
||||
*/
|
||||
static OrderUnloadFlags GetUnloadType(const Vehicle *v)
|
||||
{
|
||||
const Vehicle *front = v->First();
|
||||
OrderUnloadFlags ouf = front->current_order.GetUnloadType();
|
||||
if (ouf == OUFB_CARGO_TYPE_UNLOAD) ouf = front->current_order.GetUnloadType(v->cargo_type);
|
||||
return ouf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the vehicle to be unloaded.
|
||||
* @param curr_station the station where the consist is at the moment
|
||||
@@ -1267,12 +1296,13 @@ void PrepareUnload(Vehicle *front_v)
|
||||
if (front_v->orders.list == NULL || (front_v->current_order.GetUnloadType() & OUFB_NO_UNLOAD) == 0) {
|
||||
Station *st = Station::Get(front_v->last_station_visited);
|
||||
for (Vehicle *v = front_v; v != NULL; v = v->Next()) {
|
||||
if (GetUnloadType(v) & OUFB_NO_UNLOAD) continue;
|
||||
const GoodsEntry *ge = &st->goods[v->cargo_type];
|
||||
if (v->cargo_cap > 0 && v->cargo.TotalCount() > 0) {
|
||||
v->cargo.Stage(
|
||||
HasBit(ge->status, GoodsEntry::GES_ACCEPTANCE),
|
||||
front_v->last_station_visited, next_station,
|
||||
front_v->current_order.GetUnloadType(), ge,
|
||||
GetUnloadType(v), ge,
|
||||
front_v->cargo_payment);
|
||||
if (v->cargo.UnloadCount() > 0) SetBit(v->vehicle_flags, VF_CARGO_UNLOADING);
|
||||
}
|
||||
@@ -1427,6 +1457,7 @@ struct FinalizeRefitAction
|
||||
Station *st; ///< Station to reserve cargo from.
|
||||
StationIDStack &next_station; ///< Next hops to reserve cargo for.
|
||||
bool do_reserve; ///< If the vehicle should reserve.
|
||||
Vehicle *cargo_type_loading; ///< Non-null if vehicle should reserve if the cargo type of the vehicle is a cargo-specific full-load order using this pointer
|
||||
|
||||
/**
|
||||
* Create a finalizing action.
|
||||
@@ -1435,8 +1466,8 @@ struct FinalizeRefitAction
|
||||
* @param next_station Next hops to reserve cargo for.
|
||||
* @param do_reserve If we should reserve cargo or just add up the capacities.
|
||||
*/
|
||||
FinalizeRefitAction(CargoArray &consist_capleft, Station *st, StationIDStack &next_station, bool do_reserve) :
|
||||
consist_capleft(consist_capleft), st(st), next_station(next_station), do_reserve(do_reserve) {}
|
||||
FinalizeRefitAction(CargoArray &consist_capleft, Station *st, StationIDStack &next_station, bool do_reserve, Vehicle *cargo_type_loading) :
|
||||
consist_capleft(consist_capleft), st(st), next_station(next_station), do_reserve(do_reserve), cargo_type_loading(cargo_type_loading) {}
|
||||
|
||||
/**
|
||||
* Reserve cargo from the station and update the remaining consist capacities with the
|
||||
@@ -1446,7 +1477,7 @@ struct FinalizeRefitAction
|
||||
*/
|
||||
bool operator()(Vehicle *v)
|
||||
{
|
||||
if (this->do_reserve) {
|
||||
if (this->do_reserve || (cargo_type_loading == NULL || (cargo_type_loading->current_order.GetLoadType(v->cargo_type) & OLFB_FULL_LOAD))) {
|
||||
this->st->goods[v->cargo_type].cargo.Reserve(v->cargo_cap - v->cargo.RemainingCount(),
|
||||
&v->cargo, st->xy, this->next_station);
|
||||
}
|
||||
@@ -1513,7 +1544,8 @@ static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station
|
||||
|
||||
/* Add new capacity to consist capacity and reserve cargo */
|
||||
IterateVehicleParts(v_start, FinalizeRefitAction(consist_capleft, st, next_station,
|
||||
is_auto_refit || (v->First()->current_order.GetLoadType() & OLFB_FULL_LOAD) != 0));
|
||||
is_auto_refit || (v->First()->current_order.GetLoadType() & OLFB_FULL_LOAD) != 0,
|
||||
(v->First()->current_order.GetLoadType() == OLFB_CARGO_TYPE_LOAD) ? v->First() : NULL));
|
||||
|
||||
cur_company.Restore();
|
||||
}
|
||||
@@ -1521,12 +1553,14 @@ static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station
|
||||
struct ReserveCargoAction {
|
||||
Station *st;
|
||||
StationIDStack *next_station;
|
||||
Vehicle *cargo_type_loading;
|
||||
|
||||
ReserveCargoAction(Station *st, StationIDStack *next_station) :
|
||||
st(st), next_station(next_station) {}
|
||||
ReserveCargoAction(Station *st, StationIDStack *next_station, Vehicle *cargo_type_loading) :
|
||||
st(st), next_station(next_station), cargo_type_loading(cargo_type_loading) {}
|
||||
|
||||
bool operator()(Vehicle *v)
|
||||
{
|
||||
if (cargo_type_loading != NULL && !(cargo_type_loading->current_order.GetLoadType(v->cargo_type) & OLFB_FULL_LOAD)) return true;
|
||||
if (v->cargo_cap > v->cargo.RemainingCount()) {
|
||||
st->goods[v->cargo_type].cargo.Reserve(v->cargo_cap - v->cargo.RemainingCount(),
|
||||
&v->cargo, st->xy, *next_station);
|
||||
@@ -1544,8 +1578,9 @@ struct ReserveCargoAction {
|
||||
* @param u Front of the loading vehicle consist.
|
||||
* @param consist_capleft If given, save free capacities after reserving there.
|
||||
* @param next_station Station(s) the vehicle will stop at next.
|
||||
* @param cargo_type_loading check cargo-specific loading type
|
||||
*/
|
||||
static void ReserveConsist(Station *st, Vehicle *u, CargoArray *consist_capleft, StationIDStack *next_station)
|
||||
static void ReserveConsist(Station *st, Vehicle *u, CargoArray *consist_capleft, StationIDStack *next_station, bool cargo_type_loading)
|
||||
{
|
||||
/* If there is a cargo payment not all vehicles of the consist have tried to do the refit.
|
||||
* In that case, only reserve if it's a fixed refit and the equivalent of "articulated chain"
|
||||
@@ -1561,9 +1596,10 @@ static void ReserveConsist(Station *st, Vehicle *u, CargoArray *consist_capleft,
|
||||
(v->type != VEH_TRAIN || !Train::From(v)->IsRearDualheaded()) &&
|
||||
(v->type != VEH_AIRCRAFT || Aircraft::From(v)->IsNormalAircraft()) &&
|
||||
(must_reserve || u->current_order.GetRefitCargo() == v->cargo_type)) {
|
||||
IterateVehicleParts(v, ReserveCargoAction(st, next_station));
|
||||
IterateVehicleParts(v, ReserveCargoAction(st, next_station, cargo_type_loading ? u : NULL));
|
||||
}
|
||||
if (consist_capleft == NULL || v->cargo_cap == 0) continue;
|
||||
if (cargo_type_loading && !(u->current_order.GetLoadType(v->cargo_type) & OLFB_FULL_LOAD)) continue;
|
||||
(*consist_capleft)[v->cargo_type] += v->cargo_cap - v->cargo.RemainingCount();
|
||||
}
|
||||
}
|
||||
@@ -1603,11 +1639,20 @@ static void LoadUnloadVehicle(Vehicle *front)
|
||||
StationIDStack next_station = front->GetNextStoppingStation();
|
||||
bool use_autorefit = front->current_order.IsRefit() && front->current_order.GetRefitCargo() == CT_AUTO_REFIT;
|
||||
CargoArray consist_capleft;
|
||||
if (_settings_game.order.improved_load && use_autorefit ?
|
||||
front->cargo_payment == NULL : (front->current_order.GetLoadType() & OLFB_FULL_LOAD) != 0) {
|
||||
ReserveConsist(st, front,
|
||||
(use_autorefit && front->load_unload_ticks != 0) ? &consist_capleft : NULL,
|
||||
&next_station);
|
||||
if (_settings_game.order.improved_load && use_autorefit) {
|
||||
if (front->cargo_payment == NULL) {
|
||||
ReserveConsist(st, front,
|
||||
(use_autorefit && front->load_unload_ticks != 0) ? &consist_capleft : NULL,
|
||||
&next_station,
|
||||
false);
|
||||
}
|
||||
} else {
|
||||
if ((front->current_order.GetLoadType() & OLFB_FULL_LOAD) || (front->current_order.GetLoadType() == OLFB_CARGO_TYPE_LOAD)) {
|
||||
ReserveConsist(st, front,
|
||||
(use_autorefit && front->load_unload_ticks != 0) ? &consist_capleft : NULL,
|
||||
&next_station,
|
||||
(front->current_order.GetLoadType() == OLFB_CARGO_TYPE_LOAD));
|
||||
}
|
||||
}
|
||||
|
||||
/* We have not waited enough time till the next round of loading/unloading */
|
||||
@@ -1647,7 +1692,7 @@ static void LoadUnloadVehicle(Vehicle *front)
|
||||
|
||||
GoodsEntry *ge = &st->goods[v->cargo_type];
|
||||
|
||||
if (HasBit(v->vehicle_flags, VF_CARGO_UNLOADING) && (front->current_order.GetUnloadType() & OUFB_NO_UNLOAD) == 0) {
|
||||
if (HasBit(v->vehicle_flags, VF_CARGO_UNLOADING) && (GetUnloadType(v) & OUFB_NO_UNLOAD) == 0) {
|
||||
uint cargo_count = v->cargo.UnloadCount();
|
||||
uint amount_unloaded = _settings_game.order.gradual_loading ? min(cargo_count, load_amount) : cargo_count;
|
||||
bool remaining = false; // Are there cargo entities in this vehicle that can still be unloaded here?
|
||||
@@ -1657,7 +1702,7 @@ static void LoadUnloadVehicle(Vehicle *front)
|
||||
|
||||
if (!HasBit(ge->status, GoodsEntry::GES_ACCEPTANCE) && v->cargo.ActionCount(VehicleCargoList::MTA_DELIVER) > 0) {
|
||||
/* The station does not accept our goods anymore. */
|
||||
if (front->current_order.GetUnloadType() & (OUFB_TRANSFER | OUFB_UNLOAD)) {
|
||||
if (GetUnloadType(v) & (OUFB_TRANSFER | OUFB_UNLOAD)) {
|
||||
/* Transfer instead of delivering. */
|
||||
v->cargo.Reassign<VehicleCargoList::MTA_DELIVER, VehicleCargoList::MTA_TRANSFER>(
|
||||
v->cargo.ActionCount(VehicleCargoList::MTA_DELIVER), INVALID_STATION);
|
||||
@@ -1714,7 +1759,7 @@ static void LoadUnloadVehicle(Vehicle *front)
|
||||
}
|
||||
|
||||
/* Do not pick up goods when we have no-load set or loading is stopped. */
|
||||
if (front->current_order.GetLoadType() & OLFB_NO_LOAD || HasBit(front->vehicle_flags, VF_STOP_LOADING)) continue;
|
||||
if (GetLoadType(v) & OLFB_NO_LOAD || HasBit(front->vehicle_flags, VF_STOP_LOADING)) continue;
|
||||
|
||||
/* This order has a refit, if this is the first vehicle part carrying cargo and the whole vehicle is empty, try refitting. */
|
||||
if (front->current_order.IsRefit() && artic_part == 1) {
|
||||
@@ -1817,6 +1862,16 @@ static void LoadUnloadVehicle(Vehicle *front)
|
||||
if (!anything_unloaded) delete payment;
|
||||
|
||||
ClrBit(front->vehicle_flags, VF_STOP_LOADING);
|
||||
|
||||
bool has_full_load_order = front->current_order.GetLoadType() & OLFB_FULL_LOAD;
|
||||
if (front->current_order.GetLoadType() == OLFB_CARGO_TYPE_LOAD) {
|
||||
for (Vehicle *v = front; v != NULL; v = v->Next()) {
|
||||
if (front->current_order.GetLoadType(v->cargo_type) & OLFB_FULL_LOAD) {
|
||||
has_full_load_order = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (anything_loaded || anything_unloaded) {
|
||||
if (_settings_game.order.gradual_loading) {
|
||||
/* The time it takes to load one 'slice' of cargo or passengers depends
|
||||
@@ -1827,7 +1882,7 @@ static void LoadUnloadVehicle(Vehicle *front)
|
||||
}
|
||||
/* We loaded less cargo than possible for all cargo types and it's not full
|
||||
* load and we're not supposed to wait any longer: stop loading. */
|
||||
if (!anything_unloaded && full_load_amount == 0 && reservation_left == 0 && !(front->current_order.GetLoadType() & OLFB_FULL_LOAD) &&
|
||||
if (!anything_unloaded && full_load_amount == 0 && reservation_left == 0 && !has_full_load_order &&
|
||||
front->current_order_time >= (uint)max(front->current_order.GetTimetabledWait() - front->lateness_counter, 0)) {
|
||||
SetBit(front->vehicle_flags, VF_STOP_LOADING);
|
||||
}
|
||||
@@ -1836,7 +1891,7 @@ static void LoadUnloadVehicle(Vehicle *front)
|
||||
} else {
|
||||
UpdateLoadUnloadTicks(front, st, 20); // We need the ticks for link refreshing.
|
||||
bool finished_loading = true;
|
||||
if (front->current_order.GetLoadType() & OLFB_FULL_LOAD) {
|
||||
if (has_full_load_order) {
|
||||
if (front->current_order.GetLoadType() == OLF_FULL_LOAD_ANY) {
|
||||
/* if the aircraft carries passengers and is NOT full, then
|
||||
* continue loading, no matter how much mail is in */
|
||||
|
@@ -3755,6 +3755,7 @@ STR_ORDER_DROP_LOAD_IF_POSSIBLE :Load if availab
|
||||
STR_ORDER_DROP_FULL_LOAD_ALL :Full load all cargo
|
||||
STR_ORDER_DROP_FULL_LOAD_ANY :Full load any cargo
|
||||
STR_ORDER_DROP_NO_LOADING :No loading
|
||||
STR_ORDER_DROP_CARGO_TYPE_LOAD :Load by cargo type
|
||||
STR_ORDER_TOOLTIP_FULL_LOAD :{BLACK}Change the loading behaviour of the highlighted order
|
||||
|
||||
STR_ORDER_TOGGLE_UNLOAD :{BLACK}Unload all
|
||||
@@ -3762,6 +3763,7 @@ STR_ORDER_DROP_UNLOAD_IF_ACCEPTED :Unload if accep
|
||||
STR_ORDER_DROP_UNLOAD :Unload all
|
||||
STR_ORDER_DROP_TRANSFER :Transfer
|
||||
STR_ORDER_DROP_NO_UNLOADING :No unloading
|
||||
STR_ORDER_DROP_CARGO_TYPE_UNLOAD :Unload by cargo type
|
||||
STR_ORDER_TOOLTIP_UNLOAD :{BLACK}Change the unloading behaviour of the highlighted order
|
||||
|
||||
STR_ORDER_REFIT :{BLACK}Refit
|
||||
@@ -3845,31 +3847,48 @@ STR_ORDER_IMPLICIT :(Implicit)
|
||||
STR_ORDER_FULL_LOAD :(Full load)
|
||||
STR_ORDER_FULL_LOAD_ANY :(Full load any cargo)
|
||||
STR_ORDER_NO_LOAD :(No loading)
|
||||
STR_ORDER_CARGO_TYPE_LOAD :(Load by cargo type)
|
||||
STR_ORDER_UNLOAD :(Unload and take cargo)
|
||||
STR_ORDER_UNLOAD_FULL_LOAD :(Unload and wait for full load)
|
||||
STR_ORDER_UNLOAD_FULL_LOAD_ANY :(Unload and wait for any full load)
|
||||
STR_ORDER_UNLOAD_NO_LOAD :(Unload and leave empty)
|
||||
STR_ORDER_UNLOAD_CARGO_TYPE_LOAD :(Unload and wait for load by cargo type)
|
||||
STR_ORDER_TRANSFER :(Transfer and take cargo)
|
||||
STR_ORDER_TRANSFER_FULL_LOAD :(Transfer and wait for full load)
|
||||
STR_ORDER_TRANSFER_FULL_LOAD_ANY :(Transfer and wait for any full load)
|
||||
STR_ORDER_TRANSFER_NO_LOAD :(Transfer and leave empty)
|
||||
STR_ORDER_TRANSFER_CARGO_TYPE_LOAD :(Transfer and wait for load by cargo type)
|
||||
STR_ORDER_NO_UNLOAD :(No unloading and take cargo)
|
||||
STR_ORDER_NO_UNLOAD_FULL_LOAD :(No unloading and wait for full load)
|
||||
STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY :(No unloading and wait for any full load)
|
||||
STR_ORDER_NO_UNLOAD_NO_LOAD :(No unloading and no loading)
|
||||
STR_ORDER_NO_UNLOAD_CARGO_TYPE_LOAD :(No unloading and wait for load by cargo type)
|
||||
STR_ORDER_CARGO_TYPE_UNLOAD :(Unload by cargo type)
|
||||
STR_ORDER_CARGO_TYPE_UNLOAD_FULL_LOAD :(Unload by cargo type and wait for full load)
|
||||
STR_ORDER_CARGO_TYPE_UNLOAD_FULL_LOAD_ANY :(Unload by cargo type and wait for any full load)
|
||||
STR_ORDER_CARGO_TYPE_UNLOAD_NO_LOAD :(Unload by cargo type and leave empty)
|
||||
STR_ORDER_CARGO_TYPE_UNLOAD_CARGO_TYPE_LOAD :(Unload by cargo type and wait for load by cargo type)
|
||||
|
||||
STR_ORDER_AUTO_REFIT :(Refit to {STRING})
|
||||
STR_ORDER_FULL_LOAD_REFIT :(Full load with refit to {STRING})
|
||||
STR_ORDER_FULL_LOAD_ANY_REFIT :(Full load any cargo with refit to {STRING})
|
||||
STR_ORDER_CARGO_TYPE_LOAD_REFIT :(Load by cargo type with auto-refit to {STRING})
|
||||
STR_ORDER_UNLOAD_REFIT :(Unload and take cargo with refit to {STRING})
|
||||
STR_ORDER_UNLOAD_FULL_LOAD_REFIT :(Unload and wait for full load with refit to {STRING})
|
||||
STR_ORDER_UNLOAD_FULL_LOAD_ANY_REFIT :(Unload and wait for any full load with refit to {STRING})
|
||||
STR_ORDER_UNLOAD_CARGO_TYPE_LOAD_REFIT :(Unload and wait for load by cargo type with auto-refit to {STRING})
|
||||
STR_ORDER_TRANSFER_REFIT :(Transfer and take cargo with refit to {STRING})
|
||||
STR_ORDER_TRANSFER_FULL_LOAD_REFIT :(Transfer and wait for full load with refit to {STRING})
|
||||
STR_ORDER_TRANSFER_FULL_LOAD_ANY_REFIT :(Transfer and wait for any full load with refit to {STRING})
|
||||
STR_ORDER_TRANSFER_CARGO_TYPE_LOAD_REFIT :(Transfer and wait for load by cargo type with auto-refit to {STRING})
|
||||
STR_ORDER_NO_UNLOAD_REFIT :(No unloading and take cargo with refit to {STRING})
|
||||
STR_ORDER_NO_UNLOAD_FULL_LOAD_REFIT :(No unloading and wait for full load with refit to {STRING})
|
||||
STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY_REFIT :(No unloading and wait for any full load with refit to {STRING})
|
||||
STR_ORDER_NO_UNLOAD_CARGO_TYPE_LOAD_REFIT :(No unloading and wait for load by cargo type with auto-refit to {STRING})
|
||||
STR_ORDER_CARGO_TYPE_UNLOAD_REFIT :(Unload by cargo type and take cargo with auto-refit to {STRING})
|
||||
STR_ORDER_CARGO_TYPE_UNLOAD_FULL_LOAD_REFIT :(Unload by cargo type and wait for full load with auto-refit to {STRING})
|
||||
STR_ORDER_CARGO_TYPE_UNLOAD_FULL_LOAD_ANY_REFIT :(Unload by cargo type and wait for any full load with auto-refit to {STRING})
|
||||
STR_ORDER_CARGO_TYPE_UNLOAD_CARGO_TYPE_LOAD_REFIT :(Unload by cargo type and wait for load by cargo type with auto-refit to {STRING})
|
||||
|
||||
STR_ORDER_AUTO_REFIT_ANY :available cargo
|
||||
|
||||
@@ -3953,6 +3972,19 @@ STR_DATE_DAY_TOOLTIP :{BLACK}Select d
|
||||
STR_DATE_MONTH_TOOLTIP :{BLACK}Select month
|
||||
STR_DATE_YEAR_TOOLTIP :{BLACK}Select year
|
||||
|
||||
# Cargo type orders Window
|
||||
STR_CARGO_TYPE_ORDERS_LOAD_CAPTION :{WHITE}{VEHICLE} ({NUM}: Load at {STATION})
|
||||
STR_CARGO_TYPE_ORDERS_UNLOAD_CAPTION :{WHITE}{VEHICLE} ({NUM}: Unload at {STATION})
|
||||
STR_CARGO_TYPE_ORDERS_LOAD_TITLE :{GOLD}Select load order per cargo type:
|
||||
STR_CARGO_TYPE_ORDERS_UNLOAD_TITLE :{GOLD}Select unload order per cargo type:
|
||||
STR_CARGO_TYPE_ORDERS_CLOSE_BUTTON :{BLACK}Close
|
||||
|
||||
STR_CARGO_TYPE_ORDERS_DROP_FULL_LOAD :Full load
|
||||
STR_CARGO_TYPE_LOAD_ORDERS_DROP_TOOLTIP :{BLACK}Change the loading behaviour for this cargo type
|
||||
STR_CARGO_TYPE_UNLOAD_ORDERS_DROP_TOOLTIP :{BLACK}Change the unloading behaviour for this cargo type
|
||||
|
||||
STR_CARGO_TYPE_ORDERS_SET_TO_ALL_LABEL :{BLACK}Set all to:
|
||||
STR_CARGO_TYPE_ORDERS_SET_TO_ALL_TOOLTIP :{BLACK}Set all cargo type orders to the one selected by the dropdown
|
||||
|
||||
# AI debug window
|
||||
STR_AI_DEBUG :{WHITE}AI/Game Script Debug
|
||||
|
@@ -43,6 +43,8 @@ private:
|
||||
|
||||
CargoID refit_cargo; ///< Refit CargoID
|
||||
|
||||
uint8 cargo_type_flags[NUM_CARGO]; ///< Load/unload types for each cargo type.
|
||||
|
||||
uint16 wait_time; ///< How long in ticks to wait at the destination.
|
||||
uint16 travel_time; ///< How long in ticks the journey to this destination should take.
|
||||
uint16 max_speed; ///< How fast the vehicle may go on the way to the destination.
|
||||
@@ -126,9 +128,35 @@ public:
|
||||
void SetRefit(CargoID cargo);
|
||||
|
||||
/** How must the consist be loaded? */
|
||||
inline OrderLoadFlags GetLoadType() const { return (OrderLoadFlags)GB(this->flags, 4, 3); }
|
||||
inline OrderLoadFlags GetLoadType() const { return (OrderLoadFlags)GB(this->flags, 4, 4); }
|
||||
|
||||
/**
|
||||
* How must the consist be loaded for this type of cargo?
|
||||
* @pre GetLoadType() == OLFB_CARGO_TYPE_LOAD
|
||||
* @param cargo_id The cargo type index.
|
||||
* @return The load type for this cargo.
|
||||
*/
|
||||
inline OrderLoadFlags GetLoadType(CargoID cargo_id) const
|
||||
{
|
||||
assert(cargo_id < NUM_CARGO);
|
||||
return (OrderLoadFlags) GB(this->cargo_type_flags[cargo_id], 4, 4);
|
||||
}
|
||||
|
||||
/** How must the consist be unloaded? */
|
||||
inline OrderUnloadFlags GetUnloadType() const { return (OrderUnloadFlags)GB(this->flags, 0, 3); }
|
||||
inline OrderUnloadFlags GetUnloadType() const { return (OrderUnloadFlags)GB(this->flags, 0, 4); }
|
||||
|
||||
/**
|
||||
* How must the consist be unloaded for this type of cargo?
|
||||
* @pre GetUnloadType() == OUFB_CARGO_TYPE_UNLOAD
|
||||
* @param cargo_id The cargo type index.
|
||||
* @return The unload type for this cargo.
|
||||
*/
|
||||
inline OrderUnloadFlags GetUnloadType(CargoID cargo_id) const
|
||||
{
|
||||
assert(cargo_id < NUM_CARGO);
|
||||
return (OrderUnloadFlags) GB(this->cargo_type_flags[cargo_id], 0, 4);
|
||||
}
|
||||
|
||||
/** At which stations must we stop? */
|
||||
inline OrderNonStopFlags GetNonStopType() const { return (OrderNonStopFlags)GB(this->type, 6, 2); }
|
||||
/** Where must we stop at the platform? */
|
||||
@@ -147,9 +175,35 @@ public:
|
||||
inline uint16 GetConditionValue() const { return GB(this->dest, 0, 11); }
|
||||
|
||||
/** Set how the consist must be loaded. */
|
||||
inline void SetLoadType(OrderLoadFlags load_type) { SB(this->flags, 4, 3, load_type); }
|
||||
inline void SetLoadType(OrderLoadFlags load_type) { SB(this->flags, 4, 4, load_type); }
|
||||
|
||||
/**
|
||||
* Set how the consist must be loaded for this type of cargo.
|
||||
* @pre GetLoadType() == OLFB_CARGO_TYPE_LOAD
|
||||
* @param load_type The load type.
|
||||
* @param cargo_id The cargo type index.
|
||||
*/
|
||||
inline void SetLoadType(OrderLoadFlags load_type, CargoID cargo_id)
|
||||
{
|
||||
assert(cargo_id < NUM_CARGO);
|
||||
SB(this->cargo_type_flags[cargo_id], 4, 4, load_type);
|
||||
}
|
||||
|
||||
/** Set how the consist must be unloaded. */
|
||||
inline void SetUnloadType(OrderUnloadFlags unload_type) { SB(this->flags, 0, 3, unload_type); }
|
||||
inline void SetUnloadType(OrderUnloadFlags unload_type) { SB(this->flags, 0, 4, unload_type); }
|
||||
|
||||
/**
|
||||
* Set how the consist must be unloaded for this type of cargo.
|
||||
* @pre GetUnloadType() == OUFB_CARGO_TYPE_UNLOAD
|
||||
* @param unload_type The unload type.
|
||||
* @param cargo_id The cargo type index.
|
||||
*/
|
||||
inline void SetUnloadType(OrderUnloadFlags unload_type, CargoID cargo_id)
|
||||
{
|
||||
assert(cargo_id < NUM_CARGO);
|
||||
SB(this->cargo_type_flags[cargo_id], 0, 4, unload_type);
|
||||
}
|
||||
|
||||
/** Set whether we must stop at stations or not. */
|
||||
inline void SetNonStopType(OrderNonStopFlags non_stop_type) { SB(this->type, 6, 2, non_stop_type); }
|
||||
/** Set where we must stop at the platform. */
|
||||
|
@@ -282,6 +282,12 @@ void Order::AssignOrder(const Order &other)
|
||||
this->wait_time = other.wait_time;
|
||||
this->travel_time = other.travel_time;
|
||||
this->max_speed = other.max_speed;
|
||||
|
||||
if (this->GetUnloadType() == OUFB_CARGO_TYPE_UNLOAD || this->GetLoadType() == OLFB_CARGO_TYPE_LOAD) {
|
||||
for (uint i = 0; i < NUM_CARGO; i++) {
|
||||
this->cargo_type_flags[i] = other.cargo_type_flags[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1277,12 +1283,13 @@ CommandCost CmdMoveOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||
* @param flags operation to perform
|
||||
* @param p1 various bitstuffed elements
|
||||
* - p1 = (bit 0 - 19) - ID of the vehicle
|
||||
* - p1 = (bit 24 - 31) - the selected order (if any). If the last order is given,
|
||||
* - p1 = (bit 20 - 27) - the selected order (if any). If the last order is given,
|
||||
* the order will be inserted before that one
|
||||
* the maximum vehicle order id is 254.
|
||||
* @param p2 various bitstuffed elements
|
||||
* - p2 = (bit 0 - 3) - what data to modify (@see ModifyOrderFlags)
|
||||
* - p2 = (bit 4 - 15) - the data to modify
|
||||
* - p2 = (bit 16 - 23) - a CargoID for cargo type orders (MOF_CARGO_TYPE_UNLOAD or MOF_CARGO_TYPE_LOAD)
|
||||
* @param text unused
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
@@ -1292,6 +1299,7 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||
VehicleID veh = GB(p1, 0, 20);
|
||||
ModifyOrderFlags mof = Extract<ModifyOrderFlags, 0, 4>(p2);
|
||||
uint16 data = GB(p2, 4, 11);
|
||||
CargoID cargo_id = (mof == MOF_CARGO_TYPE_UNLOAD || mof == MOF_CARGO_TYPE_LOAD) ? (CargoID) GB(p2, 16, 8) : (CargoID) CT_INVALID;
|
||||
|
||||
if (mof >= MOF_END) return CMD_ERROR;
|
||||
|
||||
@@ -1307,7 +1315,7 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||
Order *order = v->GetOrder(sel_ord);
|
||||
switch (order->GetType()) {
|
||||
case OT_GOTO_STATION:
|
||||
if (mof != MOF_NON_STOP && mof != MOF_STOP_LOCATION && mof != MOF_UNLOAD && mof != MOF_LOAD) return CMD_ERROR;
|
||||
if (mof != MOF_NON_STOP && mof != MOF_STOP_LOCATION && mof != MOF_UNLOAD && mof != MOF_LOAD && mof != MOF_CARGO_TYPE_UNLOAD && mof != MOF_CARGO_TYPE_LOAD) return CMD_ERROR;
|
||||
break;
|
||||
|
||||
case OT_GOTO_DEPOT:
|
||||
@@ -1340,17 +1348,27 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||
if (data >= OSL_END) return CMD_ERROR;
|
||||
break;
|
||||
|
||||
case MOF_CARGO_TYPE_UNLOAD:
|
||||
if (cargo_id >= NUM_CARGO) return CMD_ERROR;
|
||||
if (data == OUFB_CARGO_TYPE_UNLOAD) return CMD_ERROR;
|
||||
/* FALL THROUGH */
|
||||
case MOF_UNLOAD:
|
||||
if (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) return CMD_ERROR;
|
||||
if ((data & ~(OUFB_UNLOAD | OUFB_TRANSFER | OUFB_NO_UNLOAD)) != 0) return CMD_ERROR;
|
||||
if ((data & ~(OUFB_UNLOAD | OUFB_TRANSFER | OUFB_NO_UNLOAD | OUFB_CARGO_TYPE_UNLOAD)) != 0) return CMD_ERROR;
|
||||
/* Unload and no-unload are mutual exclusive and so are transfer and no unload. */
|
||||
if (data != 0 && ((data & (OUFB_UNLOAD | OUFB_TRANSFER)) != 0) == ((data & OUFB_NO_UNLOAD) != 0)) return CMD_ERROR;
|
||||
if (data != 0 && (data & OUFB_CARGO_TYPE_UNLOAD) == 0 && ((data & (OUFB_UNLOAD | OUFB_TRANSFER)) != 0) == ((data & OUFB_NO_UNLOAD) != 0)) return CMD_ERROR;
|
||||
/* Cargo-type-unload exclude all the other flags. */
|
||||
if ((data & OUFB_CARGO_TYPE_UNLOAD) != 0 && data != OUFB_CARGO_TYPE_UNLOAD) return CMD_ERROR;
|
||||
if (data == order->GetUnloadType()) return CMD_ERROR;
|
||||
break;
|
||||
|
||||
case MOF_CARGO_TYPE_LOAD:
|
||||
if (cargo_id >= NUM_CARGO) return CMD_ERROR;
|
||||
if (data == OLFB_CARGO_TYPE_LOAD || data == OLF_FULL_LOAD_ANY) return CMD_ERROR;
|
||||
/* FALL THROUGH */
|
||||
case MOF_LOAD:
|
||||
if (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) return CMD_ERROR;
|
||||
if (data > OLFB_NO_LOAD || data == 1) return CMD_ERROR;
|
||||
if ((data > OLFB_NO_LOAD && data != OLFB_CARGO_TYPE_LOAD) || data == 1) return CMD_ERROR;
|
||||
if (data == order->GetLoadType()) return CMD_ERROR;
|
||||
break;
|
||||
|
||||
@@ -1418,11 +1436,19 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||
order->SetUnloadType((OrderUnloadFlags)data);
|
||||
break;
|
||||
|
||||
case MOF_CARGO_TYPE_UNLOAD:
|
||||
order->SetUnloadType((OrderUnloadFlags)data, cargo_id);
|
||||
break;
|
||||
|
||||
case MOF_LOAD:
|
||||
order->SetLoadType((OrderLoadFlags)data);
|
||||
if (data & OLFB_NO_LOAD) order->SetRefit(CT_NO_REFIT);
|
||||
break;
|
||||
|
||||
case MOF_CARGO_TYPE_LOAD:
|
||||
order->SetLoadType((OrderLoadFlags)data, cargo_id);
|
||||
break;
|
||||
|
||||
case MOF_DEPOT_ACTION: {
|
||||
switch (data) {
|
||||
case DA_ALWAYS_GO:
|
||||
|
@@ -34,9 +34,305 @@
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
enum CargoTypeOrdersWindowVariant {
|
||||
CTOWV_LOAD = 0,
|
||||
CTOWV_UNLOAD = 1,
|
||||
};
|
||||
|
||||
/** Cargo type orders strings for load dropdowns. */
|
||||
static const StringID _cargo_type_load_order_drowdown[] = {
|
||||
STR_ORDER_DROP_LOAD_IF_POSSIBLE, // OLF_LOAD_IF_POSSIBLE
|
||||
STR_EMPTY,
|
||||
STR_CARGO_TYPE_ORDERS_DROP_FULL_LOAD, // OLFB_FULL_LOAD
|
||||
STR_EMPTY,
|
||||
STR_ORDER_DROP_NO_LOADING, // OLFB_NO_LOAD
|
||||
INVALID_STRING_ID
|
||||
};
|
||||
static const uint32 _cargo_type_load_order_drowdown_hidden_mask = 0xA; // 01010
|
||||
|
||||
/** Cargo type orders strings for unload dropdowns. */
|
||||
static const StringID _cargo_type_unload_order_drowdown[] = {
|
||||
STR_ORDER_DROP_UNLOAD_IF_ACCEPTED, // OUF_UNLOAD_IF_POSSIBLE
|
||||
STR_ORDER_DROP_UNLOAD, // OUFB_UNLOAD
|
||||
STR_ORDER_DROP_TRANSFER, // OUFB_TRANSFER
|
||||
STR_EMPTY,
|
||||
STR_ORDER_DROP_NO_UNLOADING, // OUFB_NO_UNLOAD
|
||||
INVALID_STRING_ID
|
||||
};
|
||||
static const uint32 _cargo_type_unload_order_drowdown_hidden_mask = 0x8; // 01000
|
||||
|
||||
struct CargoTypeOrdersWindow : public Window {
|
||||
private:
|
||||
CargoTypeOrdersWindowVariant variant;
|
||||
|
||||
const Vehicle *vehicle; ///< Vehicle owning the orders being displayed and manipulated.
|
||||
VehicleOrderID order_id; ///< Index of the order concerned by this window.
|
||||
|
||||
static const uint8 CARGO_ICON_WIDTH = 12;
|
||||
static const uint8 CARGO_ICON_HEIGHT = 8;
|
||||
|
||||
const StringID *cargo_type_order_dropdown; ///< Strings used to populate order dropdowns.
|
||||
uint32 cargo_type_order_dropdown_hmask; ///< Hidden mask for order dropdowns.
|
||||
|
||||
uint max_cargo_name_width; ///< Greatest width of cargo names.
|
||||
uint max_cargo_dropdown_width; ///< Greatest width of order names.
|
||||
|
||||
uint set_to_all_dropdown_sel; ///< Selected entry for the 'set to all' dropdown
|
||||
|
||||
/**
|
||||
* Initialize \c max_cargo_name_width and \c max_cargo_dropdown_width.
|
||||
* @post \c max_cargo_name_width
|
||||
* @post \c max_cargo_dropdown_width
|
||||
*/
|
||||
void InitMaxWidgetWidth()
|
||||
{
|
||||
this->max_cargo_name_width = 0;
|
||||
for (int i = 0; i < _sorted_standard_cargo_specs_size; i++) {
|
||||
SetDParam(0, _sorted_cargo_specs[i]->name);
|
||||
this->max_cargo_name_width = max(this->max_cargo_name_width, GetStringBoundingBox(STR_JUST_STRING).width);
|
||||
}
|
||||
this->max_cargo_dropdown_width = 0;
|
||||
for (int i = 0; this->cargo_type_order_dropdown[i] != INVALID_STRING_ID; i++) {
|
||||
SetDParam(0, this->cargo_type_order_dropdown[i]);
|
||||
this->max_cargo_dropdown_width = max(this->max_cargo_dropdown_width, GetStringBoundingBox(STR_JUST_STRING).width);
|
||||
}
|
||||
}
|
||||
|
||||
/** Populate the selected entry of order dropdowns. */
|
||||
void InitDropdownSelectedTypes()
|
||||
{
|
||||
StringID tooltip = STR_CARGO_TYPE_LOAD_ORDERS_DROP_TOOLTIP + this->variant;
|
||||
const Order *order = this->vehicle->GetOrder(this->order_id);
|
||||
for (int i = 0; i < _sorted_standard_cargo_specs_size; i++) {
|
||||
const CargoSpec *cs = _sorted_cargo_specs[i];
|
||||
CargoID cargo_id = GetCargoIDByBitnum(cs->bitnum);
|
||||
uint8 order_type = (this->variant == CTOWV_LOAD) ? (uint8) order->GetLoadType(cargo_id) : (uint8) order->GetUnloadType(cargo_id);
|
||||
this->GetWidget<NWidgetCore>(WID_CTO_CARGO_DROPDOWN_FIRST + i)->SetDataTip(this->cargo_type_order_dropdown[order_type], tooltip);
|
||||
}
|
||||
this->set_to_all_dropdown_sel = 0;
|
||||
this->GetWidget<NWidgetCore>(WID_CTO_SET_TO_ALL_DROPDOWN)->widget_data = this->cargo_type_order_dropdown[this->set_to_all_dropdown_sel];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the load/unload type of this order for the specified cargo.
|
||||
* @param cargo_id The cargo index for wich we want the load/unload type.
|
||||
* @return an OrderLoadFlags if \c load_variant = true, an OrderUnloadFlags otherwise.
|
||||
*/
|
||||
uint8 GetOrderActionTypeForCargo(CargoID cargo_id)
|
||||
{
|
||||
const Order *order = this->vehicle->GetOrder(this->order_id);
|
||||
return (this->variant == CTOWV_LOAD) ? (uint8) order->GetLoadType(cargo_id) : (uint8) order->GetUnloadType(cargo_id);
|
||||
}
|
||||
|
||||
public:
|
||||
/**
|
||||
* Instantiate a new CargoTypeOrdersWindow.
|
||||
* @param desc The window description.
|
||||
* @param v The vehicle the order belongs to.
|
||||
* @param order_id Which order to display/edit.
|
||||
* @param variant Which aspect of the order to display/edit: load or unload.
|
||||
* @pre \c v != NULL
|
||||
*/
|
||||
CargoTypeOrdersWindow(WindowDesc *desc, const Vehicle *v, VehicleOrderID order_id, CargoTypeOrdersWindowVariant variant) : Window(desc)
|
||||
{
|
||||
this->variant = variant;
|
||||
this->cargo_type_order_dropdown = (this->variant == CTOWV_LOAD) ? _cargo_type_load_order_drowdown : _cargo_type_unload_order_drowdown;
|
||||
this->cargo_type_order_dropdown_hmask = (this->variant == CTOWV_LOAD) ? _cargo_type_load_order_drowdown_hidden_mask : _cargo_type_unload_order_drowdown_hidden_mask;
|
||||
this->InitMaxWidgetWidth();
|
||||
|
||||
this->vehicle = v;
|
||||
this->order_id = order_id;
|
||||
|
||||
this->CreateNestedTree(desc);
|
||||
this->GetWidget<NWidgetCore>(WID_CTO_CAPTION)->SetDataTip(STR_CARGO_TYPE_ORDERS_LOAD_CAPTION + this->variant, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS);
|
||||
this->GetWidget<NWidgetCore>(WID_CTO_HEADER)->SetDataTip(STR_CARGO_TYPE_ORDERS_LOAD_TITLE + this->variant, STR_NULL);
|
||||
this->InitDropdownSelectedTypes();
|
||||
this->FinishInitNested(v->index);
|
||||
|
||||
this->owner = v->owner;
|
||||
}
|
||||
|
||||
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
||||
{
|
||||
if (widget == WID_CTO_HEADER) {
|
||||
(*size).height = max((*size).height, (uint) WD_FRAMERECT_TOP + FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM);
|
||||
} else if (WID_CTO_CARGO_LABEL_FIRST <= widget && widget <= WID_CTO_CARGO_LABEL_LAST) {
|
||||
(*size).width = max((*size).width, WD_FRAMERECT_LEFT + this->CARGO_ICON_WIDTH + WD_FRAMETEXT_LEFT + this->max_cargo_name_width + WD_FRAMETEXT_RIGHT + padding.width);
|
||||
(*size).height = max((*size).height, (uint) WD_FRAMERECT_TOP + FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM);
|
||||
} else if ((WID_CTO_CARGO_DROPDOWN_FIRST <= widget && widget <= WID_CTO_CARGO_DROPDOWN_LAST) || widget == WID_CTO_SET_TO_ALL_DROPDOWN) {
|
||||
(*size).width = max((*size).width, WD_DROPDOWNTEXT_LEFT + this->max_cargo_dropdown_width + WD_DROPDOWNTEXT_RIGHT);
|
||||
(*size).height = max((*size).height, (uint) WD_DROPDOWNTEXT_TOP + FONT_HEIGHT_NORMAL + WD_DROPDOWNTEXT_BOTTOM);
|
||||
} else if (widget == WID_CTO_SET_TO_ALL_LABEL) {
|
||||
(*size).width = max((*size).width, this->max_cargo_name_width + WD_FRAMETEXT_RIGHT + padding.width);
|
||||
(*size).height = max((*size).height, (uint) WD_FRAMERECT_TOP + FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void DrawWidget(const Rect &r, int widget) const
|
||||
{
|
||||
if (WID_CTO_CARGO_LABEL_FIRST <= widget && widget <= WID_CTO_CARGO_LABEL_LAST) {
|
||||
const CargoSpec *cs = _sorted_cargo_specs[widget - WID_CTO_CARGO_LABEL_FIRST];
|
||||
bool rtl = (_current_text_dir == TD_RTL);
|
||||
|
||||
/* Draw cargo icon. */
|
||||
int rect_left = rtl ? r.right - WD_FRAMETEXT_RIGHT - this->CARGO_ICON_WIDTH : r.left + WD_FRAMERECT_LEFT;
|
||||
int rect_right = rect_left + this->CARGO_ICON_WIDTH;
|
||||
int rect_top = r.top + WD_FRAMERECT_TOP + ((r.bottom - WD_FRAMERECT_BOTTOM - r.top - WD_FRAMERECT_TOP) - this->CARGO_ICON_HEIGHT) / 2;
|
||||
int rect_bottom = rect_top + this->CARGO_ICON_HEIGHT;
|
||||
GfxFillRect(rect_left, rect_top, rect_right, rect_bottom, PC_BLACK);
|
||||
GfxFillRect(rect_left + 1, rect_top + 1, rect_right - 1, rect_bottom - 1, cs->legend_colour);
|
||||
|
||||
/* Draw cargo name */
|
||||
int text_left = rtl ? r.left + WD_FRAMETEXT_LEFT : rect_right + WD_FRAMETEXT_LEFT;
|
||||
int text_right = rtl ? rect_left - WD_FRAMETEXT_LEFT : r.right - WD_FRAMETEXT_RIGHT;
|
||||
int text_top = r.top + WD_FRAMERECT_TOP;
|
||||
SetDParam(0, cs->name);
|
||||
DrawString(text_left, text_right, text_top, STR_BLACK_STRING);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnClick(Point pt, int widget, int click_count)
|
||||
{
|
||||
if (widget == WID_CTO_CLOSEBTN) {
|
||||
delete this;
|
||||
} else if (WID_CTO_CARGO_DROPDOWN_FIRST <= widget && widget <= WID_CTO_CARGO_DROPDOWN_LAST) {
|
||||
const CargoSpec *cs = _sorted_cargo_specs[widget - WID_CTO_CARGO_DROPDOWN_FIRST];
|
||||
CargoID cargo_id = GetCargoIDByBitnum(cs->bitnum);
|
||||
|
||||
ShowDropDownMenu(this, this->cargo_type_order_dropdown, this->GetOrderActionTypeForCargo(cargo_id), widget, 0, this->cargo_type_order_dropdown_hmask);
|
||||
} else if (widget == WID_CTO_SET_TO_ALL_DROPDOWN) {
|
||||
ShowDropDownMenu(this, this->cargo_type_order_dropdown, this->set_to_all_dropdown_sel, widget, 0, this->cargo_type_order_dropdown_hmask);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnDropdownSelect(int widget, int action_type)
|
||||
{
|
||||
if (WID_CTO_CARGO_DROPDOWN_FIRST <= widget && widget <= WID_CTO_CARGO_DROPDOWN_LAST) {
|
||||
const CargoSpec *cs = _sorted_cargo_specs[widget - WID_CTO_CARGO_DROPDOWN_FIRST];
|
||||
CargoID cargo_id = GetCargoIDByBitnum(cs->bitnum);
|
||||
uint8 order_action_type = this->GetOrderActionTypeForCargo(cargo_id);
|
||||
|
||||
if (action_type == order_action_type) return;
|
||||
|
||||
ModifyOrderFlags mof = (this->variant == CTOWV_LOAD) ? MOF_CARGO_TYPE_LOAD : MOF_CARGO_TYPE_UNLOAD;
|
||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->order_id << 20), mof | (action_type << 4) | (cargo_id << 16), CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
||||
|
||||
this->GetWidget<NWidgetCore>(widget)->SetDataTip(this->cargo_type_order_dropdown[this->GetOrderActionTypeForCargo(cargo_id)], STR_CARGO_TYPE_LOAD_ORDERS_DROP_TOOLTIP + this->variant);
|
||||
this->SetWidgetDirty(widget);
|
||||
} else if (widget == WID_CTO_SET_TO_ALL_DROPDOWN) {
|
||||
for (int i = 0; i < _sorted_standard_cargo_specs_size; i++) {
|
||||
this->OnDropdownSelect(i + WID_CTO_CARGO_DROPDOWN_FIRST, action_type);
|
||||
}
|
||||
|
||||
if (action_type != (int) this->set_to_all_dropdown_sel) {
|
||||
this->set_to_all_dropdown_sel = action_type;
|
||||
this->GetWidget<NWidgetCore>(widget)->widget_data = this->cargo_type_order_dropdown[this->set_to_all_dropdown_sel];
|
||||
this->SetWidgetDirty(widget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void SetStringParameters(int widget) const
|
||||
{
|
||||
if (widget == WID_CTO_CAPTION) {
|
||||
SetDParam(0, this->vehicle->index);
|
||||
SetDParam(1, this->order_id + 1);
|
||||
SetDParam(2, this->vehicle->GetOrder(this->order_id)->GetDestination());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Make a list of panel for each available cargo type.
|
||||
* Each panel contains a label to display the cargo name.
|
||||
* @param biggest_index Storage for collecting the biggest index used in the returned tree
|
||||
* @return A vertical container of cargo type orders rows.
|
||||
* @post \c *biggest_index contains the largest used index in the tree.
|
||||
*/
|
||||
static NWidgetBase *MakeCargoTypeOrdersRows(int *biggest_index)
|
||||
{
|
||||
NWidgetVertical *ver = new NWidgetVertical;
|
||||
|
||||
for (int i = 0; i < _sorted_standard_cargo_specs_size; i++) {
|
||||
/* Cargo row */
|
||||
NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, WID_CTO_CARGO_ROW_FIRST + i);
|
||||
ver->Add(panel);
|
||||
NWidgetHorizontal *horiz = new NWidgetHorizontal;
|
||||
panel->Add(horiz);
|
||||
/* Cargo label */
|
||||
NWidgetBackground *label = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, WID_CTO_CARGO_LABEL_FIRST + i);
|
||||
label->SetFill(1, 0);
|
||||
label->SetResize(1, 0);
|
||||
horiz->Add(label);
|
||||
/* Orders dropdown */
|
||||
NWidgetLeaf *dropdown = new NWidgetLeaf(WWT_DROPDOWN, COLOUR_GREY, WID_CTO_CARGO_DROPDOWN_FIRST + i, STR_NULL, STR_EMPTY);
|
||||
dropdown->SetFill(1, 0);
|
||||
dropdown->SetResize(1, 0);
|
||||
horiz->Add(dropdown);
|
||||
}
|
||||
|
||||
*biggest_index = WID_CTO_CARGO_DROPDOWN_LAST;
|
||||
return ver;
|
||||
}
|
||||
|
||||
/** Widgets definition of CargoTypeOrdersWindow. */
|
||||
static const NWidgetPart _nested_cargo_type_orders_widgets[] = {
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
||||
NWidget(WWT_CAPTION, COLOUR_GREY, WID_CTO_CAPTION), SetDataTip(STR_NULL, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
||||
EndContainer(),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY),
|
||||
NWidget(WWT_LABEL, COLOUR_GREY, WID_CTO_HEADER), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_NULL, STR_NULL),
|
||||
EndContainer(),
|
||||
NWidgetFunction(MakeCargoTypeOrdersRows),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(1, 4), SetFill(1, 0), SetResize(1, 0), EndContainer(), // SPACER
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY),
|
||||
NWidget(WWT_TEXT, COLOUR_GREY, WID_CTO_SET_TO_ALL_LABEL), SetPadding(0, 0, 0, WD_FRAMERECT_LEFT + 12 + WD_FRAMETEXT_LEFT), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_CARGO_TYPE_ORDERS_SET_TO_ALL_LABEL, STR_CARGO_TYPE_ORDERS_SET_TO_ALL_TOOLTIP),
|
||||
EndContainer(),
|
||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_CTO_SET_TO_ALL_DROPDOWN), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_NULL, STR_CARGO_TYPE_ORDERS_SET_TO_ALL_TOOLTIP),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_CTO_CLOSEBTN), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_CARGO_TYPE_ORDERS_CLOSE_BUTTON, STR_TOOLTIP_CLOSE_WINDOW),
|
||||
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
|
||||
EndContainer(),
|
||||
};
|
||||
|
||||
/** Window description for the 'load' variant of CargoTypeOrdersWindow. */
|
||||
static WindowDesc _cargo_type_load_orders_widgets (
|
||||
WDP_AUTO, "view_cargo_type_load_order", 195, 186,
|
||||
WC_VEHICLE_CARGO_TYPE_LOAD_ORDERS, WC_VEHICLE_ORDERS,
|
||||
WDF_CONSTRUCTION,
|
||||
_nested_cargo_type_orders_widgets, lengthof(_nested_cargo_type_orders_widgets)
|
||||
);
|
||||
|
||||
/** Window description for the 'unload' variant of CargoTypeOrdersWindow. */
|
||||
static WindowDesc _cargo_type_unload_orders_widgets (
|
||||
WDP_AUTO, "view_cargo_type_unload_order", 195, 186,
|
||||
WC_VEHICLE_CARGO_TYPE_UNLOAD_ORDERS, WC_VEHICLE_ORDERS,
|
||||
WDF_CONSTRUCTION,
|
||||
_nested_cargo_type_orders_widgets, lengthof(_nested_cargo_type_orders_widgets)
|
||||
);
|
||||
|
||||
/**
|
||||
* Show the CargoTypeOrdersWindow for an order.
|
||||
* @param v The vehicle the order belongs to.
|
||||
* @param parent The parent window.
|
||||
* @param order_id Which order to display/edit.
|
||||
* @param variant Which aspect of the order to display/edit: load or unload.
|
||||
* @pre \c v != NULL
|
||||
*/
|
||||
void ShowCargoTypeOrdersWindow(const Vehicle *v, Window *parent, VehicleOrderID order_id, CargoTypeOrdersWindowVariant variant)
|
||||
{
|
||||
WindowDesc &desc = (variant == CTOWV_LOAD) ? _cargo_type_load_orders_widgets : _cargo_type_unload_orders_widgets;
|
||||
DeleteWindowById(desc.cls, v->index);
|
||||
CargoTypeOrdersWindow *w = new CargoTypeOrdersWindow(&desc, v, order_id, variant);
|
||||
w->parent = parent;
|
||||
}
|
||||
|
||||
|
||||
/** Order load types that could be given to station orders. */
|
||||
static const StringID _station_load_types[][5][5] = {
|
||||
static const StringID _station_load_types[][9][9] = {
|
||||
{
|
||||
/* No refitting. */
|
||||
{
|
||||
@@ -45,30 +341,67 @@ static const StringID _station_load_types[][5][5] = {
|
||||
STR_ORDER_FULL_LOAD,
|
||||
STR_ORDER_FULL_LOAD_ANY,
|
||||
STR_ORDER_NO_LOAD,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
STR_ORDER_CARGO_TYPE_LOAD,
|
||||
}, {
|
||||
STR_ORDER_UNLOAD,
|
||||
INVALID_STRING_ID,
|
||||
STR_ORDER_UNLOAD_FULL_LOAD,
|
||||
STR_ORDER_UNLOAD_FULL_LOAD_ANY,
|
||||
STR_ORDER_UNLOAD_NO_LOAD,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
STR_ORDER_UNLOAD_CARGO_TYPE_LOAD,
|
||||
}, {
|
||||
STR_ORDER_TRANSFER,
|
||||
INVALID_STRING_ID,
|
||||
STR_ORDER_TRANSFER_FULL_LOAD,
|
||||
STR_ORDER_TRANSFER_FULL_LOAD_ANY,
|
||||
STR_ORDER_TRANSFER_NO_LOAD,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
STR_ORDER_TRANSFER_CARGO_TYPE_LOAD,
|
||||
}, {
|
||||
/* Unload and transfer do not work together. */
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID,
|
||||
INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID,
|
||||
INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID,
|
||||
}, {
|
||||
STR_ORDER_NO_UNLOAD,
|
||||
INVALID_STRING_ID,
|
||||
STR_ORDER_NO_UNLOAD_FULL_LOAD,
|
||||
STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY,
|
||||
STR_ORDER_NO_UNLOAD_NO_LOAD,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
STR_ORDER_NO_UNLOAD_CARGO_TYPE_LOAD,
|
||||
}, {
|
||||
INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID,
|
||||
INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID,
|
||||
INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID,
|
||||
}, {
|
||||
INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID,
|
||||
INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID,
|
||||
INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID,
|
||||
}, {
|
||||
INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID,
|
||||
INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID,
|
||||
INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID,
|
||||
}, {
|
||||
STR_ORDER_CARGO_TYPE_UNLOAD,
|
||||
INVALID_STRING_ID,
|
||||
STR_ORDER_CARGO_TYPE_UNLOAD_FULL_LOAD,
|
||||
STR_ORDER_CARGO_TYPE_UNLOAD_FULL_LOAD_ANY,
|
||||
STR_ORDER_CARGO_TYPE_UNLOAD_NO_LOAD,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
STR_ORDER_CARGO_TYPE_UNLOAD_CARGO_TYPE_LOAD,
|
||||
}
|
||||
}, {
|
||||
/* With auto-refitting. No loading and auto-refitting do not work together. */
|
||||
@@ -78,30 +411,67 @@ static const StringID _station_load_types[][5][5] = {
|
||||
STR_ORDER_FULL_LOAD_REFIT,
|
||||
STR_ORDER_FULL_LOAD_ANY_REFIT,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
STR_ORDER_CARGO_TYPE_LOAD_REFIT,
|
||||
}, {
|
||||
STR_ORDER_UNLOAD_REFIT,
|
||||
INVALID_STRING_ID,
|
||||
STR_ORDER_UNLOAD_FULL_LOAD_REFIT,
|
||||
STR_ORDER_UNLOAD_FULL_LOAD_ANY_REFIT,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
STR_ORDER_UNLOAD_CARGO_TYPE_LOAD_REFIT,
|
||||
}, {
|
||||
STR_ORDER_TRANSFER_REFIT,
|
||||
INVALID_STRING_ID,
|
||||
STR_ORDER_TRANSFER_FULL_LOAD_REFIT,
|
||||
STR_ORDER_TRANSFER_FULL_LOAD_ANY_REFIT,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
STR_ORDER_TRANSFER_CARGO_TYPE_LOAD_REFIT,
|
||||
}, {
|
||||
/* Unload and transfer do not work together. */
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID,
|
||||
INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID,
|
||||
INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID,
|
||||
}, {
|
||||
STR_ORDER_NO_UNLOAD_REFIT,
|
||||
INVALID_STRING_ID,
|
||||
STR_ORDER_NO_UNLOAD_FULL_LOAD_REFIT,
|
||||
STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY_REFIT,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
STR_ORDER_NO_UNLOAD_CARGO_TYPE_LOAD_REFIT,
|
||||
}, {
|
||||
INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID,
|
||||
INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID,
|
||||
INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID,
|
||||
}, {
|
||||
INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID,
|
||||
INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID,
|
||||
INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID,
|
||||
}, {
|
||||
INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID,
|
||||
INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID,
|
||||
INVALID_STRING_ID, INVALID_STRING_ID, INVALID_STRING_ID,
|
||||
}, {
|
||||
STR_ORDER_CARGO_TYPE_UNLOAD_REFIT,
|
||||
INVALID_STRING_ID,
|
||||
STR_ORDER_CARGO_TYPE_UNLOAD_FULL_LOAD_REFIT,
|
||||
STR_ORDER_CARGO_TYPE_UNLOAD_FULL_LOAD_ANY_REFIT,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
INVALID_STRING_ID,
|
||||
STR_ORDER_CARGO_TYPE_UNLOAD_CARGO_TYPE_LOAD_REFIT,
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -120,6 +490,10 @@ static const StringID _order_full_load_drowdown[] = {
|
||||
STR_ORDER_DROP_FULL_LOAD_ALL,
|
||||
STR_ORDER_DROP_FULL_LOAD_ANY,
|
||||
STR_ORDER_DROP_NO_LOADING,
|
||||
STR_EMPTY,
|
||||
STR_EMPTY,
|
||||
STR_EMPTY,
|
||||
STR_ORDER_DROP_CARGO_TYPE_LOAD,
|
||||
INVALID_STRING_ID
|
||||
};
|
||||
|
||||
@@ -129,6 +503,10 @@ static const StringID _order_unload_drowdown[] = {
|
||||
STR_ORDER_DROP_TRANSFER,
|
||||
STR_EMPTY,
|
||||
STR_ORDER_DROP_NO_UNLOADING,
|
||||
STR_EMPTY,
|
||||
STR_EMPTY,
|
||||
STR_EMPTY,
|
||||
STR_ORDER_DROP_CARGO_TYPE_UNLOAD,
|
||||
INVALID_STRING_ID
|
||||
};
|
||||
|
||||
@@ -573,12 +951,16 @@ private:
|
||||
VehicleOrderID sel_ord = this->OrderGetSel();
|
||||
const Order *order = this->vehicle->GetOrder(sel_ord);
|
||||
|
||||
if (order == NULL || order->GetLoadType() == load_type) return;
|
||||
if (order == NULL || (order->GetLoadType() == load_type && load_type != OLFB_CARGO_TYPE_LOAD)) return;
|
||||
|
||||
if (load_type < 0) {
|
||||
load_type = order->GetLoadType() == OLF_LOAD_IF_POSSIBLE ? OLF_FULL_LOAD_ANY : OLF_LOAD_IF_POSSIBLE;
|
||||
}
|
||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_LOAD | (load_type << 4), CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
||||
if (order->GetLoadType() != load_type) {
|
||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_LOAD | (load_type << 4), CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
||||
}
|
||||
|
||||
if (load_type == OLFB_CARGO_TYPE_LOAD) ShowCargoTypeOrdersWindow(this->vehicle, this, sel_ord, CTOWV_LOAD);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -627,18 +1009,22 @@ private:
|
||||
VehicleOrderID sel_ord = this->OrderGetSel();
|
||||
const Order *order = this->vehicle->GetOrder(sel_ord);
|
||||
|
||||
if (order == NULL || order->GetUnloadType() == unload_type) return;
|
||||
if (order == NULL || (order->GetUnloadType() == unload_type && unload_type != OUFB_CARGO_TYPE_UNLOAD)) return;
|
||||
|
||||
if (unload_type < 0) {
|
||||
unload_type = order->GetUnloadType() == OUF_UNLOAD_IF_POSSIBLE ? OUFB_UNLOAD : OUF_UNLOAD_IF_POSSIBLE;
|
||||
}
|
||||
|
||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_UNLOAD | (unload_type << 4), CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
||||
if (order->GetUnloadType() != unload_type) {
|
||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_UNLOAD | (unload_type << 4), CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
||||
}
|
||||
|
||||
/* Transfer orders with leave empty as default */
|
||||
if (unload_type == OUFB_TRANSFER) {
|
||||
/* Transfer orders with leave empty as default */
|
||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_LOAD | (OLFB_NO_LOAD << 4), CMD_MODIFY_ORDER);
|
||||
this->SetWidgetDirty(WID_O_FULL_LOAD);
|
||||
} else if(unload_type == OUFB_CARGO_TYPE_UNLOAD) {
|
||||
ShowCargoTypeOrdersWindow(this->vehicle, this, sel_ord, CTOWV_UNLOAD);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1255,7 +1641,7 @@ public:
|
||||
if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
|
||||
this->OrderClick_FullLoad(-1);
|
||||
} else {
|
||||
ShowDropDownMenu(this, _order_full_load_drowdown, this->vehicle->GetOrder(this->OrderGetSel())->GetLoadType(), WID_O_FULL_LOAD, 0, 2);
|
||||
ShowDropDownMenu(this, _order_full_load_drowdown, this->vehicle->GetOrder(this->OrderGetSel())->GetLoadType(), WID_O_FULL_LOAD, 0, 0xE2 /* 1110 0010 */);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1263,7 +1649,7 @@ public:
|
||||
if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
|
||||
this->OrderClick_Unload(-1);
|
||||
} else {
|
||||
ShowDropDownMenu(this, _order_unload_drowdown, this->vehicle->GetOrder(this->OrderGetSel())->GetUnloadType(), WID_O_UNLOAD, 0, 8);
|
||||
ShowDropDownMenu(this, _order_unload_drowdown, this->vehicle->GetOrder(this->OrderGetSel())->GetUnloadType(), WID_O_UNLOAD, 0, 0xE8 /* 1110 1000 */);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@@ -60,6 +60,7 @@ enum OrderUnloadFlags {
|
||||
OUFB_UNLOAD = 1 << 0, ///< Force unloading all cargo onto the platform, possibly not getting paid.
|
||||
OUFB_TRANSFER = 1 << 1, ///< Transfer all cargo onto the platform.
|
||||
OUFB_NO_UNLOAD = 1 << 2, ///< Totally no unloading will be done.
|
||||
OUFB_CARGO_TYPE_UNLOAD = 1 << 3, ///< Unload actions are defined per cargo type.
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -70,6 +71,7 @@ enum OrderLoadFlags {
|
||||
OLFB_FULL_LOAD = 1 << 1, ///< Full load all cargoes of the consist.
|
||||
OLF_FULL_LOAD_ANY = 3, ///< Full load a single cargo of the consist.
|
||||
OLFB_NO_LOAD = 4, ///< Do not load anything.
|
||||
OLFB_CARGO_TYPE_LOAD = 1 << 3 ///< Load actions are defined per cargo type.
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -155,6 +157,8 @@ enum ModifyOrderFlags {
|
||||
MOF_COND_COMPARATOR, ///< A comparator changes.
|
||||
MOF_COND_VALUE, ///< The value to set the condition to.
|
||||
MOF_COND_DESTINATION,///< Change the destination of a conditional order.
|
||||
MOF_CARGO_TYPE_UNLOAD, ///< Passes an OrderUnloadType and a CargoID.
|
||||
MOF_CARGO_TYPE_LOAD, ///< Passes an OrderLoadType and a CargoID.
|
||||
MOF_END
|
||||
};
|
||||
template <> struct EnumPropsT<ModifyOrderFlags> : MakeEnumPropsT<ModifyOrderFlags, byte, MOF_NON_STOP, MOF_END, MOF_END, 4> {};
|
||||
|
@@ -45,6 +45,8 @@ std::vector<uint32> _sl_xv_discardable_chunk_ids; ///< list of chunks
|
||||
static const uint32 _sl_xv_slxi_chunk_version = 0; ///< current version os SLXI chunk
|
||||
|
||||
const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
|
||||
{ XSLFI_CARGO_TYPE_ORDERS, XSCF_NULL, 1, 1, "cargo_type_orders", NULL, NULL, NULL },
|
||||
|
||||
{ XSLFI_NULL, XSCF_NULL, 0, 0, NULL, NULL, NULL, NULL },// This is the end marker
|
||||
};
|
||||
|
||||
|
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
enum SlXvFeatureIndex {
|
||||
XSLFI_NULL = 0, ///< Unused value, to indicate that no extended feature test is in use
|
||||
XSLFI_CARGO_TYPE_ORDERS, ///< Cargo-specific load/unload order flags
|
||||
|
||||
XSLFI_SIZE, ///< Total count of features, including null feature
|
||||
};
|
||||
|
@@ -113,6 +113,7 @@ const SaveLoad *GetOrderDescription()
|
||||
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),
|
||||
SLE_CONDARR_X(Order, cargo_type_flags, SLE_UINT8, NUM_CARGO, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_CARGO_TYPE_ORDERS, 1)),
|
||||
|
||||
/* Leftover from the minor savegame version stuff
|
||||
* We will never use those free bytes, but we have to keep this line to allow loading of old savegames */
|
||||
|
@@ -289,6 +289,18 @@ public:
|
||||
*/
|
||||
WC_VEHICLE_ORDERS = ::WC_VEHICLE_ORDERS,
|
||||
|
||||
/**
|
||||
* Vehicle cargo type load orders; %Window numbers:
|
||||
* - #VehicleID = #CargoTypeOrdersWidgets
|
||||
*/
|
||||
WC_VEHICLE_CARGO_TYPE_LOAD_ORDERS = ::WC_VEHICLE_CARGO_TYPE_LOAD_ORDERS,
|
||||
|
||||
/**
|
||||
* Vehicle cargo type unload orders; %Window numbers:
|
||||
* - #VehicleID = #CargoTypeOrdersWidgets
|
||||
*/
|
||||
WC_VEHICLE_CARGO_TYPE_UNLOAD_ORDERS = ::WC_VEHICLE_CARGO_TYPE_UNLOAD_ORDERS,
|
||||
|
||||
/**
|
||||
* Replace vehicle window; %Window numbers:
|
||||
* - #VehicleType = #ReplaceVehicleWidgets
|
||||
@@ -1945,6 +1957,21 @@ public:
|
||||
WID_O_SHARED_ORDER_LIST = ::WID_O_SHARED_ORDER_LIST, ///< Open list of shared vehicles.
|
||||
};
|
||||
|
||||
/** Widgets of the #CargoTypeOrdersWindow class. */
|
||||
enum CargoTypeOrdersWidgets {
|
||||
WID_CTO_CAPTION = ::WID_CTO_CAPTION, ///< Caption of the window.
|
||||
WID_CTO_HEADER = ::WID_CTO_HEADER, ///< Window header.
|
||||
WID_CTO_CLOSEBTN = ::WID_CTO_CLOSEBTN, ///< Close button.
|
||||
WID_CTO_SET_TO_ALL_LABEL = ::WID_CTO_SET_TO_ALL_LABEL, ///< 'Set to all' dropdown label
|
||||
WID_CTO_SET_TO_ALL_DROPDOWN = ::WID_CTO_SET_TO_ALL_DROPDOWN, ///< 'Set to all' dropdown
|
||||
WID_CTO_CARGO_ROW_FIRST = ::WID_CTO_CARGO_ROW_FIRST, ///< First cargo type order row.
|
||||
WID_CTO_CARGO_ROW_LAST = ::WID_CTO_CARGO_ROW_LAST, ///< Last cargo type order row.
|
||||
WID_CTO_CARGO_LABEL_FIRST = ::WID_CTO_CARGO_LABEL_FIRST, ///< First cargo label.
|
||||
WID_CTO_CARGO_LABEL_LAST = ::WID_CTO_CARGO_LABEL_LAST, ///< Last cargo label.
|
||||
WID_CTO_CARGO_DROPDOWN_FIRST = ::WID_CTO_CARGO_DROPDOWN_FIRST, ///< First order dropdown.
|
||||
WID_CTO_CARGO_DROPDOWN_LAST = ::WID_CTO_CARGO_DROPDOWN_LAST, ///< Last order dropdown.
|
||||
};
|
||||
|
||||
/* automatically generated from ../../widgets/osk_widget.h */
|
||||
/** Widgets of the #OskWindow class. */
|
||||
enum OnScreenKeyboardWidgets {
|
||||
|
@@ -12,6 +12,8 @@
|
||||
#ifndef WIDGETS_ORDER_WIDGET_H
|
||||
#define WIDGETS_ORDER_WIDGET_H
|
||||
|
||||
#include "../cargo_type.h"
|
||||
|
||||
/** Widgets of the #OrdersWindow class. */
|
||||
enum OrderWidgets {
|
||||
WID_O_CAPTION, ///< Caption of the window.
|
||||
@@ -41,4 +43,19 @@ enum OrderWidgets {
|
||||
WID_O_SHARED_ORDER_LIST, ///< Open list of shared vehicles.
|
||||
};
|
||||
|
||||
/** Widgets of the #CargoTypeOrdersWindow class. */
|
||||
enum CargoTypeOrdersWidgets {
|
||||
WID_CTO_CAPTION, ///< Caption of the window.
|
||||
WID_CTO_HEADER, ///< Window header.
|
||||
WID_CTO_CLOSEBTN, ///< Close button.
|
||||
WID_CTO_SET_TO_ALL_LABEL, ///< 'Set to all' dropdown label
|
||||
WID_CTO_SET_TO_ALL_DROPDOWN, ///< 'Set to all' dropdown
|
||||
WID_CTO_CARGO_ROW_FIRST, ///< First cargo type order row.
|
||||
WID_CTO_CARGO_ROW_LAST = WID_CTO_CARGO_ROW_FIRST + NUM_CARGO - 1, ///< Last cargo type order row.
|
||||
WID_CTO_CARGO_LABEL_FIRST, ///< First cargo label.
|
||||
WID_CTO_CARGO_LABEL_LAST = WID_CTO_CARGO_LABEL_FIRST + NUM_CARGO - 1, ///< Last cargo label.
|
||||
WID_CTO_CARGO_DROPDOWN_FIRST, ///< First order dropdown.
|
||||
WID_CTO_CARGO_DROPDOWN_LAST = WID_CTO_CARGO_DROPDOWN_FIRST + NUM_CARGO - 1, ///< Last order dropdown.
|
||||
};
|
||||
|
||||
#endif /* WIDGETS_ORDER_WIDGET_H */
|
||||
|
@@ -206,6 +206,18 @@ enum WindowClass {
|
||||
*/
|
||||
WC_VEHICLE_ORDERS,
|
||||
|
||||
/**
|
||||
* Vehicle cargo type load orders; %Window numbers:
|
||||
* - #VehicleID = #CargoTypeOrdersWidgets
|
||||
*/
|
||||
WC_VEHICLE_CARGO_TYPE_LOAD_ORDERS,
|
||||
|
||||
/**
|
||||
* Vehicle cargo type unload orders; %Window numbers:
|
||||
* - #VehicleID = #CargoTypeOrdersWidgets
|
||||
*/
|
||||
WC_VEHICLE_CARGO_TYPE_UNLOAD_ORDERS,
|
||||
|
||||
/**
|
||||
* Replace vehicle window; %Window numbers:
|
||||
* - #VehicleType = #ReplaceVehicleWidgets
|
||||
|
Reference in New Issue
Block a user