summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-10-20 19:48:25 +0000
committerpeter1138 <peter1138@openttd.org>2006-10-20 19:48:25 +0000
commitdf8b06dec6b999aa3901787ec664899b5e6f7074 (patch)
tree48fd84eccf2c748dcfa67f2c508ad836d3d47088
parent6d2c7b4fdf07692be6d39dcccc32f8134d868797 (diff)
downloadopenttd-df8b06dec6b999aa3901787ec664899b5e6f7074.tar.xz
(svn r6858) - Fix (r6855): Handle rail vehicles with no capacity (N/A) by setting cargo type to CT_INVALID and handling it later. STR_8838_N_A is not a valid cargo type...
-rw-r--r--engine_gui.c2
-rw-r--r--strings.c3
-rw-r--r--train_gui.c14
3 files changed, 11 insertions, 8 deletions
diff --git a/engine_gui.c b/engine_gui.c
index 90ea19140..f328d422e 100644
--- a/engine_gui.c
+++ b/engine_gui.c
@@ -139,7 +139,7 @@ static void DrawTrainEngineInfo(EngineID engine, int x, int y, int maxw)
SetDParam(5, rvi->cargo_type);
SetDParam(6, rvi->capacity << multihead);
} else {
- SetDParam(5, STR_8838_N_A);
+ SetDParam(5, CT_INVALID);
}
DrawStringMultiCenter(x, y, STR_VEHICLE_INFO_COST_WEIGHT_SPEED_POWER, maxw);
}
diff --git a/strings.c b/strings.c
index 7e20c2c01..ead83f84f 100644
--- a/strings.c
+++ b/strings.c
@@ -731,7 +731,8 @@ static char *FormatString(char *buff, const char *str, const int32 *argv, uint c
// Layout now is:
// 8bit - cargo type
// 16-bit - cargo count
- StringID cargo_str = _cargoc.names_long[GetInt32(&argv)];
+ CargoID cargo = GetInt32(&argv);
+ StringID cargo_str = (cargo == CT_INVALID) ? STR_8838_N_A : _cargoc.names_long[cargo];
buff = GetStringWithArgs(buff, cargo_str, argv++);
break;
}
diff --git a/train_gui.c b/train_gui.c
index e89dec050..fc02c6792 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -269,9 +269,10 @@ void DrawTrainEnginePurchaseInfo(int x, int y, EngineID engine_number)
};
/* Cargo type + capacity, or N/A */
- SetDParam(0, STR_8838_N_A);
- SetDParam(2, STR_EMPTY);
- if (rvi->capacity != 0) {
+ if (rvi->capacity == 0) {
+ SetDParam(0, CT_INVALID);
+ SetDParam(2, STR_EMPTY);
+ } else {
SetDParam(0, rvi->cargo_type);
SetDParam(1, (rvi->capacity * (CountArticulatedParts(engine_number) + 1)) << multihead);
SetDParam(2, STR_9842_REFITTABLE);
@@ -317,9 +318,10 @@ void DrawTrainWagonPurchaseInfo(int x, int y, EngineID engine_number)
y += 10;
/* Cargo type + capacity, or N/A */
- SetDParam(0, STR_8838_N_A);
- SetDParam(2, STR_EMPTY);
- if (rvi->capacity != 0) {
+ if (rvi->capacity == 0) {
+ SetDParam(0, CT_INVALID);
+ SetDParam(2, STR_EMPTY);
+ } else {
SetDParam(0, rvi->cargo_type);
SetDParam(1, rvi->capacity * (CountArticulatedParts(engine_number) + 1));
SetDParam(2, refittable ? STR_9842_REFITTABLE : STR_EMPTY);