summaryrefslogtreecommitdiff
path: root/src/net/manaserv/beinghandler.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-08-19 02:37:09 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-08-19 02:37:09 +0200
commit27114fa2694318f2a1c56cb828a3b79731efcb74 (patch)
treeaad31af84a5932bf8fda83e367dfa1ac78fec1c3 /src/net/manaserv/beinghandler.cpp
parent36239b2d689b862a951a65a9be7376a500f1ace9 (diff)
downloadmana-27114fa2694318f2a1c56cb828a3b79731efcb74.tar.gz
mana-27114fa2694318f2a1c56cb828a3b79731efcb74.tar.bz2
mana-27114fa2694318f2a1c56cb828a3b79731efcb74.tar.xz
mana-27114fa2694318f2a1c56cb828a3b79731efcb74.zip
Fixed visible equipment updates, and made it based on equip.xml.
Diffstat (limited to 'src/net/manaserv/beinghandler.cpp')
-rw-r--r--src/net/manaserv/beinghandler.cpp34
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));
}
}