summaryrefslogtreecommitdiff
path: root/src/gui/windows/chatwindow.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-12-28 18:28:01 +0300
committerAndrei Karas <akaras@inbox.ru>2014-12-28 18:28:01 +0300
commit31a4e17565b91b62fec057c10d3903310526c824 (patch)
treebb8d9c51ee9045074f5ef8ed7fb7fe95ad70fe91 /src/gui/windows/chatwindow.cpp
parenta204d2b11e6a4b620877ab6c5b80a818eaa7d476 (diff)
downloadmv-31a4e17565b91b62fec057c10d3903310526c824.tar.gz
mv-31a4e17565b91b62fec057c10d3903310526c824.tar.bz2
mv-31a4e17565b91b62fec057c10d3903310526c824.tar.xz
mv-31a4e17565b91b62fec057c10d3903310526c824.zip
Impliment actual change direction actions from pet commands.
Diffstat (limited to 'src/gui/windows/chatwindow.cpp')
-rw-r--r--src/gui/windows/chatwindow.cpp47
1 files changed, 32 insertions, 15 deletions
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index 7f6c2e731..553deea70 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -1522,6 +1522,13 @@ bool ChatWindow::resortChatLog(std::string line,
if (parse2Int(line, x, y))
localPetMove(nick, x, y);
}
+ else if (line.find(": \302\202\302d") != std::string::npos)
+ {
+ const std::string nick = line.substr(0, idx2 - 1);
+ line = line.substr(idx2 + 6);
+ localPetDirection(nick, static_cast<BeingDirection::Type>(
+ atoi(line.c_str())));
+ }
// ignore other special message formats.
return false;
}
@@ -1667,31 +1674,41 @@ void ChatWindow::localPetSay(const std::string &nick, const std::string &text)
}
}
-void ChatWindow::localPetEmote(const std::string &nick, const uint8_t emoteId)
+static Being *getPetForNick(const std::string &nick)
{
Being *const being = actorManager->findBeingByName(
nick, ActorType::Player);
if (being)
- {
- Being *const pet = being->getFirstPet();
- if (pet)
- pet->setEmote(emoteId, 0);
- }
+ return being->getFirstPet();
+ return nullptr;
+}
+
+void ChatWindow::localPetEmote(const std::string &nick, const uint8_t emoteId)
+{
+ Being *const pet = getPetForNick(nick);
+ if (pet)
+ pet->setEmote(emoteId, 0);
}
void ChatWindow::localPetMove(const std::string &nick,
const int x, const int y)
{
- Being *const being = actorManager->findBeingByName(
- nick, ActorType::Player);
- if (being)
+ Being *const pet = getPetForNick(nick);
+ if (pet)
{
- Being *const pet = being->getFirstPet();
- if (pet)
- {
- pet->setDestination(x, y);
- pet->disablePetAi();
- }
+ pet->setDestination(x, y);
+ pet->disablePetAi();
+ }
+}
+
+void ChatWindow::localPetDirection(const std::string &nick,
+ BeingDirection::Type dir)
+{
+ Being *const pet = getPetForNick(nick);
+ if (pet)
+ {
+ pet->setDirection(dir);
+ pet->disablePetAi();
}
}