properly implement Merscom DPK data format
This commit is contained in:
parent
e585c425b8
commit
7899dbc7ce
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<UniversalEditor Version="4.0">
|
||||
<Associations>
|
||||
<Association>
|
||||
<Filters>
|
||||
<Filter HintComparison="MagicThenFilter" ContentType="application/x-merscom-dpk" Title="Merscom data package (DPK) archive">
|
||||
<FileNameFilters>
|
||||
<FileNameFilter>*.dpk</FileNameFilter>
|
||||
</FileNameFilters>
|
||||
<MagicByteSequences>
|
||||
<MagicByteSequence>
|
||||
<MagicByte Type="String">DPK4</MagicByte>
|
||||
</MagicByteSequence>
|
||||
</MagicByteSequences>
|
||||
</Filter>
|
||||
</Filters>
|
||||
<ObjectModels>
|
||||
<ObjectModel TypeName="UniversalEditor.ObjectModels.FileSystem.FileSystemObjectModel" />
|
||||
</ObjectModels>
|
||||
<DataFormats>
|
||||
<DataFormat TypeName="UniversalEditor.DataFormats.FileSystem.Merscom.DPKDataFormat" />
|
||||
</DataFormats>
|
||||
</Association>
|
||||
</Associations>
|
||||
</UniversalEditor>
|
||||
@ -28,6 +28,7 @@ namespace UniversalEditor.DataFormats.FileSystem.Merscom
|
||||
/// <summary>
|
||||
/// Provides a <see cref="DataFormat" />for manipulating archives in Merscom DPK format.
|
||||
/// </summary>
|
||||
[ImplementationStatus(DataFormatImplementationStatus.Load)]
|
||||
public class DPKDataFormat : DataFormat
|
||||
{
|
||||
private static DataFormatReference _dfr;
|
||||
@ -53,27 +54,43 @@ namespace UniversalEditor.DataFormats.FileSystem.Merscom
|
||||
if (DPK4 != "DPK4")
|
||||
throw new InvalidDataFormatException();
|
||||
|
||||
uint u1 = br.ReadUInt32();
|
||||
uint u2 = br.ReadUInt32();
|
||||
uint archiveLength = br.ReadUInt32();
|
||||
uint tocLength = br.ReadUInt32();
|
||||
uint u3 = br.ReadUInt32();
|
||||
uint u4 = br.ReadUInt32();
|
||||
uint uFileCount = br.ReadUInt32();
|
||||
for (int i = 0; i < uFileCount; i++)
|
||||
for (int i = 0; i < u3; i++)
|
||||
{
|
||||
br.SeekUntilFirstNonNull();
|
||||
uint u4 = br.ReadUInt32();
|
||||
uint decompressedLength = br.ReadUInt32();
|
||||
uint compressedLength = br.ReadUInt32(); // 371 39325
|
||||
uint offset = br.ReadUInt32(); // 292196 292567
|
||||
|
||||
uint u6 = br.ReadUInt32();
|
||||
uint u7 = br.ReadUInt32();
|
||||
string nam = br.ReadNullTerminatedString(); // action.accfg
|
||||
br.Align(4);
|
||||
|
||||
string nam = br.ReadNullTerminatedString();
|
||||
File file = fsom.AddFile(nam);
|
||||
|
||||
ushort u8 = br.ReadUInt16();
|
||||
uint u9 = br.ReadUInt32();
|
||||
uint u10 = br.ReadUInt32();
|
||||
file.Properties["compressedLength"] = compressedLength;
|
||||
file.Properties["offset"] = offset;
|
||||
|
||||
file.Size = decompressedLength;
|
||||
|
||||
file.DataRequest += File_DataRequest;
|
||||
}
|
||||
}
|
||||
|
||||
void File_DataRequest(object sender, DataRequestEventArgs e)
|
||||
{
|
||||
File file = (File)sender;
|
||||
uint compressedLength = (uint)file.Properties["compressedLength"];
|
||||
uint offset = (uint)file.Properties["offset"];
|
||||
|
||||
Accessor.Reader.Seek(offset, SeekOrigin.Begin);
|
||||
byte[] compressedData = Accessor.Reader.ReadBytes(compressedLength);
|
||||
byte[] decompressedData = Compression.CompressionModule.FromKnownCompressionMethod(Compression.CompressionMethod.Zlib).Decompress(compressedData);
|
||||
e.Data = decompressedData;
|
||||
}
|
||||
|
||||
|
||||
protected override void SaveInternal(ObjectModel objectModel)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
@ -306,6 +306,7 @@
|
||||
<Folder Include="Associations\KenSilverman\" />
|
||||
<Folder Include="Associations\ElectronicArts\" />
|
||||
<Folder Include="Associations\Ultra3D\" />
|
||||
<Folder Include="Associations\Merscom\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Associations\7Zip.uexml" />
|
||||
@ -396,6 +397,7 @@
|
||||
<EmbeddedResource Include="Associations\Ultra3D\RBX.uexml" />
|
||||
<EmbeddedResource Include="Associations\Ultra3D\TBV.uexml" />
|
||||
<EmbeddedResource Include="DataFormats\FileSystem\StuffIt\StuffItDataFormat.uexml" />
|
||||
<EmbeddedResource Include="Associations\Merscom\DPK.uexml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user