summaryrefslogtreecommitdiff
path: root/src/net/manaserv/inventoryhandler.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-11-03 12:06:48 -0700
committerJared Adams <jaxad0127@gmail.com>2009-11-03 12:06:48 -0700
commite07e2a6db902f2ce0095b65708a98fa4dbf40aa0 (patch)
treeb91b3e3d3f06199dcc34e32834941964a263e0be /src/net/manaserv/inventoryhandler.cpp
parente2897e4a7cb7eb0c4a7e46d72a9a19b909368c26 (diff)
downloadmana-e07e2a6db902f2ce0095b65708a98fa4dbf40aa0.tar.gz
mana-e07e2a6db902f2ce0095b65708a98fa4dbf40aa0.tar.bz2
mana-e07e2a6db902f2ce0095b65708a98fa4dbf40aa0.tar.xz
mana-e07e2a6db902f2ce0095b65708a98fa4dbf40aa0.zip
Simplify ManaServ netcode some more
Diffstat (limited to 'src/net/manaserv/inventoryhandler.cpp')
-rw-r--r--src/net/manaserv/inventoryhandler.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/net/manaserv/inventoryhandler.cpp b/src/net/manaserv/inventoryhandler.cpp
index e4fe0ecc..0d0c1b34 100644
--- a/src/net/manaserv/inventoryhandler.cpp
+++ b/src/net/manaserv/inventoryhandler.cpp
@@ -26,9 +26,6 @@
#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
-#include "net/manaserv/gameserver/internal.h"
-#include "net/manaserv/gameserver/player.h"
-
#include "equipment.h"
#include "inventory.h"
#include "item.h"
@@ -45,6 +42,8 @@ Net::InventoryHandler *inventoryHandler;
namespace ManaServ {
+extern Connection *gameServerConnection;
+
InventoryHandler::InventoryHandler()
{
static const Uint16 _messages[] = {
@@ -93,14 +92,14 @@ void InventoryHandler::equipItem(const Item *item)
{
MessageOut msg(PGMSG_EQUIP);
msg.writeInt8(item->getInvIndex());
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void InventoryHandler::unequipItem(const Item *item)
{
MessageOut msg(PGMSG_UNEQUIP);
msg.writeInt8(item->getInvIndex());
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
// Tidy equipment directly to avoid weapon still shown bug, for instance
int equipSlot = item->getInvIndex();
@@ -112,7 +111,7 @@ void InventoryHandler::useItem(const Item *item)
{
MessageOut msg(PGMSG_USE_ITEM);
msg.writeInt8(item->getInvIndex());
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void InventoryHandler::dropItem(const Item *item, int amount)
@@ -120,7 +119,7 @@ void InventoryHandler::dropItem(const Item *item, int amount)
MessageOut msg(PGMSG_DROP);
msg.writeInt8(item->getInvIndex());
msg.writeInt8(amount);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
bool InventoryHandler::canSplit(const Item *item)
@@ -133,7 +132,11 @@ void InventoryHandler::splitItem(const Item *item, int amount)
int newIndex = player_node->getInventory()->getFreeSlot();
if (newIndex > Inventory::NO_SLOT_INDEX)
{
- GameServer::Player::moveItem(item->getInvIndex(), newIndex, amount);
+ MessageOut msg(PGMSG_MOVE_ITEM);
+ msg.writeInt8(item->getInvIndex());
+ msg.writeInt8(newIndex);
+ msg.writeInt8(amount);
+ gameServerConnection->send(msg);
}
}
@@ -142,8 +145,12 @@ void InventoryHandler::moveItem(int oldIndex, int newIndex)
if (oldIndex == newIndex)
return;
- GameServer::Player::moveItem(oldIndex, newIndex,
- player_node->getInventory()->getItem(oldIndex)->getQuantity());
+ MessageOut msg(PGMSG_MOVE_ITEM);
+ msg.writeInt8(oldIndex);
+ msg.writeInt8(newIndex);
+ msg.writeInt8(player_node->getInventory()->getItem(oldIndex)
+ ->getQuantity());
+ gameServerConnection->send(msg);
}
void InventoryHandler::openStorage()