31 #define ERR_PF LOG_STREAM(err, log_engine) 
   34 #define ERR_WML LOG_STREAM(err, log_wml) 
   40     const std::string reversed_suffix = 
"-__REVERSED__";
 
   59     if (
cfg[
"id"].empty()) {
 
   64             id_ += reversed_suffix;
 
   77         um_ = &empty_unit_map;
 
   81     const std::vector<team> & 
teams()
 const override { 
return *
tm_; }
 
   83     std::vector<std::string>& 
hidden_label_categories()
 override { 
throw "Writable hidden label categories not supported in this context"; }
 
   88     const std::vector<team> * 
tm_;
 
   89     const std::vector<std::string> * 
lbls_;
 
  116         , 
const bool ignore_units)
 const 
  121     utils::optional<ignore_units_filter_context> ignore_context;
 
  124         fc = &ignore_context.value();
 
  132         terrain_filter source_filter(source, fc, 
false);
 
  133         source_filter.get_locations(
reversed_ ? loc_pair.second : loc_pair.first, u);
 
  135         terrain_filter target_filter(target, fc, 
false);
 
  136         target_filter.get_locations(
reversed_ ? loc_pair.first : loc_pair.second, u);
 
  145     return cfg_[
"always_visible"].to_bool(
false);
 
  149     return cfg_[
"pass_allied_units"].to_bool(
true);
 
  153     return cfg_[
"allow_vision"].to_bool(
true);
 
  165           const std::vector<teleport_group>& groups
 
  167         , 
const team &viewing_team
 
  169         , 
const bool ignore_units
 
  170         , 
const bool check_vision)
 
  180         if (check_vision && !group.allow_vision()) {
 
  184         group.get_teleport_pair(locations, 
unit, ignore_units);
 
  185         if (!see_all && !group.always_visible() && viewing_team.
is_enemy(
unit.
side())) {
 
  189                     filter_locs.first.insert(
loc);
 
  193                     filter_locs.second.insert(
loc);
 
  195             locations.first.swap(filter_locs.first);
 
  196             locations.second.swap(filter_locs.second);
 
  199         if (!group.pass_allied_units() && !ignore_units && !check_vision) {
 
  201             while(
loc != locations.second.end()) {
 
  209                     loc = locations.second.erase(
loc);
 
  217         for (; source_it != locations.first.end(); ++source_it ) {
 
  221                 teleport_map_.emplace(*source_it, std::unordered_set(locations.second.begin(), locations.second.end()));
 
  223                 map_it->second.insert(locations.second.begin(), locations.second.end());
 
  226         sources_.insert(locations.first.begin(), locations.first.end());
 
  227         targets_.insert(locations.second.begin(), locations.second.end());
 
  252     const team &viewing_team,
 
  253     bool see_all, 
bool ignore_units, 
bool check_vision)
 
  255     std::vector<teleport_group> groups;
 
  258         const int tunnel_count = (teleport.ability_cfg)->child_count(
"tunnel");
 
  259         for(
int i = 0; 
i < tunnel_count; ++
i) {
 
  260             config teleport_group_cfg = (teleport.ability_cfg)->mandatory_child(
"tunnel", 
i);
 
  261             groups.emplace_back(
vconfig(teleport_group_cfg, 
true), 
false);
 
  266     groups.insert(groups.end(), global_groups.begin(), global_groups.end());
 
  268     return teleport_map(groups, u, viewing_team, see_all, ignore_units, check_vision);
 
  273     for(
int i = 0; 
i < tunnel_count; ++
i) {
 
  275         if(!
t[
"saved"].to_bool()) {
 
  276             lg::log_to_chat() << 
"Do not use [tunnel] directly in a [scenario]. Use it in an [event] or [abilities] tag.\n";
 
  277             ERR_WML << 
"Do not use [tunnel] directly in a [scenario]. Use it in an [event] or [abilities] tag.";
 
  292         if (
t->get_teleport_id() == 
id || 
t->get_teleport_id() == 
id + reversed_suffix) {
 
  307     std::vector<teleport_group>::const_iterator tunnel = 
tunnels_.begin();
 
  308     for(; tunnel != 
tunnels_.end(); ++tunnel) {
 
  309         store.
add_child(
"tunnel", tunnel->to_config());
 
  311     store[
"next_teleport_group_id"] = std::to_string(
id_);
 
  317     return std::to_string(++
id_);
 
A config object defines a single node in a WML file, with access to child nodes.
 
config & add_child(std::string_view key)
 
bool has_attribute(std::string_view key) const
 
std::size_t child_count(std::string_view key) const
 
const config & child_or_empty(std::string_view key) const
Returns the first child with the given key, or an empty config if there is none.
 
config & mandatory_child(std::string_view key, int n=0)
Returns the nth child with the given key, or throws an error if there is none.
 
Abstract class for exposing game data that doesn't depend on the GUI, however which for historical re...
 
unit_map::iterator find_visible_unit(const map_location &loc, const team ¤t_team, bool see_all=false)
 
virtual const unit_map & units() const override
 
Encapsulates the map of the game.
 
std::vector< std::string > & hidden_label_categories() override
 
const std::vector< team > * tm_
 
const std::vector< std::string > * lbls_
 
const gamemap & map() const override
 
const unit_map & units() const override
 
const std::vector< team > & teams() const override
 
ignore_units_display_context(const display_context &dc)
 
const std::vector< std::string > & hidden_label_categories() const override
 
const tod_manager & get_tod_man() const override
 
const display_context & get_disp_context() const override
 
const ignore_units_display_context dc_
 
game_lua_kernel * get_lua_kernel() const override
 
const game_data * get_game_data() const override
 
ignore_units_filter_context(const filter_context &fc)
 
config to_config() const
Inherited from savegame_config.
 
void add(const teleport_group &group)
 
std::vector< teleport_group > tunnels_
 
void remove(const std::string &id)
 
const std::vector< teleport_group > & get() const
 
manager(const config &cfg)
 
std::string next_unique_id()
 
config to_config() const
Inherited from savegame_config.
 
bool always_visible() const
 
const std::string & get_teleport_id() const
 
teleport_group(const config &cfg)
 
bool pass_allied_units() const
 
void get_teleport_pair(teleport_pair &loc_pair, const unit &u, const bool ignore_units) const
 
bool allow_vision() const
 
const std::unordered_set< map_location > & get_sources() const
Returns the locations that are an entrance of the tunnel.
 
std::unordered_set< map_location > targets_
 
std::unordered_map< map_location, std::unordered_set< map_location > > teleport_map_
 
std::unordered_set< map_location > sources_
 
const std::unordered_set< map_location > & get_targets() const
Returns the locations that are an exit of the tunnel.
 
std::unordered_set< map_location > empty_set_
 
const std::unordered_set< map_location > & get_adjacents(map_location loc) const
 
This class stores all the data for a single 'side' (in game nomenclature).
 
bool is_enemy(int n) const
 
bool fogged(const map_location &loc) const
 
bool matches(const unit &u, const map_location &loc) const
Determine if *this matches filter at a specified location.
 
Container associating units to locations.
 
unit_iterator find(std::size_t id)
 
This class represents a single unit of a specific type.
 
A variable-expanding proxy for the config class.
 
unit_ability_list get_abilities(const std::string &tag_name, const map_location &loc) const
Gets the unit's active abilities of a particular type if it were on a specified location.
 
int side() const
The side this unit belongs to.
 
Standard logging facilities (interface).
 
retval
Default window/dialog return values.
 
std::stringstream & log_to_chat()
Use this to show WML errors in the ingame chat.
 
std::pair< std::set< map_location >, std::set< map_location > > teleport_pair
 
const teleport_map get_teleport_locations(const unit &u, const team &viewing_team, bool see_all, bool ignore_units, bool check_vision)
 
pathfind::manager * tunnels
 
filter_context * filter_con
 
std::string::const_iterator iterator
 
Encapsulates the map of the game.
 
Data typedef for unit_ability_list.
 
static lg::log_domain log_engine("engine")
 
static lg::log_domain log_wml("wml")
 
std::string missing_mandatory_wml_key(const std::string §ion, const std::string &key, const std::string &primary_key, const std::string &primary_value)
Returns a standard message for a missing wml key (attribute).
 
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...
 
#define VALIDATE(cond, message)
The macro to use for the validation of WML.