From 2622ea08b68e63d2f552342d8d826dd02d0c488c Mon Sep 17 00:00:00 2001 From: dexy Date: Tue, 29 Jan 2019 00:29:59 +1100 Subject: [PATCH] Added Save method to YptFile --- .../GameFiles/FileTypes/YptFile.cs | 7 +++ CodeWalker.Core/GameFiles/GameFileCache.cs | 55 +++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/CodeWalker.Core/GameFiles/FileTypes/YptFile.cs b/CodeWalker.Core/GameFiles/FileTypes/YptFile.cs index 3a6530c..ae00043 100644 --- a/CodeWalker.Core/GameFiles/FileTypes/YptFile.cs +++ b/CodeWalker.Core/GameFiles/FileTypes/YptFile.cs @@ -97,6 +97,13 @@ namespace CodeWalker.GameFiles } + public byte[] Save() + { + byte[] data = ResourceBuilder.Build(PtfxList, 68); //ypt is type/version 68... + + return data; + } + } diff --git a/CodeWalker.Core/GameFiles/GameFileCache.cs b/CodeWalker.Core/GameFiles/GameFileCache.cs index 2cf9019..6a6a157 100644 --- a/CodeWalker.Core/GameFiles/GameFileCache.cs +++ b/CodeWalker.Core/GameFiles/GameFileCache.cs @@ -182,6 +182,7 @@ namespace CodeWalker.GameFiles //TestYdrs(); //TestYdds(); //TestYfts(); + //TestYpts(); //TestYmaps(); //TestPlacements(); //TestDrawables(); @@ -3264,6 +3265,60 @@ namespace CodeWalker.GameFiles if (errorfiles.Count > 0) { } } + public void TestYpts() + { + var errorfiles = new List(); + foreach (RpfFile file in AllRpfs) + { + foreach (RpfEntry entry in file.AllEntries) + { + //try + { + if (entry.NameLower.EndsWith(".ypt")) + { + UpdateStatus(string.Format(entry.Path)); + YptFile ypt = null; + try + { + ypt = RpfMan.GetFile(entry); + } + catch (Exception ex) + { + UpdateStatus("Error! " + ex.ToString()); + errorfiles.Add(entry); + } + if ((ypt != null) && (ypt.PtfxList != null)) + { + var fentry = entry as RpfFileEntry; + if (fentry == null) + { continue; } //shouldn't happen + + var bytes = ypt.Save(); + + + string origlen = TextUtil.GetBytesReadable(fentry.FileSize); + string bytelen = TextUtil.GetBytesReadable(bytes.Length); + + var ypt2 = new YptFile(); + RpfFile.LoadResourceFile(ypt2, bytes, 68); + + if (ypt2.PtfxList == null) + { continue; } + if (ypt2.PtfxList.Name?.Value != ypt.PtfxList.Name?.Value) + { continue; } + + } + } + } + //catch (Exception ex) + //{ + // UpdateStatus("Error! " + ex.ToString()); + //} + } + } + if (errorfiles.Count > 0) + { } + } public void TestYmaps() { foreach (RpfFile file in AllRpfs)