private static void OnProperties(int client, PacketReader reader) { reader.ReadInt16(); // WORD 0x01 int serial = reader.ReadInt32(); reader.ReadInt16(); // WORD 0x00 int hash = reader.ReadInt32(); Property p; StringBuilder propertyText = new StringBuilder(); List<Property> propertyList = new List<Property>(); string named6 = ""; bool nameSet = false, first = true; int lastCliloc = -1; for (; ; ) { p = new Property(); p.Cliloc = reader.ReadInt32(); if (p.Cliloc == 0) break; if (!first) propertyText.Append("\r\n"); int len = reader.ReadInt16(); if (len > 0) { //TODO: Fix the below two lines to use reader.ReadUnicodeString(); p.Arguments = UnicodeEncoding.Unicode.GetString(reader.Data, reader.Index, len).Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries); reader.Seek(len, SeekOrigin.Current); p.Text = Cliloc.GetLocalString(p.Cliloc, p.Arguments); if (!nameSet) { named6 = p.Text; nameSet = true; } } else { p.Text = Cliloc.GetProperty(p.Cliloc); if (!nameSet) { named6 = p.Text; nameSet = true; } } if (lastCliloc != -1) { if (lastCliloc != p.Cliloc) { propertyList.Add(p); propertyText.Append(p.Text); } } else { propertyList.Add(p); propertyText.Append(p.Text); } lastCliloc = p.Cliloc; first = false; } IncomingPackets.OnProperties(client, serial, named6, propertyList.ToArray(), propertyText.ToString()); }
private static void OnCompressedGump(int client, PacketReader reader) { int serialdd = reader.ReadInt32(); int iddd = reader.ReadInt32(); int xdd = reader.ReadInt32(); int ydd = reader.ReadInt32(); int compressLendd = reader.ReadInt32(); if (compressLendd <= 4) { return; } else { compressLendd -= 4; } int decompressLendd = reader.ReadInt32() + 1; byte[] decompresseddd = new byte[decompressLendd]; byte[] compresseddd = new byte[compressLendd]; Buffer.BlockCopy(reader.Data, reader.Index, compresseddd, 0, compressLendd); reader.Seek(compressLendd, SeekOrigin.Current); int success; //if (IntPtr.Size == 8) success = NativeMethods.uncompress64(decompresseddd, ref decompressLendd, compresseddd, compressLendd); success = NativeMethods.uncompress32(decompresseddd, ref decompressLendd, compresseddd, compressLendd); if (success != 0) { Log.LogDataMessage(client, reader.Data, "*** Error decompressing gump layout:"); return; } string layoutdd = ASCIIEncoding.ASCII.GetString(decompresseddd).TrimEnd('\0'); int offsetdd = 27 + compressLendd; int linesdd = reader.ReadInt32(); compressLendd = reader.ReadInt32(); string[] textdd = new string[linesdd]; if (compressLendd > 4) { compressLendd -= 4; compresseddd = new byte[compressLendd]; decompressLendd = reader.ReadInt32() + 1; decompresseddd = new byte[decompressLendd]; Buffer.BlockCopy(reader.Data, reader.Index, compresseddd, 0, compressLendd); reader.Seek(compressLendd, SeekOrigin.Current); //if (IntPtr.Size == 8) success = NativeMethods.uncompress64(decompresseddd, ref decompressLendd, compresseddd, compressLendd); success = NativeMethods.uncompress32(decompresseddd, ref decompressLendd, compresseddd, compressLendd); if (success != 0) { Log.LogDataMessage(client, reader.Data, "*** Error decompressing gump strings:"); return; } offsetdd = 0; int lendd = 0; for (int x = 0; x < linesdd; x++) { lendd = (decompresseddd[offsetdd] << 8 | decompresseddd[offsetdd + 1]) * 2; offsetdd += 2; textdd[x] = UnicodeEncoding.BigEndianUnicode.GetString(decompresseddd, offsetdd, lendd); offsetdd += lendd; } } IncomingPackets.OnGenericGump(client, serialdd, iddd, xdd, ydd, layoutdd, textdd); }
private static void OnCompressedGump(int client, PacketReader reader) { int serialdd = reader.ReadInt32(); int iddd = reader.ReadInt32(); int xdd = reader.ReadInt32(); int ydd = reader.ReadInt32(); int compressLendd = reader.ReadInt32(); if (compressLendd <= 4) return; else compressLendd -= 4; int decompressLendd = reader.ReadInt32() + 1; byte[] decompresseddd = new byte[decompressLendd]; byte[] compresseddd = new byte[compressLendd]; Buffer.BlockCopy(reader.Data, reader.Index, compresseddd, 0, compressLendd); reader.Seek(compressLendd, SeekOrigin.Current); int success; //if (IntPtr.Size == 8) success = NativeMethods.uncompress64(decompresseddd, ref decompressLendd, compresseddd, compressLendd); success = NativeMethods.uncompress32(decompresseddd, ref decompressLendd, compresseddd, compressLendd); if (success != 0) { Log.LogDataMessage(client, reader.Data, "*** Error decompressing gump layout:"); return; } string layoutdd = ASCIIEncoding.ASCII.GetString(decompresseddd).TrimEnd('\0'); int offsetdd = 27 + compressLendd; int linesdd = reader.ReadInt32(); compressLendd = reader.ReadInt32(); string[] textdd = new string[linesdd]; if (compressLendd > 4) { compressLendd -= 4; compresseddd = new byte[compressLendd]; decompressLendd = reader.ReadInt32() + 1; decompresseddd = new byte[decompressLendd]; Buffer.BlockCopy(reader.Data, reader.Index, compresseddd, 0, compressLendd); reader.Seek(compressLendd, SeekOrigin.Current); //if (IntPtr.Size == 8) success = NativeMethods.uncompress64(decompresseddd, ref decompressLendd, compresseddd, compressLendd); success = NativeMethods.uncompress32(decompresseddd, ref decompressLendd, compresseddd, compressLendd); if (success != 0) { Log.LogDataMessage(client, reader.Data, "*** Error decompressing gump strings:"); return; } offsetdd = 0; int lendd = 0; for (int x = 0; x < linesdd; x++) { lendd = (decompresseddd[offsetdd] << 8 | decompresseddd[offsetdd + 1]) * 2; offsetdd += 2; textdd[x] = UnicodeEncoding.BigEndianUnicode.GetString(decompresseddd, offsetdd, lendd); offsetdd += lendd; } } IncomingPackets.OnGenericGump(client, serialdd, iddd, xdd, ydd, layoutdd, textdd); }
private static void OnProperties(int client, PacketReader reader) { reader.ReadInt16(); // WORD 0x01 int serial = reader.ReadInt32(); reader.ReadInt16(); // WORD 0x00 int hash = reader.ReadInt32(); Property p; StringBuilder propertyText = new StringBuilder(); List <Property> propertyList = new List <Property>(); string named6 = ""; bool nameSet = false, first = true; int lastCliloc = -1; for (; ;) { p = new Property(); p.Cliloc = reader.ReadInt32(); if (p.Cliloc == 0) { break; } if (!first) { propertyText.Append("\r\n"); } int len = reader.ReadInt16(); if (len > 0) { //TODO: Fix the below two lines to use reader.ReadUnicodeString(); p.Arguments = UnicodeEncoding.Unicode.GetString(reader.Data, reader.Index, len).Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries); reader.Seek(len, SeekOrigin.Current); p.Text = Cliloc.GetLocalString(p.Cliloc, p.Arguments); if (!nameSet) { named6 = p.Text; nameSet = true; } } else { p.Text = Cliloc.GetProperty(p.Cliloc); if (!nameSet) { named6 = p.Text; nameSet = true; } } if (lastCliloc != -1) { if (lastCliloc != p.Cliloc) { propertyList.Add(p); propertyText.Append(p.Text); } } else { propertyList.Add(p); propertyText.Append(p.Text); } lastCliloc = p.Cliloc; first = false; } IncomingPackets.OnProperties(client, serial, named6, propertyList.ToArray(), propertyText.ToString()); }