From 1408da68ce7d1c749b2bc448da1dc6fd4b411bda Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Wed, 19 Jul 2017 14:17:00 +1100 Subject: [PATCH] Unit Map: added has_unit_at helper function Just a small wrapper function to check whether a unit is present a certain location. --- src/units/map.cpp | 5 +++++ src/units/map.hpp | 3 +++ 2 files changed, 8 insertions(+) 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 ;