diff --git a/src/Parsec/Shaiya/3dc/_3dc.cs b/src/Parsec/Shaiya/3dc/_3dc.cs
index 276bd795..a37f48df 100644
--- a/src/Parsec/Shaiya/3dc/_3dc.cs
+++ b/src/Parsec/Shaiya/3dc/_3dc.cs
@@ -13,6 +13,11 @@ namespace Parsec.Shaiya._3dc;
///
public sealed class _3dc : FileBase
{
+ ///
+ /// Some mob files store TGA name.
+ ///
+ public string Icon { get; set; } = "";
+
///
/// List of bones linked to this 3d model. Although a model might be linked to a few bones (for example boots models), the
/// 3DC file contains the definitions for all the bones in the whole skeleton.
@@ -30,15 +35,17 @@ public sealed class _3dc : FileBase
///
public List Faces { get; set; } = new();
+ private const int Ep6Flag = 444;
+
[JsonIgnore]
public override string Extension => "3DC";
protected override void Read(SBinaryReader binaryReader)
{
- var version = binaryReader.ReadInt32();
+ var versionOrTGALength = binaryReader.ReadInt32();
Episode = Episode.EP5;
- if (version == 444)
+ if (versionOrTGALength == Ep6Flag)
{
Episode = Episode.EP6;
}
@@ -46,6 +53,8 @@ protected override void Read(SBinaryReader binaryReader)
// Vertex instances expect the episode to be set on the serialization options
binaryReader.SerializationOptions.Episode = Episode;
+ if (versionOrTGALength > 0 && versionOrTGALength != Ep6Flag)
+ Icon = binaryReader.ReadString(versionOrTGALength);
Bones = binaryReader.ReadList<_3dcBone>().ToList();
Vertices = binaryReader.ReadList<_3dcVertex>().ToList();
Faces = binaryReader.ReadList().ToList();
@@ -57,13 +66,16 @@ protected override void Write(SBinaryWriter binaryWriter)
if (Episode >= Episode.EP6)
{
- version = 444;
+ version = Ep6Flag;
}
// Vertex instances expect the episode to be set on the serialization options
binaryWriter.SerializationOptions.Episode = Episode;
- binaryWriter.Write(version);
+ if (string.IsNullOrEmpty(Icon) || version == Ep6Flag)
+ binaryWriter.Write(version);
+ else
+ binaryWriter.Write(Icon);
binaryWriter.Write(Bones.ToSerializable());
binaryWriter.Write(Vertices.ToSerializable());
binaryWriter.Write(Faces.ToSerializable());
diff --git a/tests/Parsec.Tests/Parsec.Tests.csproj b/tests/Parsec.Tests/Parsec.Tests.csproj
index 3a3770d2..60c1afed 100644
--- a/tests/Parsec.Tests/Parsec.Tests.csproj
+++ b/tests/Parsec.Tests/Parsec.Tests.csproj
@@ -24,6 +24,9 @@
+
+ PreserveNewest
+
PreserveNewest
diff --git a/tests/Parsec.Tests/Shaiya/3DC/_3DCTests.cs b/tests/Parsec.Tests/Shaiya/3DC/_3DCTests.cs
index 1a09891a..a1ea154e 100644
--- a/tests/Parsec.Tests/Shaiya/3DC/_3DCTests.cs
+++ b/tests/Parsec.Tests/Shaiya/3DC/_3DCTests.cs
@@ -95,6 +95,7 @@ public void _3DCReadWriteEP6Test()
[InlineData("vehicle_El_06.3DC")]
[InlineData("WhiteWing.3DC")]
[InlineData("Wing_01.3DC")]
+ [InlineData("mob_rend_01_a.3dc")]
public void _3DCMultipleReadWriteTest(string fileName)
{
var filePath = $"Shaiya/3DC/{fileName}";
diff --git a/tests/Parsec.Tests/Shaiya/3DC/mob_rend_01_a.3dc b/tests/Parsec.Tests/Shaiya/3DC/mob_rend_01_a.3dc
new file mode 100644
index 00000000..64765acf
Binary files /dev/null and b/tests/Parsec.Tests/Shaiya/3DC/mob_rend_01_a.3dc differ