XML editing for audioconfig.dat4.rel

This commit is contained in:
dexy 2019-01-20 16:54:42 +11:00
parent 63a7b1bceb
commit 6d8a785635
3 changed files with 1020 additions and 92 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2376,53 +2376,14 @@ namespace CodeWalker.GameFiles
sb.AppendLine();
byte[] data;
if (!savetest) continue;
byte[] data = rel.Save();
if (data != null)
if (savetest)
{
if (data.Length != rbfe.FileUncompressedSize)
{ }
else if (data.Length != rel.RawFileData.Length)
{ }
else
{
for (int i = 0; i < data.Length; i++) //raw file test
if (data[i] != rel.RawFileData[i])
{ break; }
}
}
else
{ }
RelFile rel2 = new RelFile();
rel2.Load(data, rfe);//roundtrip test
if (rel2.IndexCount != rel.IndexCount)
{ }
if (rel2.RelDatas == null)
{ }
if (!xmltest) continue;
var relxml = RelXml.GetXml(rel); //XML test...
var rel3 = XmlRel.GetRel(relxml);
if (rel3 != null)
{
if (rel3.RelDatasSorted?.Length != rel.RelDatasSorted?.Length)
{ } //check nothing went missing...
data = rel3.Save(); //full roundtrip!
data = rel.Save();
if (data != null)
{
var rel4 = new RelFile();
rel4.Load(data, rfe); //insanity check
if (data.Length != rbfe.FileUncompressedSize)
{ }
else if (data.Length != rel.RawFileData.Length)
@ -2434,20 +2395,62 @@ namespace CodeWalker.GameFiles
{ break; }
}
var relxml2 = RelXml.GetXml(rel4); //full insanity
if (relxml2.Length != relxml.Length)
RelFile rel2 = new RelFile();
rel2.Load(data, rfe);//roundtrip test
if (rel2.IndexCount != rel.IndexCount)
{ }
if (relxml2 != relxml)
if (rel2.RelDatas == null)
{ }
}
else
{ }
}
else
{ }
if (xmltest)
{
var relxml = RelXml.GetXml(rel); //XML test...
var rel3 = XmlRel.GetRel(relxml);
if (rel3 != null)
{
if (rel3.RelDatasSorted?.Length != rel.RelDatasSorted?.Length)
{ } //check nothing went missing...
data = rel3.Save(); //full roundtrip!
if (data != null)
{
var rel4 = new RelFile();
rel4.Load(data, rfe); //insanity check
if (data.Length != rbfe.FileUncompressedSize)
{ }
else if (data.Length != rel.RawFileData.Length)
{ }
else
{
for (int i = 0; i < data.Length; i++) //raw file test
if (data[i] != rel.RawFileData[i])
{ break; }
}
var relxml2 = RelXml.GetXml(rel4); //full insanity
if (relxml2.Length != relxml.Length)
{ }
if (relxml2 != relxml)
{ }
}
else
{ }
}
else
{ }
}
//sbi.Clear();

View File

@ -303,6 +303,51 @@ namespace CodeWalker
return GetRawVector3Array(cnode);
}
public static Vector4[] GetRawVector4Array(XmlNode node)
{
if (node == null) return new Vector4[0];
float x = 0f;
float y = 0f;
float z = 0f;
float w = 0f;
var items = new List<Vector4>();
var split = node.InnerText.Split('\n');// Regex.Split(node.InnerText, @"[\s\r\n\t]");
for (int i = 0; i < split.Length; i++)
{
var s = split[i]?.Trim();
if (string.IsNullOrEmpty(s)) continue;
var split2 = s.Split(',');// Regex.Split(s, @"[\s\t]");
int c = 0;
x = 0f; y = 0f;
for (int n = 0; n < split2.Length; n++)
{
var ts = split2[n]?.Trim();
if (string.IsNullOrEmpty(ts)) continue;
var f = FloatUtil.Parse(ts);
switch (c)
{
case 0: x = f; break;
case 1: y = f; break;
case 2: z = f; break;
case 3: w = f; break;
}
c++;
}
if (c >= 4)
{
var val = new Vector4(x, y, z, w);
items.Add(val);
}
}
return items.ToArray();
}
public static Vector4[] GetChildRawVector4Array(XmlNode node, string name)
{
var cnode = node.SelectSingleNode(name);
return GetRawVector4Array(cnode);
}
}
}