diff options
author | Trazom62 <none@none> | 2010-01-30 22:42:04 +0100 |
---|---|---|
committer | Trazom62 <none@none> | 2010-01-30 22:42:04 +0100 |
commit | 4732618c22c7835a79672a1635454d1d61fcf3a7 (patch) | |
tree | 1581f5d051e95e63b181deaa97764e7e6ca1e128 /src | |
parent | aee31b916436ef9aefafe46fdd18ce27a26e0b33 (diff) |
Fix crash in SelectTargetList
Fixes issue #578.
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/game/UnitAI.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/game/UnitAI.cpp b/src/game/UnitAI.cpp index cb8335fac04..dc81dcb0e0e 100644 --- a/src/game/UnitAI.cpp +++ b/src/game/UnitAI.cpp @@ -180,16 +180,17 @@ void UnitAI::SelectTargetList(std::list<Unit*> &targetList, uint32 num, SelectAg targetList.push_back((*itr)->getTarget()); if (targetType == SELECT_TARGET_NEAREST || targetType == SELECT_TARGET_FARTHEST) - { targetList.sort(TargetDistanceOrder(me)); - } if (targetType == SELECT_TARGET_FARTHEST || targetType == SELECT_TARGET_BOTTOMAGGRO) targetList.reverse(); + if (targetList.size() < num) + return; + if (targetType == SELECT_TARGET_RANDOM) { - while (num > targetList.size()) { + while (num < targetList.size()) { std::list<Unit*>::iterator itr = targetList.begin(); advance(itr, urand(0, targetList.size()-1)); targetList.erase(itr); |