diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ai/default/default.cpp | 12 | ||||
-rw-r--r-- | src/ai/trolly/trolly.cpp | 6 | ||||
-rw-r--r-- | src/economy.cpp | 18 | ||||
-rw-r--r-- | src/industry_cmd.cpp | 4 | ||||
-rw-r--r-- | src/openttd.cpp | 4 | ||||
-rw-r--r-- | src/order_base.h | 8 | ||||
-rw-r--r-- | src/order_cmd.cpp | 20 | ||||
-rw-r--r-- | src/order_type.h | 41 | ||||
-rw-r--r-- | src/vehicle.cpp | 2 |
9 files changed, 57 insertions, 58 deletions
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp index 35407ed56..9a563e96a 100644 --- a/src/ai/default/default.cpp +++ b/src/ai/default/default.cpp @@ -2554,9 +2554,9 @@ handle_nocash: order.MakeGoToStation(AiGetStationIdByDef(aib->use_tile, aib->cur_building_rule)); - if (!is_pass && i == 1) order.SetUnloadType(OFB_UNLOAD); + if (!is_pass && i == 1) order.SetUnloadType(OUFB_UNLOAD); if (_players_ai[p->index].num_want_fullload != 0 && (is_pass || i == 0)) - order.SetLoadType(OFB_FULL_LOAD); + order.SetLoadType(OLFB_FULL_LOAD); DoCommand(0, loco_id + (i << 16), order.Pack(), DC_EXEC, CMD_INSERT_ORDER); } @@ -3289,9 +3289,9 @@ static void AiStateBuildRoadVehicles(Player *p) order.MakeGoToStation(AiGetStationIdFromRoadBlock(aib->use_tile, aib->cur_building_rule)); - if (!is_pass && i == 1) order.SetUnloadType(OFB_UNLOAD); + if (!is_pass && i == 1) order.SetUnloadType(OUFB_UNLOAD); if (_players_ai[p->index].num_want_fullload != 0 && (is_pass || i == 0)) - order.SetLoadType(OFB_FULL_LOAD); + order.SetLoadType(OLFB_FULL_LOAD); DoCommand(0, loco_id + (i << 16), order.Pack(), DC_EXEC, CMD_INSERT_ORDER); } @@ -3568,9 +3568,9 @@ static void AiStateBuildAircraftVehicles(Player *p) order.MakeGoToStation(AiGetStationIdFromAircraftBlock(aib->use_tile, aib->cur_building_rule)); - if (!is_pass && i == 1) order.SetUnloadType(OFB_UNLOAD); + if (!is_pass && i == 1) order.SetUnloadType(OUFB_UNLOAD); if (_players_ai[p->index].num_want_fullload != 0 && (is_pass || i == 0)) - order.SetLoadType(OFB_FULL_LOAD); + order.SetLoadType(OLFB_FULL_LOAD); DoCommand(0, loco_id + (i << 16), order.Pack(), DC_EXEC, CMD_INSERT_ORDER); } diff --git a/src/ai/trolly/trolly.cpp b/src/ai/trolly/trolly.cpp index 9170950df..e047a5a29 100644 --- a/src/ai/trolly/trolly.cpp +++ b/src/ai/trolly/trolly.cpp @@ -1190,14 +1190,12 @@ static void AiNew_State_GiveOrders(Player *p) idx = 0; order.MakeGoToStation(GetStationIndex(_players_ainew[p->index].to_tile)); - if (_players_ainew[p->index].tbt == AI_TRUCK && _players_ainew[p->index].to_deliver) - order.SetLoadType(OFB_FULL_LOAD); + if (_players_ainew[p->index].tbt == AI_TRUCK && _players_ainew[p->index].to_deliver) order.SetLoadType(OLFB_FULL_LOAD); AI_DoCommand(0, _players_ainew[p->index].veh_id + (idx << 16), order.Pack(), DC_EXEC, CMD_INSERT_ORDER); idx = 0; order.MakeGoToStation(GetStationIndex(_players_ainew[p->index].from_tile)); - if (_players_ainew[p->index].tbt == AI_TRUCK && _players_ainew[p->index].from_deliver) - order.SetLoadType(OFB_FULL_LOAD); + if (_players_ainew[p->index].tbt == AI_TRUCK && _players_ainew[p->index].from_deliver) order.SetLoadType(OLFB_FULL_LOAD); AI_DoCommand(0, _players_ainew[p->index].veh_id + (idx << 16), order.Pack(), DC_EXEC, CMD_INSERT_ORDER); // Start the engines! diff --git a/src/economy.cpp b/src/economy.cpp index 2e50b146f..7c70bba06 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -1489,7 +1489,7 @@ void VehiclePayment(Vehicle *front_v) if (!cp->paid_for && cp->source != last_visited && HasBit(ge->acceptance_pickup, GoodsEntry::ACCEPTANCE) && - (front_v->current_order.GetUnloadType() & OFB_TRANSFER) == 0) { + (front_v->current_order.GetUnloadType() & OUFB_TRANSFER) == 0) { /* Deliver goods to the station */ st->time_since_unload = 0; @@ -1502,8 +1502,8 @@ void VehiclePayment(Vehicle *front_v) result |= 1; SetBit(v->vehicle_flags, VF_CARGO_UNLOADING); - } else if (front_v->current_order.GetUnloadType() & (OFB_UNLOAD | OFB_TRANSFER)) { - if (!cp->paid_for && (front_v->current_order.GetUnloadType() & OFB_TRANSFER) != 0) { + } else if (front_v->current_order.GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) { + if (!cp->paid_for && (front_v->current_order.GetUnloadType() & OUFB_TRANSFER) != 0) { Money profit = GetTransportedGoodsIncome( cp->count, /* pay transfer vehicle for only the part of transfer it has done: ie. cargo_loaded_at_xy to here */ @@ -1556,7 +1556,7 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left) /* We have not waited enough time till the next round of loading/unloading */ if (--v->load_unload_time_rem != 0) { - if (_patches.improved_load && HasBit(v->current_order.GetLoadType(), OF_FULL_LOAD)) { + if (_patches.improved_load && (v->current_order.GetLoadType() & OLFB_FULL_LOAD)) { /* 'Reserve' this cargo for this vehicle, because we were first. */ for (; v != NULL; v = v->Next()) { if (v->cargo_cap != 0) cargo_left[v->cargo_type] -= v->cargo_cap - v->cargo.Count(); @@ -1604,12 +1604,12 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left) uint amount_unloaded = _patches.gradual_loading ? min(cargo_count, load_amount) : cargo_count; bool remaining; // Are there cargo entities in this vehicle that can still be unloaded here? - if (HasBit(ge->acceptance_pickup, GoodsEntry::ACCEPTANCE) && !(u->current_order.GetUnloadType() & OFB_TRANSFER)) { + if (HasBit(ge->acceptance_pickup, GoodsEntry::ACCEPTANCE) && !(u->current_order.GetUnloadType() & OUFB_TRANSFER)) { /* The cargo has reached it's final destination, the packets may now be destroyed */ remaining = v->cargo.MoveTo(NULL, amount_unloaded, CargoList::MTA_FINAL_DELIVERY, last_visited); result |= 1; - } else if (u->current_order.GetUnloadType() & (OFB_UNLOAD | OFB_TRANSFER)) { + } else if (u->current_order.GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) { remaining = v->cargo.MoveTo(&ge->cargo, amount_unloaded); SetBit(ge->acceptance_pickup, GoodsEntry::PICKUP); @@ -1638,7 +1638,7 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left) } /* Do not pick up goods that we unloaded */ - if (u->current_order.GetUnloadType() & OFB_UNLOAD) continue; + if (u->current_order.GetUnloadType() & OUFB_UNLOAD) continue; /* update stats */ int t; @@ -1710,7 +1710,7 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left) * all wagons at the same time instead of using the same 'improved' * loading algorithm for the wagons (only fill wagon when there is * enough to fill the previous wagons) */ - if (_patches.improved_load && HasBit(u->current_order.GetLoadType(), OF_FULL_LOAD)) { + if (_patches.improved_load && (u->current_order.GetLoadType() & OLFB_FULL_LOAD)) { /* Update left cargo */ for (v = u; v != NULL; v = v->Next()) { if (v->cargo_cap != 0) cargo_left[v->cargo_type] -= v->cargo_cap - v->cargo.Count(); @@ -1729,7 +1729,7 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left) } } else { bool finished_loading = true; - if (HasBit(v->current_order.GetLoadType(), OF_FULL_LOAD)) { + if (v->current_order.GetLoadType() & OLFB_FULL_LOAD) { if (_patches.full_load_any) { /* if the aircraft carries passengers and is NOT full, then * continue loading, no matter how much mail is in */ diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 510aa2219..aaf06cebb 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -1968,13 +1968,13 @@ int WhoCanServiceIndustry(Industry* ind) */ const Order *o; FOR_VEHICLE_ORDERS(v, o) { - if (o->IsType(OT_GOTO_STATION) && !HasBit(o->GetUnloadType(), OF_TRANSFER)) { + if (o->IsType(OT_GOTO_STATION) && !(o->GetUnloadType() & OUFB_TRANSFER)) { /* Vehicle visits a station to load or unload */ Station *st = GetStation(o->GetDestination()); if (!st->IsValid()) continue; /* Same cargo produced by industry is dropped here => not serviced by vehicle v */ - if (HasBit(o->GetUnloadType(), OF_UNLOAD) && !c_accepts) break; + if ((o->GetUnloadType() & OUFB_UNLOAD) && !c_accepts) break; if (stations.find(st) != stations.end()) { if (v->owner == _local_player) return 2; // Player services industry diff --git a/src/openttd.cpp b/src/openttd.cpp index 967f4e210..ec69aafb8 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -2306,8 +2306,8 @@ bool AfterLoadGame() Order *order; FOR_ALL_ORDERS(order) { if (order->IsType(OT_GOTO_STATION) && GetStation(order->GetDestination())->IsBuoy()) { - order->SetLoadType(0); - order->SetUnloadType(0); + order->SetLoadType(OLF_LOAD_IF_POSSIBLE); + order->SetUnloadType(OUF_UNLOAD_IF_POSSIBLE); } } diff --git a/src/order_base.h b/src/order_base.h index f6f2dc396..410a7f183 100644 --- a/src/order_base.h +++ b/src/order_base.h @@ -161,9 +161,9 @@ public: void SetRefit(CargoID cargo, byte subtype = 0); /** How must the consist be loaded? */ - inline byte GetLoadType() const { return this->flags & OFB_FULL_LOAD; } + inline OrderLoadFlags GetLoadType() const { return (OrderLoadFlags)(this->flags & OLFB_FULL_LOAD); } /** How must the consist be unloaded? */ - inline byte GetUnloadType() const { return GB(this->flags, 0, 2); } + inline OrderUnloadFlags GetUnloadType() const { return (OrderUnloadFlags)GB(this->flags, 0, 2); } /** Where must we stop? */ OrderNonStopFlags GetNonStopType() const; /** What caused us going to the depot? */ @@ -172,9 +172,9 @@ public: inline OrderDepotActionFlags GetDepotActionType() const { return (OrderDepotActionFlags)this->flags; } /** Set how the consist must be loaded. */ - inline void SetLoadType(byte load_type) { SB(this->flags, 2, 1, !!load_type); } + inline void SetLoadType(OrderLoadFlags load_type) { SB(this->flags, 2, 1, !!load_type); } /** Set how the consist must be unloaded. */ - inline void SetUnloadType(byte unload_type) { SB(this->flags, 0, 2, unload_type); } + inline void SetUnloadType(OrderUnloadFlags unload_type) { SB(this->flags, 0, 2, unload_type); } /** Set whether we must stop at stations or not. */ inline void SetNonStopType(OrderNonStopFlags non_stop_type) { SB(this->flags, 3, 1, !!non_stop_type); } /** Set the cause to go to the depot. */ diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index b940ba25b..ea4a9e102 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -322,11 +322,11 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) * non-stop orders (if any) are only valid for trains */ switch (new_order.GetLoadType() | new_order.GetUnloadType()) { case 0: - case OFB_FULL_LOAD: - case OFB_FULL_LOAD | OFB_TRANSFER: - case OFB_UNLOAD: - case OFB_UNLOAD | OFB_TRANSFER: - case OFB_TRANSFER: + case OLFB_FULL_LOAD: + case OLFB_FULL_LOAD | OUFB_TRANSFER: + case OUFB_UNLOAD: + case OUFB_UNLOAD | OUFB_TRANSFER: + case OUFB_TRANSFER: break; default: return CMD_ERROR; @@ -766,19 +766,19 @@ CommandCost CmdModifyOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) if (order->IsType(OT_GOTO_DEPOT)) { order->SetDepotOrderType((OrderDepotTypeFlags)(order->GetDepotOrderType() ^ ODTFB_SERVICE)); } else { - order->SetLoadType(order->GetLoadType() ^ OFB_FULL_LOAD); - order->SetUnloadType(order->GetUnloadType() & ~OFB_UNLOAD); + order->SetLoadType((OrderLoadFlags)(order->GetLoadType() ^ OLFB_FULL_LOAD)); + order->SetUnloadType((OrderUnloadFlags)(order->GetUnloadType() & ~OUFB_UNLOAD)); } break; case OF_UNLOAD: - order->SetUnloadType(order->GetUnloadType() ^ OFB_UNLOAD); - order->SetLoadType(0); + order->SetUnloadType((OrderUnloadFlags)(order->GetUnloadType() ^ OUFB_UNLOAD)); + order->SetLoadType(OLF_LOAD_IF_POSSIBLE); break; case OF_NON_STOP: order->SetNonStopType(order->GetNonStopType() == ONSF_STOP_EVERYWHERE ? ONSF_NO_STOP_AT_ANY_STATION : ONSF_STOP_EVERYWHERE); break; case OF_TRANSFER: - order->SetUnloadType(order->GetUnloadType() ^ OFB_TRANSFER); + order->SetUnloadType((OrderUnloadFlags)(order->GetUnloadType() ^ OUFB_TRANSFER)); break; default: NOT_REACHED(); } diff --git a/src/order_type.h b/src/order_type.h index 4a21807e9..ec8be1b7c 100644 --- a/src/order_type.h +++ b/src/order_type.h @@ -36,29 +36,31 @@ template <> struct EnumPropsT<OrderType> : MakeEnumPropsT<OrderType, byte, OT_BE typedef TinyEnumT<OrderType> OrderTypeByte; -/* Order flags -- please use OF instead OF and use HASBIT/SETBIT/CLEARBIT */ - -/** Order flag masks - these are for direct bit operations */ -enum OrderFlagMasks { - //Flags for stations: - /** vehicle will transfer cargo (i. e. not deliver to nearby industry/town even if accepted there) */ - OFB_TRANSFER = 0x1, - /** If OFB_TRANSFER is not set, drop any cargo loaded. If accepted, deliver, otherwise cargo remains at the station. - * No new cargo is loaded onto the vehicle whatsoever */ - OFB_UNLOAD = 0x2, - /** Wait for full load of all vehicles, or of at least one cargo type, depending on patch setting - * @todo make this two different flags */ - OFB_FULL_LOAD = 0x4, +/** + * Flags related to the unloading order. + */ +enum OrderUnloadFlags { + OUF_UNLOAD_IF_POSSIBLE = 0, ///< Unload all cargo that the station accepts. + OUFB_TRANSFER = 1 << 0, ///< Transfer all cargo onto the platform. + OUFB_UNLOAD = 1 << 1, ///< Force unloading all cargo onto the platform, possibly not getting paid. +}; + +/** + * Flags related to the loading order. + */ +enum OrderLoadFlags { + OLF_LOAD_IF_POSSIBLE = 0, ///< Load as long as there is cargo that fits in the train. + OLFB_FULL_LOAD = 1 << 2, ///< Full load the complete (or a single cargo) of the consist. }; /** * Non-stop order flags. */ enum OrderNonStopFlags { - ONSF_STOP_EVERYWHERE = 0, - ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS = 1, - ONSF_NO_STOP_AT_DESTINATION_STATION = 2, - ONSF_NO_STOP_AT_ANY_STATION = 3 + ONSF_STOP_EVERYWHERE = 0, ///< The vehicle will stop at any station it passes and the destination. + ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS = 1, ///< The vehicle will not stop at any stations it passes except the destination. + ONSF_NO_STOP_AT_DESTINATION_STATION = 2, ///< The vehicle will stop at any station it passes except the destination. + ONSF_NO_STOP_AT_ANY_STATION = 3, ///< The vehicle will not stop at any stations it passes including the destination. }; /** @@ -78,9 +80,8 @@ enum OrderDepotActionFlags { ODATFB_HALT = 1 << 2, ///< Service the vehicle and then halt it. }; -/** Order flags bits - these are for the *BIT macros - * for descrption of flags, see OrderFlagMasks - * @see OrderFlagMasks +/** + * Enumeration for the 'flag' to toggle in CmdModifyOrder. */ enum { OF_TRANSFER = 0, diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 5cdf9e35d..c8c963b7c 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -2175,7 +2175,7 @@ uint8 CalcPercentVehicleFilled(Vehicle *v, StringID *color) max += v->cargo_cap; if (v->cargo_cap != 0) { unloading += HasBit(v->vehicle_flags, VF_CARGO_UNLOADING) ? 1 : 0; - loading |= !HasBit(u->current_order.GetUnloadType(), OF_UNLOAD) && st->goods[v->cargo_type].days_since_pickup != 255; + loading |= !(u->current_order.GetUnloadType() & OUFB_UNLOAD) && st->goods[v->cargo_type].days_since_pickup != 255; cars++; } } |