Skip to content

Commit

Permalink
Unit Map: added has_unit_at helper function
Browse files Browse the repository at this point in the history
Just a small wrapper function to check whether a unit is present a certain location.
  • Loading branch information
Vultraz committed Jul 26, 2017
1 parent fc8e9cf commit 1408da6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/units/map.cpp
Expand Up @@ -385,3 +385,8 @@ bool unit_map::has_unit(const unit * const u) const
}
return false;
}

bool unit_map::has_unit_at(const map_location& loc) const
{
return find(loc) != end();
}
3 changes: 3 additions & 0 deletions src/units/map.hpp
Expand Up @@ -394,6 +394,9 @@ class unit_map {
*/
bool has_unit(const unit * const u) const ;

/** Tests whether a unit exists at the given location. */
bool has_unit_at(const map_location& loc) const;

private:
umap::iterator begin_core() const ;

Expand Down

0 comments on commit 1408da6

Please sign in to comment.