Skip to content

Commit

Permalink
Merge branch 'fixup_filter_vision' into 1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeck88 committed Jul 12, 2014
2 parents b8007ed + 7253a1a commit 31699f6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
7 changes: 5 additions & 2 deletions src/terrain_filter.cpp
Expand Up @@ -166,13 +166,16 @@ bool terrain_filter::match_internal(const map_location& loc, const bool ignore_x
side_filter ssf(*i);
std::vector<int> sides = ssf.get_teams();

bool found = false;
BOOST_FOREACH(const int side, sides) {
const team &viewing_team = resources::teams->at(side - 1);
bool viewer_sees = respect_fog ? !viewing_team.fogged(loc) : !viewing_team.shrouded(loc);
if (visible != viewer_sees) {
return false;
if (visible == viewer_sees) {
found = true;
break;
}
}
if (!found) return false;
}
}

Expand Down
16 changes: 9 additions & 7 deletions src/unit.cpp
Expand Up @@ -1562,16 +1562,18 @@ bool unit::internal_matches_filter(const vconfig& cfg, const map_location& loc,
side_filter ssf(*i);
std::vector<int> sides = ssf.get_teams();
viewers.insert(sides.begin(), sides.end());
if (viewers.empty()) {
return false;
}
std::set<int>::const_iterator viewer, viewer_end = viewers.end();
for (viewer = viewers.begin(); viewer != viewer_end; ++viewer) {
bool fogged = teams_manager::get_teams()[*viewer - 1].fogged(loc);

bool found = false;
BOOST_FOREACH(const int viewer, viewers) {
bool fogged = teams_manager::get_teams()[viewer - 1].fogged(loc);
bool hiding = this->invisible(loc/*, false(?) */);
bool unit_hidden = fogged || hiding;
if (visible == unit_hidden) return false;
if (visible != unit_hidden) {
found = true;
break;
}
}
if (!found) return false;
}
}

Expand Down

0 comments on commit 31699f6

Please sign in to comment.