diff src/station_gui.cpp @ 6297:e7e15e4d1367 draft

(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)
author peter1138 <peter1138@openttd.org>
date Sun, 11 Mar 2007 22:29:37 +0000 (2007-03-11)
parents 3e2faa1f190c
children 8132258640be
line wrap: on
line diff
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -777,13 +777,17 @@
 
 		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;
 		}
 	}
 }