Skip to content

Commit

Permalink
Implement character rename packet.
Browse files Browse the repository at this point in the history
  • Loading branch information
ratkosrb committed May 21, 2022
1 parent e755576 commit fc5c553
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
14 changes: 14 additions & 0 deletions HermesProxy/World/Client/PacketHandlers/CharacterHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -569,5 +569,19 @@ void HandleInspectArenaTeams(WorldPacket packet)
inspect.ArenaTeams.Add(GetSession().GameState.GetArenaTeamDataForPlayer(inspect.PlayerGUID, slot));
SendPacketToClient(inspect);
}

[PacketHandler(Opcode.SMSG_CHARACTER_RENAME_RESULT)]
void HandleCharacterRenameResult(WorldPacket packet)
{
CharacterRenameResult rename = new();
Enums.Vanilla.ResponseCodes legacyCode = (Enums.Vanilla.ResponseCodes)packet.ReadUInt8();
rename.Result = (Enums.Classic.ResponseCodes)Enum.Parse(typeof(Enums.Classic.ResponseCodes), legacyCode.ToString());
if (rename.Result == Enums.Classic.ResponseCodes.Success)
{
rename.Guid = packet.ReadGuid().To128(GetSession().GameState);
rename.Name = packet.ReadCString();
}
SendPacketToClient(rename);
}
}
}
9 changes: 9 additions & 0 deletions HermesProxy/World/Server/PacketHandlers/CharacterHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,14 @@ void HandleInspectArenaTeams(Inspect inspect)
SendPacket(pvp);
}
}

[PacketHandler(Opcode.CMSG_CHARACTER_RENAME_REQUEST)]
void HandleCharacterRenameRequest(CharacterRenameRequest rename)
{
WorldPacket packet = new WorldPacket(Opcode.CMSG_CHARACTER_RENAME_REQUEST);
packet.WriteGuid(rename.Guid.To64());
packet.WriteCString(rename.NewName);
SendPacketToServer(packet);
}
}
}
36 changes: 36 additions & 0 deletions HermesProxy/World/Server/Packets/CharacterPackets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -982,4 +982,40 @@ public void Write(WorldPacket data)
public int PersonalGamesPlayed;
public int PersonalRating;
}

public class CharacterRenameRequest : ClientPacket
{
public CharacterRenameRequest(WorldPacket packet) : base(packet) { }

public override void Read()
{
Guid = _worldPacket.ReadPackedGuid128();
NewName = _worldPacket.ReadString(_worldPacket.ReadBits<uint>(6));
}

public string NewName;
public WowGuid128 Guid;
}

public class CharacterRenameResult : ServerPacket
{
public CharacterRenameResult() : base(Opcode.SMSG_CHARACTER_RENAME_RESULT) { }

public override void Write()
{
_worldPacket.WriteUInt8((byte)Result);
_worldPacket.WriteBit(Guid != null);
_worldPacket.WriteBits(Name.GetByteCount(), 6);
_worldPacket.FlushBits();

if (Guid != null)
_worldPacket.WritePackedGuid128(Guid);

_worldPacket.WriteString(Name);
}

public string Name = "";
public Enums.Classic.ResponseCodes Result = 0;
public WowGuid128 Guid;
}
}

0 comments on commit fc5c553

Please sign in to comment.