Skip to content
Permalink
Browse files

Add: Conditional order for max. reliability (patch by Cirdan, #6360) (#…

  • Loading branch information
Eddi-z authored and planetmaker committed Jan 5, 2019
1 parent 96b961c commit 13056aedbc0a6c22704a525c1395980d887e0ad2
@@ -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
@@ -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;
@@ -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,
@@ -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
@@ -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");
@@ -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");
@@ -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:
@@ -91,6 +91,7 @@ class ScriptOrder : public ScriptObject {
/* 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.

0 comments on commit 13056ae

Please sign in to comment.
You can’t perform that action at this time.