summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-05-04 22:04:28 +0000
committerrubidium <rubidium@openttd.org>2010-05-04 22:04:28 +0000
commitb11dfa8cb835692a8136120c4ee32ee2608d7f80 (patch)
treef1775ab693acf4a0a293e512614896d0275e7b5a /src
parent5db70ad649129bc9cbdbed58cc62c34f0ee1d376 (diff)
downloadopenttd-b11dfa8cb835692a8136120c4ee32ee2608d7f80.tar.xz
(svn r19758) -Add: {HEIGHT} string command
Diffstat (limited to 'src')
-rw-r--r--src/lang/english.txt3
-rw-r--r--src/strings.cpp15
-rw-r--r--src/table/control_codes.h1
-rw-r--r--src/table/strgen_tables.h1
4 files changed, 19 insertions, 1 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index cfc24b94f..f33f01f45 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -215,6 +215,9 @@ STR_UNITS_VOLUME_LONG_SI :{COMMA} m³
STR_UNITS_FORCE_SI :{COMMA} kN
+STR_UNITS_HEIGHT_IMPERIAL :{COMMA} ft
+STR_UNITS_HEIGHT_SI :{COMMA} m
+
# Common window strings
STR_LIST_FILTER_OSKTITLE :{BLACK}Enter filter string
STR_LIST_FILTER_TOOLTIP :{BLACK}Enter a keyword to filter the list for
diff --git a/src/strings.cpp b/src/strings.cpp
index 613ee8ffc..3f4339153 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -508,6 +508,9 @@ struct Units {
int f_m; ///< Multiplier for force
int f_s; ///< Shift for force
StringID force; ///< String for force
+ int h_m; ///< Multiplier for height
+ int h_s; ///< Shift for height
+ StringID height; ///< String for height
};
/* Unit conversions */
@@ -518,6 +521,7 @@ static const Units units[] = {
1, 0, STR_UNITS_WEIGHT_SHORT_METRIC, STR_UNITS_WEIGHT_LONG_METRIC,
1000, 0, STR_UNITS_VOLUME_SHORT_METRIC, STR_UNITS_VOLUME_LONG_METRIC,
1, 0, STR_UNITS_FORCE_SI,
+ 3, 0, STR_UNITS_HEIGHT_IMPERIAL,
},
{ // Metric (km/h, hp, metric ton, litre, kN)
103, 6, STR_UNITS_VELOCITY_METRIC,
@@ -525,6 +529,7 @@ static const Units units[] = {
1, 0, STR_UNITS_WEIGHT_SHORT_METRIC, STR_UNITS_WEIGHT_LONG_METRIC,
1000, 0, STR_UNITS_VOLUME_SHORT_METRIC, STR_UNITS_VOLUME_LONG_METRIC,
1, 0, STR_UNITS_FORCE_SI,
+ 1, 0, STR_UNITS_HEIGHT_SI,
},
{ // SI (m/s, kilowatt, kilogram, cubic metres, kilonewton)
1831, 12, STR_UNITS_VELOCITY_SI,
@@ -532,6 +537,7 @@ static const Units units[] = {
1000, 0, STR_UNITS_WEIGHT_SHORT_SI, STR_UNITS_WEIGHT_LONG_SI,
1, 0, STR_UNITS_VOLUME_SHORT_SI, STR_UNITS_VOLUME_LONG_SI,
1, 0, STR_UNITS_FORCE_SI,
+ 1, 0, STR_UNITS_HEIGHT_SI,
},
};
@@ -603,7 +609,7 @@ static char *FormatString(char *buff, const char *str, int64 *argv, uint casei,
buff = FormatMonthAndYear(buff, GetInt32(&argv), last);
break;
- case SCC_VELOCITY: {// {VELOCITY}
+ case SCC_VELOCITY: { // {VELOCITY}
int64 args[1];
assert(_settings_game.locale.units < lengthof(units));
args[0] = ConvertSpeedToDisplaySpeed(GetInt32(&argv) * 10 / 16);
@@ -612,6 +618,13 @@ static char *FormatString(char *buff, const char *str, int64 *argv, uint casei,
break;
}
+ case SCC_HEIGHT: { // {HEIGHT}
+ int64 args[1] = {GetInt32(&argv) * units[_settings_game.locale.units].h_m >> units[_settings_game.locale.units].h_s};
+ buff = FormatString(buff, GetStringPtr(units[_settings_game.locale.units].height), args, modifier >> 24, last);
+ modifier = 0;
+ break;
+ }
+
case SCC_CURRENCY_COMPACT: // {CURRCOMPACT}
buff = FormatGenericCurrency(buff, _currency, GetInt64(&argv), true, last);
break;
diff --git a/src/table/control_codes.h b/src/table/control_codes.h
index 29ad80b26..4df3badee 100644
--- a/src/table/control_codes.h
+++ b/src/table/control_codes.h
@@ -56,6 +56,7 @@ enum StringControlCode {
SCC_WEIGHT_SHORT,
SCC_FORCE,
SCC_VELOCITY,
+ SCC_HEIGHT,
SCC_DATE_TINY,
SCC_DATE_SHORT,
diff --git a/src/table/strgen_tables.h b/src/table/strgen_tables.h
index b657f80ac..c0271434a 100644
--- a/src/table/strgen_tables.h
+++ b/src/table/strgen_tables.h
@@ -77,6 +77,7 @@ static const CmdStruct _cmd_structs[] = {
{"WEIGHT_S", EmitSingleChar, SCC_WEIGHT_SHORT, 1, C_NONE},
{"FORCE", EmitSingleChar, SCC_FORCE, 1, C_NONE},
{"VELOCITY", EmitSingleChar, SCC_VELOCITY, 1, C_NONE},
+ {"HEIGHT", EmitSingleChar, SCC_HEIGHT, 1, C_NONE},
{"P", EmitPlural, 0, 0, C_DONTCOUNT}, // plural specifier
{"G", EmitGender, 0, 0, C_DONTCOUNT}, // gender specifier