Skip to content

Commit

Permalink
Merge branch 'master' into game_variables
Browse files Browse the repository at this point in the history
Conflicts:
	src/unit_filter.cpp
  • Loading branch information
gfgtdf committed Jul 4, 2014
2 parents dc38053 + c9d05ff commit c03ac97
Show file tree
Hide file tree
Showing 4 changed files with 269 additions and 139 deletions.
23 changes: 13 additions & 10 deletions .travis.yml
Expand Up @@ -3,38 +3,41 @@ compiler:
- gcc
- clang
env:
- STRICT_COMPILATION=True
- STRICT_COMPILATION=False
- ALTERNATE_CONFIGURATION=true
- ALTERNATE_CONFIGURATION=false
matrix:
exclude:
- compiler: gcc
env: STRICT_COMPILATION=False
env: ALTERNATE_CONFIGURATION=true
before_install:
- export TARGETS="wesnoth wesnothd campaignd test"
- export WML_TESTS=true
- export CPP_TESTS=true
- export CHECK_UTF8=true
- if [ "$CXX" = "g++" ]; then export TARGETS="wesnoth test"; fi
- export STRICT_COMPILATION=true
- export EXTRA_FLAGS_RELEASE="-O0"
- export WML_TEST_TIME=40
- if [ "$ALTERNATE_CONFIGURATION" = true ]; then export STRICT_COMPILATION=false; fi
- if [ "$ALTERNATE_CONFIGURATION" = true ]; then export EXTRA_FLAGS_RELEASE=""; fi
- if [ "$ALTERNATE_CONFIGURATION" = true ]; then export WML_TEST_TIME=20; fi
- if [ "$CXX" = "g++" ]; then export WML_TESTS=false; fi
# - if [ "$CXX" = "g++" ]; then export CPP_TESTS=false; fi
- if [ "$CXX" = "g++" ]; then export CHECK_UTF8=false; fi
- if [ "$CXX" = "g++" ]; then time sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y; fi
- if [ "$CXX" = "g++" ]; then time sudo apt-get update -qq; fi
- if [ "$CXX" = "g++" ]; then time sudo apt-get install g++-4.8; fi
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8"; fi
install:
- time sudo apt-get update -qq
- time sudo apt-get install -qq libboost-iostreams-dev libboost-program-options-dev libboost-regex-dev libboost-system-dev libboost-test-dev libcairo2-dev libfribidi-dev libpango1.0-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev
- if [ "$CXX" = "g++" ]; then time sudo apt-get install g++-4.8; fi
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8"; fi
- if [ "$CHECK_UTF8" = true ]; then time sudo apt-get install -qq moreutils; fi
script:
- if [ "$CHECK_UTF8" = true ]; then time ./utils/travis/check_utf8.sh; fi
- time if grep -qorHbm1 "^`echo -ne '\xef\xbb\xbf'`" po/ src/ data/ ; then echo "Error, Found a UTF8 BOM:\n"; grep -orHbm1 "^`echo -ne '\xef\xbb\xbf'`" po/ src/ data/ ; exit 1; fi
# UTF8 checks are the previous two lines. the second one checks po src data for UTF8 bom, this takes a few seconds.
- scons cxxtool=$CXX --debug=time strict=$STRICT_COMPILATION $TARGETS
- scons cxxtool=$CXX --debug=time build=release extra_flags_release="$EXTRA_FLAGS_RELEASE" strict=$STRICT_COMPILATION $TARGETS
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- if [[ "$CPP_TESTS" = true ]]; then time ./utils/travis/test_wrapper.sh; fi
- if [[ "$WML_TESTS" = true ]]; then time ./run_wml_tests -v -t 20; fi
- if [[ "$WML_TESTS" = true ]]; then time ./run_wml_tests -v -t "$WML_TEST_TIME"; fi
after_failure:
- if [ -f "errors.log" ]; then echo -e "\n*** \n*\n* Errors reported in wml unit tests, here is errors.log...\n*\n*** \n"; cat errors.log; fi
notifications:
Expand Down
57 changes: 52 additions & 5 deletions src/pathfind/teleport.cpp
Expand Up @@ -13,6 +13,8 @@

#include "pathfind/teleport.hpp"

#include "display_context.hpp"
#include "filter_context.hpp"
#include "game_board.hpp"
#include "log.hpp"
#include "resources.hpp"
Expand Down Expand Up @@ -60,28 +62,73 @@ teleport_group::teleport_group(const vconfig& cfg, bool reversed) : cfg_(cfg.get
}
}

class ignore_units_display_context : public display_context {
public:
ignore_units_display_context(const display_context & dc)
: um_()
, gm_(&dc.map())
, tm_(&dc.teams())
{
static unit_map empty_unit_map;
um_ = &empty_unit_map;
}
const unit_map & units() const { return *um_; }
const gamemap & map() const { return *gm_; }
const std::vector<team> & teams() const { return *tm_; }

private:
const unit_map * um_;
const gamemap * gm_;
const std::vector<team> * tm_;
};

class ignore_units_filter_context : public filter_context {
public:
ignore_units_filter_context(const filter_context & fc)
: dc_(fc.get_disp_context())
, tod_(&fc.get_tod_man())
{}

const display_context & get_disp_context() const { return dc_; }
const tod_manager & get_tod_man() const { return *tod_; }

private:
const ignore_units_display_context dc_;
const tod_manager * tod_;
};

void teleport_group::get_teleport_pair(
teleport_pair& loc_pair
, const unit& u
, const bool /*ignore_units*/) const
, const bool ignore_units) const
{
const map_location &loc = u.get_location();
static unit_map empty_unit_map;

const filter_context * fc = resources::filter_con;
assert(fc);

if (ignore_units) {
fc = new ignore_units_filter_context(*resources::filter_con);
}

vconfig filter(cfg_.child_or_empty("filter"), true);
vconfig source(cfg_.child_or_empty("source"), true);
vconfig target(cfg_.child_or_empty("target"), true);
const unit_filter ufilt(filter, resources::filter_con);
const unit_filter ufilt(filter, resources::filter_con); //Note: Don't use the ignore units filter context here, only for the terrain filters. (That's how it worked before the filter contexts were introduced)
if (ufilt.matches(u, loc)) {

scoped_xy_unit teleport_unit("teleport_unit", loc.x, loc.y, *resources::units);

terrain_filter source_filter(source, resources::filter_con);
terrain_filter source_filter(source, fc);
source_filter.get_locations(reversed_ ? loc_pair.second : loc_pair.first);

terrain_filter target_filter(target, resources::filter_con);
terrain_filter target_filter(target, fc);
target_filter.get_locations(reversed_ ? loc_pair.first : loc_pair.second);
}

if (ignore_units) {
delete fc;
}
}

const std::string& teleport_group::get_teleport_id() const {
Expand Down

0 comments on commit c03ac97

Please sign in to comment.