diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-07-14 13:52:28 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-07-14 13:52:28 +0000 |
commit | a138d81a27ed41062a677b1a54309b01f415df62 (patch) | |
tree | 41a8b2b7a10fb3a2b3150c153d1c7b64f8932448 /src/net | |
parent | 038388c2d1aeab8d653a8129e5ff95b4c83b2f88 (diff) | |
download | mana-a138d81a27ed41062a677b1a54309b01f415df62.tar.gz mana-a138d81a27ed41062a677b1a54309b01f415df62.tar.bz2 mana-a138d81a27ed41062a677b1a54309b01f415df62.tar.xz mana-a138d81a27ed41062a677b1a54309b01f415df62.zip |
Reduced size of equipment packets.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/beinghandler.cpp | 32 | ||||
-rw-r--r-- | src/net/protocol.h | 2 |
2 files changed, 29 insertions, 5 deletions
diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp index a6bc7fc3..51609b1d 100644 --- a/src/net/beinghandler.cpp +++ b/src/net/beinghandler.cpp @@ -417,10 +417,34 @@ void BeingHandler::handleMessage(MessageIn &msg) static void handleLooks(Being *being, MessageIn &msg) { - being->setWeapon(msg.readShort()); - being->setVisibleEquipment(Being::HAT_SPRITE, msg.readShort()); - being->setVisibleEquipment(Being::TOPCLOTHES_SPRITE, msg.readShort()); - being->setVisibleEquipment(Being::BOTTOMCLOTHES_SPRITE, msg.readShort()); + // Order of sent slots. Has to be in sync with the server code. + static int const nb_slots = 4; + static int const slots[nb_slots] = + { Being::WEAPON_SPRITE, Being::HAT_SPRITE, Being::TOPCLOTHES_SPRITE, + Being::BOTTOMCLOTHES_SPRITE }; + + int mask = msg.readByte(); + if (mask & (1 << 8)) + { + // The equipment has to be cleared first. + being->setWeaponById(0); + for (int i = 0; i < nb_slots; ++i) + { + if (slots[i] != Being::WEAPON_SPRITE) + being->setVisibleEquipment(slots[i], 0); + } + } + + // Fill slots enumerated by the bitmask. + for (int i = 0; i < nb_slots; ++i) + { + if (!(mask & (1 << i))) continue; + int id = msg.readShort(); + if (slots[i] != Being::WEAPON_SPRITE) + being->setVisibleEquipment(slots[i], id); + else + being->setWeaponById(id); + } } void diff --git a/src/net/protocol.h b/src/net/protocol.h index ba16e99d..f13b6a02 100644 --- a/src/net/protocol.h +++ b/src/net/protocol.h @@ -163,7 +163,7 @@ enum { GPMSG_INVENTORY_FULL = 0x0121, // { B slot, W item id [, B amount] }* GPMSG_PLAYER_ATTRIBUTE_UPDATE = 0x0130, // { W attribute, W value }* GPMSG_BEING_ENTER = 0x0200, // B type, W being id, B action, W*2 position - // player: S name, B hair style, B hair color, B gender, W weapon, W hat, W top clothes, W bottom clothes + // player: S name, B hair style, B hair color, B gender, B item bitmask, { W item id }* // monster: W type id GPMSG_BEING_LEAVE = 0x0201, // W being id GPMSG_ITEM_APPEAR = 0x0202, // W item id, W*2 position |