Skip to content

Commit e7af911

Browse files
committed
- Resolved issues in the expansion of GMP/EQP data.
1 parent ee792ec commit e7af911

File tree

1 file changed

+8
-5
lines changed
  • xivModdingFramework/Models/FileTypes

1 file changed

+8
-5
lines changed

xivModdingFramework/Models/FileTypes/Eqp.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,11 @@ public async Task SaveGmpEntries(List<(uint PrimaryId, GimmickParameter GmpData)
129129

130130
// Resolve offsets, expanding on the first pass.
131131
// (GMP files use an identical file structure to EQP files)
132+
132133
while (!clean)
133134
{
134135
clean = true;
136+
offsets.Clear();
135137
foreach (var tuple in entries)
136138
{
137139
var offset = ResolveEqpEntryOffset(file, (int)tuple.PrimaryId);
@@ -281,9 +283,10 @@ public async Task SaveEqpEntries(List<(uint PrimaryId, EquipmentParameter EqpDat
281283
var clean = false;
282284

283285
// Resolve offsets, expanding on the first pass.
284-
while(!clean)
286+
while (!clean)
285287
{
286288
clean = true;
289+
offsets.Clear();
287290
foreach (var tuple in entries)
288291
{
289292
var offset = ResolveEqpEntryOffset(file, (int)tuple.PrimaryId);
@@ -310,7 +313,7 @@ public async Task SaveEqpEntries(List<(uint PrimaryId, EquipmentParameter EqpDat
310313
}
311314

312315

313-
foreach(var tuple in entries)
316+
foreach (var tuple in entries)
314317
{
315318
var offset = offsets[tuple.PrimaryId];
316319
var slotOffset = EquipmentParameterSet.EntryOffsets[tuple.EqpData.Slot];
@@ -582,7 +585,7 @@ private byte[] ExpandEqpBlock(byte[] eqpData, int setId)
582585
var baseOffset = uncompressedBlocks * blockSize;
583586

584587
// Total Size of the data.
585-
var totalDataSize = (totalUncompressedBlocks * blockSize * EquipmentParameterEntrySize);
588+
var totalDataSize = ((totalUncompressedBlocks + 1) * blockSize * EquipmentParameterEntrySize);
586589

587590
// Pad out to nearest 512 bytes.
588591
var padding = totalDataSize % 512 == 0 ? 0 : 512 - (totalDataSize % 512);
@@ -597,12 +600,12 @@ private byte[] ExpandEqpBlock(byte[] eqpData, int setId)
597600
// Copy the first half of the data in, then a blank block, then the second half of the data.
598601
Array.Copy(eqpData, 0, newData, 0, newDataByteOffset);
599602
var rem = eqpData.Length - newDataByteOffset;
600-
var rem2 = newData.Length - newDataByteOffset - (blockSize * EquipmentDeformerParameterEntrySize);
603+
var rem2 = newData.Length - newDataByteOffset - (blockSize * EquipmentParameterEntrySize);
601604

602605
// Don't let us try to write padding data off the end of the file.
603606
rem = rem > rem2 ? rem2 : rem;
604607

605-
Array.Copy(eqpData, newDataByteOffset, newData, newDataByteOffset + (blockSize * EquipmentDeformerParameterEntrySize), rem);
608+
Array.Copy(eqpData, newDataByteOffset, newData, newDataByteOffset + (blockSize * EquipmentParameterEntrySize), rem);
606609

607610
// Return new array.
608611
return newData;

0 commit comments

Comments
 (0)