mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-09 19:10:38 +00:00
Scheduled dispatch: Add hints about dispatch order to timetable window
Adjust condition for dispatch order
This commit is contained in:
parent
4c15e3dacc
commit
9917a1daef
@ -4932,6 +4932,8 @@ STR_TIMETABLE_AUTO_SEPARATION_TOOLTIP :{BLACK}Automati
|
|||||||
|
|
||||||
STR_TIMETABLE_SCHEDULED_DISPATCH :{BLACK}Scheduled Dispatch
|
STR_TIMETABLE_SCHEDULED_DISPATCH :{BLACK}Scheduled Dispatch
|
||||||
STR_TIMETABLE_SCHEDULED_DISPATCH_TOOLTIP :{BLACK}Open scheduled dispatch windows for automatic setting of timetable start time
|
STR_TIMETABLE_SCHEDULED_DISPATCH_TOOLTIP :{BLACK}Open scheduled dispatch windows for automatic setting of timetable start time
|
||||||
|
STR_TIMETABLE_SCHEDULED_DISPATCH_ORDER :[scheduled dispatch]
|
||||||
|
STR_TIMETABLE_SCHEDULED_DISPATCH_ORDER_NO_WAIT_TIME :{PUSH_COLOUR}{RED}[scheduled dispatch - no wait time timetabled]{POP_COLOUR}
|
||||||
|
|
||||||
STR_TIMETABLE_EXPECTED :{BLACK}Expected
|
STR_TIMETABLE_EXPECTED :{BLACK}Expected
|
||||||
STR_TIMETABLE_SCHEDULED :{BLACK}Scheduled
|
STR_TIMETABLE_SCHEDULED :{BLACK}Scheduled
|
||||||
@ -4957,7 +4959,8 @@ STR_TIMETABLE_WARNING_AUTOSEP_MISSING_TIMINGS :{BLACK}Cannot a
|
|||||||
STR_TIMETABLE_WARNING_FULL_LOAD :{BLACK}Timetabling full-load orders is not recommended
|
STR_TIMETABLE_WARNING_FULL_LOAD :{BLACK}Timetabling full-load orders is not recommended
|
||||||
STR_TIMETABLE_WARNING_AUTOFILL_CONDITIONAL :{BLACK}Autofill will only update taken branch of conditional orders.
|
STR_TIMETABLE_WARNING_AUTOFILL_CONDITIONAL :{BLACK}Autofill will only update taken branch of conditional orders.
|
||||||
STR_TIMETABLE_NON_TIMETABLED_BRANCH :{BLACK}Not all conditional order branch-taken travel times are timetabled.
|
STR_TIMETABLE_NON_TIMETABLED_BRANCH :{BLACK}Not all conditional order branch-taken travel times are timetabled.
|
||||||
|
STR_TIMETABLE_WARNING_NO_SCHEDULED_DISPATCH_ORDER :{BLACK}No order is suitable for use with scheduled dispatch.
|
||||||
|
STR_TIMETABLE_WARNING_SCHEDULED_DISPATCH_ORDER_NO_WAIT_TIME :{BLACK}The scheduled dispatch order should have a timetabled wait time.
|
||||||
|
|
||||||
# Date window (for timetable)
|
# Date window (for timetable)
|
||||||
STR_DATE_CAPTION :{WHITE}Set date
|
STR_DATE_CAPTION :{WHITE}Set date
|
||||||
|
@ -937,6 +937,10 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
|
|||||||
if (timetable && timetable_wait_time_valid && order->GetLeaveType() == OLT_LEAVE_EARLY && edge != 0) {
|
if (timetable && timetable_wait_time_valid && order->GetLeaveType() == OLT_LEAVE_EARLY && edge != 0) {
|
||||||
edge = DrawString(rtl ? left : edge + 3, rtl ? edge - 3 : right, y, STR_TIMETABLE_LEAVE_EARLY_ORDER, colour);
|
edge = DrawString(rtl ? left : edge + 3, rtl ? edge - 3 : right, y, STR_TIMETABLE_LEAVE_EARLY_ORDER, colour);
|
||||||
}
|
}
|
||||||
|
if (timetable && HasBit(v->vehicle_flags, VF_SCHEDULED_DISPATCH) && v->GetFirstWaitingLocation(false) == order_index) {
|
||||||
|
StringID str = order->IsWaitTimetabled() ? STR_TIMETABLE_SCHEDULED_DISPATCH_ORDER : STR_TIMETABLE_SCHEDULED_DISPATCH_ORDER_NO_WAIT_TIME;
|
||||||
|
edge = DrawString(rtl ? left : edge + 3, rtl ? edge - 3 : right, y, str, colour);
|
||||||
|
}
|
||||||
|
|
||||||
if (timetable && timetable_wait_time_valid && order->IsWaitFixed() && edge != 0) {
|
if (timetable && timetable_wait_time_valid && order->IsWaitFixed() && edge != 0) {
|
||||||
Dimension lock_d = GetSpriteSize(SPR_LOCK);
|
Dimension lock_d = GetSpriteSize(SPR_LOCK);
|
||||||
|
@ -722,21 +722,9 @@ void UpdateSeparationOrder(Vehicle *v_start)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VehicleOrderID GetVehicleFirstWaitingLocation(const Vehicle *v)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < v->orders.list->GetNumOrders(); ++i) {
|
|
||||||
Order* order = v->orders.list->GetOrderAt(i);
|
|
||||||
|
|
||||||
if (order->IsWaitTimetabled() && !order->IsType(OT_IMPLICIT) && !order->IsType(OT_CONDITIONAL)) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return INVALID_VEH_ORDER_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool IsVehicleAtFirstWaitingLocation(const Vehicle *v)
|
static bool IsVehicleAtFirstWaitingLocation(const Vehicle *v)
|
||||||
{
|
{
|
||||||
return (v->cur_implicit_order_index == GetVehicleFirstWaitingLocation(v));
|
return (v->cur_implicit_order_index == v->GetFirstWaitingLocation(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
static DateTicksScaled GetScheduledDispatchTime(Vehicle *v, int wait_offset)
|
static DateTicksScaled GetScheduledDispatchTime(Vehicle *v, int wait_offset)
|
||||||
|
@ -33,8 +33,6 @@
|
|||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
|
|
||||||
VehicleOrderID GetVehicleFirstWaitingLocation(const Vehicle *v);
|
|
||||||
|
|
||||||
/** Container for the arrival/departure dates of a vehicle */
|
/** Container for the arrival/departure dates of a vehicle */
|
||||||
struct TimetableArrivalDeparture {
|
struct TimetableArrivalDeparture {
|
||||||
Ticks arrival; ///< The arrival time
|
Ticks arrival; ///< The arrival time
|
||||||
@ -114,7 +112,7 @@ static void FillTimetableArrivalDepartureTable(const Vehicle *v, VehicleOrderID
|
|||||||
}
|
}
|
||||||
|
|
||||||
VehicleOrderID scheduled_dispatch_order = INVALID_VEH_ORDER_ID;
|
VehicleOrderID scheduled_dispatch_order = INVALID_VEH_ORDER_ID;
|
||||||
if (HasBit(v->vehicle_flags, VF_SCHEDULED_DISPATCH)) scheduled_dispatch_order = GetVehicleFirstWaitingLocation(v);
|
if (HasBit(v->vehicle_flags, VF_SCHEDULED_DISPATCH)) scheduled_dispatch_order = v->GetFirstWaitingLocation(true);
|
||||||
|
|
||||||
/* Cyclically loop over all orders until we reach the current one again.
|
/* Cyclically loop over all orders until we reach the current one again.
|
||||||
* As we may start at the current order, do a post-checking loop */
|
* As we may start at the current order, do a post-checking loop */
|
||||||
@ -685,6 +683,14 @@ struct TimetableWindow : Window {
|
|||||||
if (have_bad_full_load) draw_info(STR_TIMETABLE_WARNING_FULL_LOAD, true);
|
if (have_bad_full_load) draw_info(STR_TIMETABLE_WARNING_FULL_LOAD, true);
|
||||||
if (have_conditional && HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE)) draw_info(STR_TIMETABLE_WARNING_AUTOFILL_CONDITIONAL, true);
|
if (have_conditional && HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE)) draw_info(STR_TIMETABLE_WARNING_AUTOFILL_CONDITIONAL, true);
|
||||||
if (total_time && have_non_timetabled_conditional_branch) draw_info(STR_TIMETABLE_NON_TIMETABLED_BRANCH, false);
|
if (total_time && have_non_timetabled_conditional_branch) draw_info(STR_TIMETABLE_NON_TIMETABLED_BRANCH, false);
|
||||||
|
if (HasBit(v->vehicle_flags, VF_SCHEDULED_DISPATCH)) {
|
||||||
|
VehicleOrderID n = v->GetFirstWaitingLocation(false);
|
||||||
|
if (n == INVALID_VEH_ORDER_ID) {
|
||||||
|
draw_info(STR_TIMETABLE_WARNING_NO_SCHEDULED_DISPATCH_ORDER, true);
|
||||||
|
} else if (!v->GetOrder(n)->IsWaitTimetabled()) {
|
||||||
|
draw_info(STR_TIMETABLE_WARNING_SCHEDULED_DISPATCH_ORDER_NO_WAIT_TIME, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (warning_count != this->summary_warnings) {
|
if (warning_count != this->summary_warnings) {
|
||||||
TimetableWindow *mutable_this = const_cast<TimetableWindow *>(this);
|
TimetableWindow *mutable_this = const_cast<TimetableWindow *>(this);
|
||||||
|
@ -2387,6 +2387,21 @@ void Vehicle::MarkAllViewportsDirty() const
|
|||||||
::MarkAllViewportsDirty(this->coord.left, this->coord.top, this->coord.right, this->coord.bottom);
|
::MarkAllViewportsDirty(this->coord.left, this->coord.top, this->coord.right, this->coord.bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VehicleOrderID Vehicle::GetFirstWaitingLocation(bool require_wait_timetabled) const
|
||||||
|
{
|
||||||
|
for (int i = 0; i < this->GetNumOrders(); ++i) {
|
||||||
|
const Order* order = this->GetOrder(i);
|
||||||
|
|
||||||
|
if (order->IsWaitTimetabled() && !order->IsType(OT_IMPLICIT) && !order->IsType(OT_CONDITIONAL)) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
if (order->IsType(OT_GOTO_STATION)) {
|
||||||
|
return (order->IsWaitTimetabled() || !require_wait_timetabled) ? i : INVALID_VEH_ORDER_ID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return INVALID_VEH_ORDER_ID;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get position information of a vehicle when moving one pixel in the direction it is facing
|
* Get position information of a vehicle when moving one pixel in the direction it is facing
|
||||||
* @param v Vehicle to move
|
* @param v Vehicle to move
|
||||||
|
@ -880,6 +880,8 @@ public:
|
|||||||
|
|
||||||
inline void SetServiceIntervalIsPercent(bool on) { SB(this->vehicle_flags, VF_SERVINT_IS_PERCENT, 1, on); }
|
inline void SetServiceIntervalIsPercent(bool on) { SB(this->vehicle_flags, VF_SERVINT_IS_PERCENT, 1, on); }
|
||||||
|
|
||||||
|
VehicleOrderID GetFirstWaitingLocation(bool require_wait_timetabled) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Advance cur_real_order_index to the next real order.
|
* Advance cur_real_order_index to the next real order.
|
||||||
|
Loading…
Reference in New Issue
Block a user