summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormaedhros <maedhros@openttd.org>2007-08-10 08:57:04 +0000
committermaedhros <maedhros@openttd.org>2007-08-10 08:57:04 +0000
commitc4f77a2f2674247de9274fcdced7f531c1a02bf8 (patch)
treec151ab1085f0bcaa299c53d37d3a94c3f957da84 /src
parentdb65f0ea8d7780b0a8981a7625cbd59f4dd536a3 (diff)
downloadopenttd-c4f77a2f2674247de9274fcdced7f531c1a02bf8.tar.xz
(svn r10836) -Fix [FS#1014]: Make sure the third cargo type accepted by houses is valid in
the current climate when copying properties from existing houses and using action 0 property 0F.
Diffstat (limited to 'src')
-rw-r--r--src/newgrf.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index d7a3d7af6..f0340e2a3 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -1242,6 +1242,14 @@ static bool TownHouseChangeInfo(uint hid, int numinfo, int prop, byte **bufp, in
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.
@@ -1280,9 +1288,13 @@ static bool TownHouseChangeInfo(uint hid, int numinfo, int prop, byte **bufp, in
/* 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;