diff options
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/ea/beinghandler.cpp | 7 | ||||
-rw-r--r-- | src/net/ea/npchandler.cpp | 49 | ||||
-rw-r--r-- | src/net/ea/playerhandler.cpp | 12 | ||||
-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 |
7 files changed, 67 insertions, 62 deletions
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index 65d19040..1f5f79c7 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -35,12 +35,8 @@ #include "npc.h" #include "playerrelations.h" -#include "gui/npctextdialog.h" - #include <iostream> -extern NpcTextDialog *npcTextDialog; - namespace EAthena { const int EMOTION_TIME = 150; /**< Duration of emotion icon */ @@ -246,9 +242,6 @@ void BeingHandler::handleMessage(MessageIn &msg) // A being should be removed or has died id = msg.readInt32(); - if (id == current_npc) - npcTextDialog->showCloseButton(); - dstBeing = beingManager->findBeing(id); if (!dstBeing) diff --git a/src/net/ea/npchandler.cpp b/src/net/ea/npchandler.cpp index 5c41c380..16137476 100644 --- a/src/net/ea/npchandler.cpp +++ b/src/net/ea/npchandler.cpp @@ -32,10 +32,7 @@ #include "localplayer.h" #include "npc.h" -#include "gui/npctextdialog.h" -#include "gui/npcintegerdialog.h" -#include "gui/npclistdialog.h" -#include "gui/npcstringdialog.h" +#include "gui/npcdialog.h" #include <SDL_types.h> @@ -68,57 +65,58 @@ void NpcHandler::handleMessage(MessageIn &msg) msg.readInt16(); // length current_npc = msg.readInt32(); player_node->setAction(LocalPlayer::STAND); - npcListDialog->parseItems(msg.readString(msg.getLength() - 8)); - npcListDialog->setVisible(true); - npcListDialog->requestFocus(); + npcDialog->setNpc(current_npc); + npcDialog->choiceRequest(); + npcDialog->parseListItems(msg.readString(msg.getLength() - 8)); + npcDialog->setVisible(true); break; case SMSG_NPC_MESSAGE: msg.readInt16(); // length current_npc = msg.readInt32(); player_node->setAction(LocalPlayer::STAND); - npcTextDialog->addText(msg.readString(msg.getLength() - 8)); - npcTextDialog->setVisible(true); - npcTextDialog->requestFocus(); + npcDialog->setNpc(current_npc); + npcDialog->addText(msg.readString(msg.getLength() - 8)); + npcDialog->setVisible(true); break; case SMSG_NPC_CLOSE: id = msg.readInt32(); // If we're talking to that NPC, show the close button if (id == current_npc) - npcTextDialog->showCloseButton(); + npcDialog->showCloseButton(); // Otherwise, move on as an empty dialog doesn't help else - npcTextDialog->closeDialog(id); + npcDialog->closeDialog(); break; + /* Note: with the new dialog, we automaticilly assume "Next" case SMSG_NPC_NEXT: id = msg.readInt32(); // If we're talking to that NPC, show the next button - if (id == current_npc) - npcTextDialog->showNextButton(); + if (id == current_npc && dialog) + dialog->showNextButton(); // Otherwise, move on as an empty dialog doesn't help - else - npcTextDialog->nextDialog(id); + else if (dialog) + nextDialog(id); break; - + */ case SMSG_NPC_INT_INPUT: // Request for an integer current_npc = msg.readInt32(); player_node->setAction(LocalPlayer::STAND); - npcIntegerDialog->setRange(0, 2147483647); - npcIntegerDialog->setDefaultValue(0); - npcIntegerDialog->setVisible(true); - npcIntegerDialog->requestFocus(); + npcDialog->setNpc(current_npc); + npcDialog->integerRequest(0); + npcDialog->setVisible(true); break; case SMSG_NPC_STR_INPUT: // Request for a string current_npc = msg.readInt32(); player_node->setAction(LocalPlayer::STAND); - npcStringDialog->setValue(""); - npcStringDialog->setVisible(true); - npcStringDialog->requestFocus(); + npcDialog->setNpc(current_npc); + npcDialog->textRequest(""); + npcDialog->setVisible(true); break; } } @@ -140,6 +138,8 @@ void NpcHandler::closeDialog(int npcId) { MessageOut outMsg(CMSG_NPC_CLOSE); outMsg.writeInt32(npcId); + npcDialog->setText(""); + npcDialog->setVisible(false); } void NpcHandler::listInput(int npcId, int value) @@ -158,6 +158,7 @@ void NpcHandler::integerInput(int npcId, int value) void NpcHandler::stringInput(int npcId, const std::string &value) { + printf("I got a %s", value.c_str()); MessageOut outMsg(CMSG_NPC_STR_RESPONSE); outMsg.writeInt16(value.length() + 9); outMsg.writeInt32(npcId); diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index ef6edc87..3f8fbc09 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -35,10 +35,6 @@ #include "gui/buy.h" #include "gui/buysell.h" #include "gui/gui.h" -#include "gui/npctextdialog.h" -#include "gui/npcintegerdialog.h" -#include "gui/npclistdialog.h" -#include "gui/npcstringdialog.h" #include "gui/okdialog.h" #include "gui/sell.h" #include "gui/skill.h" @@ -81,14 +77,6 @@ namespace { { player_node->revive(); deathNotice = NULL; - npcIntegerDialog->reset(); - npcIntegerDialog->setVisible(false); - npcListDialog->reset(); - npcListDialog->setVisible(false); - npcStringDialog->setValue(""); - npcStringDialog->setVisible(false); - npcTextDialog->clearText(); - npcTextDialog->setVisible(false); buyDialog->setVisible(false); sellDialog->setVisible(false); buySellDialog->setVisible(false); 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, // - |