Skip to content

Commit 797a796

Browse files
committed
- Updated DAT file mod/unmod status check to be more robust (Checks all 8 bytes instead of just 1st byte in the identifier segment).
1 parent ba6f881 commit 797a796

File tree

1 file changed

+23
-3
lines changed
  • xivModdingFramework/SqPack/FileTypes

1 file changed

+23
-3
lines changed

xivModdingFramework/SqPack/FileTypes/Dat.cs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,18 @@ await Task.Run(async () =>
242242
using (var binaryReader = new BinaryReader(File.OpenRead(datFilePath)))
243243
{
244244
binaryReader.BaseStream.Seek(24, SeekOrigin.Begin);
245-
var b = binaryReader.ReadByte();
246-
if (b != 0)
245+
bool anyNonZero = false;
246+
for (int byteIdx = 0; byteIdx < 8; byteIdx++)
247+
{
248+
if (binaryReader.ReadByte() != 0)
249+
{
250+
anyNonZero = true;
251+
break;
252+
}
253+
}
254+
255+
// If there is any data in these bytes, it is an original dat.
256+
if (anyNonZero)
247257
{
248258
datList.Add(datFilePath);
249259
}
@@ -293,8 +303,18 @@ await Task.Run(async () =>
293303
using (var binaryReader = new BinaryReader(File.OpenRead(datFilePath)))
294304
{
295305
binaryReader.BaseStream.Seek(24, SeekOrigin.Begin);
306+
bool anyNonZero = false;
307+
for (int byteIdx = 0; byteIdx < 8; byteIdx++)
308+
{
309+
if (binaryReader.ReadByte() != 0)
310+
{
311+
anyNonZero = true;
312+
break;
313+
}
314+
}
296315

297-
if (binaryReader.ReadByte() == 0)
316+
// If it's all zeros, this is a custom modded dat.
317+
if(!anyNonZero)
298318
{
299319
datList.Add(datFilePath);
300320
}

0 commit comments

Comments
 (0)