From 9e1549b61b4a7fa493d2f6a77452cff4624650e4 Mon Sep 17 00:00:00 2001 From: Uleat Date: Sat, 16 Aug 2014 18:12:21 -0400 Subject: [PATCH] Fix for invalid handling of heading criteria in Client::Handle_OP_ClientUpdate() --- changelog.txt | 9 +++++++++ common/MiscFunctions.h | 3 ++- zone/client_packet.cpp | 6 ++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/changelog.txt b/changelog.txt index 1f43ed0d9..6e1240815 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,14 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 08/16/2014 == +Uleat (Noudness): Fixed a floating-point comparison error that led to the notorious 'client bounce' (this is not related to the +'mob falling' due to not having maps installed.) This fix also eliminates a sizeable amount of unnecessary out-going packets due +to invalid orientation corrections. + +Note: This patch is probably of significant enough importance that admins may wish to manually apply this to older server builds. +The number of packets reduced per second should be approximately (num_stationary_close_clients * (num_close_clients - 1)). This will +likely have the most effect in zones like: Nexus, Bazaar, Guilds (Halls) and RAID INSTANCES - where players don't move around a lot. + == 08/15/2014 == Uleat: Reactivated the Bot::Spawn() code for sending post-spawn wear change updates..temporary until I can sort out the proper usage. diff --git a/common/MiscFunctions.h b/common/MiscFunctions.h index 2117773f6..c057af8d8 100644 --- a/common/MiscFunctions.h +++ b/common/MiscFunctions.h @@ -103,7 +103,8 @@ int NewFloatToEQ13(float d); int FloatToEQ19(float d); int FloatToEQH(float d); - +// macro to catch fp errors (provided by noudness) +#define FCMP(a,b) (fabs(a-b) < FLT_EPSILON) #define _ITOA_BUFLEN 25 const char *itoa(int num); //not thread safe diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 0d44bfa93..ff8b9e717 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -1231,7 +1231,6 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) delta_y = ppu->delta_y; delta_z = ppu->delta_z; delta_heading = ppu->delta_heading; - heading = EQ19toFloat(ppu->heading); if(IsTracking() && ((x_pos!=ppu->x_pos) || (y_pos!=ppu->y_pos))){ if(MakeRandomFloat(0, 100) < 70)//should be good @@ -1257,12 +1256,15 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) } // Outgoing client packet - if (ppu->y_pos != y_pos || ppu->x_pos != x_pos || ppu->heading != heading || ppu->animation != animation) + float tmpheading = EQ19toFloat(ppu->heading); + + if (!FCMP(ppu->y_pos, y_pos) || !FCMP(ppu->x_pos, x_pos) || !FCMP(tmpheading, heading) || ppu->animation != animation) { x_pos = ppu->x_pos; y_pos = ppu->y_pos; z_pos = ppu->z_pos; animation = ppu->animation; + heading = tmpheading; EQApplicationPacket* outapp = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); PlayerPositionUpdateServer_Struct* ppu = (PlayerPositionUpdateServer_Struct*)outapp->pBuffer;