[Hitpoints] Remove HP Update Throttling (#1517)

* Remove HP update throttling and increase HP update resolution and accuracy

* Make some log statements detail

* Add better logging messages

* Remove old self update throttle block check preventing updates to self
This commit is contained in:
Chris Miles 2021-09-03 19:47:25 -05:00 committed by GitHub
parent 7f823256f4
commit e1df72d64d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 73 deletions

View File

@ -169,8 +169,6 @@ Client::Client(EQStreamInterface* ieqs)
last_region_type(RegionTypeUnsupported), last_region_type(RegionTypeUnsupported),
m_dirtyautohaters(false), m_dirtyautohaters(false),
mob_close_scan_timer(6000), mob_close_scan_timer(6000),
hp_self_update_throttle_timer(300),
hp_other_update_throttle_timer(500),
position_update_timer(10000), position_update_timer(10000),
consent_throttle_timer(2000), consent_throttle_timer(2000),
tmSitting(0) tmSitting(0)

View File

@ -1818,8 +1818,6 @@ private:
Timer helm_toggle_timer; Timer helm_toggle_timer;
Timer aggro_meter_timer; Timer aggro_meter_timer;
Timer mob_close_scan_timer; Timer mob_close_scan_timer;
Timer hp_self_update_throttle_timer; /* This is to prevent excessive packet sending under trains/fast combat */
Timer hp_other_update_throttle_timer; /* This is to keep clients from DOSing the server with macros that change client targets constantly */
Timer position_update_timer; /* Timer used when client hasn't updated within a 10 second window */ Timer position_update_timer; /* Timer used when client hasn't updated within a 10 second window */
Timer consent_throttle_timer; Timer consent_throttle_timer;
Timer dynamiczone_removal_timer; Timer dynamiczone_removal_timer;

View File

@ -119,8 +119,9 @@ bool Client::Process() {
// SendHPUpdate calls hpupdate_timer.Start so it can delay this timer, so lets not reset with the check // SendHPUpdate calls hpupdate_timer.Start so it can delay this timer, so lets not reset with the check
// since the function will anyways // since the function will anyways
if (hpupdate_timer.Check(false)) if (hpupdate_timer.Check(false)) {
SendHPUpdate(); SendHPUpdate();
}
/* I haven't naturally updated my position in 10 seconds, updating manually */ /* I haven't naturally updated my position in 10 seconds, updating manually */
if (!is_client_moving && position_update_timer.Check()) { if (!is_client_moving && position_update_timer.Check()) {

View File

@ -1355,31 +1355,24 @@ void Mob::CreateHPPacket(EQApplicationPacket* app)
} }
} }
void Mob::SendHPUpdate(bool skip_self /*= false*/, bool force_update_all /*= false*/) { void Mob::SendHPUpdate(bool skip_self /*= false*/, bool force_update_all /*= false*/)
{
/** // If our HP is different from last HP update call - let's update selves
* If our HP is different from last HP update call - let's update selves
*/
if (IsClient()) { if (IsClient()) {
// delay to allow the client to catch up on buff states // delay allowing the client to catch up on buff states
if (max_hp != last_max_hp) { if (max_hp != last_max_hp) {
last_max_hp = max_hp; last_max_hp = max_hp;
CastToClient()->hp_self_update_throttle_timer.Trigger();
return; return;
} }
if (current_hp != last_hp || force_update_all) { if (current_hp != last_hp || force_update_all) {
/** // This is to prevent excessive packet sending under trains/fast combat
* This is to prevent excessive packet sending under trains/fast combat LogHPUpdate(
*/ "[SendHPUpdate] Update HP of self [{}] HP: [{}/{}] last: [{}/{}] skip_self: [{}]",
if (this->CastToClient()->hp_self_update_throttle_timer.Check() || force_update_all) { GetCleanName(),
Log(Logs::General, Logs::HPUpdate,
"Mob::SendHPUpdate :: Update HP of self (%s) HP: %i/%i last: %i/%i skip_self: %s",
this->GetCleanName(),
current_hp, current_hp,
max_hp, max_hp,
last_hp, last_hp,
@ -1402,35 +1395,32 @@ void Mob::SendHPUpdate(bool skip_self /*= false*/, bool force_update_all /*= fal
ResetHPUpdateTimer(); ResetHPUpdateTimer();
} }
/** // Used to check if HP has changed to update self next round
* Used to check if HP has changed to update self next round
*/
last_hp = current_hp; last_hp = current_hp;
} }
} }
}
auto current_hp_percent = GetIntHPRatio(); auto current_hp_percent = GetIntHPRatio();
Log(Logs::General, LogHPUpdateDetail(
Logs::HPUpdate, "[SendHPUpdate] Client [{}] HP is [{}] last [{}]",
"Mob::SendHPUpdate :: SendHPUpdate %s HP is %i last %i", GetCleanName(),
this->GetCleanName(),
current_hp_percent, current_hp_percent,
last_hp_percent); last_hp_percent
);
if (current_hp_percent == last_hp_percent && !force_update_all) { if (current_hp_percent == last_hp_percent && !force_update_all) {
Log(Logs::General, Logs::HPUpdate, "Mob::SendHPUpdate :: Same HP - skipping update"); LogHPUpdateDetail("[SendHPUpdate] Same HP for mob [{}] skipping update", GetCleanName());
ResetHPUpdateTimer(); ResetHPUpdateTimer();
return; return;
} }
else { else {
if (IsClient() && RuleB(Character, MarqueeHPUpdates)) { if (IsClient() && RuleB(Character, MarqueeHPUpdates)) {
this->CastToClient()->SendHPUpdateMarquee(); CastToClient()->SendHPUpdateMarquee();
} }
Log(Logs::General, Logs::HPUpdate, "Mob::SendHPUpdate :: HP Changed - Send update"); LogHPUpdate("[SendHPUpdate] HP Changed for mob [{}] send update", GetCleanName());
last_hp_percent = current_hp_percent; last_hp_percent = current_hp_percent;
} }
@ -1440,24 +1430,16 @@ void Mob::SendHPUpdate(bool skip_self /*= false*/, bool force_update_all /*= fal
CreateHPPacket(&hp_packet); CreateHPPacket(&hp_packet);
/** // update those who have us targeted
* Update those who have us targeted
*/
entity_list.QueueClientsByTarget(this, &hp_packet, false, 0, false, true, EQ::versions::maskAllClients); entity_list.QueueClientsByTarget(this, &hp_packet, false, 0, false, true, EQ::versions::maskAllClients);
/** // Update those who have us on x-target
* Update those who have us on x-target
*/
entity_list.QueueClientsByXTarget(this, &hp_packet, false); entity_list.QueueClientsByXTarget(this, &hp_packet, false);
/** // Update groups using Group LAA health name tag counter
* Update groups using Group LAA health name tag counter
*/
entity_list.QueueToGroupsForNPCHealthAA(this, &hp_packet); entity_list.QueueToGroupsForNPCHealthAA(this, &hp_packet);
/** // Group
* Group
*/
if (IsGrouped()) { if (IsGrouped()) {
group = entity_list.GetGroupByMob(this); group = entity_list.GetGroupByMob(this);
if (group) { if (group) {
@ -1465,9 +1447,7 @@ void Mob::SendHPUpdate(bool skip_self /*= false*/, bool force_update_all /*= fal
} }
} }
/** // Raid
* Raid
*/
if (IsClient()) { if (IsClient()) {
Raid *raid = entity_list.GetRaidByClient(CastToClient()); Raid *raid = entity_list.GetRaidByClient(CastToClient());
if (raid) { if (raid) {
@ -1475,9 +1455,7 @@ void Mob::SendHPUpdate(bool skip_self /*= false*/, bool force_update_all /*= fal
} }
} }
/** // Pet
* Pet
*/
if (GetOwner() && GetOwner()->IsClient()) { if (GetOwner() && GetOwner()->IsClient()) {
GetOwner()->CastToClient()->QueuePacket(&hp_packet, false); GetOwner()->CastToClient()->QueuePacket(&hp_packet, false);
group = entity_list.GetGroupByClient(GetOwner()->CastToClient()); group = entity_list.GetGroupByClient(GetOwner()->CastToClient());
@ -3282,8 +3260,8 @@ void Mob::SetTarget(Mob *mob)
else if (IsClient()) { else if (IsClient()) {
parse->EventPlayer(EVENT_TARGET_CHANGE, CastToClient(), "", 0); parse->EventPlayer(EVENT_TARGET_CHANGE, CastToClient(), "", 0);
if (this->CastToClient()->admin > 200) { if (CastToClient()->admin > 200) {
this->DisplayInfo(mob); DisplayInfo(mob);
} }
#ifdef BOTS #ifdef BOTS
@ -3295,8 +3273,8 @@ void Mob::SetTarget(Mob *mob)
GetOwner()->CastToClient()->UpdateXTargetType(MyPetTarget, mob); GetOwner()->CastToClient()->UpdateXTargetType(MyPetTarget, mob);
} }
if (this->IsClient() && this->GetTarget() && this->CastToClient()->hp_other_update_throttle_timer.Check()) { if (IsClient() && GetTarget()) {
this->GetTarget()->SendHPUpdate(false, true); GetTarget()->SendHPUpdate(false, true);
} }
} }