(svn r9094) -Codechange: Don't set up refit masks for engine types not in the current climate, and exclude engine types if their cargo type is invalid and they have no refittable type.
authorpeter1138
Sat, 10 Mar 2007 10:08:38 +0000
changeset 6608 80bc656cc6fb
parent 6607 b4f6595855c4
child 6609 7c466c7c850a
(svn r9094) -Codechange: Don't set up refit masks for engine types not in the current climate, and exclude engine types if their cargo type is invalid and they have no refittable type.
src/newgrf.cpp
--- a/src/newgrf.cpp	Sat Mar 10 09:55:11 2007 +0000
+++ b/src/newgrf.cpp	Sat Mar 10 10:08:38 2007 +0000
@@ -3752,6 +3752,9 @@
 static void CalculateRefitMasks()
 {
 	for (EngineID engine = 0; engine < TOTAL_NUM_ENGINES; engine++) {
+		/* Skip engine if not available in this climate */
+		if (!HASBIT(_engine_info[engine].climates, _opt.landscape)) continue;
+
 		uint32 mask = 0;
 		uint32 not_mask = 0;
 		uint32 xor_mask = _engine_info[engine].refit_mask;
@@ -3792,16 +3795,19 @@
 			case VEH_TRAIN: {
 				RailVehicleInfo *rvi = &_rail_vehicle_info[engine];
 				if (rvi->cargo_type == CT_INVALID) rvi->cargo_type = FindFirstRefittableCargo(engine);
+				if (rvi->cargo_type == CT_INVALID) _engine_info[engine].climates = 0;
 				break;
 			}
 			case VEH_ROAD: {
 				RoadVehicleInfo *rvi = &_road_vehicle_info[engine - ROAD_ENGINES_INDEX];
 				if (rvi->cargo_type == CT_INVALID) rvi->cargo_type = FindFirstRefittableCargo(engine);
+				if (rvi->cargo_type == CT_INVALID) _engine_info[engine].climates = 0;
 				break;
 			}
 			case VEH_SHIP: {
 				ShipVehicleInfo *svi = &_ship_vehicle_info[engine - SHIP_ENGINES_INDEX];
 				if (svi->cargo_type == CT_INVALID) svi->cargo_type = FindFirstRefittableCargo(engine);
+				if (svi->cargo_type == CT_INVALID) _engine_info[engine].climates = 0;
 				break;
 			}
 		}