From 27114fa2694318f2a1c56cb828a3b79731efcb74 Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Fri, 19 Aug 2011 02:37:09 +0200 Subject: Fixed visible equipment updates, and made it based on equip.xml. --- src/net/manaserv/beinghandler.cpp | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) (limited to 'src/net/manaserv/beinghandler.cpp') diff --git a/src/net/manaserv/beinghandler.cpp b/src/net/manaserv/beinghandler.cpp index 4d45da8a..44c3d77b 100644 --- a/src/net/manaserv/beinghandler.cpp +++ b/src/net/manaserv/beinghandler.cpp @@ -31,8 +31,10 @@ #include "gui/okdialog.h" +#include "net/net.h" #include "net/messagein.h" +#include "net/manaserv/inventoryhandler.h" #include "net/manaserv/playerhandler.h" #include "net/manaserv/manaserv_protocol.h" @@ -93,29 +95,17 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) static void handleLooks(Being *being, Net::MessageIn &msg) { - // 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] = - { SPRITE_WEAPON, SPRITE_HAT, SPRITE_TOPCLOTHES, - SPRITE_BOTTOMCLOTHES }; + int lookChanges = msg.readInt8(); - int mask = msg.readInt8(); - - if (mask & (1 << 7)) - { - // The equipment has to be cleared first. - for (int i = 0; i < nb_slots; ++i) - { - being->setSprite(slots[i], 0); - } - } + if (lookChanges <= 0) + return; - // Fill slots enumerated by the bitmask. - for (int i = 0; i < nb_slots; ++i) + while (lookChanges-- > 0) { - if (!(mask & (1 << i))) continue; - int id = msg.readInt16(); - being->setSprite(slots[i], id,"", (slots[i] == SPRITE_WEAPON)); + unsigned int slotTypeId = msg.readInt8(); + being->setSprite(slotTypeId + FIXED_SPRITE_LAYER_SIZE, + msg.readInt16(), "", + Net::getInventoryHandler()->isWeaponSlot(slotTypeId)); } } @@ -154,7 +144,7 @@ void BeingHandler::handleBeingEnterMessage(Net::MessageIn &msg) being->setName(name); } int hs = msg.readInt8(), hc = msg.readInt8(); - being->setSprite(SPRITE_HAIR, hs * -1, ColorDB::get(hc)); + being->setSprite(SPRITE_LAYER_HAIR, hs * -1, ColorDB::get(hc)); being->setGender(msg.readInt8() == GENDER_MALE ? GENDER_MALE : GENDER_FEMALE); handleLooks(being, msg); @@ -342,7 +332,7 @@ void BeingHandler::handleBeingLooksChangeMessage(Net::MessageIn &msg) { int style = msg.readInt16(); int color = msg.readInt16(); - being->setSprite(SPRITE_HAIR, style * -1, ColorDB::get(color)); + being->setSprite(SPRITE_LAYER_HAIR, style * -1, ColorDB::get(color)); } } -- cgit v1.2.3-70-g09d2