16 #define GETTEXT_DOMAIN "wesnoth-lib"
34 #include "formula/callable_objects.hpp"
39 #define ERR_NG LOG_STREAM(err, log_engine_sf)
42 #define ERR_WML LOG_STREAM(err, log_wml)
55 : cfg_(
vconfig::empty_vconfig()), flat_(flat_tod), side_string_(side_string), fc_(fc)
63 std::vector<int> result;
66 result.push_back(
t.side());
98 if (!cfg_team_name.
blank()) {
99 const std::string& that_team_name = cfg_team_name;
100 const std::string& this_team_name =
t.team_name();
102 if(std::find(this_team_name.begin(), this_team_name.end(),
',') == this_team_name.end()) {
103 if(this_team_name != that_team_name)
return false;
106 const std::vector<std::string>& these_team_names =
utils::split(this_team_name);
107 bool search_futile =
true;
108 for(
const std::string& this_single_team_name : these_team_names) {
109 if(this_single_team_name == that_team_name) {
110 search_futile =
false;
114 if(search_futile)
return false;
127 if (u.side() !=
t.side()) {
135 if(!found && ufilt_cfg[
"search_recall_list"].to_bool(
false)) {
137 scoped_recall_unit this_unit(
"this_unit",
t.save_id_or_number(),
t.recall_list().find_index(u->id()));
150 if(!enemy_of.
null()) {
154 if(teams.empty())
return false;
155 for(
const int side : teams) {
162 if(!allied_with.
null()) {
166 if(teams.empty())
return false;
167 for(
const int side : teams) {
174 if(!has_enemy.
null()) {
179 for(
const int side : teams) {
186 if (!found)
return false;
190 if(!has_ally.
null()) {
195 for(
const int side : teams) {
202 if (!found)
return false;
207 if (!cfg_controller.
blank())
210 ERR_NG <<
"ignoring controller= in SSF due to danger of OOS errors";
235 lg::log_to_chat() <<
"Formula error in side filter: " <<
e.type <<
" at " <<
e.filename <<
':' <<
e.line <<
")\n";
236 ERR_WML <<
"Formula error in side filter: " <<
e.type <<
" at " <<
e.filename <<
':' <<
e.line <<
")";
272 else if(key ==
"or") {
276 else if(key ==
"not") {
Variant for storing WML attributes.
bool blank() const
Tests for an attribute that was never set.
const team & get_team(int side) const
This getter takes a 1-based side number, not a 0-based team number.
virtual const std::vector< team > & teams() const =0
virtual const unit_map & units() const =0
virtual const display_context & get_disp_context() const =0
virtual game_lua_kernel * get_lua_kernel() const =0
bool run_filter(char const *name, const unit &u)
Runs a script from a unit filter.
std::unique_ptr< side_filter > has_ally_filter_
std::vector< int > get_teams() const
const filter_context * fc_
The filter context for this filter.
bool match(const team &t) const
bool match_internal(const team &t) const
std::unique_ptr< side_filter > allied_filter_
std::unique_ptr< side_filter > has_enemy_filter_
std::unique_ptr< side_filter > enemy_filter_
side_filter(const std::string &side_string, const filter_context *fc, bool flat_tod=false)
std::unique_ptr< unit_filter > ufilter_
This class stores all the data for a single 'side' (in game nomenclature).
bool is_enemy(int n) const
This class represents a single unit of a specific type.
A variable-expanding proxy for the config class.
bool has_attribute(const std::string &key) const
< Synonym for operator[]
vconfig child(const std::string &key) const
Returns a child of *this whose key is key.
const vconfig & make_safe() const
instruct the vconfig to make a private copy of its underlying data.
boost::iterator_range< all_children_iterator > all_ordered() const
bool has_child(const std::string &key) const
Returns whether or not *this has a child whose key is key.
bool as_bool() const
Returns a boolean state of the variant value.
Definitions for the interface to Wesnoth Markup Language (WML).
Standard logging facilities (interface).
bool in_ranges(const Cmp c, const std::vector< std::pair< Cmp, Cmp >> &ranges)
std::stringstream & log_to_chat()
Use this to show WML errors in the ingame chat.
std::function< int(lua_State *)> lua_function
play_controller * controller
std::vector< std::pair< int, int > > parse_ranges_unsigned(const std::string &str)
Handles a comma-separated list of inputs to parse_range, in a context that does not expect negative v...
std::vector< std::string > split(const config_attribute_value &val)
std::shared_ptr< const unit > unit_const_ptr
static lg::log_domain log_engine_sf("engine/side_filter")
static bool check_side_number(const team &t, const std::string &str)
static lg::log_domain log_wml("wml")
static std::string get_string(enum_type key)
Converts a enum to its string equivalent.