From 5186d3a2eff3a6f8f4bc05097c41469e5dbdc718 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Mon, 8 Jun 2015 18:04:08 -0400 Subject: [PATCH] Make filtering out OP_ClientUpdate less aggressive to fix spinning toons If we are too aggressive filtering out the same position packets it's possible for toons to continue to spin indefinitely. Instead of just not sending the update when the position is the same we keep a tally of how many we get and stop once a threshold (6) is reached. --- zone/client.cpp | 1 + zone/client.h | 3 +++ zone/client_packet.cpp | 13 ++++++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/zone/client.cpp b/zone/client.cpp index 53d39ea7b..e4d49e979 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -208,6 +208,7 @@ Client::Client(EQStreamInterface* ieqs) npclevel = 0; pQueuedSaveWorkID = 0; position_timer_counter = 0; + position_update_same_count = 0; fishing_timer.Disable(); shield_timer.Disable(); dead_timer.Disable(); diff --git a/zone/client.h b/zone/client.h index de093990c..4a166feed 100644 --- a/zone/client.h +++ b/zone/client.h @@ -1447,6 +1447,9 @@ private: Timer position_timer; uint8 position_timer_counter; + // this is used to try to cut back on position update reflections + int position_update_same_count; + PTimerList p_timers; //persistent timers Timer hpupdate_timer; Timer camp_timer; diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 5603023e5..2ae2babac 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -4457,9 +4457,20 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) // Outgoing client packet float tmpheading = EQ19toFloat(ppu->heading); + /* The clients send an update at best every 1.3 seconds + * We want to avoid reflecting these updates to other clients as much as possible + * The client also sends an update every 280 ms while turning, if we prevent + * sending these by checking if the location is the same too aggressively, clients end up spinning + * so keep a count of how many packets are the same within a tolerance and stop when we get there */ - if (!FCMP(ppu->y_pos, m_Position.y) || !FCMP(ppu->x_pos, m_Position.x) || !FCMP(tmpheading, m_Position.w) || ppu->animation != animation) + bool pos_same = FCMP(ppu->y_pos, m_Position.y) && FCMP(ppu->x_pos, m_Position.x) && FCMP(tmpheading, m_Position.w) && ppu->animation == animation; + if (!pos_same || (pos_same && position_update_same_count < 6)) { + if (pos_same) + position_update_same_count++; + else + position_update_same_count = 0; + m_Position.x = ppu->x_pos; m_Position.y = ppu->y_pos; m_Position.z = ppu->z_pos;