src/newgrf.cpp
branchNewGRF_ports
changeset 6800 6c09e1e86fcb
parent 6789 8817427af899
child 6801 a0b87c971f44
--- a/src/newgrf.cpp	Sun Aug 12 18:18:48 2007 +0000
+++ b/src/newgrf.cpp	Sun Aug 12 18:32:47 2007 +0000
@@ -1245,6 +1245,14 @@
 				housespec->random_colour[2] = 0x0C;  // they stand for red, blue, orange and green
 				housespec->random_colour[3] = 0x06;
 
+				/* Make sure that the third cargo type is valid in this
+				 * climate. This can cause problems when copying the properties
+				 * of a house that accepts food, where the new house is valid
+				 * in the temperate climate. */
+				if (!GetCargo(housespec->accepts_cargo[2])->IsValid()) {
+					housespec->cargo_acceptance[2] = 0;
+				}
+
 				/**
 				 * New houses do not (currently) expect to have a default start
 				 * date before 1930, as this breaks the build date stuff.
@@ -1283,9 +1291,13 @@
 
 				/* If value of goods is negative, it means in fact food or, if in toyland, fizzy_drink acceptance.
 				 * Else, we have "standard" 3rd cargo type, goods or candy, for toyland once more */
-				housespec->accepts_cargo[2] = (goods >= 0) ? ((_opt.landscape == LT_TOYLAND) ? CT_CANDY : CT_GOODS) :
+				CargoID cid = (goods >= 0) ? ((_opt.landscape == LT_TOYLAND) ? CT_CANDY : CT_GOODS) :
 						((_opt.landscape == LT_TOYLAND) ? CT_FIZZY_DRINKS : CT_FOOD);
 
+				/* Make sure the cargo type is valid in this climate. */
+				if (!GetCargo(cid)->IsValid()) goods = 0;
+
+				housespec->accepts_cargo[2] = cid;
 				housespec->cargo_acceptance[2] = abs(goods); // but we do need positive value here
 			} break;