Skip to content

Commit a2c578d

Browse files
committed
A few fixes
- ExportPsk: do not crash if bone name exceeds 64 characters - truncating the name instead - UE4 pak file: properly handling concatenation of "Mount/" and "/", avoiding "//" at the end - GAME_Dauntless is now UE4.26-based
1 parent 0f6f4df commit a2c578d

File tree

5 files changed

+23
-7
lines changed

5 files changed

+23
-7
lines changed

Exporters/ExportPsk.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,22 @@ static void ExportExtraUV
306306
unguard;
307307
}
308308

309+
static void CopyBoneName(char* Dst, int DstLen, const char* Src)
310+
{
311+
int NameLength = strlen(Src);
312+
if (NameLength < DstLen)
313+
{
314+
strcpy(Dst, Src);
315+
}
316+
else
317+
{
318+
int Middle = (DstLen - 4) / 2;
319+
memcpy(Dst, Src, Middle);
320+
memcpy(Dst + Middle, "____", 4);
321+
memcpy(Dst + Middle + 4, Src + NameLength - Middle + 1, Middle); // +1 for keeping null terminating character
322+
appPrintf("WARNING: bone name \"%s\" is too long, renamed to \"%s\"\n", Src, Dst);
323+
}
324+
}
309325

310326
static void ExportSkeletalMeshLod(const CSkeletalMesh &Mesh, const CSkelMeshLod &Lod, FArchive &Ar)
311327
{
@@ -361,7 +377,7 @@ static void ExportSkeletalMeshLod(const CSkeletalMesh &Mesh, const CSkelMeshLod
361377
VBone B;
362378
memset(&B, 0, sizeof(B));
363379
const CSkelMeshBone &S = Mesh.RefSkeleton[i];
364-
strcpy(B.Name, S.Name);
380+
CopyBoneName(B.Name, sizeof(B.Name), *S.Name);
365381
// count NumChildren
366382
int NumChildren = 0;
367383
for (j = 0; j < numBones; j++)
@@ -561,8 +577,7 @@ static void DoExportPsa(const CAnimSet* Anim, const UObject* OriginalAnim)
561577
{
562578
FNamedBoneBinary B;
563579
memset(&B, 0, sizeof(B));
564-
assert(strlen(*Anim->TrackBoneNames[i]) < sizeof(B.Name));
565-
strcpy(B.Name, *Anim->TrackBoneNames[i]);
580+
CopyBoneName(B.Name, sizeof(B.Name), *Anim->TrackBoneNames[i]);
566581
B.Flags = 0; // reserved
567582
B.NumChildren = 0; // unknown here
568583
B.ParentIndex = (i > 0) ? 0 : -1; // unknown for UAnimSet

Unreal/FileSystem/UnArchivePak.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,8 +953,9 @@ bool FPakVFS::LoadPakIndex(FArchive* reader, const FPakInfo& info, FString& erro
953953
DirectoryPath = MountPoint;
954954
DirectoryPath += DirectoryName;
955955
CompactFilePath(DirectoryPath);
956-
if (DirectoryPath[DirectoryPath.Len()-1] == '/')
957-
DirectoryPath.RemoveAt(DirectoryPath.Len()-1, 1);
956+
// Remove any trailing slashes. Note that MountPoint may be empty (consisting just of '/'), so let's use a loop.
957+
while (DirectoryPath.EndsWith("//"))
958+
DirectoryPath.RemoveAt(DirectoryPath.Len()-1);
958959

959960
// Read size of FPakDirectory (DirectoryIndex::Value)
960961
int32 NumFilesInDirectory;

Unreal/UnCore.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,8 @@ enum EGame
495495
GAME_Borderlands3 = GAME_UE4(20)+1,
496496
// 4.21
497497
GAME_Jedi = GAME_UE4(21)+1,
498-
// 4.25
499-
GAME_Dauntless = GAME_UE4(25)+1,
498+
// 4.26
499+
GAME_Dauntless = GAME_UE4(26)+1,
500500

501501
GAME_ENGINE = 0xFFF0000 // mask for game engine
502502
};

umodel

0 Bytes
Binary file not shown.

umodel.exe

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)