Skip to content

Commit

Permalink
(svn r24438) -Fix [FS#5256-ish]: Make (non-refittable) vehicles with …
Browse files Browse the repository at this point in the history
…invalid default cargo unavailable.
  • Loading branch information
frosch123 committed Jul 27, 2012
1 parent 4d53128 commit 13bfb09
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/newgrf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 13bfb09

Please sign in to comment.