From 6da7116c668e613a2d854a01772a058643ee894a Mon Sep 17 00:00:00 2001 From: KayenEQ Date: Tue, 14 Dec 2021 11:26:59 -0500 Subject: [PATCH] [Bug Fix] Hero Forge armor graphics not displaying properly to other clients in zone. (#1883) * fix part1 * updates * Update inventory.cpp * fixed * Update inventory.cpp * update * [Bug Fix] Hero Forge armor graphics not displaying properly to other clients in zone. --- zone/client.cpp | 2 ++ zone/client.h | 2 ++ zone/client_packet.cpp | 25 +++++-------------------- zone/client_process.cpp | 19 +++++++++++++++++++ zone/inventory.cpp | 6 +++++- zone/mob.cpp | 12 ++++++++++++ zone/mob.h | 3 +++ zone/mob_appearance.cpp | 3 +++ 8 files changed, 51 insertions(+), 21 deletions(-) diff --git a/zone/client.cpp b/zone/client.cpp index 5a8bc9d88..fbb1ac106 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -270,6 +270,8 @@ Client::Client(EQStreamInterface* ieqs) if (RuleI(World, PVPMinLevel) > 0 && level >= RuleI(World, PVPMinLevel) && m_pp.pvp == 0) SetPVP(true, false); dynamiczone_removal_timer.Disable(); + heroforge_wearchange_timer.Disable(); + //for good measure: memset(&m_pp, 0, sizeof(m_pp)); memset(&m_epp, 0, sizeof(m_epp)); diff --git a/zone/client.h b/zone/client.h index a9266230d..51649d1b9 100644 --- a/zone/client.h +++ b/zone/client.h @@ -1870,6 +1870,8 @@ private: Timer dynamiczone_removal_timer; Timer task_request_timer; + Timer heroforge_wearchange_timer; + glm::vec3 m_Proximity; glm::vec4 last_position_before_bulk_update; diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 99017d7ce..e23bebe65 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -747,28 +747,11 @@ void Client::CompleteConnect() entity_list.SendAppearanceEffects(this); - int x; - for (x = EQ::textures::textureBegin; x <= EQ::textures::LastTexture; x++) { - SendWearChange(x); - } - // added due to wear change above - UpdateActiveLight(); - SendAppearancePacket(AT_Light, GetActiveLightType()); - - Mob *pet = GetPet(); - if (pet != nullptr) { - for (x = EQ::textures::textureBegin; x <= EQ::textures::LastTexture; x++) { - pet->SendWearChange(x); - } - // added due to wear change above - pet->UpdateActiveLight(); - pet->SendAppearancePacket(AT_Light, pet->GetActiveLightType()); - } - entity_list.SendTraders(this); - if (GetPet()) { - GetPet()->SendPetBuffsToClient(); + Mob *pet = GetPet(); + if (pet) { + pet->SendPetBuffsToClient(); } if (GetGroup()) @@ -918,6 +901,8 @@ void Client::CompleteConnect() worldserver.SendPacket(p); safe_delete(p); } + + heroforge_wearchange_timer.Start(250); } // connecting opcode handlers diff --git a/zone/client_process.cpp b/zone/client_process.cpp index deadb2cbb..b363292e8 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -199,6 +199,25 @@ bool Client::Process() { instalog = true; } + if (heroforge_wearchange_timer.Check()) { + /* + This addresses bug where on zone in heroforge models would not be sent to other clients when this was + in Client::CompleteConnect(). Sending after a small 250 ms delay after that function resolves the issue. + Unclear the underlying reason for this, if a better solution can be found then can move this back. + */ + if (queue_wearchange_slot >= 0) { //Resend slot from Client::SwapItem if heroforge item is swapped. + SendWearChange(static_cast(queue_wearchange_slot)); + } + else { //Send from Client::CompleteConnect() + SendWearChangeAndLighting(EQ::textures::LastTexture); + Mob *pet = GetPet(); + if (pet) { + pet->SendWearChangeAndLighting(EQ::textures::LastTexture); + } + } + heroforge_wearchange_timer.Disable(); + } + if (IsStunned() && stunned_timer.Check()) Mob::UnStun(); diff --git a/zone/inventory.cpp b/zone/inventory.cpp index 62c3148ec..41e67e7b9 100644 --- a/zone/inventory.cpp +++ b/zone/inventory.cpp @@ -2224,9 +2224,13 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { } int matslot = SlotConvert2(dst_slot_id); - if (dst_slot_id <= EQ::invslot::EQUIPMENT_END && matslot != EQ::textures::armorHead) { // think this is to allow the client to update with /showhelm + if (dst_slot_id <= EQ::invslot::EQUIPMENT_END) {// on Titanium and ROF2 /showhelm works even if sending helm slot SendWearChange(matslot); } + // This is part of a bug fix to ensure heroforge graphics display to other clients in zone. + if (queue_wearchange_slot >= 0) { + heroforge_wearchange_timer.Start(100); + } // Step 7: Save change to the database if (src_slot_id == EQ::invslot::slotCursor) { diff --git a/zone/mob.cpp b/zone/mob.cpp index 2274b34a4..972d40afb 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -495,6 +495,8 @@ Mob::Mob( use_double_melee_round_dmg_bonus = false; dw_same_delay = 0; + queue_wearchange_slot = -1; + #ifdef BOTS m_manual_follow = false; #endif @@ -3168,6 +3170,16 @@ bool Mob::UpdateActiveLight() return (m_Light.Level[EQ::lightsource::LightActive] != old_light_level); } +void Mob::SendWearChangeAndLighting(int8 last_texture) { + + for (int i = EQ::textures::textureBegin; i <= last_texture; i++) { + SendWearChange(i); + } + UpdateActiveLight(); + SendAppearancePacket(AT_Light, GetActiveLightType()); + +} + void Mob::ChangeSize(float in_size = 0, bool bNoRestriction) { // Size Code if (!bNoRestriction) diff --git a/zone/mob.h b/zone/mob.h index f82d0eb87..1a7818358 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -911,6 +911,7 @@ public: virtual void UpdateEquipmentLight() { m_Light.Type[EQ::lightsource::LightEquipment] = 0; m_Light.Level[EQ::lightsource::LightEquipment] = 0; } inline void SetSpellLightType(uint8 light_type) { m_Light.Type[EQ::lightsource::LightSpell] = (light_type & 0x0F); m_Light.Level[EQ::lightsource::LightSpell] = EQ::lightsource::TypeToLevel(m_Light.Type[EQ::lightsource::LightSpell]); } + void SendWearChangeAndLighting(int8 last_texture); inline uint8 GetActiveLightType() { return m_Light.Type[EQ::lightsource::LightActive]; } bool UpdateActiveLight(); // returns true if change, false if no change @@ -1515,6 +1516,8 @@ protected: int32 appearance_effects_id[MAX_APPEARANCE_EFFECTS]; int32 appearance_effects_slot[MAX_APPEARANCE_EFFECTS]; + + int queue_wearchange_slot; Timer shield_timer; uint32 m_shield_target_id; diff --git a/zone/mob_appearance.cpp b/zone/mob_appearance.cpp index e0629b83a..112ad81c1 100644 --- a/zone/mob_appearance.cpp +++ b/zone/mob_appearance.cpp @@ -433,6 +433,9 @@ void Mob::SendWearChange(uint8 material_slot, Client *one_client) wear_change->wear_slot_id = material_slot; + // Part of a bug fix to ensure heroforge models send to other clients in zone. + queue_wearchange_slot = wear_change->hero_forge_model ? material_slot : -1; + if (!one_client) { entity_list.QueueClients(this, packet); }