summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-03-31 15:11:26 -0600
committerJared Adams <jaxad0127@gmail.com>2009-03-31 15:11:26 -0600
commit37432edac65a6b85c7a3414a421f2afd3e67a14e (patch)
treea4dc561371fab9d1800aec72960d7f86a1e88135
parent2c5f308192d18b5447a5b0e2ee3428984c1f1b78 (diff)
downloadmana-client-37432edac65a6b85c7a3414a421f2afd3e67a14e.tar.gz
mana-client-37432edac65a6b85c7a3414a421f2afd3e67a14e.tar.bz2
mana-client-37432edac65a6b85c7a3414a421f2afd3e67a14e.tar.xz
mana-client-37432edac65a6b85c7a3414a421f2afd3e67a14e.zip
Add first draft of net handlers
eAthena NPC handler has been implemented and is being used for NPC interraction.
-rw-r--r--src/gui/buy.cpp9
-rw-r--r--src/gui/buysell.cpp14
-rw-r--r--src/gui/npc_text.cpp11
-rw-r--r--src/gui/npcintegerdialog.cpp8
-rw-r--r--src/gui/npclistdialog.cpp8
-rw-r--r--src/gui/npcstringdialog.cpp10
-rw-r--r--src/gui/sell.cpp9
-rw-r--r--src/net/adminhandler.h53
-rw-r--r--src/net/charhandler.h40
-rw-r--r--src/net/chathandler.h56
-rw-r--r--src/net/ea/npchandler.cpp78
-rw-r--r--src/net/ea/npchandler.h25
-rw-r--r--src/net/generalhandler.h35
-rw-r--r--src/net/guildhandler.h57
-rw-r--r--src/net/inventoryhandler.h60
-rw-r--r--src/net/loginhandler.h46
-rw-r--r--src/net/maphandler.h41
-rw-r--r--src/net/net.h67
-rw-r--r--src/net/npchandler.h60
-rw-r--r--src/net/partyhandler.h53
-rw-r--r--src/net/playerhandler.h58
-rw-r--r--src/net/skillhandler.h38
-rw-r--r--src/net/tradehandler.h51
-rw-r--r--src/npc.cpp9
24 files changed, 846 insertions, 50 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp
index 6d336e4c..7cefa3e5 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -37,8 +37,7 @@
#ifdef TMWSERV_SUPPORT
#include "net/tmwserv/gameserver/player.h"
#else
-#include "net/messageout.h"
-#include "net/ea/protocol.h"
+#include "net/ea/npchandler.h"
#endif
#include "resources/iteminfo.h"
@@ -188,14 +187,12 @@ void BuyDialog::action(const gcn::ActionEvent &event)
else if (event.getId() == "buy" && mAmountItems > 0 &&
mAmountItems <= mMaxItems)
{
+ // Net::getNpcHandler()->buyItem(current_npc, mShopItems->at(selectedItem)->getId(), mAmountItems);
#ifdef TMWSERV_SUPPORT
Net::GameServer::Player::tradeWithNPC
(mShopItems->at(selectedItem)->getId(), mAmountItems);
#else
- MessageOut outMsg(CMSG_NPC_BUY_REQUEST);
- outMsg.writeInt16(8);
- outMsg.writeInt16(mAmountItems);
- outMsg.writeInt16(mShopItems->at(selectedItem)->getId());
+ npcHandler->buyItem(current_npc, mShopItems->at(selectedItem)->getId(), mAmountItems);
#endif
// Update money and adjust the max number of items that can be bought
diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp
index a0e2fc93..33e12e87 100644
--- a/src/gui/buysell.cpp
+++ b/src/gui/buysell.cpp
@@ -25,8 +25,7 @@
#include "gui/button.h"
-#include "net/messageout.h"
-#include "net/ea/protocol.h"
+#include "net/ea/npchandler.h"
#include "utils/gettext.h"
@@ -77,25 +76,22 @@ void BuySellDialog::setVisible(bool visible)
void BuySellDialog::action(const gcn::ActionEvent &event)
{
setVisible(false);
- int action = 0;
NPC::isTalking = false;
if (event.getId() == "Buy")
{
- action = 0;
+ // Net::getNpcHandler()->buy(current_npc);
+ npcHandler->buy(current_npc);
}
else if (event.getId() == "Sell")
{
- action = 1;
+ // Net::getNpcHandler()->buy(current_npc);
+ npcHandler->sell(current_npc);
}
else if (event.getId() == "Cancel")
{
current_npc = 0;
return;
}
-
- MessageOut outMsg(CMSG_NPC_BUY_SELL_REQUEST);
- outMsg.writeInt32(current_npc);
- outMsg.writeInt8(action);
}
diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp
index 31f48486..b33b9970 100644
--- a/src/gui/npc_text.cpp
+++ b/src/gui/npc_text.cpp
@@ -28,11 +28,10 @@
#include "../npc.h"
-#include "../net/messageout.h"
#ifdef TMWSERV_SUPPORT
#include "../net/tmwserv/gameserver/player.h"
#else
-#include "../net/ea/protocol.h"
+#include "../net/ea/npchandler.h"
#endif
#include "../utils/gettext.h"
@@ -126,19 +125,19 @@ void NpcTextDialog::action(const gcn::ActionEvent &event)
void NpcTextDialog::nextDialog(int npcID)
{
+ // Net::getNpcHandler()->nextDialog(npcID);
#ifdef TMWSERV_SUPPORT
Net::GameServer::Player::talkToNPC(npcID, false);
#else
- MessageOut outMsg(CMSG_NPC_NEXT_REQUEST);
- outMsg.writeInt32(npcID);
+ npcHandler->nextDialog(npcID);
#endif
}
void NpcTextDialog::closeDialog(int npcID)
{
+ // Net::getNpcHandler()->closeDialog(npcID);
#ifdef EATHENA_SUPPORT
- MessageOut outMsg(CMSG_NPC_CLOSE);
- outMsg.writeInt32(npcID);
+ npcHandler->closeDialog(npcID);
#endif
}
diff --git a/src/gui/npcintegerdialog.cpp b/src/gui/npcintegerdialog.cpp
index 4d2ae1ce..86dad4ab 100644
--- a/src/gui/npcintegerdialog.cpp
+++ b/src/gui/npcintegerdialog.cpp
@@ -28,9 +28,8 @@
#include "../npc.h"
-#include "../net/messageout.h"
#ifdef EATHENA_SUPPORT
-#include "../net/ea/protocol.h"
+#include "../net/ea/npchandler.h"
#endif
#include "../utils/gettext.h"
@@ -119,10 +118,9 @@ void NpcIntegerDialog::action(const gcn::ActionEvent &event)
setVisible(false);
NPC::isTalking = false;
+ // Net::getNpcHandler()->integerInput(current_npc, mValueField->getValue());
#ifdef EATHENA_SUPPORT
- MessageOut outMsg(CMSG_NPC_INT_RESPONSE);
- outMsg.writeInt32(current_npc);
- outMsg.writeInt32(mValueField->getValue());
+ npcHandler->integerInput(current_npc, mValueField->getValue());
#endif
mValueField->reset();
diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp
index efac8954..8b0128d5 100644
--- a/src/gui/npclistdialog.cpp
+++ b/src/gui/npclistdialog.cpp
@@ -31,11 +31,10 @@
#include "../npc.h"
-#include "../net/messageout.h"
#ifdef TMWSERV_SUPPORT
#include "../net/tmwserv/gameserver/player.h"
#else
-#include "../net/ea/protocol.h"
+#include "../net/ea/npchandler.h"
#endif
#include "../utils/gettext.h"
@@ -133,12 +132,11 @@ void NpcListDialog::action(const gcn::ActionEvent &event)
saveWindowState();
reset();
+ // Net::getNpcHandler()->listInput(current_npc, choice);
#ifdef TMWSERV_SUPPORT
Net::GameServer::Player::selectFromNPC(current_npc, choice);
#else
- MessageOut outMsg(CMSG_NPC_LIST_CHOICE);
- outMsg.writeInt32(current_npc);
- outMsg.writeInt8(choice);
+ npcHandler->listInput(current_npc, choice);
#endif
}
}
diff --git a/src/gui/npcstringdialog.cpp b/src/gui/npcstringdialog.cpp
index e5137d9c..8d45e332 100644
--- a/src/gui/npcstringdialog.cpp
+++ b/src/gui/npcstringdialog.cpp
@@ -28,9 +28,8 @@
#include "../npc.h"
-#include "../net/messageout.h"
#ifdef EATHENA_SUPPORT
-#include "../net/ea/protocol.h"
+#include "../net/ea/npchandler.h"
#endif
#include "../utils/gettext.h"
@@ -87,12 +86,9 @@ void NpcStringDialog::action(const gcn::ActionEvent &event)
std::string text = mValueField->getText();
mValueField->setText("");
+ // Net::getNpcHandler()->stringInput(current_npc, text);
#ifdef EATHENA_SUPPORT
- MessageOut outMsg(CMSG_NPC_STR_RESPONSE);
- outMsg.writeInt16(text.length() + 9);
- outMsg.writeInt32(current_npc);
- outMsg.writeString(text, text.length());
- outMsg.writeInt8(0);
+ npcHandler->stringInput(current_npc, text);
#endif
}
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index 1057c2e9..3b4e9982 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -34,11 +34,10 @@
#include "shopitem.h"
#include "units.h"
-#include "net/messageout.h"
#ifdef TMWSERV_SUPPORT
#include "net/tmwserv/gameserver/player.h"
#else
-#include "net/ea/protocol.h"
+#include "net/ea/npchandler.h"
#endif
#include "resources/iteminfo.h"
@@ -207,14 +206,12 @@ void SellDialog::action(const gcn::ActionEvent &event)
mAmountItems * mShopItems->at(selectedItem)->getPrice();
mMaxItems -= mAmountItems;
while (mAmountItems > 0) {
- MessageOut outMsg(CMSG_NPC_SELL_REQUEST);
- outMsg.writeInt16(8);
- outMsg.writeInt16(item->getCurrentInvIndex() + 2);
// This order is important, item->getCurrentInvIndex() would return
// the inventory index of the next Duplicate otherwise.
sellCount = item->sellCurrentDuplicate(mAmountItems);
mAmountItems -= sellCount;
- outMsg.writeInt16(sellCount);
+ // Net::getNpcHandler()->sellItem(current_npc, item->getCurrentInvIndex(), sellCount);
+ npcHandler->sellItem(current_npc, item->getCurrentInvIndex(), sellCount);
}
#endif
diff --git a/src/net/adminhandler.h b/src/net/adminhandler.h
new file mode 100644
index 00000000..df013eb3
--- /dev/null
+++ b/src/net/adminhandler.h
@@ -0,0 +1,53 @@
+/*
+ * The Mana World
+ * Copyright (C) 2009 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef ADMINHANDLER_H
+#define ADMINHANDLER_H
+
+#include <iosfwd>
+
+namespace Net {
+ class AdminHandler
+ {
+ public:
+ void announce(const std::string &text) {}
+
+ void localAnnounce(const std::string &text) {}
+
+ void hide(bool hide) {}
+
+ void kick(int playerId) {}
+
+ void kick(const std::string &name) {}
+
+ void ban(int playerId) {}
+
+ void ban(const std::string &name) {}
+
+ void unban(int playerId) {}
+
+ void unban(const std::string &name) {}
+
+ // TODO
+ };
+}
+
+#endif // ADMINHANDLER_H
diff --git a/src/net/charhandler.h b/src/net/charhandler.h
new file mode 100644
index 00000000..f1535ac3
--- /dev/null
+++ b/src/net/charhandler.h
@@ -0,0 +1,40 @@
+/*
+ * The Mana World
+ * Copyright (C) 2009 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef CHARHANDLER_H
+#define CHARHANDLER_H
+
+#include <iosfwd>
+
+namespace Net {
+ class CharHandler
+ {
+ public:
+ void ChooseCharacter(int slot);
+
+ void NewCharacter(const std::string &name, bool gender,
+ int hairstyle, int hairColor);
+
+ void DeleteCharacter(int slot);
+ };
+}
+
+#endif // CHARHANDLER_H
diff --git a/src/net/chathandler.h b/src/net/chathandler.h
new file mode 100644
index 00000000..237ab929
--- /dev/null
+++ b/src/net/chathandler.h
@@ -0,0 +1,56 @@
+/*
+ * The Mana World
+ * Copyright (C) 2009 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef CHATHANDLER_H
+#define CHATHANDLER_H
+
+#include <iosfwd>
+
+namespace Net {
+ class ChatHandler
+ {
+ public:
+ void talk(const std::string &text);
+
+ void me(const std::string &text);
+
+ void privateMessage(const std::string &recipient,
+ const std::string &text);
+
+ void channelList() {}
+
+ void enterChannel(int channelId, const std::string &password) {}
+
+ void quitChannel(int channelId) {}
+
+ void sendToChannel(int channelId, const std::string &text) {}
+
+ void userList(int channelId) {}
+
+ void setChannelTopic(int channelId, const std::string &text) {}
+
+ void setUserMode(int channelId, const std::string &name, int mode) {}
+
+ void kickUser(int channelId, const std::string &name) {}
+ };
+}
+
+#endif // CHATHANDLER_H
diff --git a/src/net/ea/npchandler.cpp b/src/net/ea/npchandler.cpp
index 0e0bc53d..136f07fd 100644
--- a/src/net/ea/npchandler.cpp
+++ b/src/net/ea/npchandler.cpp
@@ -24,6 +24,7 @@
#include "net/ea/protocol.h"
#include "net/messagein.h"
+#include "net/messageout.h"
#include "beingmanager.h"
#include "localplayer.h"
@@ -36,6 +37,8 @@
#include <SDL_types.h>
+NPCHandler *npcHandler;
+
NPCHandler::NPCHandler()
{
static const Uint16 _messages[] = {
@@ -48,6 +51,7 @@ NPCHandler::NPCHandler()
0
};
handledMessages = _messages;
+ npcHandler = this;
}
void NPCHandler::handleMessage(MessageIn &msg)
@@ -114,3 +118,77 @@ void NPCHandler::handleMessage(MessageIn &msg)
break;
}
}
+
+void NPCHandler::talk(int npcId)
+{
+ MessageOut outMsg(CMSG_NPC_TALK);
+ outMsg.writeInt32(npcId);
+ outMsg.writeInt8(0); // Unused
+}
+
+void NPCHandler::nextDialog(int npcId)
+{
+ MessageOut outMsg(CMSG_NPC_NEXT_REQUEST);
+ outMsg.writeInt32(npcId);
+}
+
+void NPCHandler::closeDialog(int npcId)
+{
+ MessageOut outMsg(CMSG_NPC_CLOSE);
+ outMsg.writeInt32(npcId);
+}
+
+void NPCHandler::listInput(int npcId, int value)
+{
+ MessageOut outMsg(CMSG_NPC_LIST_CHOICE);
+ outMsg.writeInt32(npcId);
+ outMsg.writeInt8(value);
+}
+
+void NPCHandler::integerInput(int npcId, int value)
+{
+ MessageOut outMsg(CMSG_NPC_INT_RESPONSE);
+ outMsg.writeInt32(npcId);
+ outMsg.writeInt32(value);
+}
+
+void NPCHandler::stringInput(int npcId, const std::string &value)
+{
+ MessageOut outMsg(CMSG_NPC_STR_RESPONSE);
+ outMsg.writeInt16(value.length() + 9);
+ outMsg.writeInt32(npcId);
+ outMsg.writeString(value, value.length());
+ outMsg.writeInt8(0); // Prevent problems with string reading
+}
+
+void NPCHandler::buy(int beingId)
+{
+
+ MessageOut outMsg(CMSG_NPC_BUY_SELL_REQUEST);
+ outMsg.writeInt32(beingId);
+ outMsg.writeInt8(0); // Buy
+}
+
+void NPCHandler::sell(int beingId)
+{
+
+ MessageOut outMsg(CMSG_NPC_BUY_SELL_REQUEST);
+ outMsg.writeInt32(beingId);
+ outMsg.writeInt8(1); // Sell
+}
+
+void NPCHandler::buyItem(int beingId, int itemId, int amount)
+{
+ MessageOut outMsg(CMSG_NPC_BUY_REQUEST);
+ outMsg.writeInt16(8); // One item (length of packet)
+ outMsg.writeInt16(amount);
+ outMsg.writeInt16(itemId);
+}
+
+void NPCHandler::sellItem(int beingId, int itemId, int amount)
+{
+ MessageOut outMsg(CMSG_NPC_SELL_REQUEST);
+ outMsg.writeInt16(8); // One item (length of packet)
+ outMsg.writeInt16(itemId + 2);
+ outMsg.writeInt16(amount);
+}
diff --git a/src/net/ea/npchandler.h b/src/net/ea/npchandler.h
index 8c252175..71e15e02 100644
--- a/src/net/ea/npchandler.h
+++ b/src/net/ea/npchandler.h
@@ -23,13 +23,36 @@
#define NET_EA_NPCHANDLER_H
#include "net/messagehandler.h"
+#include "net/net.h"
-class NPCHandler : public MessageHandler
+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 buy(int beingId);
+
+ void sell(int beingId);
+
+ void buyItem(int beingId, int itemId, int amount);
+
+ void sellItem(int beingId, int itemId, int amount);
};
+extern NPCHandler *npcHandler;
+
#endif // NET_EA_NPCHANDLER_H
diff --git a/src/net/generalhandler.h b/src/net/generalhandler.h
new file mode 100644
index 00000000..dd823240
--- /dev/null
+++ b/src/net/generalhandler.h
@@ -0,0 +1,35 @@
+/*
+ * The Mana World
+ * Copyright (C) 2009 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef GENERALHANDLER_H
+#define GENERALHANDLER_H
+
+namespace Net {
+ class GeneralHandler
+ {
+ public:
+ virtual void load();
+ virtual void unload();
+ virtual void guiWindowsLoaded() {}
+ };
+}
+
+#endif // GENERALHANDLER_H
diff --git a/src/net/guildhandler.h b/src/net/guildhandler.h
new file mode 100644
index 00000000..2385819a
--- /dev/null
+++ b/src/net/guildhandler.h
@@ -0,0 +1,57 @@
+/*
+ * The Mana World
+ * Copyright (C) 2009 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef GUILDHANDLER_H
+#define GUILDHANDLER_H
+
+#include <iosfwd>
+
+namespace Net {
+ class GuildHandler
+ {
+ public:
+ void create(const std::string &name) {}
+
+ void join(int guildId) {}
+
+ void invite(int guidId, int playerId) {}
+
+ void inviteResponse(int guidId, bool response) {}
+
+ void leave(int guidId) {}
+
+ void kick(int guidId, int playerId) {}
+
+ void chat(int guidId, const std::string &text) {}
+
+ void memberList(int guidId) {}
+
+ void changeMemberPostion(int guildId, int playerId, int level) {}
+
+ void requestAlliance(int guildId, int otherGuildId) {}
+
+ void requestAllianceResponse(int guildId, int otherGuildId, bool response) {}
+
+ void endAlliance(int guildId, int otherGuildId) {}
+ };
+}
+
+#endif // GUILDHANDLER_H
diff --git a/src/net/inventoryhandler.h b/src/net/inventoryhandler.h
new file mode 100644
index 00000000..22427099
--- /dev/null
+++ b/src/net/inventoryhandler.h
@@ -0,0 +1,60 @@
+/*
+ * The Mana World
+ * Copyright (C) 2009 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef INVENTORYHANDLER_H
+#define INVENTORYHANDLER_H
+
+#include "item.h"
+
+#include <iosfwd>
+
+namespace Net {
+ class InvyHandler
+ {
+ public:
+ void equipItem(Item *item);
+
+ void unequipItem(Item *item);
+
+ void useItem(int slot, Item *item);
+
+ void dropItem(int slot, int amount);
+
+ void splitItem(int slot, int amount) {}
+
+ void openStorage() {}
+
+ void closeStorage() {}
+
+ //void changeCart() {}
+
+ enum StorageType {
+ INVENTORY,
+ STORAGE,
+ CART
+ };
+
+ void moveItem(StorageType source, int slot, int amount,
+ StorageType destination) {}
+ };
+}
+
+#endif // INVENTORYHANDLER_H
diff --git a/src/net/loginhandler.h b/src/net/loginhandler.h
new file mode 100644
index 00000000..ca72248a
--- /dev/null
+++ b/src/net/loginhandler.h
@@ -0,0 +1,46 @@
+/*
+ * The Mana World
+ * Copyright (C) 2009 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef LOGINHANDLER_H
+#define LOGINHANDLER_H
+
+#include <iosfwd>
+
+namespace Net {
+ class LoginHandler
+ {
+ public:
+ virtual void loginAccount(const std::string &username,
+ const std::string &password);
+ virtual void changeEmail(const std::string &email) {}
+ virtual void changePassword(const std::string &username,
+ const std::string &oldPassword,
+ const std::string &newPassword) {}
+ virtual void chooseServer(int server) {}
+ virtual void registerAccount(const std::string &username,
+ const std::string &password,
+ const std::string &email = "");
+ virtual void unregisterAccount(const std::string &username,
+ const std::string &password);
+ };
+}
+
+#endif // LOGINHANDLER_H
diff --git a/src/net/maphandler.h b/src/net/maphandler.h
new file mode 100644
index 00000000..e5157fc6
--- /dev/null
+++ b/src/net/maphandler.h
@@ -0,0 +1,41 @@
+/*
+ * The Mana World
+ * Copyright (C) 2009 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef MAPHANDLER_H
+#define MAPHANDLER_H
+
+#include <iosfwd>
+
+namespace Net {
+ class MapHandler
+ {
+ public:
+ void connect() {}
+
+ void mapLoaded(const std::string &mapName) {}
+
+ void who() {}
+
+ void quit() {}
+ };
+}
+
+#endif // MAPHANDLER_H
diff --git a/src/net/net.h b/src/net/net.h
new file mode 100644
index 00000000..0d2beffc
--- /dev/null
+++ b/src/net/net.h
@@ -0,0 +1,67 @@
+/*
+ * The Mana World
+ * Copyright (C) 2009 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef NET_H
+#define NET_H
+
+#include "net/adminhandler.h"
+#include "net/charhandler.h"
+#include "net/chathandler.h"
+#include "net/generalhandler.h"
+#include "net/guildhandler.h"
+#include "net/inventoryhandler.h"
+#include "net/loginhandler.h"
+#include "net/maphandler.h"
+#include "net/npchandler.h"
+#include "net/partyhandler.h"
+#include "net/playerhandler.h"
+#include "net/skillhandler.h"
+#include "net/tradehandler.h"
+
+namespace Net {
+ Net::AdminHandler *getAdminHandler();
+
+ Net::CharHandler *getCharHandler();
+
+ Net::ChatHandler *getChatHandler();
+
+ Net::GeneralHandler *getGeneralHandler();
+
+ Net::GuildHandler *getGuildHandler();
+
+ Net::InvyHandler *getInvyHandler();
+
+ Net::LoginHandler *getLoginHandler();
+
+ Net::MapHandler *getMapHandler();
+
+ Net::NpcHandler *getNpcHandler();
+
+ Net::PartyHandler *getPartyHandler();
+
+ Net::PlayerHandler *getPlayerHandler();
+
+ Net::SkillHandler *getSkillHandler();
+
+ Net::TradeHandler *getTradeHandler();
+}
+
+#endif // NET_H
diff --git a/src/net/npchandler.h b/src/net/npchandler.h
new file mode 100644
index 00000000..9ff02f28
--- /dev/null
+++ b/src/net/npchandler.h
@@ -0,0 +1,60 @@
+/*
+ * The Mana World
+ * Copyright (C) 2009 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef NPCHANDLER_H
+#define NPCHANDLER_H
+
+#include <iosfwd>
+
+namespace Net {
+ class NpcHandler
+ {
+ public:
+ 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 startShoping(int beingId) {}
+
+ void buy(int beingId) {}
+
+ void sell(int beingId) {}
+
+ void buyItem(int beingId, int itemId, int ammount) {}
+
+ void sellItem(int beingId, int itemId, int ammount) {}
+
+ void endShoping(int beingId) {}
+ };
+}
+
+#endif // NPCHANDLER_H
diff --git a/src/net/partyhandler.h b/src/net/partyhandler.h
new file mode 100644
index 00000000..6c400bf1
--- /dev/null
+++ b/src/net/partyhandler.h
@@ -0,0 +1,53 @@
+/*
+ * The Mana World
+ * Copyright (C) 2009 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PARTYHANDLER_H
+#define PARTYHANDLER_H
+
+#include <iosfwd>
+
+namespace Net {
+ class PartyHandler
+ {
+ public:
+ void create(const std::string &name="") {}
+
+ void join(int partyId) {}
+
+ void invite(int playerId) {}
+
+ void inviteResponse(bool accept) {}
+
+ void leave() {}
+
+ void kick(int playerId) {}
+
+ void chat(const std::string &text) {}
+
+ void partyMembers() {}
+
+ // void options() {}
+
+ // void message() {}
+ };
+}
+
+#endif // PARTYHANDLER_H
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
new file mode 100644
index 00000000..df5e341e
--- /dev/null
+++ b/src/net/playerhandler.h
@@ -0,0 +1,58 @@
+/*
+ * The Mana World
+ * Copyright (C) 2009 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PLAYERHANDLER_H
+#define PLAYERHANDLER_H
+
+#include "being.h"
+#include "floor_item.h"
+
+#include <iosfwd>
+
+namespace Net {
+ class PlayerHandler
+ {
+ public:
+ void attack(Being *being);
+
+ void emote(int emoteId) {}
+
+ void increaseStat(int statId) {}
+
+ void decreaseStat(int statId) {}
+
+ void pickUp(FloorItem *floorItem) {}
+
+ void setDirection(int direction) {}
+
+ void setDestination(int x, int y, int direction = -1);
+
+ void sit() {}
+
+ void respawn() {}
+
+ void ingorePlayer(const std::string &player, bool ignore) {}
+
+ void ingoreAll(bool ignore) {}
+ };
+}
+
+#endif // PLAYERHANDLER_H
diff --git a/src/net/skillhandler.h b/src/net/skillhandler.h
new file mode 100644
index 00000000..1ab16f05
--- /dev/null
+++ b/src/net/skillhandler.h
@@ -0,0 +1,38 @@
+/*
+ * The Mana World
+ * Copyright (C) 2009 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef SKILLHANDLER_H
+#define SKILLHANDLER_H
+
+#include <iosfwd>
+
+namespace Net {
+ class SkillHandler
+ {
+ public:
+ void up(int skillId) {}
+ void use(int skillId, int level, int beingId) {}
+ void use(int skillId, int level, int x, int y) {}
+ void use(int skillId, const std::string &map) {}
+ };
+}
+
+#endif // SKILLHANDLER_H
diff --git a/src/net/tradehandler.h b/src/net/tradehandler.h
new file mode 100644
index 00000000..84de3196
--- /dev/null
+++ b/src/net/tradehandler.h
@@ -0,0 +1,51 @@
+/*
+ * The Mana World
+ * Copyright (C) 2009 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef TRADEHANDLER_H
+#define TRADEHANDLER_H
+
+#include "being.h"
+
+#include <iosfwd>
+
+namespace Net {
+ class TradeHandler
+ {
+ public:
+ void request(Being *being) {}
+
+ void respond(bool accepet) {}
+
+ void addItem(int slotNum, int amount) {}
+
+ void removeItem(int slotNum, int amount) {}
+
+ void setMoney(int amount) {}
+
+ void confirm() {}
+
+ void finish() {}
+
+ void cancel() {}
+ };
+}
+
+#endif // TRADEHANDLER_H
diff --git a/src/npc.cpp b/src/npc.cpp
index 359546e2..b3f14e8c 100644
--- a/src/npc.cpp
+++ b/src/npc.cpp
@@ -28,11 +28,11 @@
#include "gui/npc_text.h"
#include "gui/palette.h"
+#include "net/net.h"
#ifdef TMWSERV_SUPPORT
#include "net/tmwserv/gameserver/player.h"
#else
-#include "net/messageout.h"
-#include "net/ea/protocol.h"
+#include "net/ea/npchandler.h"
#endif
#include "resources/npcdb.h"
@@ -117,12 +117,11 @@ void NPC::talk()
isTalking = true;
+ // Net::getNpcHandler()->talk(mId);
#ifdef TMWSERV_SUPPORT
Net::GameServer::Player::talkToNPC(mId, true);
#else
- MessageOut outMsg(CMSG_NPC_TALK);
- outMsg.writeInt32(mId);
- outMsg.writeInt8(0);
+ npcHandler->talk(mId);
#endif
}