Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Server/PacketIO: Fixed Russian name declensions. Russian Clients can …
Browse files Browse the repository at this point in the history
…now correctly get into world. Thanks @Smerdokryl for reporting the issue.

 Closes: #772

Signed-off-by: AriDEV <aridev666@gmail.com>
  • Loading branch information
AriDEV committed Apr 28, 2019
1 parent de16dae commit 917818c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 70 deletions.
1 change: 1 addition & 0 deletions src/server/game/Entities/Unit/Unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,7 @@ struct RedirectThreatInfo
struct DeclinedName
{
std::string name [MAX_DECLINED_NAME_CASES];
uint32 nameLength[MAX_DECLINED_NAME_CASES];
};

enum CurrentSpellTypes
Expand Down
95 changes: 25 additions & 70 deletions src/server/game/Handlers/CharacterHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1428,47 +1428,29 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(PreparedQueryResult resu
void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recvData)
{
ObjectGuid guid;
DeclinedName declinedname;

guid[0] = recvData.ReadBit();
guid[2] = recvData.ReadBit();
guid[1] = recvData.ReadBit();
guid[7] = recvData.ReadBit();
guid[5] = recvData.ReadBit();
guid[6] = recvData.ReadBit();
guid[4] = recvData.ReadBit();
guid[3] = recvData.ReadBit();

uint32 nameLength = 0;

recvData.ReadGuidMask(guid, 0, 2, 1, 7, 5, 6, 4, 3);
for (uint32 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
{
uint32 nameLength = recvData.ReadBits(7);
declinedname.nameLength[i] = recvData.ReadBits(7);
}

recvData.FlushBits();
for (uint32 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
{
std::string name = recvData.ReadString(nameLength);
declinedname.name[i] = recvData.ReadString(declinedname.nameLength[i]);
}

recvData.FlushBits();

recvData.ReadByteSeq(guid[0]);
recvData.ReadByteSeq(guid[7]);
recvData.ReadByteSeq(guid[3]);
recvData.ReadByteSeq(guid[6]);
recvData.ReadByteSeq(guid[4]);
recvData.ReadByteSeq(guid[2]);
recvData.ReadByteSeq(guid[1]);
recvData.ReadByteSeq(guid[5]);
recvData.ReadGuidBytes(guid, 0, 7, 3, 6, 4, 2, 1, 5);

// not accept declined names for unsupported languages
std::string name;
if (!sObjectMgr->GetPlayerNameByGUID(guid, name))
{
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4 + 8);
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 1 + 4 + 8);
data.WriteBit(1);
data.WriteBits(0, 8);
data.WriteGuidMask(guid, 2, 0, 3, 1, 4, 6, 5, 7);
data.FlushBits();
data.WriteGuidBytes(guid, 2, 7, 1, 0, 4, 3, 6, 5);
data << uint32(1);
SendPacket(&data);
return;
Expand All @@ -1477,51 +1459,37 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recvData)
std::wstring wname;
if (!Utf8toWStr(name, wname))
{
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4 + 8);
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 1 + 4 + 8);
data.WriteBit(1);
data.WriteBits(0, 8);
data.WriteGuidMask(guid, 2, 0, 3, 1, 4, 6, 5, 7);
data.FlushBits();
data.WriteGuidBytes(guid, 2, 7, 1, 0, 4, 3, 6, 5);
data << uint32(1);
SendPacket(&data);
return;
}

if (!isCyrillicCharacter(wname[0])) // name already stored as only single alphabet using
{
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4 + 8);
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 1 + 4 + 8);
data.WriteBit(1);
data.WriteBits(0, 8);
data.FlushBits();
data << uint32(1);
SendPacket(&data);
return;
}

std::string name2;
DeclinedName declinedname;

recvData >> name2;

if (name2 != name) // character have different name
{
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4 + 8);
data.WriteBit(1);
data.WriteBits(0, 8);
data.WriteGuidMask(guid, 2, 0, 3, 1, 4, 6, 5, 7);
data.FlushBits();
data.WriteGuidBytes(guid, 2, 7, 1, 0, 4, 3, 6, 5);
data << uint32(1);
SendPacket(&data);
return;
}

for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
{
recvData >> declinedname.name[i];
if (!normalizePlayerName(declinedname.name[i]))
{
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4 + 8);
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 1 + 4 + 8);
data.WriteBit(1);
data.WriteBits(0, 8);
data.WriteGuidMask(guid, 2, 0, 3, 1, 4, 6, 5, 7);
data.FlushBits();
data.WriteGuidBytes(guid, 2, 7, 1, 0, 4, 3, 6, 5);
data << uint32(1);
SendPacket(&data);
return;
Expand All @@ -1530,10 +1498,11 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recvData)

if (!ObjectMgr::CheckDeclinedNames(wname, declinedname))
{
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4 + 8);
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 1 + 4 + 8);
data.WriteBit(1);
data.WriteBits(0, 8);
data.WriteGuidMask(guid, 2, 0, 3, 1, 4, 6, 5, 7);
data.FlushBits();
data.WriteGuidBytes(guid, 2, 7, 1, 0, 4, 3, 6, 5);
data << uint32(1);
SendPacket(&data);
return;
Expand All @@ -1558,26 +1527,12 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recvData)

CharacterDatabase.CommitTransaction(trans);

WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4 + 8);
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 1 + 4 + 8);
data.WriteBit(0);
data.WriteBit(guid[2]);
data.WriteBit(guid[0]);
data.WriteBit(guid[3]);
data.WriteBit(guid[1]);
data.WriteBit(guid[4]);
data.WriteBit(guid[6]);
data.WriteBit(guid[5]);
data.WriteBit(guid[7]);
data.WriteGuidMask(guid, 2, 0, 3, 1, 4, 6, 5, 7);
data.FlushBits();
data.WriteByteSeq(guid[2]);
data.WriteByteSeq(guid[7]);
data.WriteByteSeq(guid[1]);
data.WriteByteSeq(guid[0]);
data.WriteByteSeq(guid[4]);
data.WriteByteSeq(guid[3]);
data.WriteByteSeq(guid[6]);
data.WriteByteSeq(guid[5]);
data << uint32(0); // OK
data.WriteGuidBytes(guid, 2, 7, 1, 0, 4, 3, 6, 5);
data << uint32(0); // OK
SendPacket(&data);
}

Expand Down

0 comments on commit 917818c

Please sign in to comment.