summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-08-19 15:40:42 +0200
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2025-03-07 09:54:31 +0100
commit9d1c20860e8a5b8e7d5a4fb53c2ddb1c372bad7f (patch)
treeeb1f6bcd9f4c81c16efdc5dcdd869fdbcc9626c3 /src
parent2d94ced04f34387352e4250363b18a908a67fdf2 (diff)
downloadmana-9d1c20860e8a5b8e7d5a4fb53c2ddb1c372bad7f.tar.gz
mana-9d1c20860e8a5b8e7d5a4fb53c2ddb1c372bad7f.tar.bz2
mana-9d1c20860e8a5b8e7d5a4fb53c2ddb1c372bad7f.tar.xz
mana-9d1c20860e8a5b8e7d5a4fb53c2ddb1c372bad7f.zip
Ability related network message adjustments
* Handle GPMSG_ABILITY_REMOVED for removal of abilities (mana/manaserv@e3fcc1a47db312933a0f5b7e725c5779a1a45722) * Adjust GPMSG_ABILITY_STATUS now that it only sends abilities that have changed state, so it should no longer clear all abilities. (mana/manaserv@3598685c0fcbb9b5fdbcdbbaee258e2b55d5c98a)
Diffstat (limited to 'src')
-rw-r--r--src/net/manaserv/manaserv_protocol.h1
-rw-r--r--src/net/manaserv/playerhandler.cpp10
-rw-r--r--src/playerinfo.cpp4
-rw-r--r--src/playerinfo.h6
4 files changed, 14 insertions, 7 deletions
diff --git a/src/net/manaserv/manaserv_protocol.h b/src/net/manaserv/manaserv_protocol.h
index 01632215..ab81846b 100644
--- a/src/net/manaserv/manaserv_protocol.h
+++ b/src/net/manaserv/manaserv_protocol.h
@@ -141,6 +141,7 @@ enum {
PGMSG_USE_ABILITY_ON_BEING = 0x0292, // B abilityID, W being id
GPMSG_ABILITY_STATUS = 0x0293, // { B abilityID, D current, D max, D recharge }
PGMSG_USE_ABILITY_ON_POINT = 0x0294, // B abilityID, W*2 position
+ GPMSG_ABILITY_REMOVED = 0x0295, // B abilityID
PGMSG_SAY = 0x02A0, // S text
GPMSG_SAY = 0x02A1, // W being id, S text
GPMSG_NPC_CHOICE = 0x02B0, // W being id, { S text }*
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index 335546be..e0d4e783 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -76,6 +76,7 @@ PlayerHandler::PlayerHandler()
GPMSG_RAISE_ATTRIBUTE_RESPONSE,
GPMSG_LOWER_ATTRIBUTE_RESPONSE,
GPMSG_ABILITY_STATUS,
+ GPMSG_ABILITY_REMOVED,
0
};
handledMessages = _messages;
@@ -245,10 +246,8 @@ void PlayerHandler::handleMessage(MessageIn &msg)
case GPMSG_ABILITY_STATUS:
{
- PlayerInfo::clearAbilityStatus();
while (msg.getUnreadLength())
{
- // { B abilityID, L current, L max, L recharge }
int id = msg.readInt8();
int current = msg.readInt32();
int max = msg.readInt32();
@@ -256,6 +255,13 @@ void PlayerHandler::handleMessage(MessageIn &msg)
PlayerInfo::setAbilityStatus(id, current, max, recharge);
}
} break;
+
+ case GPMSG_ABILITY_REMOVED:
+ {
+ int id = msg.readInt8();
+ PlayerInfo::clearAbilityStatus(id);
+ } break;
+
/*
case SMSG_PLAYER_ARROW_MESSAGE:
{
diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp
index 6eaa20b7..a05ffaaa 100644
--- a/src/playerinfo.cpp
+++ b/src/playerinfo.cpp
@@ -280,9 +280,9 @@ void setBuySellState(BuySellState buySellState)
// --- Abilities --------------------------------------------------------------
-void clearAbilityStatus()
+void clearAbilityStatus(int id)
{
- mAbilities.clear();
+ mAbilities.erase(id);
}
void setAbilityStatus(int id, int current, int max, int recharge)
diff --git a/src/playerinfo.h b/src/playerinfo.h
index 8ac82463..492ccf42 100644
--- a/src/playerinfo.h
+++ b/src/playerinfo.h
@@ -218,9 +218,9 @@ namespace PlayerInfo
// --- Abilities --------------------------------------------------------------
/**
- * Removes all abilities.
+ * Removes the status for the given ability.
*/
- void clearAbilityStatus();
+ void clearAbilityStatus(int id);
/**
* Changes the status of the given ability.
@@ -228,7 +228,7 @@ namespace PlayerInfo
void setAbilityStatus(int id, int current, int max, int recharge);
/**
- * Returns the status of the given ability.
+ * Returns the status all abilities.
*/
const std::map<int, Ability> &getAbilityStatus();