private static void OnGenericGump(int client, PacketReader reader) { int serialb0 = reader.ReadInt32(); int idb0 = reader.ReadInt32(); int xb0 = reader.ReadInt32(); int yb0 = reader.ReadInt32(); int layoutLenb0 = reader.ReadInt16(); string layoutb0 = reader.ReadString(layoutLenb0); int linesb0 = reader.ReadInt16(); string[] textb0 = new string[linesb0]; int textLenb0; for (int x = 0; x < linesb0; x++) { textLenb0 = reader.ReadInt16() * 2; textb0[x] = reader.ReadUnicodeString(textLenb0); } IncomingPackets.OnGenericGump(client, serialb0, idb0, xb0, yb0, layoutb0, textb0); }
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); }