diff options
Diffstat (limited to 'src/net/tmwserv')
-rw-r--r-- | src/net/tmwserv/npchandler.cpp | 48 | ||||
-rw-r--r-- | src/net/tmwserv/npchandler.h | 2 | ||||
-rw-r--r-- | src/net/tmwserv/playerhandler.cpp | 6 | ||||
-rw-r--r-- | src/net/tmwserv/protocol.h | 5 |
4 files changed, 42 insertions, 19 deletions
diff --git a/src/net/tmwserv/npchandler.cpp b/src/net/tmwserv/npchandler.cpp index 20a13ec2..9447e2f8 100644 --- a/src/net/tmwserv/npchandler.cpp +++ b/src/net/tmwserv/npchandler.cpp @@ -33,9 +33,8 @@ #include "beingmanager.h" #include "npc.h" -#include "gui/npclistdialog.h" #include "gui/npcpostdialog.h" -#include "gui/npctextdialog.h" +#include "gui/npcdialog.h" Net::NpcHandler *npcHandler; @@ -48,6 +47,7 @@ NpcHandler::NpcHandler() GPMSG_NPC_POST, GPMSG_NPC_MESSAGE, GPMSG_NPC_ERROR, + GPMSG_NPC_CLOSE, 0 }; handledMessages = _messages; @@ -63,31 +63,43 @@ void NpcHandler::handleMessage(MessageIn &msg) } current_npc = being->getId(); + npcDialog->setNpc(current_npc); switch (msg.getId()) { case GPMSG_NPC_CHOICE: - npcListDialog->reset(); + npcDialog->choiceRequest(); while (msg.getUnreadLength()) { - npcListDialog->addItem(msg.readString()); + npcDialog->addChoice(msg.readString()); } - npcListDialog->setVisible(true); break; + case GPMSG_NPC_NUMBER: + { + int min_num = msg.readInt32(); + int max_num = msg.readInt32(); + npcDialog->integerRequest(msg.readInt32(), min_num, max_num); + break; + } + case GPMSG_NPC_POST: - npcTextDialog->setVisible(false); + npcDialog->setVisible(false); npcPostDialog->clear(); npcPostDialog->setVisible(true); break; case GPMSG_NPC_ERROR: current_npc = NULL; + break; + case GPMSG_NPC_MESSAGE: - npcTextDialog->addText(msg.readString(msg.getUnreadLength())); - npcListDialog->setVisible(false); - npcTextDialog->setVisible(true); - npcPostDialog->setVisible(false); + npcDialog->addText(msg.readString(msg.getUnreadLength())); + npcDialog->setVisible(true); + break; + + case GPMSG_NPC_CLOSE: + npcDialog->showCloseButton(); break; } } @@ -108,7 +120,11 @@ void NpcHandler::nextDialog(int npcId) void NpcHandler::closeDialog(int npcId) { - // TODO + MessageOut msg(PGMSG_NPC_TALK_NEXT); + msg.writeInt16(npcId); + Net::GameServer::connection->send(msg); + npcDialog->setVisible(false); + npcDialog->setText(""); } void NpcHandler::listInput(int npcId, int value) @@ -121,12 +137,18 @@ void NpcHandler::listInput(int npcId, int value) void NpcHandler::integerInput(int npcId, int value) { - // TODO + MessageOut msg(PGMSG_NPC_NUMBER); + msg.writeInt16(npcId); + msg.writeInt32(value); + Net::GameServer::connection->send(msg); } void NpcHandler::stringInput(int npcId, const std::string &value) { - // TODO + MessageOut msg(PGMSG_NPC_STRING); + msg.writeInt16(npcId); + msg.writeString(value); + Net::GameServer::connection->send(msg); } void NpcHandler::sendLetter(int npcId, const std::string &recipient, diff --git a/src/net/tmwserv/npchandler.h b/src/net/tmwserv/npchandler.h index 2c405e16..2bf953c0 100644 --- a/src/net/tmwserv/npchandler.h +++ b/src/net/tmwserv/npchandler.h @@ -25,6 +25,8 @@ #include "net/messagehandler.h" #include "net/npchandler.h" +#include <list> + namespace TmwServ { class NpcHandler : public MessageHandler, public Net::NpcHandler diff --git a/src/net/tmwserv/playerhandler.cpp b/src/net/tmwserv/playerhandler.cpp index e2b5cec4..c7769ede 100644 --- a/src/net/tmwserv/playerhandler.cpp +++ b/src/net/tmwserv/playerhandler.cpp @@ -40,8 +40,6 @@ #include "gui/buy.h" #include "gui/chat.h" #include "gui/gui.h" -#include "gui/npclistdialog.h" -#include "gui/npctextdialog.h" #include "gui/okdialog.h" #include "gui/sell.h" #include "gui/skill.h" @@ -51,8 +49,6 @@ OkDialog *weightNotice = NULL; OkDialog *deathNotice = NULL; -extern NpcListDialog *npcListDialog; -extern NpcTextDialog *npcTextDialog; extern BuyDialog *buyDialog; extern SellDialog *sellDialog; extern Window *buySellDialog; @@ -87,8 +83,6 @@ namespace { { player_node->revive(); deathNotice = NULL; - npcListDialog->setVisible(false); - npcTextDialog->setVisible(false); buyDialog->setVisible(false); sellDialog->setVisible(false); current_npc = 0; diff --git a/src/net/tmwserv/protocol.h b/src/net/tmwserv/protocol.h index fc52bd57..7fa3b372 100644 --- a/src/net/tmwserv/protocol.h +++ b/src/net/tmwserv/protocol.h @@ -120,9 +120,14 @@ enum { GPMSG_NPC_SELL = 0x02B6, // W being id, { W item id, W amount, W cost }* PGMSG_NPC_BUYSELL = 0x02B7, // W item id, W amount GPMSG_NPC_ERROR = 0x02B8, // B error + GPMSG_NPC_CLOSE = 0x02B9, // W being id GPMSG_NPC_POST = 0x02D0, // W being id PGMSG_NPC_POST_SEND = 0x02D1, // S name, S text, W item id GPMSG_NPC_POST_GET = 0x02D2, // W being id, { S name, S text, W item id } + PGMSG_NPC_NUMBER = 0x02D3, // W being id, L number + PGMSG_NPC_STRING = 0x02D4, // W being id, S string + GPMSG_NPC_NUMBER = 0x02D5, // W being id, L max, L min, L default + GPMSG_NPC_STRING = 0x02D6, // W being id PGMSG_TRADE_REQUEST = 0x02C0, // W being id GPMSG_TRADE_REQUEST = 0x02C1, // W being id GPMSG_TRADE_START = 0x02C2, // - |