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); 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) void Game::processInventoryChange(int slot, const ItemPtr& item)
{ {
if(item) if(item)

View File

@ -48,6 +48,7 @@ public:
void processTextMessage(const std::string& type, const std::string& message); 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 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 processInventoryChange(int slot, const ItemPtr& item);
void processCreatureMove(const CreaturePtr& creature, const Position& oldPos, const Position& newPos); void processCreatureMove(const CreaturePtr& creature, const Position& oldPos, const Position& newPos);
void processAttackCancel(); void processAttackCancel();

View File

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