summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game.cpp6
-rw-r--r--src/gui/buy.cpp17
-rw-r--r--src/gui/buysell.cpp9
-rw-r--r--src/gui/npc_text.cpp34
-rw-r--r--src/gui/npcintegerdialog.cpp27
-rw-r--r--src/gui/npclistdialog.cpp35
-rw-r--r--src/gui/npcpostdialog.cpp9
-rw-r--r--src/gui/npcstringdialog.cpp27
-rw-r--r--src/gui/sell.cpp27
-rw-r--r--src/gui/sell.h4
-rw-r--r--src/gui/shop.cpp2
-rw-r--r--src/gui/shop.h2
-rw-r--r--src/net/chathandler.h22
-rw-r--r--src/net/ea/inventoryhandler.cpp4
-rw-r--r--src/net/ea/npchandler.cpp6
-rw-r--r--src/net/ea/npchandler.h4
-rw-r--r--src/net/net.cpp16
-rw-r--r--src/net/npchandler.h4
-rw-r--r--src/net/tmwserv/buysellhandler.cpp2
-rw-r--r--src/net/tmwserv/inventoryhandler.cpp4
-rw-r--r--src/net/tmwserv/inventoryhandler.h2
-rw-r--r--src/net/tmwserv/npchandler.cpp75
-rw-r--r--src/net/tmwserv/npchandler.h34
-rw-r--r--src/npc.cpp13
24 files changed, 216 insertions, 169 deletions
diff --git a/src/game.cpp b/src/game.cpp
index c6031eba..4cdada3e 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -374,7 +374,11 @@ Game::Game(Network *network):
mInventoryHandler(new EAthena::InventoryHandler),
#endif
mItemHandler(new ItemHandler),
- mNpcHandler(new NpcHandler),
+#ifdef TMWSERV_SUPPORT
+ mNpcHandler(new TmwServ::NpcHandler),
+#else
+ mNpcHandler(new EAthena::NpcHandler),
+#endif
mPlayerHandler(new PlayerHandler),
mTradeHandler(new TradeHandler),
mLastTarget(Being::UNKNOWN),
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp
index 7cefa3e5..8d963227 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -34,11 +34,8 @@
#include "shopitem.h"
#include "units.h"
-#ifdef TMWSERV_SUPPORT
-#include "net/tmwserv/gameserver/player.h"
-#else
-#include "net/ea/npchandler.h"
-#endif
+#include "net/net.h"
+#include "net/npchandler.h"
#include "resources/iteminfo.h"
@@ -187,13 +184,9 @@ 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
- npcHandler->buyItem(current_npc, mShopItems->at(selectedItem)->getId(), mAmountItems);
-#endif
+ Net::getNpcHandler()->buyItem(current_npc,
+ mShopItems->at(selectedItem)->getId(),
+ mAmountItems);
// Update money and adjust the max number of items that can be bought
mMaxItems -= mAmountItems;
diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp
index 33e12e87..80e2cdfe 100644
--- a/src/gui/buysell.cpp
+++ b/src/gui/buysell.cpp
@@ -25,7 +25,8 @@
#include "gui/button.h"
-#include "net/ea/npchandler.h"
+#include "net/net.h"
+#include "net/npchandler.h"
#include "utils/gettext.h"
@@ -81,13 +82,11 @@ void BuySellDialog::action(const gcn::ActionEvent &event)
if (event.getId() == "Buy")
{
- // Net::getNpcHandler()->buy(current_npc);
- npcHandler->buy(current_npc);
+ Net::getNpcHandler()->buy(current_npc);
}
else if (event.getId() == "Sell")
{
- // Net::getNpcHandler()->buy(current_npc);
- npcHandler->sell(current_npc);
+ Net::getNpcHandler()->buy(current_npc);
}
else if (event.getId() == "Cancel")
{
diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp
index b33b9970..2d4a5891 100644
--- a/src/gui/npc_text.cpp
+++ b/src/gui/npc_text.cpp
@@ -19,22 +19,20 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "button.h"
-#include "npc_text.h"
-#include "scrollarea.h"
-#include "textbox.h"
+#include "gui/npc_text.h"
-#include "widgets/layout.h"
+#include "gui/button.h"
+#include "gui/scrollarea.h"
+#include "gui/textbox.h"
-#include "../npc.h"
+#include "gui/widgets/layout.h"
-#ifdef TMWSERV_SUPPORT
-#include "../net/tmwserv/gameserver/player.h"
-#else
-#include "../net/ea/npchandler.h"
-#endif
+#include "npc.h"
-#include "../utils/gettext.h"
+#include "net/net.h"
+#include "net/npchandler.h"
+
+#include "utils/gettext.h"
NpcTextDialog::NpcTextDialog()
: Window(_("NPC"))
@@ -125,20 +123,12 @@ 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
- npcHandler->nextDialog(npcID);
-#endif
+ Net::getNpcHandler()->nextDialog(npcID);
}
void NpcTextDialog::closeDialog(int npcID)
{
- // Net::getNpcHandler()->closeDialog(npcID);
-#ifdef EATHENA_SUPPORT
- npcHandler->closeDialog(npcID);
-#endif
+ Net::getNpcHandler()->closeDialog(npcID);
}
void NpcTextDialog::widgetResized(const gcn::Event &event)
diff --git a/src/gui/npcintegerdialog.cpp b/src/gui/npcintegerdialog.cpp
index 86dad4ab..7955214c 100644
--- a/src/gui/npcintegerdialog.cpp
+++ b/src/gui/npcintegerdialog.cpp
@@ -19,21 +19,21 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "button.h"
-#include "inttextfield.h"
-#include "npc_text.h"
-#include "npcintegerdialog.h"
+#include "gui/npcintegerdialog.h"
-#include "widgets/layout.h"
+#include "gui/button.h"
+#include "gui/inttextfield.h"
+#include "gui/npc_text.h"
-#include "../npc.h"
+#include "gui/widgets/layout.h"
-#ifdef EATHENA_SUPPORT
-#include "../net/ea/npchandler.h"
-#endif
+#include "npc.h"
-#include "../utils/gettext.h"
-#include "../utils/strprintf.h"
+#include "net/net.h"
+#include "net/npchandler.h"
+
+#include "utils/gettext.h"
+#include "utils/strprintf.h"
NpcIntegerDialog::NpcIntegerDialog()
: Window(_("NPC Number Request"))
@@ -118,10 +118,7 @@ void NpcIntegerDialog::action(const gcn::ActionEvent &event)
setVisible(false);
NPC::isTalking = false;
- // Net::getNpcHandler()->integerInput(current_npc, mValueField->getValue());
-#ifdef EATHENA_SUPPORT
- npcHandler->integerInput(current_npc, mValueField->getValue());
-#endif
+ Net::getNpcHandler()->integerInput(current_npc, mValueField->getValue());
mValueField->reset();
}
diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp
index 8b0128d5..5cd7dbab 100644
--- a/src/gui/npclistdialog.cpp
+++ b/src/gui/npclistdialog.cpp
@@ -19,26 +19,24 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <sstream>
+#include "gui/npclistdialog.h"
+
+#include "gui/button.h"
+#include "gui/listbox.h"
+#include "gui/npc_text.h"
+#include "gui/scrollarea.h"
-#include "button.h"
-#include "listbox.h"
-#include "npc_text.h"
-#include "npclistdialog.h"
-#include "scrollarea.h"
+#include "gui/widgets/layout.h"
-#include "widgets/layout.h"
+#include "npc.h"
-#include "../npc.h"
+#include "net/net.h"
+#include "net/npchandler.h"
-#ifdef TMWSERV_SUPPORT
-#include "../net/tmwserv/gameserver/player.h"
-#else
-#include "../net/ea/npchandler.h"
-#endif
+#include "utils/gettext.h"
+#include "utils/strprintf.h"
-#include "../utils/gettext.h"
-#include "../utils/strprintf.h"
+#include <sstream>
NpcListDialog::NpcListDialog()
: Window("NPC")
@@ -132,12 +130,7 @@ 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
- npcHandler->listInput(current_npc, choice);
-#endif
+ Net::getNpcHandler()->listInput(current_npc, choice);
}
}
diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp
index 5c083612..2b178cff 100644
--- a/src/gui/npcpostdialog.cpp
+++ b/src/gui/npcpostdialog.cpp
@@ -28,7 +28,11 @@
#include "gui/widgets/chattab.h"
-#include "net/tmwserv/gameserver/player.h"
+#include "npc.h"
+
+#include "net/net.h"
+#include "net/npchandler.h"
+
#include "utils/gettext.h"
#include <guichan/widgets/label.hpp>
@@ -84,7 +88,8 @@ void NpcPostDialog::action(const gcn::ActionEvent &event)
}
else
{
- Net::GameServer::Player::sendLetter(mSender->getText(), mText->getText());
+ Net::getNpcHandler()->sendLetter(current_npc, mSender->getText(),
+ mText->getText());
}
setVisible(false);
clear();
diff --git a/src/gui/npcstringdialog.cpp b/src/gui/npcstringdialog.cpp
index 8d45e332..7ce4060c 100644
--- a/src/gui/npcstringdialog.cpp
+++ b/src/gui/npcstringdialog.cpp
@@ -19,21 +19,21 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "button.h"
-#include "npc_text.h"
-#include "npcstringdialog.h"
-#include "textfield.h"
+#include "gui/npc_text.h"
-#include "widgets/layout.h"
+#include "gui/button.h"
+#include "gui/npcstringdialog.h"
+#include "gui/textfield.h"
-#include "../npc.h"
+#include "gui/widgets/layout.h"
-#ifdef EATHENA_SUPPORT
-#include "../net/ea/npchandler.h"
-#endif
+#include "npc.h"
-#include "../utils/gettext.h"
-#include "../utils/strprintf.h"
+#include "net/net.h"
+#include "net/npchandler.h"
+
+#include "utils/gettext.h"
+#include "utils/strprintf.h"
NpcStringDialog::NpcStringDialog()
: Window(_("NPC Text Request"))
@@ -86,10 +86,7 @@ void NpcStringDialog::action(const gcn::ActionEvent &event)
std::string text = mValueField->getText();
mValueField->setText("");
- // Net::getNpcHandler()->stringInput(current_npc, text);
-#ifdef EATHENA_SUPPORT
- npcHandler->stringInput(current_npc, text);
-#endif
+ Net::getNpcHandler()->stringInput(current_npc, text);
}
bool NpcStringDialog::isInputFocused()
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index 3b4e9982..2dfc66a7 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -34,11 +34,8 @@
#include "shopitem.h"
#include "units.h"
-#ifdef TMWSERV_SUPPORT
-#include "net/tmwserv/gameserver/player.h"
-#else
-#include "net/ea/npchandler.h"
-#endif
+#include "net/net.h"
+#include "net/npchandler.h"
#include "resources/iteminfo.h"
@@ -129,16 +126,6 @@ void SellDialog::reset()
updateButtonsAndLabels();
}
-#ifdef TMWSERV_SUPPORT
-
-void SellDialog::addItem(int item, int amount, int price)
-{
- mShopItems->addItem(item, amount, price);
- mShopItemList->adjustSize();
-}
-
-#else
-
void SellDialog::addItem(const Item *item, int price)
{
if (!item)
@@ -150,8 +137,6 @@ void SellDialog::addItem(const Item *item, int price)
mShopItemList->adjustSize();
}
-#endif
-
void SellDialog::action(const gcn::ActionEvent &event)
{
if (event.getId() == "quit")
@@ -195,10 +180,6 @@ void SellDialog::action(const gcn::ActionEvent &event)
else if (event.getId() == "sell" && mAmountItems > 0
&& mAmountItems <= mMaxItems)
{
-#ifdef TMWSERV_SUPPORT
- Net::GameServer::Player::tradeWithNPC
- (mShopItems->at(selectedItem)->getId(), mAmountItems);
-#else
// Attempt sell
ShopItem *item = mShopItems->at(selectedItem);
int sellCount;
@@ -210,10 +191,8 @@ void SellDialog::action(const gcn::ActionEvent &event)
// the inventory index of the next Duplicate otherwise.
sellCount = item->sellCurrentDuplicate(mAmountItems);
mAmountItems -= sellCount;
- // Net::getNpcHandler()->sellItem(current_npc, item->getCurrentInvIndex(), sellCount);
- npcHandler->sellItem(current_npc, item->getCurrentInvIndex(), sellCount);
+ Net::getNpcHandler()->sellItem(current_npc, item->getCurrentInvIndex(), sellCount);
}
-#endif
mPlayerMoney +=
mAmountItems * mShopItems->at(selectedItem)->getPrice();
diff --git a/src/gui/sell.h b/src/gui/sell.h
index b3e59b4f..89ae06c4 100644
--- a/src/gui/sell.h
+++ b/src/gui/sell.h
@@ -61,11 +61,7 @@ class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener
/**
* Adds an item to the inventory.
*/
-#ifdef TMWSERV_SUPPORT
- void addItem(int item, int amount, int price);
-#else
void addItem(const Item *item, int price);
-#endif
/**
* Called when receiving actions from the widgets.
diff --git a/src/gui/shop.cpp b/src/gui/shop.cpp
index 4799ea42..b72be694 100644
--- a/src/gui/shop.cpp
+++ b/src/gui/shop.cpp
@@ -50,7 +50,6 @@ void ShopItems::addItem(int id, int amount, int price)
mShopItems.push_back(new ShopItem(-1, id, amount, price));
}
-#ifdef EATHENA_SUPPORT
void ShopItems::addItem(int inventoryIndex, int id, int quantity, int price)
{
ShopItem *item = 0;
@@ -69,7 +68,6 @@ void ShopItems::addItem(int inventoryIndex, int id, int quantity, int price)
mShopItems.push_back(item);
}
}
-#endif
ShopItem *ShopItems::at(int i) const
{
diff --git a/src/gui/shop.h b/src/gui/shop.h
index 190ef655..28f5d4b3 100644
--- a/src/gui/shop.h
+++ b/src/gui/shop.h
@@ -56,7 +56,6 @@ class ShopItems : public gcn::ListModel
*/
void addItem(int id, int amount, int price);
-#ifdef EATHENA_SUPPORT
/**
* Adds an item to the list (used by sell dialog). Looks for
* duplicate entries, if mergeDuplicates was turned on.
@@ -67,7 +66,6 @@ class ShopItems : public gcn::ListModel
* @param price price of the item
*/
void addItem(int inventoryIndex, int id, int amount, int price);
-#endif
/**
* Returns the number of items in the shop.
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
diff --git a/src/npc.cpp b/src/npc.cpp
index b3f14e8c..374e7525 100644
--- a/src/npc.cpp
+++ b/src/npc.cpp
@@ -29,11 +29,7 @@
#include "gui/palette.h"
#include "net/net.h"
-#ifdef TMWSERV_SUPPORT
-#include "net/tmwserv/gameserver/player.h"
-#else
-#include "net/ea/npchandler.h"
-#endif
+#include "net/npchandler.h"
#include "resources/npcdb.h"
@@ -117,12 +113,7 @@ void NPC::talk()
isTalking = true;
- // Net::getNpcHandler()->talk(mId);
-#ifdef TMWSERV_SUPPORT
- Net::GameServer::Player::talkToNPC(mId, true);
-#else
- npcHandler->talk(mId);
-#endif
+ Net::getNpcHandler()->talk(mId);
}
void NPC::updateCoords()