summaryrefslogtreecommitdiff
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
parenta204d2b11e6a4b620877ab6c5b80a818eaa7d476 (diff)
downloadplus-31a4e17565b91b62fec057c10d3903310526c824.tar.gz
plus-31a4e17565b91b62fec057c10d3903310526c824.tar.bz2
plus-31a4e17565b91b62fec057c10d3903310526c824.tar.xz
plus-31a4e17565b91b62fec057c10d3903310526c824.zip
Impliment actual change direction actions from pet commands.
-rw-r--r--src/gui/windows/chatwindow.cpp47
-rw-r--r--src/gui/windows/chatwindow.h4
-rw-r--r--src/net/tmwa/pethandler.cpp2
3 files changed, 38 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();
}
}
diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h
index 1b22ee05f..bbc188c3a 100644
--- a/src/gui/windows/chatwindow.h
+++ b/src/gui/windows/chatwindow.h
@@ -23,6 +23,8 @@
#ifndef GUI_WINDOWS_CHATWINDOW_H
#define GUI_WINDOWS_CHATWINDOW_H
+#include "being/beingdirection.h"
+
#include "gui/chatmsgtype.h"
#include "gui/widgets/window.h"
@@ -300,6 +302,8 @@ class ChatWindow final : public Window,
static void localPetMove(const std::string &nick,
const int x, const int y);
+ static void localPetDirection(const std::string &nick,
+ BeingDirection::Type dir);
void postConnection();
#ifdef USE_PROFILER
diff --git a/src/net/tmwa/pethandler.cpp b/src/net/tmwa/pethandler.cpp
index 079caae37..982f3a861 100644
--- a/src/net/tmwa/pethandler.cpp
+++ b/src/net/tmwa/pethandler.cpp
@@ -107,6 +107,8 @@ void PetHandler::unequip() const
void PetHandler::setDirection(const BeingDirection::Type type) const
{
+ chatHandler->talk(strprintf("\302\202\302d%d",
+ static_cast<int>(type)), GENERAL_CHANNEL);
}
} // namespace TmwAthena