25 #define DBG_MP LOG_STREAM(debug, log_mp_connect_engine)
26 #define LOG_MP LOG_STREAM(info, log_mp_connect_engine)
27 #define WRN_MP LOG_STREAM(warn, log_mp_connect_engine)
28 #define ERR_MP LOG_STREAM(err, log_mp_connect_engine)
40 return "~RC(" + unit_color +
">" + color +
49 era_factions_(era_factions),
51 use_map_settings_(use_map_settings),
52 saved_game_(saved_game),
53 has_no_recruits_(get_original_recruits(side_).empty() && side_[
"previous_recruits"].empty()),
54 faction_lock_(side_[
"faction_lock"].to_bool(lock_settings) && use_map_settings),
55 leader_lock_(side_[
"leader_lock"].to_bool(lock_settings) && use_map_settings),
56 available_factions_(),
59 choosable_factions_(),
62 current_faction_(nullptr),
63 current_leader_(
"null"),
64 current_gender_(
"null"),
65 default_leader_type_(side_[
"type"]),
66 default_leader_gender_(side_[
"gender"]),
67 default_leader_cfg_(nullptr)
70 if (!leader_id.empty()) {
82 if (side_unit[
"canrecruit"].to_bool()) {
92 if (unit ==
nullptr) {
121 if ((*faction)[
"id"] ==
id) {
127 ERR_MP <<
"Faction '" <<
id <<
"' is not available for side " <<
side_[
"side"] <<
" Ignoring";
148 std::vector<std::string> leaders;
155 }
else if (leader ==
"random") {
158 }
else if (leader ==
"null") {
161 leaders.push_back(
"?");
175 std::vector<std::string> genders;
183 _(
"Female ♀") :
_(
"Male ♂");
188 }
else if (gender ==
"random") {
191 }
else if (gender ==
"null") {
194 genders.push_back(
"?");
220 std::vector<std::string> faction_choices, faction_excepts;
223 if (faction_choices.size() == 1 && faction_choices.front() ==
"") {
224 faction_choices.clear();
228 if (faction_excepts.size() == 1 && faction_excepts.front() ==
"") {
229 faction_excepts.clear();
234 std::vector<int> nonrandom_sides;
235 std::vector<int> fallback_nonrandom_sides;
239 if (!(*
i)[
"random_faction"].to_bool()) {
242 if (!faction_choices.empty() &&
243 std::find(faction_choices.begin(), faction_choices.end(),
244 faction_id) == faction_choices.end()) {
248 if (!faction_excepts.empty() &&
249 std::find(faction_excepts.begin(), faction_excepts.end(),
250 faction_id) != faction_excepts.end()) {
254 fallback_nonrandom_sides.push_back(num);
256 if (!avoid.empty() &&
258 faction_id) != avoid.end()) {
262 nonrandom_sides.push_back(num);
266 if (nonrandom_sides.empty()) {
267 nonrandom_sides = fallback_nonrandom_sides;
270 if (nonrandom_sides.empty()) {
283 std::vector<std::string> nonrandom_leaders =
285 if (nonrandom_leaders.empty()) {
287 if (leader !=
"random") {
288 nonrandom_leaders.push_back(leader);
293 if (nonrandom_leaders.empty()) {
295 i18n_symbols[
"faction"] = (*current_faction_)[
"name"];
297 "Unable to find a leader type for faction $faction",
312 std::vector<std::string> nonrandom_genders;
314 if (gender !=
"random") {
315 nonrandom_genders.push_back(gender);
325 "Cannot obtain genders for invalid leader $leader",
333 const config* custom_faction =
nullptr;
337 if ((*faction)[
"id"] ==
"Custom" && !show_custom_faction) {
342 custom_faction = faction;
380 if ((*
f)[
"id"] !=
"Random") {
389 std::set<std::string> seen;
395 if (seen.insert(*walker).second) {
396 *modifier++ = *walker;
425 side_unit[
"canrecruit"].to_bool()) {
427 gender = side_unit[
"gender"].str();
431 if (!gender.empty()) {
475 if (faction_index >= 0) {
503 if (default_gender.empty()) {
518 std::vector<std::string>
find;
523 find.push_back(
f->str());
525 }
else if (
side_[
"faction_from_recruit"].to_bool()) {
528 search_field =
"recruit";
532 search_field =
"leader";
534 find.push_back(
"Custom");
538 int res = -1,
index = 0, best_score = 0;
541 int faction_score = 0;
542 std::vector<std::string> recruit =
552 if (faction_score > best_score) {
553 best_score = faction_score;
570 std::vector<std::string> leaders_to_append =
574 leaders_to_append.end());
579 std::vector<const config*>::const_iterator it =
std::find(
588 std::vector<std::string>::const_iterator it =
std::find(
596 std::vector<std::string>::const_iterator it =
std::find(
606 ERR_MP <<
"Leader '" << leader <<
"' is not available for side " <<
side_[
"side"] <<
" Ignoring";
617 ERR_MP <<
"Gender '" << gender <<
"' is not available for side " <<
side_[
"side"] <<
" Ignoring";
const config * default_leader_cfg_
child_itors child_range(const std::string &key)
std::string default_leader_type_
static const std::string s_male
Standard string id (not translatable) for MALE.
static const config & get_default_faction(const config &cfg)
const unit_type & get_gender_unit_type(std::string gender) const
const t_string & type_name() const
The name of the unit in the current language setting.
static l_noret error(LoadState *S, const char *why)
uint32_t get_next_random()
Get a new random number.
static lg::log_domain log_mp_connect_engine("mp/connect/engine")
unit_type_data unit_types
void set_current_leader(const unsigned index)
const std::string & image() const
int faction_index(const config &faction) const
void update_available_factions()
void set_current_gender(const unsigned index)
int leader_index(const std::string &leader) const
returns -1 if no leader with that name was found
Definitions for the interface to Wesnoth Markup Language (WML).
Variant for storing WML attributes.
std::string default_leader_gender_
static const std::string s_female
Standard string id (not translatable) for FEMALE.
static UNUSEDNOWARN std::string _(const char *str)
const std::string & flag_rgb() const
std::map< std::string, t_string > string_map
void reset_leader_combo(gui::combo &combo_leader, const std::string &color) const
int current_gender_index() const
flg_manager(const std::vector< const config * > &era_factions, const config &side, const bool faction_lock, const bool leader_lock, const bool saved_game)
void append_leaders_from_faction(const config *faction)
std::vector< const config * > available_factions_
std::vector< const config * > choosable_factions_
const std::vector< unit_race::GENDER > & genders() const
The returned vector will not be empty, provided this has been built to the HELP_INDEXED status...
int gender_index(const std::string &gender) const
returns -1 if no gender with that name was found
const std::string unicode_em_dash
const bool has_no_recruits_
void reset_gender_combo(gui::combo &combo_gender, const std::string &color) const
std::string current_leader_
std::string get_RC_suffix(const std::string &unit_color, const std::string &color)
int current_faction_index() const
int find_suitable_faction() const
void set_current_faction(const unsigned index)
std::string current_gender_
std::vector< std::string > choosable_genders_
void set_selected(int val)
static std::vector< std::string > get_original_recruits(const config &cfg)
void set_items(const std::vector< std::string > &items)
GLdouble GLdouble GLdouble r
const std::vector< const config * > & era_factions_
const std::string random_enemy_picture("units/random-dice.png")
const attribute_value * get(const std::string &key) const
Returns a pointer to the attribute with the given key or nullptr if it does not exist.
char const COLUMN_SEPARATOR
bool find(E event, F functor)
Tests whether an event handler is available.
void update_available_genders()
void update_choosable_genders()
config & child(const std::string &key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
config & find_child(const std::string &key, const std::string &name, const std::string &value)
Returns the first child of tag key with a name attribute containing value.
Standard logging facilities (interface).
void update_choosable_leaders()
const unit_type * find(const std::string &key, unit_type::BUILD_STATUS status=unit_type::FULL) const
Finds a unit_type by its id() and makes sure it is built to the specified level.
std::vector< std::string > available_genders_
int current_leader_index() const
std::vector< std::string > split(std::string const &val, const char c, const int flags)
Splits a (comma-)separated string into a vector of pieces.
void update_available_leaders()
void resolve_random(rand_rng::mt_rng &rng, const std::vector< std::string > &avoid)
A config object defines a single node in a WML file, with access to child nodes.
GLsizei const GLcharARB ** string
std::vector< std::string > available_leaders_
void update_choosable_factions()
std::vector< std::string > choosable_leaders_
const config * current_faction_