init container

This commit is contained in:
Henrique Santiago 2012-01-12 17:25:58 -02:00
parent 830ebdbea9
commit b812d60690
4 changed files with 34 additions and 17 deletions

@ -1 +1 @@
Subproject commit 9beb17daaeb170c127c39c5a5e4feb9d95ebed92
Subproject commit dd648e1431171bffe091b748744395780df7eba1

View File

@ -122,6 +122,14 @@ void Game::processTextMessage(const std::string& type, const std::string& messag
g_lua.callGlobalField("Game","onTextMessage", type, message);
}
void Game::processContainerAddItem(int containerId, const ItemPtr& item)
{
if(item)
item->setPos(Position(65535, containerId, 0));
g_lua.callGlobalField("Game", "onContainerAddItem", containerId, item);
}
void Game::processInventoryChange(int slot, const ItemPtr& item)
{
if(item)

View File

@ -48,6 +48,7 @@ public:
void processTextMessage(const std::string& type, const std::string& message);
void processCreatureSpeak(const std::string& name, int level, const std::string& type, const std::string& message, int channelId, const Position& creaturePos);
void processContainerAddItem(int containerId, const ItemPtr& item);
void processInventoryChange(int slot, const ItemPtr& item);
void processCreatureMove(const CreaturePtr& creature, const Position& oldPos, const Position& newPos);
void processAttackCancel();

View File

@ -430,39 +430,47 @@ void ProtocolGame::parseCreatureMove(InputMessage& msg)
void ProtocolGame::parseOpenContainer(InputMessage& msg)
{
msg.getU8(); // cid
msg.getU16(); // itemid
msg.getString(); // name
msg.getU8(); // capacity
msg.getU8(); // hasParent
int size = msg.getU8(); // size
int containerId = msg.getU8();
int itemId = msg.getU16();
std::string name = msg.getString();
int capacity = msg.getU8();
bool hasParent = (msg.getU8() != 0);
int itemCount = msg.getU8();
for(int i = 0; i < size; i++)
internalGetItem(msg);
g_lua.callGlobalField("Game", "onContainerOpen", containerId, itemId, name, capacity, hasParent);
for(int i = 0; i < itemCount; i++) {
ItemPtr item = internalGetItem(msg);
g_lua.callGlobalField("Game", "onContainerAddItem", containerId, item);
}
}
void ProtocolGame::parseCloseContainer(InputMessage& msg)
{
msg.getU8(); // cid
int containerId = msg.getU8();
g_lua.callGlobalField("Game", "onContainerClose", containerId);
}
void ProtocolGame::parseContainerAddItem(InputMessage& msg)
{
msg.getU8(); // cid
internalGetItem(msg);
int containerId = msg.getU8();
ItemPtr item = internalGetItem(msg);
g_lua.callGlobalField("Game", "onContainerAddItem", containerId, item);
}
void ProtocolGame::parseContainerUpdateItem(InputMessage& msg)
{
msg.getU8(); // cid
msg.getU8(); // slot
internalGetItem(msg);
int containerId = msg.getU8();
int slot = msg.getU8();
ItemPtr item = internalGetItem(msg);
g_lua.callGlobalField("Game", "onContainerUpdateItem", containerId, slot, item);
}
void ProtocolGame::parseContainerRemoveItem(InputMessage& msg)
{
msg.getU8(); // cid
msg.getU8(); // slot
int containerId = msg.getU8();
int slot = msg.getU8();
g_lua.callGlobalField("Game", "onContainerUpdateItem", containerId, slot);
}
void ProtocolGame::parseAddInventoryItem(InputMessage& msg)