From 1c55149e1fb8aca7b94d0343779f8d7231a0259c Mon Sep 17 00:00:00 2001 From: peter1138 Date: Sun, 11 Mar 2007 22:29:37 +0000 Subject: (svn r9127) -Codechange: Check if a cargo is valid before displaying it in a station's cargo rating list. (And duff up the block a little) --- src/station_gui.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/station_gui.cpp') diff --git a/src/station_gui.cpp b/src/station_gui.cpp index 98115f973..309e311a1 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -777,13 +777,17 @@ static void DrawStationViewWindow(Window *w) y = 77; for (CargoID i = 0; i != NUM_CARGO; i++) { - if (st->goods[i].enroute_from != INVALID_STATION) { - SetDParam(0, GetCargo(i)->name); - SetDParam(2, st->goods[i].rating * 101 >> 8); - SetDParam(1, STR_3035_APPALLING + (st->goods[i].rating >> 5)); - DrawString(8, y, STR_303D, 0); - y += 10; - } + const CargoSpec *cs = GetCargo(i); + if (!cs->IsValid()) continue; + + const GoodsEntry *ge = &st->goods[i]; + if (ge->enroute_from == INVALID_STATION) continue; + + SetDParam(0, cs->name); + SetDParam(2, ge->rating * 101 >> 8); + SetDParam(1, STR_3035_APPALLING + (ge->rating >> 5)); + DrawString(8, y, STR_303D, 0); + y += 10; } } } -- cgit v1.2.3-54-g00ecf