summaryrefslogtreecommitdiff
path: root/src/game-server
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-07-12 19:47:25 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-07-12 19:47:25 +0000
commitce69890ac991fcac5c8ffb29591d68ab203d811a (patch)
treeed04511b6273121080de87b78088044c5062f9f8 /src/game-server
parent21c0c9d07b897235b422c004394325dd07daa304 (diff)
downloadmanaserv-ce69890ac991fcac5c8ffb29591d68ab203d811a.tar.gz
manaserv-ce69890ac991fcac5c8ffb29591d68ab203d811a.tar.bz2
manaserv-ce69890ac991fcac5c8ffb29591d68ab203d811a.tar.xz
manaserv-ce69890ac991fcac5c8ffb29591d68ab203d811a.zip
Added support for visible equipment.
Diffstat (limited to 'src/game-server')
-rw-r--r--src/game-server/inventory.cpp4
-rw-r--r--src/game-server/inventory.hpp2
-rw-r--r--src/game-server/item.hpp8
-rw-r--r--src/game-server/itemmanager.cpp2
-rw-r--r--src/game-server/object.hpp3
-rw-r--r--src/game-server/state.cpp30
6 files changed, 40 insertions, 9 deletions
diff --git a/src/game-server/inventory.cpp b/src/game-server/inventory.cpp
index 4204304f..7cefd72b 100644
--- a/src/game-server/inventory.cpp
+++ b/src/game-server/inventory.cpp
@@ -369,9 +369,9 @@ bool Inventory::equip(int slot)
firstSlot = EQUIP_RING1_SLOT;
secondSlot = EQUIP_RING2_SLOT;
break;
- case ITEM_EQUIPMENT_BREST:
+ case ITEM_EQUIPMENT_TORSO:
availableSlots = 1;
- firstSlot = EQUIP_BREST_SLOT;
+ firstSlot = EQUIP_TORSO_SLOT;
break;
case ITEM_EQUIPMENT_ARMS:
availableSlots = 1;
diff --git a/src/game-server/inventory.hpp b/src/game-server/inventory.hpp
index 65d010d7..1ae3cbb5 100644
--- a/src/game-server/inventory.hpp
+++ b/src/game-server/inventory.hpp
@@ -31,7 +31,7 @@ enum
{
// Equipment rules:
// 1 Brest equipment
- EQUIP_BREST_SLOT = 0,
+ EQUIP_TORSO_SLOT = 0,
// 1 arms equipment
EQUIP_ARMS_SLOT = 1,
// 1 head equipment
diff --git a/src/game-server/item.hpp b/src/game-server/item.hpp
index d4d4af74..e563d67a 100644
--- a/src/game-server/item.hpp
+++ b/src/game-server/item.hpp
@@ -38,7 +38,7 @@ enum
ITEM_USABLE, // 1
ITEM_EQUIPMENT_ONE_HAND_WEAPON, // 2
ITEM_EQUIPMENT_TWO_HANDS_WEAPON, // 3
- ITEM_EQUIPMENT_BREST, // 4
+ ITEM_EQUIPMENT_TORSO, // 4
ITEM_EQUIPMENT_ARMS, // 5
ITEM_EQUIPMENT_HEAD, // 6
ITEM_EQUIPMENT_LEGS, // 7
@@ -207,13 +207,13 @@ class ItemClass
/**
* Sets the sprite ID.
*/
- void setSpriteID(unsigned short spriteID)
- { mSpriteID = spriteID; }
+ void setSpriteID(int spriteID)
+ { mSpriteID = spriteID; }
/**
* Gets the sprite ID.
*/
- unsigned short getSpriteID()
+ int getSpriteID()
{ return mSpriteID; }
diff --git a/src/game-server/itemmanager.cpp b/src/game-server/itemmanager.cpp
index ea63be2e..80035847 100644
--- a/src/game-server/itemmanager.cpp
+++ b/src/game-server/itemmanager.cpp
@@ -86,6 +86,7 @@ void ItemManager::initialize(std::string const &itemReferenceFile)
int weight = XML::getProperty(node, "weight", 0);
int value = XML::getProperty(node, "value", 0);
int maxPerSlot = XML::getProperty(node, "max_per_slot", 0);
+ int sprite = XML::getProperty(node, "sprite_id", 0);
std::string scriptName = XML::getProperty(node, "script_name", std::string());
//TODO: add child nodes for these modifiers (additive and factor)
@@ -111,6 +112,7 @@ void ItemManager::initialize(std::string const &itemReferenceFile)
item->setMaxPerSlot(maxPerSlot);
item->setScriptName(scriptName);
item->setModifiers(modifiers);
+ item->setSpriteID(sprite ? sprite : id);
itemClasses[id] = item;
++nbItems;
diff --git a/src/game-server/object.hpp b/src/game-server/object.hpp
index 6c30bb0d..0fb63783 100644
--- a/src/game-server/object.hpp
+++ b/src/game-server/object.hpp
@@ -36,7 +36,8 @@ enum
UPDATEFLAG_NEW_DESTINATION = 2,
UPDATEFLAG_ATTACK = 4,
UPDATEFLAG_ACTIONCHANGE = 8,
- UPDATEFLAG_REMOVE = 16
+ UPDATEFLAG_LOOKSCHANGE = 16,
+ UPDATEFLAG_REMOVE = 32
};
/**
diff --git a/src/game-server/state.cpp b/src/game-server/state.cpp
index 7ade4d1b..0c29c566 100644
--- a/src/game-server/state.cpp
+++ b/src/game-server/state.cpp
@@ -27,7 +27,9 @@
#include "point.h"
#include "game-server/accountconnection.hpp"
#include "game-server/gamehandler.hpp"
+#include "game-server/inventory.hpp"
#include "game-server/item.hpp"
+#include "game-server/itemmanager.hpp"
#include "game-server/map.hpp"
#include "game-server/mapcomposite.hpp"
#include "game-server/mapmanager.hpp"
@@ -86,6 +88,22 @@ static void updateMap(MapComposite *map)
}
/**
+ * Sets message fields describing character look.
+ */
+static void serializeLooks(Character *ch, MessageOut &msg)
+{
+ Possessions const &poss = ch->getPossessions();
+ static int const slots[] =
+ { EQUIP_FIGHT1_SLOT, EQUIP_HEAD_SLOT, EQUIP_TORSO_SLOT, EQUIP_LEGS_SLOT };
+ for (int i = 0; i < 4; ++i)
+ {
+ int id = poss.equipment[slots[i]];
+ ItemClass *eq;
+ msg.writeShort(id && (eq = ItemManager::getItem(id)) ? eq->getSpriteID() : 0);
+ }
+}
+
+/**
* Informs a player of what happened around the character.
*/
static void informPlayer(MapComposite *map, Character *p)
@@ -116,7 +134,7 @@ static void informPlayer(MapComposite *map, Character *p)
gameHandler->sendTo(p, AttackMsg);
}
- // Send state change messages.
+ // Send action change messages.
if ((oflags & UPDATEFLAG_ACTIONCHANGE))
{
MessageOut ActionMsg(GPMSG_BEING_ACTION_CHANGE);
@@ -125,6 +143,15 @@ static void informPlayer(MapComposite *map, Character *p)
gameHandler->sendTo(p, ActionMsg);
}
+ // Send looks change messages.
+ if (oflags & UPDATEFLAG_LOOKSCHANGE)
+ {
+ MessageOut LooksMsg(GPMSG_BEING_LOOKS_CHANGE);
+ LooksMsg.writeShort(oid);
+ serializeLooks(static_cast< Character * >(o), LooksMsg);
+ gameHandler->sendTo(p, LooksMsg);
+ }
+
// Send leave messages of dead beings
if ((oflags & UPDATEFLAG_REMOVE))
{
@@ -176,6 +203,7 @@ static void informPlayer(MapComposite *map, Character *p)
enterMsg.writeByte(q->getHairStyle());
enterMsg.writeByte(q->getHairColor());
enterMsg.writeByte(q->getGender());
+ serializeLooks(q, enterMsg);
} break;
case OBJECT_MONSTER:
{