summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/being/being.cpp9
-rw-r--r--src/being/being.h7
-rw-r--r--src/gui/windows/chatwindow.cpp25
-rw-r--r--src/gui/windows/chatwindow.h3
-rw-r--r--src/net/tmwa/pethandler.cpp3
5 files changed, 45 insertions, 2 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 289f49411..b5c317ac4 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -211,7 +211,8 @@ Being::Being(const int id,
mShop(false),
mAway(false),
mInactive(false),
- mNeedPosUpdate(true)
+ mNeedPosUpdate(true),
+ mPetAi(true)
{
for (int f = 0; f < 20; f ++)
{
@@ -1590,9 +1591,12 @@ void Being::petLogic()
fixPetSpawnPos(dstX, dstY);
setTileCoords(dstX, dstY);
petHandler->spawn(mOwner, mId, dstX, dstY);
+ mPetAi = true;
}
else if (!followDist || divX > followDist || divY > followDist)
{
+ if (!mPetAi)
+ return;
if (!dist)
{
fixPetSpawnPos(dstX, dstY);
@@ -1645,6 +1649,9 @@ void Being::petLogic()
return;
}
}
+ if (!mPetAi)
+ return;
+
if (mOwner->getCurrentAction() != BeingAction::ATTACK)
{
if (mAction == BeingAction::ATTACK)
diff --git a/src/being/being.h b/src/being/being.h
index a194bac72..119bcc637 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -920,6 +920,12 @@ class Being notfinal : public ActorSprite,
int getManner() const
{ return mManner; }
+ void disablePetAi()
+ { mPetAi = false; }
+
+ void enablePetAi()
+ { mPetAi = true; }
+
protected:
/**
* Updates name's location.
@@ -1098,6 +1104,7 @@ class Being notfinal : public ActorSprite,
bool mAway;
bool mInactive;
bool mNeedPosUpdate;
+ bool mPetAi;
};
extern std::list<BeingCacheEntry*> beingInfoCache;
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index 524256dd4..7f6c2e731 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -1513,6 +1513,15 @@ bool ChatWindow::resortChatLog(std::string line,
localPetEmote(nick, static_cast<uint8_t>(
atoi(line.c_str())));
}
+ else if (line.find(": \302\202\302m") != std::string::npos)
+ {
+ const std::string nick = line.substr(0, idx2 - 1);
+ line = line.substr(idx2 + 6);
+ int x = 0;
+ int y = 0;
+ if (parse2Int(line, x, y))
+ localPetMove(nick, x, y);
+ }
// ignore other special message formats.
return false;
}
@@ -1670,6 +1679,22 @@ void ChatWindow::localPetEmote(const std::string &nick, const uint8_t emoteId)
}
}
+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 = being->getFirstPet();
+ if (pet)
+ {
+ pet->setDestination(x, y);
+ pet->disablePetAi();
+ }
+ }
+}
+
void ChatWindow::initTradeFilter()
{
const std::string tradeListName = settings.serverConfigDir
diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h
index a6bf15384..1b22ee05f 100644
--- a/src/gui/windows/chatwindow.h
+++ b/src/gui/windows/chatwindow.h
@@ -297,6 +297,9 @@ class ChatWindow final : public Window,
static void localPetEmote(const std::string &nick,
const uint8_t emoteId);
+ static void localPetMove(const std::string &nick,
+ const int x, const int y);
+
void postConnection();
#ifdef USE_PROFILER
diff --git a/src/net/tmwa/pethandler.cpp b/src/net/tmwa/pethandler.cpp
index eba2f4093..0156ef7c2 100644
--- a/src/net/tmwa/pethandler.cpp
+++ b/src/net/tmwa/pethandler.cpp
@@ -52,8 +52,9 @@ void PetHandler::handleMessage(Net::MessageIn &msg A_UNUSED)
}
void PetHandler::move(const int petId A_UNUSED,
- const int x A_UNUSED, const int y A_UNUSED) const
+ const int x, const int y) const
{
+ chatHandler->talk(strprintf("\302\202\302m%d %d", x, y), GENERAL_CHANNEL);
}
void PetHandler::spawn(const Being *const being A_UNUSED,