summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-07-14 13:52:28 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-07-14 13:52:28 +0000
commita138d81a27ed41062a677b1a54309b01f415df62 (patch)
tree41a8b2b7a10fb3a2b3150c153d1c7b64f8932448
parent038388c2d1aeab8d653a8129e5ff95b4c83b2f88 (diff)
downloadmana-client-a138d81a27ed41062a677b1a54309b01f415df62.tar.gz
mana-client-a138d81a27ed41062a677b1a54309b01f415df62.tar.bz2
mana-client-a138d81a27ed41062a677b1a54309b01f415df62.tar.xz
mana-client-a138d81a27ed41062a677b1a54309b01f415df62.zip
Reduced size of equipment packets.
-rw-r--r--ChangeLog7
-rw-r--r--src/net/beinghandler.cpp32
-rw-r--r--src/net/protocol.h2
3 files changed, 35 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 641e18a3..634562d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,9 @@
-2007-07-12 Guillaume Melquiond <guillaume.melquiond@gmail.com>
+2007-07-14 Guillaume Melquiond <guillaume.melquiond@gmail.com>
+
+ * src/net/beinghandler.cpp, src/net/protocol.h: Reduced size of
+ equipment packets.
+
+2007-07-12 Guillaume Melquiond <guillaume.melquiond@gmail.com>
* src/net/beinghandler.cpp, src/net/beinghandler.h, src/net/protocol.h:
Added support for visible equipment.
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