Merge branch 'tracerestrict-sx' into jgrpp

# Conflicts:
#	src/lang/english.txt
#	src/saveload/extended_ver_sl.cpp
#	src/tracerestrict.cpp
#	src/tracerestrict.h
#	src/tracerestrict_gui.cpp
pull/8/head
Jonathan G Rennison 8 years ago
commit 80e3af6bf5

@ -678,6 +678,7 @@
<ClInclude Include="..\src\os\windows\win32.h" />
<ClInclude Include="..\src\music\win32_m.h" />
<ClInclude Include="..\src\sound\win32_s.h" />
<ClInclude Include="..\src\unit_conversion.h" />
<ClInclude Include="..\src\video\win32_v.h" />
<ClInclude Include="..\src\window_func.h" />
<ClInclude Include="..\src\window_gui.h" />

@ -1263,6 +1263,9 @@
<ClInclude Include="..\src\sound\win32_s.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\unit_conversion.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\video\win32_v.h">
<Filter>Header Files</Filter>
</ClInclude>

@ -695,6 +695,7 @@
<ClInclude Include="..\src\os\windows\win32.h" />
<ClInclude Include="..\src\music\win32_m.h" />
<ClInclude Include="..\src\sound\win32_s.h" />
<ClInclude Include="..\src\unit_conversion.h" />
<ClInclude Include="..\src\video\win32_v.h" />
<ClInclude Include="..\src\window_func.h" />
<ClInclude Include="..\src\window_gui.h" />

@ -1263,6 +1263,9 @@
<ClInclude Include="..\src\sound\win32_s.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\unit_conversion.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\video\win32_v.h">
<Filter>Header Files</Filter>
</ClInclude>

@ -1986,6 +1986,10 @@
RelativePath=".\..\src\sound\win32_s.h"
>
</File>
<File
RelativePath=".\..\src\unit_conversion.h"
>
</File>
<File
RelativePath=".\..\src\video\win32_v.h"
>

@ -1983,6 +1983,10 @@
RelativePath=".\..\src\sound\win32_s.h"
>
</File>
<File
RelativePath=".\..\src\unit_conversion.h"
>
</File>
<File
RelativePath=".\..\src\video\win32_v.h"
>

@ -418,6 +418,7 @@ widget_type.h
os/windows/win32.h
music/win32_m.h
sound/win32_s.h
unit_conversion.h
video/win32_v.h
window_func.h
window_gui.h

@ -2535,11 +2535,21 @@ STR_TRACE_RESTRICT_VARIABLE_ENTRY_DIRECTION :entry direction
STR_TRACE_RESTRICT_VARIABLE_PBS_ENTRY_SIGNAL :PBS entry signal
STR_TRACE_RESTRICT_VARIABLE_PBS_ENTRY_SIGNAL_LONG :entered signal of PBS block
STR_TRACE_RESTRICT_VARIABLE_TRAIN_GROUP :train group
STR_TRACE_RESTRICT_VARIABLE_TRAIN_WEIGHT :weight
STR_TRACE_RESTRICT_VARIABLE_TRAIN_POWER :power
STR_TRACE_RESTRICT_VARIABLE_TRAIN_MAX_TE :max T.E.
STR_TRACE_RESTRICT_VARIABLE_TRAIN_POWER_WEIGHT_RATIO :power / weight ratio
STR_TRACE_RESTRICT_VARIABLE_TRAIN_MAX_TE_WEIGHT_RATIO :max T.E. / weight ratio
STR_TRACE_RESTRICT_VARIABLE_TRAIN_OWNER :train owner
STR_TRACE_RESTRICT_VARIABLE_UNDEFINED :undefined
STR_TRACE_RESTRICT_VARIABLE_UNDEFINED_RED :{RED}undefined
STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_INTEGER :{STRING} {STRING} {STRING} {COMMA} then
STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_SPEED :{STRING} {STRING} {STRING} {VELOCITY} then
STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_WEIGHT :{STRING} {STRING} {STRING} {WEIGHT_SHORT} then
STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_POWER :{STRING} {STRING} {STRING} {POWER} then
STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_FORCE :{STRING} {STRING} {STRING} {FORCE} then
STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_POWER_WEIGHT_RATIO :{STRING} {STRING} {STRING} {POWER} / {STRING1} then
STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_FORCE_WEIGHT_RATIO :{STRING} {STRING} {STRING} {FORCE} / {STRING1} then
STR_TRACE_RESTRICT_CONDITIONAL_ORDER_STATION :{STRING} {STRING} {STRING} {STATION} then
STR_TRACE_RESTRICT_CONDITIONAL_ORDER_WAYPOINT :{STRING} {STRING} {STRING} {WAYPOINT} then
STR_TRACE_RESTRICT_CONDITIONAL_ORDER_DEPOT :{STRING} {STRING} {STRING} {DEPOT} then

@ -47,7 +47,7 @@ std::vector<uint32> _sl_xv_discardable_chunk_ids; ///< list of chunks
static const uint32 _sl_xv_slxi_chunk_version = 0; ///< current version os SLXI chunk
const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
{ XSLFI_TRACE_RESTRICT, XSCF_NULL, 5, 5, "tracerestrict", NULL, NULL, "TRRM,TRRP" },
{ XSLFI_TRACE_RESTRICT, XSCF_NULL, 6, 6, "tracerestrict", NULL, NULL, "TRRM,TRRP" },
{ XSLFI_TRACE_RESTRICT_OWNER, XSCF_NULL, 1, 1, "tracerestrict_owner", NULL, NULL, NULL },
{ XSLFI_PROG_SIGS, XSCF_NULL, 1, 1, "programmable_signals", NULL, NULL, "SPRG" },
{ XSLFI_ADJACENT_CROSSINGS, XSCF_NULL, 1, 1, "adjacent_crossings", NULL, NULL, NULL },

@ -34,6 +34,7 @@
#include "smallmap_gui.h"
#include "window_func.h"
#include "debug.h"
#include "unit_conversion.h"
#include "game/game_text.hpp"
#include "network/network_content_gui.h"
#include <stack>
@ -782,6 +783,67 @@ uint ConvertDisplaySpeedToKmhishSpeed(uint speed)
{
return _units_velocity[_settings_game.locale.units_velocity].c.FromDisplay(speed * 16, true, 10);
}
/**
* Convert the given internal weight to the display weight.
* @param weight the weight to convert
* @return the converted weight.
*/
uint ConvertWeightToDisplayWeight(uint weight)
{
return _units_weight[_settings_game.locale.units_weight].c.ToDisplay(weight);
}
/**
* Convert the given display weight to the (internal) weight.
* @param weight the weight to convert
* @return the converted weight.
*/
uint ConvertDisplayWeightToWeight(uint weight)
{
return _units_weight[_settings_game.locale.units_weight].c.FromDisplay(weight);
}
/**
* Convert the given internal power to the display power.
* @param power the power to convert
* @return the converted power.
*/
uint ConvertPowerToDisplayPower(uint power)
{
return _units_power[_settings_game.locale.units_power].c.ToDisplay(power);
}
/**
* Convert the given display power to the (internal) power.
* @param power the power to convert
* @return the converted power.
*/
uint ConvertDisplayPowerToPower(uint power)
{
return _units_power[_settings_game.locale.units_power].c.FromDisplay(power);
}
/**
* Convert the given internal force to the display force.
* @param force the force to convert
* @return the converted force.
*/
uint ConvertForceToDisplayForce(uint force)
{
return _units_force[_settings_game.locale.units_force].c.ToDisplay(force);
}
/**
* Convert the given display force to the (internal) force.
* @param force the force to convert
* @return the converted force.
*/
uint ConvertDisplayForceToForce(uint force)
{
return _units_force[_settings_game.locale.units_force].c.FromDisplay(force);
}
/**
* Parse most format codes within a string and write the result to a buffer.
* @param buff The buffer to write the final string to.

@ -349,6 +349,44 @@ void TraceRestrictProgram::Execute(const Train* v, const TraceRestrictProgramInp
break;
}
case TRIT_COND_PHYS_PROP: {
switch (static_cast<TraceRestrictPhysPropCondAuxField>(GetTraceRestrictAuxField(item))) {
case TRPPCAF_WEIGHT:
result = TestCondition(v->gcache.cached_weight, condop, condvalue);
break;
case TRPPCAF_POWER:
result = TestCondition(v->gcache.cached_power, condop, condvalue);
break;
case TRPPCAF_MAX_TE:
result = TestCondition(v->gcache.cached_max_te / 1000, condop, condvalue);
break;
default:
NOT_REACHED();
break;
}
break;
}
case TRIT_COND_PHYS_RATIO: {
switch (static_cast<TraceRestrictPhysPropRatioCondAuxField>(GetTraceRestrictAuxField(item))) {
case TRPPRCAF_POWER_WEIGHT:
result = TestCondition(min<uint>(UINT16_MAX, (100 * v->gcache.cached_power) / max<uint>(1, v->gcache.cached_weight)), condop, condvalue);
break;
case TRPPRCAF_MAX_TE_WEIGHT:
result = TestCondition(min<uint>(UINT16_MAX, (v->gcache.cached_max_te / 10) / max<uint>(1, v->gcache.cached_weight)), condop, condvalue);
break;
default:
NOT_REACHED();
break;
}
break;
}
case TRIT_COND_TRAIN_OWNER: {
result = TestBinaryConditionCommon(item, v->owner == condvalue);
break;
@ -491,6 +529,8 @@ CommandCost TraceRestrictProgram::Validate(const std::vector<TraceRestrictItem>
case TRIT_COND_ENTRY_DIRECTION:
case TRIT_COND_PBS_ENTRY_SIGNAL:
case TRIT_COND_TRAIN_GROUP:
case TRIT_COND_PHYS_PROP:
case TRIT_COND_PHYS_RATIO:
case TRIT_COND_TRAIN_OWNER:
break;
@ -565,8 +605,15 @@ void SetTraceRestrictValueDefault(TraceRestrictItem &item, TraceRestrictValueTyp
case TRVT_TILE_INDEX:
case TRVT_RESERVE_THROUGH:
case TRVT_LONG_RESERVE:
case TRVT_WEIGHT:
case TRVT_POWER:
case TRVT_FORCE:
case TRVT_POWER_WEIGHT_RATIO:
case TRVT_FORCE_WEIGHT_RATIO:
SetTraceRestrictValue(item, 0);
SetTraceRestrictAuxField(item, 0);
if (!IsTraceRestrictTypeAuxSubtype(GetTraceRestrictType(item))) {
SetTraceRestrictAuxField(item, 0);
}
break;
case TRVT_ORDER:
@ -609,7 +656,7 @@ void SetTraceRestrictValueDefault(TraceRestrictItem &item, TraceRestrictValueTyp
/**
* Set the type field of a TraceRestrictItem, and resets any other fields which are no longer valid/meaningful to sensible defaults
*/
void SetTraceRestrictTypeAndNormalise(TraceRestrictItem &item, TraceRestrictItemType type)
void SetTraceRestrictTypeAndNormalise(TraceRestrictItem &item, TraceRestrictItemType type, uint8 aux_data)
{
if (item != 0) {
assert(GetTraceRestrictType(item) != TRIT_NULL);
@ -619,6 +666,11 @@ void SetTraceRestrictTypeAndNormalise(TraceRestrictItem &item, TraceRestrictItem
TraceRestrictTypePropertySet old_properties = GetTraceRestrictTypeProperties(item);
SetTraceRestrictType(item, type);
if (IsTraceRestrictTypeAuxSubtype(type)) {
SetTraceRestrictAuxField(item, aux_data);
} else {
assert(aux_data == 0);
}
TraceRestrictTypePropertySet new_properties = GetTraceRestrictTypeProperties(item);
if (old_properties.cond_type != new_properties.cond_type ||
@ -626,6 +678,10 @@ void SetTraceRestrictTypeAndNormalise(TraceRestrictItem &item, TraceRestrictItem
SetTraceRestrictCondOp(item, TRCO_IS);
SetTraceRestrictValueDefault(item, new_properties.value_type);
}
if (GetTraceRestrictType(item) == TRIT_COND_LAST_STATION && GetTraceRestrictAuxField(item) != TROCAF_STATION) {
// if changing type from another order type to last visited station, reset value if not currently a station
SetTraceRestrictValueDefault(item, TRVT_ORDER);
}
}
/**
@ -763,7 +819,7 @@ void TraceRestrictDoCommandP(TileIndex tile, Track track, TraceRestrictDoCommand
}
/**
* Check whether a tile/tracl pair contains a usable signal
* Check whether a tile/track pair contains a usable signal
*/
static CommandCost TraceRestrictCheckTileIsUsable(TileIndex tile, Track track)
{

@ -113,6 +113,8 @@ enum TraceRestrictItemType {
TRIT_COND_ENTRY_DIRECTION = 16, ///< Test which side of signal/signal tile is being entered from
TRIT_COND_PBS_ENTRY_SIGNAL = 17, ///< Test tile and PBS-state of previous signal
TRIT_COND_TRAIN_GROUP = 18, ///< Test train group membership
TRIT_COND_PHYS_PROP = 19, ///< Test train physical property
TRIT_COND_PHYS_RATIO = 20, ///< Test train physical property ratio
TRIT_COND_TRAIN_OWNER = 24, ///< Test train owner
/* space up to 31 */
};
@ -172,6 +174,25 @@ enum TraceRestrictOrderCondAuxField {
/* space up to 3 */
};
/**
* TraceRestrictItem auxiliary type field, for physical property type conditionals
*/
enum TraceRestrictPhysPropCondAuxField {
TRPPCAF_WEIGHT = 0, ///< value field is a weight
TRPPCAF_POWER = 1, ///< value field is a power
TRPPCAF_MAX_TE = 2, ///< value field is a tractive effort
/* space up to 3 */
};
/**
* TraceRestrictItem auxiliary type field, for physical property ratio type conditionals
*/
enum TraceRestrictPhysPropRatioCondAuxField {
TRPPRCAF_POWER_WEIGHT = 0, ///< value field is a 100 * power / weight ratio
TRPPRCAF_MAX_TE_WEIGHT = 1, ///< value field is a 100 * tractive effort / weight ratio
/* space up to 3 */
};
/**
* TraceRestrictItem auxiliary type field, for order type conditionals
*/
@ -414,6 +435,11 @@ enum TraceRestrictValueType {
TRVT_RESERVE_THROUGH = 10,///< takes a value 0 = reserve through, 1 = cancel previous reserve through
TRVT_LONG_RESERVE = 11,///< takes a value 0 = long reserve, 1 = cancel previous long reserve
TRVT_GROUP_INDEX = 12,///< takes a GroupID
TRVT_WEIGHT = 13,///< takes a weight
TRVT_POWER = 14,///< takes a power
TRVT_FORCE = 15,///< takes a force
TRVT_POWER_WEIGHT_RATIO = 16,///< takes a power / weight ratio, * 100
TRVT_FORCE_WEIGHT_RATIO = 17,///< takes a force / weight ratio, * 100
TRVT_OWNER = 40,///< takes a CompanyID
};
@ -426,7 +452,7 @@ struct TraceRestrictTypePropertySet {
};
void SetTraceRestrictValueDefault(TraceRestrictItem &item, TraceRestrictValueType value_type);
void SetTraceRestrictTypeAndNormalise(TraceRestrictItem &item, TraceRestrictItemType type);
void SetTraceRestrictTypeAndNormalise(TraceRestrictItem &item, TraceRestrictItemType type, uint8 aux_data = 0);
/**
* Get TraceRestrictTypePropertySet for a given instruction, only looks at value field
@ -481,6 +507,42 @@ static inline TraceRestrictTypePropertySet GetTraceRestrictTypeProperties(TraceR
out.cond_type = TRCOT_BINARY;
break;
case TRIT_COND_PHYS_PROP:
switch (static_cast<TraceRestrictPhysPropCondAuxField>(GetTraceRestrictAuxField(item))) {
case TRPPCAF_WEIGHT:
out.value_type = TRVT_WEIGHT;
break;
case TRPPCAF_POWER:
out.value_type = TRVT_POWER;
break;
case TRPPCAF_MAX_TE:
out.value_type = TRVT_FORCE;
break;
default:
NOT_REACHED();
break;
}
break;
case TRIT_COND_PHYS_RATIO:
switch (static_cast<TraceRestrictPhysPropRatioCondAuxField>(GetTraceRestrictAuxField(item))) {
case TRPPRCAF_POWER_WEIGHT:
out.value_type = TRVT_POWER_WEIGHT_RATIO;
break;
case TRPPRCAF_MAX_TE_WEIGHT:
out.value_type = TRVT_FORCE_WEIGHT_RATIO;
break;
default:
NOT_REACHED();
break;
}
break;
case TRIT_COND_TRAIN_OWNER:
out.value_type = TRVT_OWNER;
out.cond_type = TRCOT_BINARY;
@ -508,6 +570,19 @@ static inline TraceRestrictTypePropertySet GetTraceRestrictTypeProperties(TraceR
return out;
}
/** Is the aux field for this TraceRestrictItemType used as a subtype which changes the type of the value field? */
static inline bool IsTraceRestrictTypeAuxSubtype(TraceRestrictItemType type)
{
switch (type) {
case TRIT_COND_PHYS_PROP:
case TRIT_COND_PHYS_RATIO:
return true;
default:
return false;
}
}
/** Get mapping ref ID from tile and track */
static inline TraceRestrictRefId MakeTraceRestrictRefId(TileIndex t, Track track)
{

@ -37,12 +37,10 @@
#include "cargotype.h"
#include "sortlist_type.h"
#include "group.h"
#include "unit_conversion.h"
#include "table/sprites.h"
#include "toolbar_gui.h"
extern uint ConvertSpeedToDisplaySpeed(uint speed);
extern uint ConvertDisplaySpeedToSpeed(uint speed);
/** Widget IDs */
enum TraceRestrictWindowWidgets {
TR_WIDGET_CAPTION,
@ -242,10 +240,27 @@ static StringID GetDropDownStringByValue(const TraceRestrictDropDownListSet *lis
return list_set->string_array[GetDropDownListIndexByValue(list_set, value, false)];
}
typedef uint TraceRestrictGuiItemType;
static TraceRestrictGuiItemType GetItemGuiType(TraceRestrictItem item)
{
TraceRestrictItemType type = GetTraceRestrictType(item);
if (IsTraceRestrictTypeAuxSubtype(type)) {
return type | (GetTraceRestrictAuxField(item) << 16);
} else {
return type;
}
}
static TraceRestrictItemType ItemTypeFromGuiType(TraceRestrictGuiItemType type)
{
return static_cast<TraceRestrictItemType>(type & 0xFFFF);
}
/**
* Return the appropriate type dropdown TraceRestrictDropDownListSet for the given item type @p type
*/
static const TraceRestrictDropDownListSet *GetTypeDropDownListSet(TraceRestrictItemType type)
static const TraceRestrictDropDownListSet *GetTypeDropDownListSet(TraceRestrictGuiItemType type)
{
static const StringID str_action[] = {
STR_TRACE_RESTRICT_PF_DENY,
@ -275,6 +290,11 @@ static const TraceRestrictDropDownListSet *GetTypeDropDownListSet(TraceRestrictI
STR_TRACE_RESTRICT_VARIABLE_PBS_ENTRY_SIGNAL,
STR_TRACE_RESTRICT_VARIABLE_TRAIN_GROUP,
STR_TRACE_RESTRICT_VARIABLE_TRAIN_OWNER,
STR_TRACE_RESTRICT_VARIABLE_TRAIN_WEIGHT,
STR_TRACE_RESTRICT_VARIABLE_TRAIN_POWER,
STR_TRACE_RESTRICT_VARIABLE_TRAIN_MAX_TE,
STR_TRACE_RESTRICT_VARIABLE_TRAIN_POWER_WEIGHT_RATIO,
STR_TRACE_RESTRICT_VARIABLE_TRAIN_MAX_TE_WEIGHT_RATIO,
STR_TRACE_RESTRICT_VARIABLE_UNDEFINED,
INVALID_STRING_ID,
};
@ -289,13 +309,18 @@ static const TraceRestrictDropDownListSet *GetTypeDropDownListSet(TraceRestrictI
TRIT_COND_PBS_ENTRY_SIGNAL,
TRIT_COND_TRAIN_GROUP,
TRIT_COND_TRAIN_OWNER,
TRIT_COND_PHYS_PROP | (TRPPCAF_WEIGHT << 16),
TRIT_COND_PHYS_PROP | (TRPPCAF_POWER << 16),
TRIT_COND_PHYS_PROP | (TRPPCAF_MAX_TE << 16),
TRIT_COND_PHYS_RATIO | (TRPPRCAF_POWER_WEIGHT << 16),
TRIT_COND_PHYS_RATIO | (TRPPRCAF_MAX_TE_WEIGHT << 16),
TRIT_COND_UNDEFINED,
};
static const TraceRestrictDropDownListSet set_cond = {
str_cond, val_cond,
};
return IsTraceRestrictTypeConditional(type) ? &set_cond : &set_action;
return IsTraceRestrictTypeConditional(ItemTypeFromGuiType(type)) ? &set_cond : &set_action;
}
/**
@ -382,8 +407,9 @@ static StringID GetCargoStringByID(CargoID cargo)
/**
* Get the StringID for a given item type @p type
*/
static StringID GetTypeString(TraceRestrictItemType type)
static StringID GetTypeString(TraceRestrictItem item)
{
TraceRestrictGuiItemType type = GetItemGuiType(item);
return GetDropDownStringByValue(GetTypeDropDownListSet(type), type);
}
@ -450,6 +476,11 @@ static bool IsIntegerValueType(TraceRestrictValueType type)
switch (type) {
case TRVT_INT:
case TRVT_SPEED:
case TRVT_WEIGHT:
case TRVT_POWER:
case TRVT_FORCE:
case TRVT_POWER_WEIGHT_RATIO:
case TRVT_FORCE_WEIGHT_RATIO:
return true;
default:
@ -471,6 +502,36 @@ static uint ConvertIntegerValue(TraceRestrictValueType type, uint in, bool to_di
? ConvertSpeedToDisplaySpeed(in) * 10 / 16
: ConvertDisplaySpeedToSpeed(in) * 16 / 10;
case TRVT_WEIGHT:
return to_display
? ConvertWeightToDisplayWeight(in)
: ConvertDisplayWeightToWeight(in);
break;
case TRVT_POWER:
return to_display
? ConvertPowerToDisplayPower(in)
: ConvertDisplayPowerToPower(in);
break;
case TRVT_FORCE:
return to_display
? ConvertForceToDisplayForce(in)
: ConvertDisplayForceToForce(in);
break;
case TRVT_POWER_WEIGHT_RATIO:
return to_display
? ConvertPowerToDisplayPower(in) * 10
: ConvertDisplayPowerToPower(in) / 10;
break;
case TRVT_FORCE_WEIGHT_RATIO:
return to_display
? ConvertForceToDisplayForce(in) * 10
: ConvertDisplayForceToForce(in) / 10;
break;
case TRVT_PF_PENALTY:
return in;
@ -553,7 +614,7 @@ static void DrawInstructionStringConditionalCommon(TraceRestrictItem item, const
{
assert(GetTraceRestrictCondFlags(item) <= TRCF_OR);
SetDParam(0, _program_cond_type[GetTraceRestrictCondFlags(item)]);
SetDParam(1, GetTypeString(GetTraceRestrictType(item)));
SetDParam(1, GetTypeString(item));
SetDParam(2, GetDropDownStringByValue(GetCondOpDropDownListSet(properties), GetTraceRestrictCondOp(item)));
}
@ -714,6 +775,35 @@ static void DrawInstructionString(const TraceRestrictProgram *prog, TraceRestric
break;
}
case TRVT_WEIGHT:
instruction_string = STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_WEIGHT;
DrawInstructionStringConditionalIntegerCommon(item, properties);
break;
case TRVT_POWER:
instruction_string = STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_POWER;
DrawInstructionStringConditionalIntegerCommon(item, properties);
break;
case TRVT_FORCE:
instruction_string = STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_FORCE;
DrawInstructionStringConditionalIntegerCommon(item, properties);
break;
case TRVT_POWER_WEIGHT_RATIO:
instruction_string = STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_POWER_WEIGHT_RATIO;
DrawInstructionStringConditionalIntegerCommon(item, properties);
SetDParam(4, STR_UNITS_WEIGHT_LONG_METRIC);
SetDParam(5, 100);
break;
case TRVT_FORCE_WEIGHT_RATIO:
instruction_string = STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_FORCE_WEIGHT_RATIO;
DrawInstructionStringConditionalIntegerCommon(item, properties);
SetDParam(4, STR_UNITS_WEIGHT_LONG_METRIC);
SetDParam(5, 100);
break;
default:
NOT_REACHED();
break;
@ -925,7 +1015,7 @@ public:
case TR_WIDGET_TYPE_COND:
case TR_WIDGET_TYPE_NONCOND: {
TraceRestrictItem item = this->GetSelected();
TraceRestrictItemType type = GetTraceRestrictType(item);
TraceRestrictGuiItemType type = GetItemGuiType(item);
if (type != TRIT_NULL) {
this->ShowDropDownListWithValue(GetTypeDropDownListSet(type), type, false, widget, 0, 0, 0);
@ -1109,11 +1199,8 @@ public:
case TR_WIDGET_TYPE_COND:
case TR_WIDGET_TYPE_NONCOND: {
SetTraceRestrictTypeAndNormalise(item, static_cast<TraceRestrictItemType>(value));
if (GetTraceRestrictType(item) == TRIT_COND_LAST_STATION && GetTraceRestrictAuxField(item) != TROCAF_STATION) {
// if changing type from another order type to last visited station, reset value if not currently a station
SetTraceRestrictValueDefault(item, TRVT_ORDER);
}
SetTraceRestrictTypeAndNormalise(item, static_cast<TraceRestrictItemType>(value & 0xFFFF), value >> 16);
TraceRestrictDoCommandP(this->tile, this->track, TRDCT_MODIFY_ITEM, this->selected_instruction - 1, item, STR_TRACE_RESTRICT_ERROR_CAN_T_MODIFY_ITEM);
break;
}
@ -1675,7 +1762,7 @@ private:
this->EnableWidget(type_widget);
this->GetWidget<NWidgetCore>(type_widget)->widget_data =
GetTypeString(GetTraceRestrictType(item));
GetTypeString(item);
if (properties.cond_type == TRCOT_BINARY || properties.cond_type == TRCOT_ALL) {
middle_sel->SetDisplayedPlane(DPM_COMPARATOR);

@ -0,0 +1,19 @@
/* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file unit_conversion.h Functions related to unit conversion. */
uint ConvertSpeedToDisplaySpeed(uint speed);
uint ConvertDisplaySpeedToSpeed(uint speed);
uint ConvertWeightToDisplayWeight(uint weight);
uint ConvertDisplayWeightToWeight(uint weight);
uint ConvertPowerToDisplayPower(uint power);
uint ConvertDisplayPowerToPower(uint power);
uint ConvertForceToDisplayForce(uint force);
uint ConvertDisplayForceToForce(uint force);
Loading…
Cancel
Save