public void ReadMsg(BitStream stream) { ServerClassCount = stream.ReadShort(); CreateOnClient = stream.ReadBool(); if (CreateOnClient) { return; } byte serverClassBits = (byte)(ExtMath.Log2(ServerClassCount) + 1); ServerClasses = new List <ServerClass>(); for (int i = 0; i < ServerClassCount; i++) { ServerClass sc = new ServerClass(); sc.ClassID = stream.ReadUShort(serverClassBits); sc.ClassName = stream.ReadCString(); sc.DataTableName = stream.ReadCString(); ServerClasses.Add(sc); } }
public void ReadMsg(BitStream stream) { //bool isFilenames; if (stream.ReadChar() == ':') { //isFilenames = true; } else { stream.Seek(-8, System.IO.SeekOrigin.Current); //isFilenames = false; } TableName = stream.ReadCString(); MaxEntries = stream.ReadUShort(); int encodeBits = ExtMath.Log2(MaxEntries); Entries = stream.ReadUShort((byte)(encodeBits + 1)); ulong bitCount = stream.ReadVarUInt(); // userdatafixedsize if (stream.ReadBool()) { UserDataSize = stream.ReadUShort(12); UserDataSizeBits = stream.ReadByte(4); } bool isCompressedData = stream.ReadBool(); Data = stream.Subsection(stream.Cursor, stream.Cursor + bitCount); stream.Seek(bitCount, System.IO.SeekOrigin.Current); if (isCompressedData) { uint decompressedNumBytes = Data.ReadUInt(); uint compressedNumBytes = Data.ReadUInt(); byte[] compressedData = Data.ReadBytes(compressedNumBytes); char[] magic = Encoding.ASCII.GetChars(compressedData, 0, 4); if ( magic[0] != 'S' || magic[1] != 'N' || magic[2] != 'A' || magic[3] != 'P') { throw new FormatException("Unknown format for compressed stringtable"); } int snappyDecompressedNumBytes = SnappyCodec.GetUncompressedLength(compressedData, 4, compressedData.Length - 4); if (snappyDecompressedNumBytes != decompressedNumBytes) { throw new FormatException("Mismatching decompressed data lengths"); } byte[] decompressedData = new byte[snappyDecompressedNumBytes]; if (SnappyCodec.Uncompress(compressedData, 4, compressedData.Length - 4, decompressedData, 0) != decompressedNumBytes) { throw new FormatException("Snappy didn't decode all the bytes"); } Data = new BitStream(decompressedData); } }