diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-04-26 21:56:11 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-04-26 21:56:11 +0300 |
commit | 8f10444e4ce4a4e25455f0a3857edc7ca74631e8 (patch) | |
tree | 7917730822f7bc090adc6af482eab843c79a389c /src/localplayer.cpp | |
parent | 110134603554e06adab93a132ef8f82e55db68ad (diff) | |
download | manaplus-8f10444e4ce4a4e25455f0a3857edc7ca74631e8.tar.gz manaplus-8f10444e4ce4a4e25455f0a3857edc7ca74631e8.tar.bz2 manaplus-8f10444e4ce4a4e25455f0a3857edc7ca74631e8.tar.xz manaplus-8f10444e4ce4a4e25455f0a3857edc7ca74631e8.zip |
Impliment 3 attack lists. (priority, attack, ignore)
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r-- | src/localplayer.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp index de6eef334..860b1cbe4 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -3806,11 +3806,14 @@ void LocalPlayer::checkNewName(Being *being) void LocalPlayer::removeAttackMob(const std::string &name) { + mPriorityAttackMobs.remove(name); mAttackMobs.remove(name); mIgnoreAttackMobs.remove(name); + mPriorityAttackMobsSet.erase(name); mAttackMobsSet.erase(name); mIgnoreAttackMobsSet.erase(name); rebuildAttackMobs(); + rebuildPriorityAttackMobs(); } void LocalPlayer::addAttackMob(std::string name) @@ -3836,6 +3839,32 @@ void LocalPlayer::addAttackMob(std::string name) } mAttackMobsSet.insert(name); rebuildAttackMobs(); + rebuildPriorityAttackMobs(); +} + +void LocalPlayer::addPriorityAttackMob(std::string name) +{ + int size = getPriorityAttackMobsSize(); + if (size > 0) + { + int idx = getPriorityAttackMobIndex(""); + if (idx + 1 == size) + { + std::list<std::string>::iterator itr = mPriorityAttackMobs.end(); + -- itr; + mPriorityAttackMobs.insert(itr, name); + } + else + { + mPriorityAttackMobs.push_back(name); + } + } + else + { + mPriorityAttackMobs.push_back(name); + } + mPriorityAttackMobsSet.insert(name); + rebuildPriorityAttackMobs(); } void LocalPlayer::addIgnoreAttackMob(std::string name) @@ -3843,6 +3872,20 @@ void LocalPlayer::addIgnoreAttackMob(std::string name) mIgnoreAttackMobs.push_back(name); mIgnoreAttackMobsSet.insert(name); rebuildAttackMobs(); + rebuildPriorityAttackMobs(); +} + +void LocalPlayer::rebuildPriorityAttackMobs() +{ + mPriorityAttackMobsMap.clear(); + std::list<std::string>::iterator i = mPriorityAttackMobs.begin(); + int cnt = 0; + while (i != mPriorityAttackMobs.end()) + { + mPriorityAttackMobsMap[*i] = cnt; + ++ i; + ++ cnt; + } } void LocalPlayer::rebuildAttackMobs() @@ -3858,6 +3901,15 @@ void LocalPlayer::rebuildAttackMobs() } } +int LocalPlayer::getPriorityAttackMobIndex(std::string name) +{ + std::map<std::string, int>::iterator i = mPriorityAttackMobsMap.find(name); + if (i == mPriorityAttackMobsMap.end()) + return -1; + + return (*i).second; +} + int LocalPlayer::getAttackMobIndex(std::string name) { std::map<std::string, int>::iterator i = mAttackMobsMap.find(name); |