From f386fcbebbfb59426e566f6f749c8d064b123d32 Mon Sep 17 00:00:00 2001 From: Warlockbugs Date: Sun, 8 Dec 2024 05:22:31 +0300 Subject: [PATCH] Tryfixing secure UI frames broken on reconnecting in combat This is an important UI QoL fix mostly aimed at 2.0.0+ clients to ensure secure UI elements created/initialized properly when reconnecting in combat. 1.12.x is not affected as much by this due to less restrictive UI API. --- src/game/Entities/CharacterHandler.cpp | 8 ++++++++ src/game/Entities/Object.cpp | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/src/game/Entities/CharacterHandler.cpp b/src/game/Entities/CharacterHandler.cpp index e45aa8f98c..ceaa8eab0d 100644 --- a/src/game/Entities/CharacterHandler.cpp +++ b/src/game/Entities/CharacterHandler.cpp @@ -948,6 +948,9 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) void WorldSession::HandlePlayerReconnect() { + // Detect if reconnecting in combat + const bool inCombat = _player->IsInCombat(); + // stop logout timer if need LogoutRequest(0); @@ -1073,6 +1076,10 @@ void WorldSession::HandlePlayerReconnect() // Undo flags and states set by logout if present: _player->SetStunnedByLogout(false); + // Mark self for unit flags update to ensure re-application of combat flag at own client + if (inCombat) + _player->ForceValuesUpdateAtIndex(UNIT_FIELD_FLAGS); + m_playerLoading = false; } @@ -1235,3 +1242,4 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(QueryResult* result, uin sWorld.InvalidatePlayerDataToAllClient(guid); } + diff --git a/src/game/Entities/Object.cpp b/src/game/Entities/Object.cpp index e261610657..3a5b7caa33 100644 --- a/src/game/Entities/Object.cpp +++ b/src/game/Entities/Object.cpp @@ -527,6 +527,13 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask* u value &= ~UNIT_FLAG_TAXI_FLIGHT; } + // On login/reconnect: delay combat state application at client UI to not interfere with secure frames init + if (target == this && (value & UNIT_FLAG_IN_COMBAT)) + { + if (static_cast(this)->GetSession()->PlayerLoading()) + value &= ~UNIT_FLAG_IN_COMBAT; + } + *data << value; } // Hide lootable animation for unallowed players