summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-07-27 19:16:01 +0000
committerfrosch <frosch@openttd.org>2012-07-27 19:16:01 +0000
commit13bfb09cbb1de18383ffa7991fa581cacc5b28b4 (patch)
treeb1764c6568f83ce0a306b2157c5e0a2d257f05a5
parent4d53128f0cc21da03543cf0c4649e25d90f46775 (diff)
downloadopenttd-13bfb09cbb1de18383ffa7991fa581cacc5b28b4.tar.xz
(svn r24438) -Fix [FS#5256-ish]: Make (non-refittable) vehicles with invalid default cargo unavailable.
-rw-r--r--src/newgrf.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 0b6d9715d..0a5fb30a7 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -1041,7 +1041,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop
} else if (_cur.grffile->grf_version >= 8) {
/* Use translated cargo. Might result in CT_INVALID (first refittable), if cargo is not defined. */
ei->cargo_type = GetCargoTranslation(ctype, _cur.grffile);
- } else if (ctype < NUM_CARGO && HasBit(_cargo_mask, ctype)) {
+ } else if (ctype < NUM_CARGO) {
/* Use untranslated cargo. */
ei->cargo_type = ctype;
} else {
@@ -1276,7 +1276,7 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop
} else if (_cur.grffile->grf_version >= 8) {
/* Use translated cargo. Might result in CT_INVALID (first refittable), if cargo is not defined. */
ei->cargo_type = GetCargoTranslation(ctype, _cur.grffile);
- } else if (ctype < NUM_CARGO && HasBit(_cargo_mask, ctype)) {
+ } else if (ctype < NUM_CARGO) {
/* Use untranslated cargo. */
ei->cargo_type = ctype;
} else {
@@ -1454,7 +1454,7 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop
} else if (_cur.grffile->grf_version >= 8) {
/* Use translated cargo. Might result in CT_INVALID (first refittable), if cargo is not defined. */
ei->cargo_type = GetCargoTranslation(ctype, _cur.grffile);
- } else if (ctype < NUM_CARGO && HasBit(_cargo_mask, ctype)) {
+ } else if (ctype < NUM_CARGO) {
/* Use untranslated cargo. */
ei->cargo_type = ctype;
} else {
@@ -8190,6 +8190,9 @@ static void CalculateRefitMasks()
only_defaultcargo = (ei->refit_mask == 0);
}
+ /* Clear invalid cargoslots (from default vehicles or pre-NewCargo GRFs) */
+ if (!HasBit(_cargo_mask, ei->cargo_type)) ei->cargo_type = CT_INVALID;
+
/* Ensure that the vehicle is either not refittable, or that the default cargo is one of the refittable cargoes.
* Note: Vehicles refittable to no cargo are handle differently to vehicle refittable to a single cargo. The latter might have subtypes. */
if (!only_defaultcargo && (e->type != VEH_SHIP || e->u.ship.old_refittable) && ei->cargo_type != CT_INVALID && !HasBit(ei->refit_mask, ei->cargo_type)) {