aboutsummaryrefslogtreecommitdiff
path: root/src/game/Unit.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/Unit.h')
-rw-r--r--src/game/Unit.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/game/Unit.h b/src/game/Unit.h
index d30f694e88d..05c0c493abe 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -2085,4 +2085,19 @@ namespace Trinity
}
}
+// binary function to sort unit based on the distance to a reference unit
+struct TargetDistanceOrder : public std::binary_function<const Unit *, const Unit *, bool>
+{
+ const Unit *me;
+
+ // pUnit: the reference unit from which the distance is computed.
+ TargetDistanceOrder(const Unit* pUnit) : me(pUnit) {};
+
+ // functor for operator "<"
+ bool operator()(const Unit* left, const Unit* right) const
+ {
+ return (me->GetExactDistSq(left) < me->GetExactDistSq(right));
+ }
+};
+
#endif