diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-08-18 22:01:43 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-08-18 22:01:43 +0000 |
commit | a971d34980ecbeefd7db08dd7f8049795bf9f56b (patch) | |
tree | d096fa01a38f31374256d14e06ff4a46676fa86c /src/net | |
parent | 1a68e441ec6d7d529b5c64bfafac56ae45d3f2fb (diff) | |
download | mana-a971d34980ecbeefd7db08dd7f8049795bf9f56b.tar.gz mana-a971d34980ecbeefd7db08dd7f8049795bf9f56b.tar.bz2 mana-a971d34980ecbeefd7db08dd7f8049795bf9f56b.tar.xz mana-a971d34980ecbeefd7db08dd7f8049795bf9f56b.zip |
Adapted to new server handling of character attributes.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/playerhandler.cpp | 30 | ||||
-rw-r--r-- | src/net/protocol.h | 2 |
2 files changed, 12 insertions, 20 deletions
diff --git a/src/net/playerhandler.cpp b/src/net/playerhandler.cpp index 335c2eb1..b94b5128 100644 --- a/src/net/playerhandler.cpp +++ b/src/net/playerhandler.cpp @@ -87,16 +87,9 @@ namespace { PlayerHandler::PlayerHandler() { static const Uint16 _messages[] = { - //SMSG_PLAYER_STAT_UPDATE_1, - //SMSG_PLAYER_STAT_UPDATE_2, - //SMSG_PLAYER_STAT_UPDATE_3, - //SMSG_PLAYER_STAT_UPDATE_4, - //SMSG_PLAYER_STAT_UPDATE_5, - //SMSG_PLAYER_STAT_UPDATE_6, - //SMSG_PLAYER_ARROW_MESSAGE, GPMSG_PLAYER_MAP_CHANGE, GPMSG_PLAYER_SERVER_CHANGE, - GPMSG_PLAYER_ATTRIBUTE_UPDATE, + GPMSG_PLAYER_ATTRIBUTE_CHANGE, 0 }; handledMessages = _messages; @@ -118,26 +111,25 @@ void PlayerHandler::handleMessage(MessageIn &msg) logger->log("Changing server to %s:%d", address.c_str(), port); } break; - case GPMSG_PLAYER_ATTRIBUTE_UPDATE: + case GPMSG_PLAYER_ATTRIBUTE_CHANGE: { logger->log("ATTRIBUTE UPDATE:"); while (msg.getUnreadLength()) { - int stat = msg.readShort(); + int stat = msg.readByte(); + int base = msg.readShort(); int value = msg.readShort(); - logger->log("%d set to %d", stat, value); + logger->log("%d set to %d %d", stat, base, value); - if (stat < NB_BASE_ATTRIBUTES) + if (stat == BASE_ATTR_HP) { - player_node->setAttributeBase(stat, value); + player_node->setMaxHP(base); + player_node->setHP(value); } - else if (stat < NB_EFFECTIVE_ATTRIBUTES) + else if (stat < NB_CHARACTER_ATTRIBUTES) { - player_node->setAttributeEffective(stat - NB_BASE_ATTRIBUTES, value); - } - else if (stat == DERIVED_ATTR_HP_MAXIMUM) - { - player_node->setMaxHP(value); + player_node->setAttributeBase(stat, base); + player_node->setAttributeEffective(stat, value); } else { diff --git a/src/net/protocol.h b/src/net/protocol.h index 3e67e647..d8b9fcb2 100644 --- a/src/net/protocol.h +++ b/src/net/protocol.h @@ -82,7 +82,7 @@ enum { PGMSG_MOVE_ITEM = 0x0114, // B slot1, B slot2, B amount GPMSG_INVENTORY = 0x0120, // { B slot, W item id [, B amount] }* GPMSG_INVENTORY_FULL = 0x0121, // { B slot, W item id [, B amount] }* - GPMSG_PLAYER_ATTRIBUTE_UPDATE = 0x0130, // { W attribute, W value }* + GPMSG_PLAYER_ATTRIBUTE_CHANGE = 0x0130, // { B attribute, W base value, W modified value }* GPMSG_BEING_ENTER = 0x0200, // B type, W being id, B action, W*2 position // player: S name, B hair style, B hair color, B gender, B item bitmask, { W item id }* // monster: W type id |