[Hitpoints] More HP Fixes - Remove Hacks (#1518)

* Fix HP update throttling

* Remove more hacks

Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
splose 2021-09-05 00:17:59 -04:00 committed by GitHub
parent 41352f77ae
commit 943c623be0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 21 deletions

View File

@ -3739,7 +3739,7 @@ void Mob::CommonDamage(Mob* attacker, int &damage, const uint16 spell_id, const
//send an HP update if we are hurt
if (GetHP() < GetMaxHP())
SendHPUpdate(!iBuffTic); // the OP_Damage actually updates the client in these cases, so we skip the HP update for them
SendHPUpdate(); // the OP_Damage actually updates the client in these cases, so we skip the HP update for them
} //end `if damage was done`
//send damage packet...

View File

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

View File

@ -190,7 +190,6 @@ Mob::Mob(
last_hp_percent = 0;
last_hp = 0;
last_max_hp = 0;
current_speed = base_runspeed;
@ -1355,32 +1354,22 @@ void Mob::CreateHPPacket(EQApplicationPacket* app)
}
}
void Mob::SendHPUpdate(bool skip_self /*= false*/, bool force_update_all /*= false*/)
void Mob::SendHPUpdate(bool force_update_all)
{
// If our HP is different from last HP update call - let's update selves
if (IsClient()) {
// delay allowing the client to catch up on buff states
if (max_hp != last_max_hp) {
last_max_hp = max_hp;
return;
}
if (current_hp != last_hp || force_update_all) {
// This is to prevent excessive packet sending under trains/fast combat
LogHPUpdate(
"[SendHPUpdate] Update HP of self [{}] HP: [{}/{}] last: [{}/{}] skip_self: [{}]",
"[SendHPUpdate] Update HP of self [{}] current_hp [{}] max_hp [{}] last_hp [{}]",
GetCleanName(),
current_hp,
max_hp,
last_hp,
last_max_hp,
(skip_self ? "true" : "false")
last_hp
);
if (!skip_self || this->CastToClient()->ClientVersion() >= EQ::versions::ClientVersion::SoD) {
if (CastToClient()->ClientVersion() >= EQ::versions::ClientVersion::SoD) {
auto client_packet = new EQApplicationPacket(OP_HPUpdate, sizeof(SpawnHPUpdate_Struct));
auto *hp_packet_client = (SpawnHPUpdate_Struct *) client_packet->pBuffer;
@ -3279,7 +3268,7 @@ void Mob::SetTarget(Mob *mob)
}
if (IsClient() && GetTarget()) {
GetTarget()->SendHPUpdate(false, true);
GetTarget()->SendHPUpdate(true);
}
}

View File

@ -680,7 +680,7 @@ public:
static void CreateSpawnPacket(EQApplicationPacket* app, NewSpawn_Struct* ns);
virtual void FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho);
void CreateHPPacket(EQApplicationPacket* app);
void SendHPUpdate(bool skip_self = false, bool force_update_all = false);
void SendHPUpdate(bool force_update_all = false);
virtual void ResetHPUpdateTimer() {}; // does nothing
//Util