Core/PacketIO: Updated and enabled CMSG_SET_PLAYER_DECLINED_NAMES

This commit is contained in:
Carbenium
2016-02-02 23:19:37 +01:00
parent aa5c947555
commit 3ea1cfc4d0
5 changed files with 42 additions and 33 deletions
+15 -31
View File
@@ -1350,80 +1350,64 @@ void WorldSession::HandleCharRenameCallBack(PreparedQueryResult result, WorldPac
sWorld->UpdateCharacterInfo(renameInfo->Guid, renameInfo->NewName);
}
void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recvData)
void WorldSession::HandleSetPlayerDeclinedNames(WorldPackets::Character::SetPlayerDeclinedNames& packet)
{
ObjectGuid guid;
recvData >> guid;
// not accept declined names for unsupported languages
std::string name;
if (!ObjectMgr::GetPlayerNameByGUID(guid, name))
if (!ObjectMgr::GetPlayerNameByGUID(packet.Player, name))
{
SendSetPlayerDeclinedNamesResult(DECLINED_NAMES_RESULT_ERROR, guid);
SendSetPlayerDeclinedNamesResult(DECLINED_NAMES_RESULT_ERROR, packet.Player);
return;
}
std::wstring wname;
if (!Utf8toWStr(name, wname))
{
SendSetPlayerDeclinedNamesResult(DECLINED_NAMES_RESULT_ERROR, guid);
SendSetPlayerDeclinedNamesResult(DECLINED_NAMES_RESULT_ERROR, packet.Player);
return;
}
if (!isCyrillicCharacter(wname[0])) // name already stored as only single alphabet using
{
SendSetPlayerDeclinedNamesResult(DECLINED_NAMES_RESULT_ERROR, guid);
return;
}
std::string name2;
DeclinedName declinedname;
recvData >> name2;
if (name2 != name) // character have different name
{
SendSetPlayerDeclinedNamesResult(DECLINED_NAMES_RESULT_ERROR, guid);
SendSetPlayerDeclinedNamesResult(DECLINED_NAMES_RESULT_ERROR, packet.Player);
return;
}
for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
{
recvData >> declinedname.name[i];
if (!normalizePlayerName(declinedname.name[i]))
if (!normalizePlayerName(packet.DeclinedNames.name[i]))
{
SendSetPlayerDeclinedNamesResult(DECLINED_NAMES_RESULT_ERROR, guid);
SendSetPlayerDeclinedNamesResult(DECLINED_NAMES_RESULT_ERROR, packet.Player);
return;
}
}
if (!ObjectMgr::CheckDeclinedNames(wname, declinedname))
if (!ObjectMgr::CheckDeclinedNames(wname, packet.DeclinedNames))
{
SendSetPlayerDeclinedNamesResult(DECLINED_NAMES_RESULT_ERROR, guid);
SendSetPlayerDeclinedNamesResult(DECLINED_NAMES_RESULT_ERROR, packet.Player);
return;
}
for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
CharacterDatabase.EscapeString(declinedname.name[i]);
CharacterDatabase.EscapeString(packet.DeclinedNames.name[i]);
SQLTransaction trans = CharacterDatabase.BeginTransaction();
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_DECLINED_NAME);
stmt->setUInt64(0, guid.GetCounter());
stmt->setUInt64(0, packet.Player.GetCounter());
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_DECLINED_NAME);
stmt->setUInt64(0, guid.GetCounter());
stmt->setUInt64(0, packet.Player.GetCounter());
for (uint8 i = 0; i < 5; i++)
stmt->setString(i+1, declinedname.name[i]);
for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; i++)
stmt->setString(i + 1, packet.DeclinedNames.name[i]);
trans->Append(stmt);
CharacterDatabase.CommitTransaction(trans);
SendSetPlayerDeclinedNamesResult(DECLINED_NAMES_RESULT_SUCCESS, guid);
SendSetPlayerDeclinedNamesResult(DECLINED_NAMES_RESULT_SUCCESS, packet.Player);
}
void WorldSession::HandleAlterAppearance(WorldPackets::Character::AlterApperance& packet)
@@ -545,3 +545,16 @@ WorldPacket const* WorldPackets::Character::CharCustomizeFailed::Write()
return &_worldPacket;
}
void WorldPackets::Character::SetPlayerDeclinedNames::Read()
{
_worldPacket >> Player;
uint8 stringLengths[MAX_DECLINED_NAME_CASES];
for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
stringLengths[i] = _worldPacket.ReadBits(7);
for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
DeclinedNames.name[i] = _worldPacket.ReadString(stringLengths[i]);
}
@@ -716,6 +716,17 @@ namespace WorldPackets
uint8 Result = 0;
ObjectGuid CharGUID;
};
class SetPlayerDeclinedNames final : public ClientPacket
{
public:
SetPlayerDeclinedNames(WorldPacket&& packet) : ClientPacket(CMSG_SET_PLAYER_DECLINED_NAMES, std::move(packet)) { }
void Read() override;
ObjectGuid Player;
DeclinedName DeclinedNames;
};
}
}
+1 -1
View File
@@ -694,7 +694,7 @@ void OpcodeTable::Initialize()
DEFINE_HANDLER(CMSG_SET_PARTY_ASSIGNMENT, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Party::SetPartyAssignment, &WorldSession::HandleSetPartyAssignment);
DEFINE_HANDLER(CMSG_SET_PARTY_LEADER, STATUS_LOGGEDIN, PROCESS_INPLACE, WorldPackets::Party::SetPartyLeader, &WorldSession::HandleSetPartyLeaderOpcode);
DEFINE_HANDLER(CMSG_SET_PET_SLOT, STATUS_UNHANDLED, PROCESS_INPLACE, WorldPackets::Null, &WorldSession::Handle_NULL);
DEFINE_OPCODE_HANDLER_OLD(CMSG_SET_PLAYER_DECLINED_NAMES, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleSetPlayerDeclinedNames );
DEFINE_HANDLER(CMSG_SET_PLAYER_DECLINED_NAMES, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Character::SetPlayerDeclinedNames, &WorldSession::HandleSetPlayerDeclinedNames);
DEFINE_HANDLER(CMSG_SET_PREFERRED_CEMETERY, STATUS_UNHANDLED, PROCESS_INPLACE, WorldPackets::Null, &WorldSession::Handle_NULL);
DEFINE_HANDLER(CMSG_SET_PVP, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Misc::SetPvP, &WorldSession::HandleSetPvP);
DEFINE_HANDLER(CMSG_SET_RAID_DIFFICULTY, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Misc::SetRaidDifficulty, &WorldSession::HandleSetRaidDifficultyOpcode);
+2 -1
View File
@@ -197,6 +197,7 @@ namespace WorldPackets
class SetFactionNotAtWar;
class SetFactionInactive;
class SetWatchedFaction;
class SetPlayerDeclinedNames;
enum class LoginFailureReason : uint8;
}
@@ -1071,7 +1072,7 @@ class WorldSession
void HandlePlayerLogin(LoginQueryHolder * holder);
void HandleCharRenameOpcode(WorldPackets::Character::CharacterRenameRequest& request);
void HandleCharRenameCallBack(PreparedQueryResult result, WorldPackets::Character::CharacterRenameInfo* renameInfo);
void HandleSetPlayerDeclinedNames(WorldPacket& recvData);
void HandleSetPlayerDeclinedNames(WorldPackets::Character::SetPlayerDeclinedNames& packet);
void HandleAlterAppearance(WorldPackets::Character::AlterApperance& packet);
void HandleCharCustomizeOpcode(WorldPackets::Character::CharCustomize& packet);
void HandleCharCustomizeCallback(PreparedQueryResult result, WorldPackets::Character::CharCustomizeInfo* customizeInfo);