diff options
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | src/defines.h | 3 | ||||
-rw-r--r-- | src/game-server/inventory.cpp | 4 | ||||
-rw-r--r-- | src/game-server/inventory.hpp | 2 | ||||
-rw-r--r-- | src/game-server/item.hpp | 8 | ||||
-rw-r--r-- | src/game-server/itemmanager.cpp | 2 | ||||
-rw-r--r-- | src/game-server/object.hpp | 3 | ||||
-rw-r--r-- | src/game-server/state.cpp | 30 |
8 files changed, 52 insertions, 11 deletions
@@ -1,4 +1,13 @@ -2007-07-08 Guillaume Melquiond <guillaume.melquiond@gmail.com> +2007-07-12 Guillaume Melquiond <guillaume.melquiond@gmail.com> + + * src/game-server/item.hpp, src/game-server/inventory.cpp, + src/game-server/inventory.hpp: Fixed naming of equipment slot. + * src/game-server/object.hpp: Added update flag for looks. + * src/game-server/itemmanager.cpp: Added field loaded for sprite_id. + * src/defines.h, src/game-server/state.cpp: Added support for visible + equipment. + +2007-07-08 Guillaume Melquiond <guillaume.melquiond@gmail.com> * src/game-server/being.cpp: Lowered messages to debug level. * src/game-server/deathlistener.hpp: Made members non-abstract, so that diff --git a/src/defines.h b/src/defines.h index c0f44daa..25e35069 100644 --- a/src/defines.h +++ b/src/defines.h @@ -149,10 +149,11 @@ 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 - // character: S name, B hair style, B hair color, B gender + // character: S name, B hair style, B hair color, B gender, W weapon, W hat, W top clothes, W bottom clothes // monster: W type id GPMSG_BEING_LEAVE = 0x0201, // W being id GPMSG_ITEM_APPEAR = 0x0202, // W item id, W*2 position + GPMSG_BEING_LOOKS_CHANGE = 0x0210, // W weapon, W hat, W top clothes, W bottom clothes PGMSG_WALK = 0x0260, // W*2 destination PGMSG_ACTION_CHANGE = 0x0270, // B Action GPMSG_BEING_ACTION_CHANGE = 0x0271, // W being id, B action 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: { |