summaryrefslogtreecommitdiff
path: root/src/newgrf_cargo.cpp
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-07-28 06:16:34 +0000
committerpeter1138 <peter1138@openttd.org>2008-07-28 06:16:34 +0000
commit81dafb5e6921744e373162b8c52328dfdc59bc07 (patch)
tree1d27765d4d5a74f4c05bff85bbfbcaeb190f2648 /src/newgrf_cargo.cpp
parent78730d4c71c08909d4c8f6f7de84d0148906040b (diff)
downloadopenttd-81dafb5e6921744e373162b8c52328dfdc59bc07.tar.xz
(svn r13855) -Fix [FS#2157]: Cargo type lookup was incorrect for GRFv7 files without a translation table.
Diffstat (limited to 'src/newgrf_cargo.cpp')
-rw-r--r--src/newgrf_cargo.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/newgrf_cargo.cpp b/src/newgrf_cargo.cpp
index 790c0b3e8..1ff8de73f 100644
--- a/src/newgrf_cargo.cpp
+++ b/src/newgrf_cargo.cpp
@@ -109,9 +109,15 @@ CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile, bool usebit)
/* Else the cargo value is a 'climate independent' 'bitnum' */
if (HasBit(_cargo_mask, cargo)) return GetCargoIDByBitnum(cargo);
} else {
- /* If the GRF contains a translation table (and the cargo is in bounds)
- * then get the cargo ID for the label */
- if (cargo < grffile->cargo_max) return GetCargoIDByLabel(grffile->cargo_list[cargo]);
+ /* If the GRF contains a translation table... */
+ if (grffile->cargo_max > 0) {
+ /* ...and the cargo is in bounds, then get the cargo ID for
+ * the label */
+ if (cargo < grffile->cargo_max) return GetCargoIDByLabel(grffile->cargo_list[cargo]);
+ } else {
+ /* Else the cargo value is a 'climate independent' 'bitnum' */
+ if (HasBit(_cargo_mask, cargo)) return GetCargoIDByBitnum(cargo);
+ }
}
return CT_INVALID;
}