29 #define ERR_PF LOG_STREAM(err, log_engine)
35 const std::string reversed_suffix =
"-__REVERSED__";
54 if (cfg[
"id"].empty()) {
57 id_ = cfg[
"id"].str();
59 id_ += reversed_suffix;
72 um_ = &empty_unit_map;
76 const std::vector<team> &
teams()
const {
return *
tm_; }
82 const std::vector<team> *
tm_;
83 const std::vector<std::string> *
lbls_;
110 ,
const bool ignore_units)
const
125 if (ufilt.matches(u, loc)) {
146 return cfg_[
"always_visible"].to_bool(
false);
151 retval[
"saved"] =
"yes";
152 retval[
"reversed"] =
reversed_ ?
"yes" :
"no";
158 const std::vector<teleport_group>&
groups
160 ,
const team &viewing_team
162 ,
const bool ignore_units)
171 group.get_teleport_pair(locations, u, ignore_units);
175 if(!viewing_team.
fogged(loc))
176 filter_locs.first.insert(loc);
179 if(!viewing_team.
fogged(loc))
180 filter_locs.second.insert(loc);
182 locations.first.swap(filter_locs.first);
183 locations.second.swap(filter_locs.second);
188 for (; source_it != locations.first.end(); ++source_it ) {
190 std::set<std::string> id_set;
191 id_set.insert(teleport_id);
194 (
teleport_map_.find(*source_it)->second).insert(teleport_id);
197 sources_.insert(std::make_pair(teleport_id, locations.first));
198 targets_.insert(std::make_pair(teleport_id, locations.second));
207 const std::set<std::string>& keyset = (
teleport_map_.find(loc)->second);
208 for(std::set<std::string>::const_iterator it = keyset.begin(); it != keyset.end(); ++it) {
210 const std::set<map_location>&
target =
targets_.find(*it)->second;
211 adjacents.insert(target.begin(), target.end());
218 std::map<std::string, std::set<map_location> >::const_iterator it;
220 sources.insert(it->second.begin(), it->second.end());
226 std::map<std::string, std::set<map_location> >::const_iterator it;
228 targets.insert(it->second.begin(), it->second.end());
234 const team &viewing_team,
235 bool see_all,
bool ignore_units)
237 std::vector<teleport_group>
groups;
241 const int tunnel_count = (teleport.first)->child_count(
"tunnel");
242 for(
int i = 0;
i < tunnel_count; ++
i) {
243 config teleport_group_cfg = (teleport.first)->child(
"tunnel",
i);
250 groups.insert(groups.end(), global_groups.begin(), global_groups.end());
252 return teleport_map(groups, u, viewing_team, see_all, ignore_units);
256 const int tunnel_count = cfg.
child_count(
"tunnel");
257 for(
int i = 0;
i < tunnel_count; ++
i) {
259 if(!t[
"saved"].to_bool()) {
260 lg::wml_error() <<
"Do not use [tunnel] directly in a [scenario]. Use it in an [event] or [abilities] tag.\n";
275 if (t->get_teleport_id() ==
id || t->get_teleport_id() ==
id + reversed_suffix) {
290 std::vector<teleport_group>::const_iterator tunnel =
tunnels_.begin();
291 for(; tunnel !=
tunnels_.end(); ++tunnel) {
292 store.
add_child(
"tunnel", tunnel->to_config());
294 store[
"next_teleport_group_id"] = std::to_string(
id_);
300 return std::to_string(++
id_);
std::map< std::string, std::set< map_location > > sources_
std::pair< std::set< map_location >, std::set< map_location > > teleport_pair
const ignore_units_display_context dc_
const map_location & get_location() const
std::string next_unique_id()
void remove(const std::string &id)
bool is_enemy(int n) const
const std::vector< teleport_group > & get() const
config to_config() const
Inherited from savegame_config.
void get_targets(std::set< map_location > &targets) const
const config & child_or_empty(const std::string &key) const
Returns the first child with the given key, or an empty config if there is none.
bool always_visible() const
bool get_ability_bool(const std::string &tag_name, const map_location &loc) const
Returns true if the unit is currently under effect by an ability with this given TAG NAME...
teleport_group(const config &cfg)
This class stores all the data for a single 'side' (in game nomenclature).
const std::vector< std::string > & hidden_label_categories() const
void get_sources(std::set< map_location > &sources) const
filter_context * filter_con
game_lua_kernel * get_lua_kernel() const
ignore_units_filter_context(const filter_context &fc)
const std::vector< team > & teams() const
const display_context & get_disp_context() const
const unit_map & units() const
Encapsulates the map of the game.
const tod_manager & get_tod_man() const
const std::vector< std::string > * lbls_
config & add_child(const std::string &key)
std::map< std::string, std::set< map_location > > targets_
config to_config() const
Inherited from savegame_config.
GLsizei const GLint * locations
const game_data * get_game_data() const
Encapsulates the map of the game.
void get_locations(std::set< map_location > &locs, bool with_border=false) const
std::map< map_location, std::set< std::string > > teleport_map_
std::stringstream & wml_error()
Use this logger to send errors due to deprecated WML.
std::pair< const config *, map_location > unit_ability
The things contained within a unit_ability_list.
const gamemap & map() const
bool fogged(const map_location &loc) const
unit_ability_list get_abilities(const std::string &tag_name, const map_location &loc) const
unsigned child_count(const std::string &key) const
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
const std::string & get_teleport_id() const
void add(const teleport_group &group)
manager(const config &cfg)
bool has_attribute(const std::string &key) const
static lg::log_domain log_engine("engine")
std::vector< teleport_group > tunnels_
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...
A variable-expanding proxy for the config class.
const std::vector< team > * tm_
Standard logging facilities (interface).
Container associating units to locations.
ignore_units_display_context(const display_context &dc)
void get_teleport_pair(teleport_pair &loc_pair, const unit &u, const bool ignore_units) const
const teleport_map get_teleport_locations(const unit &u, const team &viewing_team, bool see_all, bool ignore_units)
A config object defines a single node in a WML file, with access to child nodes.
pathfind::manager * tunnels
GLsizei const GLcharARB ** string
GLsizei GLsizei GLchar * source
void get_adjacents(std::set< map_location > &adjacents, map_location loc) const