33 #define ERR_NG_TC LOG_STREAM(err, log_engine_tc)
34 #define WRN_NG_TC LOG_STREAM(warn, log_engine_tc)
35 #define LOG_NG_TC LOG_STREAM(info, log_engine_tc)
36 #define DBG_NG_TC LOG_STREAM(debug, log_engine_tc)
110 LOG_NG_TC <<
"team "<<side_<<
" construction: "<< s << std::endl;
116 side_ = side_cfg_[
"side"].to_int(1);
118 throw config::error(
"Side number 0 encountered. Side numbers start at 1");
119 if (
unsigned(side_ - 1) >= teams_.size()) {
120 std::stringstream ss;
121 ss <<
"Side number " << side_ <<
" higher than number of sides (" << teams_.size() <<
")";
124 if (teams_[side_ - 1].side() != 0) {
125 std::stringstream ss;
126 ss <<
"Duplicate definition of side " <<
side_;
129 t_ = &teams_[side_ - 1];
134 player_exists_ =
false;
140 DBG_NG_TC <<
"snapshot: "<< (player_exists_ ?
"true" :
"false") <<std::endl;
142 unit_configs_.clear();
152 gold_info_ngold_ = side_cfg_[
"gold"];
154 DBG_NG_TC <<
"set gold to '" << gold_info_ngold_ <<
"'\n";
181 if (!side_cfg_)
return;
184 DBG_NG_TC <<
"adding previous recruit: " << rec <<
'\n';
196 <<
"unit from "<<origin
197 <<
": type=["<<u[
"type"]
199 <<
"] placement=["<<u[
"placement"]
204 if (u[
"type"].empty()) {
205 WRN_NG_TC <<
"warning: when building level, skipping a unit (id=[" << u[
"id"] <<
"]) from " << origin
206 <<
" with no type information,\n"
207 <<
"for side:\n" << side_cfg_.
debug() << std::endl;
214 if ( seen_ids_.find(
id)!=seen_ids_.end() ) {
217 u_tmp[
"side"] = std::to_string(side_);
221 unit_configs_.push_back(&u);
222 seen_ids_.insert(
id);
226 unit_configs_.push_back(&u);
233 leader_configs_.push_back(leader);
234 config & stored = leader_configs_.back();
243 if (a1.
blank()) a1 =
true;
245 if (a2.
blank()) a2 =
"map,leader";
260 if (side_cfg_.
has_attribute(
"type") && side_cfg_[
"type"] !=
"null" ) {
296 for (
const config *u : unit_configs_) {
304 std::vector<team>&
teams,
312 tb_ptr->build_team_stage_one();
317 tb_ptr->build_team_stage_two();
child_itors child_range(const std::string &key)
unit_creator & allow_rename_side(bool b)
void remove_attribute(const std::string &key)
std::deque< config > leader_configs_
void build_team_stage_two(team_builder_ptr tb_ptr)
void set_objectives(const t_string &new_objectives, bool silently=false)
unit_creator & allow_invalidate(bool b)
unit_creator & allow_show(bool b)
static l_noret error(LoadState *S, const char *why)
void log_step(const char *s) const
Error used when game loading fails.
const t_string & objectives() const
unit_creator & allow_discover(bool b)
void build_team_stage_two()
void build(const config &cfg, const gamemap &map, int gold=default_team_gold_)
std::vector< team > & teams_
std::string debug() const
void add_recruit(const std::string &)
std::vector< const config * > unit_configs_
Definitions for the interface to Wesnoth Markup Language (WML).
unit_creator & allow_add_to_recall(bool b)
Variant for storing WML attributes.
bool blank() const
Tests for an attribute that was never set.
static const boost::container::flat_set< std::string > attributes
Stores the attributes recognized by [side].
static std::vector< team > *& teams
This class stores all the data for a single 'side' (in game nomenclature).
map_location starting_position(int side) const
static lg::log_domain log_engine_tc("engine/team_construction")
bool empty() const
Tell if the map is of 0 size.
void handle_leader(const config &leader)
void build_team_stage_one()
Various functions related to the creation of units (recruits, recalls, and placed units)...
boost::shared_ptr< team_builder > team_builder_ptr
unit_creator & allow_get_village(bool b)
void handle_unit(const config &u, const char *origin)
void build_team_stage_one(team_builder_ptr tb_ptr)
team_builder_ptr create_team_builder(const config &side_cfg, std::vector< team > &teams, const config &level, game_board &board)
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.
virtual const gamemap & map() const
std::set< std::string > seen_ids_
void add_unit(const config &cfg, const vconfig *vcfg=nullptr)
adds a unit on map without firing any events (so, usable during team construction in gamestatus) ...
boost::intrusive_ptr< unit > unit_ptr
bool has_attribute(const std::string &key) const
Standard logging facilities (interface).
recall_list_manager & recall_list()
void add(const unit_ptr &ptr)
Add a unit to the list.
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.
A config object defines a single node in a WML file, with access to child nodes.
GLsizei const GLcharARB ** string
team_builder(const config &side_cfg, std::vector< team > &teams, const config &level, game_board &board)