mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Battle.net: Fixed client crashes happening when reconnecting too soon after being kicked
This commit is contained in:
@@ -97,15 +97,19 @@ void WorldListener::HandleToonOnlineStatusChange(Battlenet::RealmHandle const& r
|
||||
{
|
||||
if (online)
|
||||
{
|
||||
Battlenet::WoWRealm::ToonReady* toonReady = new Battlenet::WoWRealm::ToonReady();
|
||||
toonReady->Realm.Battlegroup = realm.Battlegroup;
|
||||
toonReady->Realm.Index = realm.Index;
|
||||
toonReady->Realm.Region = realm.Region;
|
||||
toonReady->Guid = toonHandle.Guid;
|
||||
toonReady->Name = toonHandle.Name;
|
||||
session->AsyncWrite(toonReady);
|
||||
if (!session->IsToonOnline())
|
||||
{
|
||||
Battlenet::WoWRealm::ToonReady* toonReady = new Battlenet::WoWRealm::ToonReady();
|
||||
toonReady->Realm.Battlegroup = realm.Battlegroup;
|
||||
toonReady->Realm.Index = realm.Index;
|
||||
toonReady->Realm.Region = realm.Region;
|
||||
toonReady->Guid = toonHandle.Guid;
|
||||
toonReady->Name = toonHandle.Name;
|
||||
session->SetToonOnline(true);
|
||||
session->AsyncWrite(toonReady);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (session->IsToonOnline())
|
||||
session->AsyncWrite(new Battlenet::WoWRealm::ToonLoggedOut());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ Battlenet::Session::ModuleHandler const Battlenet::Session::ModuleHandlers[MODUL
|
||||
|
||||
Battlenet::Session::Session(tcp::socket&& socket) : Socket(std::move(socket)), _accountId(0), _accountName(), _locale(),
|
||||
_os(), _build(0), _gameAccountId(0), _gameAccountName(), _accountSecurityLevel(SEC_PLAYER), I(), s(), v(), b(), B(), K(),
|
||||
_reconnectProof(), _crypt(), _authed(false), _subscribedToRealmListUpdates(false)
|
||||
_reconnectProof(), _crypt(), _authed(false), _subscribedToRealmListUpdates(false), _toonOnline(false)
|
||||
{
|
||||
static uint8 const N_Bytes[] =
|
||||
{
|
||||
|
||||
@@ -91,6 +91,9 @@ namespace Battlenet
|
||||
uint32 GetAccountId() const { return _accountId; }
|
||||
uint32 GetGameAccountId() const { return _gameAccountId; }
|
||||
|
||||
bool IsToonOnline() const { return _toonOnline; }
|
||||
void SetToonOnline(bool online) { _toonOnline = online; }
|
||||
|
||||
bool IsSubscribedToRealmListUpdates() const { return _subscribedToRealmListUpdates; }
|
||||
|
||||
void AsyncWrite(ServerPacket* packet);
|
||||
@@ -141,6 +144,7 @@ namespace Battlenet
|
||||
PacketCrypt _crypt;
|
||||
bool _authed;
|
||||
bool _subscribedToRealmListUpdates;
|
||||
bool _toonOnline;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -46,7 +46,11 @@ void Battlenet::SessionManager::AddSession(Session* session)
|
||||
void Battlenet::SessionManager::RemoveSession(Session* session)
|
||||
{
|
||||
std::unique_lock<boost::shared_mutex> lock(_sessionMutex);
|
||||
_sessions.erase({ session->GetAccountId(), session->GetGameAccountId() });
|
||||
auto itr = _sessions.find({ session->GetAccountId(), session->GetGameAccountId() });
|
||||
// Remove old session only if it was not overwritten by reconnecting
|
||||
if (itr != _sessions.end() && itr->second == session)
|
||||
_sessions.erase(itr);
|
||||
|
||||
_sessionsByAccountId[session->GetAccountId()].remove(session);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user