diff --git a/CodeWalker.Core/GameFiles/FileTypes/YtdFile.cs b/CodeWalker.Core/GameFiles/FileTypes/YtdFile.cs index 5915e5f..ff3ce26 100644 --- a/CodeWalker.Core/GameFiles/FileTypes/YtdFile.cs +++ b/CodeWalker.Core/GameFiles/FileTypes/YtdFile.cs @@ -45,5 +45,13 @@ namespace CodeWalker.GameFiles } + public byte[] Save() + { + byte[] data = ResourceBuilder.Build(TextureDict, 13); //ytd is type/version 13... + + return data; + } + + } } diff --git a/CodeWalker.Core/GameFiles/GameFileCache.cs b/CodeWalker.Core/GameFiles/GameFileCache.cs index ce33956..4f51144 100644 --- a/CodeWalker.Core/GameFiles/GameFileCache.cs +++ b/CodeWalker.Core/GameFiles/GameFileCache.cs @@ -164,19 +164,20 @@ namespace CodeWalker.GameFiles RpfMan.BuildExtendedJenkIndex = BuildExtendedJenkIndex; RpfMan.Init(GTAFolder, UpdateStatus, ErrorLog);//, true); - //RE test area! - //TestAudioRels(); - InitGlobal(); InitDlc(); + + //RE test area! + //TestAudioRels(); //TestAudioYmts(); //TestMetas(); //TestPsos(); //TestYcds(); + //TestYtds(); //TestYmaps(); //TestPlacements(); //TestDrawables(); @@ -2106,13 +2107,11 @@ namespace CodeWalker.GameFiles private void AddTextureLookups(YtdFile ytd) { - if (ytd == null) return; - if (ytd.TextureDict == null) return; - if (ytd.TextureDict.TextureNameHashes == null) return; + if (ytd?.TextureDict?.TextureNameHashes?.data_items == null) return; lock (textureSyncRoot) { - foreach (uint hash in ytd.TextureDict.TextureNameHashes) + foreach (uint hash in ytd.TextureDict.TextureNameHashes.data_items) { textureLookup[hash] = ytd.RpfFileEntry; } @@ -2864,6 +2863,66 @@ namespace CodeWalker.GameFiles //{ //} } + public void TestYtds() + { + var errorfiles = new List(); + foreach (RpfFile file in AllRpfs) + { + foreach (RpfEntry entry in file.AllEntries) + { + //try + { + if (entry.NameLower.EndsWith(".ytd")) + { + UpdateStatus(string.Format(entry.Path)); + YtdFile ytdfile = null; + try + { + ytdfile = RpfMan.GetFile(entry); + } + catch(Exception ex) + { + UpdateStatus("Error! " + ex.ToString()); + errorfiles.Add(entry); + } + if ((ytdfile != null) && (ytdfile.TextureDict != null)) + { + var fentry = entry as RpfFileEntry; + if (fentry == null) + { continue; } //shouldn't happen + + var bytes = ytdfile.Save(); + + string origlen = TextUtil.GetBytesReadable(fentry.FileSize); + string bytelen = TextUtil.GetBytesReadable(bytes.Length); + + if (ytdfile.TextureDict.Textures?.Count == 0) + { } + + + var ytd2 = new YtdFile(); + //ytd2.Load(bytes, fentry); + RpfFile.LoadResourceFile(ytd2, bytes, 13); + + if (ytd2.TextureDict == null) + { continue; } + if (ytd2.TextureDict.Textures?.Count != ytdfile.TextureDict.Textures?.Count) + { continue; } + + + + } + } + } + //catch (Exception ex) + //{ + // UpdateStatus("Error! " + ex.ToString()); + //} + } + } + if (errorfiles.Count > 0) + { } + } public void TestYmaps() { foreach (RpfFile file in AllRpfs) diff --git a/CodeWalker.Core/GameFiles/MetaTypes/Meta.cs b/CodeWalker.Core/GameFiles/MetaTypes/Meta.cs index 5d9857f..b636eef 100644 --- a/CodeWalker.Core/GameFiles/MetaTypes/Meta.cs +++ b/CodeWalker.Core/GameFiles/MetaTypes/Meta.cs @@ -54,6 +54,8 @@ namespace CodeWalker.GameFiles public string Name { get; private set; } //public string[] Strings { get; set; } + private string_r NameBlock = null; + /// /// Reads the data-block from a stream. @@ -107,6 +109,9 @@ namespace CodeWalker.GameFiles (ulong)this.NamePointer // offset ); + if (!string.IsNullOrEmpty(Name)) + { } + //Strings = MetaTypes.GetStrings(this); } @@ -121,7 +126,7 @@ namespace CodeWalker.GameFiles this.StructureInfosPointer = this.StructureInfos?.FilePosition ?? 0; this.EnumInfosPointer = this.EnumInfos?.FilePosition ?? 0; this.DataBlocksPointer = this.DataBlocks?.FilePosition ?? 0; - //this.NamePointer = this.Name?.Position ?? 0; //TODO: fix + this.NamePointer = this.NameBlock?.FilePosition ?? 0; this.UselessPointer = 0; this.StructureInfosCount = (short)(this.StructureInfos?.Count ?? 0); this.EnumInfosCount = (short)(this.EnumInfos?.Count ?? 0); @@ -162,7 +167,11 @@ namespace CodeWalker.GameFiles if ((StructureInfos != null) && (StructureInfos.Count > 0)) list.Add(StructureInfos); if ((EnumInfos != null) && (EnumInfos.Count > 0)) list.Add(EnumInfos); if ((DataBlocks != null) && (DataBlocks.Count > 0)) list.Add(DataBlocks); - //if (Name != null) list.Add(Name); //TODO: fix + if (!string.IsNullOrEmpty(Name)) + { + NameBlock = (string_r)Name; + list.Add(NameBlock); + } return list.ToArray(); } diff --git a/CodeWalker.Core/GameFiles/Resources/Bounds.cs b/CodeWalker.Core/GameFiles/Resources/Bounds.cs index 1f25591..dea2416 100644 --- a/CodeWalker.Core/GameFiles/Resources/Bounds.cs +++ b/CodeWalker.Core/GameFiles/Resources/Bounds.cs @@ -53,9 +53,7 @@ namespace CodeWalker.GameFiles public uint Unknown_14h { get; set; } // 0x00000001 public uint Unknown_18h { get; set; } // 0x00000001 public uint Unknown_1Ch { get; set; } // 0x00000001 - //public ResourceSimpleList64 BoundNameHashes; - public ResourceSimpleList64Ptr BoundNameHashesPtr { get; set; } - public uint[] BoundNameHashes { get; set; } + public ResourceSimpleList64_uint BoundNameHashes; public ResourcePointerList64 Bounds { get; set; } /// @@ -70,9 +68,7 @@ namespace CodeWalker.GameFiles this.Unknown_14h = reader.ReadUInt32(); this.Unknown_18h = reader.ReadUInt32(); this.Unknown_1Ch = reader.ReadUInt32(); - //this.BoundNameHashes = reader.ReadBlock>(); - this.BoundNameHashesPtr = reader.ReadStruct(); - this.BoundNameHashes = reader.ReadUintsAt(this.BoundNameHashesPtr.EntriesPointer, this.BoundNameHashesPtr.EntriesCount); + this.BoundNameHashes = reader.ReadBlock(); this.Bounds = reader.ReadBlock>(); } @@ -88,14 +84,14 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_14h); writer.Write(this.Unknown_18h); writer.Write(this.Unknown_1Ch); - //writer.WriteBlock(this.BoundNameHashes); //TODO: fix! - //writer.WriteBlock(this.Bounds); + writer.WriteBlock(this.BoundNameHashes); + writer.WriteBlock(this.Bounds); } public override Tuple[] GetParts() { return new Tuple[] { - //new Tuple(0x20, BoundNameHashes), //TODO: fix! + new Tuple(0x20, BoundNameHashes), new Tuple(0x30, Bounds) }; } @@ -196,16 +192,16 @@ namespace CodeWalker.GameFiles writer.Write(this.BoundingSphereRadius); writer.Write(this.Unknown_18h); writer.Write(this.Unknown_1Ch); - //writer.WriteBlock(this.BoundingBoxMax); //TODO: FIX!! + writer.Write(this.BoundingBoxMax); writer.Write(this.Margin); - //writer.WriteBlock(this.BoundingBoxMin); + writer.Write(this.BoundingBoxMin); writer.Write(this.Unknown_3Ch); - //writer.WriteBlock(this.BoundingBoxCenter); + writer.Write(this.BoundingBoxCenter); writer.Write(this.MaterialIndex); writer.Write(this.ProceduralId); writer.Write(this.RoomId_and_PedDensity); writer.Write(this.Unknown_4Fh); - //writer.WriteBlock(this.Center); + writer.Write(this.Center); writer.Write(this.PolyFlags); writer.Write(this.MaterialColorIndex); writer.Write(this.Unknown_5Eh); @@ -329,9 +325,7 @@ namespace CodeWalker.GameFiles public BoundVertex_s[] p1data { get; set; } - public BoundPolygon[] Polygons { get; set; } - public Vector3[] Vertices { get; set; } public uint[] Unknown_B8h_Data { get; set; } public uint[] Unknown_C0h_Data { get; set; } @@ -408,10 +402,9 @@ namespace CodeWalker.GameFiles if (this.Unknown_C0h_Data != null) { - ulong[] ptrlist = reader.ReadUlongsAt(this.Unknown_C8h_Pointer, (uint)Unknown_C0h_Data.Length);//8 - //reader.Position += Unknown_C0h_Data.Length * 8; //account for ptrlist read - Unknown_C8h_Data = new uint[Unknown_C0h_Data.Length][]; //8 - for (int i = 0; i < Unknown_C0h_Data.Length; i++) //8 + ulong[] ptrlist = reader.ReadUlongsAt(this.Unknown_C8h_Pointer, 8);//(uint)Unknown_C0h_Data.Length + Unknown_C8h_Data = new uint[8][]; //Unknown_C0h_Data.Length + for (int i = 0; i < 8; i++) //Unknown_C0h_Data.Length { Unknown_C8h_Data[i] = reader.ReadUintsAt(ptrlist[i], Unknown_C0h_Data[i]); } @@ -1091,9 +1084,10 @@ namespace CodeWalker.GameFiles } // structure data - public ulong NodesPointer { get; set; } - public uint NodesCount { get; set; } - public uint Count2 { get; set; } + //public ulong NodesPointer { get; set; } + //public uint NodesCount { get; set; } + //public uint Count2 { get; set; } + public ResourceSimpleList64b_s Nodes { get; set; } public uint Unknown_10h { get; set; } // 0x00000000 public uint Unknown_14h { get; set; } // 0x00000000 public uint Unknown_18h { get; set; } // 0x00000000 @@ -1103,14 +1097,12 @@ namespace CodeWalker.GameFiles public Vector4 BoundingBoxCenter { get; set; } public Vector4 QuantumInverse { get; set; } public Vector4 Quantum { get; set; } // bounding box dimension / 2^16 - //public ResourceSimpleList64 Trees { get; set; } - public ResourceSimpleList64Ptr TreesPtr { get; set; } - public BVHTreeInfo_s[] Trees { get; set; } + public ResourceSimpleList64_s Trees { get; set; } // reference data - //public ResourceSimpleArray2 Nodes; - public BVHNode_s[] Nodes { get; set; } - public BVHNode_s[] Nodes_Unk1 { get; set; } + ////public ResourceSimpleArray2 Nodes; + //public BVHNode_s[] Nodes { get; set; } + //public BVHNode_s[] Nodes_Unk1 { get; set; } /// /// Reads the data-block from a stream. @@ -1118,40 +1110,34 @@ namespace CodeWalker.GameFiles public override void Read(ResourceDataReader reader, params object[] parameters) { // read structure data - this.NodesPointer = reader.ReadUInt64(); - this.NodesCount = reader.ReadUInt32(); - this.Count2 = reader.ReadUInt32(); + //this.NodesPointer = reader.ReadUInt64(); + //this.NodesCount = reader.ReadUInt32(); + //this.Count2 = reader.ReadUInt32(); + this.Nodes = reader.ReadBlock>(); this.Unknown_10h = reader.ReadUInt32(); this.Unknown_14h = reader.ReadUInt32(); this.Unknown_18h = reader.ReadUInt32(); this.Unknown_1Ch = reader.ReadUInt32(); - //this.BoundingBoxMin = reader.ReadBlock(); - //this.BoundingBoxMax = reader.ReadBlock(); - //this.BoundingBoxCenter = reader.ReadBlock(); - //this.QuantumInverse = reader.ReadBlock(); - //this.Quantum = reader.ReadBlock(); this.BoundingBoxMin = reader.ReadStruct(); this.BoundingBoxMax = reader.ReadStruct(); this.BoundingBoxCenter = reader.ReadStruct(); this.QuantumInverse = reader.ReadStruct(); this.Quantum = reader.ReadStruct(); - //this.Trees = reader.ReadBlock>(); - this.TreesPtr = reader.ReadStruct(); - this.Trees = reader.ReadStructsAt(this.TreesPtr.EntriesPointer, this.TreesPtr.EntriesCount); + this.Trees = reader.ReadBlock>(); // read reference data - //this.Nodes = reader.ReadBlockAt>( - // this.NodesPointer, // offset - // this.NodesCount, - // this.Count2 - this.NodesCount - //); - - this.Nodes = reader.ReadStructsAt(this.NodesPointer, this.NodesCount); - - this.Nodes_Unk1 = reader.ReadStructsAt(this.NodesPointer + NodesCount * 16 /*sizeof(BVHNode_s)*/, Count2 - NodesCount); + ////this.Nodes = reader.ReadBlockAt>( + //// this.NodesPointer, // offset + //// this.NodesCount, + //// this.Count2 - this.NodesCount + ////); + //this.Nodes = reader.ReadStructsAt(this.NodesPointer, this.NodesCount); + //this.Nodes_Unk1 = reader.ReadStructsAt(this.NodesPointer + NodesCount * 16 /*sizeof(BVHNode_s)*/, Count2 - NodesCount); + //if (Nodes_Unk1 != null) + //{ } } /// @@ -1166,19 +1152,20 @@ namespace CodeWalker.GameFiles //TODO: fix // write structure data - writer.Write(this.NodesPointer); - writer.Write(this.NodesCount); - writer.Write(this.Count2); + //writer.Write(this.NodesPointer); + //writer.Write(this.NodesCount); + //writer.Write(this.Count2); + writer.WriteBlock(this.Nodes); writer.Write(this.Unknown_10h); writer.Write(this.Unknown_14h); writer.Write(this.Unknown_18h); writer.Write(this.Unknown_1Ch); - //writer.WriteBlock(this.BoundingBoxMin); - //writer.WriteBlock(this.BoundingBoxMax); - //writer.WriteBlock(this.BoundingBoxCenter); - //writer.WriteBlock(this.QuantumInverse); - //writer.WriteBlock(this.Quantum); - //writer.WriteBlock(this.Trees); //TODO: fix + writer.Write(this.BoundingBoxMin); + writer.Write(this.BoundingBoxMax); + writer.Write(this.BoundingBoxCenter); + writer.Write(this.QuantumInverse); + writer.Write(this.Quantum); + writer.WriteBlock(this.Trees); } /// @@ -1195,12 +1182,13 @@ namespace CodeWalker.GameFiles public override Tuple[] GetParts() { return new Tuple[] { + new Tuple(0x0, Nodes), //new Tuple(0x20, BoundingBoxMin), //new Tuple(0x30, BoundingBoxMax), //new Tuple(0x40, BoundingBoxCenter), //new Tuple(0x50, QuantumInverse), //new Tuple(0x60, Quantum), - //new Tuple(0x70, Trees) //TODO: fix! + new Tuple(0x70, Trees) }; } } diff --git a/CodeWalker.Core/GameFiles/Resources/Clip.cs b/CodeWalker.Core/GameFiles/Resources/Clip.cs index 67bc2e1..ba392b3 100644 --- a/CodeWalker.Core/GameFiles/Resources/Clip.cs +++ b/CodeWalker.Core/GameFiles/Resources/Clip.cs @@ -291,9 +291,9 @@ namespace CodeWalker.GameFiles public uint Unknown_38h { get; set; } public uint Unknown_3Ch { get; set; } public ResourcePointerList64 Sequences { get; set; } - //public ResourceSimpleList64 Unknown_50h { get; set; } - public ResourceSimpleList64Ptr BoneIdsPtr { get; set; } - public AnimationBoneId[] BoneIds { get; set; } + public ResourceSimpleList64_s BoneIds { get; set; } + //public ResourceSimpleList64Ptr BoneIdsPtr { get; set; } + //public AnimationBoneId[] BoneIds { get; set; } public YcdFile Ycd { get; set; } @@ -323,10 +323,10 @@ namespace CodeWalker.GameFiles this.Unknown_38h = reader.ReadUInt32(); //314 174 1238 390 sequences length? this.Unknown_3Ch = reader.ReadUInt32(); //2 2 2 2 material/type? this.Sequences = reader.ReadBlock>(); - //this.Unknown_50h = reader.ReadBlock>(); - this.BoneIdsPtr = reader.ReadStruct(); - //this.BoneIds = reader.ReadUintsAt(this.BoneIdsPtr.EntriesPointer, this.BoneIdsPtr.EntriesCount); - this.BoneIds = reader.ReadStructsAt(this.BoneIdsPtr.EntriesPointer, this.BoneIdsPtr.EntriesCount); + this.BoneIds = reader.ReadBlock>(); + //this.BoneIdsPtr = reader.ReadStruct(); + ////this.BoneIds = reader.ReadUintsAt(this.BoneIdsPtr.EntriesPointer, this.BoneIdsPtr.EntriesCount); + //this.BoneIds = reader.ReadStructsAt(this.BoneIdsPtr.EntriesPointer, this.BoneIdsPtr.EntriesCount); } public override void Write(ResourceDataWriter writer, params object[] parameters) @@ -352,14 +352,14 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_38h); writer.Write(this.Unknown_3Ch); writer.WriteBlock(this.Sequences); - //writer.WriteBlock(this.Unknown_50h);//todo: fix!! + writer.WriteBlock(this.BoneIds); } public override Tuple[] GetParts() { return new Tuple[] { new Tuple(0x40, Sequences), - //new Tuple(0x50, Unknown_50h)//todo: fix! + new Tuple(0x50, BoneIds) }; } } diff --git a/CodeWalker.Core/GameFiles/Resources/Drawable.cs b/CodeWalker.Core/GameFiles/Resources/Drawable.cs index 72acf0b..32f945a 100644 --- a/CodeWalker.Core/GameFiles/Resources/Drawable.cs +++ b/CodeWalker.Core/GameFiles/Resources/Drawable.cs @@ -2345,18 +2345,13 @@ namespace CodeWalker.GameFiles // structure data public ulong NamePointer { get; set; } - public ulong LightAttributesPointer { get; set; } - public ushort LightAttributesCount1 { get; set; } - public ushort LightAttributesCount2 { get; set; } - public uint Unknown_BCh { get; set; } // 0x00000000 + public ResourceSimpleList64_s LightAttributes { get; set; } public uint Unknown_C0h { get; set; } // 0x00000000 public uint Unknown_C4h { get; set; } // 0x00000000 public ulong BoundPointer { get; set; } // reference data public string Name { get; set; } - //public ResourceSimpleArray LightAttributes { get; set; } - public LightAttributes_s[] LightAttributes { get; set; } public Bounds Bound { get; set; } public string ErrorMessage { get; set; } @@ -2370,10 +2365,7 @@ namespace CodeWalker.GameFiles // read structure data this.NamePointer = reader.ReadUInt64(); - this.LightAttributesPointer = reader.ReadUInt64(); - this.LightAttributesCount1 = reader.ReadUInt16(); - this.LightAttributesCount2 = reader.ReadUInt16(); - this.Unknown_BCh = reader.ReadUInt32(); + this.LightAttributes = reader.ReadBlock>(); this.Unknown_C0h = reader.ReadUInt32(); this.Unknown_C4h = reader.ReadUInt32(); this.BoundPointer = reader.ReadUInt64(); @@ -2385,11 +2377,6 @@ namespace CodeWalker.GameFiles this.Name = reader.ReadStringAt(//BlockAt( this.NamePointer // offset ); - //this.LightAttributes = reader.ReadBlockAt>( - // this.LightAttributesPointer, // offset - // this.LightAttributesCount1 - //); - this.LightAttributes = reader.ReadStructsAt(this.LightAttributesPointer, this.LightAttributesCount1); this.Bound = reader.ReadBlockAt( this.BoundPointer // offset @@ -2410,16 +2397,11 @@ namespace CodeWalker.GameFiles // update structure data //this.NamePointer = (ulong)(this.Name != null ? this.Name.Position : 0); //TODO: fix - //this.LightAttributesPointer = (ulong)(this.LightAttributes != null ? this.LightAttributes.Position : 0); this.BoundPointer = (ulong)(this.Bound != null ? this.Bound.FilePosition : 0); - //TODO: fix // write structure data writer.Write(this.NamePointer); - writer.Write(this.LightAttributesPointer); - writer.Write(this.LightAttributesCount1); - writer.Write(this.LightAttributesCount2); - writer.Write(this.Unknown_BCh); + writer.WriteBlock(this.LightAttributes); writer.Write(this.Unknown_C0h); writer.Write(this.Unknown_C4h); writer.Write(this.BoundPointer); @@ -2432,10 +2414,15 @@ namespace CodeWalker.GameFiles { var list = new List(base.GetReferences()); //if (Name != null) list.Add(Name); //TODO: fix - //if (LightAttributes != null) list.Add(LightAttributes); //TODO: fix if (Bound != null) list.Add(Bound); return list.ToArray(); } + public override Tuple[] GetParts() + { + return new Tuple[] { + new Tuple(0xB0, LightAttributes), + }; + } public override string ToString() diff --git a/CodeWalker.Core/GameFiles/Resources/Frag.cs b/CodeWalker.Core/GameFiles/Resources/Frag.cs index afab44f..e6fd88a 100644 --- a/CodeWalker.Core/GameFiles/Resources/Frag.cs +++ b/CodeWalker.Core/GameFiles/Resources/Frag.cs @@ -101,9 +101,9 @@ namespace CodeWalker.GameFiles public uint Unknown_104h { get; set; } // 0x00000000 public uint Unknown_108h { get; set; } // 0x00000000 public uint Unknown_10Ch { get; set; } // 0x00000000 - //public ResourceSimpleList64 LightAttributes { get; set; } - public ResourceSimpleList64Ptr LightAttributesPtr { get; set; } - public LightAttributes_s[] LightAttributes { get; set; } + public ResourceSimpleList64_s LightAttributes { get; set; } + //public ResourceSimpleList64Ptr LightAttributesPtr { get; set; } + //public LightAttributes_s[] LightAttributes { get; set; } public ulong Unknown_120h_Pointer { get; set; } public uint Unknown_128h { get; set; } // 0x00000000 public uint Unknown_12Ch { get; set; } // 0x00000000 @@ -182,9 +182,7 @@ namespace CodeWalker.GameFiles this.Unknown_104h = reader.ReadUInt32(); this.Unknown_108h = reader.ReadUInt32(); this.Unknown_10Ch = reader.ReadUInt32(); - //this.LightAttributes = reader.ReadBlock>(); - this.LightAttributesPtr = reader.ReadStruct(); - this.LightAttributes = reader.ReadStructsAt(LightAttributesPtr.EntriesPointer, LightAttributesPtr.EntriesCount); + this.LightAttributes = reader.ReadBlock>(); this.Unknown_120h_Pointer = reader.ReadUInt64(); this.Unknown_128h = reader.ReadUInt32(); this.Unknown_12Ch = reader.ReadUInt32(); @@ -276,15 +274,13 @@ namespace CodeWalker.GameFiles this.DrawablePointer = (ulong)(this.Drawable != null ? this.Drawable.FilePosition : 0); this.Unknown_28h_Pointer = (ulong)(this.Unknown_28h_Data != null ? this.Unknown_28h_Data.FilePosition : 0); this.Unknown_30h_Pointer = (ulong)(this.Unknown_30h_Data != null ? this.Unknown_30h_Data.FilePosition : 0); - //this.cc00 = (uint)(this.pxxxxx_0data != null ? this.pxxxxx_0data.Count : 0); + this.Count0 = (uint)(this.Unknown_28h_Data != null ? this.Unknown_28h_Data.Count : 0); ////this.NamePointer = (ulong)(this.Name != null ? this.Name.Position : 0); //TODO: fix!!! - //this.cnt1 = (ushort)(this.pxxxxx_2data != null ? this.pxxxxx_2data.Count : 0); this.Unknown_A8h_Pointer = (ulong)(this.Unknown_A8h_Data != null ? this.Unknown_A8h_Data.FilePosition : 0); - //this.anotherCount = (byte)(this.pxxxxx_3data != null ? this.pxxxxx_3data.Count : 0); + this.Count3 = (byte)(this.Unknown_E0h_Data != null ? this.Unknown_E0h_Data.Count : 0); this.Unknown_E0h_Pointer = (ulong)(this.Unknown_E0h_Data != null ? this.Unknown_E0h_Data.FilePosition : 0); this.PhysicsLODGroupPointer = (ulong)(this.PhysicsLODGroup != null ? this.PhysicsLODGroup.FilePosition : 0); this.Drawable2Pointer = (ulong)(this.Drawable2 != null ? this.Drawable2.FilePosition : 0); - //this.cntxx51a = (ushort)(this.pxxxxx_5data != null ? this.pxxxxx_5data.Count : 0); this.Unknown_120h_Pointer = (ulong)(this.Unknown_120h_Data != null ? this.Unknown_120h_Data.FilePosition : 0); // write structure data @@ -343,7 +339,7 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_104h); writer.Write(this.Unknown_108h); writer.Write(this.Unknown_10Ch); - //writer.WriteBlock(this.LightAttributes); //TODO: fix! + writer.WriteBlock(this.LightAttributes); writer.Write(this.Unknown_120h_Pointer); writer.Write(this.Unknown_128h); writer.Write(this.Unknown_12Ch); @@ -371,7 +367,7 @@ namespace CodeWalker.GameFiles { return new Tuple[] { new Tuple(0x60, Clothes), - //new Tuple(0x110, LightAttributes) //TODO: fix! + new Tuple(0x110, LightAttributes) }; } } @@ -777,63 +773,37 @@ namespace CodeWalker.GameFiles public uint Unknown_14h { get; set; } public uint Unknown_18h { get; set; } public uint Unknown_1Ch { get; set; } // 0x00000000 - //public ResourceSimpleList64 Unknown_20h { get; set; } - //public ResourceSimpleList64 Unknown_30h { get; set; } - //public ResourceSimpleList64 Unknown_40h { get; set; } - public ResourceSimpleList64Ptr Unknown_20hPtr { get; set; } - public ResourceSimpleList64Ptr Unknown_30hPtr { get; set; } - public ResourceSimpleList64Ptr Unknown_40hPtr { get; set; } - public float[] Unknown_20h { get; set; } - public float[] Unknown_30h { get; set; } - public float[] Unknown_40h { get; set; } + public ResourceSimpleList64_float Unknown_20h { get; set; } + public ResourceSimpleList64_float Unknown_30h { get; set; } + public ResourceSimpleList64_float Unknown_40h { get; set; } public uint Unknown_50h { get; set; } // 0x00000000 public uint Unknown_54h { get; set; } // 0x00000000 public uint Unknown_58h { get; set; } // 0x00000000 public uint Unknown_5Ch { get; set; } // 0x00000000 - //public ResourceSimpleList64 Unknown_60h { get; set; } - //public ResourceSimpleList64 Unknown_70h { get; set; } - //public ResourceSimpleList64 Unknown_80h { get; set; } - public ResourceSimpleList64Ptr Unknown_60hPtr { get; set; } - public ResourceSimpleList64Ptr Unknown_70hPtr { get; set; } - public ResourceSimpleList64Ptr Unknown_80hPtr { get; set; } - public float[] Unknown_60h { get; set; } - public uint[] Unknown_70h { get; set; } - public uint[] Unknown_80h { get; set; } + public ResourceSimpleList64_float Unknown_60h { get; set; } + public ResourceSimpleList64_uint Unknown_70h { get; set; } + public ResourceSimpleList64_uint Unknown_80h { get; set; } public uint Unknown_90h { get; set; } // 0x00000000 public uint Unknown_94h { get; set; } // 0x00000000 public uint Unknown_98h { get; set; } // 0x00000000 public uint Unknown_9Ch { get; set; } // 0x00000000 - //public ResourceSimpleList64 Unknown_A0h { get; set; } - //public ResourceSimpleList64 Unknown_B0h { get; set; } - //public ResourceSimpleList64 Unknown_C0h { get; set; } - public ResourceSimpleList64Ptr Unknown_A0hPtr { get; set; } - public ResourceSimpleList64Ptr Unknown_B0hPtr { get; set; } - public ResourceSimpleList64Ptr Unknown_C0hPtr { get; set; } - public float[] Unknown_A0h { get; set; } - public uint[] Unknown_B0h { get; set; } - public uint[] Unknown_C0h { get; set; } + public ResourceSimpleList64_float Unknown_A0h { get; set; } + public ResourceSimpleList64_uint Unknown_B0h { get; set; } + public ResourceSimpleList64_uint Unknown_C0h { get; set; } public uint Unknown_D0h { get; set; } // 0x00000000 public uint Unknown_D4h { get; set; } // 0x00000000 public uint Unknown_D8h { get; set; } // 0x00000000 public uint Unknown_DCh { get; set; } // 0x00000000 - //public ResourceSimpleList64 Unknown_E0h { get; set; } - //public ResourceSimpleList64 Unknown_F0h { get; set; } - //public ResourceSimpleList64 Unknown_100h { get; set; } - public ResourceSimpleList64Ptr Unknown_E0hPtr { get; set; } - public ResourceSimpleList64Ptr Unknown_F0hPtr { get; set; } - public ResourceSimpleList64Ptr Unknown_100hPtr { get; set; } - public ushort[] Unknown_E0h { get; set; } - public ushort[] Unknown_F0h { get; set; } - public ushort[] Unknown_100h { get; set; } + public ResourceSimpleList64_ushort Unknown_E0h { get; set; } + public ResourceSimpleList64_ushort Unknown_F0h { get; set; } + public ResourceSimpleList64_ushort Unknown_100h { get; set; } public uint Unknown_110h { get; set; } // 0x00000000 public uint Unknown_114h { get; set; } // 0x00000000 public uint Unknown_118h { get; set; } // 0x00000000 public uint Unknown_11Ch { get; set; } // 0x00000000 public uint Unknown_120h { get; set; } // 0x00000000 public uint Unknown_124h { get; set; } // 0x00000000 - //public ResourceSimpleList64 Unknown_128h { get; set; } - public ResourceSimpleList64Ptr Unknown_128hPtr { get; set; } - public uint[] Unknown_128h { get; set; } + public ResourceSimpleList64_uint Unknown_128h { get; set; } public uint Unknown_138h { get; set; } // 0x00000000 public uint Unknown_13Ch { get; set; } // 0x00000000 @@ -851,50 +821,37 @@ namespace CodeWalker.GameFiles this.Unknown_14h = reader.ReadUInt32(); this.Unknown_18h = reader.ReadUInt32(); this.Unknown_1Ch = reader.ReadUInt32(); - this.Unknown_20hPtr = reader.ReadStruct(); - this.Unknown_30hPtr = reader.ReadStruct(); - this.Unknown_40hPtr = reader.ReadStruct(); - this.Unknown_20h = reader.ReadFloatsAt(Unknown_20hPtr.EntriesPointer, Unknown_20hPtr.EntriesCount); - this.Unknown_30h = reader.ReadFloatsAt(Unknown_30hPtr.EntriesPointer, Unknown_30hPtr.EntriesCount); - this.Unknown_40h = reader.ReadFloatsAt(Unknown_40hPtr.EntriesPointer, Unknown_40hPtr.EntriesCount); + this.Unknown_20h = reader.ReadBlock(); + this.Unknown_30h = reader.ReadBlock(); + this.Unknown_40h = reader.ReadBlock(); this.Unknown_50h = reader.ReadUInt32(); this.Unknown_54h = reader.ReadUInt32(); this.Unknown_58h = reader.ReadUInt32(); this.Unknown_5Ch = reader.ReadUInt32(); - this.Unknown_60hPtr = reader.ReadStruct(); - this.Unknown_70hPtr = reader.ReadStruct(); - this.Unknown_80hPtr = reader.ReadStruct(); - this.Unknown_60h = reader.ReadFloatsAt(Unknown_60hPtr.EntriesPointer, Unknown_60hPtr.EntriesCount); - this.Unknown_70h = reader.ReadUintsAt(Unknown_70hPtr.EntriesPointer, Unknown_70hPtr.EntriesCount); - this.Unknown_80h = reader.ReadUintsAt(Unknown_80hPtr.EntriesPointer, Unknown_80hPtr.EntriesCount); + this.Unknown_60h = reader.ReadBlock(); + this.Unknown_70h = reader.ReadBlock(); + this.Unknown_80h = reader.ReadBlock(); this.Unknown_90h = reader.ReadUInt32(); this.Unknown_94h = reader.ReadUInt32(); this.Unknown_98h = reader.ReadUInt32(); this.Unknown_9Ch = reader.ReadUInt32(); - this.Unknown_A0hPtr = reader.ReadStruct(); - this.Unknown_B0hPtr = reader.ReadStruct(); - this.Unknown_C0hPtr = reader.ReadStruct(); - this.Unknown_A0h = reader.ReadFloatsAt(Unknown_A0hPtr.EntriesPointer, Unknown_A0hPtr.EntriesCount); - this.Unknown_B0h = reader.ReadUintsAt(Unknown_B0hPtr.EntriesPointer, Unknown_B0hPtr.EntriesCount); - this.Unknown_C0h = reader.ReadUintsAt(Unknown_C0hPtr.EntriesPointer, Unknown_C0hPtr.EntriesCount); + this.Unknown_A0h = reader.ReadBlock(); + this.Unknown_B0h = reader.ReadBlock(); + this.Unknown_C0h = reader.ReadBlock(); this.Unknown_D0h = reader.ReadUInt32(); this.Unknown_D4h = reader.ReadUInt32(); this.Unknown_D8h = reader.ReadUInt32(); this.Unknown_DCh = reader.ReadUInt32(); - this.Unknown_E0hPtr = reader.ReadStruct(); - this.Unknown_F0hPtr = reader.ReadStruct(); - this.Unknown_100hPtr = reader.ReadStruct(); - this.Unknown_E0h = reader.ReadUshortsAt(Unknown_E0hPtr.EntriesPointer, Unknown_E0hPtr.EntriesCount); - this.Unknown_F0h = reader.ReadUshortsAt(Unknown_F0hPtr.EntriesPointer, Unknown_F0hPtr.EntriesCount); - this.Unknown_100h = reader.ReadUshortsAt(Unknown_100hPtr.EntriesPointer, Unknown_100hPtr.EntriesCount); + this.Unknown_E0h = reader.ReadBlock(); + this.Unknown_F0h = reader.ReadBlock(); + this.Unknown_100h = reader.ReadBlock(); this.Unknown_110h = reader.ReadUInt32(); this.Unknown_114h = reader.ReadUInt32(); this.Unknown_118h = reader.ReadUInt32(); this.Unknown_11Ch = reader.ReadUInt32(); this.Unknown_120h = reader.ReadUInt32(); this.Unknown_124h = reader.ReadUInt32(); - this.Unknown_128hPtr = reader.ReadStruct(); - this.Unknown_128h = reader.ReadUintsAt(Unknown_128hPtr.EntriesPointer, Unknown_128hPtr.EntriesCount); + this.Unknown_128h = reader.ReadBlock(); this.Unknown_138h = reader.ReadUInt32(); this.Unknown_13Ch = reader.ReadUInt32(); } @@ -913,37 +870,37 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_14h); writer.Write(this.Unknown_18h); writer.Write(this.Unknown_1Ch); - //writer.WriteBlock(this.Unknown_20h); //TODO: fix! - //writer.WriteBlock(this.Unknown_30h); - //writer.WriteBlock(this.Unknown_40h); + writer.WriteBlock(this.Unknown_20h); + writer.WriteBlock(this.Unknown_30h); + writer.WriteBlock(this.Unknown_40h); writer.Write(this.Unknown_50h); writer.Write(this.Unknown_54h); writer.Write(this.Unknown_58h); writer.Write(this.Unknown_5Ch); - //writer.WriteBlock(this.Unknown_60h); - //writer.WriteBlock(this.Unknown_70h); - //writer.WriteBlock(this.Unknown_80h); + writer.WriteBlock(this.Unknown_60h); + writer.WriteBlock(this.Unknown_70h); + writer.WriteBlock(this.Unknown_80h); writer.Write(this.Unknown_90h); writer.Write(this.Unknown_94h); writer.Write(this.Unknown_98h); writer.Write(this.Unknown_9Ch); - //writer.WriteBlock(this.Unknown_A0h); - //writer.WriteBlock(this.Unknown_B0h); - //writer.WriteBlock(this.Unknown_C0h); + writer.WriteBlock(this.Unknown_A0h); + writer.WriteBlock(this.Unknown_B0h); + writer.WriteBlock(this.Unknown_C0h); writer.Write(this.Unknown_D0h); writer.Write(this.Unknown_D4h); writer.Write(this.Unknown_D8h); writer.Write(this.Unknown_DCh); - //writer.WriteBlock(this.Unknown_E0h); - //writer.WriteBlock(this.Unknown_F0h); - //writer.WriteBlock(this.Unknown_100h); + writer.WriteBlock(this.Unknown_E0h); + writer.WriteBlock(this.Unknown_F0h); + writer.WriteBlock(this.Unknown_100h); writer.Write(this.Unknown_110h); writer.Write(this.Unknown_114h); writer.Write(this.Unknown_118h); writer.Write(this.Unknown_11Ch); writer.Write(this.Unknown_120h); writer.Write(this.Unknown_124h); - //writer.WriteBlock(this.Unknown_128h); + writer.WriteBlock(this.Unknown_128h); writer.Write(this.Unknown_138h); writer.Write(this.Unknown_13Ch); } @@ -951,19 +908,19 @@ namespace CodeWalker.GameFiles public override Tuple[] GetParts() { return new Tuple[] { - //new Tuple(0x20, Unknown_20h), //TODO: fix! - //new Tuple(0x30, Unknown_30h), - //new Tuple(0x40, Unknown_40h), - //new Tuple(0x60, Unknown_60h), - //new Tuple(0x70, Unknown_70h), - //new Tuple(0x80, Unknown_80h), - //new Tuple(0xA0, Unknown_A0h), - //new Tuple(0xB0, Unknown_B0h), - //new Tuple(0xC0, Unknown_C0h), - //new Tuple(0xE0, Unknown_E0h), - //new Tuple(0xF0, Unknown_F0h), - //new Tuple(0x100, Unknown_100h), - //new Tuple(0x128, Unknown_128h) + new Tuple(0x20, Unknown_20h), + new Tuple(0x30, Unknown_30h), + new Tuple(0x40, Unknown_40h), + new Tuple(0x60, Unknown_60h), + new Tuple(0x70, Unknown_70h), + new Tuple(0x80, Unknown_80h), + new Tuple(0xA0, Unknown_A0h), + new Tuple(0xB0, Unknown_B0h), + new Tuple(0xC0, Unknown_C0h), + new Tuple(0xE0, Unknown_E0h), + new Tuple(0xF0, Unknown_F0h), + new Tuple(0x100, Unknown_100h), + new Tuple(0x128, Unknown_128h) }; } } @@ -1092,36 +1049,16 @@ namespace CodeWalker.GameFiles public uint Unknown_44h { get; set; } // 0x00000000 public uint Unknown_48h { get; set; } // 0x00000000 public uint Unknown_4Ch { get; set; } // 0x00000000 - //public ResourceSimpleList64 Unknown_50h { get; set; } - //public ResourceSimpleList64 Unknown_60h { get; set; } - //public ResourceSimpleList64 Unknown_70h { get; set; } - //public ResourceSimpleList64 Unknown_80h { get; set; } - //public ResourceSimpleList64 Unknown_90h { get; set; } - //public ResourceSimpleList64 Unknown_A0h { get; set; } - //public ResourceSimpleList64 Unknown_B0h { get; set; } - //public ResourceSimpleList64 Unknown_C0h { get; set; } - //public ResourceSimpleList64 Unknown_D0h { get; set; } - //public ResourceSimpleList64 Unknown_E0h { get; set; } - public ResourceSimpleList64Ptr Unknown_50hPtr { get; set; } - public ResourceSimpleList64Ptr Unknown_60hPtr { get; set; } - public ResourceSimpleList64Ptr Unknown_70hPtr { get; set; } - public ResourceSimpleList64Ptr Unknown_80hPtr { get; set; } - public ResourceSimpleList64Ptr Unknown_90hPtr { get; set; } - public ResourceSimpleList64Ptr Unknown_A0hPtr { get; set; } - public ResourceSimpleList64Ptr Unknown_B0hPtr { get; set; } - public ResourceSimpleList64Ptr Unknown_C0hPtr { get; set; } - public ResourceSimpleList64Ptr Unknown_D0hPtr { get; set; } - public ResourceSimpleList64Ptr Unknown_E0hPtr { get; set; } - public Vector4[] Unknown_50h { get; set; } - public ushort[] Unknown_60h { get; set; } - public ushort[] Unknown_70h { get; set; } - public ushort[] Unknown_80h { get; set; } - public ushort[] Unknown_90h { get; set; } - public Vector4[] Unknown_A0h { get; set; } - public ushort[] Unknown_B0h { get; set; } - public ushort[] Unknown_C0h { get; set; } - public ushort[] Unknown_D0h { get; set; } - public ushort[] Unknown_E0h { get; set; } + public ResourceSimpleList64_s Unknown_50h { get; set; } + public ResourceSimpleList64_ushort Unknown_60h { get; set; } + public ResourceSimpleList64_ushort Unknown_70h { get; set; } + public ResourceSimpleList64_ushort Unknown_80h { get; set; } + public ResourceSimpleList64_ushort Unknown_90h { get; set; } + public ResourceSimpleList64_s Unknown_A0h { get; set; } + public ResourceSimpleList64_ushort Unknown_B0h { get; set; } + public ResourceSimpleList64_ushort Unknown_C0h { get; set; } + public ResourceSimpleList64_ushort Unknown_D0h { get; set; } + public ResourceSimpleList64_ushort Unknown_E0h { get; set; } public uint Unknown_F0h { get; set; } // 0x00000000 public uint Unknown_F4h { get; set; } // 0x00000000 public uint Unknown_F8h { get; set; } // 0x00000000 @@ -1146,12 +1083,8 @@ namespace CodeWalker.GameFiles public uint Unknown_144h { get; set; } // 0x00000000 public uint Unknown_148h { get; set; } // 0x00000000 public uint Unknown_14Ch { get; set; } // 0x00000000 - //public ResourceSimpleList64 Unknown_150h { get; set; } - //public ResourceSimpleList64 Unknown_160h { get; set; } - public ResourceSimpleList64Ptr Unknown_150hPtr { get; set; } - public ResourceSimpleList64Ptr Unknown_160hPtr { get; set; } - public ushort[] Unknown_150h { get; set; } - public ushort[] Unknown_160h { get; set; } + public ResourceSimpleList64_ushort Unknown_150h { get; set; } + public ResourceSimpleList64_ushort Unknown_160h { get; set; } public uint Unknown_170h { get; set; } // 0x00000000 public uint Unknown_174h { get; set; } // 0x00000000 public uint Unknown_178h { get; set; } // 0x00000000 @@ -1187,36 +1120,16 @@ namespace CodeWalker.GameFiles this.Unknown_44h = reader.ReadUInt32(); this.Unknown_48h = reader.ReadUInt32(); this.Unknown_4Ch = reader.ReadUInt32(); - //this.Unknown_50h = reader.ReadBlock>(); - //this.Unknown_60h = reader.ReadBlock>(); - //this.Unknown_70h = reader.ReadBlock>(); - //this.Unknown_80h = reader.ReadBlock>(); - //this.Unknown_90h = reader.ReadBlock>(); - //this.Unknown_A0h = reader.ReadBlock>(); - //this.Unknown_B0h = reader.ReadBlock>(); - //this.Unknown_C0h = reader.ReadBlock>(); - //this.Unknown_D0h = reader.ReadBlock>(); - //this.Unknown_E0h = reader.ReadBlock>(); - this.Unknown_50hPtr = reader.ReadStruct(); - this.Unknown_60hPtr = reader.ReadStruct(); - this.Unknown_70hPtr = reader.ReadStruct(); - this.Unknown_80hPtr = reader.ReadStruct(); - this.Unknown_90hPtr = reader.ReadStruct(); - this.Unknown_A0hPtr = reader.ReadStruct(); - this.Unknown_B0hPtr = reader.ReadStruct(); - this.Unknown_C0hPtr = reader.ReadStruct(); - this.Unknown_D0hPtr = reader.ReadStruct(); - this.Unknown_E0hPtr = reader.ReadStruct(); - this.Unknown_50h = reader.ReadStructsAt(Unknown_50hPtr.EntriesPointer, Unknown_50hPtr.EntriesCount); - this.Unknown_60h = reader.ReadUshortsAt(Unknown_60hPtr.EntriesPointer, Unknown_60hPtr.EntriesCount); - this.Unknown_70h = reader.ReadUshortsAt(Unknown_70hPtr.EntriesPointer, Unknown_70hPtr.EntriesCount); - this.Unknown_80h = reader.ReadUshortsAt(Unknown_80hPtr.EntriesPointer, Unknown_80hPtr.EntriesCount); - this.Unknown_90h = reader.ReadUshortsAt(Unknown_90hPtr.EntriesPointer, Unknown_90hPtr.EntriesCount); - this.Unknown_A0h = reader.ReadStructsAt(Unknown_A0hPtr.EntriesPointer, Unknown_A0hPtr.EntriesCount); - this.Unknown_B0h = reader.ReadUshortsAt(Unknown_B0hPtr.EntriesPointer, Unknown_B0hPtr.EntriesCount); - this.Unknown_C0h = reader.ReadUshortsAt(Unknown_C0hPtr.EntriesPointer, Unknown_C0hPtr.EntriesCount); - this.Unknown_D0h = reader.ReadUshortsAt(Unknown_D0hPtr.EntriesPointer, Unknown_D0hPtr.EntriesCount); - this.Unknown_E0h = reader.ReadUshortsAt(Unknown_E0hPtr.EntriesPointer, Unknown_E0hPtr.EntriesCount); + this.Unknown_50h = reader.ReadBlock>(); + this.Unknown_60h = reader.ReadBlock(); + this.Unknown_70h = reader.ReadBlock(); + this.Unknown_80h = reader.ReadBlock(); + this.Unknown_90h = reader.ReadBlock(); + this.Unknown_A0h = reader.ReadBlock>(); + this.Unknown_B0h = reader.ReadBlock(); + this.Unknown_C0h = reader.ReadBlock(); + this.Unknown_D0h = reader.ReadBlock(); + this.Unknown_E0h = reader.ReadBlock(); this.Unknown_F0h = reader.ReadUInt32(); this.Unknown_F4h = reader.ReadUInt32(); this.Unknown_F8h = reader.ReadUInt32(); @@ -1241,12 +1154,8 @@ namespace CodeWalker.GameFiles this.Unknown_144h = reader.ReadUInt32(); this.Unknown_148h = reader.ReadUInt32(); this.Unknown_14Ch = reader.ReadUInt32(); - //this.Unknown_150h = reader.ReadBlock>(); - //this.Unknown_160h = reader.ReadBlock>(); - this.Unknown_150hPtr = reader.ReadStruct(); - this.Unknown_160hPtr = reader.ReadStruct(); - this.Unknown_150h = reader.ReadUshortsAt(Unknown_150hPtr.EntriesPointer, Unknown_150hPtr.EntriesCount); - this.Unknown_160h = reader.ReadUshortsAt(Unknown_160hPtr.EntriesPointer, Unknown_160hPtr.EntriesCount); + this.Unknown_150h = reader.ReadBlock(); + this.Unknown_160h = reader.ReadBlock(); this.Unknown_170h = reader.ReadUInt32(); this.Unknown_174h = reader.ReadUInt32(); this.Unknown_178h = reader.ReadUInt32(); @@ -1283,16 +1192,16 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_44h); writer.Write(this.Unknown_48h); writer.Write(this.Unknown_4Ch); - //writer.WriteBlock(this.Unknown_50h); //TODO: fix this! - //writer.WriteBlock(this.Unknown_60h); - //writer.WriteBlock(this.Unknown_70h); - //writer.WriteBlock(this.Unknown_80h); - //writer.WriteBlock(this.Unknown_90h); - //writer.WriteBlock(this.Unknown_A0h); - //writer.WriteBlock(this.Unknown_B0h); - //writer.WriteBlock(this.Unknown_C0h); - //writer.WriteBlock(this.Unknown_D0h); - //writer.WriteBlock(this.Unknown_E0h); + writer.WriteBlock(this.Unknown_50h); + writer.WriteBlock(this.Unknown_60h); + writer.WriteBlock(this.Unknown_70h); + writer.WriteBlock(this.Unknown_80h); + writer.WriteBlock(this.Unknown_90h); + writer.WriteBlock(this.Unknown_A0h); + writer.WriteBlock(this.Unknown_B0h); + writer.WriteBlock(this.Unknown_C0h); + writer.WriteBlock(this.Unknown_D0h); + writer.WriteBlock(this.Unknown_E0h); writer.Write(this.Unknown_F0h); writer.Write(this.Unknown_F4h); writer.Write(this.Unknown_F8h); @@ -1317,8 +1226,8 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_144h); writer.Write(this.Unknown_148h); writer.Write(this.Unknown_14Ch); - //writer.WriteBlock(this.Unknown_150h); //TODO: fix - //writer.WriteBlock(this.Unknown_160h); + writer.WriteBlock(this.Unknown_150h); + writer.WriteBlock(this.Unknown_160h); writer.Write(this.Unknown_170h); writer.Write(this.Unknown_174h); writer.Write(this.Unknown_178h); @@ -1332,18 +1241,18 @@ namespace CodeWalker.GameFiles public override Tuple[] GetParts() { return new Tuple[] { - //new Tuple(0x50, Unknown_50h), //TODO: fix this - //new Tuple(0x60, Unknown_60h), - //new Tuple(0x70, Unknown_70h), - //new Tuple(0x80, Unknown_80h), - //new Tuple(0x90, Unknown_90h), - //new Tuple(0xA0, Unknown_A0h), - //new Tuple(0xB0, Unknown_B0h), - //new Tuple(0xC0, Unknown_C0h), - //new Tuple(0xD0, Unknown_D0h), - //new Tuple(0xE0, Unknown_E0h), - //new Tuple(0x150, Unknown_150h), - //new Tuple(0x160, Unknown_160h) + new Tuple(0x50, Unknown_50h), + new Tuple(0x60, Unknown_60h), + new Tuple(0x70, Unknown_70h), + new Tuple(0x80, Unknown_80h), + new Tuple(0x90, Unknown_90h), + new Tuple(0xA0, Unknown_A0h), + new Tuple(0xB0, Unknown_B0h), + new Tuple(0xC0, Unknown_C0h), + new Tuple(0xD0, Unknown_D0h), + new Tuple(0xE0, Unknown_E0h), + new Tuple(0x150, Unknown_150h), + new Tuple(0x160, Unknown_160h) }; } } @@ -1382,15 +1291,8 @@ namespace CodeWalker.GameFiles public uint Unknown_64h { get; set; } // 0x00000000 public uint Unknown_68h { get; set; } // 0x00000000 public uint Unknown_6Ch { get; set; } // 0x00000000 - public ResourceSimpleList64Ptr Unknown_70hPtr { get; set; } - public Vector4[] Unknown_70h { get; set; } - //public uint Unknown_70h { get; set; } // 0x00000000 - //public uint Unknown_74h { get; set; } // 0x00000000 - //public uint Unknown_78h { get; set; } // 0x00000000 - //public uint Unknown_7Ch { get; set; } // 0x00000000 - //public ResourceSimpleList64 Unknown_80h { get; set; } - public ResourceSimpleList64Ptr Unknown_80hPtr { get; set; } - public Vector4[] Unknown_80h { get; set; } + public ResourceSimpleList64_s Unknown_70h { get; set; } + public ResourceSimpleList64_s Unknown_80h { get; set; } public uint Unknown_90h { get; set; } // 0x00000000 public uint Unknown_94h { get; set; } // 0x00000000 public uint Unknown_98h { get; set; } // 0x00000000 @@ -1419,12 +1321,8 @@ namespace CodeWalker.GameFiles public uint Unknown_F4h { get; set; } // 0x00000000 public uint Unknown_F8h { get; set; } public uint Unknown_FCh { get; set; } // 0x00000000 - //public ResourceSimpleList64 Unknown_100h { get; set; } - //public ResourceSimpleList64 Unknown_110h { get; set; } - public ResourceSimpleList64Ptr Unknown_100hPtr { get; set; } - public ResourceSimpleList64Ptr Unknown_110hPtr { get; set; } - public Vector4[] Unknown_100h { get; set; } - public Vector4[] Unknown_110h { get; set; } + public ResourceSimpleList64_s Unknown_100h { get; set; } + public ResourceSimpleList64_s Unknown_110h { get; set; } public uint Unknown_120h { get; set; } // 0x00000000 public uint Unknown_124h { get; set; } // 0x00000000 public uint Unknown_128h { get; set; } // 0x00000000 @@ -1486,15 +1384,8 @@ namespace CodeWalker.GameFiles this.Unknown_64h = reader.ReadUInt32(); this.Unknown_68h = reader.ReadUInt32(); this.Unknown_6Ch = reader.ReadUInt32(); - this.Unknown_70hPtr = reader.ReadStruct(); - this.Unknown_70h = reader.ReadStructsAt(Unknown_70hPtr.EntriesPointer, Unknown_70hPtr.EntriesCount); - //this.Unknown_70h = reader.ReadUInt32(); - //this.Unknown_74h = reader.ReadUInt32(); - //this.Unknown_78h = reader.ReadUInt32(); - //this.Unknown_7Ch = reader.ReadUInt32(); - //this.Unknown_80h = reader.ReadBlock>(); - this.Unknown_80hPtr = reader.ReadStruct(); - this.Unknown_80h = reader.ReadStructsAt(Unknown_80hPtr.EntriesPointer, Unknown_80hPtr.EntriesCount); + this.Unknown_70h = reader.ReadBlock>(); + this.Unknown_80h = reader.ReadBlock>(); this.Unknown_90h = reader.ReadUInt32(); this.Unknown_94h = reader.ReadUInt32(); this.Unknown_98h = reader.ReadUInt32(); @@ -1523,12 +1414,8 @@ namespace CodeWalker.GameFiles this.Unknown_F4h = reader.ReadUInt32(); this.Unknown_F8h = reader.ReadUInt32(); this.Unknown_FCh = reader.ReadUInt32(); - //this.Unknown_100h = reader.ReadBlock>(); - //this.Unknown_110h = reader.ReadBlock>(); - this.Unknown_100hPtr = reader.ReadStruct(); - this.Unknown_110hPtr = reader.ReadStruct(); - this.Unknown_100h = reader.ReadStructsAt(Unknown_100hPtr.EntriesPointer, Unknown_100hPtr.EntriesCount); - this.Unknown_110h = reader.ReadStructsAt(Unknown_110hPtr.EntriesPointer, Unknown_110hPtr.EntriesCount); + this.Unknown_100h = reader.ReadBlock>(); + this.Unknown_110h = reader.ReadBlock>(); this.Unknown_120h = reader.ReadUInt32(); this.Unknown_124h = reader.ReadUInt32(); this.Unknown_128h = reader.ReadUInt32(); @@ -1602,11 +1489,8 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_64h); writer.Write(this.Unknown_68h); writer.Write(this.Unknown_6Ch); - //writer.Write(this.Unknown_70h); - //writer.Write(this.Unknown_74h); - //writer.Write(this.Unknown_78h); - //writer.Write(this.Unknown_7Ch); - //writer.WriteBlock(this.Unknown_80h); //TODO: fix + writer.WriteBlock(this.Unknown_70h); + writer.WriteBlock(this.Unknown_80h); writer.Write(this.Unknown_90h); writer.Write(this.Unknown_94h); writer.Write(this.Unknown_98h); @@ -1635,8 +1519,8 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_F4h); writer.Write(this.Unknown_F8h); writer.Write(this.Unknown_FCh); - //writer.WriteBlock(this.Unknown_100h); //TODO: fix - //writer.WriteBlock(this.Unknown_110h); + writer.WriteBlock(this.Unknown_100h); + writer.WriteBlock(this.Unknown_110h); writer.Write(this.Unknown_120h); writer.Write(this.Unknown_124h); writer.Write(this.Unknown_128h); @@ -1676,9 +1560,10 @@ namespace CodeWalker.GameFiles public override Tuple[] GetParts() { return new Tuple[] { - //new Tuple(0x80, Unknown_80h), //TODO: fix - //new Tuple(0x100, Unknown_100h), - //new Tuple(0x110, Unknown_110h) + new Tuple(0x70, Unknown_70h), + new Tuple(0x80, Unknown_80h), + new Tuple(0x100, Unknown_100h), + new Tuple(0x110, Unknown_110h) }; } } diff --git a/CodeWalker.Core/GameFiles/Resources/Particle.cs b/CodeWalker.Core/GameFiles/Resources/Particle.cs index 37a0bef..421ebe4 100644 --- a/CodeWalker.Core/GameFiles/Resources/Particle.cs +++ b/CodeWalker.Core/GameFiles/Resources/Particle.cs @@ -116,12 +116,12 @@ namespace CodeWalker.GameFiles base.Write(writer, parameters); // update structure data - //this.NamePointer = (ulong)(this.Name != null ? this.Name.Position : 0);//TODO: fix?! - //this.TextureDictionaryPointer = (ulong)(this.TextureDictionary != null ? this.TextureDictionary.Position : 0); - //this.DrawableDictionaryPointer = (ulong)(this.DrawableDictionary != null ? this.DrawableDictionary.Position : 0); - //this.ParticleRuleDictionaryPointer = (ulong)(this.ParticleRuleDictionary != null ? this.ParticleRuleDictionary.Position : 0); - //this.EmitterRuleDictionaryPointer = (ulong)(this.EffectRuleDictionary != null ? this.EffectRuleDictionary.Position : 0); - //this.EffectRuleDictionaryPointer = (ulong)(this.EmitterRuleDictionary != null ? this.EmitterRuleDictionary.Position : 0); + this.NamePointer = (ulong)(this.Name != null ? this.Name.FilePosition : 0); + this.TextureDictionaryPointer = (ulong)(this.TextureDictionary != null ? this.TextureDictionary.FilePosition : 0); + this.DrawableDictionaryPointer = (ulong)(this.DrawableDictionary != null ? this.DrawableDictionary.FilePosition : 0); + this.ParticleRuleDictionaryPointer = (ulong)(this.ParticleRuleDictionary != null ? this.ParticleRuleDictionary.FilePosition : 0); + this.EmitterRuleDictionaryPointer = (ulong)(this.EffectRuleDictionary != null ? this.EffectRuleDictionary.FilePosition : 0); + this.EffectRuleDictionaryPointer = (ulong)(this.EmitterRuleDictionary != null ? this.EmitterRuleDictionary.FilePosition : 0); // write structure data writer.Write(this.NamePointer); @@ -142,13 +142,13 @@ namespace CodeWalker.GameFiles public override IResourceBlock[] GetReferences() { - var list = new List(base.GetReferences()); //TODO: fix!! - //if (Name != null) list.Add(Name); - //if (TextureDictionary != null) list.Add(TextureDictionary); - //if (DrawableDictionary != null) list.Add(DrawableDictionary); - //if (ParticleRuleDictionary != null) list.Add(ParticleRuleDictionary); - //if (EffectRuleDictionary != null) list.Add(EffectRuleDictionary); - //if (EmitterRuleDictionary != null) list.Add(EmitterRuleDictionary); + var list = new List(base.GetReferences()); + if (Name != null) list.Add(Name); + if (TextureDictionary != null) list.Add(TextureDictionary); + if (DrawableDictionary != null) list.Add(DrawableDictionary); + if (ParticleRuleDictionary != null) list.Add(ParticleRuleDictionary); + if (EffectRuleDictionary != null) list.Add(EffectRuleDictionary); + if (EmitterRuleDictionary != null) list.Add(EmitterRuleDictionary); return list.ToArray(); } } @@ -350,10 +350,12 @@ namespace CodeWalker.GameFiles public override void Write(ResourceDataWriter writer, params object[] parameters) { // update structure data - //this.HashesPointer = (ulong)(this.Hashes != null ? this.Hashes.Position : 0); - ////this.HashesCount1 = (ushort)(this.Hashes != null ? this.Hashes.Count : 0); - //this.EffectRulesPointer = (ulong)(this.EmitterRules != null ? this.EmitterRules.Position : 0); - ////this.EffectRulesCount1 = (ushort)(this.EffectRules != null ? this.EffectRules.Count : 0); + this.HashesPointer = (ulong)(this.Hashes != null ? this.Hashes.FilePosition : 0); + this.HashesCount1 = (ushort)(this.Hashes != null ? this.Hashes.Count : 0); + this.HashesCount2 = this.HashesCount1; + this.EffectRulesPointer = (ulong)(this.EmitterRules != null ? this.EmitterRules.FilePosition : 0); + this.EffectRulesCount1 = (ushort)(this.EmitterRules != null ? this.EmitterRules.Count : 0); + this.EffectRulesCount2 = this.EffectRulesCount1; // write structure data writer.Write(this.VFT); @@ -548,10 +550,10 @@ namespace CodeWalker.GameFiles public override void Write(ResourceDataWriter writer, params object[] parameters) { - //// update structure data //TODO: fix! - //this.NamePointer = (ulong)(this.Name != null ? this.Name.Position : 0); - //this.p9 = (ulong)(this.p9data != null ? this.p9data.Position : 0); - //this.p10 = (ulong)(this.p10data != null ? this.p10data.Position : 0); + // update structure data + this.NamePointer = (ulong)(this.Name != null ? this.Name.FilePosition : 0); + this.p9 = (ulong)(this.p9data != null ? this.p9data.FilePosition : 0); + this.p10 = (ulong)(this.p10data != null ? this.p10data.FilePosition : 0); // write structure data writer.Write(this.VFT); @@ -622,9 +624,9 @@ namespace CodeWalker.GameFiles public override IResourceBlock[] GetReferences() { var list = new List(); - //if (Name != null) list.Add(Name); - //if (p9data != null) list.Add(p9data); - //if (p10data != null) list.Add(p10data); + if (Name != null) list.Add(Name); + if (p9data != null) list.Add(p9data); + if (p10data != null) list.Add(p10data); return list.ToArray(); } @@ -732,9 +734,9 @@ namespace CodeWalker.GameFiles /// public override void Write(ResourceDataWriter writer, params object[] parameters) { - // update structure data //TODO: fix!! - //this.EmitterRulePointer = (ulong)(this.EmitterRule != null ? this.EmitterRule.Position : 0); - //this.p1 = (ulong)(this.p1data != null ? this.p1data.Position : 0); + // update structure data + this.EmitterRulePointer = (ulong)(this.EmitterRule != null ? this.EmitterRule.FilePosition : 0); + this.p1 = (ulong)(this.p1data != null ? this.p1data.FilePosition : 0); // write structure data writer.Write(this.VFT); @@ -943,13 +945,13 @@ namespace CodeWalker.GameFiles public override void Write(ResourceDataWriter writer, params object[] parameters) { - //// update structure data - //this.NamePointer = (ulong)(this.Name != null ? this.Name.Position : 0); - //this.EventEmittersPointer = (ulong)(this.EventEmitters != null ? this.EventEmitters.Position : 0); - ////this.c3b = (ushort)(this.p3data != null ? this.p3data.Count : 0); - //this.p4 = (ulong)(this.p4data != null ? this.p4data.Position : 0); - //this.KeyframePropsPointer = (ulong)(this.KeyframeProps != null ? this.KeyframeProps.Position : 0); - ////this.refcnt2 = (ushort)(this.refs != null ? this.refs.Count : 0); + // update structure data + this.NamePointer = (ulong)(this.Name != null ? this.Name.FilePosition : 0); + this.EventEmittersPointer = (ulong)(this.EventEmitters != null ? this.EventEmitters.FilePosition : 0); + //this.c3b = (ushort)(this.p3data != null ? this.p3data.Count : 0); + this.p4 = (ulong)(this.p4data != null ? this.p4data.FilePosition : 0); + this.KeyframePropsPointer = (ulong)(this.KeyframeProps != null ? this.KeyframeProps.FilePosition : 0); + //this.refcnt2 = (ushort)(this.refs != null ? this.refs.Count : 0); // write structure data writer.Write(this.VFT); @@ -1020,10 +1022,10 @@ namespace CodeWalker.GameFiles public override IResourceBlock[] GetReferences() { var list = new List(); - //if (Name != null) list.Add(Name); - //if (EventEmitters != null) list.Add(EventEmitters); - //if (p4data != null) list.Add(p4data); - //if (KeyframeProps != null) list.Add(KeyframeProps); + if (Name != null) list.Add(Name); + if (EventEmitters != null) list.Add(EventEmitters); + if (p4data != null) list.Add(p4data); + if (KeyframeProps != null) list.Add(KeyframeProps); return list.ToArray(); } @@ -1302,11 +1304,11 @@ namespace CodeWalker.GameFiles public override void Write(ResourceDataWriter writer, params object[] parameters) { // update structure data - //this.p1 = (ulong)(this.p1data != null ? this.p1data.Position : 0); - //this.p2 = (ulong)(this.p2data != null ? this.p2data.Position : 0); - //this.p3 = (ulong)(this.p3data != null ? this.p3data.Position : 0); - //this.p4 = (ulong)(this.EmitterRule != null ? this.EmitterRule.Position : 0); - //this.p5 = (ulong)(this.ParticleRule != null ? this.ParticleRule.Position : 0); + this.p1 = (ulong)(this.p1data != null ? this.p1data.FilePosition : 0); + this.p2 = (ulong)(this.p2data != null ? this.p2data.FilePosition : 0); + this.p3 = (ulong)(this.p3data != null ? this.p3data.FilePosition : 0); + this.p4 = (ulong)(this.EmitterRule != null ? this.EmitterRule.FilePosition : 0); + this.p5 = (ulong)(this.ParticleRule != null ? this.ParticleRule.FilePosition : 0); // write structure data writer.Write(this.VFT); @@ -1337,11 +1339,11 @@ namespace CodeWalker.GameFiles public override IResourceBlock[] GetReferences() { var list = new List(); - //if (p1data != null) list.Add(p1data); - //if (p2data != null) list.Add(p2data); - //if (p3data != null) list.Add(p3data); - //if (EmitterRule != null) list.Add(EmitterRule); - //if (ParticleRule != null) list.Add(ParticleRule); + if (p1data != null) list.Add(p1data); + if (p2data != null) list.Add(p2data); + if (p3data != null) list.Add(p3data); + if (EmitterRule != null) list.Add(EmitterRule); + if (ParticleRule != null) list.Add(ParticleRule); return list.ToArray(); } } @@ -1426,7 +1428,7 @@ namespace CodeWalker.GameFiles public override void Write(ResourceDataWriter writer, params object[] parameters) { // update structure data - //this.p1 = (ulong)(this.p1data != null ? this.p1data.Position : 0); + this.p1 = (ulong)(this.p1data != null ? this.p1data.FilePosition : 0); // write structure data writer.Write(this.p1); @@ -1597,7 +1599,7 @@ namespace CodeWalker.GameFiles public override void Write(ResourceDataWriter writer, params object[] parameters) { // update structure data - //this.Unknown_8h_Pointer = (ulong)(this.Unknown_8h_Data != null ? this.Unknown_8h_Data.Position : 0); + this.Unknown_8h_Pointer = (ulong)(this.Unknown_8h_Data != null ? this.Unknown_8h_Data.FilePosition : 0); // write structure data writer.Write(this.Unknown_0h); @@ -1741,12 +1743,12 @@ namespace CodeWalker.GameFiles public override void Write(ResourceDataWriter writer, params object[] parameters) { // update structure data - //this.NamePointer = (ulong)(this.Name != null ? this.Name.Position : 0); - //this.p2 = (ulong)(this.p2data != null ? this.p2data.Position : 0); - //this.p3 = (ulong)(this.p3data != null ? this.p3data.Position : 0); - //this.p4 = (ulong)(this.p4data != null ? this.p4data.Position : 0); - //this.KeyframePropsPointer = (ulong)(this.KeyframeProps != null ? this.KeyframeProps.Position : 0); - ////this.refcnt2 = (ushort)(this.refs != null ? this.refs.Count : 0); + this.NamePointer = (ulong)(this.Name != null ? this.Name.FilePosition : 0); + this.p2 = (ulong)(this.p2data != null ? this.p2data.FilePosition : 0); + this.p3 = (ulong)(this.p3data != null ? this.p3data.FilePosition : 0); + this.p4 = (ulong)(this.p4data != null ? this.p4data.FilePosition : 0); + this.KeyframePropsPointer = (ulong)(this.KeyframeProps != null ? this.KeyframeProps.FilePosition : 0); + //this.refcnt2 = (ushort)(this.refs != null ? this.refs.Count : 0); // write structure data writer.Write(this.VFT); @@ -1796,11 +1798,11 @@ namespace CodeWalker.GameFiles public override IResourceBlock[] GetReferences() { var list = new List(); - //if (Name != null) list.Add(Name); - //if (p2data != null) list.Add(p2data); - //if (p3data != null) list.Add(p3data); - //if (p4data != null) list.Add(p4data); - //if (KeyframeProps != null) list.Add(KeyframeProps); + if (Name != null) list.Add(Name); + if (p2data != null) list.Add(p2data); + if (p3data != null) list.Add(p3data); + if (p4data != null) list.Add(p4data); + if (KeyframeProps != null) list.Add(KeyframeProps); return list.ToArray(); } @@ -2027,7 +2029,7 @@ namespace CodeWalker.GameFiles public override void Write(ResourceDataWriter writer, params object[] parameters) { // update structure data - ////this.p1 = (ulong)(this.p1data != null ? this.p1data.Position : 0); + this.p1 = (ulong)(this.p1data != null ? this.p1data.FilePosition : 0); // write structure data writer.Write(this.p1); @@ -2073,7 +2075,7 @@ namespace CodeWalker.GameFiles public override void Write(ResourceDataWriter writer, params object[] parameters) { // update structure data - ////this.p1 = (ulong)(this.p1data != null ? this.p1data.Position : 0); + this.p1 = (ulong)(this.p1data != null ? this.p1data.FilePosition : 0); // write structure data writer.Write(this.Unknown_0h); @@ -4074,8 +4076,8 @@ namespace CodeWalker.GameFiles base.Write(writer, parameters); // update structure data - //this.TexturePointer = (ulong)(this.Texture != null ? this.Texture.Position : 0); - //this.NamePointer = (ulong)(this.Name != null ? this.Name.Position : 0); + this.TexturePointer = (ulong)(this.Texture != null ? this.Texture.FilePosition : 0); + this.NamePointer = (ulong)(this.Name != null ? this.Name.FilePosition : 0); // write structure data writer.Write(this.Unknown_18h); @@ -4091,8 +4093,8 @@ namespace CodeWalker.GameFiles public override IResourceBlock[] GetReferences() { var list = new List(base.GetReferences()); - //if (Texture != null) list.Add(Texture); - //if (Name != null) list.Add(Name); + if (Texture != null) list.Add(Texture); + if (Name != null) list.Add(Name); return list.ToArray(); } } @@ -4248,9 +4250,9 @@ namespace CodeWalker.GameFiles public override void Write(ResourceDataWriter writer, params object[] parameters) { - //// update structure data - //this.Unknown_10h_Pointer = (ulong)(this.Unknown_10h_Data != null ? this.Unknown_10h_Data.Position : 0); - //this.DrawablePointer = (ulong)(this.Drawable != null ? this.Drawable.Position : 0); + // update structure data + this.Unknown_10h_Pointer = (ulong)(this.Unknown_10h_Data != null ? this.Unknown_10h_Data.FilePosition : 0); + this.DrawablePointer = (ulong)(this.Drawable != null ? this.Drawable.FilePosition : 0); // write structure data writer.Write(this.Unknown_0h); diff --git a/CodeWalker.Core/GameFiles/Resources/ResourceBaseTypes.cs b/CodeWalker.Core/GameFiles/Resources/ResourceBaseTypes.cs index dabe245..8712c4a 100644 --- a/CodeWalker.Core/GameFiles/Resources/ResourceBaseTypes.cs +++ b/CodeWalker.Core/GameFiles/Resources/ResourceBaseTypes.cs @@ -658,6 +658,9 @@ namespace CodeWalker.GameFiles //public ResourceSimpleArray Entries; public T[] data_items { get; private set; } + private ResourceSimpleArray data_block;//used for saving. + + /// /// Reads the data-block from a stream. /// @@ -693,9 +696,9 @@ namespace CodeWalker.GameFiles public override void Write(ResourceDataWriter writer, params object[] parameters) { // update structure data //TODO: fix - //this.EntriesPointer = (ulong)(this.Entries != null ? this.Entries.Position : 0); - //this.EntriesCount = (ushort)(this.Entries != null ? this.Entries.Count : 0); - //this.EntriesCapacity = (ushort)(this.Entries != null ? this.Entries.Count : 0); + this.EntriesPointer = (ulong)(this.data_block != null ? this.data_block.FilePosition : 0); + this.EntriesCount = (ushort)(this.data_block != null ? this.data_block.Count : 0); + this.EntriesCapacity = (ushort)(this.data_block != null ? this.data_block.Count : 0); // write structure data writer.Write(this.EntriesPointer); @@ -711,6 +714,518 @@ namespace CodeWalker.GameFiles { var list = new List(); //if (Entries != null) list.Add(Entries); + + data_block = new ResourceSimpleArray(); + data_block.Data = new List(); + data_block.Data.AddRange(data_items); + list.Add(data_block); + + return list.ToArray(); + } + + public override string ToString() + { + return "(Count: " + EntriesCount.ToString() + ")"; + } + } + [TypeConverter(typeof(ExpandableObjectConverter))] public class ResourceSimpleList64_s : ResourceSystemBlock where T : struct + { + public override long BlockLength + { + get { return 16; } + } + + // structure data + public ulong EntriesPointer { get; private set; } + public ushort EntriesCount { get; private set; } + public ushort EntriesCapacity { get; private set; } + + // reference data + public T[] data_items { get; private set; } + + private ResourceSystemStructBlock data_block;//used for saving. + + + /// + /// Reads the data-block from a stream. + /// + public override void Read(ResourceDataReader reader, params object[] parameters) + { + // read structure data + this.EntriesPointer = reader.ReadUInt64(); + this.EntriesCount = reader.ReadUInt16(); + this.EntriesCapacity = reader.ReadUInt16(); + reader.Position += 4; + + // read reference data + + //TODO: NEEDS TO BE TESTED!!! + data_items = reader.ReadStructsAt(EntriesPointer, EntriesCount); + } + + /// + /// Writes the data-block to a stream. + /// + public override void Write(ResourceDataWriter writer, params object[] parameters) + { + // update structure data //TODO: fix + this.EntriesPointer = (ulong)(this.data_block != null ? this.data_block.FilePosition : 0); + this.EntriesCount = (ushort)(this.data_block != null ? this.data_block.ItemCount : 0); + this.EntriesCapacity = (ushort)(this.data_block != null ? this.data_block.ItemCount : 0); + + // write structure data + writer.Write(this.EntriesPointer); + writer.Write(this.EntriesCount); + writer.Write(this.EntriesCapacity); + writer.Write((uint)0x00000000); + } + + /// + /// Returns a list of data blocks which are referenced by this block. + /// + public override IResourceBlock[] GetReferences() + { + var list = new List(); + //if (Entries != null) list.Add(Entries); + + data_block = new ResourceSystemStructBlock(data_items); + + list.Add(data_block); + + return list.ToArray(); + } + + public override string ToString() + { + return "(Count: " + EntriesCount.ToString() + ")"; + } + } + [TypeConverter(typeof(ExpandableObjectConverter))] public class ResourceSimpleList64b_s : ResourceSystemBlock where T : struct + { + //this version uses uints for the count/cap! + + public override long BlockLength + { + get { return 16; } + } + + // structure data + public ulong EntriesPointer { get; private set; } + public uint EntriesCount { get; private set; } + public uint EntriesCapacity { get; private set; } + + // reference data + public T[] data_items { get; private set; } + + private ResourceSystemStructBlock data_block;//used for saving. + + + /// + /// Reads the data-block from a stream. + /// + public override void Read(ResourceDataReader reader, params object[] parameters) + { + // read structure data + this.EntriesPointer = reader.ReadUInt64(); + this.EntriesCount = reader.ReadUInt32(); + this.EntriesCapacity = reader.ReadUInt32(); + //reader.Position += 4; + + // read reference data + + //TODO: NEEDS TO BE TESTED!!! + data_items = reader.ReadStructsAt(EntriesPointer, EntriesCount); + } + + /// + /// Writes the data-block to a stream. + /// + public override void Write(ResourceDataWriter writer, params object[] parameters) + { + // update structure data //TODO: fix + this.EntriesPointer = (ulong)(this.data_block != null ? this.data_block.FilePosition : 0); + this.EntriesCount = (ushort)(this.data_block != null ? this.data_block.ItemCount : 0); + this.EntriesCapacity = (ushort)(this.data_block != null ? this.data_block.ItemCount : 0); + + // write structure data + writer.Write(this.EntriesPointer); + writer.Write(this.EntriesCount); + writer.Write(this.EntriesCapacity); + //writer.Write((uint)0x00000000); + } + + /// + /// Returns a list of data blocks which are referenced by this block. + /// + public override IResourceBlock[] GetReferences() + { + var list = new List(); + //if (Entries != null) list.Add(Entries); + + data_block = new ResourceSystemStructBlock(data_items); + + list.Add(data_block); + + return list.ToArray(); + } + + public override string ToString() + { + return "(Count: " + EntriesCount.ToString() + ")"; + } + } + [TypeConverter(typeof(ExpandableObjectConverter))] public class ResourceSimpleList64_byte : ResourceSystemBlock + { + public override long BlockLength + { + get { return 16; } + } + + // structure data + public ulong EntriesPointer { get; private set; } + public ushort EntriesCount { get; private set; } + public ushort EntriesCapacity { get; private set; } + + // reference data + public byte[] data_items { get; private set; } + + private ResourceSystemStructBlock data_block;//used for saving. + + + /// + /// Reads the data-block from a stream. + /// + public override void Read(ResourceDataReader reader, params object[] parameters) + { + // read structure data + this.EntriesPointer = reader.ReadUInt64(); + this.EntriesCount = reader.ReadUInt16(); + this.EntriesCapacity = reader.ReadUInt16(); + reader.Position += 4; + + // read reference data + + //TODO: NEEDS TO BE TESTED!!! + data_items = reader.ReadBytesAt(EntriesPointer, EntriesCount); + } + + /// + /// Writes the data-block to a stream. + /// + public override void Write(ResourceDataWriter writer, params object[] parameters) + { + // update structure data //TODO: fix + this.EntriesPointer = (ulong)(this.data_block != null ? this.data_block.FilePosition : 0); + this.EntriesCount = (ushort)(this.data_block != null ? this.data_block.ItemCount : 0); + this.EntriesCapacity = (ushort)(this.data_block != null ? this.data_block.ItemCount : 0); + + // write structure data + writer.Write(this.EntriesPointer); + writer.Write(this.EntriesCount); + writer.Write(this.EntriesCapacity); + writer.Write((uint)0x00000000); + } + + /// + /// Returns a list of data blocks which are referenced by this block. + /// + public override IResourceBlock[] GetReferences() + { + var list = new List(); + //if (Entries != null) list.Add(Entries); + + data_block = new ResourceSystemStructBlock(data_items); + + list.Add(data_block); + + return list.ToArray(); + } + + public override string ToString() + { + return "(Count: " + EntriesCount.ToString() + ")"; + } + } + [TypeConverter(typeof(ExpandableObjectConverter))] public class ResourceSimpleList64_ushort : ResourceSystemBlock + { + public override long BlockLength + { + get { return 16; } + } + + // structure data + public ulong EntriesPointer { get; private set; } + public ushort EntriesCount { get; private set; } + public ushort EntriesCapacity { get; private set; } + + // reference data + public ushort[] data_items { get; private set; } + + private ResourceSystemStructBlock data_block;//used for saving. + + + /// + /// Reads the data-block from a stream. + /// + public override void Read(ResourceDataReader reader, params object[] parameters) + { + // read structure data + this.EntriesPointer = reader.ReadUInt64(); + this.EntriesCount = reader.ReadUInt16(); + this.EntriesCapacity = reader.ReadUInt16(); + reader.Position += 4; + + // read reference data + + //TODO: NEEDS TO BE TESTED!!! + data_items = reader.ReadUshortsAt(EntriesPointer, EntriesCount); + } + + /// + /// Writes the data-block to a stream. + /// + public override void Write(ResourceDataWriter writer, params object[] parameters) + { + // update structure data //TODO: fix + this.EntriesPointer = (ulong)(this.data_block != null ? this.data_block.FilePosition : 0); + this.EntriesCount = (ushort)(this.data_block != null ? this.data_block.ItemCount : 0); + this.EntriesCapacity = (ushort)(this.data_block != null ? this.data_block.ItemCount : 0); + + // write structure data + writer.Write(this.EntriesPointer); + writer.Write(this.EntriesCount); + writer.Write(this.EntriesCapacity); + writer.Write((uint)0x00000000); + } + + /// + /// Returns a list of data blocks which are referenced by this block. + /// + public override IResourceBlock[] GetReferences() + { + var list = new List(); + //if (Entries != null) list.Add(Entries); + + data_block = new ResourceSystemStructBlock(data_items); + + list.Add(data_block); + + return list.ToArray(); + } + + public override string ToString() + { + return "(Count: " + EntriesCount.ToString() + ")"; + } + } + [TypeConverter(typeof(ExpandableObjectConverter))] public class ResourceSimpleList64_uint : ResourceSystemBlock + { + public override long BlockLength + { + get { return 16; } + } + + // structure data + public ulong EntriesPointer { get; private set; } + public ushort EntriesCount { get; private set; } + public ushort EntriesCapacity { get; private set; } + + // reference data + public uint[] data_items { get; private set; } + + private ResourceSystemStructBlock data_block;//used for saving. + + + /// + /// Reads the data-block from a stream. + /// + public override void Read(ResourceDataReader reader, params object[] parameters) + { + // read structure data + this.EntriesPointer = reader.ReadUInt64(); + this.EntriesCount = reader.ReadUInt16(); + this.EntriesCapacity = reader.ReadUInt16(); + reader.Position += 4; + + // read reference data + + //TODO: NEEDS TO BE TESTED!!! + data_items = reader.ReadUintsAt(EntriesPointer, EntriesCount); + } + + /// + /// Writes the data-block to a stream. + /// + public override void Write(ResourceDataWriter writer, params object[] parameters) + { + // update structure data //TODO: fix + this.EntriesPointer = (ulong)(this.data_block != null ? this.data_block.FilePosition : 0); + this.EntriesCount = (ushort)(this.data_block != null ? this.data_block.ItemCount : 0); + this.EntriesCapacity = (ushort)(this.data_block != null ? this.data_block.ItemCount : 0); + + // write structure data + writer.Write(this.EntriesPointer); + writer.Write(this.EntriesCount); + writer.Write(this.EntriesCapacity); + writer.Write((uint)0x00000000); + } + + /// + /// Returns a list of data blocks which are referenced by this block. + /// + public override IResourceBlock[] GetReferences() + { + var list = new List(); + //if (Entries != null) list.Add(Entries); + + data_block = new ResourceSystemStructBlock(data_items); + + list.Add(data_block); + + return list.ToArray(); + } + + public override string ToString() + { + return "(Count: " + EntriesCount.ToString() + ")"; + } + } + [TypeConverter(typeof(ExpandableObjectConverter))] public class ResourceSimpleList64_ulong : ResourceSystemBlock + { + public override long BlockLength + { + get { return 16; } + } + + // structure data + public ulong EntriesPointer { get; private set; } + public ushort EntriesCount { get; private set; } + public ushort EntriesCapacity { get; private set; } + + // reference data + public ulong[] data_items { get; private set; } + + private ResourceSystemStructBlock data_block;//used for saving. + + + /// + /// Reads the data-block from a stream. + /// + public override void Read(ResourceDataReader reader, params object[] parameters) + { + // read structure data + this.EntriesPointer = reader.ReadUInt64(); + this.EntriesCount = reader.ReadUInt16(); + this.EntriesCapacity = reader.ReadUInt16(); + reader.Position += 4; + + // read reference data + + //TODO: NEEDS TO BE TESTED!!! + data_items = reader.ReadUlongsAt(EntriesPointer, EntriesCount); + } + + /// + /// Writes the data-block to a stream. + /// + public override void Write(ResourceDataWriter writer, params object[] parameters) + { + // update structure data //TODO: fix + this.EntriesPointer = (ulong)(this.data_block != null ? this.data_block.FilePosition : 0); + this.EntriesCount = (ushort)(this.data_block != null ? this.data_block.ItemCount : 0); + this.EntriesCapacity = (ushort)(this.data_block != null ? this.data_block.ItemCount : 0); + + // write structure data + writer.Write(this.EntriesPointer); + writer.Write(this.EntriesCount); + writer.Write(this.EntriesCapacity); + writer.Write((uint)0x00000000); + } + + /// + /// Returns a list of data blocks which are referenced by this block. + /// + public override IResourceBlock[] GetReferences() + { + var list = new List(); + //if (Entries != null) list.Add(Entries); + + data_block = new ResourceSystemStructBlock(data_items); + + list.Add(data_block); + + return list.ToArray(); + } + + public override string ToString() + { + return "(Count: " + EntriesCount.ToString() + ")"; + } + } + [TypeConverter(typeof(ExpandableObjectConverter))] public class ResourceSimpleList64_float : ResourceSystemBlock + { + public override long BlockLength + { + get { return 16; } + } + + // structure data + public ulong EntriesPointer { get; private set; } + public ushort EntriesCount { get; private set; } + public ushort EntriesCapacity { get; private set; } + + // reference data + public float[] data_items { get; private set; } + + private ResourceSystemStructBlock data_block;//used for saving. + + + /// + /// Reads the data-block from a stream. + /// + public override void Read(ResourceDataReader reader, params object[] parameters) + { + // read structure data + this.EntriesPointer = reader.ReadUInt64(); + this.EntriesCount = reader.ReadUInt16(); + this.EntriesCapacity = reader.ReadUInt16(); + reader.Position += 4; + + // read reference data + + //TODO: NEEDS TO BE TESTED!!! + data_items = reader.ReadFloatsAt(EntriesPointer, EntriesCount); + } + + /// + /// Writes the data-block to a stream. + /// + public override void Write(ResourceDataWriter writer, params object[] parameters) + { + // update structure data //TODO: fix + this.EntriesPointer = (ulong)(this.data_block != null ? this.data_block.FilePosition : 0); + this.EntriesCount = (ushort)(this.data_block != null ? this.data_block.ItemCount : 0); + this.EntriesCapacity = (ushort)(this.data_block != null ? this.data_block.ItemCount : 0); + + // write structure data + writer.Write(this.EntriesPointer); + writer.Write(this.EntriesCount); + writer.Write(this.EntriesCapacity); + writer.Write((uint)0x00000000); + } + + /// + /// Returns a list of data blocks which are referenced by this block. + /// + public override IResourceBlock[] GetReferences() + { + var list = new List(); + //if (Entries != null) list.Add(Entries); + + data_block = new ResourceSystemStructBlock(data_items); + + list.Add(data_block); + return list.ToArray(); } @@ -752,53 +1267,23 @@ namespace CodeWalker.GameFiles } - //// structure data - //public List data_pointers; - - //// reference data - //public List data_items; - public ulong[] data_pointers { get; private set; } - public T[] data_items { get; private set; } + public T[] data_items { get; set; } public ResourcePointerArray64() { - //data_items = new List(); } public override void Read(ResourceDataReader reader, params object[] parameters) { int numElements = Convert.ToInt32(parameters[0]); - // read structure data - //data_pointers = new List(); - //for (int i = 0; i < numElements; i++) - //{ - // data_pointers.Add(reader.ReadUInt64()); - //} data_pointers = reader.ReadUlongsAt((ulong)reader.Position, (uint)numElements); - //foreach (var dp in data_pointers) - //{ - // if (dp == 0) - // { - - // } - //} - - // read reference data - //data_items = new List(); - //for (int i = 0; i < numElements; i++) - //{ - // data_items.Add( - // reader.ReadBlockAt(data_pointers[i]) - // ); - //} - data_items = new T[numElements]; for (int i = 0; i < numElements; i++) { @@ -811,13 +1296,13 @@ namespace CodeWalker.GameFiles public override void Write(ResourceDataWriter writer, params object[] parameters) { // update... - //data_pointers = new List(); - //foreach (var x in data_items) - // if (x != null) - // data_pointers.Add((uint)x.Position); - // else - // data_pointers.Add((uint)0); - //TODO: fix! + var list = new List(); + foreach (var x in data_items) + if (x != null) + list.Add((uint)x.FilePosition); + else + list.Add((uint)0); + data_pointers = list.ToArray(); // write... foreach (var x in data_pointers) @@ -928,68 +1413,29 @@ namespace CodeWalker.GameFiles [TypeConverter(typeof(ExpandableObjectConverter))] public class ResourcePointerArray64_s : ResourceSystemBlock, IList where T : struct { - //public int GetNonEmptyNumber() - //{ - // int i = 0; - // foreach (var q in data_items) - // if (q != null) - // i++; - // return i; - //} - public override long BlockLength { get { return (data_items != null) ? 8 * data_items.Length : 0; } } - //// structure data - //public List data_pointers; - - //// reference data - //public List data_items; - public ulong[] data_pointers { get; private set; } public T[] data_items { get; private set; } + private ResourceSystemStructBlock[] data_blocks = null; + public ResourcePointerArray64_s() { - //data_items = new List(); } public override void Read(ResourceDataReader reader, params object[] parameters) { int numElements = Convert.ToInt32(parameters[0]); - // read structure data - //data_pointers = new List(); - //for (int i = 0; i < numElements; i++) - //{ - // data_pointers.Add(reader.ReadUInt64()); - //} - data_pointers = reader.ReadUlongsAt((ulong)reader.Position, (uint)numElements); - - //foreach (var dp in data_pointers) - //{ - // if (dp == 0) - // { - - // } - //} - - // read reference data - //data_items = new List(); - //for (int i = 0; i < numElements; i++) - //{ - // data_items.Add( - // reader.ReadBlockAt(data_pointers[i]) - // ); - //} - data_items = new T[numElements]; for (int i = 0; i < numElements; i++) { @@ -1001,13 +1447,20 @@ namespace CodeWalker.GameFiles public override void Write(ResourceDataWriter writer, params object[] parameters) { // update... - //data_pointers = new List(); + var list = new List(); + if (data_blocks != null) + { + foreach (var x in data_blocks) + { + list.Add((ulong)x.FilePosition); + } + } //foreach (var x in data_items) // if (x != null) // data_pointers.Add((uint)x.Position); // else // data_pointers.Add((uint)0); - //TODO: fix! + data_pointers = list.ToArray(); // write... foreach (var x in data_pointers) @@ -1019,7 +1472,18 @@ namespace CodeWalker.GameFiles { var list = new List(); - //foreach (var x in data_items) //TODO: fix + var blocks = new List>(); + if (data_items != null) + { + foreach (var x in data_items) + { + var block = new ResourceSystemStructBlock(new[] { x }); + blocks.Add(block); + list.Add(block); + } + } + data_blocks = blocks.ToArray(); + //foreach (var x in data_items) // list.Add(x); return list.ToArray(); @@ -1133,6 +1597,7 @@ namespace CodeWalker.GameFiles public ulong[] data_pointers { get; private set; } public T[] data_items { get; private set; } + private ResourcePointerArray64 data_block;//used for saving. public override void Read(ResourceDataReader reader, params object[] parameters) @@ -1159,10 +1624,11 @@ namespace CodeWalker.GameFiles public override void Write(ResourceDataWriter writer, params object[] parameters) { - // update... //TODO: fix... - //this.EntriesPointer = (ulong)(this.Entries != null ? this.Entries.Position : 0); - //this.EntriesCount = (ushort)(this.Entries != null ? this.Entries.Count : 0); - //this.EntriesCapacity = (ushort)(this.Entries != null ? this.Entries.Count : 0); + // update... + this.EntriesPointer = (ulong)(this.data_block != null ? this.data_block.FilePosition : 0); + this.EntriesCount = (ushort)(this.data_block != null ? this.data_block.Count : 0); + this.EntriesCapacity = (ushort)(this.data_block != null ? this.data_block.Count : 0); + // write... writer.Write(EntriesPointer); @@ -1174,7 +1640,12 @@ namespace CodeWalker.GameFiles public override IResourceBlock[] GetReferences() { var list = new List(); - //if (Entries != null) list.Add(Entries); //TODO: fix.. + + //if (Entries != null) list.Add(Entries); + data_block = new ResourcePointerArray64(); + data_block.data_items = data_items; + list.Add(data_block); + return list.ToArray(); } @@ -1358,8 +1829,8 @@ namespace CodeWalker.GameFiles foreach (var x in ptr_list) writer.Write(x); - foreach (var x in Data) - x.Write(writer); + //foreach (var x in Data) + // x.Write(writer); } @@ -1369,7 +1840,7 @@ namespace CodeWalker.GameFiles { var children = new List(); - //if (Data != null) children.AddRange(Data); + if (Data != null) children.AddRange(Data); return children.ToArray(); } @@ -1378,15 +1849,15 @@ namespace CodeWalker.GameFiles { var children = new List>(); - if (Data != null) - { - long len = 8 * Data.Count; - foreach (var f in Data) - { - children.Add(new Tuple(len, f)); - len += f.BlockLength; - } - } + //if (Data != null) + //{ + // long len = 8 * Data.Count; + // foreach (var f in Data) + // { + // children.Add(new Tuple(len, f)); + // len += f.BlockLength; + // } + //} return children.ToArray(); } diff --git a/CodeWalker.Core/GameFiles/Resources/ResourceData.cs b/CodeWalker.Core/GameFiles/Resources/ResourceData.cs index f9ee6ae..53e2b20 100644 --- a/CodeWalker.Core/GameFiles/Resources/ResourceData.cs +++ b/CodeWalker.Core/GameFiles/Resources/ResourceData.cs @@ -87,6 +87,19 @@ namespace CodeWalker.GameFiles var systemSize = resentry.SystemSize; var graphicsSize = resentry.GraphicsSize; + //if (data != null) + //{ + // if (systemSize > data.Length) + // { + // systemSize = data.Length; + // graphicsSize = 0; + // } + // else if ((systemSize + graphicsSize) > data.Length) + // { + // graphicsSize = data.Length - systemSize; + // } + //} + this.systemStream = new MemoryStream(data, 0, systemSize); this.graphicsStream = new MemoryStream(data, systemSize, graphicsSize); this.blockPool = new Dictionary>(); @@ -735,8 +748,12 @@ namespace CodeWalker.GameFiles public override void Write(ResourceDataWriter writer, params object[] parameters) { + byte[] data = MetaTypes.ConvertArrayToBytes(Items); - writer.Write(data); + if (data != null) + { + writer.Write(data); + } } } diff --git a/CodeWalker.Core/GameFiles/Resources/Texture.cs b/CodeWalker.Core/GameFiles/Resources/Texture.cs index 60b12aa..8b0c977 100644 --- a/CodeWalker.Core/GameFiles/Resources/Texture.cs +++ b/CodeWalker.Core/GameFiles/Resources/Texture.cs @@ -24,12 +24,12 @@ namespace CodeWalker.GameFiles public uint Unknown_14h { get; set; } // 0x00000000 public uint Unknown_18h { get; set; } // 0x00000001 public uint Unknown_1Ch { get; set; } // 0x00000000 - public ResourceSimpleList64Ptr TextureNameHashesPtr { get; set; } - public uint[] TextureNameHashes { get; set; } + public ResourceSimpleList64_uint TextureNameHashes { get; set; } public ResourcePointerList64 Textures { get; set; } public Dictionary Dict { get; set; } + public long MemoryUsage { get @@ -51,8 +51,8 @@ namespace CodeWalker.GameFiles public TextureDictionary() { - //this.TextureNameHashes = new ResourceSimpleList64(); - this.Textures = new ResourcePointerList64(); + //this.TextureNameHashes = new ResourceSimpleList64_uint(); + //this.Textures = new ResourcePointerList64(); } /// @@ -67,18 +67,16 @@ namespace CodeWalker.GameFiles this.Unknown_14h = reader.ReadUInt32(); this.Unknown_18h = reader.ReadUInt32(); this.Unknown_1Ch = reader.ReadUInt32(); - this.TextureNameHashesPtr = reader.ReadStruct(); - this.TextureNameHashes = reader.ReadUintsAt(this.TextureNameHashesPtr.EntriesPointer, this.TextureNameHashesPtr.EntriesCount); - //this.TextureNameHashes = reader.ReadBlock>(); + this.TextureNameHashes = reader.ReadBlock(); this.Textures = reader.ReadBlock>(); var dict = new Dictionary(); - if ((Textures != null) && (Textures.data_items != null) && (TextureNameHashes != null)) + if ((Textures?.data_items != null) && (TextureNameHashes?.data_items != null)) { - for (int i = 0; (i < Textures.data_items.Length) && (i < TextureNameHashes.Length); i++) + for (int i = 0; (i < Textures.data_items.Length) && (i < TextureNameHashes.data_items.Length); i++) { var tex = Textures.data_items[i]; - var hash = TextureNameHashes[i]; + var hash = TextureNameHashes.data_items[i]; dict[hash] = tex; } } @@ -92,19 +90,20 @@ namespace CodeWalker.GameFiles { base.Write(writer, parameters); + // write structure data writer.Write(this.Unknown_10h); writer.Write(this.Unknown_14h); writer.Write(this.Unknown_18h); writer.Write(this.Unknown_1Ch); - //writer.WriteBlock(this.TextureNameHashes); //TODO: fix! - //writer.WriteBlock(this.Textures); + writer.WriteBlock(this.TextureNameHashes); + writer.WriteBlock(this.Textures); } public override Tuple[] GetParts() { return new Tuple[] { - //new Tuple(0x20, TextureNameHashes), //TODO: fix! + new Tuple(0x20, TextureNameHashes), new Tuple(0x30, Textures) }; } @@ -163,6 +162,8 @@ namespace CodeWalker.GameFiles public string Name { get; set; } public uint NameHash { get; set; } + private string_r NameBlock = null; + /// /// Reads the data-block from a stream. /// @@ -202,7 +203,7 @@ namespace CodeWalker.GameFiles public override void Write(ResourceDataWriter writer, params object[] parameters) { // update structure data - //this.NamePointer = (ulong)(this.Name != null ? this.Name.Position : 0); //TODO: fix + this.NamePointer = (ulong)(this.NameBlock != null ? this.NameBlock.FilePosition : 0); // write structure data writer.Write(this.VFT); @@ -228,7 +229,11 @@ namespace CodeWalker.GameFiles public override IResourceBlock[] GetReferences() { var list = new List(); - //if (Name != null) list.Add(Name); //TODO: fix + if (!string.IsNullOrEmpty(Name)) + { + NameBlock = (string_r)Name; + list.Add(NameBlock); + } return list.ToArray(); } diff --git a/CodeWalker.Core/World/Space.cs b/CodeWalker.Core/World/Space.cs index c34eada..0454e99 100644 --- a/CodeWalker.Core/World/Space.cs +++ b/CodeWalker.Core/World/Space.cs @@ -1285,7 +1285,7 @@ namespace CodeWalker.World { continue; } if (bgeom.Polygons == null) { continue; } - if ((bgeom.BVH == null) || (bgeom.BVH.Trees == null)) + if ((bgeom.BVH?.Nodes?.data_items == null) || (bgeom.BVH?.Trees?.data_items == null)) { continue; } box.Minimum = bgeom.BoundingBoxMin; @@ -1299,9 +1299,9 @@ namespace CodeWalker.World var q = bgeom.BVH.Quantum.XYZ(); var c = bgeom.BVH.BoundingBoxCenter.XYZ(); var cg = bgeom.CenterGeom; - for (int t = 0; t < bgeom.BVH.Trees.Length; t++) + for (int t = 0; t < bgeom.BVH.Trees.data_items.Length; t++) { - var tree = bgeom.BVH.Trees[t]; + var tree = bgeom.BVH.Trees.data_items[t]; box.Minimum = new Vector3(tree.MinX, tree.MinY, tree.MinZ) * q + c; box.Maximum = new Vector3(tree.MaxX, tree.MaxY, tree.MaxZ) * q + c; if (!ray.Intersects(ref box, out bvhboxhittest)) @@ -1315,7 +1315,7 @@ namespace CodeWalker.World int lastind = tree.NodeIndex2; while (nodeind < lastind) { - var node = bgeom.BVH.Nodes[nodeind]; + var node = bgeom.BVH.Nodes.data_items[nodeind]; box.Minimum = new Vector3(node.MinX, node.MinY, node.MinZ) * q + c; box.Maximum = new Vector3(node.MaxX, node.MaxY, node.MaxZ) * q + c; bool nodehit = ray.Intersects(ref box, out bvhboxhittest); @@ -1567,7 +1567,7 @@ namespace CodeWalker.World { continue; } if (bgeom.Polygons == null) { continue; } - if ((bgeom.BVH == null) || (bgeom.BVH.Trees == null)) + if ((bgeom.BVH?.Nodes?.data_items == null) || (bgeom.BVH?.Trees?.data_items == null)) { continue; } box.Minimum = bgeom.BoundingBoxMin; @@ -1578,9 +1578,9 @@ namespace CodeWalker.World var q = bgeom.BVH.Quantum.XYZ(); var c = bgeom.BVH.BoundingBoxCenter.XYZ(); var cg = bgeom.CenterGeom; - for (int t = 0; t < bgeom.BVH.Trees.Length; t++) + for (int t = 0; t < bgeom.BVH.Trees.data_items.Length; t++) { - var tree = bgeom.BVH.Trees[t]; + var tree = bgeom.BVH.Trees.data_items[t]; box.Minimum = new Vector3(tree.MinX, tree.MinY, tree.MinZ) * q + c; box.Maximum = new Vector3(tree.MaxX, tree.MaxY, tree.MaxZ) * q + c; if (!sph.Intersects(ref box)) @@ -1590,7 +1590,7 @@ namespace CodeWalker.World int lastind = tree.NodeIndex2; while (nodeind < lastind) { - var node = bgeom.BVH.Nodes[nodeind]; + var node = bgeom.BVH.Nodes.data_items[nodeind]; box.Minimum = new Vector3(node.MinX, node.MinY, node.MinZ) * q + c; box.Maximum = new Vector3(node.MaxX, node.MaxY, node.MaxZ) * q + c; bool nodehit = sph.Intersects(ref box); diff --git a/Project/Panels/GenerateLODLightsPanel.cs b/Project/Panels/GenerateLODLightsPanel.cs index eedf6c0..2f0fc84 100644 --- a/Project/Panels/GenerateLODLightsPanel.cs +++ b/Project/Panels/GenerateLODLightsPanel.cs @@ -123,11 +123,11 @@ namespace CodeWalker.Project.Panels LightAttributes_s[] lightAttrs = null; if (ddwbl != null) { - lightAttrs = ddwbl.LightAttributes; + lightAttrs = ddwbl.LightAttributes?.data_items; } else if (fdwbl != null) { - lightAttrs = fdwbl.OwnerFragment?.LightAttributes; + lightAttrs = fdwbl.OwnerFragment?.LightAttributes?.data_items; } if (lightAttrs != null) {