diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-01-03 22:35:40 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-01-03 22:35:40 +0000 |
commit | 0af87580d604b43a0b3e46354583c956f42b7cae (patch) | |
tree | 3673e01e941d3987b2cad113746967a91c2af73d /src/net/itemhandler.cpp | |
parent | 73911893133028a855931b037ed4e90217d5503a (diff) | |
download | mana-0af87580d604b43a0b3e46354583c956f42b7cae.tar.gz mana-0af87580d604b43a0b3e46354583c956f42b7cae.tar.bz2 mana-0af87580d604b43a0b3e46354583c956f42b7cae.tar.xz mana-0af87580d604b43a0b3e46354583c956f42b7cae.zip |
Modified handler for items on floor.
Diffstat (limited to 'src/net/itemhandler.cpp')
-rw-r--r-- | src/net/itemhandler.cpp | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/src/net/itemhandler.cpp b/src/net/itemhandler.cpp index 2961f71b..fffb3a45 100644 --- a/src/net/itemhandler.cpp +++ b/src/net/itemhandler.cpp @@ -32,9 +32,7 @@ ItemHandler::ItemHandler() { static const Uint16 _messages[] = { - SMSG_ITEM_VISIBLE, - SMSG_ITEM_DROPPED, - SMSG_ITEM_REMOVE, + GPMSG_ITEMS, 0 }; handledMessages = _messages; @@ -42,28 +40,26 @@ ItemHandler::ItemHandler() void ItemHandler::handleMessage(MessageIn &msg) { - Uint32 id; - Uint16 x, y; - Sint16 itemId; - switch (msg.getId()) { - case SMSG_ITEM_VISIBLE: - case SMSG_ITEM_DROPPED: - id = msg.readLong(); - itemId = msg.readShort(); - msg.readByte(); // identify flag - x = msg.readShort(); - y = msg.readShort(); - - floorItemManager->create(id, itemId, x, y, engine->getCurrentMap()); - break; + case GPMSG_ITEMS: + { + while (msg.getUnreadLength()) + { + int itemId = msg.readShort(); + int x = msg.readShort(); + int y = msg.readShort(); + int id = (x << 16) | y; // dummy id - case SMSG_ITEM_REMOVE: - FloorItem *item; - item = floorItemManager->findById(msg.readLong()); - 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; } } |