summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/order_base.h4
-rw-r--r--src/order_cmd.cpp48
-rw-r--r--src/order_gui.cpp4
-rw-r--r--src/order_type.h14
-rw-r--r--src/roadveh_cmd.cpp2
-rw-r--r--src/timetable_cmd.cpp2
-rw-r--r--src/timetable_gui.cpp10
-rw-r--r--src/vehicle.cpp10
8 files changed, 50 insertions, 44 deletions
diff --git a/src/order_base.h b/src/order_base.h
index b0c77b956..2e9ac6fc6 100644
--- a/src/order_base.h
+++ b/src/order_base.h
@@ -165,7 +165,7 @@ public:
/** How must the consist be unloaded? */
inline byte GetUnloadType() const { return GB(this->flags, 0, 2); }
/** Where must we stop? */
- inline byte GetNonStopType() const { return this->flags & OFB_NON_STOP; }
+ OrderNonStopFlags GetNonStopType() const;
/** What caused us going to the depot? */
inline byte GetDepotOrderType() const { return this->flags; }
/** What are we going to do when in the depot. */
@@ -176,7 +176,7 @@ public:
/** Set how the consist must be unloaded. */
inline void SetUnloadType(byte unload_type) { SB(this->flags, 0, 2, unload_type); }
/** Set whether we must stop at stations or not. */
- inline void SetNonStopType(byte non_stop_type) { SB(this->flags, 3, 1, !!non_stop_type); }
+ inline void SetNonStopType(OrderNonStopFlags non_stop_type) { SB(this->flags, 3, 1, !!non_stop_type); }
/** Set the cause to go to the depot. */
inline void SetDepotOrderType(byte depot_order_type) { this->flags = depot_order_type; }
/** Set what we are going to do in the depot. */
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index ef12ecf02..37a0acd64 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -39,7 +39,16 @@ assert_compile(sizeof(DestinationID) >= sizeof(StationID));
TileIndex _backup_orders_tile;
BackuppedOrders _backup_orders_data;
-DEFINE_OLD_POOL_GENERIC(Order, Order)
+DEFINE_OLD_POOL_GENERIC(Order, Order);
+
+OrderNonStopFlags Order::GetNonStopType() const
+{
+ return (this->flags & 0x8) ?
+ ((!_patches.new_nonstop || !this->IsType(OT_GOTO_STATION)) ?
+ ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS :
+ ONSF_NO_STOP_AT_DESTINATION_STATION) :
+ ONSF_STOP_EVERYWHERE;
+}
void Order::Free()
{
@@ -59,7 +68,12 @@ void Order::MakeGoToStation(StationID destination)
void Order::MakeGoToDepot(DepotID destination, bool order, CargoID cargo, byte subtype)
{
this->type = OT_GOTO_DEPOT;
- this->flags = order ? OFB_PART_OF_ORDERS : OFB_NON_STOP;
+ this->flags = 0;
+ if (order) {
+ this->SetDepotOrderType(OFB_PART_OF_ORDERS);
+ } else {
+ this->SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
+ }
this->dest = destination;
this->SetRefit(cargo, subtype);
}
@@ -303,7 +317,7 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
default: return CMD_ERROR;
}
- if (new_order.GetNonStopType() != OFB_NO_NON_STOP && v->type != VEH_TRAIN) return CMD_ERROR;
+ if (new_order.GetNonStopType() != ONSF_STOP_EVERYWHERE && v->type != VEH_TRAIN) return CMD_ERROR;
/* Order flags can be any of the following for stations:
* [full-load | unload] [+ transfer] [+ non-stop]
@@ -358,7 +372,7 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
}
}
- if (new_order.GetNonStopType() != OFB_NO_NON_STOP && v->type != VEH_TRAIN) return CMD_ERROR;
+ if (new_order.GetNonStopType() != ONSF_STOP_EVERYWHERE && v->type != VEH_TRAIN) return CMD_ERROR;
/* Order flags can be any of the following for depots:
* order [+ halt] [+ non-stop]
@@ -385,16 +399,7 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/* Order flags can be any of the following for waypoints:
* [non-stop]
* non-stop orders (if any) are only valid for trains */
- switch (new_order.GetNonStopType()) {
- case OFB_NO_NON_STOP: break;
-
- case OFB_NON_STOP:
- if (v->type != VEH_TRAIN) return CMD_ERROR;
- break;
-
- default: return CMD_ERROR;
- }
- break;
+ if (new_order.GetNonStopType() != ONSF_STOP_EVERYWHERE && v->type != VEH_TRAIN) return CMD_ERROR;
}
default: return CMD_ERROR;
@@ -588,7 +593,7 @@ CommandCost CmdDeleteOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/* NON-stop flag is misused to see if a train is in a station that is
* on his order list or not */
if (sel_ord == u->cur_order_index && u->current_order.IsType(OT_LOADING)) {
- u->current_order.SetNonStopType(OFB_NO_NON_STOP);
+ u->current_order.SetNonStopType(ONSF_STOP_EVERYWHERE);
}
/* Update any possible open window of the vehicle */
@@ -772,7 +777,7 @@ CommandCost CmdModifyOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
order->SetLoadType(0);
break;
case OF_NON_STOP:
- order->SetNonStopType(order->GetNonStopType() ^ OFB_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);
@@ -1396,9 +1401,8 @@ bool ProcessOrders(Vehicle *v)
v->cur_order_index++;
}
- /* Check if we've reached a non-stop station while TTDPatch nonstop is enabled.. */
- if (_patches.new_nonstop &&
- v->current_order.GetNonStopType() & OFB_NON_STOP &&
+ /* Check if we've reached a non-stop station.. */
+ if ((v->current_order.GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) &&
IsTileType(v->tile, MP_STATION) &&
v->current_order.GetDestination() == GetStationIndex(v->tile)) {
v->last_station_visited = v->current_order.GetDestination();
@@ -1482,10 +1486,8 @@ bool Order::ShouldStopAtStation(const Vehicle *v, StationID station) const
{
return
v->last_station_visited != station && // Do stop only when we've not just been there
- type == OT_GOTO_STATION && // Do stop only when going to a station
- /* Finally do stop when the non-stop flag is not set, or when we should stop at
- * this station according to the new_nonstop setting. */
- (!(this->flags & OFB_NON_STOP) || ((this->dest != station) == _patches.new_nonstop));
+ /* Finally do stop when there is no non-stop flag set for this type of station. */
+ !(this->GetNonStopType() & ((this->dest == station) ? ONSF_NO_STOP_AT_DESTINATION_STATION : ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS));
}
void InitializeOrders()
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index de929eac2..871bd5e3f 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -215,7 +215,7 @@ static void DrawOrdersWindow(Window *w)
SetDParam(2, GetDepot(order->GetDestination())->town_index);
switch (v->type) {
- case VEH_TRAIN: s = (order->GetNonStopType() & OFB_NON_STOP) ? STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT : STR_GO_TO_TRAIN_DEPOT; break;
+ case VEH_TRAIN: s = (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT : STR_GO_TO_TRAIN_DEPOT; break;
case VEH_ROAD: s = STR_GO_TO_ROADVEH_DEPOT; break;
case VEH_SHIP: s = STR_GO_TO_SHIP_DEPOT; break;
default: break;
@@ -235,7 +235,7 @@ static void DrawOrdersWindow(Window *w)
}
case OT_GOTO_WAYPOINT:
- SetDParam(1, (order->GetNonStopType() & OFB_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
+ SetDParam(1, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
SetDParam(2, order->GetDestination());
break;
diff --git a/src/order_type.h b/src/order_type.h
index cf2740b73..4d331a89d 100644
--- a/src/order_type.h
+++ b/src/order_type.h
@@ -59,12 +59,16 @@ enum OrderFlagMasks {
OFB_HALT_IN_DEPOT = 0x4,
/** if OFB_PART_OF_ORDERS is set, this will cause the order only be come active if the vehicle needs servicing */
OFB_SERVICE_IF_NEEDED = 0x4, //used when OFB_PART_OF_ORDERS is set.
+};
- //Common flags
- /** This causes the vehicle not to stop at intermediate OR the destination station (depending on patch settings)
- * @todo make this two different flags */
- OFB_NO_NON_STOP = 0x0,
- OFB_NON_STOP = 0x8
+/**
+ * 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
};
/** Order flags bits - these are for the *BIT macros
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 2312951f7..4eceebb64 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -1929,7 +1929,7 @@ static void CheckIfRoadVehNeedsService(Vehicle *v)
}
if (v->current_order.IsType(OT_GOTO_DEPOT) &&
- v->current_order.GetNonStopType() & OFB_NON_STOP &&
+ v->current_order.GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS &&
!Chance16(1, 20)) {
return;
}
diff --git a/src/timetable_cmd.cpp b/src/timetable_cmd.cpp
index 8dc71f59f..d2aa1f867 100644
--- a/src/timetable_cmd.cpp
+++ b/src/timetable_cmd.cpp
@@ -70,7 +70,7 @@ CommandCost CmdChangeTimetable(TileIndex tile, uint32 flags, uint32 p1, uint32 p
bool is_journey = HasBit(p1, 24) || packed_time;
if (!is_journey) {
if (!order->IsType(OT_GOTO_STATION)) return_cmd_error(STR_TIMETABLE_ONLY_WAIT_AT_STATIONS);
- if (_patches.new_nonstop && (order->GetNonStopType() & OFB_NON_STOP)) return_cmd_error(STR_TIMETABLE_NOT_STOPPING_HERE);
+ if (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) return_cmd_error(STR_TIMETABLE_NOT_STOPPING_HERE);
}
if (flags & DC_EXEC) {
diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp
index 494ed91b3..dd78c2e0f 100644
--- a/src/timetable_gui.cpp
+++ b/src/timetable_gui.cpp
@@ -79,7 +79,7 @@ static void DrawTimetableWindow(Window *w)
w->EnableWidget(TTV_CLEAR_TIME);
} else {
const Order *order = GetVehicleOrder(v, (selected + 1) / 2);
- bool disable = order == NULL || !order->IsType(OT_GOTO_STATION) || (_patches.new_nonstop && (order->GetNonStopType() & OFB_NON_STOP));
+ bool disable = order == NULL || !order->IsType(OT_GOTO_STATION) || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION);
w->SetWidgetDisabledState(TTV_CHANGE_TIME, disable);
w->SetWidgetDisabledState(TTV_CLEAR_TIME, disable);
@@ -119,7 +119,7 @@ static void DrawTimetableWindow(Window *w)
break;
case OT_GOTO_STATION:
- SetDParam(0, (order->GetNonStopType() & OFB_NON_STOP) ? STR_880A_GO_NON_STOP_TO : STR_8806_GO_TO);
+ SetDParam(0, (order->GetNonStopType() != ONSF_STOP_EVERYWHERE) ? STR_880A_GO_NON_STOP_TO : STR_8806_GO_TO);
SetDParam(1, order->GetDestination());
if (order->wait_time > 0) {
@@ -139,7 +139,7 @@ static void DrawTimetableWindow(Window *w)
SetDParam(1, GetDepot(order->GetDestination())->town_index);
switch (v->type) {
- case VEH_TRAIN: string = (order->GetNonStopType() & OFB_NON_STOP) ? STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT : STR_GO_TO_TRAIN_DEPOT; break;
+ case VEH_TRAIN: string = (order->GetNonStopType() != ONSF_STOP_EVERYWHERE) ? STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT : STR_GO_TO_TRAIN_DEPOT; break;
case VEH_ROAD: string = STR_GO_TO_ROADVEH_DEPOT; break;
case VEH_SHIP: string = STR_GO_TO_SHIP_DEPOT; break;
default: break;
@@ -152,7 +152,7 @@ static void DrawTimetableWindow(Window *w)
} break;
case OT_GOTO_WAYPOINT:
- SetDParam(0, (order->GetNonStopType() & OFB_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
+ SetDParam(0, (order->GetNonStopType() != ONSF_STOP_EVERYWHERE) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
SetDParam(1, order->GetDestination());
break;
@@ -197,7 +197,7 @@ static void DrawTimetableWindow(Window *w)
for (const Order *order = GetVehicleOrder(v, 0); order != NULL; order = order->next) {
total_time += order->travel_time + order->wait_time;
if (order->travel_time == 0) complete = false;
- if (order->wait_time == 0 && order->IsType(OT_GOTO_STATION) && !(_patches.new_nonstop && (order->GetNonStopType() & OFB_NON_STOP))) complete = false;
+ if (order->wait_time == 0 && order->IsType(OT_GOTO_STATION) && !(order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION)) complete = false;
}
if (total_time != 0) {
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 03bd7113b..50130ffe5 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -3138,12 +3138,12 @@ void Vehicle::BeginLoading()
* necessary to be known for HandleTrainLoading to determine
* whether the train is lost or not; not marking a train lost
* that arrives at random stations is bad. */
- this->current_order.SetNonStopType(OFB_NON_STOP);
+ this->current_order.SetNonStopType(ONSF_NO_STOP_AT_ANY_STATION);
current_order.MakeLoading(true);
UpdateVehicleTimetable(this, true);
} else {
- this->current_order.SetNonStopType(OFB_NO_NON_STOP);
+ this->current_order.SetNonStopType(ONSF_STOP_EVERYWHERE);
current_order.MakeLoading(false);
}
@@ -3165,7 +3165,7 @@ void Vehicle::LeaveStation()
assert(current_order.IsType(OT_LOADING));
/* Only update the timetable if the vehicle was supposed to stop here. */
- if (current_order.GetNonStopType() != OFB_NO_NON_STOP) UpdateVehicleTimetable(this, false);
+ if (current_order.GetNonStopType() != ONSF_STOP_EVERYWHERE) UpdateVehicleTimetable(this, false);
current_order.MakeLeaveStation();
GetStation(this->last_station_visited)->loading_vehicles.remove(this);
@@ -3187,11 +3187,11 @@ void Vehicle::HandleLoading(bool mode)
this->PlayLeaveStationSound();
- Order b = this->current_order;
+ bool at_destination_station = this->current_order.GetNonStopType() != ONSF_STOP_EVERYWHERE;
this->LeaveStation();
/* If this was not the final order, don't remove it from the list. */
- if (!(b.GetNonStopType() & OFB_NON_STOP)) return;
+ if (!at_destination_station) return;
break;
}