summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/defines.h11
-rw-r--r--src/common/inventorydata.h52
-rw-r--r--src/common/manaserv_protocol.h42
3 files changed, 72 insertions, 33 deletions
diff --git a/src/common/defines.h b/src/common/defines.h
index c14aca50..140a6929 100644
--- a/src/common/defines.h
+++ b/src/common/defines.h
@@ -126,6 +126,17 @@ enum Element
};
/**
+ * Damage type, used to know how to compute them.
+ */
+enum DamageType
+{
+ DAMAGE_PHYSICAL = 0,
+ DAMAGE_MAGICAL,
+ DAMAGE_DIRECT,
+ DAMAGE_OTHER = -1
+};
+
+/**
* A series of hardcoded attributes that must be defined.
* FIXME: Much of these serve only to indicate derivatives, and so would not be
* needed once this is no longer a hardcoded system.
diff --git a/src/common/inventorydata.h b/src/common/inventorydata.h
index 9127c816..490abff2 100644
--- a/src/common/inventorydata.h
+++ b/src/common/inventorydata.h
@@ -35,20 +35,62 @@
*/
struct InventoryItem
{
+ InventoryItem():
+ itemId(0), amount(0)
+ {}
+
unsigned int itemId;
unsigned int amount;
};
-// slot id -> { item }
-typedef std::map< unsigned short, InventoryItem > InventoryData;
-// equip slot type -> { slot ids }
-// Equipment taking up multiple slots will be referenced multiple times
-typedef std::multimap< unsigned int, unsigned int > EquipData;
+
+struct EquipmentItem
+{
+ EquipmentItem():
+ itemId(0), itemInstance(0)
+ {}
+
+ EquipmentItem(unsigned int itemId, unsigned int itemInstance)
+ {
+ this->itemId = itemId;
+ this->itemInstance = itemInstance;
+ }
+
+ // The item id taken from the item db.
+ unsigned int itemId;
+ // A unique instance number used to separate items when equipping the same
+ // item id multiple times on possible multiple slots.
+ unsigned int itemInstance;
+};
+
+// inventory slot id -> { item }
+typedef std::map< unsigned int, InventoryItem > InventoryData;
+
+// equip slot id -> { item id, item instance }
+// Equipment taking up multiple equip slot ids will be referenced multiple times
+typedef std::multimap< unsigned int, EquipmentItem > EquipData;
/**
* Structure storing the equipment and inventory of a Player.
*/
struct Possessions
{
+ friend class Inventory;
+public:
+ const EquipData &getEquipment() const
+ { return equipSlots; }
+
+ const InventoryData &getInventory() const
+ { return inventory; }
+
+ /**
+ * Should be done only at character serialization and storage load time.
+ */
+ void setEquipment(EquipData &equipData)
+ { equipSlots.swap(equipData); }
+ void setInventory(InventoryData &inventoryData)
+ { inventory.swap(inventoryData); }
+
+private:
InventoryData inventory;
EquipData equipSlots;
};
diff --git a/src/common/manaserv_protocol.h b/src/common/manaserv_protocol.h
index cbe7a0b9..8946a394 100644
--- a/src/common/manaserv_protocol.h
+++ b/src/common/manaserv_protocol.h
@@ -24,7 +24,10 @@
namespace ManaServ {
-enum { PROTOCOL_VERSION = 1 };
+enum {
+ PROTOCOL_VERSION = 1,
+ SUPPORTED_DB_VERSION = 17
+};
/**
* Enumerated type for communicated messages:
@@ -92,12 +95,12 @@ enum {
GPMSG_PLAYER_SERVER_CHANGE = 0x0101, // B*32 token, S game address, W game port
PGMSG_PICKUP = 0x0110, // W*2 position
PGMSG_DROP = 0x0111, // B slot, B amount
- PGMSG_EQUIP = 0x0112, // B slot
- PGMSG_UNEQUIP = 0x0113, // B slot
- PGMSG_MOVE_ITEM = 0x0114, // B slot1, B slot2, B amount
+ PGMSG_EQUIP = 0x0112, // W inventory slot
+ PGMSG_UNEQUIP = 0x0113, // W item Instance id
+ PGMSG_MOVE_ITEM = 0x0114, // W slot1, W slot2, W amount
GPMSG_INVENTORY = 0x0120, // { W slot, W item id [, W amount] (if item id is nonzero) }*
- GPMSG_INVENTORY_FULL = 0x0121, // W inventory slot count { W slot, W itemId, W amount }, { B equip slot, W invy slot}*
- GPMSG_EQUIP = 0x0122, // { W Invy slot, B equip slot type count { B equip slot, B number used} }*
+ GPMSG_INVENTORY_FULL = 0x0121, // W inventory slot count { W slot, W itemId, W amount }, { W equip slot, W item Id, W item Instance}*
+ GPMSG_EQUIP = 0x0122, // W item Id, W equip slot type count //{ W equip slot, W capacity used}*//<- When equipping, //{ W item instance, W 0}*//<- When unequipping
GPMSG_PLAYER_ATTRIBUTE_CHANGE = 0x0130, // { W attribute, D base value (in 1/256ths), D modified value (in 1/256ths)}*
GPMSG_PLAYER_EXP_CHANGE = 0x0140, // { W skill, D exp got, D exp needed }*
GPMSG_LEVELUP = 0x0150, // W new level, W character points, W correction points
@@ -108,12 +111,12 @@ enum {
GPMSG_LOWER_ATTRIBUTE_RESPONSE = 0x0171, // B error, W attribute
PGMSG_RESPAWN = 0x0180, // -
GPMSG_BEING_ENTER = 0x0200, // B type, W being id, B action, W*2 position, B direction
- // character: S name, B hair style, B hair color, B gender, B item bitmask, { W item id }*
+ // character: S name, B hair style, B hair color, B gender, B sprite layers changed, { B slot type, W item id }*
// monster: W type id
// npc: 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
+ GPMSG_BEING_LOOKS_CHANGE = 0x0210, // B sprite layers changed, { B slot type, W item id }*
PGMSG_WALK = 0x0260, // W*2 destination
PGMSG_ACTION_CHANGE = 0x0270, // B Action
GPMSG_BEING_ACTION_CHANGE = 0x0271, // W being id, B action
@@ -229,7 +232,7 @@ enum {
// Inter-server
GAMSG_REGISTER = 0x0500, // S address, W port, S password, D items db revision, { W map id }*
AGMSG_REGISTER_RESPONSE = 0x0501, // C item version, C password response, { S globalvar_key, S globalvar_value }
- AGMSG_ACTIVE_MAP = 0x0502, // W map id, { S mapvar_key, S mapvar_value }
+ AGMSG_ACTIVE_MAP = 0x0502, // W map id, W Number of mapvar_key mapvar_value sent, { S mapvar_key, S mapvar_value }, W Number of map items, { D item Id, W amount, W posX, W posY }
AGMSG_PLAYER_ENTER = 0x0510, // B*32 token, D id, S name, serialised character data
GAMSG_PLAYER_DATA = 0x0520, // D id, serialised character data
GAMSG_REDIRECT = 0x0530, // D id
@@ -255,6 +258,8 @@ enum {
GCMSG_STORE_POST = 0x05A5, // D sender id, S receiver name, S letter, { W attachment item id, W quantity }
CGMSG_STORE_POST_RESPONSE = 0x05A6, // D id, B error
GAMSG_TRANSACTION = 0x0600, // D character id, D action, S message
+ GAMSG_CREATE_ITEM_ON_MAP = 0x0601, // D map id, D item id, W amount, W pos x, W pos y
+ GAMSG_REMOVE_ITEM_ON_MAP = 0x0602, // D map id, D item id, W amount, W pos x, W pos y
XXMSG_INVALID = 0x7FFF
};
@@ -427,26 +432,7 @@ enum BeingDirection
};
/**
- * enum for sprites layers.
- * WARNING: Has to be in sync with the same enum in the Sprite class
- * of the client!
- */
-enum SpriteLayer
-{
- SPRITE_BASE = 0,
- SPRITE_SHOE,
- SPRITE_BOTTOMCLOTHES,
- SPRITE_TOPCLOTHES,
- SPRITE_HAIR,
- SPRITE_HAT,
- SPRITE_WEAPON,
- SPRITE_VECTOREND
-};
-
-/**
* Beings Genders
- * WARNING: Has to be in sync with the same enum in the Being class
- * of the client!
*/
enum BeingGender
{