diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-12-09 15:26:27 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-12-09 15:26:27 +0300 |
commit | 6737c33ffb89262a76bee80cdc9afeeebddbc2f7 (patch) | |
tree | 561ff4493ec0b49bb88ff4d9ee66f989ed2a1d0d | |
parent | 7dcc42c841005c5e475bfcb37e78bc7bc15b4a9d (diff) | |
download | mv-6737c33ffb89262a76bee80cdc9afeeebddbc2f7.tar.gz mv-6737c33ffb89262a76bee80cdc9afeeebddbc2f7.tar.bz2 mv-6737c33ffb89262a76bee80cdc9afeeebddbc2f7.tar.xz mv-6737c33ffb89262a76bee80cdc9afeeebddbc2f7.zip |
move buy and sell actions from commands.c to actions.c file.
-rw-r--r-- | src/actions/actions.cpp | 65 | ||||
-rw-r--r-- | src/actions/actions.h | 2 | ||||
-rw-r--r-- | src/actions/commands.cpp | 65 | ||||
-rw-r--r-- | src/actions/commands.h | 2 |
4 files changed, 67 insertions, 67 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp index 64d05f8ab..f86b08a88 100644 --- a/src/actions/actions.cpp +++ b/src/actions/actions.cpp @@ -62,11 +62,13 @@ #endif #include "net/beinghandler.h" +#include "net/buysellhandler.h" #include "net/chathandler.h" #include "net/download.h" #include "net/gamehandler.h" #include "net/ipc.h" #include "net/mercenaryhandler.h" +#include "net/npchandler.h" #include "net/pethandler.h" #include "net/playerhandler.h" #include "net/uploadcharinfo.h" @@ -157,6 +159,31 @@ static void uploadFile(const std::string &str, upload->start(); } +static Being *findBeing(const std::string &name) +{ + Being *being = nullptr; + if (name.empty()) + { + being = localPlayer->getTarget(); + } + else + { + being = actorManager->findBeingByName( + name, ActorType::Unknown); + } + if (!being) + { + being = actorManager->findNearestLivingBeing( + localPlayer, 1, ActorType::Npc, true); + } + if (!being) + { + being = actorManager->findNearestLivingBeing( + localPlayer, 1, ActorType::Player, true); + } + return being; +} + impHandler(emote) { const int emotion = 1 + event.action - InputAction::EMOTE_1; @@ -430,6 +457,44 @@ impHandler0(ignoreInput) return true; } +impHandler(buy) +{ + Being *being = findBeing(event.args); + if (!being) + return false; + + if (being->getType() == ActorType::Npc) + { + npcHandler->buy(being->getId()); + return true; + } + else if (being->getType() == ActorType::Player) + { + buySellHandler->requestSellList(being->getName()); + return true; + } + return false; +} + +impHandler(sell) +{ + Being *being = findBeing(event.args); + if (!being) + return false; + + if (being->getType() == ActorType::Npc) + { + npcHandler->sell(being->getId()); + return true; + } + else if (being->getType() == ActorType::Player) + { + buySellHandler->requestBuyList(being->getName()); + return true; + } + return false; +} + impHandler0(talk) { if (localPlayer) diff --git a/src/actions/actions.h b/src/actions/actions.h index ed8cf980c..c614f61c7 100644 --- a/src/actions/actions.h +++ b/src/actions/actions.h @@ -48,6 +48,8 @@ namespace Actions decHandler(screenshot); decHandler(ignoreInput); decHandler(talk); + decHandler(buy); + decHandler(sell); decHandler(stopAttack); decHandler(untarget); decHandler(attack); diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp index eafd0b82b..c8d4f2b21 100644 --- a/src/actions/commands.cpp +++ b/src/actions/commands.cpp @@ -37,11 +37,9 @@ #include "gui/widgets/tabs/chat/whispertab.h" #include "net/adminhandler.h" -#include "net/buysellhandler.h" #include "net/chathandler.h" #include "net/guildhandler.h" #include "net/homunculushandler.h" -#include "net/npchandler.h" #include "net/pethandler.h" #include "net/serverfeatures.h" @@ -713,67 +711,4 @@ impHandler0(fireHomunculus) return true; } -static Being *findBeing(const std::string &name) -{ - Being *being = nullptr; - if (name.empty()) - { - being = localPlayer->getTarget(); - } - else - { - being = actorManager->findBeingByName( - name, ActorType::Unknown); - } - if (!being) - { - being = actorManager->findNearestLivingBeing( - localPlayer, 1, ActorType::Npc, true); - } - if (!being) - { - being = actorManager->findNearestLivingBeing( - localPlayer, 1, ActorType::Player, true); - } - return being; -} - -impHandler(buy) -{ - Being *being = findBeing(event.args); - if (!being) - return false; - - if (being->getType() == ActorType::Npc) - { - npcHandler->buy(being->getId()); - return true; - } - else if (being->getType() == ActorType::Player) - { - buySellHandler->requestSellList(being->getName()); - return true; - } - return false; -} - -impHandler(sell) -{ - Being *being = findBeing(event.args); - if (!being) - return false; - - if (being->getType() == ActorType::Npc) - { - npcHandler->sell(being->getId()); - return true; - } - else if (being->getType() == ActorType::Player) - { - buySellHandler->requestBuyList(being->getName()); - return true; - } - return false; -} - } // namespace Actions diff --git a/src/actions/commands.h b/src/actions/commands.h index 8f55b023e..085b89663 100644 --- a/src/actions/commands.h +++ b/src/actions/commands.h @@ -76,8 +76,6 @@ namespace Actions decHandler(setPetName); decHandler(setHomunculusName); decHandler(fireHomunculus); - decHandler(buy); - decHandler(sell); } // namespace Actions #undef decHandler |