public SiMesh(GenericReader r) { LimbId = r.ReadUInt32(); ParentId = r.ReadUInt32(); ScaleX = r.ReadUInt32(); ScaleY = r.ReadUInt32(); ScaleZ = r.ReadUInt32(); Position = r.ReadVector3(); OrientationW = r.ReadSingle(); OrientationX = r.ReadSingle(); OrientationY = r.ReadSingle(); OrientationZ = r.ReadSingle(); Lod = new SiMeshLod(r); }
public static bool ParseLoginSetTimeSpeedOpcode(GenericReader gr, GenericReader gr2, StringBuilder sb, StreamWriter swe, byte direction) { sb.AppendLine("Packet offset " + gr.BaseStream.Position.ToString("X2")); sb.AppendLine("Opcode SMSG_LOGIN_SETTIMESPEED (0x0042)"); StreamWriter sw = new StreamWriter("login_timespeed.log", true, Encoding.ASCII); uint time = gr2.ReadUInt32(); float speed = gr2.ReadSingle(); sw.WriteLine("time {0}, speed {1}", time, speed); sw.Flush(); sw.Close(); if (gr2.BaseStream.Position == gr2.BaseStream.Length) { sb.AppendLine("parsed: ok..."); } else { sb.AppendLine("parsed: error..."); } return(true); }
public static bool ParseCorpseQueryOpcode(GenericReader gr, GenericReader gr2, StringBuilder sb, StreamWriter swe, byte direction) { if (direction == 0) // client packet { return(false); } StreamWriter sw = new StreamWriter("corpse_query.log", true, Encoding.ASCII); sw.WriteLine("Packet offset {0}", gr.BaseStream.Position.ToString("X2")); sw.WriteLine("Opcode MSG_CORPSE_QUERY (0x0216)"); byte unk = gr2.ReadByte(); sw.WriteLine("unk {0}", unk); if (unk > 0) { uint mapid1 = gr2.ReadUInt32(); float x = gr2.ReadSingle(); float y = gr2.ReadSingle(); float z = gr2.ReadSingle(); uint mapid2 = gr2.ReadUInt32(); sw.WriteLine("map {0}, pos {1} {2} {3}", mapid1, x, y, z); sw.WriteLine("map2 {0}", mapid2); } if (gr2.BaseStream.Position == gr2.BaseStream.Length) { sw.WriteLine("parsed: ok..."); } else { sw.WriteLine("parsed: error..."); } sw.WriteLine(); sw.Flush(); sw.Close(); return(true); }
public readonly uint[] CollisionRelated = new uint[2]; // for collision system (index list [so only values from 0, 1, or 2] that contains the index of the vertex that is closest to each of the faces [order is: left,right,front,back,bottom,top] public SiFace(GenericReader r) { Points = new[] { new SiPoint(r), new SiPoint(r), new SiPoint(r) }; Flags = r.ReadUInt32(); Flags2 = r.ReadUInt32(); NormalVector = r.ReadVector3(); VectorW = r.ReadSingle(); Material = r.ReadUInt32(); Color = r.ReadUInt32(); CollisionRelated[0] = r.ReadUInt32(); CollisionRelated[1] = r.ReadUInt32(); }
public SiFile(string name, GenericReader r) { Name = name; MeshCount = r.ReadUInt32(); LodCount = r.ReadUInt32(); CylinderBaseCentre = r.ReadVector3(); CylinderBaseHeight = r.ReadSingle(); CylinderBaseRadius = r.ReadSingle(); SphereCenter = r.ReadVector3(); SphereRadius = r.ReadSingle(); Unk1 = r.ReadSingle(); MinBounds = r.ReadVector3(); MaxBounds = r.ReadVector3(); LodThreshold0 = r.ReadUInt32(); LodThreshold1 = r.ReadUInt32(); LodThreshold2 = r.ReadUInt32(); LodThreshold3 = r.ReadUInt32(); CenterOfMass = r.ReadVector3(); MassOrVolume = r.ReadSingle(); InertiaMatrix = r.ReadRowMajorMatrix3x3(); InertiaRelated = r.ReadSingle(); // var meshCount = (int)(MeshCount * LodCount); var meshOffset = r.ReadTArray <uint>(meshCount * 4, meshCount); Meshes = new SiMesh[meshCount]; for (var i = 0; i < meshOffset.Length; i++) { r.Position = meshOffset[i]; Meshes[i] = new SiMesh(r); } }
public SiMeshLod(GenericReader r) { var bsp = r.Position; MeshSize = r.ReadUInt32(); Flags = r.ReadUInt32(); Unused1 = r.ReadUInt32(); SphereCenter = r.ReadVector3(); SphereRadius = r.ReadSingle(); MinBounds = r.ReadVector3(); MaxBounds = r.ReadVector3(); Ignorable1 = r.ReadUInt32(); Ignorable2 = r.ReadUInt32(); FaceCount = r.ReadUInt32(); MountFaceCount = r.ReadUInt32(); VertexCount = r.ReadUInt32(); MountVertexCount = r.ReadUInt32(); MaxFaceCount = r.ReadUInt32(); MaterialCount = r.ReadUInt32(); FaceOffset = r.ReadUInt32(); MountFaceOffset = r.ReadUInt32(); VertexOffset = r.ReadUInt32(); MountVertexCount2 = r.ReadUInt32(); MaterialOffset = r.ReadUInt32(); SortedFacesOffset[0] = r.ReadUInt32(); SortedFacesOffset[1] = r.ReadUInt32(); SortedFacesOffset[2] = r.ReadUInt32(); SortedFacesOffset[3] = r.ReadUInt32(); ProbablyUnused1 = r.ReadUInt32(); ProbablyUnused2 = r.ReadUInt32(); // r.Position = bsp + FaceOffset + 4; Faces = new SiFace[FaceCount]; for (var i = 0; i < Faces.Length; i++) { Faces[i] = new SiFace(r); } r.Position = bsp + VertexOffset + 4; Vertices = new Vector3[VertexCount]; for (var i = 0; i < Vertices.Length; i++) { Vertices[i] = r.ReadVector3(); } r.Position = bsp + MaterialOffset + 4; Materials = new SiMaterial[MaterialCount]; for (var i = 0; i < Materials.Length; i++) { Materials[i] = new SiMaterial(r); } }
public static bool ParseSpellLogExecuteOpcode(GenericReader gr, GenericReader gr2, StringBuilder sb, StreamWriter swe, byte direction) { StreamWriter sw = new StreamWriter("SpellLogExecute.log", true, Encoding.ASCII); sw.WriteLine("Packet offset {0}", gr.BaseStream.Position.ToString("X2")); sw.WriteLine("Opcode SMSG_SPELLLOGEXECUTE (0x024C)"); ulong caster = gr2.ReadPackedGuid(); sw.WriteLine("caster {0}", caster.ToString("X16")); uint spellid = gr2.ReadUInt32(); sw.WriteLine("spellid {0}", spellid); uint count1 = gr2.ReadUInt32(); sw.WriteLine("count1 {0}", count1); for (uint i = 0; i < count1; ++i) { uint spelleffect = gr2.ReadUInt32(); sw.WriteLine("spelleffect {0}", spelleffect); uint count2 = gr2.ReadUInt32(); sw.WriteLine("count2 {0}", count2); for (uint j = 0; j < count2; ++j) { ulong guid; uint unk1; uint unk2; float unk3; switch (spelleffect) { case 0x08: // SPELL_EFFECT_MANA_DRAIN guid = gr2.ReadPackedGuid(); unk1 = gr2.ReadUInt32(); unk2 = gr2.ReadUInt32(); unk3 = gr2.ReadSingle(); sw.WriteLine("0x08: {0} {1} {2} {3}", guid.ToString("X16"), unk1, unk2, unk3); break; case 0x13: // SPELL_EFFECT_ADD_EXTRA_ATTACKS guid = gr2.ReadPackedGuid(); unk1 = gr2.ReadUInt32(); sw.WriteLine("0x13: {0} {1}", guid.ToString("X16"), unk1); break; case 0x44: // SPELL_EFFECT_INTERRUPT_CAST guid = gr2.ReadPackedGuid(); unk1 = gr2.ReadUInt32(); sw.WriteLine("0x44: {0} {1}", guid.ToString("X16"), unk1); break; case 0x6F: // SPELL_EFFECT_DURABILITY_DAMAGE guid = gr2.ReadPackedGuid(); unk1 = gr2.ReadUInt32(); unk2 = gr2.ReadUInt32(); sw.WriteLine("0x6F: {0} {1} {2}", guid.ToString("X16"), unk1, unk2); break; case 0x21: // SPELL_EFFECT_OPEN_LOCK case 0x3B: // SPELL_EFFECT_OPEN_LOCK_ITEM guid = gr2.ReadPackedGuid(); sw.WriteLine("0x21,0x3B: {0}", guid.ToString("X16")); break; case 0x18: // SPELL_EFFECT_CREATE_ITEM unk1 = gr2.ReadUInt32(); sw.WriteLine("0x18: {0}", unk1); break; case 0x1C: // SPELL_EFFECT_SUMMON case 0x29: // SPELL_EFFECT_SUMMON_WILD case 0x2A: // SPELL_EFFECT_SUMMON_GUARDIAN case 0x32: // SPELL_EFFECT_TRANS_DOOR case 0x38: // SPELL_EFFECT_SUMMON_PET case 0x49: // SPELL_EFFECT_SUMMON_POSSESSED case 0x4A: // SPELL_EFFECT_SUMMON_TOTEM case 0x4C: // SPELL_EFFECT_SUMMON_OBJECT_WILD case 0x51: // SPELL_EFFECT_CREATE_HOUSE case 0x53: // SPELL_EFFECT_DUEL case 0x57: // SPELL_EFFECT_SUMMON_TOTEM_SLOT1 case 0x58: // SPELL_EFFECT_SUMMON_TOTEM_SLOT2 case 0x59: // SPELL_EFFECT_SUMMON_TOTEM_SLOT3 case 0x5A: // SPELL_EFFECT_SUMMON_TOTEM_SLOT4 case 0x5D: // SPELL_EFFECT_SUMMON_PHANTASM case 0x61: // SPELL_EFFECT_SUMMON_CRITTER case 0x68: // SPELL_EFFECT_SUMMON_OBJECT_SLOT1 case 0x69: // SPELL_EFFECT_SUMMON_OBJECT_SLOT2 case 0x6A: // SPELL_EFFECT_SUMMON_OBJECT_SLOT3 case 0x6B: // SPELL_EFFECT_SUMMON_OBJECT_SLOT4 case 0x70: // SPELL_EFFECT_SUMMON_DEMON case 0x96: // SPELL_EFFECT_150 guid = gr2.ReadPackedGuid(); sw.WriteLine("summon: {0}", guid.ToString("X16")); break; case 0x65: // SPELL_EFFECT_FEED_PET unk1 = gr2.ReadUInt32(); sw.WriteLine("0x65: {0}", unk1); break; case 0x66: // SPELL_EFFECT_DISMISS_PET guid = gr2.ReadPackedGuid(); sw.WriteLine("0x66: {0}", guid.ToString("X16")); break; default: sw.WriteLine("unknown spell effect {0}", spelleffect); break; } } } if (gr2.BaseStream.Position != gr2.BaseStream.Length) { sw.WriteLine("F**K!"); } sw.WriteLine(); sw.Flush(); sw.Close(); return(true); }
public static bool ParseSpellNonMeleeDamageLogOpcode(GenericReader gr, GenericReader gr2, StringBuilder sb, StreamWriter swe, byte direction) { StreamWriter sw = new StreamWriter("SpellNonMeleeDamageLog.log", true, Encoding.ASCII); sw.WriteLine("Packet offset {0}", gr.BaseStream.Position.ToString("X2")); sw.WriteLine("Opcode SpellNonMeleeDamageLog (0x0250)"); ulong target = gr2.ReadPackedGuid(); ulong caster = gr2.ReadPackedGuid(); sw.WriteLine("target {0}, caster {1}", target, caster); uint spellid = gr2.ReadUInt32(); sw.WriteLine("spell {0}", spellid); uint damage = gr2.ReadUInt32(); sw.WriteLine("damage {0}", damage); byte unk1 = gr2.ReadByte(); sw.WriteLine("unk1 {0}", unk1); uint adsorb = gr2.ReadUInt32(); sw.WriteLine("adsorb {0}", adsorb); uint resist = gr2.ReadUInt32(); sw.WriteLine("resist {0}", resist); byte unk2 = gr2.ReadByte(); sw.WriteLine("unk2 {0}", unk2); byte unk3 = gr2.ReadByte(); sw.WriteLine("unk3 {0}", unk3); uint blocked = gr2.ReadUInt32(); sw.WriteLine("blocked {0}", blocked); uint flags = gr2.ReadUInt32(); sw.WriteLine("flags {0}", flags.ToString("X8")); byte unk4 = gr2.ReadByte(); sw.WriteLine("unk4 {0}", unk4); if ((flags & 0x1) != 0) { float a = gr2.ReadSingle(); float b = gr2.ReadSingle(); sw.WriteLine("0x1: a {0}, b {1}", a, b); } if ((flags & 0x4) != 0) { float a = gr2.ReadSingle(); float b = gr2.ReadSingle(); sw.WriteLine("0x4: a {0}, b {1}", a, b); } if ((flags & 0x20) != 0) { float a = gr2.ReadSingle(); float b = gr2.ReadSingle(); float c = gr2.ReadSingle(); float d = gr2.ReadSingle(); float e = gr2.ReadSingle(); float f = gr2.ReadSingle(); sw.WriteLine("0x20: a {0}, b {1}, c {2}, d {3}, e {4}, f {5}", a, b, c, d, e, f); } if (gr2.BaseStream.Position != gr2.BaseStream.Length) { sw.WriteLine("F**K!: " + flags.ToString("X8")); } sw.WriteLine(); sw.Flush(); sw.Close(); return(true); }
public static bool ParseAttackerStateUpdateOpcode(GenericReader gr, GenericReader gr2, StringBuilder sb, StreamWriter swe, byte direction) { sb.AppendLine("Packet offset " + gr.BaseStream.Position.ToString("X2")); sb.AppendLine("Opcode SMSG_ATTACKERSTATEUPDATE (0x01B1)"); StreamWriter sw = new StreamWriter("attacker_state.log", true, Encoding.ASCII); HitInfo hi = (HitInfo)gr2.ReadUInt32(); ulong attacker = gr2.ReadPackedGuid(); ulong target = gr2.ReadPackedGuid(); uint damage = gr2.ReadUInt32(); sw.WriteLine("HitInfo {0}", hi); sw.WriteLine("attacker {0}", attacker.ToString("X16")); sw.WriteLine("target {0}", target.ToString("X16")); sw.WriteLine("damage {0}", damage); byte count = gr2.ReadByte(); sw.WriteLine("count {0}", count); for (byte i = 0; i < count; i++) { ITEM_DAMAGE_TYPE damagetype = (ITEM_DAMAGE_TYPE)gr2.ReadUInt32(); float damage2 = gr2.ReadSingle(); uint damage3 = gr2.ReadUInt32(); uint adsorb = gr2.ReadUInt32(); uint resist = gr2.ReadUInt32(); sw.WriteLine("damagetype {0}", damagetype); sw.WriteLine("damage2 {0}", damage2); sw.WriteLine("damage3 {0}", damage3); sw.WriteLine("adsorb {0}", adsorb); sw.WriteLine("resist {0}", resist); } VictimState targetstate = (VictimState)gr2.ReadUInt32(); uint unk1 = gr2.ReadUInt32(); uint unk2 = gr2.ReadUInt32(); uint blocked = gr2.ReadUInt32(); sw.WriteLine("targetstate {0}", targetstate); sw.WriteLine("unk1 {0}", unk1); sw.WriteLine("unk2 {0}", unk2); sw.WriteLine("blocked {0}", blocked); sw.WriteLine(); sw.Flush(); sw.Close(); if (gr2.BaseStream.Position == gr2.BaseStream.Length) { sb.AppendLine("parsed: ok..."); } else { sb.AppendLine("parsed: error..."); } return(true); }
/// <summary> /// Monster move opcode parser method. /// </summary> /// <param name="gr">Main stream reader.</param> /// <param name="gr2">Packet stream reader.</param> /// <param name="sb">Logger string builder.</param> /// <param name="swe">Error logger writer.</param> /// <returns>Successful</returns> public static bool ParseMonsterMoveOpcode(GenericReader gr, GenericReader gr2, StringBuilder sb, StreamWriter swe, byte direction) { sb.AppendLine("Packet offset " + gr.BaseStream.Position.ToString("X2")); sb.AppendLine("Opcode SMSG_MONSTER_MOVE (0x00DD)"); ulong guid = gr2.ReadPackedGuid(); sb.AppendLine("GUID " + guid.ToString("X16")); Coords3 coords = gr2.ReadCoords3(); sb.AppendLine("Start point " + coords.GetCoords()); uint time = gr2.ReadUInt32(); sb.AppendLine("Time " + time); byte unk = gr2.ReadByte(); sb.AppendLine("unk_byte " + unk); switch (unk) { case 0: // обычный пакет break; case 1: // стоп, конец пакета... sb.AppendLine("stop"); return(true); case 2: Coords3 point = gr2.ReadCoords3(); sb.AppendLine("unk point " + point.GetCoords()); break; case 3: // чей-то гуид, скорее всего таргета... ulong target_guid = gr2.ReadUInt64(); sb.AppendLine("GUID unknown " + target_guid.ToString("X16")); break; case 4: // похоже на ориентацию... float orientation = gr2.ReadSingle(); sb.AppendLine("Orientation " + orientation.ToString().Replace(",", ".")); break; default: swe.WriteLine("Error in position " + gr.BaseStream.Position.ToString("X2")); swe.WriteLine("unknown unk " + unk); break; } Flags flags = (Flags)gr2.ReadUInt32(); sb.AppendLine("Flags " + flags); uint movetime = gr2.ReadUInt32(); sb.AppendLine("MoveTime " + movetime); uint points = gr2.ReadUInt32(); sb.AppendLine("Points " + points); List <Node> nodes = new List <Node>((int)points); if ((flags & Flags.flag10) != 0) // 0x200 { sb.AppendLine("Taxi"); for (uint i = 0; i < points; i++) { Node node = new Node(); node.x = gr2.ReadSingle(); node.y = gr2.ReadSingle(); node.z = gr2.ReadSingle(); nodes.Add(node); //Coords3 path = gr2.ReadCoords3(); //sb.AppendLine("Path point" + i + ": " + path.GetCoords()); } } else { if ((flags & Flags.flag09) == 0 && (flags & Flags.flag10) == 0 && flags != 0) { swe.WriteLine("Unknown flags " + flags); } if ((flags & Flags.flag09) != 0) { sb.AppendLine("Running"); } Coords3 end = gr2.ReadCoords3(); sb.AppendLine("End point " + end.GetCoords()); for (uint i = 0; i < (points - 1); i++) { int mask = gr2.ReadInt32(); sb.AppendLine("shift mask" + i + " " + mask.ToString("X8")); int temp1, temp2, temp3; temp1 = (mask & 0x07FF) << 0x15; temp2 = ((mask >> 0x0B) & 0x07FF) << 0x15; temp3 = (mask >> 0x16) << 0x16; temp1 >>= 0x15; temp2 >>= 0x15; temp3 >>= 0x16; float x = temp1 * 0.25f; float y = temp2 * 0.25f; float z = temp3 * 0.25f; sb.AppendLine("shift is " + x + " " + y + " " + z + "."); } } if ((flags & Flags.flag10) != 0) { StreamWriter sw = new StreamWriter("taxiinfo.txt", true); sw.WriteLine("GUID: 0x" + guid.ToString("X16")); sw.WriteLine(string.Format("Position: {0} {1} {2}", coords.X, coords.Y, coords.Z)); sw.WriteLine("Time: " + time); sw.WriteLine("Movetime: " + movetime); sw.WriteLine("Nodes: " + points); for (int i = 0; i < points; i++) { sw.WriteLine(string.Format("Node {0}: {1} {2} {3}", i, nodes[i].x, nodes[i].y, nodes[i].z)); } uint mangos_time = 0; float len = 0, xd, yd, zd; /*xd = nodes[0].x - coords.X; * yd = nodes[0].y - coords.Y; * zd = nodes[0].z - coords.Z; * len += (float)Math.Sqrt((xd * xd + yd * yd + zd * zd));*/ for (int i = 1; i < points; i++) { xd = nodes[i].x - nodes[i - 1].x; yd = nodes[i].y - nodes[i - 1].y; zd = nodes[i].z - nodes[i - 1].z; len += (float)Math.Sqrt((xd * xd + yd * yd + zd * zd)); } mangos_time = (uint)(len * 33.360f); // 33.373f / 33.336 sw.WriteLine("Mangostime 3D: " + mangos_time); mangos_time = 0; len = 0; for (int i = 1; i < points; i++) { xd = nodes[i].x - nodes[i - 1].x; yd = nodes[i].y - nodes[i - 1].y; len += (float)Math.Sqrt((xd * xd + yd * yd)); } mangos_time = (uint)(len * 33.360f); sw.WriteLine("Mangostime 2D: " + mangos_time); sw.WriteLine(); sw.Flush(); sw.Close(); } return(true); }
private static bool ParseMovementUpdateBlock(GenericReader gr, StringBuilder sb, StreamWriter swe, StreamWriter data, ObjectTypes objectTypeId, WoWObject obj) { Coords4 coords; coords.X = 0; coords.Y = 0; coords.Z = 0; coords.O = 0; sb.AppendLine("=== movement_update_block_start ==="); MovementFlags mf = MovementFlags.MOVEMENTFLAG_NONE; // movement flags UpdateFlags flags = (UpdateFlags)gr.ReadByte(); sb.AppendLine("Update Flags: " + flags.ToString("X") + " : " + flags); if ((UpdateFlags.UPDATEFLAG_LIVING & flags) != 0) // 0x20 { mf = (MovementFlags)gr.ReadUInt32(); sb.AppendLine("Movement Flags: " + mf.ToString("X") + " : " + mf); byte unk = gr.ReadByte(); sb.AppendLine("Unknown Byte: " + unk.ToString("X2")); uint time = gr.ReadUInt32(); sb.AppendLine("Time: " + time.ToString("X8")); } if ((UpdateFlags.UPDATEFLAG_HASPOSITION & flags) != 0) // 0x40 { coords = gr.ReadCoords4(); sb.AppendLine("Coords: " + coords.GetCoordsAsString()); if (objectTypeId == ObjectTypes.TYPEID_UNIT || objectTypeId == ObjectTypes.TYPEID_GAMEOBJECT) { if (obj != null) { obj.SetPosition(coords.X, coords.Y, coords.Z, coords.O); } } } if ((flags & UpdateFlags.UPDATEFLAG_LIVING) != 0) // 0x20 { /*if (objectTypeId == ObjectTypes.TYPEID_UNIT || objectTypeId == ObjectTypes.TYPEID_GAMEOBJECT) * { * data.WriteLine(); * data.WriteLine(objectTypeId + ": " + coords.GetCoordsAsString()); * }*/ if ((mf & MovementFlags.MOVEMENTFLAG_ONTRANSPORT) != 0) // transport { ulong t_guid = gr.ReadUInt64(); sb.Append("Transport GUID: " + t_guid.ToString("X16") + ", "); Coords4 transport = gr.ReadCoords4(); sb.AppendLine("Transport Coords: " + transport.GetCoordsAsString()); uint unk2 = gr.ReadUInt32(); // unk, probably timestamp sb.AppendLine("Transport Unk: " + unk2.ToString("X8")); } if ((mf & (MovementFlags.MOVEMENTFLAG_SWIMMING | MovementFlags.MOVEMENTFLAG_UNK5)) != 0) { float unkf1 = gr.ReadSingle(); sb.AppendLine("MovementFlags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_UNK5): " + unkf1); } uint unk1 = gr.ReadUInt32(); sb.AppendLine("Unk1: " + unk1.ToString("X8")); if ((mf & MovementFlags.MOVEMENTFLAG_JUMPING) != 0) { // looks like orientation/coords/speed float unk3 = gr.ReadSingle(); sb.AppendLine("unk3: " + unk3); float unk4 = gr.ReadSingle(); sb.AppendLine("unk4: " + unk4); float unk5 = gr.ReadSingle(); sb.AppendLine("unk5: " + unk5); float unk6 = gr.ReadSingle(); sb.AppendLine("unk6: " + unk6); } if ((mf & MovementFlags.MOVEMENTFLAG_SPLINE) != 0) { float unkf2 = gr.ReadSingle(); sb.AppendLine("MovementFlags & MOVEMENTFLAG_SPLINE: " + unkf2); } float ws = gr.ReadSingle(); sb.AppendLine("Walk speed: " + ws); float rs = gr.ReadSingle(); sb.AppendLine("Run speed: " + rs); float sbs = gr.ReadSingle(); sb.AppendLine("Swimback speed: " + sbs); float ss = gr.ReadSingle(); sb.AppendLine("Swim speed: " + ss); float wbs = gr.ReadSingle(); sb.AppendLine("Walkback speed: " + wbs); float fs = gr.ReadSingle(); sb.AppendLine("Fly speed: " + fs); float fbs = gr.ReadSingle(); sb.AppendLine("Flyback speed: " + fbs); float ts = gr.ReadSingle(); sb.AppendLine("Turn speed: " + ts); // pi = 3.14 if ((mf & MovementFlags.MOVEMENTFLAG_SPLINE2) != 0) { uint flags3 = gr.ReadUInt32(); sb.AppendLine("SplineFlags " + flags3.ToString("X8")); if ((flags3 & 0x10000) != 0) { Coords3 c = gr.ReadCoords3(); sb.AppendLine("SplineFlags & 0x10000: " + c.GetCoords()); } if ((flags3 & 0x20000) != 0) { ulong g3 = gr.ReadUInt64(); sb.AppendLine("flags3_guid: " + g3.ToString("X16")); // ???? } if ((flags3 & 0x40000) != 0) { uint f3_3 = gr.ReadUInt32(); sb.AppendLine("flags3_unk_value3: " + f3_3.ToString("X8")); } uint t1 = gr.ReadUInt32(); sb.AppendLine("curr tick: " + t1.ToString("X8")); uint t2 = gr.ReadUInt32(); sb.AppendLine("last tick: " + t2.ToString("X8")); uint t3 = gr.ReadUInt32(); sb.AppendLine("tick count " + t3.ToString("X8")); uint coords_count = gr.ReadUInt32(); sb.AppendLine("coords_count: " + coords_count.ToString("X8")); for (uint i = 0; i < coords_count; i++) { Coords3 v = gr.ReadCoords3(); sb.AppendLine("coord" + i + ": " + v.GetCoords()); } Coords3 end = gr.ReadCoords3(); sb.AppendLine("end: " + end.GetCoords()); } } if ((flags & UpdateFlags.UPDATEFLAG_LOWGUID) != 0) // 0x08 { uint temp = gr.ReadUInt32(); // timestamp or something like it sb.AppendLine("UpdateFlags & 0x08 (lowguid): " + temp.ToString("X8")); } if ((UpdateFlags.UPDATEFLAG_HIGHGUID & flags) != 0) // 0x10 { uint guid_high = gr.ReadUInt32(); // timestamp or something like it sb.AppendLine("UpdateFlags & 0x10 (highguid): " + guid_high.ToString("X8")); } if ((UpdateFlags.UPDATEFLAG_FULLGUID & flags) != 0) // 0x04 { ulong guid2 = gr.ReadPackedGuid(); // guid, but what guid? sb.AppendLine("UpdateFlags & 0x04 guid: " + guid2.ToString("X16")); } if ((UpdateFlags.UPDATEFLAG_TRANSPORT & flags) != 0) // 0x02 { uint time = gr.ReadUInt32(); // time sb.AppendLine("UpdateFlags & 0x02 t_time: " + time.ToString("X8")); } if ((UpdateFlags.UPDATEFLAG_SELFTARGET & flags) != 0) // 0x01 { sb.AppendLine("updating self!"); } sb.AppendLine("=== movement_update_block_end ==="); return(true); }
private static void ReadAndDumpField(UpdateField uf, StringBuilder sb, GenericReader gr, UpdateTypes updatetype, StreamWriter data, WoWObject obj) { MemoryStream ms = new MemoryStream(gr.ReadBytes(4)); GenericReader gr2 = new GenericReader(ms); if (updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT || updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT2) { obj.SetUInt32Value(uf.Identifier, gr2.ReadUInt32()); gr2.BaseStream.Position -= 4; } switch (uf.Type) { // TODO: add data writing /*case 3: * string val1 = gr.ReadSingle().ToString().Replace(",", "."); * if (updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT || updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT2) * data.WriteLine(uf.Name + " (" + uf.Identifier + "): " + val1); * sb.AppendLine(uf.Name + " (" + index + "): " + val1); * break; * default: * uint val2 = gr.ReadUInt32(); * if (updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT || updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT2) * data.WriteLine(uf.Name + " (" + uf.Identifier + "): " + val2); * sb.AppendLine(uf.Name + " (" + uf.Identifier + "): " + val2); * break;*/ case 1: // uint32 sb.AppendLine(uf.Name + " (" + uf.Identifier + "): " + gr2.ReadUInt32().ToString("X8")); break; case 2: // uint16+uint16 ushort value1 = gr2.ReadUInt16(); ushort value2 = gr2.ReadUInt16(); sb.AppendLine(uf.Name + " (" + uf.Identifier + "): " + "first " + value1.ToString("X4") + ", second " + value2.ToString("X4")); if (uf.Name.StartsWith("PLAYER_SKILL_INFO_1_")) { int num = uf.Identifier - 858; if ((num % 3) == 0) { ushort skill = value1; ushort flag = value2; string str = String.Format("skill {0}, flag {1}", skill, (ProfessionFlags)flag); sb.AppendLine(str); } else if (((num - 1) % 3) == 0) { ushort minskill = value1; ushort maxskill = value2; string str = String.Format("minskill {0}, maxskill {1}", minskill, maxskill); sb.AppendLine(str); } else { ushort minbonus = value1; ushort maxbonus = value2; string str = String.Format("minbonus {0}, maxbonus {1}", minbonus, maxbonus); sb.AppendLine(str); } } break; case 3: // float sb.AppendLine(uf.Name + " (" + uf.Identifier + "): " + gr2.ReadSingle()); //sb.AppendLine(uf.Name + " (" + uf.Identifier + "): " + gr.ReadSingle().ToString().Replace(",", ".")); break; case 4: // uint64 (can be only low part) sb.AppendLine(uf.Name + " (" + uf.Identifier + "): " + gr2.ReadUInt32().ToString("X8")); break; case 5: // bytes uint value = gr2.ReadUInt32(); sb.AppendLine(uf.Name + " (" + uf.Identifier + "): " + value.ToString("X8")); if (uf.Identifier == 36) // UNIT_FIELD_BYTES_0 { byte[] bytes = BitConverter.GetBytes(value); Races race = (Races)bytes[0]; Class class_ = (Class)bytes[1]; Gender gender = (Gender)bytes[2]; Powers powertype = (Powers)bytes[3]; string str = String.Format("Race: {0}, class: {1}, gender: {2}, powertype: {3}", race, class_, gender, powertype); sb.AppendLine(str); } break; default: sb.AppendLine(uf.Name + " (" + uf.Identifier + "): " + "unknown type " + gr2.ReadUInt32().ToString("X8")); break; } gr2.Close(); }
private bool ParseMovementUpdateBlock(GenericReader gr, StringBuilder sb, StreamWriter swe, StreamWriter data, ObjectTypes objectTypeId) { Coords4 coords; // need figure out flags2, check flags, because we can't read packet without it... // flags2: // 0x1 - not affect data // 0x2 - need check // 0x4 // 0x8 // 0x10 - need check // 0x20 - not affect data // 0x100 // 0x800 // 0x2000 - need check // 0x4000 // 0x200000 // 0x8000000 ? // 0x10000000 // 0x20000000 sb.AppendLine("=== movement_update_block_start ==="); uint flags2 = 0; UpdateFlags flags = (UpdateFlags)gr.ReadByte(); sb.AppendLine("flags " + flags.ToString("X")); if ((UpdateFlags.UPDATEFLAG_LIVING & flags) != 0) // 0x20 { flags2 = gr.ReadUInt32(); sb.AppendLine("flags2 " + flags2.ToString("X8")); uint time = gr.ReadUInt32(); sb.AppendLine("time " + time); } if ((UpdateFlags.UPDATEFLAG_HASPOSITION & flags) != 0) // 0x40 { if ((UpdateFlags.UPDATEFLAG_TRANSPORT & flags) != 0) // 0x02 { coords = gr.ReadCoords4(); sb.AppendLine("coords " + coords.GetCoordsAsString()); } else // strange, we read the same data :) { coords = gr.ReadCoords4(); sb.AppendLine("coords " + coords.GetCoordsAsString()); } if (objectTypeId == ObjectTypes.TYPEID_UNIT || objectTypeId == ObjectTypes.TYPEID_GAMEOBJECT) { data.WriteLine(); data.WriteLine(objectTypeId + ": " + coords.GetCoordsAsString()); } if ((flags2 & 0x0200) != 0) // transport { ulong t_guid = gr.ReadUInt64(); sb.Append("t_guid " + t_guid.ToString("X2") + ", "); Coords4 transport = gr.ReadCoords4(); sb.AppendLine("t_coords " + transport.GetCoordsAsString()); uint unk1 = gr.ReadUInt32(); // unk, 2.0.6 == 0x11 or random sb.AppendLine("unk1 " + unk1); } } if ((UpdateFlags.UPDATEFLAG_LIVING & flags) != 0) // 0x20 { uint unk1 = gr.ReadUInt32(); sb.AppendLine("unk1 " + unk1); if ((flags2 & 0x2000) != 0) // <--- { // looks like orientation/coords/speed float unk2 = gr.ReadSingle(); sb.AppendLine("unk2 " + unk2); float unk3 = gr.ReadSingle(); sb.AppendLine("unk3 " + unk3); float unk4 = gr.ReadSingle(); sb.AppendLine("unk4 " + unk4); float unk5 = gr.ReadSingle(); sb.AppendLine("unk5 " + unk5); } float ws = gr.ReadSingle(); sb.AppendLine("Walk speed " + ws); float rs = gr.ReadSingle(); sb.AppendLine("Run speed " + rs); float sbs = gr.ReadSingle(); sb.AppendLine("Swimback speed " + sbs); float ss = gr.ReadSingle(); sb.AppendLine("Swim speed " + ss); float wbs = gr.ReadSingle(); sb.AppendLine("Walkback speed " + wbs); float fs = gr.ReadSingle(); sb.AppendLine("Fly speed " + fs); float fbs = gr.ReadSingle(); sb.AppendLine("Flyback speed " + fbs); float ts = gr.ReadSingle(); sb.AppendLine("Turn speed " + ts); // pi = 3.14 } // after 2.0.10 released, I can't figure out what is flags3 and when it used... uint flags3 = 0; if ((UpdateFlags.UPDATEFLAG_ALL & flags) != 0) // 0x10 { flags3 = gr.ReadUInt32(); // looks like flags (0x0, 0x1, 0x100, 0x20000, 0x40000)... sb.AppendLine("flags3 " + flags3.ToString("X2")); } /* // still used, but can't figure out when... if ((flags2 & 0x8000000) == 0 && objectTypeId == ObjectTypes.TYPEID_UNIT) { if ((flags3 & 0x40000) != 0) { uint f3_3 = br.ReadUInt32(); sb.AppendLine("flags3_unk_value3 " + f3_3); } if ((flags3 & 0x20000) != 0) { ulong g3 = br.ReadUInt64(); sb.AppendLine("flags3_guid " + g3); // ???? } } */ if ((UpdateFlags.UPDATEFLAG_HIGHGUID & flags) != 0) // 0x08 { uint guid_high = gr.ReadUInt32(); // 2.0.10 - it's not high guid anymore sb.AppendLine("guid_high " + guid_high); } if ((UpdateFlags.UPDATEFLAG_FULLGUID & flags) != 0) // 0x04 //if ((UpdateFlags.UPDATEFLAG_FULLGUID & flags) != 0 && (flags3 & 0x20000) == 0) // 0x04 //if ((UpdateFlags.UPDATEFLAG_FULLGUID & flags) != 0 && (flags3 & 0x40000) == 0) // 0x04 { //long pos = br.BaseStream.Position; //swe.WriteLine("flags & 0x4 at position " + pos.ToString("X2")); ulong guid2 = gr.ReadPackedGuid(); // looks like guid, but what guid? sb.AppendLine("unk guid " + guid2); } if ((UpdateFlags.UPDATEFLAG_TRANSPORT & flags) != 0) // 0x02 { uint time = gr.ReadUInt32(); sb.AppendLine("t_time " + time); } if ((flags2 & 0x8000000) != 0) // splines { uint t1 = gr.ReadUInt32(); sb.AppendLine("t1 " + t1); uint t2 = gr.ReadUInt32(); sb.AppendLine("t2 " + t2); //outdated 2.0.10 //uint t3 = br.ReadUInt32(); //sb.AppendLine("t3 " + t3); uint coords_count = gr.ReadUInt32(); sb.AppendLine("coords_count " + coords_count); //if (coords_count > 1000) //{ // coords_count = br.ReadUInt32(); // sb.AppendLine("second attempt to get correct coords count, now " + coords_count); //} //if (coords_count > 1000) //{ // coords_count = br.ReadUInt32(); // sb.AppendLine("third attempt to get correct coords count, now " + coords_count); //} if (coords_count > 1000) // prevent overflow in case wrong packet parsing :) { long pos = gr.BaseStream.Position; swe.WriteLine("error position " + pos.ToString("X2")); swe.WriteLine("error while parsing movement update block, flags: " + flags.ToString("X") + ", flags2: " + flags2.ToString("X") + ", flags3: " + flags3.ToString("X") + ", objecttype " + objectTypeId); return false; } if (coords_count > 0) { for (uint i = 0; i < coords_count; i++) { Coords3 v = gr.ReadCoords3(); sb.AppendLine("coord" + i + ": " + v.GetCoords()); } } Coords3 end = gr.ReadCoords3(); sb.AppendLine("end: " + end.GetCoords()); uint t8 = gr.ReadUInt32(); sb.AppendLine("t8 " + t8); // added in 2.0.10 (really?) uint t9 = gr.ReadUInt32(); sb.AppendLine("t9 " + t9); } sb.AppendLine("=== movement_update_block_end ==="); return true; }
private bool ParseValuesUpdateBlock(GenericReader gr, StringBuilder sb, StreamWriter swe, StreamWriter data, ObjectTypes objectTypeId, UpdateTypes updatetype) { // may be we can reduce size of code there... sb.AppendLine("=== values_update_block_start ==="); byte blocks_count = gr.ReadByte(); // count of update blocks (4 bytes for each update block) sb.AppendLine("Bit mask blocks count: " + blocks_count); uint[] updatemask = new uint[blocks_count]; // create array of update blocks for (int j = 0; j < blocks_count; j++) updatemask[j] = gr.ReadUInt32(); // populate array of update blocks with data Mask = (BitArr)updatemask; // convert array of update blocks to bitmask array int reallength = Mask.RealLength; // bitmask size (bits) // item/container values update block if (objectTypeId == ObjectTypes.TYPEID_ITEM || objectTypeId == ObjectTypes.TYPEID_CONTAINER) { if (reallength > 160) // 5*32, ?? { long pos = gr.BaseStream.Position; swe.WriteLine("error position " + pos.ToString("X2")); swe.WriteLine("error while parsing ITEM values update block, count " + reallength); return false; } for (uint index = 0; index < reallength; index++) { if (index > UpdateFields.ITEM_END) break; if (Mask[index]) { switch (UpdateFields.item_updatefields[index].type) { case 1: sb.AppendLine(UpdateFields.item_updatefields[index].name + " (" + index + "): " + gr.ReadSingle().ToString().Replace(",", ".")); break; default: sb.AppendLine(UpdateFields.item_updatefields[index].name + " (" + index + "): " + gr.ReadUInt32()); break; } } } } // unit values update block if (objectTypeId == ObjectTypes.TYPEID_UNIT) { if (reallength > 256) // 32*8 (for units bitmask = 8) { long pos = gr.BaseStream.Position; swe.WriteLine("error position " + pos.ToString("X2")); swe.WriteLine("error while parsing UNIT values update block, count " + reallength); return false; } for (uint index = 0; index < reallength; index++) { if (index > UpdateFields.UNIT_END) break; if (Mask[index]) { switch (UpdateFields.unit_updatefields[index].type) { case 1: string val1 = gr.ReadSingle().ToString().Replace(",", "."); if(updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT || updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT2) data.WriteLine(UpdateFields.unit_updatefields[index].name + " (" + index + "): " + val1); sb.AppendLine(UpdateFields.unit_updatefields[index].name + " (" + index + "): " + val1); break; default: uint val2 = gr.ReadUInt32(); if (updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT || updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT2) data.WriteLine(UpdateFields.unit_updatefields[index].name + " (" + index + "): " + val2); sb.AppendLine(UpdateFields.unit_updatefields[index].name + " (" + index + "): " + val2); break; } } } } // player values update block if (objectTypeId == ObjectTypes.TYPEID_PLAYER) { if (reallength > 1440) // 32*45 (for player bitmask = 45) { long pos = gr.BaseStream.Position; swe.WriteLine("error position " + pos.ToString("X2")); swe.WriteLine("error while parsing PLAYER values update block, count " + reallength); return false; } for (uint index = 0; index < reallength; index++) { if (index > UpdateFields.PLAYER_END) break; if (Mask[index]) { switch (UpdateFields.unit_updatefields[index].type) { case 1: string val1 = gr.ReadSingle().ToString().Replace(",", "."); sb.AppendLine(UpdateFields.unit_updatefields[index].name + " (" + index + "): " + val1); break; default: uint val2 = gr.ReadUInt32(); sb.AppendLine(UpdateFields.unit_updatefields[index].name + " (" + index + "): " + val2); break; } } } } // gameobject values update block if (objectTypeId == ObjectTypes.TYPEID_GAMEOBJECT) { if (reallength > 32) // 1*32 { long pos = gr.BaseStream.Position; swe.WriteLine("error position " + pos.ToString("X2")); swe.WriteLine("error while parsing GO values update block, count " + reallength); return false; } for (uint index = 0; index < reallength; index++) { if (index > UpdateFields.GO_END) break; if (Mask[index]) { switch (UpdateFields.go_updatefields[index].type) { case 1: string val1 = gr.ReadSingle().ToString().Replace(",", "."); if (updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT || updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT2) data.WriteLine(UpdateFields.go_updatefields[index].name + " (" + index + "): " + val1); sb.AppendLine(UpdateFields.go_updatefields[index].name + " (" + index + "): " + val1); break; default: uint val2 = gr.ReadUInt32(); if (updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT || updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT2) data.WriteLine(UpdateFields.go_updatefields[index].name + " (" + index + "): " + val2); sb.AppendLine(UpdateFields.go_updatefields[index].name + " (" + index + "): " + val2); break; } } } } // dynamicobject values update block if (objectTypeId == ObjectTypes.TYPEID_DYNAMICOBJECT) { if (reallength > 32) // 1*32 { long pos = gr.BaseStream.Position; swe.WriteLine("error position " + pos.ToString("X2")); swe.WriteLine("error while parsing DO values update block, count " + reallength); return false; } for (uint index = 0; index < reallength; index++) { if (index > UpdateFields.DO_END) break; if (Mask[index]) { switch (UpdateFields.do_updatefields[index].type) { case 1: sb.AppendLine(UpdateFields.do_updatefields[index].name + " (" + index + "): " + gr.ReadSingle().ToString().Replace(",", ".")); break; default: sb.AppendLine(UpdateFields.do_updatefields[index].name + " (" + index + "): " + gr.ReadUInt32()); break; } } } } // corpse values update block if (objectTypeId == ObjectTypes.TYPEID_CORPSE) { if (reallength > 64) // 2*32 { long pos = gr.BaseStream.Position; swe.WriteLine("error position " + pos.ToString("X2")); swe.WriteLine("error while parsing CORPSE values update block, count " + reallength); return false; } for (uint index = 0; index < reallength; index++) { if (index > UpdateFields.CORPSE_END) break; if (Mask[index]) { switch (UpdateFields.corpse_updatefields[index].type) { case 1: sb.AppendLine(UpdateFields.corpse_updatefields[index].name + " (" + index + "): " + gr.ReadSingle().ToString().Replace(",", ".")); break; default: sb.AppendLine(UpdateFields.corpse_updatefields[index].name + " (" + index + "): " + gr.ReadUInt32()); break; } } } } //swe.WriteLine("ok..."); sb.AppendLine("=== values_update_block_end ==="); return true; }