summaryrefslogtreecommitdiff
path: root/station_gui.c
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-11-06 15:25:02 +0000
committerpeter1138 <peter1138@openttd.org>2006-11-06 15:25:02 +0000
commitbc92e4ee9b39b4de8fd310893772235639979c04 (patch)
tree14d27e1fa0b04e593a00ca91c8c3cc98645ab0a9 /station_gui.c
parentdb7d474b0f7589c1598b5a947a93a462352f1d7d (diff)
downloadopenttd-bc92e4ee9b39b4de8fd310893772235639979c04.tar.xz
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
Diffstat (limited to 'station_gui.c')
-rw-r--r--station_gui.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/station_gui.c b/station_gui.c
index d69e34297..0ed5367b1 100644
--- a/station_gui.c
+++ b/station_gui.c
@@ -637,25 +637,28 @@ static void DrawStationViewWindow(Window *w)
if (IsWindowOfPrototype(w, _station_view_widgets)) {
char *b = _userstring;
+ bool first = true;
b = InlineString(b, STR_000C_ACCEPTS);
for (i = 0; i != NUM_CARGO; i++) {
if (b >= endof(_userstring) - 5 - 1) break;
if (st->goods[i].waiting_acceptance & 0x8000) {
+ if (first) {
+ first = false;
+ } else {
+ /* Add a comma if this is not the first item */
+ *b++ = ',';
+ *b++ = ' ';
+ }
b = InlineString(b, _cargoc.names_s[i]);
- *b++ = ',';
- *b++ = ' ';
}
}
- if (b == &_userstring[3]) {
- b = InlineString(b, STR_00D0_NOTHING);
- *b++ = '\0';
- } else {
- b[-2] = '\0';
- }
+ /* If first is still true then no cargo is accepted */
+ if (first) b = InlineString(b, STR_00D0_NOTHING);
+ *b = '\0';
DrawStringMultiLine(2, 67, STR_SPEC_USERSTRING, 245);
} else {
DrawString(2, 67, STR_3034_LOCAL_RATING_OF_TRANSPORT, 0);