summaryrefslogtreecommitdiff
path: root/src/server/game/Handlers/CharacterHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Handlers/CharacterHandler.cpp')
-rw-r--r--src/server/game/Handlers/CharacterHandler.cpp56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp
index 259bf34158..1bb8ac6ed2 100644
--- a/src/server/game/Handlers/CharacterHandler.cpp
+++ b/src/server/game/Handlers/CharacterHandler.cpp
@@ -668,51 +668,46 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket& recvData)
void WorldSession::HandlePlayerLoginOpcode(WorldPacket& recvData)
{
- m_playerLoading = true;
- ObjectGuid playerGuid;
- recvData >> playerGuid;
+ if (!sWorld->getBoolConfig(CONFIG_REALM_LOGIN_ENABLED))
+ {
+ SendCharLoginFailed(LoginFailureReason::NoWorld);
+ return;
+ }
- if (PlayerLoading() || GetPlayer() != nullptr || !playerGuid.IsPlayer())
+ if (PlayerLoading() || GetPlayer() != nullptr)
{
- // limit player interaction with the world
- if (!sWorld->getBoolConfig(CONFIG_REALM_LOGIN_ENABLED))
- {
- WorldPacket data(SMSG_CHARACTER_LOGIN_FAILED, 1);
- // see LoginFailureReason enum for more reasons
- data << uint8(LoginFailureReason::NoWorld);
- SendPacket(&data);
- return;
- }
+ LOG_ERROR("network", "Player tried to login again, AccountId = {}", GetAccountId());
+ KickPlayer("WorldSession::HandlePlayerLoginOpcode Another client logging in");
+ return;
}
- if (!playerGuid.IsPlayer() || !IsLegitCharacterForAccount(playerGuid))
+ ObjectGuid playerGuid;
+ recvData >> playerGuid;
+
+ if (!IsLegitCharacterForAccount(playerGuid))
{
LOG_ERROR("network", "Account ({}) can't login with that character ({}).", GetAccountId(), playerGuid.ToString());
KickPlayer("Account can't login with this character");
return;
}
- auto SendCharLogin = [&](ResponseCodes result)
- {
- WorldPacket data(SMSG_CHARACTER_LOGIN_FAILED, 1);
- data << uint8(result);
- SendPacket(&data);
- };
-
// pussywizard:
if (WorldSession* sess = sWorldSessionMgr->FindOfflineSessionForCharacterGUID(playerGuid.GetCounter()))
+ {
if (sess->GetAccountId() != GetAccountId())
{
- SendCharLogin(CHAR_LOGIN_DUPLICATE_CHARACTER);
+ SendCharLoginFailed(LoginFailureReason::DuplicateCharacter);
return;
}
+ }
+
// pussywizard:
if (WorldSession* sess = sWorldSessionMgr->FindOfflineSession(GetAccountId()))
{
Player* p = sess->GetPlayer();
if (!p || sess->IsKicked())
{
- SendCharLogin(CHAR_LOGIN_DUPLICATE_CHARACTER);
+ SendCharLoginFailed(LoginFailureReason::DuplicateCharacter);
return;
}
@@ -723,7 +718,7 @@ void WorldSession::HandlePlayerLoginOpcode(WorldPacket& recvData)
// pussywizard: players stay ingame no matter what (prevent abuse), but allow to turn it off to stop crashing
if (!sWorld->getBoolConfig(CONFIG_ENABLE_LOGIN_AFTER_DC))
{
- SendCharLogin(CHAR_LOGIN_DUPLICATE_CHARACTER);
+ SendCharLoginFailed(LoginFailureReason::DuplicateCharacter);
return;
}
@@ -765,7 +760,7 @@ void WorldSession::HandlePlayerLoginOpcode(WorldPacket& recvData)
}
if (!p->FindMap() || !p->IsInWorld() || sess->IsKicked())
{
- SendCharLogin(CHAR_LOGIN_DUPLICATE_CHARACTER);
+ SendCharLoginFailed(LoginFailureReason::DuplicateCharacter);
return;
}
@@ -781,11 +776,9 @@ void WorldSession::HandlePlayerLoginOpcode(WorldPacket& recvData)
std::shared_ptr<LoginQueryHolder> holder = std::make_shared<LoginQueryHolder>(GetAccountId(), playerGuid);
if (!holder->Initialize())
- {
- m_playerLoading = false;
return;
- }
+ m_playerLoading = true;
AddQueryHolderCallback(CharacterDatabase.DelayQueryHolder(holder)).AfterComplete([this](SQLQueryHolderBase const& holder)
{
HandlePlayerLoginFromDB(static_cast<LoginQueryHolder const&>(holder));
@@ -2575,6 +2568,13 @@ void WorldSession::SendCharDelete(ResponseCodes result)
SendPacket(&data);
}
+void WorldSession::SendCharLoginFailed(LoginFailureReason reason)
+{
+ WorldPacket data(SMSG_CHARACTER_LOGIN_FAILED, 1);
+ data << uint8(reason);
+ SendPacket(&data);
+};
+
void WorldSession::SendCharRename(ResponseCodes result, CharacterRenameInfo const* renameInfo)
{
WorldPacket data(SMSG_CHAR_RENAME, 1 + 8 + renameInfo->Name.size() + 1);