summaryrefslogtreecommitdiff
path: root/src/net/itemhandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/itemhandler.cpp')
-rw-r--r--src/net/itemhandler.cpp49
1 files changed, 23 insertions, 26 deletions
diff --git a/src/net/itemhandler.cpp b/src/net/itemhandler.cpp
index 8c4af4e4..189c6eb9 100644
--- a/src/net/itemhandler.cpp
+++ b/src/net/itemhandler.cpp
@@ -29,39 +29,36 @@
ItemHandler::ItemHandler()
{
static const Uint16 _messages[] = {
- SMSG_ITEM_VISIBLE,
- SMSG_ITEM_DROPPED,
- SMSG_ITEM_REMOVE,
+ GPMSG_ITEMS,
+ GPMSG_ITEM_APPEAR,
0
};
handledMessages = _messages;
}
-void ItemHandler::handleMessage(MessageIn *msg)
+void ItemHandler::handleMessage(MessageIn &msg)
{
- Uint32 id;
- Uint16 x, y;
- Sint16 itemId;
-
- switch (msg->getId())
+ switch (msg.getId())
{
- case SMSG_ITEM_VISIBLE:
- case SMSG_ITEM_DROPPED:
- id = msg->readInt32();
- itemId = msg->readInt16();
- msg->readInt8(); // identify flag
- x = msg->readInt16();
- y = msg->readInt16();
- msg->skip(4); // amount,subX,subY / subX,subY,amount
-
- floorItemManager->create(id, itemId, x, y, engine->getCurrentMap());
- break;
+ case GPMSG_ITEM_APPEAR:
+ case GPMSG_ITEMS:
+ {
+ while (msg.getUnreadLength())
+ {
+ int itemId = msg.readInt16();
+ int x = msg.readInt16();
+ int y = msg.readInt16();
+ int id = (x << 16) | y; // dummy id
- case SMSG_ITEM_REMOVE:
- FloorItem *item;
- item = floorItemManager->findById(msg->readInt32());
- if (item)
- floorItemManager->destroy(item);
- break;
+ if (itemId)
+ {
+ floorItemManager->create(id, itemId, x / 32, y / 32, engine->getCurrentMap());
+ }
+ else if (FloorItem *item = floorItemManager->findById(id))
+ {
+ floorItemManager->destroy(item);
+ }
+ }
+ } break;
}
}