Skip to content

Commit 96f5548

Browse files
committed
Days Gone support (has minor issues)
1 parent 961952b commit 96f5548

File tree

7 files changed

+101
-2
lines changed

7 files changed

+101
-2
lines changed

Unreal/GameDatabase.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,9 @@ const GameInfo GListOfGames[] = {
359359
# if GEARS4
360360
G("Gears of War 4", gears4, GAME_Gears4),
361361
# endif
362+
# if DAYSGONE
363+
G("Days Gone", daysgone, GAME_DaysGone),
364+
# endif
362365
# if ARK
363366
G("Ark: Survival Evolved", ark, GAME_Ark),
364367
# endif
@@ -908,6 +911,9 @@ static const UEVersionMap ueVersions[] =
908911
// is defined as GAME_UE4(13), but we're defining package version 4.14.
909912
G(GAME_Lawbreakers, VER_UE4_14)
910913
#endif
914+
#if DAYSGONE
915+
G(GAME_DaysGone, 499) // 500 = VER_UE4_INNER_ARRAY_TAG_INFO, but it's not here
916+
#endif
911917
#endif // UNREAL4
912918
#if ENDWAR
913919
G(GAME_EndWar, 224)

Unreal/GameDefines.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@
150150
#if UNREAL4
151151

152152
#define GEARS4 1 // Gears of War 4
153+
#define DAYSGONE 1 // Days Gone
153154
#define TEKKEN7 1 // Tekken 7
154155
#define LAWBREAKERS 1 // Lawbreakers
155156
#define SOD2 1 // State of Decay 2

Unreal/UnAnim4.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ FArchive& operator<<(FArchive& Ar, FReferenceSkeleton& S)
5454
if (Ar.ArVer >= VER_UE4_REFERENCE_SKELETON_REFACTOR)
5555
Ar << S.NameToIndexMap;
5656

57+
#if DAYSGONE
58+
if (Ar.Game == GAME_DaysGone)
59+
{
60+
// Additional per-bone attribute
61+
TArray<FVector> unk;
62+
Ar << unk;
63+
}
64+
#endif // DAYSGONE
65+
5766
int NumBones = S.RefBoneInfo.Num();
5867
if (Ar.ArVer < VER_UE4_FIXUP_ROOTBONE_PARENT && NumBones > 0 && S.RefBoneInfo[0].ParentIndex != INDEX_NONE)
5968
S.RefBoneInfo[0].ParentIndex = INDEX_NONE;

Unreal/UnCore.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ enum EGame
420420
GAME_HIT = GAME_UE4(8)+1,
421421
// 4.11
422422
GAME_Gears4 = GAME_UE4(11)+1,
423+
GAME_DaysGone = GAME_UE4(11)+2,
423424
// 4.13
424425
GAME_Lawbreakers = GAME_UE4(13)+1,
425426
GAME_StateOfDecay2 = GAME_UE4(13)+2,

Unreal/UnMaterial3.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ enum ETextureCompressionSettings
8686
TC_NormalmapBC5,
8787
TC_OneBitMonochrome,
8888
TC_SimpleLightmapModification,
89+
90+
#if DAYSGONE
91+
TC_BendDefault,
92+
TC_BendNormalmap,
93+
#endif
8994
};
9095

9196
_ENUM(ETextureCompressionSettings)
@@ -109,6 +114,11 @@ _ENUM(ETextureCompressionSettings)
109114
_E(TC_NormalmapBC5),
110115
_E(TC_OneBitMonochrome),
111116
_E(TC_SimpleLightmapModification),
117+
118+
#if DAYSGONE
119+
_E(TC_BendDefault),
120+
_E(TC_BendNormalmap),
121+
#endif
112122
};
113123

114124
struct FTextureSource

Unreal/UnMesh4.cpp

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,23 @@ struct FColorVertexBuffer4
7373
}
7474
};
7575

76+
#if DAYSGONE
77+
78+
struct FDGPackedVector
79+
{
80+
FVectorFixed48 V;
81+
uint16 Pad;
82+
83+
friend FArchive& operator<<(FArchive& Ar, FDGPackedVector& PV)
84+
{
85+
return Ar << PV.V << PV.Pad;
86+
}
87+
};
88+
89+
SIMPLE_TYPE(FDGPackedVector, uint16);
90+
91+
#endif // DAYSGONE
92+
7693
struct FPositionVertexBuffer4
7794
{
7895
TArray<FVector> Verts;
@@ -85,6 +102,36 @@ struct FPositionVertexBuffer4
85102

86103
Ar << S.Stride << S.NumVertices;
87104
DBG_MESH("PositionStream: IS:%d NV:%d\n", S.Stride, S.NumVertices);
105+
106+
#if DAYSGONE
107+
if (Ar.Game == GAME_DaysGone)
108+
{
109+
// This happens only for StaticMesh
110+
if (S.Stride == 8)
111+
{
112+
TArray<FDGPackedVector> PackedVerts;
113+
PackedVerts.BulkSerialize(Ar);
114+
S.Verts.AddUninitialized(PackedVerts.Num());
115+
for (int i = 0; i < PackedVerts.Num(); i++)
116+
{
117+
S.Verts[i] = PackedVerts[i].V;
118+
}
119+
//todo: should use some bounds to unpack positions, almost works but a bit distorted data
120+
return Ar;
121+
}
122+
else if (S.Stride == 4)
123+
{
124+
TArray<uint32> PackedVerts;
125+
// No idea which format is used here
126+
PackedVerts.BulkSerialize(Ar);
127+
//todo: should use some bounds to unpack positions; position is 32-bit, with full use of all bits
128+
return Ar;
129+
}
130+
// else - use standard format
131+
assert(S.Stride == 12);
132+
}
133+
#endif // DAYSGONE
134+
88135
S.Verts.BulkSerialize(Ar);
89136
return Ar;
90137

@@ -504,6 +551,14 @@ struct FSkeletalMaterial
504551

505552
Ar << M.Material;
506553

554+
#if DAYSGONE
555+
if (Ar.Game == GAME_DaysGone)
556+
{
557+
int32 unk1;
558+
Ar << unk1;
559+
}
560+
#endif // DAYSGONE
561+
507562
if (FEditorObjectVersion::Get(Ar) >= FEditorObjectVersion::RefactorMeshEditorMaterials)
508563
{
509564
Ar << M.MaterialSlotName;
@@ -1217,6 +1272,15 @@ struct FStaticLODModel4
12171272

12181273
if (Ar.ArVer >= VER_UE4_APEX_CLOTH && Lod.HasClothData())
12191274
Ar << Lod.ClothVertexBuffer;
1275+
1276+
#if DAYSGONE
1277+
if (Ar.Game == GAME_DaysGone)
1278+
{
1279+
FMultisizeIndexContainer unk1;
1280+
int32 unk2, unk3, unk4;
1281+
Ar << unk1 << unk2 << unk3 << unk4;
1282+
}
1283+
#endif // DAYSGONE
12201284
}
12211285
}
12221286

@@ -2267,6 +2331,14 @@ void UStaticMesh4::Serialize(FArchive &Ar)
22672331
// serialize FStaticMeshRenderData
22682332
if (bCooked)
22692333
{
2334+
#if DAYSGONE
2335+
if (Ar.Game == GAME_DaysGone)
2336+
{
2337+
int32 unk;
2338+
Ar << unk;
2339+
}
2340+
#endif // DAYSGONE
2341+
22702342
// Note: code below still contains 'if (bCooked)' switches, this is because the same
22712343
// code could be used to read data from DDC, for non-cooked assets.
22722344
DBG_STAT("Serializing RenderData\n");

Unreal/UnPackage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,8 +1647,8 @@ void UnPackage::LoadNameTable()
16471647
#if UNREAL4
16481648
if (Game >= GAME_UE4_BASE)
16491649
{
1650-
#if GEARS4
1651-
if (Game == GAME_Gears4) goto name_hashes;
1650+
#if GEARS4 || DAYSGONE
1651+
if (Game == GAME_Gears4 || Game == GAME_DaysGone) goto name_hashes;
16521652
#endif
16531653
if (ArVer >= VER_UE4_NAME_HASHES_SERIALIZED)
16541654
{

0 commit comments

Comments
 (0)