From a5e3d86efb85bb2a65e160972cc56e89cd764453 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 28 Dec 2014 19:36:50 +0300 Subject: Add chat command for stop and start pet ai. --- src/gui/windows/chatwindow.cpp | 18 ++++++++++++++++++ src/gui/windows/chatwindow.h | 4 ++++ 2 files changed, 22 insertions(+) (limited to 'src/gui') diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 553deea70..a707ac8c4 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -1529,6 +1529,12 @@ bool ChatWindow::resortChatLog(std::string line, localPetDirection(nick, static_cast( atoi(line.c_str()))); } + else if (line.find(": \302\202\302a") != std::string::npos) + { + const std::string nick = line.substr(0, idx2 - 1); + line = line.substr(idx2 + 6); + localPetAi(nick, atoi(line.c_str()) ? true : false); + } // ignore other special message formats. return false; } @@ -1690,6 +1696,18 @@ void ChatWindow::localPetEmote(const std::string &nick, const uint8_t emoteId) pet->setEmote(emoteId, 0); } +void ChatWindow::localPetAi(const std::string &nick, const bool start) +{ + Being *const pet = getPetForNick(nick); + if (pet) + { + if (start) + pet->enablePetAi(); + else + pet->disablePetAi(); + } +} + void ChatWindow::localPetMove(const std::string &nick, const int x, const int y) { diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index bbc188c3a..9455557dd 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -304,6 +304,10 @@ class ChatWindow final : public Window, static void localPetDirection(const std::string &nick, BeingDirection::Type dir); + + static void localPetAi(const std::string &nick, + const bool start); + void postConnection(); #ifdef USE_PROFILER -- cgit v1.2.3-70-g09d2