Moved faction sorting from the FLG manager to the connect engine

This list in the connect engine was passed to each of its side engine's flg managers,
where it was then sorted by update_choosable_factions(). Basically, a whole bunch of
unnecessary sorting. This makes it so the list is already sorted when it's passed to
each side engine.

None of the post-processing of the faction list (in populating available_leaders_)
should mess with the order, as far as I can tell.
This commit is contained in:
Charles Dang 2018-05-27 03:00:25 +11:00
parent 67d2ee7db0
commit 5395fcd106
2 changed files with 19 additions and 19 deletions

View file

@ -180,6 +180,25 @@ connect_engine::connect_engine(saved_game& state, const bool first_scenario, mp_
era_factions_.push_back(&era);
}
// Sort alphabetically, but with the random faction options always first.
// Since some eras have multiple random options we can't just assume there is
// only one random faction on top of the list.
std::sort(era_factions_.begin(), era_factions_.end(), [](const config* c1, const config* c2) {
const config& lhs = *c1;
const config& rhs = *c2;
// Random factions always first.
if(lhs["random_faction"].to_bool() && !rhs["random_faction"].to_bool()) {
return true;
}
if(!lhs["random_faction"].to_bool() && rhs["random_faction"].to_bool()) {
return false;
}
return translation::compare(lhs["name"].str(), rhs["name"].str()) < 0;
});
game_config::add_color_info(scenario());
// Create side engines.

View file

@ -381,25 +381,6 @@ void flg_manager::update_choosable_factions()
choosable_factions_.push_back(faction);
}
}
// Sort alphabetically, but with the random faction options always first.
// Since some eras have multiple random options we can't just assume there is
// only one random faction on top of the list.
std::sort(choosable_factions_.begin(), choosable_factions_.end(), [](const config* c1, const config* c2) {
const config& lhs = *c1;
const config& rhs = *c2;
// Random factions always first.
if(lhs["random_faction"].to_bool() && !rhs["random_faction"].to_bool()) {
return true;
}
if(!lhs["random_faction"].to_bool() && rhs["random_faction"].to_bool()) {
return false;
}
return translation::compare(lhs["name"].str(), rhs["name"].str()) < 0;
});
}
void flg_manager::update_choosable_leaders()