diff --git a/src/units/map.cpp b/src/units/map.cpp index 9860adbbcf7c..d66240c901b9 100644 --- a/src/units/map.cpp +++ b/src/units/map.cpp @@ -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(); +} diff --git a/src/units/map.hpp b/src/units/map.hpp index fe9d3ab7ea5a..2f1285ea0580 100644 --- a/src/units/map.hpp +++ b/src/units/map.hpp @@ -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 ;