public FsdAsset(byte[] data) { if (data.Length < 0x1F8) { throw new Exception("Invalid file size"); } Magic = Swap(BitConverter.ToUInt32(data, 0)); if (Magic != 0x46534441) { throw new Exception("Invalid asset file magic!"); } Version = Swap(BitConverter.ToUInt32(data, 4)); if (Version != 1) { throw new NotSupportedException("Unsupported asset file version!"); } Reserved = Swap(BitConverter.ToUInt32(data, 8)); AssetFlags = Swap(BitConverter.ToUInt32(data, 12)); AssetCount = Swap(BitConverter.ToUInt32(data, 16)); ScreenshotCount = Swap(BitConverter.ToUInt32(data, 20)); for (var i = 0; i < Entries.Length; i++) { Entries[i] = new FsdAssetEntry(ref data, 24 + (i * 16)); } for (var i = 0; i < Screenshots.Length; i++) { Screenshots[i] = new FsdScreenshotEntry(ref data, (24 + (16 * Entries.Length)) + (i * 16)); } }
public FsdAsset(byte[] data) { if(data.Length < 0x1F8) throw new Exception("Invalid file size"); Magic = Swap(BitConverter.ToUInt32(data, 0)); if(Magic != 0x46534441) throw new Exception("Invalid asset file magic!"); Version = Swap(BitConverter.ToUInt32(data, 4)); if(Version != 1) throw new NotSupportedException("Unsupported asset file version!"); Reserved = Swap(BitConverter.ToUInt32(data, 8)); AssetFlags = Swap(BitConverter.ToUInt32(data, 12)); AssetCount = Swap(BitConverter.ToUInt32(data, 16)); ScreenshotCount = Swap(BitConverter.ToUInt32(data, 20)); for(var i = 0; i < Entries.Length; i++) Entries[i] = new FsdAssetEntry(ref data, 24 + (i * 16)); for(var i = 0; i < Screenshots.Length; i++) Screenshots[i] = new FsdScreenshotEntry(ref data, (24 + (16 * Entries.Length)) + (i * 16)); }