From ea57190029bf649a73217bbd703696c9f3ad8c7d Mon Sep 17 00:00:00 2001 From: BlueCube3310 <53150244+BlueCube3310@users.noreply.github.com> Date: Wed, 22 Jan 2025 20:21:00 +0100 Subject: [PATCH] Fix TerrainInstanceInfo v0 reading and writing (#24) --- .../HedgehogEngine/Mirage/TerrainInstanceInfo.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/SharpNeedle/HedgehogEngine/Mirage/TerrainInstanceInfo.cs b/Source/SharpNeedle/HedgehogEngine/Mirage/TerrainInstanceInfo.cs index bc3dd86..ba84139 100644 --- a/Source/SharpNeedle/HedgehogEngine/Mirage/TerrainInstanceInfo.cs +++ b/Source/SharpNeedle/HedgehogEngine/Mirage/TerrainInstanceInfo.cs @@ -26,9 +26,11 @@ public override void Read(BinaryObjectReader reader) ModelName = reader.ReadStringOffset(); Transform = Matrix4x4.Transpose(reader.ReadValueOffset()); Name = reader.ReadStringOffset(); - LightGroups = DataVersion >= 5 - ? reader.ReadObject>>().Unwind() - : new List(2) { reader.ReadObject() }; + + if (DataVersion >= 5) + LightGroups = reader.ReadObject>>().Unwind(); + else if(DataVersion > 0) + LightGroups = new List(2) { reader.ReadObject() }; } public override void Write(BinaryObjectWriter writer) @@ -45,7 +47,7 @@ public override void Write(BinaryObjectWriter writer) writer.WriteObjectOffset(group); }); } - else + else if (DataVersion > 0) { if (LightGroups.Count == 1) LightGroups[0].Write(writer);