summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-04-21 05:25:01 +0300
committerAndrei Karas <akaras@inbox.ru>2011-04-21 05:25:01 +0300
commit8037d33c9f429d4c0322da383cdda46776c3c14e (patch)
tree7460a6dd0c774817ff1dd92aa190776ae1684ed9 /src/localplayer.cpp
parentd7eae524bf7e88ebb5a324431b74a77ce1e7fded (diff)
downloadmv-8037d33c9f429d4c0322da383cdda46776c3c14e.tar.gz
mv-8037d33c9f429d4c0322da383cdda46776c3c14e.tar.bz2
mv-8037d33c9f429d4c0322da383cdda46776c3c14e.tar.xz
mv-8037d33c9f429d4c0322da383cdda46776c3c14e.zip
Impliment attack filter.
Add tab in social tab.
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r--src/localplayer.cpp75
1 files changed, 73 insertions, 2 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index ac113a54a..a4289b22b 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -179,6 +179,7 @@ LocalPlayer::LocalPlayer(int id, int subtype):
config.addListener("showJobExp", this);
setShowName(config.getBoolValue("showownname"));
beingInfoCache.clear();
+ addAttackMob("");
}
LocalPlayer::~LocalPlayer()
@@ -2568,12 +2569,19 @@ bool LocalPlayer::isReachable(Being *being, int maxCost)
if (being->isReachable() == Being::REACH_NO)
return false;
- if (being->getTileX() - 1 <= getTileX()
+ if (being->getTileX() == getTileX()
+ && being->getTileY() == getTileY())
+ {
+ being->setDistance(0);
+ being->setIsReachable(Being::REACH_YES);
+ return true;
+ }
+ else if (being->getTileX() - 1 <= getTileX()
&& being->getTileX() + 1 >= getTileX()
&& being->getTileY() - 1 <= getTileY()
&& being->getTileY() + 1 >= getTileY())
{
- being->setDistance(0);
+ being->setDistance(1);
being->setIsReachable(Being::REACH_YES);
return true;
}
@@ -3774,6 +3782,69 @@ void LocalPlayer::checkNewName(Being *being)
}
}
+void LocalPlayer::removeAttackMob(const std::string &name)
+{
+ mAttackMobs.remove(name);
+ mIgnoreAttackMobs.remove(name);
+ mAttackMobsSet.erase(name);
+ mIgnoreAttackMobsSet.erase(name);
+ rebuildAttackMobs();
+}
+
+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();
+}
+
+void LocalPlayer::addIgnoreAttackMob(std::string name)
+{
+ mIgnoreAttackMobs.push_back(name);
+ mIgnoreAttackMobsSet.insert(name);
+ rebuildAttackMobs();
+}
+
+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::getAttackMobIndex(std::string name)
+{
+ std::map<std::string, int>::iterator i = mAttackMobsMap.find(name);
+ if (i == mAttackMobsMap.end())
+ return -1;
+
+ return (*i).second;
+}
+
void AwayListener::action(const gcn::ActionEvent &event)
{
if (event.getId() == "ok" && player_node && player_node->getAwayMode())