Changeset - r8903:9c0d5a75fa24
[Not reviewed]
master
0 5 0
rubidium - 16 years ago 2008-04-12 13:07:25
rubidium@openttd.org
(svn r12670) -Add: unconditional/always order 'jump/skip' variable.
5 files changed with 43 insertions and 20 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -2706,21 +2706,23 @@ STR_ORDER_CONDITIONAL_VALUE_TOOLTIP     
 
STR_ORDER_CONDITIONAL_VALUE_CAPT                                :{WHITE}Enter value to compare against
 
STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE                           :Load percentage
 
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
 
STR_ORDER_CONDITIONAL_COMPARATOR_LESS_EQUALS                    :is less or equal to
 
STR_ORDER_CONDITIONAL_COMPARATOR_MORE_THAN                      :is more than
 
STR_ORDER_CONDITIONAL_COMPARATOR_MORE_EQUALS                    :is more or equal to
 
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}
 

	
 
STR_TIMETABLE_GO_TO                                             :{STRING4} {STRING2}
 
STR_TIMETABLE_TRAVEL_NOT_TIMETABLED                             :Travel (not timetabled)
 
STR_TIMETABLE_TRAVEL_FOR                                        :Travel for {STRING1}
src/order_cmd.cpp
Show inline comments
 
@@ -893,24 +893,28 @@ CommandCost CmdModifyOrder(TileIndex til
 
			if (data >= OCV_END) return CMD_ERROR;
 
			break;
 

	
 
		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;
 

	
 
				default:
 
					if (data == OCC_IS_TRUE || data == OCC_IS_FALSE) return CMD_ERROR;
 
					break;
 
			}
 
			break;
 

	
 
		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;
 
					break;
 

	
 
				default:
 
@@ -947,12 +951,17 @@ CommandCost CmdModifyOrder(TileIndex til
 

	
 
			case MOF_COND_VARIABLE: {
 
				order->SetConditionVariable((OrderConditionVariable)data);
 

	
 
				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;
 

	
 
					case OCV_LOAD_PERCENTAGE:
 
					case OCV_RELIABILITY:
 
@@ -1703,12 +1712,13 @@ bool ProcessOrders(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, v->reliability * 100 >> 16,        value); break;
 
				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);
 
			if (skip_order) {
 
				v->cur_order_index = order->GetConditionSkipToOrder();
 
			} else {
src/order_gui.cpp
Show inline comments
 
@@ -188,12 +188,13 @@ static const StringID _order_goto_dropdo
 
static const StringID _order_conditional_variable[] = {
 
	STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE,
 
	STR_ORDER_CONDITIONAL_RELIABILITY,
 
	STR_ORDER_CONDITIONAL_MAX_SPEED,
 
	STR_ORDER_CONDITIONAL_AGE,
 
	STR_ORDER_CONDITIONAL_REQUIRES_SERVICE,
 
	STR_ORDER_CONDITIONAL_UNCONDITIONALLY,
 
	INVALID_STRING_ID,
 
};
 

	
 
static const StringID _order_conditional_condition[] = {
 
	STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS,
 
	STR_ORDER_CONDITIONAL_COMPARATOR_NOT_EQUALS,
 
@@ -282,13 +283,14 @@ static void DrawOrdersWindow(Window *w)
 
				w->HideWidget(ORDER_WIDGET_FULL_LOAD);
 
				w->ShowWidget(ORDER_WIDGET_COND_VARIABLE);
 
				w->ShowWidget(ORDER_WIDGET_COND_COMPARATOR);
 
				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);
 
				SetDParam(1, value);
 
			} break;
 

	
 
@@ -369,23 +371,27 @@ static void DrawOrdersWindow(Window *w)
 

	
 
				case OT_GOTO_WAYPOINT:
 
					SetDParam(1, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
 
					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);
 
					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;
 
						uint value = order->GetConditionValue();
 
						if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
 
						SetDParam(5, value);
 
					}
 
					break;
 

	
 
				default: NOT_REACHED();
 
			}
 

	
 
			SetDParam(0, i + 1);
 
			DrawString(2, y, str, (i == WP(w, order_d).sel) ? TC_WHITE : TC_BLACK);
src/order_type.h
Show inline comments
 
@@ -92,12 +92,13 @@ enum OrderDepotActionFlags {
 
enum OrderConditionVariable {
 
	OCV_LOAD_PERCENTAGE,  ///< Skip based on the amount of load
 
	OCV_RELIABILITY,      ///< Skip based on the 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
 
	OCV_UNCONDITIONALLY,  ///< Always skip
 
	OCV_END
 
};
 

	
 
/**
 
 * Comparator for the skip reasoning.
 
 */
src/timetable_gui.cpp
Show inline comments
 
@@ -176,24 +176,28 @@ static void DrawTimetableWindow(Window *
 
				case OT_GOTO_WAYPOINT:
 
					SetDParam(0, (order->GetNonStopType() != ONSF_STOP_EVERYWHERE) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
 
					SetDParam(1, order->GetDestination());
 
					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);
 
					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;
 
						uint value = order->GetConditionValue();
 
						if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
 
						SetDParam(4, value);
 
					}
 
					break;
 

	
 
				default: break;
 
			}
 

	
 
			DrawString(2, y, STR_TIMETABLE_GO_TO, (i == selected) ? TC_WHITE : TC_BLACK);
 

	
0 comments (0 inline, 0 general)