Merge pull request #782 from wesnoth/fix-tunnel-issues

Fix issues with tunnels when exit hex is occupied by an allied unit
This commit is contained in:
mattsc 2016-09-16 06:51:05 -07:00 committed by GitHub
commit ff9450eff2
3 changed files with 22 additions and 7 deletions

View file

@ -453,12 +453,6 @@ namespace { // Private helpers for move_unit()
if ( blocking_unit == resources::units->end() )
return false;
if ( !tiles_adjacent(hex, prev_hex) ) {
// Cannot teleport to an occupied hex.
teleport_failed_ = true;
return true;
}
if ( current_team_->is_enemy(blocking_unit->side()) ) {
// Trying to go through an enemy.
blocked_loc_ = hex;

View file

@ -146,6 +146,10 @@ bool teleport_group::always_visible() const {
return cfg_["always_visible"].to_bool(false);
}
bool teleport_group::pass_allied_units() const {
return cfg_["pass_allied_units"].to_bool(false);
}
config teleport_group::to_config() const {
config retval = cfg_;
retval["saved"] = "yes";
@ -182,8 +186,20 @@ teleport_map::teleport_map(
locations.first.swap(filter_locs.first);
locations.second.swap(filter_locs.second);
}
std::string teleport_id = group.get_teleport_id();
if (!group.pass_allied_units() && !ignore_units) {
std::set<map_location>::iterator loc = locations.second.begin();
while(loc != locations.second.end()) {
const unit *v = resources::gameboard->get_visible_unit(*loc, viewing_team, see_all);
if (v) {
loc = locations.second.erase(loc);
} else {
++loc;
}
}
}
std::string teleport_id = group.get_teleport_id();
std::set<map_location>::iterator source_it = locations.first.begin();
for (; source_it != locations.first.end(); ++source_it ) {
if(teleport_map_.count(*source_it) == 0) {

View file

@ -70,6 +70,11 @@ public:
*/
bool always_visible() const;
/*
* Returns whether allied units on the exit hex can be passed.
*/
bool pass_allied_units() const;
/** Inherited from savegame_config. */
config to_config() const;