changeset 18240:4ecb22f0d875 draft

(svn r23076) -Codechange: Separate code for NewGRF and default refit masks more strictly.
author frosch <frosch@openttd.org>
date Tue, 01 Nov 2011 00:26:22 +0000
parents e6cbcbf3780f
children b9d050ddad0f
files src/newgrf.cpp
diffstat 1 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -7948,12 +7948,13 @@
 	FOR_ALL_ENGINES(e) {
 		EngineID engine = e->index;
 		EngineInfo *ei = &e->info;
-		uint32 mask = 0;
-		uint32 not_mask = 0;
-		uint32 xor_mask = 0;
 
 		/* Did the newgrf specify any refitting? If not, use defaults. */
 		if (_gted[engine].refitmask_valid) {
+			uint32 mask = 0;
+			uint32 not_mask = 0;
+			uint32 xor_mask = 0;
+
 			if (ei->refit_mask != 0) {
 				const GRFFile *file = _gted[engine].refitmask_grf;
 				if (file == NULL) file = e->GetGRF();
@@ -7985,7 +7986,11 @@
 					if (_gted[engine].cargo_disallowed & cs->classes) SetBit(not_mask, cs->Index());
 				}
 			}
+
+			ei->refit_mask = ((mask & ~not_mask) ^ xor_mask) & _cargo_mask;
 		} else {
+			uint32 xor_mask = 0;
+
 			/* Don't apply default refit mask to wagons nor engines with no capacity */
 			if (e->type != VEH_TRAIN || (e->u.rail.capacity != 0 && e->u.rail.railveh_type != RAILVEH_WAGON)) {
 				const CargoLabel *cl = _default_refitmasks[e->type];
@@ -7998,9 +8003,9 @@
 					SetBit(xor_mask, cargo);
 				}
 			}
-		}
-
-		ei->refit_mask = ((mask & ~not_mask) ^ xor_mask) & _cargo_mask;
+
+			ei->refit_mask = xor_mask & _cargo_mask;
+		}
 
 		/* Check if this engine's cargo type is valid. If not, set to the first refittable
 		 * cargo type. Finally disable the vehicle, if there is still no cargo. */