summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-04-12 13:07:25 +0000
committerrubidium <rubidium@openttd.org>2008-04-12 13:07:25 +0000
commited250cc7b581595ed57a518ce6dfd4b00551a022 (patch)
treecb10294f4483a7fa3996d88041453988e023385f
parent8c89250f58116309341c04ff4fc5d31887e8b180 (diff)
downloadopenttd-ed250cc7b581595ed57a518ce6dfd4b00551a022.tar.xz
(svn r12670) -Add: unconditional/always order 'jump/skip' variable.
-rw-r--r--src/lang/english.txt2
-rw-r--r--src/order_cmd.cpp10
-rw-r--r--src/order_gui.cpp28
-rw-r--r--src/order_type.h1
-rw-r--r--src/timetable_gui.cpp26
5 files changed, 45 insertions, 22 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index c51b686f6..e29c1ec8c 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -2709,6 +2709,7 @@ STR_ORDER_CONDITIONAL_RELIABILITY :Reliability
STR_ORDER_CONDITIONAL_MAX_SPEED :Maximum speed
STR_ORDER_CONDITIONAL_AGE :Vehicle age (years)
STR_ORDER_CONDITIONAL_REQUIRES_SERVICE :Requires service
+STR_ORDER_CONDITIONAL_UNCONDITIONALLY :Always
STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS :is equal to
STR_ORDER_CONDITIONAL_COMPARATOR_NOT_EQUALS :is not equal to
STR_ORDER_CONDITIONAL_COMPARATOR_LESS_THAN :is less than
@@ -2718,6 +2719,7 @@ STR_ORDER_CONDITIONAL_COMPARATOR_MORE_EQUALS :is more or equa
STR_ORDER_CONDITIONAL_COMPARATOR_IS_TRUE :is true
STR_ORDER_CONDITIONAL_COMPARATOR_IS_FALSE :is false
STR_CONDITIONAL_VALUE :{SKIP}{BLACK}{COMMA}
+STR_CONDITIONAL_UNCONDITIONAL :Jump to order {COMMA}
STR_CONDITIONAL_NUM :Jump to order {COMMA} when {STRING} {STRING} {COMMA}
STR_CONDITIONAL_TRUE_FALSE :Jump to order {COMMA} when {STRING} {STRING}
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index 70ad28861..bae55b75c 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -896,6 +896,8 @@ CommandCost CmdModifyOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
case MOF_COND_COMPARATOR:
if (data >= OCC_END) return CMD_ERROR;
switch (order->GetConditionVariable()) {
+ case OCV_UNCONDITIONALLY: return CMD_ERROR;
+
case OCV_REQUIRES_SERVICE:
if (data != OCC_IS_TRUE && data != OCC_IS_FALSE) return CMD_ERROR;
break;
@@ -908,6 +910,8 @@ CommandCost CmdModifyOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
case MOF_COND_VALUE:
switch (order->GetConditionVariable()) {
+ case OCV_UNCONDITIONALLY: return CMD_ERROR;
+
case OCV_LOAD_PERCENTAGE:
case OCV_RELIABILITY:
if (data > 100) return CMD_ERROR;
@@ -950,6 +954,11 @@ CommandCost CmdModifyOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
OrderConditionComparator occ = order->GetConditionComparator();
switch (order->GetConditionVariable()) {
+ case OCV_UNCONDITIONALLY:
+ order->SetConditionComparator(OCC_EQUALS);
+ order->SetConditionValue(0);
+ break;
+
case OCV_REQUIRES_SERVICE:
if (occ != OCC_IS_TRUE && occ != OCC_IS_FALSE) order->SetConditionComparator(OCC_IS_TRUE);
break;
@@ -1706,6 +1715,7 @@ bool ProcessOrders(Vehicle *v)
case OCV_MAX_SPEED: skip_order = OrderConditionCompare(occ, v->GetDisplayMaxSpeed(), value); break;
case OCV_AGE: skip_order = OrderConditionCompare(occ, v->age / 366, value); break;
case OCV_REQUIRES_SERVICE: skip_order = OrderConditionCompare(occ, v->NeedsServicing(), value); break;
+ case OCV_UNCONDITIONALLY: skip_order = true; break;
default: NOT_REACHED();
}
UpdateVehicleTimetable(v, true);
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index 4fc7a6b47..77b593907 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -191,6 +191,7 @@ static const StringID _order_conditional_variable[] = {
STR_ORDER_CONDITIONAL_MAX_SPEED,
STR_ORDER_CONDITIONAL_AGE,
STR_ORDER_CONDITIONAL_REQUIRES_SERVICE,
+ STR_ORDER_CONDITIONAL_UNCONDITIONALLY,
INVALID_STRING_ID,
};
@@ -285,7 +286,8 @@ static void DrawOrdersWindow(Window *w)
w->ShowWidget(ORDER_WIDGET_COND_VALUE);
OrderConditionVariable ocv = order->GetConditionVariable();
- w->SetWidgetDisabledState(ORDER_WIDGET_COND_VALUE, ocv == OCV_REQUIRES_SERVICE);
+ w->SetWidgetDisabledState(ORDER_WIDGET_COND_COMPARATOR, ocv == OCV_UNCONDITIONALLY);
+ w->SetWidgetDisabledState(ORDER_WIDGET_COND_VALUE, ocv == OCV_REQUIRES_SERVICE || ocv == OCV_UNCONDITIONALLY);
uint value = order->GetConditionValue();
if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
@@ -372,17 +374,21 @@ static void DrawOrdersWindow(Window *w)
SetDParam(2, order->GetDestination());
break;
- case OT_CONDITIONAL: {
- OrderConditionComparator occ = order->GetConditionComparator();
- SetDParam(1, (occ == OCC_IS_TRUE || occ == OCC_IS_FALSE) ? STR_CONDITIONAL_TRUE_FALSE : STR_CONDITIONAL_NUM);
+ case OT_CONDITIONAL:
SetDParam(2, order->GetConditionSkipToOrder() + 1);
- SetDParam(3, STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + order->GetConditionVariable());
- SetDParam(4, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + occ);
-
- uint value = order->GetConditionValue();
- if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
- SetDParam(5, value);
- } break;
+ if (order->GetConditionVariable() == OCV_UNCONDITIONALLY) {
+ SetDParam(1, STR_CONDITIONAL_UNCONDITIONAL);
+ } else {
+ OrderConditionComparator occ = order->GetConditionComparator();
+ SetDParam(1, (occ == OCC_IS_TRUE || occ == OCC_IS_FALSE) ? STR_CONDITIONAL_TRUE_FALSE : STR_CONDITIONAL_NUM);
+ SetDParam(3, STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + order->GetConditionVariable());
+ SetDParam(4, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + occ);
+
+ uint value = order->GetConditionValue();
+ if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
+ SetDParam(5, value);
+ }
+ break;
default: NOT_REACHED();
}
diff --git a/src/order_type.h b/src/order_type.h
index 33de1bd83..1d01bdb74 100644
--- a/src/order_type.h
+++ b/src/order_type.h
@@ -95,6 +95,7 @@ enum OrderConditionVariable {
OCV_MAX_SPEED, ///< Skip based on the maximum speed
OCV_AGE, ///< Skip based on the age
OCV_REQUIRES_SERVICE, ///< Skip when the vehicle requires service
+ OCV_UNCONDITIONALLY, ///< Always skip
OCV_END
};
diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp
index d77691552..75ed54a65 100644
--- a/src/timetable_gui.cpp
+++ b/src/timetable_gui.cpp
@@ -179,18 +179,22 @@ static void DrawTimetableWindow(Window *w)
break;
- case OT_CONDITIONAL: {
- extern uint ConvertSpeedToDisplaySpeed(uint speed);
- OrderConditionComparator occ = order->GetConditionComparator();
- SetDParam(0, (occ == OCC_IS_TRUE || occ == OCC_IS_FALSE) ? STR_CONDITIONAL_TRUE_FALSE : STR_CONDITIONAL_NUM);
+ case OT_CONDITIONAL:
SetDParam(1, order->GetConditionSkipToOrder() + 1);
- SetDParam(2, STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + order->GetConditionVariable());
- SetDParam(3, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + occ);
-
- uint value = order->GetConditionValue();
- if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
- SetDParam(4, value);
- } break;
+ if (order->GetConditionVariable() == OCV_UNCONDITIONALLY) {
+ SetDParam(0, STR_CONDITIONAL_UNCONDITIONAL);
+ } else {
+ extern uint ConvertSpeedToDisplaySpeed(uint speed);
+ OrderConditionComparator occ = order->GetConditionComparator();
+ SetDParam(0, (occ == OCC_IS_TRUE || occ == OCC_IS_FALSE) ? STR_CONDITIONAL_TRUE_FALSE : STR_CONDITIONAL_NUM);
+ SetDParam(2, STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + order->GetConditionVariable());
+ SetDParam(3, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + occ);
+
+ uint value = order->GetConditionValue();
+ if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
+ SetDParam(4, value);
+ }
+ break;
default: break;
}