internal static List <WZObject> ParsePropertyList(WZBinaryReader r, WZObject parent, WZImage f, bool encrypted) { int num = r.ReadWZInt(); List <WZObject> ret = new List <WZObject>(num); for (int i = 0; i < num; ++i) { string name = r.ReadWZStringBlock(encrypted); byte type = r.ReadByte(); switch (type) { case 0: ret.Add(new WZNullProperty(name, parent, f)); break; case 0x0B: case 2: ret.Add(new WZUInt16Property(name, parent, r, f)); break; case 0x13: case 3: ret.Add(new WZInt32Property(name, parent, r, f)); break; case 0x14: ret.Add(new WZInt64Property(name, parent, r, f)); break; case 4: ret.Add(new WZSingleProperty(name, parent, r, f)); break; case 5: ret.Add(new WZDoubleProperty(name, parent, r, f)); break; case 8: ret.Add(new WZStringProperty(name, parent, r, f)); break; case 9: uint blockLen = r.ReadUInt32(); ret.Add(ParseExtendedProperty(name, r.Clone(), parent, f, encrypted)); r.Skip(blockLen); break; default: return (WZUtil.Die <List <WZObject> >( $"Unknown property type {type} at ParsePropertyList")); } } return(ret); }
internal void CheckParsed() { if (_parsed) { return; } WZBinaryReader r = _r.Clone(); r.Seek(_offset); Parse(r, false, out _value); }
private void Parse(WZBinaryReader wzbr, long offset) { wzbr.Seek(offset); int entryCount = wzbr.ReadWZInt(); for (int i = 0; i < entryCount; ++i) { byte type = wzbr.ReadByte(); string name = null; switch (type) { case 2: int x = wzbr.ReadInt32(); wzbr.PeekFor(() => { wzbr.Seek(x + File._fstart); type = wzbr.ReadByte(); name = wzbr.ReadWZString(File._encrypted); }); break; case 3: case 4: name = wzbr.ReadWZString(File._encrypted); break; case 1: // wzbr.Skip(10); // continue; default: WZUtil.Die($"Unknown object type {type} in WzDirectory."); break; } if (name == null) { WZUtil.Die("Failed to read WZDirectory entry name."); } int size = wzbr.ReadWZInt(); wzbr.ReadWZInt(); uint woffset = wzbr.ReadWZOffset(File._fstart); switch (type) { case 3: Add(new WZDirectory(name, this, File, wzbr.Clone(), woffset)); break; case 4: Add(new WZImage(name, this, File, File.GetSubstream(woffset, size))); break; } } }