From 2b59043709507e5acbf952ed2cf835f066cadd11 Mon Sep 17 00:00:00 2001 From: killerwife Date: Tue, 7 Jan 2025 13:10:32 +0100 Subject: [PATCH] Player: Cleanup reconnect protocol vs connect protocol --- src/game/Entities/CharacterHandler.cpp | 14 ++------ src/game/Entities/Player.cpp | 36 ++++++++++--------- src/game/Entities/Player.h | 2 +- src/game/MotionGenerators/MovementHandler.cpp | 2 +- 4 files changed, 24 insertions(+), 30 deletions(-) diff --git a/src/game/Entities/CharacterHandler.cpp b/src/game/Entities/CharacterHandler.cpp index 5273fbe2768..f66d2db34e2 100644 --- a/src/game/Entities/CharacterHandler.cpp +++ b/src/game/Entities/CharacterHandler.cpp @@ -983,7 +983,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) group->SendUpdateTo(pCurrChar); - pCurrChar->SendInitialPacketsAfterAddToMap(); + pCurrChar->SendInitialPacketsAfterAddToMap(false); static SqlStatementID updChars; static SqlStatementID updAccount; @@ -1193,14 +1193,7 @@ void WorldSession::HandlePlayerReconnect() if (group) group->SendUpdateTo(_player); - _player->GetSocial()->SendSocialList(); - uint32 areaId = 0; - uint32 zoneId = 0; - _player->GetZoneAndAreaId(zoneId, areaId); - _player->SendInitWorldStates(zoneId, areaId); - _player->CastSpell(_player, 836, TRIGGERED_OLD_TRIGGERED); // LOGINEFFECT - _player->SendEnchantmentDurations(); // must be after add to map - _player->SendItemDurations(); // must be after add to map + _player->SendInitialPacketsAfterAddToMap(true); // Send friend list online status for other players sSocialMgr.SendFriendStatus(_player, FRIEND_ONLINE, _player->GetObjectGuid(), true); @@ -1222,9 +1215,6 @@ void WorldSession::HandlePlayerReconnect() sLog.outChar("Account: %d (IP: %s) Login Character:[%s] (guid: %u)", GetAccountId(), IP_str.c_str(), _player->GetName(), _player->GetGUIDLow()); - // sync client auras timer - _player->UpdateClientAuras(); - // sync client control (if taxi flying the client is already sync) if (_player->IsTaxiFlying()) _player->TaxiFlightResume(true); diff --git a/src/game/Entities/Player.cpp b/src/game/Entities/Player.cpp index 609444113bb..30dc9eb6df4 100644 --- a/src/game/Entities/Player.cpp +++ b/src/game/Entities/Player.cpp @@ -21430,7 +21430,7 @@ void Player::SendInitialPacketsBeforeAddToMap() SetMover(this); } -void Player::SendInitialPacketsAfterAddToMap() +void Player::SendInitialPacketsAfterAddToMap(bool reconnect) { // update zone uint32 newzone, newarea; @@ -21442,23 +21442,27 @@ void Player::SendInitialPacketsAfterAddToMap() CastSpell(nullptr, 836, TRIGGERED_OLD_TRIGGERED); // LOGINEFFECT - RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_LOGIN_CANCELS); + if (!reconnect) + RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_LOGIN_CANCELS); - // set some aura effects that send packet to player client after add player to map - // SendMessageToSet not send it to player not it map, only for aura that not changed anything at re-apply - // same auras state lost at far teleport, send it one more time in this case also - static const AuraType auratypes[] = + if (!reconnect) { - SPELL_AURA_GHOST, SPELL_AURA_TRANSFORM, SPELL_AURA_WATER_WALK, - SPELL_AURA_FEATHER_FALL, SPELL_AURA_HOVER, SPELL_AURA_SAFE_FALL, - SPELL_AURA_MOD_STUN, SPELL_AURA_MOD_ROOT, SPELL_AURA_MOD_FEAR, - SPELL_AURA_FLY, SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED, SPELL_AURA_NONE - }; - for (AuraType const* itr = &auratypes[0]; itr && itr[0] != SPELL_AURA_NONE; ++itr) - { - Unit::AuraList const& auraList = GetAurasByType(*itr); - if (!auraList.empty()) - auraList.front()->ApplyModifier(true, true); + // set some aura effects that send packet to player client after add player to map + // SendMessageToSet not send it to player not it map, only for aura that not changed anything at re-apply + // same auras state lost at far teleport, send it one more time in this case also + static const AuraType auratypes[] = + { + SPELL_AURA_GHOST, SPELL_AURA_TRANSFORM, SPELL_AURA_WATER_WALK, + SPELL_AURA_FEATHER_FALL, SPELL_AURA_HOVER, SPELL_AURA_SAFE_FALL, + SPELL_AURA_MOD_STUN, SPELL_AURA_MOD_ROOT, SPELL_AURA_MOD_FEAR, + SPELL_AURA_FLY, SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED, SPELL_AURA_NONE + }; + for (AuraType const* itr = &auratypes[0]; itr && itr[0] != SPELL_AURA_NONE; ++itr) + { + Unit::AuraList const& auraList = GetAurasByType(*itr); + if (!auraList.empty()) + auraList.front()->ApplyModifier(true, true); + } } WorldPacket setCompoundState(SMSG_MULTIPLE_MOVES, 100); diff --git a/src/game/Entities/Player.h b/src/game/Entities/Player.h index 599fcf3d88e..0eb27cb1b57 100644 --- a/src/game/Entities/Player.h +++ b/src/game/Entities/Player.h @@ -1113,7 +1113,7 @@ class Player : public Unit static bool BuildEnumData(QueryResult* result, WorldPacket& p_data); void SendInitialPacketsBeforeAddToMap(); - void SendInitialPacketsAfterAddToMap(); + void SendInitialPacketsAfterAddToMap(bool reconnect); void SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time) const; Creature* GetNPCIfCanInteractWith(ObjectGuid guid, uint32 npcflagmask); diff --git a/src/game/MotionGenerators/MovementHandler.cpp b/src/game/MotionGenerators/MovementHandler.cpp index ed022ff84ad..df33baf8da5 100644 --- a/src/game/MotionGenerators/MovementHandler.cpp +++ b/src/game/MotionGenerators/MovementHandler.cpp @@ -235,7 +235,7 @@ void WorldSession::HandleMoveWorldportAckOpcode() m_anticheat->Teleport({ loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation }); - GetPlayer()->SendInitialPacketsAfterAddToMap(); + GetPlayer()->SendInitialPacketsAfterAddToMap(false); // flight fast teleport case if (_player->InBattleGround())