# HG changeset patch # User frosch # Date 2010-09-25 21:59:22 # Node ID e91bfb8299b5e19bea2cfa9ddea9677331818a0b # Parent c68b24872c591345a59db5d37372dcb25a6fbd49 (svn r20848) -Add: _loaded_newgrf_features.used_liveries to keep track which liveries are used by some vehicle resp. which are not used at all. diff --git a/src/newgrf.cpp b/src/newgrf.cpp --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -46,6 +46,7 @@ #include "smallmap_gui.h" #include "genworld.h" #include "gui.h" +#include "vehicle_func.h" #include "table/strings.h" #include "table/build_industry.h" @@ -7062,6 +7063,7 @@ void ResetNewGRFData() _misc_grf_features = 0; _loaded_newgrf_features.has_2CC = false; + _loaded_newgrf_features.used_liveries = 1 << LS_DEFAULT; _loaded_newgrf_features.has_newhouses = false; _loaded_newgrf_features.has_newindustries = false; _loaded_newgrf_features.shore = SHORE_REPLACE_NONE; @@ -7261,6 +7263,33 @@ static void FinaliseEngineArray() e->info.string_id = STR_NEWGRF_INVALID_ENGINE; } } + + /* Skip wagons, there livery is defined via the engine */ + if (e->type != VEH_TRAIN || e->u.rail.railveh_type != RAILVEH_WAGON) { + LiveryScheme ls = GetEngineLiveryScheme(e->index, INVALID_ENGINE, NULL); + SetBit(_loaded_newgrf_features.used_liveries, ls); + /* Note: For ships and roadvehicles we assume that they cannot be refitted between passenger and freight */ + + if (e->type == VEH_TRAIN) { + SetBit(_loaded_newgrf_features.used_liveries, LS_FREIGHT_WAGON); + switch (ls) { + case LS_STEAM: + case LS_DIESEL: + case LS_ELECTRIC: + case LS_MONORAIL: + case LS_MAGLEV: + SetBit(_loaded_newgrf_features.used_liveries, LS_PASSENGER_WAGON_STEAM + ls - LS_STEAM); + break; + + case LS_DMU: + case LS_EMU: + SetBit(_loaded_newgrf_features.used_liveries, LS_PASSENGER_WAGON_DIESEL + ls - LS_DMU); + break; + + default: NOT_REACHED(); + } + } + } } } diff --git a/src/newgrf.h b/src/newgrf.h --- a/src/newgrf.h +++ b/src/newgrf.h @@ -148,6 +148,7 @@ enum ShoreReplacement { struct GRFLoadedFeatures { bool has_2CC; ///< Set if any vehicle is loaded which uses 2cc (two company colours). + uint64 used_liveries; ///< Bitmask of #LiveryScheme used by the defined engines. bool has_newhouses; ///< Set if there are any newhouses loaded. bool has_newindustries; ///< Set if there are any newindustries loaded. ShoreReplacement shore; ///< It which way shore sprites were replaced.