From 7b2fbfb1f4384cb0e86d4c7cca81a526444d54b8 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 27 Dec 2013 19:21:37 +0300 Subject: add pet emote command. New chat command: /emotepet emote --- src/gui/windows/chatwindow.cpp | 22 +++++++++++++++++++++- src/gui/windows/chatwindow.h | 2 ++ 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'src/gui/windows') diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index d6bca3781..992932084 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -1479,9 +1479,17 @@ bool ChatWindow::resortChatLog(std::string line, Own own, const size_t idx = line.find(": \302\202"); if (idx == idx2) { - // ignore special message formats. if (line.find(": \302\202\302") != std::string::npos) + { + if (line.find(": \302\202\302e") != std::string::npos) + { + const std::string nick = line.substr(0, idx2 - 1); + line = line.substr(idx2 + 6); + localPetEmote(nick, atoi(line.c_str())); + } + // ignore other special message formats. return false; + } // pet talk message detected if (line.find(": \302\202\303 ") != std::string::npos) @@ -1587,6 +1595,18 @@ void ChatWindow::localPetSay(const std::string &nick, const std::string &text) } } +void ChatWindow::localPetEmote(const std::string &nick, const uint8_t emoteId) +{ + Being *const being = actorManager->findBeingByName( + nick, ActorSprite::PLAYER); + if (being) + { + Being *const pet = being->getPet(); + if (pet) + pet->setEmote(emoteId, 0); + } +} + void ChatWindow::initTradeFilter() { const std::string tradeListName = client->getServerConfigDirectory() diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index 8cda0fa84..64db4d1df 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -294,6 +294,8 @@ class ChatWindow final : public Window, void localPetSay(const std::string &nick, const std::string &text); + void localPetEmote(const std::string &nick, const uint8_t emoteId); + #ifdef USE_PROFILER void logicChildren(); #endif -- cgit v1.2.3-70-g09d2