From 452b1a1eae3aa627080a4f421f4f8469ae37f398 Mon Sep 17 00:00:00 2001 From: KimLS Date: Sat, 7 Feb 2015 15:54:42 -0800 Subject: [PATCH] Added throttling to some appearance packets, also removed responding to client light packets. With the new light code we'll tell the client when the light has changed not the other way around. --- zone/client.cpp | 5 +++++ zone/client.h | 5 +++++ zone/client_packet.cpp | 36 +++++++++++++++++++++--------------- zone/client_process.cpp | 7 +++++++ 4 files changed, 38 insertions(+), 15 deletions(-) diff --git a/zone/client.cpp b/zone/client.cpp index 5cc5ae309..6adffd471 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -141,6 +141,11 @@ Client::Client(EQStreamInterface* ieqs) merc_timer(RuleI(Mercs, UpkeepIntervalMS)), ItemTickTimer(10000), ItemQuestTimer(500), + anim_change_timer(100), + anon_toggle_timer(250), + afk_toggle_timer(250), + helm_toggle_timer(250), + light_update_timer(250), m_Proximity(FLT_MAX, FLT_MAX, FLT_MAX), //arbitrary large number m_ZoneSummonLocation(-2.0f,-2.0f,-2.0f), m_AutoAttackPosition(0.0f, 0.0f, 0.0f, 0.0f), diff --git a/zone/client.h b/zone/client.h index a2cb823f1..3d5bc8e4b 100644 --- a/zone/client.h +++ b/zone/client.h @@ -1465,6 +1465,11 @@ private: Timer TrackingTimer; Timer RespawnFromHoverTimer; Timer merc_timer; + Timer anim_change_timer; + Timer anon_toggle_timer; + Timer afk_toggle_timer; + Timer helm_toggle_timer; + Timer light_update_timer; glm::vec3 m_Proximity; diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 8ade0bc55..24a811016 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -12640,6 +12640,10 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) else if (sa->type == AT_Anim) { if (IsAIControlled()) return; + + if(!anim_change_timer.Check()) + return; + if (sa->parameter == ANIM_STAND) { SetAppearance(eaStanding); playeraction = 0; @@ -12673,15 +12677,6 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) SetFeigned(false); } - // This is from old code - // I have no clue what it's for - /* - else if (sa->parameter == 0x05) { - // Illusion - std::cout << "Illusion packet recv'd:" << std::endl; - DumpPacket(app); - } - */ else { std::cerr << "Client " << name << " unknown apperance " << (int)sa->parameter << std::endl; return; @@ -12690,6 +12685,10 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) entity_list.QueueClients(this, app, true); } else if (sa->type == AT_Anon) { + if(!anon_toggle_timer.Check()) { + return; + } + // For Anon/Roleplay if (sa->parameter == 1) { // Anon m_pp.anon = 1; @@ -12711,13 +12710,18 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) return; } else if (sa->type == AT_AFK) { - this->AFK = (sa->parameter == 1); - entity_list.QueueClients(this, app, true); + if(afk_toggle_timer.Check()) { + AFK = (sa->parameter == 1); + entity_list.QueueClients(this, app, true); + } } else if (sa->type == AT_Split) { m_pp.autosplit = (sa->parameter == 1); } else if (sa->type == AT_Sneak) { + if(sneaking == 0) + return; + if (sa->parameter != 0) { if (!HasSkill(SkillSneak)) @@ -12729,7 +12733,7 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) } return; } - this->sneaking = 0; + sneaking = 0; entity_list.QueueClients(this, app, true); } else if (sa->type == AT_Size) @@ -12741,7 +12745,7 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) } else if (sa->type == AT_Light) // client emitting light (lightstone, shiny shield) { - entity_list.QueueClients(this, app, false); + //don't do anything with this } else if (sa->type == AT_Levitate) { @@ -12750,8 +12754,10 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) } else if (sa->type == AT_ShowHelm) { - m_pp.showhelm = (sa->parameter == 1); - entity_list.QueueClients(this, app, true); + if(helm_toggle_timer.Check()) { + m_pp.showhelm = (sa->parameter == 1); + entity_list.QueueClients(this, app, true); + } } else { std::cout << "Unknown SpawnAppearance type: 0x" << std::hex << std::setw(4) << std::setfill('0') << sa->type << std::dec diff --git a/zone/client_process.cpp b/zone/client_process.cpp index bddc874c2..e978552e8 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -260,6 +260,13 @@ bool Client::Process() { } } + if(light_update_timer.Check()) { + UpdateEquipLightValue(); + if(UpdateActiveLightValue()) { + SendAppearancePacket(AT_Light, GetActiveLightValue()); + } + } + bool may_use_attacks = false; /* Things which prevent us from attacking: