Skip to content

Commit 7412ccc

Browse files
committed
Update 2.3.2.7
2 parents 2fc18c5 + 7a344c1 commit 7412ccc

File tree

1 file changed

+13
-7
lines changed
  • xivModdingFramework/SqPack/FileTypes

1 file changed

+13
-7
lines changed

xivModdingFramework/SqPack/FileTypes/Index.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public Index(DirectoryInfo gameDirectory)
5151
/// </summary>
5252
/// <param name="dataFile">The data file to update the index for.</param>
5353
/// <param name="datNum">The dat number to update to.</param>
54-
public void UpdateIndexDatCount(XivDataFile dataFile, int datNum)
54+
public void UpdateIndexDatCount(XivDataFile dataFile, int datNum, bool alreadySemaphoreLocked = false)
5555
{
5656
var datCount = (byte)(datNum + 1);
5757

@@ -63,7 +63,10 @@ public void UpdateIndexDatCount(XivDataFile dataFile, int datNum)
6363

6464
foreach (var indexPath in indexPaths)
6565
{
66-
_semaphoreSlim.Wait();
66+
if (!alreadySemaphoreLocked)
67+
{
68+
_semaphoreSlim.Wait();
69+
}
6770
try
6871
{
6972
using (var bw = new BinaryWriter(File.OpenWrite(indexPath)))
@@ -74,7 +77,10 @@ public void UpdateIndexDatCount(XivDataFile dataFile, int datNum)
7477
}
7578
finally
7679
{
77-
_semaphoreSlim.Release();
80+
if (!alreadySemaphoreLocked)
81+
{
82+
_semaphoreSlim.Release();
83+
}
7884
}
7985
}
8086
}
@@ -790,6 +796,10 @@ public async Task SaveIndexFile(IndexFile index, bool alreadySemaphoreLocked = f
790796
}
791797
}
792798

799+
800+
var _dat = new Dat(XivCache.GameInfo.GameDirectory);
801+
var largestDatNum = _dat.GetLargestDatNumber(index.DataFile);
802+
UpdateIndexDatCount(index.DataFile, largestDatNum, true);
793803
}
794804
finally
795805
{
@@ -798,10 +808,6 @@ public async Task SaveIndexFile(IndexFile index, bool alreadySemaphoreLocked = f
798808
_semaphoreSlim.Release();
799809
}
800810
}
801-
802-
var _dat = new Dat(XivCache.GameInfo.GameDirectory);
803-
var largestDatNum = _dat.GetLargestDatNumber(index.DataFile);
804-
UpdateIndexDatCount(index.DataFile, largestDatNum);
805811
}
806812

807813

0 commit comments

Comments
 (0)