16 #define GETTEXT_DOMAIN "wesnoth-lib" 36 #include "formula/callable_objects.hpp" 41 #define ERR_NG LOG_STREAM(err, log_engine_sf) 44 #define ERR_WML LOG_STREAM(err, log_wml) 65 std::vector<int> result;
68 result.push_back(
t.side());
79 std::vector<std::pair<int,int>>::const_iterator range, range_end = ranges.end();
80 for (range = ranges.begin(); range != range_end; ++range) {
81 if(side_number >= range->first && side_number <= range->second) {
109 if (!cfg_team_name.
blank()) {
110 const std::string& that_team_name = cfg_team_name;
111 const std::string& this_team_name = t.
team_name();
113 if(std::find(this_team_name.begin(), this_team_name.end(),
',') == this_team_name.end()) {
114 if(this_team_name != that_team_name)
return false;
117 const std::vector<std::string>& these_team_names =
utils::split(this_team_name);
118 bool search_futile =
true;
119 for(
const std::string& this_single_team_name : these_team_names) {
120 if(this_single_team_name == that_team_name) {
121 search_futile =
false;
125 if(search_futile)
return false;
138 if (u.side() != t.
side()) {
146 if(!found && ufilt_cfg[
"search_recall_list"].to_bool(
false)) {
161 if(!enemy_of.
null()) {
165 if(teams.empty())
return false;
166 for(
const int side : teams) {
173 if(!allied_with.
null()) {
177 if(teams.empty())
return false;
178 for(
const int side : teams) {
185 if(!has_enemy.
null()) {
190 for(
const int side : teams) {
197 if (!found)
return false;
201 if(!has_ally.
null()) {
206 for(
const int side : teams) {
213 if (!found)
return false;
218 if (!cfg_controller.
blank())
221 ERR_NG <<
"ignoring controller= in SSF due to danger of OOS errors";
283 else if(key ==
"or") {
287 else if(key ==
"not") {
play_controller * controller
std::function< int(lua_State *)> lua_function
static lg::log_domain log_engine_sf("engine/side_filter")
std::unique_ptr< side_filter > has_enemy_filter_
const team & get_team(int side) const
virtual const display_context & get_disp_context() const =0
vconfig child(const std::string &key) const
Returns a child of *this whose key is key.
This class represents a single unit of a specific type.
const filter_context * fc_
The filter context for this filter.
bool match_internal(const team &t) const
bool run_filter(char const *name, const unit &u)
Runs a script from a unit filter.
Variant for storing WML attributes.
bool has_attribute(const std::string &key) const
< Synonym for operator[]
std::string save_id_or_number() const
Definitions for the interface to Wesnoth Markup Language (WML).
std::shared_ptr< const unit > unit_const_ptr
This class stores all the data for a single 'side' (in game nomenclature).
const vconfig & make_safe() const
instruct the vconfig to make a private copy of its underlying data.
std::vector< std::pair< int, int > > parse_ranges(const std::string &str)
side_controller::type controller() const
bool blank() const
Tests for an attribute that was never set.
bool is_enemy(int n) const
virtual const unit_map & units() const =0
std::unique_ptr< unit_filter > ufilter_
virtual const std::vector< team > & teams() const =0
bool has_child(const std::string &key) const
Returns whether or not *this has a child whose key is key.
std::unique_ptr< side_filter > has_ally_filter_
bool match(const team &t) const
std::vector< std::string > split(const config_attribute_value &val)
static bool check_side_number(const team &t, const std::string &str)
std::vector< int > get_teams() const
A variable-expanding proxy for the config class.
Standard logging facilities (interface).
std::unique_ptr< side_filter > allied_filter_
virtual game_lua_kernel * get_lua_kernel() const =0
recall_list_manager & recall_list()
bool as_bool() const
Returns a boolean state of the variant value.
static lg::log_domain log_wml("wml")
const std::string & team_name() const
std::size_t find_index(const std::string &unit_id) const
Find the index of a unit by its id.
side_filter(const std::string &side_string, const filter_context *fc, bool flat_tod=false)
std::unique_ptr< side_filter > enemy_filter_
std::stringstream & log_to_chat()
Use this to show WML errors in the ingame chat.
boost::iterator_range< all_children_iterator > all_ordered() const
static std::string get_string(enum_type key)
Converts a enum to its string equivalent.