summaryrefslogtreecommitdiff
path: root/src/commands.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-08-27 16:57:34 +0300
committerAndrei Karas <akaras@inbox.ru>2014-08-27 16:57:34 +0300
commite70704f2b1609b49319e34f466afaf4454d92382 (patch)
tree8e6cccc2103fcb80e420c95a28801c6f7aff2435 /src/commands.cpp
parent8f173afdd496eda7fddd2b166e11626651600501 (diff)
downloadmanaplus-e70704f2b1609b49319e34f466afaf4454d92382.tar.gz
manaplus-e70704f2b1609b49319e34f466afaf4454d92382.tar.bz2
manaplus-e70704f2b1609b49319e34f466afaf4454d92382.tar.xz
manaplus-e70704f2b1609b49319e34f466afaf4454d92382.zip
Move method replaceVars into chatutils.cpp.
Diffstat (limited to 'src/commands.cpp')
-rw-r--r--src/commands.cpp75
1 files changed, 0 insertions, 75 deletions
diff --git a/src/commands.cpp b/src/commands.cpp
index ac854bc39..15f76351d 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -159,79 +159,4 @@ static void uploadFile(const std::string &str,
upload->start();
}
-void replaceVars(std::string &str)
-{
- if (!localPlayer || !actorManager)
- return;
-
- if (str.find("<PLAYER>") != std::string::npos)
- {
- const Being *target = localPlayer->getTarget();
- if (!target || target->getType() != ActorType::PLAYER)
- {
- target = actorManager->findNearestLivingBeing(
- localPlayer, 20, ActorType::PLAYER, true);
- }
- if (target)
- replaceAll(str, "<PLAYER>", target->getName());
- else
- replaceAll(str, "<PLAYER>", "");
- }
- if (str.find("<MONSTER>") != std::string::npos)
- {
- const Being *target = localPlayer->getTarget();
- if (!target || target->getType() != ActorType::MONSTER)
- {
- target = actorManager->findNearestLivingBeing(
- localPlayer, 20, ActorType::MONSTER, true);
- }
- if (target)
- replaceAll(str, "<MONSTER>", target->getName());
- else
- replaceAll(str, "<MONSTER>", "");
- }
- if (str.find("<PEOPLE>") != std::string::npos)
- {
- StringVect names;
- std::string newStr;
- actorManager->getPlayerNames(names, false);
- FOR_EACH (StringVectCIter, it, names)
- {
- if (*it != localPlayer->getName())
- newStr.append(*it).append(",");
- }
- if (newStr[newStr.size() - 1] == ',')
- newStr = newStr.substr(0, newStr.size() - 1);
- if (!newStr.empty())
- replaceAll(str, "<PEOPLE>", newStr);
- else
- replaceAll(str, "<PEOPLE>", "");
- }
- if (str.find("<PARTY>") != std::string::npos)
- {
- StringVect names;
- std::string newStr;
- const Party *party = nullptr;
- if (localPlayer->isInParty() && (party = localPlayer->getParty()))
- {
- party->getNames(names);
- FOR_EACH (StringVectCIter, it, names)
- {
- if (*it != localPlayer->getName())
- newStr.append(*it).append(",");
- }
- if (newStr[newStr.size() - 1] == ',')
- newStr = newStr.substr(0, newStr.size() - 1);
- if (!newStr.empty())
- replaceAll(str, "<PARTY>", newStr);
- else
- replaceAll(str, "<PARTY>", "");
- }
- else
- {
- replaceAll(str, "<PARTY>", "");
- }
- }
-}
-
} // namespace Commands