diff options
author | Machiavelli <machiavelli.trinity@gmail.com> | 2013-02-14 16:07:36 +0100 |
---|---|---|
committer | Machiavelli <machiavelli.trinity@gmail.com> | 2013-02-14 16:07:36 +0100 |
commit | 1093abb1ad166546380b3b77bd83c9e934656c98 (patch) | |
tree | c4455bc72ba0b5c829260bf94f2ab7d402a037a1 /src | |
parent | 877a7e9968a0d2a1e3f646a94bfb81018ef318a9 (diff) |
Core/Handlers: Prevent some cheating in CharacterHandler
Prevents factionchanging and char customising of characters that do not
belong to the current account.
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Handlers/CharacterHandler.cpp | 25 | ||||
-rw-r--r-- | src/server/game/Server/WorldSession.h | 6 |
2 files changed, 24 insertions, 7 deletions
diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index 1e6dfa8c94c..02d4d1b1a25 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -215,7 +215,7 @@ void WorldSession::HandleCharEnum(PreparedQueryResult result) data << num; - _allowedCharsToLogin.clear(); + _legitCharacters.clear(); if (result) { do @@ -224,7 +224,7 @@ void WorldSession::HandleCharEnum(PreparedQueryResult result) sLog->outInfo(LOG_FILTER_NETWORKIO, "Loading char guid %u from account %u.", guidlow, GetAccountId()); if (Player::BuildEnumData(result, &data)) { - _allowedCharsToLogin.insert(guidlow); + _legitCharacters.insert(guidlow); if (!sWorld->HasCharacterNameData(guidlow)) // This can happen if characters are inserted into the database manually. Core hasn't loaded name data yet. sWorld->AddCharacterNameData(guidlow, (*result)[1].GetString(), (*result)[4].GetUInt8(), (*result)[2].GetUInt8(), (*result)[3].GetUInt8(), (*result)[7].GetUInt8()); ++num; @@ -759,7 +759,7 @@ void WorldSession::HandlePlayerLoginOpcode(WorldPacket& recvData) recvData >> playerGuid; - if (!CharCanLogin(GUID_LOPART(playerGuid))) + if (!IsLegitCharacterForAccount(GUID_LOPART(playerGuid))) { sLog->outError(LOG_FILTER_NETWORKIO, "Account (%u) can't login with that character (%u).", GetAccountId(), GUID_LOPART(playerGuid)); KickPlayer(); @@ -1386,6 +1386,14 @@ void WorldSession::HandleCharCustomize(WorldPacket& recvData) std::string newName; recvData >> guid; + if (!IsLegitCharacterForAccount(GUID_LOPART(guid))) + { + sLog->outError(LOG_FILTER_NETWORKIO, "Account %u, IP: %s tried to customise character %u, but it does not belong to their account!", + GetAccountId(), GetRemoteAddress().c_str(), GUID_LOPART(guid)); + recvData.rfinish(); + KickPlayer(); + } + recvData >> newName; uint8 gender, skin, face, hairStyle, hairColor, facialHair; @@ -1394,7 +1402,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recvData) PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_AT_LOGIN); stmt->setUInt32(0, GUID_LOPART(guid)); - + // TODO: Make async with callback PreparedQueryResult result = CharacterDatabase.Query(stmt); if (!result) @@ -1619,6 +1627,15 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) std::string newname; uint8 gender, skin, face, hairStyle, hairColor, facialHair, race; recvData >> guid; + + if (!IsLegitCharacterForAccount(GUID_LOPART(guid))) + { + sLog->outError(LOG_FILTER_NETWORKIO, "Account %u, IP: %s tried to factionchange character %u, but it does not belong to their account!", + GetAccountId(), GetRemoteAddress().c_str(), GUID_LOPART(guid)); + recvData.rfinish(); + KickPlayer(); + } + recvData >> newname; recvData >> gender >> skin >> hairColor >> hairStyle >> facialHair >> face >> race; diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index d6877b8a18a..c1d7f0b00db 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -919,14 +919,14 @@ class WorldSession void LogUnprocessedTail(WorldPacket* packet); // EnumData helpers - bool CharCanLogin(uint32 lowGUID) + bool IsLegitCharacterForAccount(uint32 lowGUID) { - return _allowedCharsToLogin.find(lowGUID) != _allowedCharsToLogin.end(); + return _legitCharacters.find(lowGUID) != _legitCharacters.end(); } // this stores the GUIDs of the characters who can login // characters who failed on Player::BuildEnumData shouldn't login - std::set<uint32> _allowedCharsToLogin; + std::set<uint32> _legitCharacters; uint32 m_GUIDLow; // set loggined or recently logout player (while m_playerRecentlyLogout set) Player* _player; |