From 5d23f8735975e04d8a5a55b270dc694900423899 Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Sat, 31 Aug 2024 09:34:18 +0100 Subject: [PATCH] Add yucky textrepl parsing --- project/code/LGS/Database/Chunks/Property.cs | 11 +++++++ project/code/LGS/Database/File.cs | 4 +++ project/code/LGS/Database/ObjectHierarchy.cs | 32 ++++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/project/code/LGS/Database/Chunks/Property.cs b/project/code/LGS/Database/Chunks/Property.cs index 98096cc..81362eb 100644 --- a/project/code/LGS/Database/Chunks/Property.cs +++ b/project/code/LGS/Database/Chunks/Property.cs @@ -93,3 +93,14 @@ public class PropRenderType : Property mode = (Mode)reader.ReadUInt32(); } } + +public class PropString : Property +{ + public string value; + + public override void Read(BinaryReader reader) + { + base.Read(reader); + value = Encoding.UTF8.GetString(reader.ReadBytes(length)).Replace("\0", string.Empty); + } +} diff --git a/project/code/LGS/Database/File.cs b/project/code/LGS/Database/File.cs index 7e63410..afe4e1b 100644 --- a/project/code/LGS/Database/File.cs +++ b/project/code/LGS/Database/File.cs @@ -105,6 +105,10 @@ public class DbFile "P$ModelName" => new PropertyChunk(), "P$Scale" => new PropertyChunk(), "P$RenderTyp" => new PropertyChunk(), + "P$OTxtRepr0" => new PropertyChunk(), + "P$OTxtRepr1" => new PropertyChunk(), + "P$OTxtRepr2" => new PropertyChunk(), + "P$OTxtRepr3" => new PropertyChunk(), "LD$MetaProp" => new LinkDataMetaProp(), _ when entryName.StartsWith("L$") => new LinkChunk(), _ when entryName.StartsWith("P$") => new PropertyChunk(), diff --git a/project/code/LGS/Database/ObjectHierarchy.cs b/project/code/LGS/Database/ObjectHierarchy.cs index cde0a3d..b5f32a4 100644 --- a/project/code/LGS/Database/ObjectHierarchy.cs +++ b/project/code/LGS/Database/ObjectHierarchy.cs @@ -38,12 +38,20 @@ public class ObjectHierarchy if (db.Chunks.TryGetValue("P$ModelName", out var modelNamesRaw) && db.Chunks.TryGetValue("P$Scale", out var scalesRaw) && db.Chunks.TryGetValue("P$RenderTyp", out var renderTypesRaw) && + db.Chunks.TryGetValue("P$OTxtRepr0", out var txtRepl0Raw) && + db.Chunks.TryGetValue("P$OTxtRepr1", out var txtRepl1Raw) && + db.Chunks.TryGetValue("P$OTxtRepr2", out var txtRepl2Raw) && + db.Chunks.TryGetValue("P$OTxtRepr3", out var txtRepl3Raw) && db.Chunks.TryGetValue("L$MetaProp", out var metaPropLinksRaw) && db.Chunks.TryGetValue("LD$MetaProp", out var metaPropLinkDataRaw)) { var modelNames = (PropertyChunk)modelNamesRaw; var scales = (PropertyChunk)scalesRaw; var renderTypes = (PropertyChunk)renderTypesRaw; + var txtRepl0s = (PropertyChunk)txtRepl0Raw; + var txtRepl1s = (PropertyChunk)txtRepl1Raw; + var txtRepl2s = (PropertyChunk)txtRepl2Raw; + var txtRepl3s = (PropertyChunk)txtRepl3Raw; var metaPropLinks = (LinkChunk)metaPropLinksRaw; var metaPropLinkData = (LinkDataMetaProp)metaPropLinkDataRaw; @@ -52,12 +60,20 @@ public class ObjectHierarchy gam.Chunks.TryGetValue("P$ModelName", out var gamModelNames) && gam.Chunks.TryGetValue("P$Scale", out var gamScales) && gam.Chunks.TryGetValue("P$RenderTyp", out var gamRenderTypes) && + gam.Chunks.TryGetValue("P$OTxtRepr0", out var gamTxtRepl0s) && + gam.Chunks.TryGetValue("P$OTxtRepr1", out var gamTxtRepl1s) && + gam.Chunks.TryGetValue("P$OTxtRepr2", out var gamTxtRepl2s) && + gam.Chunks.TryGetValue("P$OTxtRepr3", out var gamTxtRepl3s) && gam.Chunks.TryGetValue("L$MetaProp", out var gamLinks) && gam.Chunks.TryGetValue("LD$MetaProp", out var gamLinkData)) { modelNames.properties.AddRange(((PropertyChunk)gamModelNames).properties); scales.properties.AddRange(((PropertyChunk)gamScales).properties); renderTypes.properties.AddRange(((PropertyChunk)gamRenderTypes).properties); + txtRepl0s.properties.AddRange(((PropertyChunk)gamTxtRepl0s).properties); + txtRepl1s.properties.AddRange(((PropertyChunk)gamTxtRepl1s).properties); + txtRepl2s.properties.AddRange(((PropertyChunk)gamTxtRepl2s).properties); + txtRepl3s.properties.AddRange(((PropertyChunk)gamTxtRepl3s).properties); metaPropLinks.links.AddRange(((LinkChunk)gamLinks).links); metaPropLinkData.linkData.AddRange(((LinkDataMetaProp)gamLinkData).linkData); } @@ -108,6 +124,22 @@ public class ObjectHierarchy { TryAddProp("P$RenderTyp", prop); } + foreach (var prop in txtRepl0s.properties) + { + TryAddProp("P$OTxtRepr0", prop); + } + foreach (var prop in txtRepl1s.properties) + { + TryAddProp("P$OTxtRepr1", prop); + } + foreach (var prop in txtRepl2s.properties) + { + TryAddProp("P$OTxtRepr2", prop); + } + foreach (var prop in txtRepl3s.properties) + { + TryAddProp("P$OTxtRepr3", prop); + } } }