From 02aecca5aea8acf35862f4d1f06e0a22669308a2 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sun, 27 Aug 2023 11:16:59 +0100 Subject: [PATCH] Conditional order: Replace "next station" with manually set station --- src/lang/extra/czech.txt | 16 +-- src/lang/extra/english.txt | 22 ++-- src/lang/extra/galician.txt | 16 +-- src/lang/extra/german.txt | 16 +-- src/lang/extra/korean.txt | 12 +-- src/lang/extra/russian.txt | 5 +- src/lang/extra/simplified_chinese.txt | 14 +-- src/order_base.h | 7 ++ src/order_cmd.cpp | 48 +++++---- src/order_cmd.h | 2 +- src/order_gui.cpp | 139 ++++++++++++++++++++------ src/order_type.h | 14 ++- src/saveload/afterload.cpp | 31 +++++- src/sl/extended_ver_sl.cpp | 2 +- src/widgets/order_widget.h | 2 + 15 files changed, 219 insertions(+), 127 deletions(-) diff --git a/src/lang/extra/czech.txt b/src/lang/extra/czech.txt index 5f15d546f6..c8a49acd3d 100644 --- a/src/lang/extra/czech.txt +++ b/src/lang/extra/czech.txt @@ -1506,13 +1506,6 @@ STR_ORDER_DROP_SELL_DEPOT :Prodat vozidlo STR_ORDER_CONDITIONAL_VEHICLE_IN_SLOT :Vozidlo ve slotu -STR_ORDER_CONDITIONAL_REQUIRES_SERVICE_ORDER :{STRING}, že vyžaduje údržbu -STR_ORDER_CONDITIONAL_CARGO_WAITING_ORDER :další stanice {STRING} čekající {STRING} -STR_ORDER_CONDITIONAL_ACCEPTANCE :další stanice {STRING} {STRING} - -STR_CONDITIONAL_FREE_PLATFORMS :Skočit na příkaz {COMMA}, když další stanice {STRING} {COMMA} {P "volné nástupiště" "volná nástupiště" "volných nástupišť"} -STR_CONDITIONAL_PERCENT :Skočit na příkaz {COMMA} v {COMMA} procentech případů - STR_ORDER_CONDITIONAL_NEXT_STATION :Další stanice STR_ORDER_CONDITIONAL_CARGO_TOOLTIP :{BLACK}Náklad, s nímž mají být porovnávány údaje ze stanice STR_ORDER_CONDITIONAL_SLOT_TOOLTIP :{BLACK}Vlakový slot, jehož obsazenost má být ověřena @@ -1611,15 +1604,16 @@ STR_ORDER_RV_DIR_SE :[jihovýchodní STR_ORDER_RV_DIR_SW :[jihozápadní směr] STR_ORDER_RV_DIR_NW :[severozápadní směr] -STR_ORDER_CONDITIONAL_CARGO_ACCEPTANCE :Skočit na příkaz {COMMA}, když další stanice {STRING} {STRING} -STR_ORDER_CONDITIONAL_CARGO_WAITING_DISPLAY :Skočit na příkaz {COMMA}, když další stanice {STRING} čekající {STRING} +STR_ORDER_CONDITIONAL_PERCENT_DISPLAY :Skočit na příkaz {COMMA} v {COMMA} procentech případů +STR_ORDER_CONDITIONAL_CARGO_ACCEPTANCE :Skočit na příkaz {COMMA}, když {STRING} {STRING} {STRING} +STR_ORDER_CONDITIONAL_CARGO_WAITING_DISPLAY :Skočit na příkaz {COMMA}, když {STRING} {STRING} čekající {STRING} STR_ORDER_CONDITIONAL_SLOT :Skočit na příkaz {COMMA}, když {TRSLOT} {STRING} STR_ORDER_CONDITIONAL_INVALID_SLOT :Skočit na příkaz {COMMA}, když {PUSH_COLOUR}{RED}{STRING} {POP_COLOUR}{STRING} STR_ORDER_CONDITIONAL_IN_SLOT :Skočit na příkaz {COMMA}, když {STRING} slotu: {TRSLOT} STR_ORDER_CONDITIONAL_IN_INVALID_SLOT :Skočit na příkaz {COMMA}, když {STRING} {PUSH_COLOUR}{RED}{STRING} {POP_COLOUR} STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE_DISPLAY :Skočit na příkaz {COMMA}, když procento naložení {STRING} {STRING} {COMMA} -STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_DISPLAY :Skočit na příkaz {COMMA}, když množství {STRING} v další stanici {STRING} {CARGO_SHORT} -STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_VIA_DISPLAY :Skočit na příkaz {COMMA}, když množství {STRING} v další stanici přes {STATION} {STRING} {CARGO_SHORT} +STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_DISPLAY :Skočit na příkaz {COMMA}, když množství {STRING} v {STRING} {STRING} {CARGO_SHORT} +STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_VIA_DISPLAY :Skočit na příkaz {COMMA}, když množství {STRING} v {STRING} přes {STRING} {STRING} {CARGO_SHORT} STR_ORDER_CONDITIONAL_COUNTER :Skočit na příkaz {COMMA}, když hodnota {TRCOUNTER} {STRING} {COMMA} STR_ORDER_CONDITIONAL_INVALID_COUNTER :Skočit na příkaz {COMMA}, když hodnota {PUSH_COLOUR}{RED}{STRING}{POP_COLOUR} {STRING} {COMMA} STR_ORDER_CONDITIONAL_TIME_HHMM :Skočit na příkaz {COMMA}, když {STRING} {STRING} {TIME_HHMM} diff --git a/src/lang/extra/english.txt b/src/lang/extra/english.txt index 2007a0fabe..16dfd4c555 100644 --- a/src/lang/extra/english.txt +++ b/src/lang/extra/english.txt @@ -18,6 +18,7 @@ STR_JUST_STRING3 :{STRING3} STR_JUST_VELOCITY :{VELOCITY} STR_JUST_TT_TICKS :{TT_TICKS} STR_JUST_TT_TICKS_LONG :{TT_TICKS_LONG} +STR_JUST_STATION :{STATION} STR_RED_INT :{RED}{NUM} @@ -1566,13 +1567,6 @@ STR_ORDER_DROP_SELL_DEPOT :Sell vehicle STR_ORDER_CONDITIONAL_VEHICLE_IN_SLOT :Vehicle in slot -STR_ORDER_CONDITIONAL_REQUIRES_SERVICE_ORDER :Requires service {STRING} -STR_ORDER_CONDITIONAL_CARGO_WAITING_ORDER :Next station {STRING} {STRING} waiting -STR_ORDER_CONDITIONAL_ACCEPTANCE :Next station {STRING} {STRING} - -STR_CONDITIONAL_FREE_PLATFORMS :Jump to order {COMMA} when Next station {STRING} {COMMA} free platform{P "" s} -STR_CONDITIONAL_PERCENT :Jump to order {COMMA} {COMMA} percent of times - STR_ORDER_CONDITIONAL_NEXT_STATION :Next station STR_ORDER_CONDITIONAL_CARGO_TOOLTIP :{BLACK}The cargo to compare the station data against STR_ORDER_CONDITIONAL_SLOT_TOOLTIP :{BLACK}The train slot to check the occupancy of @@ -1583,6 +1577,8 @@ STR_ORDER_CONDITIONAL_SCHED_SELECT_TOOLTIP :{BLACK}The disp STR_ORDER_CONDITIONAL_SCHED_TEST_TOOLTIP :{BLACK}The dispatch schedule condition to test STR_ORDER_CONDITIONAL_VIA :{BLACK}Via STR_ORDER_CONDITIONAL_VIA_TOOLTIP :{BLACK}The via station to check the waiting cargo amount for +STR_ORDER_CONDITIONAL_STATION :{BLACK}Station +STR_ORDER_CONDITIONAL_STATION_TOOLTIP :{BLACK}The station to check STR_ORDER_CONDITIONAL_COMPARATOR_ACCEPTS :accepts STR_ORDER_CONDITIONAL_COMPARATOR_DOES_NOT_ACCEPT :does not accept @@ -1671,15 +1667,19 @@ STR_ORDER_RV_DIR_SE :[south-east dir STR_ORDER_RV_DIR_SW :[south-west direction] STR_ORDER_RV_DIR_NW :[north-west direction] -STR_ORDER_CONDITIONAL_CARGO_ACCEPTANCE :Jump to order {COMMA} when Next station {STRING} {STRING} -STR_ORDER_CONDITIONAL_CARGO_WAITING_DISPLAY :Jump to order {COMMA} when Next station {STRING} {STRING} +STR_ORDER_CONDITIONAL_UNDEFINED_STATION :{PUSH_COLOUR}{RED}undefined station{POP_COLOUR} + +STR_ORDER_CONDITIONAL_FREE_PLATFORMS_DISPLAY :Jump to order {COMMA} when {STRING1} {STRING} {COMMA} free platform{P "" s} +STR_ORDER_CONDITIONAL_PERCENT_DISPLAY :Jump to order {COMMA} {COMMA} percent of times +STR_ORDER_CONDITIONAL_CARGO_ACCEPTANCE :Jump to order {COMMA} when {STRING1} {STRING} {STRING} +STR_ORDER_CONDITIONAL_CARGO_WAITING_DISPLAY :Jump to order {COMMA} when {STRING1} {STRING} {STRING} STR_ORDER_CONDITIONAL_SLOT :Jump to order {COMMA} when {TRSLOT} {STRING} STR_ORDER_CONDITIONAL_INVALID_SLOT :Jump to order {COMMA} when {PUSH_COLOUR}{RED}{STRING} {POP_COLOUR}{STRING} STR_ORDER_CONDITIONAL_IN_SLOT :Jump to order {COMMA} when {STRING} slot: {TRSLOT} STR_ORDER_CONDITIONAL_IN_INVALID_SLOT :Jump to order {COMMA} when {STRING} {PUSH_COLOUR}{RED}{STRING} {POP_COLOUR} STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE_DISPLAY :Jump to order {COMMA} when Load percentage of {STRING} {STRING} {COMMA} -STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_DISPLAY :Jump to order {COMMA} when {STRING} at next station {STRING} {CARGO_SHORT} -STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_VIA_DISPLAY :Jump to order {COMMA} when {STRING} at next station via {STATION} {STRING} {CARGO_SHORT} +STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_DISPLAY :Jump to order {COMMA} when {STRING} at {STRING1} {STRING} {CARGO_SHORT} +STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_VIA_DISPLAY :Jump to order {COMMA} when {STRING} at {STRING1} via {STRING1} {STRING} {CARGO_SHORT} STR_ORDER_CONDITIONAL_COUNTER :Jump to order {COMMA} when value of {TRCOUNTER} {STRING} {COMMA} STR_ORDER_CONDITIONAL_INVALID_COUNTER :Jump to order {COMMA} when value of {PUSH_COLOUR}{RED}{STRING}{POP_COLOUR} {STRING} {COMMA} STR_ORDER_CONDITIONAL_TIME_HHMM :Jump to order {COMMA} when {STRING} {STRING} {TIME_HHMM} diff --git a/src/lang/extra/galician.txt b/src/lang/extra/galician.txt index 0e0189a058..c6df344a5b 100644 --- a/src/lang/extra/galician.txt +++ b/src/lang/extra/galician.txt @@ -1513,13 +1513,6 @@ STR_ORDER_DROP_SELL_DEPOT :Vender vehícul STR_ORDER_CONDITIONAL_VEHICLE_IN_SLOT :Vehículo en slot -STR_ORDER_CONDITIONAL_REQUIRES_SERVICE_ORDER :Precisa servizo {STRING} -STR_ORDER_CONDITIONAL_CARGO_WAITING_ORDER :Próxima estación {STRING} {STRING} agardando -STR_ORDER_CONDITIONAL_ACCEPTANCE :Próxima estación {STRING} {STRING} - -STR_CONDITIONAL_FREE_PLATFORMS :Saltar á orde {COMMA} cando a próxima estación {STRING} {COMMA} plataforma{P "" s} libre{P "" s} -STR_CONDITIONAL_PERCENT :Saltar á orde {COMMA} {COMMA} porcentaxe das veces - STR_ORDER_CONDITIONAL_NEXT_STATION :Próxima estación STR_ORDER_CONDITIONAL_CARGO_TOOLTIP :{BLACK}A carga contra a que comparar os datos da estación STR_ORDER_CONDITIONAL_SLOT_TOOLTIP :{BLACK}O Slot de tren no que comprobar a ocupación @@ -1617,15 +1610,16 @@ STR_ORDER_RV_DIR_SE :[dirección sue STR_ORDER_RV_DIR_SW :[dirección suroeste] STR_ORDER_RV_DIR_NW :[dirección noroeste] -STR_ORDER_CONDITIONAL_CARGO_ACCEPTANCE :Saltar á orde {COMMA} cando a próxima estación {STRING} {STRING} -STR_ORDER_CONDITIONAL_CARGO_WAITING_DISPLAY :Saltar á orde {COMMA} cando a pŕoxima estación {STRING} {STRING} +STR_ORDER_CONDITIONAL_PERCENT_DISPLAY :Saltar á orde {COMMA} {COMMA} porcentaxe das veces +STR_ORDER_CONDITIONAL_CARGO_ACCEPTANCE :Saltar á orde {COMMA} cando a {STRING} {STRING} {STRING} +STR_ORDER_CONDITIONAL_CARGO_WAITING_DISPLAY :Saltar á orde {COMMA} cando a {STRING} {STRING} {STRING} STR_ORDER_CONDITIONAL_SLOT :Saltar á orde {COMMA} cando {TRSLOT} {STRING} STR_ORDER_CONDITIONAL_INVALID_SLOT :Saltar á orde {COMMA} cando {PUSH_COLOUR}{RED}{STRING} {POP_COLOUR}{STRING} STR_ORDER_CONDITIONAL_IN_SLOT :Saltar á orde {COMMA} cando {STRING} no slot: {TRSLOT} STR_ORDER_CONDITIONAL_IN_INVALID_SLOT :Saltar á orde {COMMA} cando {STRING} {PUSH_COLOUR}{RED}{STRING} {POP_COLOUR} STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE_DISPLAY :Saltar á orde {COMMA} cando o porcentaxe de carga de {STRING} {STRING} {COMMA} -STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_DISPLAY :Saltar á orde {COMMA} cando {STRING} na próxima estación {STRING} {CARGO_SHORT} -STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_VIA_DISPLAY :Saltar á orde {COMMA} cando {STRING} na próxima estación vía {STATION} {STRING} {CARGO_SHORT} +STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_DISPLAY :Saltar á orde {COMMA} cando {STRING} na {STRING} {STRING} {CARGO_SHORT} +STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_VIA_DISPLAY :Saltar á orde {COMMA} cando {STRING} na {STRING} vía {STRING} {STRING} {CARGO_SHORT} STR_ORDER_CONDITIONAL_COUNTER :Saltar á orde {COMMA} cando o valor de {TRCOUNTER} {STRING} {COMMA} STR_ORDER_CONDITIONAL_INVALID_COUNTER :Saltar á orde {COMMA} cando o valor de {PUSH_COLOUR}{RED}{STRING}{POP_COLOUR} {STRING} {COMMA} STR_ORDER_CONDITIONAL_TIME_HHMM :Saltar á orde {COMMA} cando {STRING} {STRING} {TIME_HHMM} diff --git a/src/lang/extra/german.txt b/src/lang/extra/german.txt index 5b3effb742..9a0074b055 100644 --- a/src/lang/extra/german.txt +++ b/src/lang/extra/german.txt @@ -1353,13 +1353,6 @@ STR_ORDER_DROP_SELL_DEPOT :Fahrzeug verkau STR_ORDER_CONDITIONAL_VEHICLE_IN_SLOT :Fahrzeug im Zeitfenster -STR_ORDER_CONDITIONAL_REQUIRES_SERVICE_ORDER :Wartung erforderlich {STRING} -STR_ORDER_CONDITIONAL_CARGO_WAITING_ORDER :nächste Station {STRING} wartende{G 1 n "" s ""} {STRING} -STR_ORDER_CONDITIONAL_ACCEPTANCE :nächste Station {STRING} {STRING} - -STR_CONDITIONAL_FREE_PLATFORMS :Springe zu Auftrag {COMMA} wenn die nächste Station {STRING} {COMMA} freie{P n ""} Bahnsteig{P "" e} -STR_CONDITIONAL_PERCENT :Springe zu Auftrag {COMMA} in {COMMA} Prozent der Fälle - STR_ORDER_CONDITIONAL_NEXT_STATION :nächste Station STR_ORDER_CONDITIONAL_CARGO_TOOLTIP :{BLACK}Frachtart, die mit der Stationsinformation verglichen wird STR_ORDER_CONDITIONAL_SLOT_TOOLTIP :{BLACK}Zugslot, dessen Auslastung geprüft wird @@ -1432,15 +1425,16 @@ STR_ORDER_RV_DIR_SE :[Südost-Richtu STR_ORDER_RV_DIR_SW :[Südwest-Richtung] STR_ORDER_RV_DIR_NW :[Nordwest-Richtung] -STR_ORDER_CONDITIONAL_CARGO_ACCEPTANCE :Springe zu Auftrag {COMMA}, wenn nächste Station {STRING} {STRING} -STR_ORDER_CONDITIONAL_CARGO_WAITING_DISPLAY :Springe zu Auftrag {COMMA}, wenn nächste Station {STRING} {STRING} +STR_ORDER_CONDITIONAL_PERCENT_DISPLAY :Springe zu Auftrag {COMMA} in {COMMA} Prozent der Fälle +STR_ORDER_CONDITIONAL_CARGO_ACCEPTANCE :Springe zu Auftrag {COMMA}, wenn {STRING} {STRING} {STRING} +STR_ORDER_CONDITIONAL_CARGO_WAITING_DISPLAY :Springe zu Auftrag {COMMA}, wenn {STRING} {STRING} {STRING} STR_ORDER_CONDITIONAL_SLOT :Springe zu Auftrag {COMMA}, wenn {TRSLOT} {STRING} STR_ORDER_CONDITIONAL_INVALID_SLOT :Springe zu Auftrag {COMMA}, wenn {PUSH_COLOUR}{RED}{STRING} {POP_COLOUR}{STRING} STR_ORDER_CONDITIONAL_IN_SLOT :Springe zu Auftrag {COMMA}, wenn {STRING} Slot: {TRSLOT} STR_ORDER_CONDITIONAL_IN_INVALID_SLOT :Springe zu Auftrag {COMMA}, wenn {STRING} {PUSH_COLOUR}{RED}{STRING} {POP_COLOUR} STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE_DISPLAY :Springe zu Auftrag {COMMA}, wenn Ladezustand (Prozent) gleich {STRING} {STRING} {COMMA} ist -STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_DISPLAY :Springe zu Auftrag {COMMA}, wenn {STRING} bei nächster Station {STRING} {CARGO_SHORT} -STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_VIA_DISPLAY :Springe zu Auftrag {COMMA}, wenn {STRING} bei nächster Station über {STATION} {STRING} {CARGO_SHORT} +STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_DISPLAY :Springe zu Auftrag {COMMA}, wenn {STRING} bei {STRING} {STRING} {CARGO_SHORT} +STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_VIA_DISPLAY :Springe zu Auftrag {COMMA}, wenn {STRING} bei {STRING} über {STRING} {STRING} {CARGO_SHORT} STR_ORDER_CONDITIONAL_COUNTER :Springe zu Auftrag {COMMA}, wenn Wert von {TRCOUNTER} {STRING} {COMMA} ist STR_ORDER_CONDITIONAL_INVALID_COUNTER :Springe zu Auftrag {COMMA}, wenn Wert von {PUSH_COLOUR}{RED}{STRING}{POP_COLOUR} {STRING} {COMMA} ist STR_ORDER_CONDITIONAL_TIME_HHMM :Springe zu Auftrag {COMMA}, wenn {STRING} {STRING} {TIME_HHMM} diff --git a/src/lang/extra/korean.txt b/src/lang/extra/korean.txt index e4446c0891..f1cc4b4317 100644 --- a/src/lang/extra/korean.txt +++ b/src/lang/extra/korean.txt @@ -1513,13 +1513,6 @@ STR_ORDER_DROP_SELL_DEPOT :판매 STR_ORDER_CONDITIONAL_VEHICLE_IN_SLOT :{G=m}슬롯에 있는 차량 -STR_ORDER_CONDITIONAL_REQUIRES_SERVICE_ORDER :서비스 {STRING}가 필요함 -STR_ORDER_CONDITIONAL_CARGO_WAITING_ORDER :다음 역 {STRING} {STRING} 대기 중 -STR_ORDER_CONDITIONAL_ACCEPTANCE :다음 역 {STRING} {STRING} - -STR_CONDITIONAL_FREE_PLATFORMS :[조건 경로] {COMMA}번 경로로 건너뛰기 (다음 역에 빈 승강장이 {2:COMMA}개 {1:STRING}) -STR_CONDITIONAL_PERCENT :[조건 경로] {COMMA}번 경로로 건너뛰기 ({COMMA}%의 확률로) - STR_ORDER_CONDITIONAL_NEXT_STATION :다음 역: STR_ORDER_CONDITIONAL_CARGO_TOOLTIP :{BLACK}비교할 화물을 선택하세요 STR_ORDER_CONDITIONAL_SLOT_TOOLTIP :{BLACK}점유되었는지 확인할 슬롯을 선택하세요 @@ -1618,15 +1611,12 @@ STR_ORDER_RV_DIR_SE :[남동쪽 방 STR_ORDER_RV_DIR_SW :[남서쪽 방향] STR_ORDER_RV_DIR_NW :[북서쪽 방향] -STR_ORDER_CONDITIONAL_CARGO_ACCEPTANCE :[조건 경로] {COMMA}번 경로로 건너뛰기 (다음 역이 {2:STRING}{G 2 "을" "를"} {1:STRING}) -STR_ORDER_CONDITIONAL_CARGO_WAITING_DISPLAY :[조건 경로] {COMMA}번 경로로 건너뛰기 (다음 역에 {2:STRING}{G 2 "이" "가"} {1:STRING}) +STR_ORDER_CONDITIONAL_PERCENT_DISPLAY :[조건 경로] {COMMA}번 경로로 건너뛰기 ({COMMA}%의 확률로) STR_ORDER_CONDITIONAL_SLOT :[조건 경로] {COMMA}번 경로로 건너뛰기 ({TRSLOT} 슬롯이 {STRING}) STR_ORDER_CONDITIONAL_INVALID_SLOT :[조건 경로] {COMMA}번 경로로 건너뛰기 ({PUSH_COLOUR}{RED}{STRING}{POP_COLOUR} 슬롯이 {STRING}) STR_ORDER_CONDITIONAL_IN_SLOT :[조건 경로] {COMMA}번 경로로 건너뛰기 (열차가 {2:TRSLOT} 슬롯에 {1:STRING}) STR_ORDER_CONDITIONAL_IN_INVALID_SLOT :[조건 경로] {COMMA}번 경로로 건너뛰기 (열차가 {PUSH_COLOUR}{RED}{2:STRING}{POP_COLOUR}{1:STRING}) STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE_DISPLAY :[조건 경로] {COMMA}번 경로로 건너뛰기 ({STRING}의 적재율 {STRING} {COMMA}일 때) -STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_DISPLAY :[조건 경로] {COMMA}번 경로로 건너뛰기 (다음 역의 {STRING} 대기량 {STRING} {CARGO_SHORT}일 때) -STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_VIA_DISPLAY :[조건 경로] {COMMA}번 경로로 건너뛰기 (다음 역에 있는 {2:STATION} 경유 {1:STRING} {3:STRING} {4:CARGO_SHORT}일 때) STR_ORDER_CONDITIONAL_COUNTER :[조건 경로] {COMMA}번 경로로 건너뛰기 ({TRCOUNTER}의 값 {STRING} {COMMA}일 때) STR_ORDER_CONDITIONAL_INVALID_COUNTER :[조건 경로] {COMMA}번 경로로 건너뛰기 ({PUSH_COLOUR}{RED}{STRING}{POP_COLOUR}의 값 {STRING} {COMMA}일 때) STR_ORDER_CONDITIONAL_TIME_HHMM :[조건 경로] {COMMA}번 경로로 건너뛰기 ({STRING} {STRING} {TIME_HHMM}일 때) diff --git a/src/lang/extra/russian.txt b/src/lang/extra/russian.txt index 91be7a0cff..c018c9673f 100644 --- a/src/lang/extra/russian.txt +++ b/src/lang/extra/russian.txt @@ -54,9 +54,6 @@ STR_PURCHASE_INFO_DESIGNED :{BLACK}Разр STR_BUY_REFIT_VEHICLE_BUY_VEHICLE_BUTTON :{BLACK}Переоборудовать STR_BUY_REFIT_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Переоборудовать купленное транспортное средство сразу после покупки для выделенного вида груза -STR_CONDITIONAL_FREE_PLATFORMS :Перейти к заданию {COMMA} когда след. станция {STRING} {COMMA} свободн{P ая ые ых} платформ{P а ы ""} -STR_CONDITIONAL_PERCENT :Перейти к заданию {COMMA} {COMMA} процентов времени - STR_ORDER_CONDITIONAL_COMPARATOR_ACCEPTS :принимает STR_ORDER_CONDITIONAL_COMPARATOR_DOES_NOT_ACCEPT :не принимает STR_ORDER_CONDITIONAL_COMPARATOR_HAS :имеет @@ -66,6 +63,8 @@ STR_ORDER_CONDITIONAL_COMPARATOR_HAS_LESS_EQUALS :имеет ме STR_ORDER_CONDITIONAL_COMPARATOR_HAS_MORE_THAN :имеет больше чем STR_ORDER_CONDITIONAL_COMPARATOR_HAS_MORE_EQUALS :имеет больше или равно +STR_ORDER_CONDITIONAL_PERCENT_DISPLAY :Перейти к заданию {COMMA} {COMMA} процентов времени + # Cargo type orders Window # Plans window diff --git a/src/lang/extra/simplified_chinese.txt b/src/lang/extra/simplified_chinese.txt index b26a19b1d5..b83f652297 100644 --- a/src/lang/extra/simplified_chinese.txt +++ b/src/lang/extra/simplified_chinese.txt @@ -1422,13 +1422,6 @@ STR_ORDER_DROP_SELL_DEPOT :卖出车辆 STR_ORDER_CONDITIONAL_VEHICLE_IN_SLOT :条目内车辆 -STR_ORDER_CONDITIONAL_REQUIRES_SERVICE_ORDER :服务需求 {STRING} -STR_ORDER_CONDITIONAL_CARGO_WAITING_ORDER :下一站 {STRING} {STRING} 等待中 -STR_ORDER_CONDITIONAL_ACCEPTANCE :下一站 {STRING} {STRING} - -STR_CONDITIONAL_FREE_PLATFORMS :跳转至调度计划 {COMMA} 当下一站 {STRING} {COMMA} 拥有自由站台 -STR_CONDITIONAL_PERCENT :跳转至调度计划 {COMMA} {COMMA} 次数百分比 - STR_ORDER_CONDITIONAL_NEXT_STATION :下一站 STR_ORDER_CONDITIONAL_CARGO_TOOLTIP :{BLACK}货物对比车站数据 STR_ORDER_CONDITIONAL_SLOT_TOOLTIP :{BLACK}火车槽位检查占用率: @@ -1513,15 +1506,14 @@ STR_ORDER_RV_DIR_SE :[东南方] STR_ORDER_RV_DIR_SW :[西南方] STR_ORDER_RV_DIR_NW :[西北方] -STR_ORDER_CONDITIONAL_CARGO_ACCEPTANCE :跳至 {COMMA} [ 当 下一站 {STRING} {STRING} -STR_ORDER_CONDITIONAL_CARGO_WAITING_DISPLAY :跳至 {COMMA} [ 当 下一站 {STRING} {STRING} +STR_ORDER_CONDITIONAL_PERCENT_DISPLAY :跳转至调度计划 {COMMA} {COMMA} 次数百分比 +STR_ORDER_CONDITIONAL_CARGO_ACCEPTANCE :跳至 {COMMA} [ 当 {STRING} {STRING} {STRING} +STR_ORDER_CONDITIONAL_CARGO_WAITING_DISPLAY :跳至 {COMMA} [ 当 {STRING} {STRING} {STRING} STR_ORDER_CONDITIONAL_SLOT :跳至 {COMMA} [ 当 {TRSLOT} {STRING} STR_ORDER_CONDITIONAL_INVALID_SLOT :跳至 {COMMA} [ 当 {PUSH_COLOUR}{RED}{STRING} {POP_COLOUR}{STRING} STR_ORDER_CONDITIONAL_IN_SLOT :跳至 {COMMA} [ 当 {STRING} 条目:{TRSLOT} STR_ORDER_CONDITIONAL_IN_INVALID_SLOT :跳至 {COMMA} [ 当 {STRING} {PUSH_COLOUR}{RED}{STRING} {POP_COLOUR} STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE_DISPLAY :跳至 {COMMA} [ 当 Load percentage of {STRING} {STRING} {COMMA} -STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_DISPLAY :跳至 {COMMA} [ 当 {STRING} 在下一站 {STRING} {CARGO_SHORT} -STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_VIA_DISPLAY :跳至 {COMMA} [ 当 {STRING} 在下一站 经由 {STATION} {STRING} {CARGO_SHORT} STR_ORDER_CONDITIONAL_COUNTER :跳至 {COMMA} [ 当 值:{TRCOUNTER} {STRING} {COMMA} STR_ORDER_CONDITIONAL_INVALID_COUNTER :跳至 {COMMA} [ 当 值:{PUSH_COLOUR}{RED}{STRING}{POP_COLOUR} {STRING} {COMMA} STR_ORDER_CONDITIONAL_TIME_HHMM :跳至 {COMMA} [ 当 {STRING} {STRING} {TIME_HHMM} diff --git a/src/order_base.h b/src/order_base.h index ad8e9102cf..07fb4961c1 100644 --- a/src/order_base.h +++ b/src/order_base.h @@ -71,6 +71,13 @@ void ClearOrderDestinationRefcountMap(); * OCV_DISPATCH_SLOT: Bits 0-15: Dispatch schedule ID * OCV_PERCENT: Bits 0-7: Jump counter */ +/* + * xdata2 users: + * OCV_CARGO_WAITING: Bits 0-15: Station ID to test + 1 + * OCV_CARGO_ACCEPTANCE: Bits 0-15: Station ID to test + 1 + * OCV_FREE_PLATFORMS: Bits 0-15: Station ID to test + 1 + * OCV_CARGO_WAITING_AMOUNT: Bits 0-15: Station ID to test + 1 + */ struct OrderExtraInfo { uint8 cargo_type_flags[NUM_CARGO] = {}; ///< Load/unload types for each cargo type. diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 311b77b7c5..55c001e676 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -1859,7 +1859,7 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 break; case OT_CONDITIONAL: - if (mof != MOF_COND_VARIABLE && mof != MOF_COND_COMPARATOR && mof != MOF_COND_VALUE && mof != MOF_COND_VALUE_2 && mof != MOF_COND_VALUE_3 && mof != MOF_COND_DESTINATION) return CMD_ERROR; + if (mof != MOF_COND_VARIABLE && mof != MOF_COND_COMPARATOR && mof != MOF_COND_VALUE && mof != MOF_COND_VALUE_2 && mof != MOF_COND_VALUE_3 && mof != MOF_COND_DESTINATION && mof != MOF_COND_STATION_ID) return CMD_ERROR; break; case OT_RELEASE_SLOT: @@ -2040,6 +2040,7 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 switch (order->GetConditionVariable()) { case OCV_CARGO_WAITING_AMOUNT: if (!(data == NEW_STATION || Station::GetIfValid(data) != nullptr)) return CMD_ERROR; + if (GB(order->GetXData2(), 0, 16) - 1 == data) return CMD_ERROR; break; default: @@ -2047,6 +2048,14 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 } break; + case MOF_COND_STATION_ID: + if (ConditionVariableHasStationID(order->GetConditionVariable())) { + if (Station::GetIfValid(data) == nullptr) return CMD_ERROR; + } else { + return CMD_ERROR; + } + break; + case MOF_COND_DESTINATION: if (data >= v->GetNumOrders() || data == sel_ord) return CMD_ERROR; break; @@ -2314,6 +2323,14 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 SB(order->GetXDataRef(), 16, 16, data + 2); break; + case MOF_COND_STATION_ID: + SB(order->GetXData2Ref(), 0, 16, data + 1); + if (order->GetConditionVariable() == OCV_CARGO_WAITING_AMOUNT && data == GB(order->GetXData(), 16, 16) - 2) { + /* Clear via if station is set to the same ID */ + SB(order->GetXDataRef(), 16, 16, 0); + } + break; + case MOF_COND_DESTINATION: order->SetConditionSkipToOrder(data); break; @@ -2878,6 +2895,9 @@ void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination, bool if (type == OT_GOTO_STATION && o->GetConditionVariable() == OCV_CARGO_WAITING_AMOUNT) { if (GB(order->GetXData(), 16, 16) - 2 == destination) SB(order->GetXDataRef(), 16, 16, INVALID_STATION + 2); } + if (type == OT_GOTO_STATION && ConditionVariableHasStationID(o->GetConditionVariable())) { + if (GB(order->GetXData2(), 0, 16) - 1 == destination) SB(order->GetXData2Ref(), 0, 16, INVALID_STATION + 1); + } return false; } if (ot == OT_GOTO_DEPOT && (o->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0) return false; @@ -3057,22 +3077,6 @@ bool EvaluateDispatchSlotConditionalOrder(const Order *order, const Vehicle *v, return OrderConditionCompare(order->GetConditionComparator(), value, 0); } -/** Gets the next 'real' station in the order list - * @param v the vehicle in question - * @param order the current (conditional) order - * @return the StationID of the next valid station in the order list, or INVALID_STATION if there is none. - */ -static StationID GetNextRealStation(const Vehicle *v, const Order *order) -{ - const uint max = std::min(64, v->GetNumOrders()); - for (uint i = 0; i < max; i++) { - if (order->IsType(OT_GOTO_STATION) && Station::IsValidID(order->GetDestination())) return order->GetDestination(); - - order = (order->next != nullptr) ? order->next : v->GetFirstOrder(); - } - return INVALID_STATION; -} - static std::vector _pco_deferred_slot_acquires; static std::vector _pco_deferred_slot_releases; static btree::btree_map _pco_deferred_counter_values; @@ -3104,12 +3108,12 @@ VehicleOrderID ProcessConditionalOrder(const Order *order, const Vehicle *v, Pro case OCV_REQUIRES_SERVICE: skip_order = OrderConditionCompare(occ, v->NeedsServicing(), value); break; case OCV_UNCONDITIONALLY: skip_order = true; break; case OCV_CARGO_WAITING: { - StationID next_station = GetNextRealStation(v, order); + StationID next_station = GB(order->GetXData2(), 0, 16) - 1; if (Station::IsValidID(next_station)) skip_order = OrderConditionCompare(occ, (Station::Get(next_station)->goods[value].CargoAvailableCount() > 0), value); break; } case OCV_CARGO_WAITING_AMOUNT: { - StationID next_station = GetNextRealStation(v, order); + StationID next_station = GB(order->GetXData2(), 0, 16) - 1; if (Station::IsValidID(next_station)) { if (GB(order->GetXData(), 16, 16) == 0) { skip_order = OrderConditionCompare(occ, Station::Get(next_station)->goods[value].CargoAvailableCount(), GB(order->GetXData(), 0, 16)); @@ -3120,7 +3124,7 @@ VehicleOrderID ProcessConditionalOrder(const Order *order, const Vehicle *v, Pro break; } case OCV_CARGO_ACCEPTANCE: { - StationID next_station = GetNextRealStation(v, order); + StationID next_station = GB(order->GetXData2(), 0, 16) - 1; if (Station::IsValidID(next_station)) skip_order = OrderConditionCompare(occ, HasBit(Station::Get(next_station)->goods[value].status, GoodsEntry::GES_ACCEPTANCE), value); break; } @@ -3177,7 +3181,7 @@ VehicleOrderID ProcessConditionalOrder(const Order *order, const Vehicle *v, Pro break; } case OCV_FREE_PLATFORMS: { - StationID next_station = GetNextRealStation(v, order); + StationID next_station = GB(order->GetXData2(), 0, 16) - 1; if (Station::IsValidID(next_station)) skip_order = OrderConditionCompare(occ, GetFreeStationPlatforms(next_station), value); break; } @@ -3673,7 +3677,7 @@ CommandCost CmdMassChangeOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, u int index = 0; bool changed = false; - for(Order *order : v->Orders()) { + for (Order *order : v->Orders()) { if (order->GetDestination() == from_dest && order->IsType(order_type) && !(order_type == OT_GOTO_DEPOT && order->GetDepotActionType() & ODATFB_NEAREST_DEPOT)) { Order new_order; diff --git a/src/order_cmd.h b/src/order_cmd.h index 7ab889f2f2..fbeb897aa1 100644 --- a/src/order_cmd.h +++ b/src/order_cmd.h @@ -35,7 +35,7 @@ inline void UnregisterOrderDestination(const Order *order, VehicleType type, Own template void RemoveVehicleOrdersIf(Vehicle * const v, F order_predicate) { /* Clear the order from the order-list */ int id = -1; - for(Order *order = v->GetFirstOrder(); order != nullptr; order = order->next) { + for (Order *order = v->GetFirstOrder(); order != nullptr; order = order->next) { id++; restart: diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 28d2790c7f..22d0b79389 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -989,18 +989,29 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int } case OT_CONDITIONAL: { + auto set_station_id = [&order](uint index, StringParameters &sp = _global_string_params) { + const Station *st = Station::GetIfValid(GB(order->GetXData2(), 0, 16) - 1); + if (st == nullptr) { + sp.SetParam(index, STR_ORDER_CONDITIONAL_UNDEFINED_STATION); + } else { + sp.SetParam(index, STR_JUST_STATION); + sp.SetParam(index + 1, st->index); + } + }; + SetDParam(1, order->GetConditionSkipToOrder() + 1); - const OrderConditionVariable ocv = order->GetConditionVariable( ); + const OrderConditionVariable ocv = order->GetConditionVariable(); /* handle some non-ordinary cases seperately */ if (ocv == OCV_UNCONDITIONALLY) { SetDParam(0, STR_ORDER_CONDITIONAL_UNCONDITIONAL); } else if (ocv == OCV_PERCENT) { - SetDParam(0, STR_CONDITIONAL_PERCENT); + SetDParam(0, STR_ORDER_CONDITIONAL_PERCENT_DISPLAY); SetDParam(2, order->GetConditionValue()); } else if (ocv == OCV_FREE_PLATFORMS) { - SetDParam(0, STR_CONDITIONAL_FREE_PLATFORMS ); - SetDParam(2, STR_ORDER_CONDITIONAL_COMPARATOR_HAS + order->GetConditionComparator()); - SetDParam(3, order->GetConditionValue()); + SetDParam(0, STR_ORDER_CONDITIONAL_FREE_PLATFORMS_DISPLAY); + set_station_id(2); + SetDParam(4, STR_ORDER_CONDITIONAL_COMPARATOR_HAS + order->GetConditionComparator()); + SetDParam(5, order->GetConditionValue()); } else if (ocv == OCV_SLOT_OCCUPANCY) { if (TraceRestrictSlot::IsValidID(order->GetXData())) { SetDParam(0, STR_ORDER_CONDITIONAL_SLOT); @@ -1046,20 +1057,36 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int SetDParam(3, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + order->GetConditionComparator()); SetDParam(4, order->GetXData()); } else if (ocv == OCV_CARGO_WAITING_AMOUNT) { + char buf[512] = ""; + int64 args_array[10] = {}; + StringParameters tmp_params(args_array); + StringID substr; + + tmp_params.SetParam(0, order->GetConditionSkipToOrder() + 1); + tmp_params.SetParam(1, CargoSpec::Get(order->GetConditionValue())->name); + set_station_id(2, tmp_params); + if (GB(order->GetXData(), 16, 16) == 0) { - SetDParam(0, STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_DISPLAY); - SetDParam(2, CargoSpec::Get(order->GetConditionValue())->name); - SetDParam(3, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + order->GetConditionComparator()); - SetDParam(4, order->GetConditionValue()); - SetDParam(5, GB(order->GetXData(), 0, 16)); + substr = STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_DISPLAY; + tmp_params.SetParam(4, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + order->GetConditionComparator()); + tmp_params.SetParam(5, order->GetConditionValue()); + tmp_params.SetParam(6, GB(order->GetXData(), 0, 16)); } else { - SetDParam(0, STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_VIA_DISPLAY); - SetDParam(2, CargoSpec::Get(order->GetConditionValue())->name); - SetDParam(3, GB(order->GetXData(), 16, 16) - 2); - SetDParam(4, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + order->GetConditionComparator()); - SetDParam(5, order->GetConditionValue()); - SetDParam(6, GB(order->GetXData(), 0, 16)); + substr = STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_VIA_DISPLAY; + const Station *via_st = Station::GetIfValid(GB(order->GetXData(), 16, 16) - 2); + if (via_st == nullptr) { + tmp_params.SetParam(4, STR_ORDER_CONDITIONAL_UNDEFINED_STATION); + } else { + tmp_params.SetParam(4, STR_JUST_STATION); + tmp_params.SetParam(5, via_st->index); + } + tmp_params.SetParam(6, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + order->GetConditionComparator()); + tmp_params.SetParam(7, order->GetConditionValue()); + tmp_params.SetParam(8, GB(order->GetXData(), 0, 16)); } + char *end = GetStringWithArgs(buf, substr, &tmp_params, lastof(buf)); + _temp_special_strings[0].assign(buf, end); + SetDParam(0, SPECSTR_TEMP_START); } else if (ocv == OCV_COUNTER_VALUE) { if (TraceRestrictCounter::IsValidID(GB(order->GetXData(), 16, 16))) { SetDParam(0, STR_ORDER_CONDITIONAL_COUNTER); @@ -1110,13 +1137,15 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int switch (ocv) { case OCV_CARGO_ACCEPTANCE: SetDParam(0, STR_ORDER_CONDITIONAL_CARGO_ACCEPTANCE); - SetDParam(2, STR_ORDER_CONDITIONAL_COMPARATOR_ACCEPTS + occ - OCC_IS_TRUE); - SetDParam(3, CargoSpec::Get(value)->name); + set_station_id(2); + SetDParam(4, STR_ORDER_CONDITIONAL_COMPARATOR_ACCEPTS + occ - OCC_IS_TRUE); + SetDParam(5, CargoSpec::Get(value)->name); break; case OCV_CARGO_WAITING: SetDParam(0, STR_ORDER_CONDITIONAL_CARGO_WAITING_DISPLAY); - SetDParam(2, STR_ORDER_CONDITIONAL_COMPARATOR_HAS + occ - OCC_IS_TRUE); - SetDParam(3, CargoSpec::Get(value)->name); + set_station_id(2); + SetDParam(4, STR_ORDER_CONDITIONAL_COMPARATOR_HAS + occ - OCC_IS_TRUE); + SetDParam(5, CargoSpec::Get(value)->name); break; case OCV_REQUIRES_SERVICE: SetDParam(3, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + occ); @@ -1397,6 +1426,7 @@ private: OPOS_CONDITIONAL, OPOS_SHARE, OPOS_COND_VIA, + OPOS_COND_STATION, OPOS_CONDITIONAL_RETARGET, OPOS_DEPARTURE_VIA, OPOS_END, @@ -1452,6 +1482,9 @@ private: DP_COND_AUX2_VIA = 0, ///< Display via button DP_COND_AUX2_SCHED_TEST = 1, ///< Display dropdown for scheduled dispatch test selection + /* WID_O_SEL_COND_AUX3 */ + DP_COND_AUX3_STATION = 0, ///< Display station button + /* WID_O_SEL_BOTTOM_LEFT */ DP_BOTTOM_LEFT_SKIP = 0, ///< Display 'skip' in the left button of the bottom row of the vehicle order window. DP_BOTTOM_LEFT_MANAGE_LIST = 1, ///< Display 'manage list' in the left button of the bottom row of the vehicle order window. @@ -1478,6 +1511,7 @@ private: int query_text_widget; ///< widget which most recently called ShowQueryString int current_aux_plane; int current_aux2_plane; + int current_aux3_plane; int current_mgmt_plane; /** @@ -1561,6 +1595,7 @@ private: HT_NONE, // OPOS_CONDITIONAL HT_VEHICLE, // OPOS_SHARE HT_RECT, // OPOS_COND_VIA + HT_RECT, // OPOS_COND_STATION HT_NONE, // OPOS_CONDITIONAL_RETARGET HT_RECT, // OPOS_DEPARTURE_VIA }; @@ -1568,6 +1603,7 @@ private: this->goto_type = type; this->SetWidgetDirty(WID_O_GOTO); this->SetWidgetDirty(WID_O_COND_AUX_VIA); + this->SetWidgetDirty(WID_O_COND_AUX_STATION); this->SetWidgetDirty(WID_O_MGMT_BTN); } @@ -1826,10 +1862,18 @@ public: this->SetWidgetLoweredState(WID_O_OCCUPANCY_TOGGLE, _settings_client.gui.show_order_occupancy_by_default); this->current_aux_plane = SZSP_NONE; this->current_aux2_plane = SZSP_NONE; + this->current_aux3_plane = SZSP_NONE; this->current_mgmt_plane = this->GetOrderManagementPlane(); if (v->owner == _local_company) { - this->GetWidget(WID_O_SEL_COND_AUX)->SetDisplayedPlane(this->current_aux_plane); - this->GetWidget(WID_O_SEL_COND_AUX2)->SetDisplayedPlane(this->current_aux2_plane); + NWidgetStacked *aux_sel = this->GetWidget(WID_O_SEL_COND_AUX); + NWidgetStacked *aux2_sel = this->GetWidget(WID_O_SEL_COND_AUX2); + NWidgetStacked *aux3_sel = this->GetWidget(WID_O_SEL_COND_AUX3); + aux_sel->independent_planes = true; + aux2_sel->independent_planes = true; + aux3_sel->independent_planes = true; + aux_sel->SetDisplayedPlane(this->current_aux_plane); + aux2_sel->SetDisplayedPlane(this->current_aux2_plane); + aux3_sel->SetDisplayedPlane(this->current_aux3_plane); this->GetWidget(WID_O_SEL_MGMT)->SetDisplayedPlane(this->current_mgmt_plane); } this->FinishInitNested(v->index); @@ -2072,26 +2116,37 @@ public: NWidgetStacked *aux_sel = this->GetWidget(WID_O_SEL_COND_AUX); NWidgetStacked *aux2_sel = this->GetWidget(WID_O_SEL_COND_AUX2); + NWidgetStacked *aux3_sel = this->GetWidget(WID_O_SEL_COND_AUX3); NWidgetStacked *mgmt_sel = this->GetWidget(WID_O_SEL_MGMT); mgmt_sel->SetDisplayedPlane(this->GetOrderManagementPlane()); auto aux_plane_guard = scope_guard([&]() { + bool reinit = false; if (this->current_aux_plane != aux_sel->shown_plane) { this->current_aux_plane = aux_sel->shown_plane; - this->ReInit(); + reinit = true; } if (this->current_aux2_plane != aux2_sel->shown_plane) { this->current_aux2_plane = aux2_sel->shown_plane; - this->ReInit(); + reinit = true; + } + if (this->current_aux3_plane != aux3_sel->shown_plane) { + this->current_aux3_plane = aux3_sel->shown_plane; + reinit = true; } if ((this->current_mgmt_plane == SZSP_NONE) != (mgmt_sel->shown_plane == SZSP_NONE)) { this->current_mgmt_plane = mgmt_sel->shown_plane; - this->ReInit(); + reinit = true; } else if (this->current_mgmt_plane != mgmt_sel->shown_plane) { this->current_mgmt_plane = mgmt_sel->shown_plane; } + if (reinit) this->ReInit(); }); + aux_sel->SetDisplayedPlane(SZSP_NONE); + aux2_sel->SetDisplayedPlane(SZSP_NONE); + aux3_sel->SetDisplayedPlane(SZSP_NONE); + if (order == nullptr) { if (row_sel != nullptr) { row_sel->SetDisplayedPlane(DP_ROW_LOAD); @@ -2239,6 +2294,12 @@ public: aux2_sel->SetDisplayedPlane(SZSP_NONE); } + if (ConditionVariableHasStationID(ocv)) { + aux3_sel->SetDisplayedPlane(DP_COND_AUX3_STATION); + } else { + aux3_sel->SetDisplayedPlane(SZSP_NONE); + } + /* Set the strings for the dropdown boxes. */ this->GetWidget(WID_O_COND_VARIABLE)->widget_data = OrderStringForVariable(this->vehicle, ocv); this->GetWidget(WID_O_COND_COMPARATOR)->widget_data = GetComparatorStrings(this->vehicle, order)[order->GetConditionComparator()]; @@ -2321,8 +2382,10 @@ public: if (this->vehicle->owner != _local_company) { this->selected_order = -1; // Disable selection any selected row at a competitor order window. } else { - this->SetWidgetLoweredState(WID_O_GOTO, this->goto_type != OPOS_NONE && this->goto_type != OPOS_COND_VIA && this->goto_type != OPOS_CONDITIONAL_RETARGET); + this->SetWidgetLoweredState(WID_O_GOTO, this->goto_type != OPOS_NONE && this->goto_type != OPOS_COND_VIA + && this->goto_type != OPOS_COND_STATION && this->goto_type != OPOS_CONDITIONAL_RETARGET); this->SetWidgetLoweredState(WID_O_COND_AUX_VIA, this->goto_type == OPOS_COND_VIA); + this->SetWidgetLoweredState(WID_O_COND_AUX_STATION, this->goto_type == OPOS_COND_STATION); this->SetWidgetLoweredState(WID_O_MGMT_BTN, this->goto_type == OPOS_CONDITIONAL_RETARGET); } this->DrawWidgets(); @@ -2776,7 +2839,7 @@ public: this->OrderClick_Goto(OPOS_GOTO); } } else { - if (this->goto_type == OPOS_COND_VIA) ResetObjectToPlace(); + if (this->goto_type == OPOS_COND_VIA || this->goto_type == OPOS_COND_STATION) ResetObjectToPlace(); int sel; switch (this->goto_type) { case OPOS_NONE: sel = -1; break; @@ -2934,6 +2997,15 @@ public: break; } + case WID_O_COND_AUX_STATION: { + if (this->goto_type != OPOS_NONE) { + ResetObjectToPlace(); + } else { + this->OrderClick_Goto(OPOS_COND_STATION); + } + break; + } + case WID_O_TIMETABLE_VIEW: ShowTimetableWindow(this->vehicle); break; @@ -3364,7 +3436,7 @@ public: /* With quick goto the Go To button stays active */ if (!_settings_client.gui.quick_goto) ResetObjectToPlace(); } - } else if (this->goto_type == OPOS_COND_VIA) { + } else if (this->goto_type == OPOS_COND_VIA || this->goto_type == OPOS_COND_STATION) { if (IsTileType(tile, MP_STATION) || IsTileType(tile, MP_INDUSTRY)) { const Station *st = nullptr; @@ -3375,7 +3447,7 @@ public: st = in->neutral_station; } if (st != nullptr && IsInfraUsageAllowed(this->vehicle->type, this->vehicle->owner, st->owner)) { - if (this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE_3 | st->index << 8)) { + if (this->ModifyOrder(this->OrderGetSel(), (this->goto_type == OPOS_COND_VIA ? MOF_COND_VALUE_3 : MOF_COND_STATION_ID) | st->index << 8)) { ResetObjectToPlace(); } } @@ -3462,6 +3534,7 @@ public: this->goto_type = OPOS_NONE; this->SetWidgetDirty(WID_O_GOTO); this->SetWidgetDirty(WID_O_COND_AUX_VIA); + this->SetWidgetDirty(WID_O_COND_AUX_STATION); this->SetWidgetDirty(WID_O_MGMT_BTN); /* Remove drag highlighting if it exists. */ @@ -3622,6 +3695,10 @@ static const NWidgetPart _nested_orders_train_widgets[] = { NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_COND_SCHED_SELECT), SetMinimalSize(124, 12), SetFill(1, 0), SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_SCHED_SELECT_TOOLTIP), SetResize(1, 0), EndContainer(), + NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_COND_AUX3), + NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_O_COND_AUX_STATION), SetMinimalSize(72, 12), + SetDataTip(STR_ORDER_CONDITIONAL_STATION, STR_ORDER_CONDITIONAL_STATION_TOOLTIP), + EndContainer(), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_COND_AUX2), NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_O_COND_AUX_VIA), SetMinimalSize(36, 12), SetDataTip(STR_ORDER_CONDITIONAL_VIA, STR_ORDER_CONDITIONAL_VIA_TOOLTIP), @@ -3766,6 +3843,10 @@ static const NWidgetPart _nested_orders_widgets[] = { NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_COND_SCHED_SELECT), SetMinimalSize(124, 12), SetFill(1, 0), SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_SCHED_SELECT_TOOLTIP), SetResize(1, 0), EndContainer(), + NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_COND_AUX3), + NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_O_COND_AUX_STATION), SetMinimalSize(72, 12), + SetDataTip(STR_ORDER_CONDITIONAL_STATION, STR_ORDER_CONDITIONAL_STATION_TOOLTIP), + EndContainer(), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_COND_AUX2), NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_O_COND_AUX_VIA), SetMinimalSize(36, 12), SetDataTip(STR_ORDER_CONDITIONAL_VIA, STR_ORDER_CONDITIONAL_VIA_TOOLTIP), diff --git a/src/order_type.h b/src/order_type.h index 724daa4391..2e19ce1a9d 100644 --- a/src/order_type.h +++ b/src/order_type.h @@ -165,14 +165,14 @@ enum OrderConditionVariable { OCV_UNCONDITIONALLY, ///< Always skip OCV_REMAINING_LIFETIME, ///< Skip based on the remaining lifetime OCV_MAX_RELIABILITY, ///< Skip based on the maximum reliability - OCV_CARGO_WAITING, ///< Skip if specified cargo is waiting at next station - OCV_CARGO_ACCEPTANCE, ///< Skip if specified cargo is accepted at next station - OCV_FREE_PLATFORMS, ///< Skip based on free platforms at next station + OCV_CARGO_WAITING, ///< Skip if specified cargo is waiting at station + OCV_CARGO_ACCEPTANCE, ///< Skip if specified cargo is accepted at station + OCV_FREE_PLATFORMS, ///< Skip based on free platforms at station OCV_PERCENT, ///< Skip xx percent of times OCV_SLOT_OCCUPANCY, ///< Test if vehicle slot is fully occupied, or empty OCV_VEH_IN_SLOT, ///< Test if vehicle is in slot OCV_CARGO_LOAD_PERCENTAGE, ///< Skip based on the amount of load of a specific cargo - OCV_CARGO_WAITING_AMOUNT, ///< Skip based on the amount of a specific cargo waiting at next station + OCV_CARGO_WAITING_AMOUNT, ///< Skip based on the amount of a specific cargo waiting at station OCV_COUNTER_VALUE, ///< Skip based on counter value OCV_TIME_DATE, ///< Skip based on current time/date OCV_TIMETABLE, ///< Skip based on timetable state @@ -180,6 +180,11 @@ enum OrderConditionVariable { OCV_END }; +inline bool ConditionVariableHasStationID(OrderConditionVariable ocv) +{ + return ocv == OCV_CARGO_WAITING || ocv == OCV_CARGO_ACCEPTANCE || ocv == OCV_FREE_PLATFORMS || ocv == OCV_CARGO_WAITING_AMOUNT; +} + /** * Comparator for the skip reasoning. */ @@ -210,6 +215,7 @@ enum ModifyOrderFlags { MOF_COND_VALUE, ///< The value to set the condition to. MOF_COND_VALUE_2, ///< The secondary value to set the condition to. MOF_COND_VALUE_3, ///< The tertiary value to set the condition to. + MOF_COND_STATION_ID, ///< The station ID to set the condition to. MOF_COND_DESTINATION,///< Change the destination of a conditional order. MOF_WAYPOINT_FLAGS, ///< Change the waypoint flags MOF_CARGO_TYPE_UNLOAD, ///< Passes an OrderUnloadType and a CargoID. diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 4ba66a6f42..990ec5822d 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -3982,12 +3982,41 @@ bool AfterLoadGame() if (SlXvIsFeaturePresent(XSLFI_MORE_COND_ORDERS, 1, 1)) { for (Order *order : Order::Iterate()) { - // Insertion of OCV_MAX_RELIABILITY between OCV_REMAINING_LIFETIME and OCV_CARGO_WAITING + /* Insertion of OCV_MAX_RELIABILITY between OCV_REMAINING_LIFETIME and OCV_CARGO_WAITING */ if (order->IsType(OT_CONDITIONAL) && order->GetConditionVariable() > OCV_REMAINING_LIFETIME) { order->SetConditionVariable(static_cast((uint)order->GetConditionVariable() + 1)); } } } + if (SlXvIsFeaturePresent(XSLFI_MORE_COND_ORDERS, 1, 14)) { + for (OrderList *order_list : OrderList::Iterate()) { + auto get_real_station = [&order_list](const Order *order) -> StationID { + const uint max = std::min(64, order_list->GetNumOrders()); + for (uint i = 0; i < max; i++) { + if (order->IsType(OT_GOTO_STATION) && Station::IsValidID(order->GetDestination())) return order->GetDestination(); + + order = (order->next != nullptr) ? order->next : order_list->GetFirstOrder(); + } + return INVALID_STATION; + }; + + for (Order *order = order_list->GetFirstOrder(); order != nullptr; order = order->next) { + /* Fixup station ID for OCV_CARGO_WAITING, OCV_CARGO_ACCEPTANCE, OCV_FREE_PLATFORMS, OCV_CARGO_WAITING_AMOUNT */ + if (order->IsType(OT_CONDITIONAL) && ConditionVariableHasStationID(order->GetConditionVariable())) { + StationID next_id = get_real_station(order); + SB(order->GetXData2Ref(), 0, 16, next_id + 1); + if (next_id != INVALID_STATION && GB(order->GetXData(), 16, 16) - 2 == next_id) { + /* Duplicate next and via, remove via */ + SB(order->GetXDataRef(), 16, 16, 0); + } + if (GB(order->GetXData(), 16, 16) != 0 && !Station::IsValidID(GB(order->GetXData(), 16, 16) - 2)) { + /* Via station is invalid */ + SB(order->GetXDataRef(), 16, 16, INVALID_STATION + 2); + } + } + } + } + } if (SlXvIsFeatureMissing(XSLFI_CONSIST_SPEED_RD_FLAG)) { for (Train *t : Train::Iterate()) { diff --git a/src/sl/extended_ver_sl.cpp b/src/sl/extended_ver_sl.cpp index b90375d297..c92ac0724e 100644 --- a/src/sl/extended_ver_sl.cpp +++ b/src/sl/extended_ver_sl.cpp @@ -103,7 +103,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = { { XSLFI_INFRA_SHARING, XSCF_NULL, 2, 2, "infra_sharing", nullptr, nullptr, "CPDP" }, { XSLFI_VARIABLE_DAY_LENGTH, XSCF_NULL, 3, 3, "variable_day_length", nullptr, nullptr, nullptr }, { XSLFI_ORDER_OCCUPANCY, XSCF_NULL, 2, 2, "order_occupancy", nullptr, nullptr, nullptr }, - { XSLFI_MORE_COND_ORDERS, XSCF_NULL, 14, 14, "more_cond_orders", nullptr, nullptr, nullptr }, + { XSLFI_MORE_COND_ORDERS, XSCF_NULL, 15, 15, "more_cond_orders", nullptr, nullptr, nullptr }, { XSLFI_EXTRA_LARGE_MAP, XSCF_NULL, 0, 1, "extra_large_map", nullptr, nullptr, nullptr }, { XSLFI_REVERSE_AT_WAYPOINT, XSCF_NULL, 1, 1, "reverse_at_waypoint", nullptr, nullptr, nullptr }, { XSLFI_VEH_LIFETIME_PROFIT, XSCF_NULL, 1, 1, "veh_lifetime_profit", nullptr, nullptr, nullptr }, diff --git a/src/widgets/order_widget.h b/src/widgets/order_widget.h index 98f6e2397d..03886e440c 100644 --- a/src/widgets/order_widget.h +++ b/src/widgets/order_widget.h @@ -45,6 +45,7 @@ enum OrderWidgets { WID_O_COND_SCHED_SELECT, ///< Choose scheduled dispatch schedule. WID_O_COND_AUX_VIA, ///< Condition via button. WID_O_COND_SCHED_TEST, ///< Choose scheduled dispatch test. + WID_O_COND_AUX_STATION, ///< Condition station button. WID_O_RELEASE_SLOT, ///< Choose slot to release. WID_O_COUNTER_OP, ///< Choose counter operation. WID_O_CHANGE_COUNTER, ///< Choose counter to change. @@ -54,6 +55,7 @@ enum OrderWidgets { WID_O_SEL_COND_VALUE, ///< Widget for conditional value or conditional cargo type. WID_O_SEL_COND_AUX, ///< Widget for auxiliary conditional cargo type. WID_O_SEL_COND_AUX2, ///< Widget for auxiliary conditional via button. + WID_O_SEL_COND_AUX3, ///< Widget for auxiliary conditional station button. WID_O_SEL_MGMT, ///< Widget for management buttons. WID_O_SEL_TOP_LEFT, ///< #NWID_SELECTION widget for left part of the top row of the 'your train' order window. WID_O_SEL_TOP_MIDDLE, ///< #NWID_SELECTION widget for middle part of the top row of the 'your train' order window.