diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-08-19 02:41:30 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-08-19 02:41:30 +0200 |
commit | 011135415f7f9c5cfeb220540621dfd1c46e6db9 (patch) | |
tree | 55dd2943dca362045e7ed96ef72924728343351e /src/net/manaserv/beinghandler.cpp | |
parent | c392eab58774154177a0e790a414c2c52c8ce83b (diff) | |
parent | 27114fa2694318f2a1c56cb828a3b79731efcb74 (diff) | |
download | mana-client-011135415f7f9c5cfeb220540621dfd1c46e6db9.tar.gz mana-client-011135415f7f9c5cfeb220540621dfd1c46e6db9.tar.bz2 mana-client-011135415f7f9c5cfeb220540621dfd1c46e6db9.tar.xz mana-client-011135415f7f9c5cfeb220540621dfd1c46e6db9.zip |
Merge git://gitorious.org/~bertram/mana/mana-equipment-fix into equipment-fix
Diffstat (limited to 'src/net/manaserv/beinghandler.cpp')
-rw-r--r-- | src/net/manaserv/beinghandler.cpp | 34 |
1 files changed, 12 insertions, 22 deletions
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)); } } |