Skip to content

Commit

Permalink
Timetable: Show warning for wrong non-stop type orders with auto-sepa…
Browse files Browse the repository at this point in the history
…ration

See: #785
  • Loading branch information
JGRennison committed Feb 9, 2025
1 parent 0f89a50 commit cbddfbc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lang/extra/english.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1876,6 +1876,7 @@ STR_TIMETABLE_AUTOSEP_OK :{BLACK}This tim
STR_TIMETABLE_AUTOSEP_SINGLE_VEH :{BLACK}This timetable is not being auto separated because there is only 1 vehicle
STR_TIMETABLE_WARNING_AUTOSEP_CONDITIONAL :{BLACK}Cannot auto separate timetable: conditional order(s) present
STR_TIMETABLE_WARNING_AUTOSEP_MISSING_TIMINGS :{BLACK}Cannot auto separate timetable: wait or travel time(s) missing
STR_TIMETABLE_WARNING_AUTOSEP_WRONG_STOP_TYPE :{BLACK}All orders should be 'non-stop' when using auto separation
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_NON_TIMETABLED_BRANCH :{BLACK}Not all conditional order branch-taken travel times are timetabled
Expand Down
10 changes: 10 additions & 0 deletions src/timetable_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ void ProcessTimetableWarnings(const Vehicle *v, std::function<void(StringID, boo
bool have_missing_travel = false;
bool have_bad_full_load = false;
bool have_non_timetabled_conditional_branch = false;
bool have_autoseparate_bad_non_stop_type = false;

const bool assume_timetabled = HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE) || HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE);
for (int n = 0; n < v->GetNumOrders(); n++) {
Expand Down Expand Up @@ -314,10 +315,19 @@ void ProcessTimetableWarnings(const Vehicle *v, std::function<void(StringID, boo
}
}
}

if (HasBit(v->vehicle_flags, VF_TIMETABLE_SEPARATION) && !have_autoseparate_bad_non_stop_type) {
if (order->IsType(OT_IMPLICIT)) {
have_autoseparate_bad_non_stop_type = true;
} else if (order->IsGotoOrder() && (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) == 0) {
have_autoseparate_bad_non_stop_type = true;
}
}
}

if (HasBit(v->vehicle_flags, VF_TIMETABLE_SEPARATION)) {
if (have_conditional) handler(STR_TIMETABLE_WARNING_AUTOSEP_CONDITIONAL, true);
if (have_autoseparate_bad_non_stop_type) handler(STR_TIMETABLE_WARNING_AUTOSEP_WRONG_STOP_TYPE, true);
if (have_missing_wait || have_missing_travel) {
if (assume_timetabled) {
handler(STR_TIMETABLE_AUTOSEP_TIMETABLE_INCOMPLETE, false);
Expand Down

0 comments on commit cbddfbc

Please sign in to comment.