summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-04-09 18:25:31 +0000
committerpeter1138 <peter1138@openttd.org>2006-04-09 18:25:31 +0000
commita4a891c007c0346ba2e6a923013d082439a06fe0 (patch)
tree686fcf3756ad71d9db76d35a891de109c3e33f2e
parent32622f2c7bb9577bd1b547454041dce6e5cb0019 (diff)
downloadopenttd-a4a891c007c0346ba2e6a923013d082439a06fe0.tar.xz
(svn r4340) Add force {FORCE} to the units system. This is currently unused.
-rw-r--r--lang/english.txt4
-rw-r--r--strgen/strgen.c1
-rw-r--r--strings.c22
3 files changed, 24 insertions, 3 deletions
diff --git a/lang/english.txt b/lang/english.txt
index f30e983b0..67fa61a78 100644
--- a/lang/english.txt
+++ b/lang/english.txt
@@ -334,6 +334,10 @@ STR_UNITS_VOLUME_LONG_IMPERIAL :{COMMA} gallon{
STR_UNITS_VOLUME_LONG_METRIC :{COMMA} litre{P "" s}
STR_UNITS_VOLUME_LONG_SI :{COMMA} m³
+STR_UNITS_FORCE_IMPERIAL :{COMMA}x10^3 lbf
+STR_UNITS_FORCE_METRIC :{COMMA} ton force
+STR_UNITS_FORCE_SI :{COMMA} kN
+
############ range for menu starts
STR_0154_OPERATING_PROFIT_GRAPH :Operating profit graph
STR_0155_INCOME_GRAPH :Income graph
diff --git a/strgen/strgen.c b/strgen/strgen.c
index 9ae091a88..58400a3f9 100644
--- a/strgen/strgen.c
+++ b/strgen/strgen.c
@@ -450,6 +450,7 @@ static const CmdStruct _cmd_structs[] = {
{"VOLUME_S", EmitEscapedByte, 17, 1, 0},
{"WEIGHT", EmitEscapedByte, 18, 1, 0},
{"WEIGHT_S", EmitEscapedByte, 19, 1, 0},
+ {"FORCE", EmitEscapedByte, 20, 1, 0},
{"P", EmitPlural, 0, 0, C_DONTCOUNT}, // plural specifier
{"G", EmitGender, 0, 0, C_DONTCOUNT}, // gender specifier
diff --git a/strings.c b/strings.c
index 361d0e429..5a16e2a8c 100644
--- a/strings.c
+++ b/strings.c
@@ -495,26 +495,33 @@ typedef struct Units {
int v_s; ///< Shift for volume
StringID s_volume; ///< Short string for volume
StringID l_volume; ///< Long string for volume
+ int f_m; ///< Multiplier for force
+ int f_s; ///< Shift for force
+ StringID force; ///< String for force
} Units;
+/* Unit conversions */
static const Units units[] = {
- { // Imperial (Original)
+ { // Imperial (Original, mph, hp, metric ton, litre, metric ton force)
10, 4, STR_UNITS_VELOCITY_IMPERIAL,
1, 0, STR_UNITS_POWER_IMPERIAL,
1, 0, STR_UNITS_WEIGHT_SHORT_METRIC, STR_UNITS_WEIGHT_LONG_METRIC,
1000, 0, STR_UNITS_VOLUME_SHORT_METRIC, STR_UNITS_VOLUME_LONG_METRIC,
+ 835, 13, STR_UNITS_FORCE_METRIC,
},
- { // Metric
+ { // Metric (km/h, hp, metric ton, litre, metric ton force)
1, 0, STR_UNITS_VELOCITY_METRIC,
1, 0, STR_UNITS_POWER_METRIC,
1, 0, STR_UNITS_WEIGHT_SHORT_METRIC, STR_UNITS_WEIGHT_LONG_METRIC,
1000, 0, STR_UNITS_VOLUME_SHORT_METRIC, STR_UNITS_VOLUME_LONG_METRIC,
+ 835, 13, STR_UNITS_FORCE_METRIC,
},
- { // SI
+ { // SI (m/s, kilowatt, kilogram, cubic metres, kilonewton)
284, 10, STR_UNITS_VELOCITY_SI,
764, 10, STR_UNITS_POWER_SI,
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,
},
};
@@ -725,6 +732,15 @@ static char *FormatString(char *buff, const char *str, const int32 *argv, uint c
break;
}
+ case 20: { // {FORCE}
+ int32 args[1];
+ assert(_opt_ptr->units < lengthof(units));
+ args[0] = GetInt32(&argv) * units[_opt_ptr->units].f_m >> units[_opt_ptr->units].f_s;
+ buff = FormatString(buff, GetStringPtr(units[_opt_ptr->units].force), args, modifier >> 24);
+ modifier = 0;
+ break;
+ }
+
default:
error("!invalid escape sequence in string");
}