Skip to content

Commit

Permalink
Fix small bug that breaks repacked resources
Browse files Browse the repository at this point in the history
Seems to repack the resources properly now, haven't tested with mods yet
though but hopefully they'll work the same as they did in the betas (might
require "devMode_enable 1" launch parameter though)
emoose committed Feb 7, 2017

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 9a6ef4c commit 1ed310c
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion DOOMExtract/Program.cs
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ static void PrintUsage()
}
static void Main(string[] args)
{
Console.WriteLine("DOOMExtract 1.5 - by infogram");
Console.WriteLine("DOOMExtract 1.5.1 - by infogram");
Console.WriteLine();
if (args.Length <= 0)
{
4 changes: 2 additions & 2 deletions DOOMExtract/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.0.0")]
[assembly: AssemblyFileVersion("1.5.0.0")]
[assembly: AssemblyVersion("1.5.1.0")]
[assembly: AssemblyFileVersion("1.5.1.0")]
16 changes: 9 additions & 7 deletions DOOMExtract/ResourceIndex.cs
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ public class DOOMResourceEntry
public int Size;
public int CompressedSize;
public long Zero;
public byte Zero1;
public byte PatchFileIndex;

public DOOMResourceEntry(DOOMResourceIndex index)
{
@@ -71,7 +71,7 @@ public void Read(EndianIO io)
else
Zero = io.Reader.ReadInt32(); // Zero field is 4 bytes instead of 8 in version 5+

Zero1 = io.Reader.ReadByte();
PatchFileIndex = io.Reader.ReadByte();
}

public void Write(EndianIO io)
@@ -96,7 +96,7 @@ public void Write(EndianIO io)
io.Writer.Write(Zero);
else
io.Writer.Write((int)Zero); // Zero field is 4 bytes instead of 8 in version 5+
io.Writer.Write(Zero1);
io.Writer.Write(PatchFileIndex);
}
}
public class DOOMResourceIndex
@@ -142,10 +142,14 @@ public long CopyEntryDataToStream(DOOMResourceEntry entry, Stream destStream, bo
resourceIO.Stream.Position = entry.Offset;

Stream sourceStream = resourceIO.Stream;
long copyLen = entry.CompressedSize;
if (entry.Size != entry.CompressedSize && decompress)
{
sourceStream = new InflaterInputStream(resourceIO.Stream, new ICSharpCode.SharpZipLib.Zip.Compression.Inflater(true), 4096);
copyLen = entry.Size;
}

return StreamCopy(destStream, sourceStream, 40960, entry.Size);
return StreamCopy(destStream, sourceStream, 40960, copyLen);
}

/*public static byte[] CompressData(byte[] data, ZLibNet.CompressionLevel level = ZLibNet.CompressionLevel.Level9)
@@ -258,8 +262,6 @@ public void Rebuild(string destResourceFile, string replaceFromFolder = "", bool
continue;
}

bool isCompressed = keepCompressed;

var replacePath = (String.IsNullOrEmpty(replaceFromFolder) ? String.Empty : Path.Combine(replaceFromFolder, file.GetFullName()));
if (File.Exists(replacePath + ";" + file.FileType))
replacePath += ";" + file.FileType;
@@ -274,7 +276,7 @@ public void Rebuild(string destResourceFile, string replaceFromFolder = "", bool
file.CompressedSize = file.Size = (int)StreamCopy(destResources.Stream, fs, 40960, fs.Length);
}
else
file.CompressedSize = file.Size = (int)CopyEntryDataToStream(file, destResources.Stream, !keepCompressed);
file.CompressedSize = (int)CopyEntryDataToStream(file, destResources.Stream, !keepCompressed);
}

// now add any files that weren't replaced

0 comments on commit 1ed310c

Please sign in to comment.