summaryrefslogtreecommitdiff
path: root/src/vehicle_gui.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2012-03-10 19:18:04 +0000
committerrubidium <rubidium@openttd.org>2012-03-10 19:18:04 +0000
commitbf6434abaf306272d14019a628af972ce181652c (patch)
tree661db86c626e8555034ce84ff833c2c14648c01f /src/vehicle_gui.cpp
parent19923e81f97fe560ba102ebcbaf116634c68ccb6 (diff)
downloadopenttd-bf6434abaf306272d14019a628af972ce181652c.tar.xz
(svn r24023) -Fix [FS#5090]: pass cases down into the list of cargos
Diffstat (limited to 'src/vehicle_gui.cpp')
-rw-r--r--src/vehicle_gui.cpp35
1 files changed, 6 insertions, 29 deletions
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 399a35576..81f85f534 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -931,49 +931,26 @@ uint ShowRefitOptionsList(int left, int right, int y, EngineID engine)
uint32 cmask = GetUnionOfArticulatedRefitMasks(engine, false);
/* List of cargo types available in this climate */
uint32 lmask = _cargo_mask;
- char string[512];
- char *b = string;
/* Draw nothing if the engine is not refittable */
if (HasAtMostOneBit(cmask)) return y;
- b = InlineString(b, STR_PURCHASE_INFO_REFITTABLE_TO);
-
if (cmask == lmask) {
/* Engine can be refitted to all types in this climate */
- b = InlineString(b, STR_PURCHASE_INFO_ALL_TYPES);
+ SetDParam(0, STR_PURCHASE_INFO_ALL_TYPES);
} else {
/* Check if we are able to refit to more cargo types and unable to. If
* so, invert the cargo types to list those that we can't refit to. */
if (CountBits(cmask ^ lmask) < CountBits(cmask) && CountBits(cmask ^ lmask) <= 7) {
cmask ^= lmask;
- b = InlineString(b, STR_PURCHASE_INFO_ALL_BUT);
- }
-
- bool first = true;
-
- /* Add each cargo type to the list */
- const CargoSpec *cs;
- FOR_ALL_SORTED_CARGOSPECS(cs) {
- if (!HasBit(cmask, cs->Index())) continue;
-
- if (b >= lastof(string) - (2 + 2 * 4)) break; // ", " and two calls to Utf8Encode()
-
- if (!first) b = strecpy(b, ", ", lastof(string));
- first = false;
-
- b = InlineString(b, cs->name);
+ SetDParam(0, STR_PURCHASE_INFO_ALL_BUT);
+ } else {
+ SetDParam(0, STR_JUST_CARGO_LIST);
}
+ SetDParam(1, cmask);
}
- /* Terminate and display the completed string */
- *b = '\0';
-
- /* Make sure we detect any buffer overflow */
- assert(b < endof(string));
-
- SetDParamStr(0, string);
- return DrawStringMultiLine(left, right, y, INT32_MAX, STR_JUST_RAW_STRING);
+ return DrawStringMultiLine(left, right, y, INT32_MAX, STR_PURCHASE_INFO_REFITTABLE_TO);
}
/** Get the cargo subtype text from NewGRF for the vehicle details window. */