summaryrefslogtreecommitdiff
path: root/src/actorspritemanager.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-05-06 22:32:21 +0300
committerAndrei Karas <akaras@inbox.ru>2011-05-07 18:24:47 +0300
commit2a4649185cda0788444452168ddcf665af7f17b5 (patch)
tree5ef92bdda9421130873a08e7793fad40364b41e3 /src/actorspritemanager.cpp
parentc371ce29dd114121fe0071e59460a9f197da70f5 (diff)
downloadplus-2a4649185cda0788444452168ddcf665af7f17b5.tar.gz
plus-2a4649185cda0788444452168ddcf665af7f17b5.tar.bz2
plus-2a4649185cda0788444452168ddcf665af7f17b5.tar.xz
plus-2a4649185cda0788444452168ddcf665af7f17b5.zip
Save atack filter between restarts.
Diffstat (limited to 'src/actorspritemanager.cpp')
-rw-r--r--src/actorspritemanager.cpp57
1 files changed, 56 insertions, 1 deletions
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp
index d193c4ab1..e7c28fd1e 100644
--- a/src/actorspritemanager.cpp
+++ b/src/actorspritemanager.cpp
@@ -180,7 +180,7 @@ ActorSpriteManager::ActorSpriteManager() :
config.addListener("cyclePlayers", this);
config.addListener("cycleMonsters", this);
- addAttackMob("");
+ loadAttackList();
}
ActorSpriteManager::~ActorSpriteManager()
@@ -189,6 +189,7 @@ ActorSpriteManager::~ActorSpriteManager()
config.removeListener("targetOnlyReachable", this);
config.removeListener("cyclePlayers", this);
config.removeListener("cycleMonsters", this);
+ storeAttackList();
clear();
}
@@ -1312,3 +1313,57 @@ int ActorSpriteManager::getAttackMobIndex(std::string name)
return (*i).second;
}
+
+void ActorSpriteManager::loadAttackList()
+{
+ bool empty = false;
+ std::list<std::string> list = unpackList(
+ serverConfig.getValue("attackPriorityMobs", ""));
+ std::list<std::string>::iterator i = list.begin();
+ while (i != list.end())
+ {
+ if (*i == "")
+ empty = true;
+ mPriorityAttackMobs.push_back(*i);
+ mPriorityAttackMobsSet.insert(*i);
+ ++ i;
+ }
+
+ list = unpackList(serverConfig.getValue("attackMobs", ""));
+ i = list.begin();
+ while (i != list.end())
+ {
+ if (*i == "")
+ empty = true;
+ mAttackMobs.push_back(*i);
+ mAttackMobsSet.insert(*i);
+ ++ i;
+ }
+
+ list = unpackList(serverConfig.getValue("ignoreAttackMobs", ""));
+ i = list.begin();
+ while (i != list.end())
+ {
+ if (*i == "")
+ empty = true;
+ mIgnoreAttackMobs.push_back(*i);
+ mIgnoreAttackMobsSet.insert(*i);
+ ++ i;
+ }
+
+ if (!empty)
+ {
+ mAttackMobs.push_back("");
+ mAttackMobsSet.insert("");
+ }
+
+ rebuildAttackMobs();
+ rebuildPriorityAttackMobs();
+}
+
+void ActorSpriteManager::storeAttackList()
+{
+ serverConfig.setValue("attackPriorityMobs", packList(mPriorityAttackMobs));
+ serverConfig.setValue("attackMobs", packList(mAttackMobs));
+ serverConfig.setValue("ignoreAttackMobs", packList(mIgnoreAttackMobs));
+}