Fix for player hp updates not matching between client and server

This commit is contained in:
Uleat 2020-01-28 21:24:14 -05:00
parent c82d08cf11
commit 92d32feb0d
4 changed files with 22 additions and 1 deletions

View File

@ -336,6 +336,10 @@ int32 Client::CalcMaxHP()
current_hp = curHP_cap;
}
}
// hack fix for client health not reflecting server value
last_max_hp = 0;
return max_hp;
}

View File

@ -186,6 +186,7 @@ Mob::Mob(
last_hp_percent = 0;
last_hp = 0;
last_max_hp = 0;
current_speed = base_runspeed;
@ -1334,6 +1335,16 @@ void Mob::SendHPUpdate(bool skip_self /*= false*/, bool force_update_all /*= fal
* If our HP is different from last HP update call - let's update selves
*/
if (IsClient()) {
// delay to allow the client to catch up on buff states
if (max_hp != last_max_hp) {
last_max_hp = max_hp;
CastToClient()->hp_self_update_throttle_timer.Trigger();
return;
}
if (current_hp != last_hp || force_update_all) {
/**
@ -1341,10 +1352,12 @@ void Mob::SendHPUpdate(bool skip_self /*= false*/, bool force_update_all /*= fal
*/
if (this->CastToClient()->hp_self_update_throttle_timer.Check() || force_update_all) {
Log(Logs::General, Logs::HPUpdate,
"Mob::SendHPUpdate :: Update HP of self (%s) HP: %i last: %i skip_self: %s",
"Mob::SendHPUpdate :: Update HP of self (%s) HP: %i/%i last: %i/%i skip_self: %s",
this->GetCleanName(),
current_hp,
max_hp,
last_hp,
last_max_hp,
(skip_self ? "true" : "false")
);

View File

@ -1526,6 +1526,7 @@ protected:
int8 last_hp_percent;
int32 last_hp;
int32 last_max_hp;
int cur_wp;
glm::vec4 m_CurrentWayPoint;

View File

@ -286,6 +286,9 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
dmg = -dmg;
}
// hack fix for client health not reflecting server value
last_hp = 0;
//do any AAs apply to these spells?
if(dmg < 0) {
if (!PassCastRestriction(false, spells[spell_id].base2[i], true))