Skip to content

Commit d73e1db

Browse files
committed
Improved fix for Transformers: Fall of Cybertron animation
Crashed on psa export when animation sequence has no tracks
1 parent 10fdbca commit d73e1db

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

Unreal/UnrealMesh/UnAnim3.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,14 @@ static void ReadArgonautsTimeArray(const TArray<unsigned> &SourceArray, int Firs
295295

296296
#if TRANSFORMERS
297297

298-
void UAnimSequence::DecodeTrans3Anims(CAnimSequence *Dst, UAnimSet *Owner) const
298+
bool UAnimSequence::DecodeTrans3Anims(CAnimSequence *Dst, UAnimSet *Owner) const
299299
{
300300
guard(UAnimSequence::DecodeTrans3Anims);
301301

302302
if (CompressedByteStream.Num() == 0)
303303
{
304304
// This situation is true for some sequences
305-
return;
305+
return false;
306306
}
307307

308308
// read some counts first
@@ -525,6 +525,7 @@ void UAnimSequence::DecodeTrans3Anims(CAnimSequence *Dst, UAnimSet *Owner) const
525525
DBG(" - %s\n", *Owner->TrackBoneNames[Bone]);
526526
}
527527

528+
return true;
528529
unguard;
529530
}
530531

@@ -710,12 +711,20 @@ void UAnimSet::ConvertAnims()
710711
if (ArGame == GAME_Transformers && Seq->Trans3Data.Num())
711712
{
712713
CAnimSequence *Dst = new CAnimSequence(Seq);
713-
AnimSet->Sequences.Add(Dst);
714714
Dst->Name = Seq->SequenceName;
715715
Dst->NumFrames = Seq->NumFrames;
716716
Dst->Rate = Seq->NumFrames / Seq->SequenceLength * Seq->RateScale;
717717
Dst->bAdditive = Seq->bIsAdditive;
718-
Seq->DecodeTrans3Anims(Dst, this);
718+
719+
if (Seq->DecodeTrans3Anims(Dst, this))
720+
{
721+
AnimSet->Sequences.Add(Dst);
722+
}
723+
else
724+
{
725+
// Failed to decode, drop the track
726+
delete Dst;
727+
}
719728
continue;
720729
}
721730
#endif // TRANSFORMERS

Unreal/UnrealMesh/UnMesh3.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ class UAnimSequence : public UObject
657657
void DecodeBatman2Anims(CAnimSequence *Dst, UAnimSet *Owner) const;
658658
#endif
659659
#if TRANSFORMERS
660-
void DecodeTrans3Anims(CAnimSequence *Dst, UAnimSet *Owner) const;
660+
bool DecodeTrans3Anims(CAnimSequence *Dst, UAnimSet *Owner) const;
661661
#endif
662662
};
663663

0 commit comments

Comments
 (0)