Skip to content

Instantly share code, notes, and snippets.

@LordJZ
Created July 2, 2011 17:50
Show Gist options
  • Save LordJZ/1061455 to your computer and use it in GitHub Desktop.
Save LordJZ/1061455 to your computer and use it in GitHub Desktop.
SMSG_CHAR_ENUM as of 4.2
using System;
using Kamilla.WorldOfWarcraft.Latest.OpcodeDatas;
namespace Kamilla.WorldOfWarcraft.Latest.Parsers.Lobby
{
[WowPacketParser(WowOpcodes.SMSG_CHAR_ENUM)]
[WowPacketParser(WowOpcodes.SMSG_COMPRESSED_CHAR_ENUM)]
internal sealed class CharEnumParser : WowPacketParser
{
protected unsafe override void Parse()
{
if ((WowOpcodes)this.Packet.Opcode == WowOpcodes.SMSG_COMPRESSED_CHAR_ENUM)
this.Decompress();
int someBool = Reader.ReadByte() >> 7;
Output.AppendLine("Not Drop Character Info: " + someBool);
Output.AppendLine();
uint count = Reader.ReadUInt32();
Output.AppendLine("Unk Count: " + count);
for (uint i = 0; i < count; ++i) // byte=[0,23]
Output.AppendFormatLine(" Unk: {1} => {0}", Reader.ReadUInt32(), Reader.ReadByte());
Output.AppendLine();
uint nCharacters = Reader.ReadUInt32();
Output.AppendLine("Total Characters: " + nCharacters);
var pack = new PackingContext(Reader);
var guids = new Tuple<byte[], byte[]>[nCharacters];
var firstLogin = new bool[nCharacters];
for (byte i = 0; i < nCharacters; ++i)
{
var guid1 = new byte[8];
var guid2 = new byte[8];
guids[i] = new Tuple<byte[], byte[]>(guid1, guid2);
guid2[0] = pack.NextBit();
firstLogin[i] = pack.NextBool();
guid1[5] = pack.NextBit();
guid2[7] = pack.NextBit();
guid2[5] = pack.NextBit();
guid1[1] = pack.NextBit();
guid1[3] = pack.NextBit();
guid2[1] = pack.NextBit();
guid1[2] = pack.NextBit();
guid1[6] = pack.NextBit();
guid2[6] = pack.NextBit();
guid2[3] = pack.NextBit();
guid2[2] = pack.NextBit();
guid1[7] = pack.NextBit();
guid1[4] = pack.NextBit();
guid2[4] = pack.NextBit();
guid1[0] = pack.NextBit();
Output.AppendLine(BitConverter.ToUInt64(guid1, 0).ToString("X16") + BitConverter.ToUInt64(guid2, 0).ToString("X16"));
}
for (byte i = 0; i < nCharacters; ++i)
{
var chrguids = guids[i];
var guid1 = new WowGuid(chrguids.Item1);
var guid2 = new WowGuid(chrguids.Item2);
Output.AppendFormatLine(" Character {0}", i);
Output.AppendLine(" First Login: " + firstLogin[i]);
Output.AppendLine(" Hair Color: " + Reader.ReadByte());
pack.XorByte(ref guid1.Bytes[7]);
Output.AppendLine(" Gender: " + (Genders)Reader.ReadByte());
pack.XorByte(ref guid2.Bytes[6]);
Output.AppendLine(" Level: " + Reader.ReadByte());
pack.XorByte(ref guid1.Bytes[6]);
Output.AppendLine(" Zone: " + Reader.ReadUInt32());
Output.AppendLine(" Pet DisplayId: " + Reader.ReadUInt32());
pack.XorByte(ref guid2.Bytes[1]);
pack.XorByte(ref guid2.Bytes[5]);
Output.AppendLine(" Race: " + (Races)Reader.ReadByte());
pack.XorByte(ref guid2.Bytes[3]);
Output.AppendLine(" Character Flags: " + (CharacterFlags)Reader.ReadUInt32());
pack.XorByte(ref guid2.Bytes[4]);
pack.XorByte(ref guid1.Bytes[5]);
pack.XorByte(ref guid1.Bytes[3]);
pack.XorByte(ref guid1.Bytes[4]);
Output.AppendLine(" Pet Family: " + Reader.ReadUInt32());
Output.AppendLine(" Hair Style: " + Reader.ReadByte());
Output.AppendLine(" Order: " + Reader.ReadByte());
pack.XorByte(ref guid2.Bytes[7]);
Reader.Skip(23 * (4 + 4 + 1)); // item data
Output.AppendLine(" Face: " + Reader.ReadByte());
pack.XorByte(ref guid1.Bytes[0]);
pack.XorByte(ref guid2.Bytes[2]);
Output.AppendLine(" Class: " + (Classes)Reader.ReadByte());
Output.AppendLine(" Position: " + Reader.ReadStruct<Vector3>());
pack.XorByte(ref guid2.Bytes[0]);
Output.AppendLine(" Name: " + Reader.ReadCString());
Output.AppendLine(" Map: " + (Maps)Reader.ReadUInt32());
pack.XorByte(ref guid1.Bytes[1]);
Output.AppendLine(" Pet Level: " + Reader.ReadUInt32());
Output.AppendLine(" Customize Flags: " + (CharacterCustomizeFlags)Reader.ReadUInt32());
pack.XorByte(ref guid1.Bytes[2]);
Output.AppendLine(" Facial Hair: " + Reader.ReadByte());
Output.AppendLine(" Skin: " + Reader.ReadByte());
Output.AppendLine(" Player Guid: " + guid2);
Output.AppendLine(" Guild Guid: " + guid1);
Output.AppendLine();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment