From 4e7669dd6e07658fa86878d1e64c482a094b3b19 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 28 Dec 2014 00:11:59 +0300 Subject: Add fake pet moving commands. Actual moving will be implimented after. --- src/actions/pets.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ src/actions/pets.h | 4 ++++ 2 files changed, 51 insertions(+) (limited to 'src/actions') diff --git a/src/actions/pets.cpp b/src/actions/pets.cpp index 30cfc9613..e30e7f529 100644 --- a/src/actions/pets.cpp +++ b/src/actions/pets.cpp @@ -62,6 +62,17 @@ namespace Actions { +static const Being *getPet() +{ + if (!localPlayer) + return nullptr; + + const std::vector &pets = localPlayer->getPets(); + if (pets.empty()) + return nullptr; + return *pets.begin(); +} + impHandler(commandEmotePet) { // need use actual pet id @@ -130,4 +141,40 @@ impHandler(catchPet) return true; } +impHandler0(petMoveUp) +{ + const Being *const pet = getPet(); + if (!pet) + return false; + petHandler->move(pet->getId(), pet->getTileX(), pet->getTileY() - 1); + return true; +} + +impHandler0(petMoveDown) +{ + const Being *const pet = getPet(); + if (!pet) + return false; + petHandler->move(pet->getId(), pet->getTileX(), pet->getTileY() + 1); + return true; +} + +impHandler0(petMoveLeft) +{ + const Being *const pet = getPet(); + if (!pet) + return false; + petHandler->move(pet->getId(), pet->getTileX() - 1, pet->getTileY()); + return true; +} + +impHandler0(petMoveRight) +{ + const Being *const pet = getPet(); + if (!pet) + return false; + petHandler->move(pet->getId(), pet->getTileX() + 1, pet->getTileY()); + return true; +} + } // namespace Actions diff --git a/src/actions/pets.h b/src/actions/pets.h index e0521b546..37bd85713 100644 --- a/src/actions/pets.h +++ b/src/actions/pets.h @@ -32,6 +32,10 @@ namespace Actions decHandler(setPetName); decHandler(petEmote); decHandler(catchPet); + decHandler(petMoveUp); + decHandler(petMoveDown); + decHandler(petMoveLeft); + decHandler(petMoveRight); } // namespace Actions #undef decHandler -- cgit v1.2.3-70-g09d2