From 7c1d56ae8932e80e152389c9666bc0a1c0ab5ed8 Mon Sep 17 00:00:00 2001 From: gumi Date: Thu, 13 Dec 2018 17:10:17 -0500 Subject: add support for sending player HP for protocol >= 9 --- src/map/clif.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++--------- src/mmo/version.hpp | 7 +++++-- tools/protocol.py | 18 +++++++++--------- 3 files changed, 56 insertions(+), 20 deletions(-) diff --git a/src/map/clif.cpp b/src/map/clif.cpp index d287f4d..95e4ef2 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -670,9 +670,20 @@ void clif_set0078_main_1d8(dumb_ptr sd, Buffer& buf, bool old_ fixed_1d8.hair_color = sd->status.hair_color; fixed_1d8.clothes_color = sd->status.clothes_color; fixed_1d8.head_dir = sd->head_dir; - fixed_1d8.guild_id = 0; - fixed_1d8.guild_emblem_id = 0; - fixed_1d8.manner = sd->status.manner; + + if (sd->client_version >= wrap(9)) + { + fixed_1d8.hp = sd->status.hp; + fixed_1d8.part_of_max_hp = static_cast(sd->status.max_hp & 0xffff); + fixed_1d8.manner_or_part_of_max_hp = static_cast(sd->status.max_hp >> 16); + } + else + { + fixed_1d8.hp = 0; // guild id + fixed_1d8.part_of_max_hp = 0; // guild emblem id + fixed_1d8.manner_or_part_of_max_hp = sd->status.manner; + } + fixed_1d8.opt3 = sd->opt3; fixed_1d8.karma = sd->status.karma; fixed_1d8.sex = sd->status.sex; @@ -725,9 +736,20 @@ void clif_set0078_alt_1d9(dumb_ptr sd, Buffer& buf, bool old_c fixed_1d8.hair_color = sd->status.hair_color; fixed_1d8.clothes_color = sd->status.clothes_color; fixed_1d8.head_dir = sd->head_dir; - fixed_1d8.guild_id = 0; - fixed_1d8.guild_emblem_id = 0; - fixed_1d8.manner = sd->status.manner; + + if (sd->client_version >= wrap(9)) + { + fixed_1d8.hp = sd->status.hp; + fixed_1d8.part_of_max_hp = static_cast(sd->status.max_hp & 0xffff); + fixed_1d8.manner_or_part_of_max_hp = static_cast(sd->status.max_hp >> 16); + } + else + { + fixed_1d8.hp = 0; // guild id + fixed_1d8.part_of_max_hp = 0; // guild emblem id + fixed_1d8.manner_or_part_of_max_hp = sd->status.manner; + } + fixed_1d8.opt3 = sd->opt3; fixed_1d8.karma = sd->status.karma; fixed_1d8.sex = sd->status.sex; @@ -781,9 +803,20 @@ void clif_set007b(dumb_ptr sd, Buffer& buf, bool old_client) fixed_1da.hair_color = sd->status.hair_color; fixed_1da.clothes_color = sd->status.clothes_color; fixed_1da.head_dir = sd->head_dir; - fixed_1da.guild_id = 0; - fixed_1da.guild_emblem_id = 0; - fixed_1da.manner = sd->status.manner; + + if (sd->client_version >= wrap(9)) + { + fixed_1da.hp = sd->status.hp; + fixed_1da.part_of_max_hp = static_cast(sd->status.max_hp & 0xffff); + fixed_1da.manner_or_part_of_max_hp = static_cast(sd->status.max_hp >> 16); + } + else + { + fixed_1da.hp = 0; // guild id + fixed_1da.part_of_max_hp = 0; // guild emblem id + fixed_1da.manner_or_part_of_max_hp = sd->status.manner; + } + fixed_1da.opt3 = sd->opt3; fixed_1da.karma = sd->status.karma; fixed_1da.sex = sd->status.sex; diff --git a/src/mmo/version.hpp b/src/mmo/version.hpp index 79d67fe..598bfd9 100644 --- a/src/mmo/version.hpp +++ b/src/mmo/version.hpp @@ -41,8 +41,11 @@ namespace tmwa // 3 = manaplus 1.5.5.23 to manaplus 1.5.8.15 // 4 = manaplus 1.5.8.15 to manaplus 1.6.3.15 // 5 = manaplus 1.6.3.15 to 1.6.4.23 (adds SMSG_SCRIPT_MESSAGE) -// 6 = manaplus 1.6.4.23 and above -#define MIN_CLIENT_VERSION 1 +// 6 = manaplus 1.6.4.23 to 1.6.5.7 (adds a filter to block remote commands) +// 7 = manaplus 1.6.5.7 to 1.8.9.1 (adds SMSG_MAP_SET_TILES_TYPE) +// 8 = manaplus 1.8.9.1 to ... (adds support for GM groups) +// 9 = manaplus ... to (adds support for player HP) +#define MIN_CLIENT_VERSION 6 // TODO now that I generate the protocol, split 'flags' out of the struct struct Version diff --git a/tools/protocol.py b/tools/protocol.py index 9820056..3a0e25e 100755 --- a/tools/protocol.py +++ b/tools/protocol.py @@ -4438,9 +4438,9 @@ def build_context(): at(30, u16, 'clothes color'), at(32, dir, 'head dir'), at(33, u8, 'unused2'), - at(34, u32, 'guild id'), - at(38, u16, 'guild emblem id'), - at(40, u16, 'manner'), + at(34, u32, 'hp'), + at(38, u16, 'part of max hp'), + at(40, u16, 'manner or part of max hp'), at(42, opt3, 'opt3'), at(44, u8, 'karma'), at(45, sex, 'sex'), @@ -4480,9 +4480,9 @@ def build_context(): at(30, u16, 'clothes color'), at(32, dir, 'head dir'), at(33, u8, 'unused2'), - at(34, u32, 'guild id'), - at(38, u16, 'guild emblem id'), - at(40, u16, 'manner'), + at(34, u32, 'hp'), + at(38, u16, 'part of max hp'), + at(40, u16, 'manner or part of max hp'), at(42, opt3, 'opt3'), at(44, u8, 'karma'), at(45, sex, 'sex'), @@ -4522,9 +4522,9 @@ def build_context(): at(34, u16, 'clothes color'), at(36, dir, 'head dir'), at(37, u8, 'unused2'), - at(38, u32, 'guild id'), - at(42, u16, 'guild emblem id'), - at(44, u16, 'manner'), + at(38, u32, 'hp'), + at(42, u16, 'part of max hp'), + at(44, u16, 'manner or part of max hp'), at(46, opt3, 'opt3'), at(48, u8, 'karma'), at(49, sex, 'sex'), -- cgit v1.2.3-60-g2f50