terrain_filter uses filter_context instead of resources
This commit is contained in:
parent
35b23ec321
commit
18159f0a6b
14 changed files with 64 additions and 60 deletions
|
@ -24,6 +24,7 @@
|
|||
#include "ai/lua/core.hpp"
|
||||
#include "ai/lua/lua_object.hpp"
|
||||
#include "ai/manager.hpp"
|
||||
#include "filter_context.hpp"
|
||||
#include "game_board.hpp"
|
||||
#include "log.hpp"
|
||||
#include "map_location.hpp"
|
||||
|
@ -165,7 +166,7 @@ void target_location_goal::on_create()
|
|||
}
|
||||
const config &criteria = cfg_.child("criteria");
|
||||
if (criteria) {
|
||||
filter_ptr_ = boost::shared_ptr<terrain_filter>(new terrain_filter(vconfig(criteria),*resources::units));
|
||||
filter_ptr_ = boost::shared_ptr<terrain_filter>(new terrain_filter(vconfig(criteria),resources::filter_con));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,7 +222,7 @@ void protect_goal::on_create()
|
|||
}
|
||||
const config &criteria = cfg_.child("criteria");
|
||||
if (criteria) {
|
||||
filter_ptr_ = boost::shared_ptr<terrain_filter>(new terrain_filter(vconfig(criteria),*resources::units));
|
||||
filter_ptr_ = boost::shared_ptr<terrain_filter>(new terrain_filter(vconfig(criteria),resources::filter_con));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -179,10 +179,10 @@ public:
|
|||
static terrain_filter cfg_to_value(const config &cfg)
|
||||
{
|
||||
if (const config &v = cfg.child("value")) {
|
||||
return terrain_filter(vconfig(v), *resources::units);
|
||||
return terrain_filter(vconfig(v), resources::filter_con);
|
||||
}
|
||||
static config c("not");
|
||||
return terrain_filter(vconfig(c),*resources::units);
|
||||
return terrain_filter(vconfig(c),resources::filter_con);
|
||||
}
|
||||
|
||||
static void cfg_to_value(const config &cfg, terrain_filter &value)
|
||||
|
@ -442,7 +442,7 @@ public:
|
|||
static terrain_filter variant_to_value(const variant &var)
|
||||
{
|
||||
static config c("not");
|
||||
terrain_filter value(vconfig(c),*resources::units);
|
||||
terrain_filter value(vconfig(c),resources::filter_con);
|
||||
variant_to_value(var,value);
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -608,7 +608,7 @@ const terrain_filter& readonly_context_impl::get_avoid() const
|
|||
}
|
||||
config cfg;
|
||||
cfg.add_child("not");
|
||||
static terrain_filter tf(vconfig(cfg),*resources::units);
|
||||
static terrain_filter tf(vconfig(cfg),resources::filter_con);
|
||||
return tf;
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ inline boost::shared_ptr<terrain_filter> lua_object<terrain_filter>::to_type(lua
|
|||
boost::shared_ptr<config> cfg = boost::shared_ptr<config>(new config());
|
||||
boost::shared_ptr<vconfig> vcfg = boost::shared_ptr<vconfig>(new vconfig(*cfg));
|
||||
luaW_tovconfig(L, n, *vcfg);
|
||||
boost::shared_ptr<terrain_filter> tf = boost::shared_ptr<terrain_filter>(new terrain_filter(*vcfg, *resources::units));
|
||||
boost::shared_ptr<terrain_filter> tf = boost::shared_ptr<terrain_filter>(new terrain_filter(*vcfg, resources::filter_con));
|
||||
return tf;
|
||||
}
|
||||
|
||||
|
|
|
@ -449,7 +449,7 @@ namespace { // Support functions
|
|||
|
||||
// Filter the locations.
|
||||
std::set<map_location> locs;
|
||||
const terrain_filter t_filter(cfg, *resources::units);
|
||||
const terrain_filter t_filter(cfg, resources::filter_con);
|
||||
t_filter.get_locations(locs, true);
|
||||
|
||||
// Loop through sides.
|
||||
|
@ -485,7 +485,7 @@ namespace { // Support functions
|
|||
|
||||
// Filter the locations.
|
||||
std::set<map_location> locs;
|
||||
const terrain_filter filter(cfg, *resources::units);
|
||||
const terrain_filter filter(cfg, resources::filter_con);
|
||||
filter.get_locations(locs, true);
|
||||
|
||||
BOOST_FOREACH(const int &side_num, sides)
|
||||
|
@ -2398,7 +2398,7 @@ WML_HANDLER_FUNCTION(time_area, /*event_info*/, cfg)
|
|||
id = ids;
|
||||
}
|
||||
std::set<map_location> locs;
|
||||
const terrain_filter filter(cfg, *resources::units);
|
||||
const terrain_filter filter(cfg, resources::filter_con);
|
||||
filter.get_locations(locs, true);
|
||||
config parsed_cfg = cfg.get_parsed_config();
|
||||
resources::tod_manager->add_time_area(id, locs, parsed_cfg);
|
||||
|
|
|
@ -114,7 +114,7 @@ namespace { // Support functions
|
|||
backwards_compat = backwards_compat && have_location.empty();
|
||||
for(vconfig::child_list::const_iterator v = have_location.begin(); v != have_location.end(); ++v) {
|
||||
std::set<map_location> res;
|
||||
terrain_filter(*v, *resources::units).get_locations(res);
|
||||
terrain_filter(*v, resources::filter_con).get_locations(res);
|
||||
|
||||
std::vector<std::pair<int,int> > counts = (*v).has_attribute("count")
|
||||
? utils::parse_ranges((*v)["count"]) : default_counts;
|
||||
|
|
|
@ -171,7 +171,7 @@ bool wml_menu_item::can_show(const map_location & hex) const
|
|||
|
||||
// Failing the [fiter_location] tag means no show.
|
||||
if ( !filter_location_.empty() &&
|
||||
!terrain_filter(filter_location_, *resources::units)(hex) )
|
||||
!terrain_filter(filter_location_, resources::filter_con)(hex) )
|
||||
return false;
|
||||
|
||||
// Failing to have a required selection means no show.
|
||||
|
|
|
@ -80,10 +80,10 @@ void teleport_group::get_teleport_pair(
|
|||
|
||||
scoped_xy_unit teleport_unit("teleport_unit", loc.x, loc.y, *resources::units);
|
||||
|
||||
terrain_filter source_filter(source, *units);
|
||||
terrain_filter source_filter(source, resources::filter_con);
|
||||
source_filter.get_locations(reversed_ ? loc_pair.second : loc_pair.first);
|
||||
|
||||
terrain_filter target_filter(target, *units);
|
||||
terrain_filter target_filter(target, resources::filter_con);
|
||||
target_filter.get_locations(reversed_ ? loc_pair.first : loc_pair.second);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "config.hpp" // for config, etc
|
||||
#include "display_chat_manager.hpp" // for clear_chat_messages
|
||||
#include "filesystem.hpp" // for get_wml_location
|
||||
#include "filter_context.hpp"
|
||||
#include "font.hpp" // for LABEL_COLOR
|
||||
#include "game_board.hpp" // for game_board
|
||||
#include "game_classification.hpp" // for game_classification, etc
|
||||
|
@ -2119,7 +2120,7 @@ static int intf_find_cost_map(lua_State *L)
|
|||
{
|
||||
filter = vconfig(config(), true);
|
||||
}
|
||||
const terrain_filter t_filter(filter, *resources::units);
|
||||
const terrain_filter t_filter(filter, resources::filter_con);
|
||||
t_filter.get_locations(location_set, true);
|
||||
++arg;
|
||||
|
||||
|
@ -3163,7 +3164,7 @@ static int intf_get_locations(lua_State *L)
|
|||
vconfig filter = luaW_checkvconfig(L, 1);
|
||||
|
||||
std::set<map_location> res;
|
||||
const terrain_filter t_filter(filter, *resources::units);
|
||||
const terrain_filter t_filter(filter, resources::filter_con);
|
||||
t_filter.get_locations(res, true);
|
||||
|
||||
lua_createtable(L, res.size(), 0);
|
||||
|
@ -3195,7 +3196,7 @@ static int intf_get_villages(lua_State *L)
|
|||
vconfig filter = luaW_checkvconfig(L, 1);
|
||||
|
||||
for(std::vector<map_location>::const_iterator it = locs.begin(); it != locs.end(); ++it) {
|
||||
bool matches = terrain_filter(filter, *resources::units).match(*it);
|
||||
bool matches = terrain_filter(filter, resources::filter_con).match(*it);
|
||||
if (matches) {
|
||||
lua_createtable(L, 2, 0);
|
||||
lua_pushinteger(L, it->x + 1);
|
||||
|
@ -3226,7 +3227,7 @@ static int intf_match_location(lua_State *L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
const terrain_filter t_filter(filter, *resources::units);
|
||||
const terrain_filter t_filter(filter, resources::filter_con);
|
||||
lua_pushboolean(L, t_filter.match(map_location(x, y)));
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -17,10 +17,11 @@
|
|||
#include "global.hpp"
|
||||
|
||||
#include "config.hpp"
|
||||
#include "display_context.hpp"
|
||||
#include "filter_context.hpp"
|
||||
#include "game_board.hpp"
|
||||
#include "log.hpp"
|
||||
#include "map.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "side_filter.hpp"
|
||||
#include "team.hpp"
|
||||
#include "terrain_filter.hpp"
|
||||
|
@ -46,7 +47,7 @@ terrain_filter::~terrain_filter()
|
|||
#pragma warning(disable:4413)
|
||||
terrain_filter::terrain_filter():
|
||||
cfg_(vconfig::unconstructed_vconfig()),
|
||||
units_(unit_map()),
|
||||
fc_(NULL),
|
||||
cache_(),
|
||||
max_loop_(),
|
||||
flat_()
|
||||
|
@ -57,10 +58,10 @@ terrain_filter::terrain_filter():
|
|||
#endif
|
||||
|
||||
|
||||
terrain_filter::terrain_filter(const vconfig& cfg, const unit_map& units,
|
||||
terrain_filter::terrain_filter(const vconfig& cfg, const filter_context * fc,
|
||||
const bool flat_tod, const size_t max_loop) :
|
||||
cfg_(cfg),
|
||||
units_(units),
|
||||
fc_(fc),
|
||||
cache_(),
|
||||
max_loop_(max_loop),
|
||||
flat_(flat_tod)
|
||||
|
@ -69,7 +70,7 @@ terrain_filter::terrain_filter(const vconfig& cfg, const unit_map& units,
|
|||
|
||||
terrain_filter::terrain_filter(const vconfig& cfg, const terrain_filter& original) :
|
||||
cfg_(cfg),
|
||||
units_(original.units_),
|
||||
fc_(original.fc_),
|
||||
cache_(),
|
||||
max_loop_(original.max_loop_),
|
||||
flat_(original.flat_)
|
||||
|
@ -80,7 +81,7 @@ terrain_filter::terrain_filter(const terrain_filter& other) :
|
|||
xy_pred(), // We should construct this too, since it has no datamembers
|
||||
// use the default constructor.
|
||||
cfg_(other.cfg_),
|
||||
units_(other.units_),
|
||||
fc_(other.fc_),
|
||||
cache_(),
|
||||
max_loop_(other.max_loop_),
|
||||
flat_(other.flat_)
|
||||
|
@ -109,7 +110,7 @@ bool terrain_filter::match_internal(const map_location& loc, const bool ignore_x
|
|||
{
|
||||
//Filter Areas
|
||||
if (cfg_.has_attribute("area") &&
|
||||
resources::tod_manager->get_area_by_id(cfg_["area"]).count(loc) == 0)
|
||||
fc_->get_tod_man().get_area_by_id(cfg_["area"]).count(loc) == 0)
|
||||
return false;
|
||||
|
||||
if(cfg_.has_attribute("terrain")) {
|
||||
|
@ -117,7 +118,7 @@ bool terrain_filter::match_internal(const map_location& loc, const bool ignore_x
|
|||
cache_.parsed_terrain = new t_translation::t_match(cfg_["terrain"]);
|
||||
}
|
||||
if(!cache_.parsed_terrain->is_empty) {
|
||||
const t_translation::t_terrain letter = resources::gameboard->map().get_terrain_info(loc).number();
|
||||
const t_translation::t_terrain letter = fc_->get_disp_context().map().get_terrain_info(loc).number();
|
||||
if(!t_translation::terrain_matches(letter, *cache_.parsed_terrain)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -153,8 +154,8 @@ bool terrain_filter::match_internal(const map_location& loc, const bool ignore_x
|
|||
//Allow filtering on unit
|
||||
if(cfg_.has_child("filter")) {
|
||||
const vconfig& unit_filter = cfg_.child("filter");
|
||||
const unit_map::const_iterator u = units_.find(loc);
|
||||
if (u == units_.end() || !unit_filter::matches_filter(unit_filter, *u, loc, resources::filter_con, flat_))
|
||||
const unit_map::const_iterator u = fc_->get_disp_context().units().find(loc);
|
||||
if (u == fc_->get_disp_context().units().end() || !unit_filter::matches_filter(unit_filter, *u, loc, fc_, flat_))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -166,11 +167,11 @@ bool terrain_filter::match_internal(const map_location& loc, const bool ignore_x
|
|||
bool visible = (*i)["visible"].to_bool(true);
|
||||
bool respect_fog = (*i)["respect_fog"].to_bool(true);
|
||||
|
||||
side_filter ssf(*i, resources::filter_con);
|
||||
side_filter ssf(*i, fc_);
|
||||
std::vector<int> sides = ssf.get_teams();
|
||||
|
||||
BOOST_FOREACH(const int side, sides) {
|
||||
const team &viewing_team = resources::teams->at(side - 1);
|
||||
const team &viewing_team = fc_->get_disp_context().teams().at(side - 1);
|
||||
bool viewer_sees = respect_fog ? !viewing_team.fogged(loc) : !viewing_team.shrouded(loc);
|
||||
if (visible != viewer_sees) {
|
||||
return false;
|
||||
|
@ -193,7 +194,7 @@ bool terrain_filter::match_internal(const map_location& loc, const bool ignore_x
|
|||
std::vector<map_location::DIRECTION>::const_iterator j, j_end = dirs.end();
|
||||
for (j = dirs.begin(); j != j_end; ++j) {
|
||||
map_location &adj = adjacent[*j];
|
||||
if (resources::gameboard->map().on_board(adj)) {
|
||||
if (fc_->get_disp_context().map().on_board(adj)) {
|
||||
if(cache_.adjacent_matches == NULL) {
|
||||
while(index >= std::distance(cache_.adjacent_match_cache.begin(), cache_.adjacent_match_cache.end())) {
|
||||
const vconfig& adj_cfg = adj_cfgs[cache_.adjacent_match_cache.size()];
|
||||
|
@ -242,9 +243,9 @@ bool terrain_filter::match_internal(const map_location& loc, const bool ignore_x
|
|||
time_of_day tod;
|
||||
|
||||
if(flat_) {
|
||||
tod = resources::tod_manager->get_time_of_day(loc);
|
||||
tod = fc_->get_tod_man().get_time_of_day(loc);
|
||||
} else {
|
||||
tod = resources::tod_manager->get_illuminated_time_of_day(resources::gameboard->units(), resources::gameboard->map(),loc);
|
||||
tod = fc_->get_tod_man().get_illuminated_time_of_day(fc_->get_disp_context().units(), fc_->get_disp_context().map(),loc);
|
||||
}
|
||||
|
||||
if(!tod_type.empty()) {
|
||||
|
@ -285,15 +286,15 @@ bool terrain_filter::match_internal(const map_location& loc, const bool ignore_x
|
|||
if(!owner_side.empty()) {
|
||||
WRN_NG << "duplicate side information in a SLF, ignoring inline owner_side=" << std::endl;
|
||||
}
|
||||
if(!resources::gameboard->map().is_village(loc))
|
||||
if(!fc_->get_disp_context().map().is_village(loc))
|
||||
return false;
|
||||
side_filter ssf(filter_owner, resources::filter_con);
|
||||
side_filter ssf(filter_owner, fc_);
|
||||
const std::vector<int>& sides = ssf.get_teams();
|
||||
bool found = false;
|
||||
if(sides.empty() && resources::gameboard->village_owner(loc) == -1)
|
||||
if(sides.empty() && fc_->get_disp_context().village_owner(loc) == -1)
|
||||
found = true;
|
||||
BOOST_FOREACH(const int side, sides) {
|
||||
if(resources::teams->at(side - 1).owns_village(loc)) {
|
||||
if(fc_->get_disp_context().teams().at(side - 1).owns_village(loc)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
@ -303,7 +304,7 @@ bool terrain_filter::match_internal(const map_location& loc, const bool ignore_x
|
|||
}
|
||||
else if(!owner_side.empty()) {
|
||||
const int side_index = owner_side.to_int(0) - 1;
|
||||
if(resources::gameboard->village_owner(loc) != side_index) {
|
||||
if(fc_->get_disp_context().village_owner(loc) != side_index) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -314,7 +315,7 @@ bool terrain_filter::match_internal(const map_location& loc, const bool ignore_x
|
|||
bool terrain_filter::match(const map_location& loc) const
|
||||
{
|
||||
if(cfg_["x"] == "recall" && cfg_["y"] == "recall") {
|
||||
return !resources::gameboard->map().on_board(loc);
|
||||
return !fc_->get_disp_context().map().on_board(loc);
|
||||
}
|
||||
std::set<map_location> hexes;
|
||||
std::vector<map_location> loc_vec(1, loc);
|
||||
|
@ -330,9 +331,9 @@ bool terrain_filter::match(const map_location& loc) const
|
|||
hexes.insert(loc_vec.begin(), loc_vec.end());
|
||||
else if ( cfg_.has_child("filter_radius") ) {
|
||||
terrain_filter r_filter(cfg_.child("filter_radius"), *this);
|
||||
get_tiles_radius(resources::gameboard->map(), loc_vec, radius, hexes, false, r_filter);
|
||||
get_tiles_radius(fc_->get_disp_context().map(), loc_vec, radius, hexes, false, r_filter);
|
||||
} else {
|
||||
get_tiles_radius(resources::gameboard->map(), loc_vec, radius, hexes);
|
||||
get_tiles_radius(fc_->get_disp_context().map(), loc_vec, radius, hexes);
|
||||
}
|
||||
|
||||
size_t loop_count = 0;
|
||||
|
@ -390,9 +391,9 @@ void terrain_filter::get_locations(std::set<map_location>& locs, bool with_borde
|
|||
&& !cfg_.has_attribute("area") ) {
|
||||
|
||||
//consider all locations on the map
|
||||
int bs = resources::gameboard->map().border_size();
|
||||
int w = with_border ? resources::gameboard->map().w() + bs : resources::gameboard->map().w();
|
||||
int h = with_border ? resources::gameboard->map().h() + bs : resources::gameboard->map().h();
|
||||
int bs = fc_->get_disp_context().map().border_size();
|
||||
int w = with_border ? fc_->get_disp_context().map().w() + bs : fc_->get_disp_context().map().w();
|
||||
int h = with_border ? fc_->get_disp_context().map().h() + bs : fc_->get_disp_context().map().h();
|
||||
for (int x = with_border ? 0 - bs : 0; x < w; ++x) {
|
||||
for (int y = with_border ? 0 - bs : 0; y < h; ++y) {
|
||||
match_set.insert(map_location(x,y));
|
||||
|
@ -406,7 +407,7 @@ void terrain_filter::get_locations(std::set<map_location>& locs, bool with_borde
|
|||
&& !cfg_.has_attribute("area") ) {
|
||||
|
||||
std::vector<map_location> xy_vector;
|
||||
xy_vector = resources::gameboard->map().parse_location_range(cfg_["x"], cfg_["y"], with_border);
|
||||
xy_vector = fc_->get_disp_context().map().parse_location_range(cfg_["x"], cfg_["y"], with_border);
|
||||
match_set.insert(xy_vector.begin(), xy_vector.end());
|
||||
} else
|
||||
|
||||
|
@ -435,7 +436,7 @@ void terrain_filter::get_locations(std::set<map_location>& locs, bool with_borde
|
|||
&& !cfg_.has_attribute("find_in")
|
||||
&& cfg_.has_attribute("area") ) {
|
||||
|
||||
const std::set<map_location>& area = resources::tod_manager->get_area_by_id(cfg_["area"]);
|
||||
const std::set<map_location>& area = fc_->get_tod_man().get_area_by_id(cfg_["area"]);
|
||||
match_set.insert(area.begin(), area.end());
|
||||
} else
|
||||
|
||||
|
@ -445,7 +446,7 @@ void terrain_filter::get_locations(std::set<map_location>& locs, bool with_borde
|
|||
&& !cfg_.has_attribute("area") ) {
|
||||
|
||||
std::vector<map_location> xy_vector;
|
||||
xy_vector = resources::gameboard->map().parse_location_range(cfg_["x"], cfg_["y"], with_border);
|
||||
xy_vector = fc_->get_disp_context().map().parse_location_range(cfg_["x"], cfg_["y"], with_border);
|
||||
match_set.insert(xy_vector.begin(), xy_vector.end());
|
||||
|
||||
// remove any locations not found in the specified variable
|
||||
|
@ -478,8 +479,8 @@ void terrain_filter::get_locations(std::set<map_location>& locs, bool with_borde
|
|||
&& cfg_.has_attribute("area") ) {
|
||||
|
||||
std::vector<map_location> xy_vector;
|
||||
xy_vector = resources::gameboard->map().parse_location_range(cfg_["x"], cfg_["y"], with_border);
|
||||
const std::set<map_location>& area = resources::tod_manager->get_area_by_id(cfg_["area"]);
|
||||
xy_vector = fc_->get_disp_context().map().parse_location_range(cfg_["x"], cfg_["y"], with_border);
|
||||
const std::set<map_location>& area = fc_->get_tod_man().get_area_by_id(cfg_["area"]);
|
||||
|
||||
BOOST_FOREACH(const map_location& loc, xy_vector) {
|
||||
if (area.count(loc) != 0)
|
||||
|
@ -492,7 +493,7 @@ void terrain_filter::get_locations(std::set<map_location>& locs, bool with_borde
|
|||
&& cfg_.has_attribute("find_in")
|
||||
&& cfg_.has_attribute("area") ) {
|
||||
|
||||
const std::set<map_location>& area = resources::tod_manager->get_area_by_id(cfg_["area"]);
|
||||
const std::set<map_location>& area = fc_->get_tod_man().get_area_by_id(cfg_["area"]);
|
||||
|
||||
//use content of find_in as starting set
|
||||
variable_info vi(cfg_["find_in"], false, variable_info::TYPE_CONTAINER);
|
||||
|
@ -517,10 +518,10 @@ void terrain_filter::get_locations(std::set<map_location>& locs, bool with_borde
|
|||
&& cfg_.has_attribute("area") ) {
|
||||
|
||||
const std::vector<map_location>& xy_vector =
|
||||
resources::gameboard->map().parse_location_range(cfg_["x"], cfg_["y"], with_border);
|
||||
fc_->get_disp_context().map().parse_location_range(cfg_["x"], cfg_["y"], with_border);
|
||||
std::set<map_location> xy_set(xy_vector.begin(), xy_vector.end());
|
||||
|
||||
const std::set<map_location>& area = resources::tod_manager->get_area_by_id(cfg_["area"]);
|
||||
const std::set<map_location>& area = fc_->get_tod_man().get_area_by_id(cfg_["area"]);
|
||||
|
||||
//use content of find_in as starting set
|
||||
variable_info vi(cfg_["find_in"], false, variable_info::TYPE_CONTAINER);
|
||||
|
@ -630,9 +631,9 @@ void terrain_filter::get_locations(std::set<map_location>& locs, bool with_borde
|
|||
std::vector<map_location> xy_vector (match_set.begin(), match_set.end());
|
||||
if(cfg_.has_child("filter_radius")) {
|
||||
terrain_filter r_filter(cfg_.child("filter_radius"), *this);
|
||||
get_tiles_radius(resources::gameboard->map(), xy_vector, radius, locs, with_border, r_filter);
|
||||
get_tiles_radius(fc_->get_disp_context().map(), xy_vector, radius, locs, with_border, r_filter);
|
||||
} else {
|
||||
get_tiles_radius(resources::gameboard->map(), xy_vector, radius, locs, with_border);
|
||||
get_tiles_radius(fc_->get_disp_context().map(), xy_vector, radius, locs, with_border);
|
||||
}
|
||||
} else {
|
||||
locs.insert(match_set.begin(), match_set.end());
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "variable.hpp"
|
||||
|
||||
class config;
|
||||
class filter_context;
|
||||
class unit;
|
||||
class unit_map;
|
||||
class team;
|
||||
|
@ -37,7 +38,7 @@ public:
|
|||
#endif
|
||||
|
||||
terrain_filter(const vconfig& cfg,
|
||||
const unit_map& units, const bool flat_tod=false, const size_t max_loop=game_config::max_loop);
|
||||
const filter_context * fc, const bool flat_tod=false, const size_t max_loop=game_config::max_loop);
|
||||
terrain_filter(const vconfig& cfg, const terrain_filter& original);
|
||||
/** Default implementation, but defined out-of-line for efficiency reasons. */
|
||||
~terrain_filter();
|
||||
|
@ -66,7 +67,7 @@ private:
|
|||
bool match_internal(const map_location& loc, const bool ignore_xy) const;
|
||||
|
||||
const vconfig cfg_; //config contains WML for a Standard Location Filter
|
||||
const unit_map& units_;
|
||||
const filter_context * fc_;
|
||||
|
||||
struct terrain_filter_cache {
|
||||
terrain_filter_cache() :
|
||||
|
|
|
@ -328,7 +328,7 @@ bool unit::ability_active(const std::string& ability,const config& cfg,const map
|
|||
if (index == map_location::NDIRECTIONS) {
|
||||
continue;
|
||||
}
|
||||
terrain_filter adj_filter(vconfig(i), units);
|
||||
terrain_filter adj_filter(vconfig(i), resources::filter_con);
|
||||
adj_filter.flatten(illuminates);
|
||||
if(!adj_filter.match(adjacent[index])) {
|
||||
return false;
|
||||
|
@ -898,7 +898,7 @@ bool attack_type::special_active(const config& special, AFFECTS whom,
|
|||
map_location::parse_direction(j);
|
||||
if (index == map_location::NDIRECTIONS)
|
||||
continue;
|
||||
terrain_filter adj_filter(vconfig(i), units);
|
||||
terrain_filter adj_filter(vconfig(i), resources::filter_con);
|
||||
if(!adj_filter.match(adjacent[index])) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -827,7 +827,7 @@ void wml_animation_internal(unit_animator &animator, const vconfig &cfg, const m
|
|||
vconfig t_filter = cfg.child("facing");
|
||||
map_location secondary_loc = map_location::null_location();
|
||||
if(!t_filter.empty()) {
|
||||
terrain_filter filter(t_filter, *resources::units);
|
||||
terrain_filter filter(t_filter, resources::filter_con);
|
||||
std::set<map_location> locs;
|
||||
filter.get_locations(locs);
|
||||
if (!locs.empty() && u->get_location() != *locs.begin()) {
|
||||
|
|
|
@ -117,7 +117,7 @@ bool internal_matches_filter(const vconfig& cfg, const unit & u, const map_locat
|
|||
if(cfg.has_child("filter_location")) {
|
||||
assert(fc != NULL);
|
||||
const vconfig& t_cfg = cfg.child("filter_location");
|
||||
terrain_filter t_filter(t_cfg, fc->get_disp_context().units(), use_flat_tod);
|
||||
terrain_filter t_filter(t_cfg, fc, use_flat_tod);
|
||||
if(!t_filter.match(loc)) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue