Skip to content

Commit

Permalink
A few fixes
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
gildor2 committed Oct 26, 2021
1 parent 0f6f4df commit a2c578d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
21 changes: 18 additions & 3 deletions Exporters/ExportPsk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,22 @@ static void ExportExtraUV
unguard;
}

static void CopyBoneName(char* Dst, int DstLen, const char* Src)
{
int NameLength = strlen(Src);
if (NameLength < DstLen)
{
strcpy(Dst, Src);
}
else
{
int Middle = (DstLen - 4) / 2;
memcpy(Dst, Src, Middle);
memcpy(Dst + Middle, "____", 4);
memcpy(Dst + Middle + 4, Src + NameLength - Middle + 1, Middle); // +1 for keeping null terminating character
appPrintf("WARNING: bone name \"%s\" is too long, renamed to \"%s\"\n", Src, Dst);
}
}

static void ExportSkeletalMeshLod(const CSkeletalMesh &Mesh, const CSkelMeshLod &Lod, FArchive &Ar)
{
Expand Down Expand Up @@ -361,7 +377,7 @@ static void ExportSkeletalMeshLod(const CSkeletalMesh &Mesh, const CSkelMeshLod
VBone B;
memset(&B, 0, sizeof(B));
const CSkelMeshBone &S = Mesh.RefSkeleton[i];
strcpy(B.Name, S.Name);
CopyBoneName(B.Name, sizeof(B.Name), *S.Name);
// count NumChildren
int NumChildren = 0;
for (j = 0; j < numBones; j++)
Expand Down Expand Up @@ -561,8 +577,7 @@ static void DoExportPsa(const CAnimSet* Anim, const UObject* OriginalAnim)
{
FNamedBoneBinary B;
memset(&B, 0, sizeof(B));
assert(strlen(*Anim->TrackBoneNames[i]) < sizeof(B.Name));
strcpy(B.Name, *Anim->TrackBoneNames[i]);
CopyBoneName(B.Name, sizeof(B.Name), *Anim->TrackBoneNames[i]);
B.Flags = 0; // reserved
B.NumChildren = 0; // unknown here
B.ParentIndex = (i > 0) ? 0 : -1; // unknown for UAnimSet
Expand Down
5 changes: 3 additions & 2 deletions Unreal/FileSystem/UnArchivePak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -953,8 +953,9 @@ bool FPakVFS::LoadPakIndex(FArchive* reader, const FPakInfo& info, FString& erro
DirectoryPath = MountPoint;
DirectoryPath += DirectoryName;
CompactFilePath(DirectoryPath);
if (DirectoryPath[DirectoryPath.Len()-1] == '/')
DirectoryPath.RemoveAt(DirectoryPath.Len()-1, 1);
// Remove any trailing slashes. Note that MountPoint may be empty (consisting just of '/'), so let's use a loop.
while (DirectoryPath.EndsWith("//"))
DirectoryPath.RemoveAt(DirectoryPath.Len()-1);

// Read size of FPakDirectory (DirectoryIndex::Value)
int32 NumFilesInDirectory;
Expand Down
4 changes: 2 additions & 2 deletions Unreal/UnCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,8 @@ enum EGame
GAME_Borderlands3 = GAME_UE4(20)+1,
// 4.21
GAME_Jedi = GAME_UE4(21)+1,
// 4.25
GAME_Dauntless = GAME_UE4(25)+1,
// 4.26
GAME_Dauntless = GAME_UE4(26)+1,

GAME_ENGINE = 0xFFF0000 // mask for game engine
};
Expand Down
Binary file modified umodel
Binary file not shown.
Binary file modified umodel.exe
Binary file not shown.

0 comments on commit a2c578d

Please sign in to comment.