summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/beinghandler.cpp32
-rw-r--r--src/net/protocol.h2
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