Mercurial > hg > openttd
changeset 6145:1930fc785078 draft
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
author | peter1138 <peter1138@openttd.org> |
---|---|
date | Sat, 24 Feb 2007 22:01:18 +0000 |
parents | 1a17a9fc035f |
children | 97fbbda2bb08 |
files | src/newgrf.cpp |
diffstat | 1 files changed, 38 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -3741,28 +3741,36 @@ } -/** Bitmasked values of what type of cargo is refittable for the given vehicle-type. - * This coupled with the landscape information (_landscape_global_cargo_mask) gives - * us exactly what is refittable and what is not */ -#define MC(cargo) (1 << cargo) -static const uint32 _default_refitmasks[NUM_VEHICLE_TYPES] = { - /* Trains */ - 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) | - 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) | - 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) */ - 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) | - 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) | - MC(GC_CANDY) | MC(GC_TOFFEE) | MC(GC_COLA) | MC(GC_COTTON_CANDY) | MC(GC_BUBBLES) | MC(GC_PLASTIC) | MC(GC_FIZZY_DRINKS), - /* Aircraft */ - MC(GC_PASSENGERS) | MC(GC_MAIL) | MC(GC_GOODS) | MC(GC_VALUABLES) | MC(GC_FOOD) | MC(GC_FRUIT) | MC(GC_SUGAR) | MC(GC_TOYS) | - 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), - /* Special/Disaster */ - 0,0 +/** List of what cargo labels are refittable for the given the vehicle-type. + * Only currently active labels are applied. */ +static const CargoLabel _default_refitmasks_rail[] = { + 'PASS', 'COAL', 'MAIL', 'LVST', 'GOOD', 'GRAI', 'WHEA', 'MAIZ', 'WOOD', + 'IORE', 'STEL', 'VALU', 'GOLD', 'DIAM', 'PAPR', 'FOOD', 'FRUT', 'CORE', + 'WATR', 'SUGR', 'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL', + 'PLST', 'FZDR', + 0 }; + +static const CargoLabel _default_refitmasks_road[] = { + 0 }; + +static const CargoLabel _default_refitmasks_ships[] = { + 'COAL', 'MAIL', 'LVST', 'GOOD', 'GRAI', 'WHEA', 'MAIZ', 'WOOD', 'IORE', + 'STEL', 'VALU', 'GOLD', 'DIAM', 'PAPR', 'FOOD', 'FRUT', 'CORE', 'WATR', + 'RUBR', 'SUGR', 'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL', + 'PLST', 'FZDR', + 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 @@ 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;