mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2025-01-24 14:32:54 +08:00
XML to audio dat.rel conversion progress
This commit is contained in:
parent
4d2f54c9c8
commit
35d10a8e48
File diff suppressed because it is too large
Load Diff
@ -2401,6 +2401,47 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
|
||||
|
||||
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();
|
||||
//foreach (var rd in rel.RelDatas)
|
||||
//{
|
||||
|
@ -3,6 +3,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
|
||||
@ -32,6 +33,14 @@ namespace CodeWalker
|
||||
int.TryParse(val, out i);
|
||||
return i;
|
||||
}
|
||||
public static uint GetUIntAttribute(XmlNode node, string attribute)
|
||||
{
|
||||
if (node == null) return 0;
|
||||
string val = node.Attributes[attribute]?.InnerText;
|
||||
uint i;
|
||||
uint.TryParse(val, out i);
|
||||
return i;
|
||||
}
|
||||
public static float GetFloatAttribute(XmlNode node, string attribute)
|
||||
{
|
||||
if (node == null) return 0;
|
||||
@ -183,5 +192,117 @@ namespace CodeWalker
|
||||
return child;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static byte[] GetRawByteArray(XmlNode node)
|
||||
{
|
||||
if (node == null) return new byte[0];
|
||||
var data = new List<byte>();
|
||||
var split = Regex.Split(node.InnerText, @"[\s\r\n\t]");
|
||||
for (int i = 0; i < split.Length; i++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(split[i]))
|
||||
{
|
||||
var str = split[i];
|
||||
if (string.IsNullOrEmpty(str)) continue;
|
||||
var val = Convert.ToByte(str, 16);
|
||||
data.Add(val);
|
||||
}
|
||||
}
|
||||
return data.ToArray();
|
||||
}
|
||||
public static byte[] GetChildRawByteArray(XmlNode node, string name)
|
||||
{
|
||||
var cnode = node.SelectSingleNode(name);
|
||||
return GetRawByteArray(cnode);
|
||||
}
|
||||
|
||||
public static Vector2[] GetRawVector2Array(XmlNode node)
|
||||
{
|
||||
if (node == null) return new Vector2[0];
|
||||
float x = 0f;
|
||||
float y = 0f;
|
||||
var items = new List<Vector2>();
|
||||
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;
|
||||
}
|
||||
c++;
|
||||
}
|
||||
if (c >= 2)
|
||||
{
|
||||
var val = new Vector2(x, y);
|
||||
items.Add(val);
|
||||
}
|
||||
}
|
||||
|
||||
return items.ToArray();
|
||||
}
|
||||
public static Vector2[] GetChildRawVector2Array(XmlNode node, string name)
|
||||
{
|
||||
var cnode = node.SelectSingleNode(name);
|
||||
return GetRawVector2Array(cnode);
|
||||
}
|
||||
|
||||
public static Vector3[] GetRawVector3Array(XmlNode node)
|
||||
{
|
||||
if (node == null) return new Vector3[0];
|
||||
float x = 0f;
|
||||
float y = 0f;
|
||||
float z = 0f;
|
||||
var items = new List<Vector3>();
|
||||
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;
|
||||
}
|
||||
c++;
|
||||
}
|
||||
if (c >= 3)
|
||||
{
|
||||
var val = new Vector3(x, y, z);
|
||||
items.Add(val);
|
||||
}
|
||||
}
|
||||
|
||||
return items.ToArray();
|
||||
}
|
||||
public static Vector3[] GetChildRawVector3Array(XmlNode node, string name)
|
||||
{
|
||||
var cnode = node.SelectSingleNode(name);
|
||||
return GetRawVector3Array(cnode);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1528,7 +1528,7 @@ namespace CodeWalker.Project
|
||||
cent.rotation = new Vector4(0, 0, 0, 1);
|
||||
cent.scaleXY = 1.0f;
|
||||
cent.scaleZ = 1.0f;
|
||||
cent.flags = 1572872;
|
||||
cent.flags = 32; //1572872;
|
||||
cent.parentIndex = -1;
|
||||
cent.lodDist = 200.0f;
|
||||
cent.lodLevel = rage__eLodType.LODTYPES_DEPTH_ORPHANHD;
|
||||
|
Loading…
Reference in New Issue
Block a user