summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r--src/localplayer.cpp52
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);