summaryrefslogtreecommitdiff
path: root/src/net/manaserv/npchandler.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-08-12 19:43:51 -0600
committerJared Adams <jaxad0127@gmail.com>2010-08-12 20:07:04 -0600
commit2293b1c5ef0bb7378140bf73f1fef03a4504bdd2 (patch)
treeb3df7512fd0e48e8b1b3a0ed3cbd6d5e9d149ad2 /src/net/manaserv/npchandler.cpp
parent71595e5db41f503f06401c59090748b46e9731f0 (diff)
downloadmana-2293b1c5ef0bb7378140bf73f1fef03a4504bdd2.tar.gz
mana-2293b1c5ef0bb7378140bf73f1fef03a4504bdd2.tar.bz2
mana-2293b1c5ef0bb7378140bf73f1fef03a4504bdd2.tar.xz
mana-2293b1c5ef0bb7378140bf73f1fef03a4504bdd2.zip
Replace most of Net::NpcHandler with events
Reviewed-by: Chuck Miller
Diffstat (limited to 'src/net/manaserv/npchandler.cpp')
-rw-r--r--src/net/manaserv/npchandler.cpp97
1 files changed, 46 insertions, 51 deletions
diff --git a/src/net/manaserv/npchandler.cpp b/src/net/manaserv/npchandler.cpp
index 09dccffe..9f63c837 100644
--- a/src/net/manaserv/npchandler.cpp
+++ b/src/net/manaserv/npchandler.cpp
@@ -51,6 +51,8 @@ NpcHandler::NpcHandler()
};
handledMessages = _messages;
npcHandler = this;
+
+ Mana::EventManager::bind(this, "NPC");
}
void NpcHandler::handleMessage(Net::MessageIn &msg)
@@ -127,58 +129,51 @@ void NpcHandler::handleMessage(Net::MessageIn &msg)
delete event;
}
-void NpcHandler::talk(int npcId)
-{
- MessageOut msg(PGMSG_NPC_TALK);
- msg.writeInt16(npcId);
- gameServerConnection->send(msg);
-}
-
-void NpcHandler::nextDialog(int npcId)
-{
- MessageOut msg(PGMSG_NPC_TALK_NEXT);
- msg.writeInt16(npcId);
- gameServerConnection->send(msg);
-}
-
-void NpcHandler::closeDialog(int npcId)
-{
- MessageOut msg(PGMSG_NPC_TALK_NEXT);
- msg.writeInt16(npcId);
- gameServerConnection->send(msg);
-}
-
-void NpcHandler::listInput(int npcId, int value)
-{
- MessageOut msg(PGMSG_NPC_SELECT);
- msg.writeInt16(npcId);
- msg.writeInt8(value);
- gameServerConnection->send(msg);
-}
-
-void NpcHandler::integerInput(int npcId, int value)
-{
- MessageOut msg(PGMSG_NPC_NUMBER);
- msg.writeInt16(npcId);
- msg.writeInt32(value);
- gameServerConnection->send(msg);
-}
-
-void NpcHandler::stringInput(int npcId, const std::string &value)
-{
- MessageOut msg(PGMSG_NPC_STRING);
- msg.writeInt16(npcId);
- msg.writeString(value);
- gameServerConnection->send(msg);
-}
-
-void NpcHandler::sendLetter(int npcId, const std::string &recipient,
- const std::string &text)
+void NpcHandler::event(const std::string &channel, const Mana::Event &event)
{
- MessageOut msg(PGMSG_NPC_POST_SEND);
- msg.writeString(recipient);
- msg.writeString(text);
- gameServerConnection->send(msg);
+ if (channel == "NPC")
+ {
+ if (event.getName() == "doTalk")
+ {
+ MessageOut msg(PGMSG_NPC_TALK);
+ msg.writeInt16(event.getInt("npcId"));
+ gameServerConnection->send(msg);
+ }
+ else if (event.getName() == "doNext" || event.getName() == "doClose")
+ {
+ MessageOut msg(PGMSG_NPC_TALK_NEXT);
+ msg.writeInt16(event.getInt("npcId"));
+ gameServerConnection->send(msg);
+ }
+ else if (event.getName() == "doMenu")
+ {
+ MessageOut msg(PGMSG_NPC_SELECT);
+ msg.writeInt16(event.getInt("npcId"));
+ msg.writeInt8(event.getInt("choice"));
+ gameServerConnection->send(msg);
+ }
+ else if (event.getName() == "doIntegerInput")
+ {
+ MessageOut msg(PGMSG_NPC_NUMBER);
+ msg.writeInt16(event.getInt("npcId"));
+ msg.writeInt32(event.getInt("value"));
+ gameServerConnection->send(msg);
+ }
+ else if (event.getName() == "doStringInput")
+ {
+ MessageOut msg(PGMSG_NPC_STRING);
+ msg.writeInt16(event.getInt("npcId"));
+ msg.writeString(event.getString("value"));
+ gameServerConnection->send(msg);
+ }
+ else if (event.getName() == "doSendLetter")
+ {
+ MessageOut msg(PGMSG_NPC_POST_SEND);
+ msg.writeString(event.getString("recipient"));
+ msg.writeString(event.getString("text"));
+ gameServerConnection->send(msg);
+ }
+ }
}
void NpcHandler::startShopping(int beingId)