Skip to content

Instantly share code, notes, and snippets.

@LordJZ
Created July 21, 2011 15:16
Show Gist options
  • Select an option

  • Save LordJZ/1097416 to your computer and use it in GitHub Desktop.

Select an option

Save LordJZ/1097416 to your computer and use it in GitHub Desktop.
Some more 4.2 opcodes
<Packet OpCode="MSG_LIST_STABLED_PETS" Sender="Server">
<Simple>
<Name>VendorEntityId</Name>
<Type>Guid</Type>
</Simple>
<Simple>
<Name>NumPets</Name>
<Type>Byte</Type>
</Simple>
<Simple>
<Name>NumOwnedSlots</Name>
<Type>Byte</Type>
</Simple>
<List LengthSegment="NumPets">
<Name>Pets</Name>
<Simple>
<Name>Pet Index (?)</Name>
<Type>UInt</Type>
</Simple>
<Simple>
<Name>Pet Number</Name>
<Type>UInt</Type>
</Simple>
<Simple>
<Name>Pet Entry Id</Name>
<Type>UInt</Type>
</Simple>
<Simple>
<Name>Pet Level</Name>
<Type>UInt</Type>
</Simple>
<Simple>
<Name>Pet Name</Name>
<Type>CString</Type>
</Simple>
<Simple>
<Name>Slot Num</Name>
<Type>Byte</Type>
</Simple>
</List>
</Packet>
[WowPacketParser(WowOpcodes.SMSG_INIT_CURRENCY)]
internal sealed class InitCurrencyParser : WowPacketParser
{
/// <summary>
/// Represents currency info of this session.
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
class CurrencyData
{
public uint Count;
public int WeekCap;
public int TotalCap;
public int ThisWeek;
public CurrencyTypes Type;
public byte UnkByte;
public bool HasWeekCap;
public bool HasTotalCap;
public bool HasThisWeek;
public override string ToString()
{
var builder = new StringBuilder(256);
this.ToString(builder);
return builder.ToString();
}
public void ToString(StringBuilder builder)
{
builder.AppendFormatLine("Count: {0} Type: {1} ({1:D})", this.Count, this.Type);
if (this.HasWeekCap)
builder.AppendLine("Week Cap: " + this.WeekCap);
if (this.HasTotalCap)
builder.AppendLine("Total Cap: " + this.TotalCap);
if (this.HasThisWeek)
builder.AppendLine("This Week: " + this.ThisWeek);
builder.AppendLine("Unk Byte: " + this.UnkByte);
}
}
protected override void Parse()
{
var reader = this.Reader;
uint count = reader.ReadUInt32();
Output.AppendLine("Currency Count: " + count);
var datas = new CurrencyData[count];
for (uint i = 0; i < count; ++i)
{
var d = datas[i] = new CurrencyData();
d.HasTotalCap = reader.UnalignedReadBit();
d.HasWeekCap = reader.UnalignedReadBit();
d.HasThisWeek = reader.UnalignedReadBit();
}
for (uint i = 0; i < count; ++i)
{
var d = datas[i];
if (d.HasTotalCap)
d.TotalCap = reader.ReadInt32();
if (d.HasWeekCap)
d.WeekCap = reader.ReadInt32();
if (d.HasThisWeek)
d.ThisWeek = reader.ReadInt32();
d.UnkByte = reader.ReadByte();
d.Type = (CurrencyTypes)reader.ReadUInt32();
d.Count = reader.ReadUInt32();
Output.AppendLine("____________");
Output.AppendFormatLine("Currency {0}:", i);
d.ToString(Output);
Output.AppendLine();
}
}
}
<Packet OpCode="SMSG_PVP_TYPES_ENABLED">
<Simple>
<Name>War Games Enabled</Name>
<Type>UnalignedBool</Type>
</Simple>
<Simple>
<Name>Unk Type Enabled</Name>
<Type>UnalignedBool</Type>
</Simple>
<Simple>
<Name>Rated Battlegrounds Enabled</Name>
<Type>UnalignedBool</Type>
</Simple>
<Simple>
<Name>Rated Arenas Enabled</Name>
<Type>UnalignedBool</Type>
</Simple>
<Simple>
<Name>Unk Type Enabled</Name>
<Type>UnalignedBool</Type>
</Simple>
</Packet>
public sealed class SetPhaseShift : PackedData
{
public readonly byte[][] Data = new byte[4][];
public WowGuid Guid;
public uint Unk;
protected override int ByteXorValue
{
get { return 1; }
}
protected override int[] MaskSequence
{
get { return new int[] { 4, 6, 3, 4, 1, 2, 0, 7 }; }
}
protected override int[] ByteSequence
{
get { return new int[] { 6, 5, -1, 3, 7, -2, -3, 2, 4, -5, 0, 1, -4 }; }
}
protected override void ElementRead(StreamHandler reader, int index)
{
if (index == -5)
this.Unk = reader.ReadUInt32();
else
this.Data[-index - 1] = reader.ReadBytes(reader.ReadInt32());
}
protected override void ElementWrite(StreamHandler writer, int index)
{
if (index == -5)
{
writer.WriteUInt32(this.Unk);
}
else
{
index = -index - 1;
writer.WriteInt32(this.Data[index].Length);
writer.WriteBytes(this.Data[index]);
}
}
protected override void PackedRead(StreamHandler reader)
{
this.Guid = reader.ReadGuid();
}
protected override void PackedSave(StreamHandler writer)
{
writer.WriteGuid(this.Guid);
}
public override CustomPacket CreatePacket()
{
return base.CreatePacket(WowOpcodes.SMSG_SET_PHASE_SHIFT, Direction.ToClient);
}
public override void ToString(StringBuilder builder)
{
builder.AppendLine("Guid: " + this.Guid);
builder.AppendLine("Unk: " + this.Unk);
for (int i = 0; i < this.Data.Length; ++i)
{
var arr = this.Data[i];
if ((arr.Length & 1) == 0)
{
builder.Append("Maps: ");
for (int j = 0; j < arr.Length; j += 2)
builder.Append((Maps)BitConverter.ToUInt16(arr, j)).Append(j == arr.Length - 2 ? "" : ", ");
builder.AppendLine();
}
else
builder.AppendLine("Bytes: " + arr.ToHexString());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment