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 | |
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')
-rw-r--r-- | src/net/itemhandler.cpp | 42 | ||||
-rw-r--r-- | src/net/protocol.h | 3 |
2 files changed, 21 insertions, 24 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; } } diff --git a/src/net/protocol.h b/src/net/protocol.h index de908c53..685d3161 100644 --- a/src/net/protocol.h +++ b/src/net/protocol.h @@ -155,6 +155,7 @@ enum { GPMSG_BEING_LEAVE = 0x0201, // W being id PGMSG_WALK = 0x0260, // W*2 destination GPMSG_BEINGS_MOVE = 0x0280, // { W being id, B flags [, C position] [, W*2 destination] }* + GPMSG_ITEMS = 0x0281, // { W item id, W*2 position }* PGMSG_ATTACK = 0x0290, // B direction GPMSG_BEING_ATTACK = 0x0291, // W being id PGMSG_SAY = 0x02A0, // S text @@ -163,7 +164,7 @@ enum { GPMSG_USE_RESPONSE = 0x0301, // B error PGMSG_EQUIP = 0x0302, // L item id, B slot GPMSG_EQUIP_RESPONSE = 0x0303, // B error - GPMSG_BEINGS_DAMAGE = 0x0310, // { W being id, W ammount }* + GPMSG_BEINGS_DAMAGE = 0x0310, // { W being id, W amount }* // Chat CPMSG_ERROR = 0x0401, // B error |