(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.

This commit is contained in:
peter1138 2007-02-24 22:01:18 +00:00
parent b3822a22d9
commit 5dcd88c59c

View File

@ -3741,28 +3741,36 @@ static void InitNewGRFFile(const GRFConfig *config, int sprite_offset)
} }
/** Bitmasked values of what type of cargo is refittable for the given vehicle-type. /** List of what cargo labels are refittable for the given the vehicle-type.
* This coupled with the landscape information (_landscape_global_cargo_mask) gives * Only currently active labels are applied. */
* us exactly what is refittable and what is not */ static const CargoLabel _default_refitmasks_rail[] = {
#define MC(cargo) (1 << cargo) 'PASS', 'COAL', 'MAIL', 'LVST', 'GOOD', 'GRAI', 'WHEA', 'MAIZ', 'WOOD',
static const uint32 _default_refitmasks[NUM_VEHICLE_TYPES] = { 'IORE', 'STEL', 'VALU', 'GOLD', 'DIAM', 'PAPR', 'FOOD', 'FRUT', 'CORE',
/* Trains */ 'WATR', 'SUGR', 'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL',
MC(GC_PASSENGERS) | MC(GC_COAL) | MC(GC_MAIL) | MC(GC_LIVESTOCK) | MC(GC_GOODS) | MC(GC_GRAIN) | MC(GC_WOOD) | MC(GC_IRON_ORE) | 'PLST', 'FZDR',
MC(GC_STEEL) | MC(GC_VALUABLES) | MC(GC_PAPER) | MC(GC_FOOD) | MC(GC_FRUIT) | MC(GC_COPPER_ORE) | MC(GC_WATER) | MC(GC_SUGAR) | 0 };
MC(GC_TOYS) | MC(GC_CANDY) | MC(GC_TOFFEE) | MC(GC_COLA) | MC(GC_COTTON_CANDY) | MC(GC_BUBBLES) | MC(GC_PLASTIC) | MC(GC_FIZZY_DRINKS),
/* Road vehicles (not refittable by default) */ static const CargoLabel _default_refitmasks_road[] = {
0, 0 };
/* Ships */
MC(GC_COAL) | MC(GC_MAIL) | MC(GC_LIVESTOCK) | MC(GC_GOODS) | MC(GC_GRAIN) | MC(GC_WOOD) | MC(GC_IRON_ORE) | MC(GC_STEEL) | MC(GC_VALUABLES) | static const CargoLabel _default_refitmasks_ships[] = {
MC(GC_PAPER) | MC(GC_FOOD) | MC(GC_FRUIT) | MC(GC_COPPER_ORE) | MC(GC_WATER) | MC(GC_RUBBER) | MC(GC_SUGAR) | MC(GC_TOYS) | MC(GC_BATTERIES) | 'COAL', 'MAIL', 'LVST', 'GOOD', 'GRAI', 'WHEA', 'MAIZ', 'WOOD', 'IORE',
MC(GC_CANDY) | MC(GC_TOFFEE) | MC(GC_COLA) | MC(GC_COTTON_CANDY) | MC(GC_BUBBLES) | MC(GC_PLASTIC) | MC(GC_FIZZY_DRINKS), 'STEL', 'VALU', 'GOLD', 'DIAM', 'PAPR', 'FOOD', 'FRUT', 'CORE', 'WATR',
/* Aircraft */ 'RUBR', 'SUGR', 'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL',
MC(GC_PASSENGERS) | MC(GC_MAIL) | MC(GC_GOODS) | MC(GC_VALUABLES) | MC(GC_FOOD) | MC(GC_FRUIT) | MC(GC_SUGAR) | MC(GC_TOYS) | 'PLST', 'FZDR',
MC(GC_BATTERIES) | MC(GC_CANDY) | MC(GC_TOFFEE) | MC(GC_COLA) | MC(GC_COTTON_CANDY) | MC(GC_BUBBLES) | MC(GC_PLASTIC) | MC(GC_FIZZY_DRINKS), 0 };
/* Special/Disaster */
0,0 static const CargoLabel _default_refitmasks_aircraft[] = {
'PASS', 'MAIL', 'GOOD', 'VALU', 'GOLD', 'DIAM', 'FOOD', 'FRUT', 'SUGR',
'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL', 'PLST', 'FZDR',
0 };
static const CargoLabel *_default_refitmasks[] = {
_default_refitmasks_rail,
_default_refitmasks_road,
_default_refitmasks_ships,
_default_refitmasks_aircraft,
}; };
#undef MC
/** /**
@ -3793,7 +3801,15 @@ static void CalculateRefitMasks(void)
RailVehInfo(engine)->railveh_type != RAILVEH_WAGON RailVehInfo(engine)->railveh_type != RAILVEH_WAGON
) )
)) { )) {
xor_mask = _default_refitmasks[GetEngine(engine)->type]; const CargoLabel *cl = _default_refitmasks[GetEngine(engine)->type];
for (uint i = 0;; i++) {
if (cl[i] == 0) break;
CargoID cargo = GetCargoIDByLabel(cl[i]);
if (cargo == CT_INVALID) continue;
SETBIT(xor_mask, GetCargo(cargo)->bitnum);
}
} }
} }
_engine_info[engine].refit_mask = ((mask & ~not_mask) ^ xor_mask) & _cargo_mask; _engine_info[engine].refit_mask = ((mask & ~not_mask) ^ xor_mask) & _cargo_mask;