Skip to content

Commit

Permalink
Player: Cleanup reconnect protocol vs connect protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
killerwife committed Jan 7, 2025
1 parent 305517b commit 2b59043
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 30 deletions.
14 changes: 2 additions & 12 deletions src/game/Entities/CharacterHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
group->SendUpdateTo(pCurrChar);


pCurrChar->SendInitialPacketsAfterAddToMap();
pCurrChar->SendInitialPacketsAfterAddToMap(false);

static SqlStatementID updChars;
static SqlStatementID updAccount;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
36 changes: 20 additions & 16 deletions src/game/Entities/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21430,7 +21430,7 @@ void Player::SendInitialPacketsBeforeAddToMap()
SetMover(this);
}

void Player::SendInitialPacketsAfterAddToMap()
void Player::SendInitialPacketsAfterAddToMap(bool reconnect)
{
// update zone
uint32 newzone, newarea;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/game/Entities/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/game/MotionGenerators/MovementHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 2b59043

Please sign in to comment.