summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2007-03-10 16:21:29 +0000
committerpeter1138 <peter1138@openttd.org>2007-03-10 16:21:29 +0000
commit53452ef9a78af5c4b0cdc63cef0e156b83d21abc (patch)
treecfb68fbfc8e827e993ae558ee5f1889b9ddfa7c9 /src
parentde5beec61cd10f1236968f7bec33e2b750037e02 (diff)
downloadopenttd-53452ef9a78af5c4b0cdc63cef0e156b83d21abc.tar.xz
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
Diffstat (limited to 'src')
-rw-r--r--src/newgrf.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 7b0e7ba4f..9edf93195 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -3757,7 +3757,31 @@ static void CalculateRefitMasks()
uint32 mask = 0;
uint32 not_mask = 0;
- uint32 xor_mask = _engine_info[engine].refit_mask;
+ uint32 xor_mask = 0;
+
+ if (_engine_info[engine].refit_mask != 0) {
+ const GRFFile *file = GetEngineGRF(engine);
+ if (file != NULL && file->cargo_max != 0) {
+ /* Apply cargo translation table to the refit mask */
+ uint num_cargo = min(32, file->cargo_max);
+ for (uint i = 0; i < num_cargo; i++) {
+ if (!HASBIT(_engine_info[engine].refit_mask, i)) continue;
+
+ CargoID c = GetCargoIDByLabel(file->cargo_list[i]);
+ if (c == CT_INVALID) continue;
+
+ SETBIT(xor_mask, c);
+ }
+ } else {
+ /* No cargo table, so use the cargo bitnum values */
+ for (CargoID c = 0; c < NUM_CARGO; c++) {
+ const CargoSpec *cs = GetCargo(c);
+ if (!cs->IsValid()) continue;
+
+ if (HASBIT(_engine_info[engine].refit_mask, cs->bitnum)) SETBIT(xor_mask, c);
+ }
+ }
+ }
if (cargo_allowed[engine] != 0) {
// Build up the list of cargo types from the set cargo classes.