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/beinghandler.cpp | |
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/beinghandler.cpp')
-rw-r--r-- | src/net/beinghandler.cpp | 32 |
1 files changed, 28 insertions, 4 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 |