From 752c00b3e14478ebfc243938ed0bfd3af0a05f58 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 22 Feb 2015 15:00:14 +0300 Subject: eathena: add packet CMSG_PET_MOVE_TO 0x0b11. --- src/actions/pets.cpp | 17 ++++++++--------- src/net/eathena/pethandler.cpp | 9 ++++++++- src/net/eathena/protocol.h | 1 + 3 files changed, 17 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/actions/pets.cpp b/src/actions/pets.cpp index 2247e0533..2b3f6dfb8 100644 --- a/src/actions/pets.cpp +++ b/src/actions/pets.cpp @@ -124,7 +124,7 @@ impHandler0(petMoveUp) const Being *const pet = getPet(); if (!pet) return false; - petHandler->move(pet->getId(), pet->getTileX(), pet->getTileY() - 1); + petHandler->move(0, pet->getTileX(), pet->getTileY() - 1); return true; } @@ -133,7 +133,7 @@ impHandler0(petMoveDown) const Being *const pet = getPet(); if (!pet) return false; - petHandler->move(pet->getId(), pet->getTileX(), pet->getTileY() + 1); + petHandler->move(0, pet->getTileX(), pet->getTileY() + 1); return true; } @@ -142,7 +142,7 @@ impHandler0(petMoveLeft) const Being *const pet = getPet(); if (!pet) return false; - petHandler->move(pet->getId(), pet->getTileX() - 1, pet->getTileY()); + petHandler->move(0, pet->getTileX() - 1, pet->getTileY()); return true; } @@ -151,12 +151,15 @@ impHandler0(petMoveRight) const Being *const pet = getPet(); if (!pet) return false; - petHandler->move(pet->getId(), pet->getTileX() + 1, pet->getTileY()); + petHandler->move(0, pet->getTileX() + 1, pet->getTileY()); return true; } impHandler0(petDirectUp) { + const Being *const pet = getPet(); + if (!pet) + return false; petHandler->setDirection(BeingDirection::UP); return true; } @@ -193,16 +196,12 @@ impHandler0(petAiStop) impHandler0(petMove) { - const Being *const pet = getPet(); - if (!pet) - return false; - int x = 0; int y = 0; if (parse2Int(event.args, x, y)) { - petHandler->move(pet->getId(), x, y); + petHandler->move(0, x, y); return true; } return false; diff --git a/src/net/eathena/pethandler.cpp b/src/net/eathena/pethandler.cpp index 6d1167198..6218da7a1 100644 --- a/src/net/eathena/pethandler.cpp +++ b/src/net/eathena/pethandler.cpp @@ -36,6 +36,7 @@ #include "net/chathandler.h" #include "net/inventoryhandler.h" +#include "net/serverfeatures.h" #include "net/ea/eaprotocol.h" @@ -109,8 +110,14 @@ void PetHandler::handleMessage(Net::MessageIn &msg) } 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 { + if (!serverFeatures->haveMovePet()) + return; + createOutPacket(CMSG_PET_MOVE_TO); + outMsg.writeInt32(0, "pet id"); + outMsg.writeInt16(x, "x"); + outMsg.writeInt16(y, "y"); } void PetHandler::spawn(const Being *const being A_UNUSED, diff --git a/src/net/eathena/protocol.h b/src/net/eathena/protocol.h index a9ab76092..9f5cdfd7e 100644 --- a/src/net/eathena/protocol.h +++ b/src/net/eathena/protocol.h @@ -515,6 +515,7 @@ #define CMSG_PET_MENU_ACTION 0x01a1 #define CMSG_PET_TALK 0x0b0c #define CMSG_PET_EMOTE 0x0b0d +#define CMSG_PET_MOVE_TO 0x0b11 #define CMSG_MERCENARY_ACTION 0x029f #define CMSG_HOMUNCULUS_SET_NAME 0x0231 -- cgit v1.2.3-60-g2f50