diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-04-05 19:17:33 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-04-05 19:17:33 -0600 |
commit | a0c7d1f61783e77e552896824855377e4bb43f8d (patch) | |
tree | e952181b83482abeffbd8ad9c62789b8f72e42e5 /src/net | |
parent | 9113afb868f6c1da5911437d3ddabdcf169cbec2 (diff) | |
download | mana-client-a0c7d1f61783e77e552896824855377e4bb43f8d.tar.gz mana-client-a0c7d1f61783e77e552896824855377e4bb43f8d.tar.bz2 mana-client-a0c7d1f61783e77e552896824855377e4bb43f8d.tar.xz mana-client-a0c7d1f61783e77e552896824855377e4bb43f8d.zip |
Implement TMWServ's NpcHandler
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/chathandler.h | 22 | ||||
-rw-r--r-- | src/net/ea/inventoryhandler.cpp | 4 | ||||
-rw-r--r-- | src/net/ea/npchandler.cpp | 6 | ||||
-rw-r--r-- | src/net/ea/npchandler.h | 4 | ||||
-rw-r--r-- | src/net/net.cpp | 16 | ||||
-rw-r--r-- | src/net/npchandler.h | 4 | ||||
-rw-r--r-- | src/net/tmwserv/buysellhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/tmwserv/inventoryhandler.cpp | 4 | ||||
-rw-r--r-- | src/net/tmwserv/inventoryhandler.h | 2 | ||||
-rw-r--r-- | src/net/tmwserv/npchandler.cpp | 75 | ||||
-rw-r--r-- | src/net/tmwserv/npchandler.h | 34 |
11 files changed, 140 insertions, 33 deletions
diff --git a/src/net/chathandler.h b/src/net/chathandler.h index 8e32313a..56707cd2 100644 --- a/src/net/chathandler.h +++ b/src/net/chathandler.h @@ -28,28 +28,28 @@ namespace Net { class ChatHandler { public: - virtual void talk(const std::string &text) {} + virtual void talk(const std::string &text) = 0; - virtual void me(const std::string &text) {} + virtual void me(const std::string &text) = 0; virtual void privateMessage(const std::string &recipient, - const std::string &text) {} + const std::string &text) = 0; - virtual void channelList() {} + virtual void channelList() = 0; - virtual void enterChannel(int channelId, const std::string &password) {} + virtual void enterChannel(int channelId, const std::string &password) = 0; - virtual void quitChannel(int channelId) {} + virtual void quitChannel(int channelId) = 0; - virtual void sendToChannel(int channelId, const std::string &text) {} + virtual void sendToChannel(int channelId, const std::string &text) = 0; - virtual void userList(int channelId) {} + virtual void userList(int channelId) = 0; - virtual void setChannelTopic(int channelId, const std::string &text) {} + virtual void setChannelTopic(int channelId, const std::string &text) = 0; - virtual void setUserMode(int channelId, const std::string &name, int mode) {} + virtual void setUserMode(int channelId, const std::string &name, int mode) = 0; - virtual void kickUser(int channelId, const std::string &name) {} + virtual void kickUser(int channelId, const std::string &name) = 0; }; } diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index e6658bbf..b4d05de2 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -45,12 +45,12 @@ #include <SDL_types.h> +Net::InventoryHandler *inventoryHandler; + namespace EAthena { enum { debugInventory = 1 }; -InventoryHandler *inventoryHandler; - InventoryHandler::InventoryHandler() { static const Uint16 _messages[] = { diff --git a/src/net/ea/npchandler.cpp b/src/net/ea/npchandler.cpp index 33e478cb..05313798 100644 --- a/src/net/ea/npchandler.cpp +++ b/src/net/ea/npchandler.cpp @@ -39,7 +39,9 @@ #include <SDL_types.h> -NpcHandler *npcHandler; +Net::NpcHandler *npcHandler; + +namespace EAthena { NpcHandler::NpcHandler() { @@ -208,3 +210,5 @@ void NpcHandler::endShopping(int beingId) { // TODO } + +} // namespace EAthena diff --git a/src/net/ea/npchandler.h b/src/net/ea/npchandler.h index 9ca83f11..557b97d9 100644 --- a/src/net/ea/npchandler.h +++ b/src/net/ea/npchandler.h @@ -26,6 +26,8 @@ #include "net/net.h" #include "net/npchandler.h" +namespace EAthena { + class NpcHandler : public MessageHandler, public Net::NpcHandler { public: @@ -61,6 +63,6 @@ class NpcHandler : public MessageHandler, public Net::NpcHandler void endShopping(int beingId); }; -extern NpcHandler *npcHandler; +} // namespace EAthena #endif // NET_EA_NPCHANDLER_H diff --git a/src/net/net.cpp b/src/net/net.cpp index 8921a954..2d894119 100644 --- a/src/net/net.cpp +++ b/src/net/net.cpp @@ -36,7 +36,9 @@ #include "net/tradehandler.h" #include "net/tmwserv/inventoryhandler.h" +#include "net/tmwserv/npchandler.h" #include "net/ea/inventoryhandler.h" +#include "net/ea/npchandler.h" #ifdef TMWSERV_SUPPORT #include "net/tmwserv/playerhandler.h" @@ -46,9 +48,8 @@ #include "net/ea/tradehandler.h" #endif -namespace EAthena { -extern InventoryHandler *inventoryHandler; -} +extern Net::InventoryHandler *inventoryHandler; +extern Net::NpcHandler *npcHandler; Net::AdminHandler *Net::getAdminHandler() { @@ -82,11 +83,7 @@ Net::GuildHandler *Net::getGuildHandler() Net::InventoryHandler *Net::getInventoryHandler() { -#ifdef TMWSERV_SUPPORT - return TmwServ::inventoryHandler; -#else - return EAthena::inventoryHandler; -#endif + return inventoryHandler; } Net::LoginHandler *Net::getLoginHandler() @@ -103,8 +100,7 @@ Net::MapHandler *Net::getMapHandler() Net::NpcHandler *Net::getNpcHandler() { - // TODO - return 0; + return npcHandler; } Net::PartyHandler *Net::getPartyHandler() diff --git a/src/net/npchandler.h b/src/net/npchandler.h index 1f211c41..e0199ebc 100644 --- a/src/net/npchandler.h +++ b/src/net/npchandler.h @@ -50,9 +50,9 @@ class NpcHandler virtual void sell(int beingId) = 0; - virtual void buyItem(int beingId, int itemId, int ammount) = 0; + virtual void buyItem(int beingId, int itemId, int amount) = 0; - virtual void sellItem(int beingId, int itemId, int ammount) = 0; + virtual void sellItem(int beingId, int itemId, int amount) = 0; virtual void endShopping(int beingId) = 0; }; diff --git a/src/net/tmwserv/buysellhandler.cpp b/src/net/tmwserv/buysellhandler.cpp index bab475d2..e6943ee0 100644 --- a/src/net/tmwserv/buysellhandler.cpp +++ b/src/net/tmwserv/buysellhandler.cpp @@ -84,7 +84,7 @@ void BuySellHandler::handleMessage(MessageIn &msg) int itemId = msg.readInt16(); int amount = msg.readInt16(); int value = msg.readInt16(); - sellDialog->addItem(itemId, amount, value); + sellDialog->addItem(new Item(itemId, amount, false), value); } break; } diff --git a/src/net/tmwserv/inventoryhandler.cpp b/src/net/tmwserv/inventoryhandler.cpp index f21c25a9..ac079846 100644 --- a/src/net/tmwserv/inventoryhandler.cpp +++ b/src/net/tmwserv/inventoryhandler.cpp @@ -37,10 +37,10 @@ #include "resources/iteminfo.h" -namespace TmwServ { - Net::InventoryHandler *inventoryHandler; +namespace TmwServ { + InventoryHandler::InventoryHandler() { static const Uint16 _messages[] = { diff --git a/src/net/tmwserv/inventoryhandler.h b/src/net/tmwserv/inventoryhandler.h index 38281e2a..c70b10c0 100644 --- a/src/net/tmwserv/inventoryhandler.h +++ b/src/net/tmwserv/inventoryhandler.h @@ -52,8 +52,6 @@ class InventoryHandler : public MessageHandler, Net::InventoryHandler StorageType destination); }; -extern Net::InventoryHandler *inventoryHandler; - } // namespace TmwServ #endif diff --git a/src/net/tmwserv/npchandler.cpp b/src/net/tmwserv/npchandler.cpp index 4acd2eee..63d341d7 100644 --- a/src/net/tmwserv/npchandler.cpp +++ b/src/net/tmwserv/npchandler.cpp @@ -23,6 +23,8 @@ #include "net/tmwserv/protocol.h" +#include "net/tmwserv/gameserver/player.h" + #include "net/messagein.h" #include "beingmanager.h" @@ -32,6 +34,10 @@ #include "gui/npcpostdialog.h" #include "gui/npc_text.h" +Net::NpcHandler *npcHandler; + +namespace TmwServ { + NpcHandler::NpcHandler() { static const Uint16 _messages[] = { @@ -42,6 +48,7 @@ NpcHandler::NpcHandler() 0 }; handledMessages = _messages; + npcHandler = this; } void NpcHandler::handleMessage(MessageIn &msg) @@ -81,3 +88,71 @@ void NpcHandler::handleMessage(MessageIn &msg) break; } } + +void NpcHandler::talk(int npcId) +{ + Net::GameServer::Player::talkToNPC(npcId, true); +} + +void NpcHandler::nextDialog(int npcId) +{ + Net::GameServer::Player::talkToNPC(npcId, false); +} + +void NpcHandler::closeDialog(int npcId) +{ + // TODO +} + +void NpcHandler::listInput(int npcId, int value) +{ + Net::GameServer::Player::selectFromNPC(npcId, value); +} + +void NpcHandler::integerInput(int npcId, int value) +{ + // TODO +} + +void NpcHandler::stringInput(int npcId, const std::string &value) +{ + // TODO +} + +void NpcHandler::sendLetter(int npcId, const std::string &recipient, + const std::string &text) +{ + Net::GameServer::Player::sendLetter(recipient, text); +} + +void NpcHandler::startShopping(int beingId) +{ + // TODO +} + +void NpcHandler::buy(int beingId) +{ + // TODO +} + +void NpcHandler::sell(int beingId) +{ + // TODO +} + +void NpcHandler::buyItem(int beingId, int itemId, int amount) +{ + Net::GameServer::Player::tradeWithNPC(itemId, amount); +} + +void NpcHandler::sellItem(int beingId, int itemId, int amount) +{ + Net::GameServer::Player::tradeWithNPC(itemId, amount); +} + +void NpcHandler::endShopping(int beingId) +{ + // TODO +} + +} // namespace TmwServ diff --git a/src/net/tmwserv/npchandler.h b/src/net/tmwserv/npchandler.h index c8ad738b..2c405e16 100644 --- a/src/net/tmwserv/npchandler.h +++ b/src/net/tmwserv/npchandler.h @@ -23,13 +23,45 @@ #define NET_TMWSERV_NPCHANDLER_H #include "net/messagehandler.h" +#include "net/npchandler.h" -class NpcHandler : public MessageHandler +namespace TmwServ { + +class NpcHandler : public MessageHandler, public Net::NpcHandler { public: NpcHandler(); void handleMessage(MessageIn &msg); + + void talk(int npcId); + + void nextDialog(int npcId); + + void closeDialog(int npcId); + + void listInput(int npcId, int value); + + void integerInput(int npcId, int value); + + void stringInput(int npcId, const std::string &value); + + void sendLetter(int npcId, const std::string &recipient, + const std::string &text); + + void startShopping(int beingId); + + void buy(int beingId); + + void sell(int beingId); + + void buyItem(int beingId, int itemId, int amount); + + void sellItem(int beingId, int itemId, int amount); + + void endShopping(int beingId); }; +} // namespace TmwServ + #endif |