summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEddi-z <43699911+Eddi-z@users.noreply.github.com>2019-01-05 22:10:37 +0100
committerIngo von Borstel <github@planetmaker.de>2019-01-05 22:10:37 +0100
commit13056aedbc0a6c22704a525c1395980d887e0ad2 (patch)
tree203f6ae42080094d4940675eabbc15b6f5cccb51
parent96b961c69a7be052b9104994b73801b32b5e1c41 (diff)
downloadopenttd-13056aedbc0a6c22704a525c1395980d887e0ad2.tar.xz
Add: Conditional order for max. reliability (patch by Cirdan, #6360) (#7017)
-rw-r--r--src/lang/english.txt1
-rw-r--r--src/order_cmd.cpp1
-rw-r--r--src/order_gui.cpp1
-rw-r--r--src/order_type.h1
-rw-r--r--src/script/api/ai/ai_order.hpp.sq1
-rw-r--r--src/script/api/game/game_order.hpp.sq1
-rw-r--r--src/script/api/script_order.cpp1
-rw-r--r--src/script/api/script_order.hpp1
8 files changed, 8 insertions, 0 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 1cfe14921..20608a278 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -3854,6 +3854,7 @@ STR_ORDER_CONDITIONAL_VARIABLE_TOOLTIP :{BLACK}Vehicle
# Conditional order variables, must follow order of OrderConditionVariable enum
STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE :Load percentage
STR_ORDER_CONDITIONAL_RELIABILITY :Reliability
+STR_ORDER_CONDITIONAL_MAX_RELIABILITY :Maximum reliability
STR_ORDER_CONDITIONAL_MAX_SPEED :Maximum speed
STR_ORDER_CONDITIONAL_AGE :Age (years)
STR_ORDER_CONDITIONAL_REQUIRES_SERVICE :Requires service
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index 12a5eec31..ba8a1a060 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -2017,6 +2017,7 @@ VehicleOrderID ProcessConditionalOrder(const Order *order, const Vehicle *v)
switch (order->GetConditionVariable()) {
case OCV_LOAD_PERCENTAGE: skip_order = OrderConditionCompare(occ, CalcPercentVehicleFilled(v, NULL), value); break;
case OCV_RELIABILITY: skip_order = OrderConditionCompare(occ, ToPercent16(v->reliability), value); break;
+ case OCV_MAX_RELIABILITY: skip_order = OrderConditionCompare(occ, ToPercent16(v->GetEngine()->reliability), value); break;
case OCV_MAX_SPEED: skip_order = OrderConditionCompare(occ, v->GetDisplayMaxSpeed() * 10 / 16, value); break;
case OCV_AGE: skip_order = OrderConditionCompare(occ, v->age / DAYS_IN_LEAP_YEAR, value); break;
case OCV_REQUIRES_SERVICE: skip_order = OrderConditionCompare(occ, v->NeedsServicing(), value); break;
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index 9045fac6b..81350deb7 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -152,6 +152,7 @@ static const StringID _order_goto_dropdown_aircraft[] = {
static const OrderConditionVariable _order_conditional_variable[] = {
OCV_LOAD_PERCENTAGE,
OCV_RELIABILITY,
+ OCV_MAX_RELIABILITY,
OCV_MAX_SPEED,
OCV_AGE,
OCV_REMAINING_LIFETIME,
diff --git a/src/order_type.h b/src/order_type.h
index d3a771ce8..ade099296 100644
--- a/src/order_type.h
+++ b/src/order_type.h
@@ -118,6 +118,7 @@ DECLARE_ENUM_AS_BIT_SET(OrderDepotActionFlags)
enum OrderConditionVariable {
OCV_LOAD_PERCENTAGE, ///< Skip based on the amount of load
OCV_RELIABILITY, ///< Skip based on the reliability
+ OCV_MAX_RELIABILITY, ///< Skip based on the maximum reliability
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
diff --git a/src/script/api/ai/ai_order.hpp.sq b/src/script/api/ai/ai_order.hpp.sq
index 71cc8cfe9..ab25e4810 100644
--- a/src/script/api/ai/ai_order.hpp.sq
+++ b/src/script/api/ai/ai_order.hpp.sq
@@ -44,6 +44,7 @@ void SQAIOrder_Register(Squirrel *engine)
SQAIOrder.DefSQConst(engine, ScriptOrder::OF_INVALID, "OF_INVALID");
SQAIOrder.DefSQConst(engine, ScriptOrder::OC_LOAD_PERCENTAGE, "OC_LOAD_PERCENTAGE");
SQAIOrder.DefSQConst(engine, ScriptOrder::OC_RELIABILITY, "OC_RELIABILITY");
+ SQAIOrder.DefSQConst(engine, ScriptOrder::OC_MAX_RELIABILITY, "OC_MAX_RELIABILITY");
SQAIOrder.DefSQConst(engine, ScriptOrder::OC_MAX_SPEED, "OC_MAX_SPEED");
SQAIOrder.DefSQConst(engine, ScriptOrder::OC_AGE, "OC_AGE");
SQAIOrder.DefSQConst(engine, ScriptOrder::OC_REQUIRES_SERVICE, "OC_REQUIRES_SERVICE");
diff --git a/src/script/api/game/game_order.hpp.sq b/src/script/api/game/game_order.hpp.sq
index f95dce925..e2126c603 100644
--- a/src/script/api/game/game_order.hpp.sq
+++ b/src/script/api/game/game_order.hpp.sq
@@ -44,6 +44,7 @@ void SQGSOrder_Register(Squirrel *engine)
SQGSOrder.DefSQConst(engine, ScriptOrder::OF_INVALID, "OF_INVALID");
SQGSOrder.DefSQConst(engine, ScriptOrder::OC_LOAD_PERCENTAGE, "OC_LOAD_PERCENTAGE");
SQGSOrder.DefSQConst(engine, ScriptOrder::OC_RELIABILITY, "OC_RELIABILITY");
+ SQGSOrder.DefSQConst(engine, ScriptOrder::OC_MAX_RELIABILITY, "OC_MAX_RELIABILITY");
SQGSOrder.DefSQConst(engine, ScriptOrder::OC_MAX_SPEED, "OC_MAX_SPEED");
SQGSOrder.DefSQConst(engine, ScriptOrder::OC_AGE, "OC_AGE");
SQGSOrder.DefSQConst(engine, ScriptOrder::OC_REQUIRES_SERVICE, "OC_REQUIRES_SERVICE");
diff --git a/src/script/api/script_order.cpp b/src/script/api/script_order.cpp
index 676262dc7..a1390bf8f 100644
--- a/src/script/api/script_order.cpp
+++ b/src/script/api/script_order.cpp
@@ -214,6 +214,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
switch (condition) {
case OC_LOAD_PERCENTAGE:
case OC_RELIABILITY:
+ case OC_MAX_RELIABILITY:
case OC_MAX_SPEED:
case OC_AGE:
case OC_REMAINING_LIFETIME:
diff --git a/src/script/api/script_order.hpp b/src/script/api/script_order.hpp
index 63089a2bd..a4f945511 100644
--- a/src/script/api/script_order.hpp
+++ b/src/script/api/script_order.hpp
@@ -91,6 +91,7 @@ public:
/* Note: these values represent part of the in-game OrderConditionVariable enum */
OC_LOAD_PERCENTAGE = ::OCV_LOAD_PERCENTAGE, ///< Skip based on the amount of load, value is in tons.
OC_RELIABILITY = ::OCV_RELIABILITY, ///< Skip based on the reliability, value is percent (0..100).
+ OC_MAX_RELIABILITY = ::OCV_MAX_RELIABILITY, ///< Skip based on the maximum reliability. Value in percent
OC_MAX_SPEED = ::OCV_MAX_SPEED, ///< Skip based on the maximum speed, value is in OpenTTD's internal speed unit, see ScriptEngine::GetMaxSpeed.
OC_AGE = ::OCV_AGE, ///< Skip based on the age, value is in years.
OC_REQUIRES_SERVICE = ::OCV_REQUIRES_SERVICE, ///< Skip when the vehicle requires service, no value.