summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/actorspritemanager.cpp137
-rw-r--r--src/actorspritemanager.h76
-rw-r--r--src/commandhandler.cpp28
-rw-r--r--src/game.cpp1
-rw-r--r--src/gui/popupmenu.cpp90
-rw-r--r--src/gui/socialwindow.cpp9
-rw-r--r--src/localplayer.cpp116
-rw-r--r--src/localplayer.h81
8 files changed, 273 insertions, 265 deletions
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp
index 3f37ce99f..d193c4ab1 100644
--- a/src/actorspritemanager.cpp
+++ b/src/actorspritemanager.cpp
@@ -29,12 +29,14 @@
#include "playerinfo.h"
#include "playerrelations.h"
-#include "gui/widgets/chattab.h"
-#include "gui/killstats.h"
#include "gui/chatwindow.h"
+#include "gui/killstats.h"
#include "gui/skilldialog.h"
+#include "gui/socialwindow.h"
#include "gui/viewport.h"
+#include "gui/widgets/chattab.h"
+
#include "utils/dtor.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
@@ -177,6 +179,8 @@ ActorSpriteManager::ActorSpriteManager() :
config.addListener("targetOnlyReachable", this);
config.addListener("cyclePlayers", this);
config.addListener("cycleMonsters", this);
+
+ addAttackMob("");
}
ActorSpriteManager::~ActorSpriteManager()
@@ -200,6 +204,8 @@ void ActorSpriteManager::setPlayer(LocalPlayer *player)
{
player_node = player;
mActors.insert(player);
+ if (socialWindow)
+ socialWindow->updateAttackFilter();
}
Being *ActorSpriteManager::createBeing(int id, ActorSprite::Type type,
@@ -665,11 +671,11 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
bool ignoreDefault = false;
if (filtered)
{
- attackMobs = player_node->getAttackMobsSet();
- priorityMobs = player_node->getPriorityAttackMobsSet();
- ignoreAttackMobs = player_node->getIgnoreAttackMobsSet();
- attackMobsMap = player_node->getAttackMobsMap();
- priorityMobsMap = player_node->getPriorityAttackMobsMap();
+ attackMobs = mAttackMobsSet;
+ priorityMobs = mPriorityAttackMobsSet;
+ ignoreAttackMobs = mIgnoreAttackMobsSet;
+ attackMobsMap = mAttackMobsMap;
+ priorityMobsMap = mPriorityAttackMobsMap;
beingSorter.attackBeings = &attackMobsMap;
beingSorter.priorityBeings = &priorityMobsMap;
if (ignoreAttackMobs.find("") != ignoreAttackMobs.end())
@@ -1190,4 +1196,119 @@ void ActorSpriteManager::optionChanged(const std::string &name)
mCyclePlayers = config.getBoolValue("cyclePlayers");
else if (name == "cycleMonsters")
mCycleMonsters = config.getBoolValue("cycleMonsters");
-} \ No newline at end of file
+}
+
+void ActorSpriteManager::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 ActorSpriteManager::addAttackMob(std::string name)
+{
+ int size = getAttackMobsSize();
+ if (size > 0)
+ {
+ int idx = getAttackMobIndex("");
+ if (idx + 1 == size)
+ {
+ std::list<std::string>::iterator itr = mAttackMobs.end();
+ -- itr;
+ mAttackMobs.insert(itr, name);
+ }
+ else
+ {
+ mAttackMobs.push_back(name);
+ }
+ }
+ else
+ {
+ mAttackMobs.push_back(name);
+ }
+ mAttackMobsSet.insert(name);
+ rebuildAttackMobs();
+ rebuildPriorityAttackMobs();
+}
+
+void ActorSpriteManager::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 ActorSpriteManager::addIgnoreAttackMob(std::string name)
+{
+ mIgnoreAttackMobs.push_back(name);
+ mIgnoreAttackMobsSet.insert(name);
+ rebuildAttackMobs();
+ rebuildPriorityAttackMobs();
+}
+
+void ActorSpriteManager::rebuildPriorityAttackMobs()
+{
+ mPriorityAttackMobsMap.clear();
+ std::list<std::string>::iterator i = mPriorityAttackMobs.begin();
+ int cnt = 0;
+ while (i != mPriorityAttackMobs.end())
+ {
+ mPriorityAttackMobsMap[*i] = cnt;
+ ++ i;
+ ++ cnt;
+ }
+}
+
+void ActorSpriteManager::rebuildAttackMobs()
+{
+ mAttackMobsMap.clear();
+ std::list<std::string>::iterator i = mAttackMobs.begin();
+ int cnt = 0;
+ while (i != mAttackMobs.end())
+ {
+ mAttackMobsMap[*i] = cnt;
+ ++ i;
+ ++ cnt;
+ }
+}
+
+int ActorSpriteManager::getPriorityAttackMobIndex(std::string name)
+{
+ std::map<std::string, int>::iterator i = mPriorityAttackMobsMap.find(name);
+ if (i == mPriorityAttackMobsMap.end())
+ return -1;
+
+ return (*i).second;
+}
+
+int ActorSpriteManager::getAttackMobIndex(std::string name)
+{
+ std::map<std::string, int>::iterator i = mAttackMobsMap.find(name);
+ if (i == mAttackMobsMap.end())
+ return -1;
+
+ return (*i).second;
+}
diff --git a/src/actorspritemanager.h b/src/actorspritemanager.h
index c7deba867..d25bee2c1 100644
--- a/src/actorspritemanager.h
+++ b/src/actorspritemanager.h
@@ -229,6 +229,73 @@ class ActorSpriteManager: public ConfigListener
void optionChanged(const std::string &name);
+ void removeAttackMob(const std::string &name);
+
+ void addPriorityAttackMob(std::string name);
+
+ void addAttackMob(std::string name);
+
+ void addIgnoreAttackMob(std::string name);
+
+ std::list<std::string> getPriorityAttackMobs()
+ { return mPriorityAttackMobs; }
+
+ std::list<std::string> getAttackMobs()
+ { return mAttackMobs; }
+
+ void setPriorityAttackMobs(std::list<std::string> mobs)
+ { mPriorityAttackMobs = mobs; }
+
+ void setAttackMobs(std::list<std::string> mobs)
+ { mAttackMobs = mobs; }
+
+ int getPriorityAttackMobsSize()
+ { return mPriorityAttackMobs.size(); }
+
+ int getAttackMobsSize()
+ { return mAttackMobs.size(); }
+
+ std::list<std::string> getIgnoreAttackMobs()
+ { return mIgnoreAttackMobs; }
+
+ std::set<std::string> getAttackMobsSet()
+ { return mAttackMobsSet; }
+
+ std::set<std::string> getPriorityAttackMobsSet()
+ { return mPriorityAttackMobsSet; }
+
+ std::set<std::string> getIgnoreAttackMobsSet()
+ { return mIgnoreAttackMobsSet; }
+
+ void rebuildPriorityAttackMobs();
+
+ void rebuildAttackMobs();
+
+ bool isInAttackList(const std::string &name)
+ { return mAttackMobsSet.find(name) != mAttackMobsSet.end(); }
+
+ bool isInPriorityAttackList(const std::string &name)
+ {
+ return mPriorityAttackMobsSet.find(name)
+ != mPriorityAttackMobsSet.end();
+ }
+
+ bool isInIgnoreAttackList(const std::string &name)
+ {
+ return mIgnoreAttackMobsSet.find(name)
+ != mIgnoreAttackMobsSet.end();
+ }
+
+ std::map<std::string, int> getAttackMobsMap()
+ { return mAttackMobsMap; }
+
+ std::map<std::string, int> getPriorityAttackMobsMap()
+ { return mPriorityAttackMobsMap; }
+
+ int getAttackMobIndex(std::string name);
+
+ int getPriorityAttackMobIndex(std::string name);
+
protected:
bool validateBeing(Being *aroundBeing, Being* being,
Being::Type type, Being* excluded = 0,
@@ -248,6 +315,15 @@ class ActorSpriteManager: public ConfigListener
bool mTargetOnlyReachable;
bool mCyclePlayers;
bool mCycleMonsters;
+
+ std::list<std::string> mPriorityAttackMobs;
+ std::list<std::string> mAttackMobs;
+ std::list<std::string> mIgnoreAttackMobs;
+ std::set<std::string> mPriorityAttackMobsSet;
+ std::set<std::string> mAttackMobsSet;
+ std::set<std::string> mIgnoreAttackMobsSet;
+ std::map<std::string, int> mPriorityAttackMobsMap;
+ std::map<std::string, int> mAttackMobsMap;
};
extern ActorSpriteManager *actorSpriteManager;
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp
index 8d4168e76..537d9645a 100644
--- a/src/commandhandler.cpp
+++ b/src/commandhandler.cpp
@@ -998,11 +998,14 @@ void CommandHandler::handleUptime(const std::string &args _UNUSED_,
void CommandHandler::handleAddPriorityAttack(const std::string &args,
ChatTab *tab _UNUSED_)
{
- if (!player_node || player_node->isInPriorityAttackList(args))
+ if (!actorSpriteManager
+ || actorSpriteManager->isInPriorityAttackList(args))
+ {
return;
+ }
- player_node->removeAttackMob(args);
- player_node->addPriorityAttackMob(args);
+ actorSpriteManager->removeAttackMob(args);
+ actorSpriteManager->addPriorityAttackMob(args);
if (socialWindow)
socialWindow->updateAttackFilter();
@@ -1011,11 +1014,11 @@ void CommandHandler::handleAddPriorityAttack(const std::string &args,
void CommandHandler::handleAddAttack(const std::string &args,
ChatTab *tab _UNUSED_)
{
- if (!player_node || player_node->isInAttackList(args))
+ if (!actorSpriteManager || actorSpriteManager->isInAttackList(args))
return;
- player_node->removeAttackMob(args);
- player_node->addAttackMob(args);
+ actorSpriteManager->removeAttackMob(args);
+ actorSpriteManager->addAttackMob(args);
if (socialWindow)
socialWindow->updateAttackFilter();
@@ -1024,10 +1027,13 @@ void CommandHandler::handleAddAttack(const std::string &args,
void CommandHandler::handleRemoveAttack(const std::string &args,
ChatTab *tab _UNUSED_)
{
- if (!player_node || args.empty() || !player_node->isInAttackList(args))
+ if (!actorSpriteManager || args.empty()
+ || !actorSpriteManager->isInAttackList(args))
+ {
return;
+ }
- player_node->removeAttackMob(args);
+ actorSpriteManager->removeAttackMob(args);
if (socialWindow)
socialWindow->updateAttackFilter();
@@ -1036,11 +1042,11 @@ void CommandHandler::handleRemoveAttack(const std::string &args,
void CommandHandler::handleAddIgnoreAttack(const std::string &args,
ChatTab *tab _UNUSED_)
{
- if (!player_node || player_node->isInIgnoreAttackList(args))
+ if (!actorSpriteManager || actorSpriteManager->isInIgnoreAttackList(args))
return;
- player_node->removeAttackMob(args);
- player_node->addIgnoreAttackMob(args);
+ actorSpriteManager->removeAttackMob(args);
+ actorSpriteManager->addIgnoreAttackMob(args);
if (socialWindow)
socialWindow->updateAttackFilter();
diff --git a/src/game.cpp b/src/game.cpp
index 3c3067bbf..d0cbbdb40 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -224,7 +224,6 @@ static void createGuiWindows()
whoIsOnline = new WhoIsOnline();
killStats = new KillStats;
socialWindow = new SocialWindow();
- socialWindow->updateAttackFilter();
localChatTab = new ChatTab(_("General"));
localChatTab->setAllowHighlight(false);
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index be76fc4a6..5cc13d8ed 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -105,7 +105,7 @@ PopupMenu::PopupMenu():
void PopupMenu::showPopup(int x, int y, Being *being)
{
- if (!being || !player_node)
+ if (!being || !player_node || !actorSpriteManager)
return;
mBeingId = being->getId();
@@ -254,9 +254,9 @@ void PopupMenu::showPopup(int x, int y, Being *being)
if (config.getBoolValue("enableAttackFilter"))
{
mBrowserBox->addRow("##3---");
- if (player_node->isInAttackList(name)
- || player_node->isInIgnoreAttackList(name)
- || player_node->isInPriorityAttackList(name))
+ if (actorSpriteManager->isInAttackList(name)
+ || actorSpriteManager->isInIgnoreAttackList(name)
+ || actorSpriteManager->isInPriorityAttackList(name))
{
mBrowserBox->addRow(
_("@@remove attack|Remove from attack list@@"));
@@ -1149,48 +1149,49 @@ void PopupMenu::handleLink(const std::string &link,
}
else if (link == "remove attack" && being)
{
- if (player_node && being->getType() == Being::MONSTER)
+ if (actorSpriteManager && being->getType() == Being::MONSTER)
{
- player_node->removeAttackMob(being->getName());
+ actorSpriteManager->removeAttackMob(being->getName());
if (socialWindow)
socialWindow->updateAttackFilter();
}
}
else if (link == "add attack" && being)
{
- if (player_node && being->getType() == Being::MONSTER)
+ if (actorSpriteManager && being->getType() == Being::MONSTER)
{
- player_node->addAttackMob(being->getName());
+ actorSpriteManager->addAttackMob(being->getName());
if (socialWindow)
socialWindow->updateAttackFilter();
}
}
else if (link == "add attack priority" && being)
{
- if (player_node && being->getType() == Being::MONSTER)
+ if (actorSpriteManager && being->getType() == Being::MONSTER)
{
- player_node->addPriorityAttackMob(being->getName());
+ actorSpriteManager->addPriorityAttackMob(being->getName());
if (socialWindow)
socialWindow->updateAttackFilter();
}
}
else if (link == "add attack ignore" && being)
{
- if (player_node && being->getType() == Being::MONSTER)
+ if (actorSpriteManager && being->getType() == Being::MONSTER)
{
- player_node->addIgnoreAttackMob(being->getName());
+ actorSpriteManager->addIgnoreAttackMob(being->getName());
if (socialWindow)
socialWindow->updateAttackFilter();
}
}
else if (link == "attack moveup")
{
- if (player_node)
+ if (actorSpriteManager)
{
- int idx = player_node->getAttackMobIndex(mNick);
+ int idx = actorSpriteManager->getAttackMobIndex(mNick);
if (idx > 0)
{
- std::list<std::string> mobs = player_node->getAttackMobs();
+ std::list<std::string> mobs
+ = actorSpriteManager->getAttackMobs();
std::list<std::string>::iterator it = mobs.begin();
std::list<std::string>::iterator it2 = mobs.begin();
while (it != mobs.end())
@@ -1199,8 +1200,8 @@ void PopupMenu::handleLink(const std::string &link,
{
-- it2;
mobs.splice(it2, mobs, it);
- player_node->setAttackMobs(mobs);
- player_node->rebuildAttackMobs();
+ actorSpriteManager->setAttackMobs(mobs);
+ actorSpriteManager->rebuildAttackMobs();
break;
}
++ it;
@@ -1214,13 +1215,13 @@ void PopupMenu::handleLink(const std::string &link,
}
else if (link == "priority moveup")
{
- if (player_node)
+ if (actorSpriteManager)
{
- int idx = player_node->getPriorityAttackMobIndex(mNick);
+ int idx = actorSpriteManager->getPriorityAttackMobIndex(mNick);
if (idx > 0)
{
std::list<std::string> mobs
- = player_node->getPriorityAttackMobs();
+ = actorSpriteManager->getPriorityAttackMobs();
std::list<std::string>::iterator it = mobs.begin();
std::list<std::string>::iterator it2 = mobs.begin();
while (it != mobs.end())
@@ -1229,8 +1230,8 @@ void PopupMenu::handleLink(const std::string &link,
{
-- it2;
mobs.splice(it2, mobs, it);
- player_node->setPriorityAttackMobs(mobs);
- player_node->rebuildPriorityAttackMobs();
+ actorSpriteManager->setPriorityAttackMobs(mobs);
+ actorSpriteManager->rebuildPriorityAttackMobs();
break;
}
++ it;
@@ -1244,13 +1245,14 @@ void PopupMenu::handleLink(const std::string &link,
}
else if (link == "attack movedown")
{
- if (player_node)
+ if (actorSpriteManager)
{
- int idx = player_node->getAttackMobIndex(mNick);
- int size = player_node->getAttackMobsSize();
+ int idx = actorSpriteManager->getAttackMobIndex(mNick);
+ int size = actorSpriteManager->getAttackMobsSize();
if (idx + 1 < size)
{
- std::list<std::string> mobs = player_node->getAttackMobs();
+ std::list<std::string> mobs
+ = actorSpriteManager->getAttackMobs();
std::list<std::string>::iterator it = mobs.begin();
std::list<std::string>::iterator it2 = mobs.begin();
while (it != mobs.end())
@@ -1262,8 +1264,8 @@ void PopupMenu::handleLink(const std::string &link,
break;
mobs.splice(it, mobs, it2);
- player_node->setAttackMobs(mobs);
- player_node->rebuildAttackMobs();
+ actorSpriteManager->setAttackMobs(mobs);
+ actorSpriteManager->rebuildAttackMobs();
break;
}
++ it;
@@ -1279,12 +1281,12 @@ void PopupMenu::handleLink(const std::string &link,
{
if (player_node)
{
- int idx = player_node->getPriorityAttackMobIndex(mNick);
- int size = player_node->getPriorityAttackMobsSize();
+ int idx = actorSpriteManager->getPriorityAttackMobIndex(mNick);
+ int size = actorSpriteManager->getPriorityAttackMobsSize();
if (idx + 1 < size)
{
std::list<std::string> mobs
- = player_node->getPriorityAttackMobs();
+ = actorSpriteManager->getPriorityAttackMobs();
std::list<std::string>::iterator it = mobs.begin();
std::list<std::string>::iterator it2 = mobs.begin();
while (it != mobs.end())
@@ -1296,8 +1298,8 @@ void PopupMenu::handleLink(const std::string &link,
break;
mobs.splice(it, mobs, it2);
- player_node->setPriorityAttackMobs(mobs);
- player_node->rebuildPriorityAttackMobs();
+ actorSpriteManager->setPriorityAttackMobs(mobs);
+ actorSpriteManager->rebuildPriorityAttackMobs();
break;
}
++ it;
@@ -1311,24 +1313,24 @@ void PopupMenu::handleLink(const std::string &link,
}
else if (link == "attack remove")
{
- if (player_node)
+ if (actorSpriteManager)
{
if (mNick.empty())
{
- if (player_node->isInAttackList(mNick))
+ if (actorSpriteManager->isInAttackList(mNick))
{
- player_node->removeAttackMob(mNick);
- player_node->addIgnoreAttackMob(mNick);
+ actorSpriteManager->removeAttackMob(mNick);
+ actorSpriteManager->addIgnoreAttackMob(mNick);
}
else
{
- player_node->removeAttackMob(mNick);
- player_node->addAttackMob(mNick);
+ actorSpriteManager->removeAttackMob(mNick);
+ actorSpriteManager->addAttackMob(mNick);
}
}
else
{
- player_node->removeAttackMob(mNick);
+ actorSpriteManager->removeAttackMob(mNick);
}
if (socialWindow)
socialWindow->updateAttackFilter();
@@ -1696,8 +1698,8 @@ void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name,
{
case MapItem::ATTACK:
{
- int idx = player_node->getAttackMobIndex(name);
- int size = player_node->getAttackMobsSize();
+ int idx = actorSpriteManager->getAttackMobIndex(name);
+ int size = actorSpriteManager->getAttackMobsSize();
if (idx > 0)
{
mBrowserBox->addRow(strprintf(
@@ -1714,8 +1716,8 @@ void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name,
}
case MapItem::PRIORITY:
{
- int idx = player_node->getPriorityAttackMobIndex(name);
- int size = player_node->getPriorityAttackMobsSize();
+ int idx = actorSpriteManager->getPriorityAttackMobIndex(name);
+ int size = actorSpriteManager->getPriorityAttackMobsSize();
if (idx > 0)
{
mBrowserBox->addRow(strprintf(
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index 2276f60e0..e943d7286 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -803,12 +803,13 @@ public:
void updateList()
{
- if (!socialWindow || !player_node)
+ if (!socialWindow || !player_node || !actorSpriteManager)
return;
std::vector<Avatar*> *avatars = mBeings->getMembers();
- std::list<std::string> mobs = player_node->getPriorityAttackMobs();
+ std::list<std::string> mobs
+ = actorSpriteManager->getPriorityAttackMobs();
std::list<std::string>::iterator i = mobs.begin();
std::vector<Avatar*>::iterator ia = avatars->begin();
@@ -860,7 +861,7 @@ public:
ava->setY(0);
avatars->push_back(ava);
- mobs = player_node->getAttackMobs();
+ mobs = actorSpriteManager->getAttackMobs();
i = mobs.begin();
while (i != mobs.end())
@@ -895,7 +896,7 @@ public:
ava->setY(0);
avatars->push_back(ava);
- mobs = player_node->getIgnoreAttackMobs();
+ mobs = actorSpriteManager->getIgnoreAttackMobs();
i = mobs.begin();
while (i != mobs.end())
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 0ab1ca713..81a8e6b89 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -179,7 +179,6 @@ LocalPlayer::LocalPlayer(int id, int subtype):
config.addListener("showJobExp", this);
setShowName(config.getBoolValue("showownname"));
beingInfoCache.clear();
- addAttackMob("");
}
LocalPlayer::~LocalPlayer()
@@ -3812,121 +3811,6 @@ 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)
-{
- int size = getAttackMobsSize();
- if (size > 0)
- {
- int idx = getAttackMobIndex("");
- if (idx + 1 == size)
- {
- std::list<std::string>::iterator itr = mAttackMobs.end();
- -- itr;
- mAttackMobs.insert(itr, name);
- }
- else
- {
- mAttackMobs.push_back(name);
- }
- }
- else
- {
- mAttackMobs.push_back(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)
-{
- 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()
-{
- mAttackMobsMap.clear();
- std::list<std::string>::iterator i = mAttackMobs.begin();
- int cnt = 0;
- while (i != mAttackMobs.end())
- {
- mAttackMobsMap[*i] = cnt;
- ++ i;
- ++ cnt;
- }
-}
-
-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);
- if (i == mAttackMobsMap.end())
- return -1;
-
- return (*i).second;
-}
-
void LocalPlayer::resetYellowBar()
{
mInvertDirection = config.resetIntValue("invertMoveDirection");
diff --git a/src/localplayer.h b/src/localplayer.h
index 4b9e98c13..6a6a015b8 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -449,79 +449,6 @@ class LocalPlayer : public Being, public ActorSpriteListener,
void checkNewName(Being *being);
- bool isInAttackList(const std::string &name)
- { return mAttackMobsSet.find(name) != mAttackMobsSet.end(); }
-
- bool isInPriorityAttackList(const std::string &name)
- {
- return mPriorityAttackMobsSet.find(name)
- != mPriorityAttackMobsSet.end();
- }
-
- bool isInIgnoreAttackList(const std::string &name)
- {
- return mIgnoreAttackMobsSet.find(name)
- != mIgnoreAttackMobsSet.end();
- }
-
-/*
- bool isInAttackOrIgnoreList(const std::string &name)
- { return mAttackMobsSet.find(name) != mAttackMobsSet.end() ||
- mIgnoreAttackMobsSet.find(name) != mIgnoreAttackMobsSet.end(); }
-*/
-
- void removeAttackMob(const std::string &name);
-
- void addPriorityAttackMob(std::string name);
-
- void addAttackMob(std::string name);
-
- void addIgnoreAttackMob(std::string name);
-
- std::list<std::string> getPriorityAttackMobs()
- { return mPriorityAttackMobs; }
-
- std::list<std::string> getAttackMobs()
- { return mAttackMobs; }
-
- void setPriorityAttackMobs(std::list<std::string> mobs)
- { mPriorityAttackMobs = mobs; }
-
- void setAttackMobs(std::list<std::string> mobs)
- { mAttackMobs = mobs; }
-
- int getPriorityAttackMobsSize()
- { return mPriorityAttackMobs.size(); }
-
- int getAttackMobsSize()
- { return mAttackMobs.size(); }
-
- std::list<std::string> getIgnoreAttackMobs()
- { return mIgnoreAttackMobs; }
-
- std::set<std::string> getAttackMobsSet()
- { return mAttackMobsSet; }
-
- std::set<std::string> getPriorityAttackMobsSet()
- { return mPriorityAttackMobsSet; }
-
- std::set<std::string> getIgnoreAttackMobsSet()
- { return mIgnoreAttackMobsSet; }
-
- void rebuildPriorityAttackMobs();
-
- void rebuildAttackMobs();
-
- std::map<std::string, int> getAttackMobsMap()
- { return mAttackMobsMap; }
-
- std::map<std::string, int> getPriorityAttackMobsMap()
- { return mPriorityAttackMobsMap; }
-
- int getAttackMobIndex(std::string name);
-
- int getPriorityAttackMobIndex(std::string name);
-
void resetYellowBar();
protected:
@@ -650,14 +577,6 @@ class LocalPlayer : public Being, public ActorSpriteListener,
bool mServerAttack;
std::string mLastHitFrom;
std::string mWaitFor;
- std::list<std::string> mPriorityAttackMobs;
- std::list<std::string> mAttackMobs;
- std::list<std::string> mIgnoreAttackMobs;
- std::set<std::string> mPriorityAttackMobsSet;
- std::set<std::string> mAttackMobsSet;
- std::set<std::string> mIgnoreAttackMobsSet;
- std::map<std::string, int> mPriorityAttackMobsMap;
- std::map<std::string, int> mAttackMobsMap;
};
extern LocalPlayer *player_node;