apply padding to the correct animation result index when results are reused between sequences

This commit is contained in:
Joshua Smith 2024-10-28 12:57:13 -05:00
parent 112fce2031
commit 17cb8623f4

8
gfx.c
View File

@ -1516,6 +1516,7 @@ void WriteNtrAnimation(char *path, struct JsonToAnimationOptions *options)
{ {
int sequenceLen = 0; int sequenceLen = 0;
int resultIndex = 0; int resultIndex = 0;
int lastNewResultIndex = -1;
for (int j = 0; j < options->sequenceData[i]->frameCount; j++) for (int j = 0; j < options->sequenceData[i]->frameCount; j++)
{ {
// check if the result has already been used // check if the result has already been used
@ -1532,6 +1533,7 @@ void WriteNtrAnimation(char *path, struct JsonToAnimationOptions *options)
if (usedResults[resultIndex] == -1) if (usedResults[resultIndex] == -1)
{ {
usedResults[resultIndex] = options->sequenceData[i]->frameData[j]->resultId; usedResults[resultIndex] = options->sequenceData[i]->frameData[j]->resultId;
lastNewResultIndex = options->sequenceData[i]->frameData[j]->resultId;
break; break;
} }
} }
@ -1547,11 +1549,11 @@ void WriteNtrAnimation(char *path, struct JsonToAnimationOptions *options)
sequenceLen += 0x8; sequenceLen += 0x8;
} }
} }
if (sequenceLen % 4 != 0) if (sequenceLen % 4 != 0 && lastNewResultIndex != -1)
{ {
totalSize += 0x02; totalSize += 0x02;
// mark the last animationResult for the sequence as padded, this saves needing to check this again later // mark the last new animationResult index for the sequence as padded, this saves needing to check this again later
options->animationResults[resultIndex]->padded = true; options->animationResults[lastNewResultIndex]->padded = true;
} }
} }