Initialize maps in a MSVC 2010-compatible way

develop
lethosor 2016-04-22 18:45:32 -04:00
parent 52728babd4
commit 8784a133e8
1 changed files with 49 additions and 49 deletions

@ -1317,48 +1317,47 @@ df::building* getAssignableBuildingAtCursor(color_ostream& out)
// ZONE FILTERS (as in, filters used by 'zone')
// Maps parameter names to filters.
unordered_map<string, function<bool(df::unit*)>> zone_filters = {
{ "caged", isContainedInItem },
{ "egglayer", isEggLayer },
{ "female", isFemale },
{ "grazer", isGrazer },
{ "hunting", isHunter },
{ "male", isMale },
{ "milkable", isMilkable },
{ "naked", isNaked },
{ "own", isOwnCiv },
{ "tamable", isTamable },
{ "tame", isTame },
{ "trainablewar", [](df::unit *unit) -> bool
{
return !isWar(unit) && !isHunter(unit) && isTrainableWar(unit);
}
},
{ "trainablehunt", [](df::unit *unit) -> bool
{
return !isWar(unit) && !isHunter(unit) && isTrainableHunting(unit);
}
},
{ "trained", isTrained },
unordered_map<string, function<bool(df::unit*)>> zone_filters;
static struct zone_filters_init { zone_filters_init() {
zone_filters["caged"] = isContainedInItem;
zone_filters["egglayer"] = isEggLayer;
zone_filters["female"] = isFemale;
zone_filters["grazer"] = isGrazer;
zone_filters["hunting"] = isHunter;
zone_filters["male"] = isMale;
zone_filters["milkable"] = isMilkable;
zone_filters["naked"] = isNaked;
zone_filters["own"] = isOwnCiv;
zone_filters["tamable"] = isTamable;
zone_filters["tame"] = isTame;
zone_filters["trainablewar"] = [](df::unit *unit) -> bool
{
return !isWar(unit) && !isHunter(unit) && isTrainableWar(unit);
};
zone_filters["trainablehunt"] = [](df::unit *unit) -> bool
{
return !isWar(unit) && !isHunter(unit) && isTrainableHunting(unit);
};
zone_filters["trained"] = isTrained;
// backwards compatibility
{ "unassigned", [](df::unit *unit) -> bool
{
return !isAssigned(unit);
}
},
{ "war", isWar },
};
zone_filters["unassigned"] = [](df::unit *unit) -> bool
{
return !isAssigned(unit);
};
zone_filters["war"] = isWar;
}} zone_filters_init_;
// Extra annotations / descriptions for parameter names.
unordered_map<string, string> zone_filter_notes = {
{ "caged", "caged (ignores built cages)" },
{ "hunting", "trained hunting creature" },
{ "named", "has name or nickname" },
{ "own", "own civilization" },
{ "trainablehunt", "trainable for hunting" },
{ "trainablewar", "trainable for war" },
{ "war", "trained war creature" },
};
unordered_map<string, string> zone_filter_notes;
static struct zone_filter_notes_init { zone_filter_notes_init() {
zone_filter_notes["caged"] = "caged (ignores built cages)";
zone_filter_notes["hunting"] = "trained hunting creature";
zone_filter_notes["named"] = "has name or nickname";
zone_filter_notes["own"] = "own civilization";
zone_filter_notes["trainablehunt"] = "trainable for hunting";
zone_filter_notes["trainablewar"] = "trainable for war";
zone_filter_notes["war"] = "trained war creature";
}} zone_filter_notes_init_;
pair<string, function<bool(df::unit*)>> createRaceFilter(vector<string> &filter_args)
{
@ -1463,12 +1462,13 @@ pair<string, function<bool(df::unit*)>> createMaxAgeFilter(vector<string> &filte
// Result filter functions are not permitted to throw std::exceptions.
// Result filter functions should not store references
unordered_map<string, pair<int,
function<pair<string, function<bool(df::unit*)>>(vector<string>&)>>> zone_param_filters = {
{ "race", { 1, createRaceFilter } },
{ "age", { 1, createAgeFilter } },
{ "minage", { 1, createMinAgeFilter } },
{ "maxage", { 1, createMaxAgeFilter } },
};
function<pair<string, function<bool(df::unit*)>>(vector<string>&)>>> zone_param_filters;
static struct zone_param_filters_init { zone_param_filters_init() {
zone_param_filters["race"] = { 1, createRaceFilter };
zone_param_filters["age"] = { 1, createAgeFilter };
zone_param_filters["minage"] = { 1, createMinAgeFilter };
zone_param_filters["maxage"] = { 1, createMaxAgeFilter };
}} zone_param_filters_init_;
command_result df_zone (color_ostream &out, vector <string> & parameters)
{