Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
Support the new format of GGPK of 3.11.2
Browse files Browse the repository at this point in the history
Support the new format of GGPK of 3.11.2
  • Loading branch information
aianlinb authored Sep 19, 2020
1 parent ce0417c commit 7b4ea04
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions LibGGPK/Records/GGPKRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public sealed class GgpkRecord : BaseRecord
/// </summary>
public long[] RecordOffsets;

public uint Version;

public GgpkRecord(uint length)
{
Length = length;
Expand All @@ -45,10 +47,10 @@ public GgpkRecord(long recordBegin, uint length, long[] recordOffsets)
/// <param name="br">Stream pointing at a GGPK record</param>
public override void Read(BinaryReader br)
{
var totalRecordOffsets = br.ReadInt32();
RecordOffsets = new long[totalRecordOffsets];
var Version = br.ReadUInt32();
RecordOffsets = new long[2];

for (var i = 0; i < totalRecordOffsets; i++)
for (var i = 0; i < 2; i++)
{
RecordOffsets[i] = br.ReadInt64();
}
Expand All @@ -58,7 +60,7 @@ public override void Write(BinaryWriter bw, Dictionary<long, long> changedOffset
{
bw.Write(Length); // 28
bw.Write(Encoding.ASCII.GetBytes(Tag)); // GGPK
bw.Write(RecordOffsets.Length); // 2
bw.Write(Version); // 2

var offset = RecordOffsets[0];
bw.Write(changedOffsets.ContainsKey(offset) ? changedOffsets[offset] : offset);
Expand All @@ -72,4 +74,4 @@ public override string ToString()
}
}

}
}

0 comments on commit 7b4ea04

Please sign in to comment.