Added Save method to YptFile

This commit is contained in:
dexy 2019-01-29 00:29:59 +11:00
parent 75748ad3d0
commit 2622ea08b6
2 changed files with 62 additions and 0 deletions

View File

@ -97,6 +97,13 @@ namespace CodeWalker.GameFiles
}
public byte[] Save()
{
byte[] data = ResourceBuilder.Build(PtfxList, 68); //ypt is type/version 68...
return data;
}
}

View File

@ -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<RpfEntry>();
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<YptFile>(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)