Skip to content

Commit 13ec118

Browse files
committed
- Updated post-patch process to always create fresh index backups.
1 parent d4f4810 commit 13ec118

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

xivModdingFramework/Mods/Modding.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,8 +902,9 @@ public async Task<long> DefragmentModdedDats(IProgress<(int Current, int Total,
902902

903903

904904
var finalSize = await GetTotalModDataSize();
905-
906-
return originalSize - finalSize;
905+
var saved = originalSize - finalSize;
906+
saved = saved > 0 ? saved : 0;
907+
return saved;
907908
} finally
908909
{
909910
var finfos = XivCache.GameInfo.GameDirectory.GetFiles();

xivModdingFramework/SqPack/DataContainers/IndexFile.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,11 +533,36 @@ public long Get8xDataOffset(string filePath)
533533
}
534534

535535
/// <summary>
536-
/// Gets the data offset in the form of (datNumber, offset Within File)
536+
/// Gets the Index2 data offset in the form of (datNumber, offset Within File)
537537
/// Or (0, 0) if the file does not exist.
538538
/// </summary>
539539
/// <param name="filePath"></param>
540540
/// <returns></returns>
541+
public uint GetRawDataOffsetIndex2(string filePath)
542+
{
543+
544+
var fullHash = (uint)HashGenerator.GetHash(filePath);
545+
546+
if (Index2Entries.ContainsKey(fullHash))
547+
{
548+
var entry = Index2Entries[fullHash];
549+
return entry.RawFileOffset;
550+
}
551+
552+
return 0;
553+
}
554+
555+
/// <summary>
556+
/// Gets the 8x multiplied Index2 data offset from the index file, with DatNumber embeded.
557+
/// Or 0 if the file does not exist.
558+
/// This is primarily useful for legacy functionality.
559+
/// </summary>
560+
/// <param name="filePath"></param>
561+
/// <returns></returns>
562+
public long Get8xDataOffsetIndex2(string filePath)
563+
{
564+
return ((long)GetRawDataOffsetIndex2(filePath)) * 8L;
565+
}
541566
public (uint DatNumber, long DataOffset) GetDataOffsetComplete(string filePath)
542567
{
543568
var raw = GetRawDataOffset(filePath);

0 commit comments

Comments
 (0)