/// <summary> /// </summary> /// <param name="stream"> /// </param> /// <returns> /// </returns> public static StatelData ReadFromStream(Stream stream) { StatelData statel = new StatelData(); FlatIdentity fi = new FlatIdentity(); fi.ReadFromStream(stream); statel.StatelIdentity = fi.Id; // Skip 4, is always 1? stream.ReadByte(); stream.ReadByte(); stream.ReadByte(); stream.ReadByte(); PFCoordHeading pfc = new PFCoordHeading(); pfc.ReadFromStream(stream); statel.X = pfc.Coordinate.X; statel.Y = pfc.Coordinate.Y; statel.Z = pfc.Coordinate.Z; statel.HeadingX = pfc.Heading.X; statel.HeadingY = pfc.Heading.Y; statel.HeadingZ = pfc.Heading.Z; statel.HeadingW = pfc.Heading.W; statel.PlayfieldId = pfc.PlayfieldIdentity; BinaryReader br = new BinaryReader(stream); br.ReadInt32(); statel.TemplateId = br.ReadInt32(); int len2 = br.ReadInt32(); byte[] HighLow = br.ReadBytes(len2); MemoryStream ms = new MemoryStream(HighLow); BinaryReader br2 = new BinaryReader(ms); br2.ReadBytes(8); int C1 = IPAddress.NetworkToHostOrder(br2.ReadInt32()); Debug.Assert(C1 % 0x3f1 == 0, "Wrong 3f1 encountered... stop please"); int evcount = IPAddress.NetworkToHostOrder(br2.ReadInt32()); while (evcount > 0) { int dataType = IPAddress.NetworkToHostOrder(br2.ReadInt32()); switch (dataType) { case 2: HLFlatEvent flatEvent = new HLFlatEvent(); flatEvent.ReadFromStream(ms); statel.Events.Add(flatEvent.ToEvents()); break; default: // Console.WriteLine("DataType " + dataType + " found... stop please"); break; } evcount--; } return statel; }
/// <summary> /// </summary> /// <param name="stream"> /// </param> /// <returns> /// </returns> public static StatelData ReadFromStream(Stream stream) { StatelData statel = new StatelData(); FlatIdentity fi = new FlatIdentity(); fi.ReadFromStream(stream); statel.Identity = fi.Id; // Skip 4, is always 1? stream.ReadByte(); stream.ReadByte(); stream.ReadByte(); stream.ReadByte(); PFCoordHeading pfc = new PFCoordHeading(); pfc.ReadFromStream(stream); statel.X = pfc.Coordinate.X; statel.Y = pfc.Coordinate.Y; statel.Z = pfc.Coordinate.Z; statel.HeadingX = pfc.Heading.X; statel.HeadingY = pfc.Heading.Y; statel.HeadingZ = pfc.Heading.Z; statel.HeadingW = pfc.Heading.W; statel.PlayfieldId = pfc.PlayfieldIdentity; BinaryReader br = new BinaryReader(stream); br.ReadInt32(); statel.TemplateId = br.ReadInt32(); int len2 = br.ReadInt32(); byte[] HighLow = br.ReadBytes(len2); MemoryStream ms = new MemoryStream(HighLow); BinaryReader br2 = new BinaryReader(ms); br2.ReadBytes(8); int C1 = IPAddress.NetworkToHostOrder(br2.ReadInt32()); Debug.Assert(C1 % 0x3f1 == 0, "Wrong 3f1 encountered... stop please"); int evcount = IPAddress.NetworkToHostOrder(br2.ReadInt32()); while (evcount > 0) { int dataType = IPAddress.NetworkToHostOrder(br2.ReadInt32()); switch (dataType) { case 2: HLFlatEvent flatEvent = new HLFlatEvent(); flatEvent.ReadFromStream(ms); statel.Events.Add(flatEvent.ToEvents()); break; default: // Console.WriteLine("DataType " + dataType + " found... stop please"); break; } evcount--; } return(statel); }