mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-26 00:43:00 +08:00
Merge pull request #16 from neos7/master
Added handler to parse arrays of raw bytes for metas (updated)
This commit is contained in:
commit
e49350ba13
@ -3401,7 +3401,24 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
|
||||
|
||||
//from dav90's PSO_RBF_XMLExport_V5.7
|
||||
AutoJunctionAdjustments = 1352439928,
|
||||
vLocation = 929088795,
|
||||
fCycleOffset = 1883372816,
|
||||
fCycleDuration = 3328650398,
|
||||
|
||||
registerAs = 1419376801,
|
||||
|
||||
CreditItems = 1705522053,
|
||||
LineType = 660169259,
|
||||
cTextId1 = 4188319879,
|
||||
cTextId2 = 2913343627,
|
||||
JOB_BIG = 1035407208,
|
||||
|
||||
flee_left = 204999120,
|
||||
flee_right = 1266046331,
|
||||
flee_forward = 1547194093,
|
||||
flee_back = 1622623046,
|
||||
|
||||
|
||||
|
||||
|
@ -189,15 +189,9 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
break;
|
||||
case MetaStructureEntryDataType.ArrayOfBytes:
|
||||
OpenTag(sb, cind, ename, false);
|
||||
var byteArrLen = (int)entry.ReferenceKey;
|
||||
for (int n = 0; n < byteArrLen; n++)
|
||||
{
|
||||
var bidx = eoffset + n;
|
||||
byte b = ((bidx >= 0) && (bidx < data.Length)) ? data[bidx] : (byte)0;
|
||||
sb.Append(b.ToString("X").PadLeft(2, '0'));
|
||||
}
|
||||
CloseTag(sb, 0, ename);
|
||||
|
||||
WriteParsedArrayOfBytesNode(sb, cind, data, ename, eoffset, entry, arrEntry);
|
||||
|
||||
break;
|
||||
case MetaStructureEntryDataType.ArrayOfChars:
|
||||
OpenTag(sb, cind, ename, false);
|
||||
@ -429,6 +423,90 @@ namespace CodeWalker.GameFiles
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteParsedArrayOfBytesNode(StringBuilder sb, int indent, byte[] data, string ename, int eoffset, MetaStructureEntryInfo_s entry, MetaStructureEntryInfo_s arrEntry)
|
||||
{
|
||||
OpenTag(sb, indent, ename, false);
|
||||
|
||||
var byteArrLen = ((int)entry.ReferenceKey);
|
||||
|
||||
switch (arrEntry.DataType)
|
||||
{
|
||||
default:
|
||||
for (int n = 0; n < byteArrLen; n++)
|
||||
{
|
||||
var bidx = eoffset + n;
|
||||
byte b = ((bidx >= 0) && (bidx < data.Length)) ? data[bidx] : (byte)0;
|
||||
sb.Append(b.ToString("X").PadLeft(2, '0'));
|
||||
}
|
||||
break;
|
||||
case MetaStructureEntryDataType.SignedByte:
|
||||
for (int n = 0; n < byteArrLen; n++)
|
||||
{
|
||||
var bidx = eoffset + n;
|
||||
sbyte b = ((bidx >= 0) && (bidx < data.Length)) ? (sbyte)data[bidx] : (sbyte)0;
|
||||
sb.Append(b.ToString()); //sb.Append(b.ToString("X").PadLeft(2, '0')); to show HEX values
|
||||
if (n < byteArrLen - 1) sb.Append(" ");
|
||||
}
|
||||
break;
|
||||
|
||||
case MetaStructureEntryDataType.UnsignedByte:
|
||||
for (int n = 0; n < byteArrLen; n++)
|
||||
{
|
||||
var bidx = eoffset + n;
|
||||
byte b = ((bidx >= 0) && (bidx < data.Length)) ? data[bidx] : (byte)0;
|
||||
sb.Append(b.ToString());
|
||||
if (n < byteArrLen - 1) sb.Append(" ");
|
||||
}
|
||||
break;
|
||||
case MetaStructureEntryDataType.SignedShort:
|
||||
for (int n = 0; n < byteArrLen; n++)
|
||||
{
|
||||
var bidx = eoffset + n * 2;
|
||||
short b = ((bidx >= 0) && (bidx < data.Length)) ? BitConverter.ToInt16(data, bidx) : (short)0;
|
||||
sb.Append(b.ToString());
|
||||
if (n < byteArrLen - 1) sb.Append(" ");
|
||||
}
|
||||
break;
|
||||
case MetaStructureEntryDataType.UnsignedShort:
|
||||
for (int n = 0; n < byteArrLen; n++)
|
||||
{
|
||||
var bidx = eoffset + n * 2;
|
||||
ushort b = ((bidx >= 0) && (bidx < data.Length)) ? BitConverter.ToUInt16(data, bidx) : (ushort)0;
|
||||
sb.Append(b.ToString());
|
||||
if (n < byteArrLen - 1) sb.Append(" ");
|
||||
}
|
||||
break;
|
||||
case MetaStructureEntryDataType.SignedInt:
|
||||
for (int n = 0; n < byteArrLen; n++)
|
||||
{
|
||||
var bidx = eoffset + n * 4;
|
||||
int b = ((bidx >= 0) && (bidx < data.Length)) ? BitConverter.ToInt32(data, bidx) : (int)0;
|
||||
sb.Append(b.ToString());
|
||||
if (n < byteArrLen - 1) sb.Append(" ");
|
||||
}
|
||||
break;
|
||||
case MetaStructureEntryDataType.UnsignedInt:
|
||||
for (int n = 0; n < byteArrLen; n++)
|
||||
{
|
||||
var bidx = eoffset + n * 4;
|
||||
uint b = ((bidx >= 0) && (bidx < data.Length)) ? BitConverter.ToUInt32(data, bidx) : (uint)0;
|
||||
sb.Append(b.ToString());
|
||||
if (n < byteArrLen - 1) sb.Append(" ");
|
||||
}
|
||||
break;
|
||||
case MetaStructureEntryDataType.Float:
|
||||
for (int n = 0; n < byteArrLen; n++)
|
||||
{
|
||||
var bidx = eoffset + n * 4;
|
||||
float b = ((bidx >= 0) && (bidx < data.Length)) ? BitConverter.ToSingle(data, bidx) : (float)0;
|
||||
sb.Append(FloatUtil.ToString(b));
|
||||
if (n < byteArrLen - 1) sb.Append(" ");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
CloseTag(sb, 0, ename);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -77,6 +77,11 @@ namespace CodeWalker.GameFiles
|
||||
}
|
||||
|
||||
case MetaStructureEntryDataType.ArrayOfBytes:
|
||||
{
|
||||
GetParsedArrayOfBytes(cnode, data, entry, arrEntry);
|
||||
break;
|
||||
}
|
||||
|
||||
case MetaStructureEntryDataType.ArrayOfChars:
|
||||
{
|
||||
int offset = entry.DataOffset;
|
||||
@ -288,6 +293,88 @@ namespace CodeWalker.GameFiles
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void GetParsedArrayOfBytes(XmlNode node, byte[] data, MetaStructureEntryInfo_s entry, MetaStructureEntryInfo_s arrEntry)
|
||||
{
|
||||
int offset = entry.DataOffset;
|
||||
string[] split;
|
||||
|
||||
switch (arrEntry.DataType)
|
||||
{
|
||||
default:
|
||||
split = Split(node.InnerText, 2);
|
||||
for (int j = 0; j < split.Length; j++)
|
||||
{
|
||||
byte val = Convert.ToByte(split[j], 16);
|
||||
data[offset] = val;
|
||||
offset += sizeof(byte);
|
||||
}
|
||||
break;
|
||||
case MetaStructureEntryDataType.SignedByte:
|
||||
split = node.InnerText.Split(); //split = Split(node.InnerText, 2); to read as unsplitted HEX
|
||||
for (int j = 0; j < split.Length; j++)
|
||||
{
|
||||
sbyte val = Convert.ToSByte(split[j], 10);
|
||||
data[offset] = (byte)val;
|
||||
offset += sizeof(sbyte);
|
||||
}
|
||||
break;
|
||||
case MetaStructureEntryDataType.UnsignedByte:
|
||||
split = node.InnerText.Split();
|
||||
for (int j = 0; j < split.Length; j++)
|
||||
{
|
||||
byte val = Convert.ToByte(split[j], 10);
|
||||
data[offset] = val;
|
||||
offset += sizeof(byte);
|
||||
}
|
||||
break;
|
||||
case MetaStructureEntryDataType.SignedShort:
|
||||
split = node.InnerText.Split();
|
||||
for (int j = 0; j < split.Length; j++)
|
||||
{
|
||||
short val = Convert.ToInt16(split[j], 10);
|
||||
Write(val, data, offset);
|
||||
offset += sizeof(short);
|
||||
}
|
||||
break;
|
||||
case MetaStructureEntryDataType.UnsignedShort:
|
||||
split = node.InnerText.Split();
|
||||
for (int j = 0; j < split.Length; j++)
|
||||
{
|
||||
ushort val = Convert.ToUInt16(split[j], 10);
|
||||
Write(val, data, offset);
|
||||
offset += sizeof(ushort);
|
||||
}
|
||||
break;
|
||||
case MetaStructureEntryDataType.SignedInt:
|
||||
split = node.InnerText.Split();
|
||||
for (int j = 0; j < split.Length; j++)
|
||||
{
|
||||
int val = Convert.ToInt32(split[j], 10);
|
||||
Write(val, data, offset);
|
||||
offset += sizeof(int);
|
||||
}
|
||||
break;
|
||||
case MetaStructureEntryDataType.UnsignedInt:
|
||||
split = node.InnerText.Split();
|
||||
for (int j = 0; j < split.Length; j++)
|
||||
{
|
||||
uint val = Convert.ToUInt32(split[j], 10);
|
||||
Write(val, data, offset);
|
||||
offset += sizeof(uint);
|
||||
}
|
||||
break;
|
||||
case MetaStructureEntryDataType.Float:
|
||||
split = node.InnerText.Split();
|
||||
for (int j = 0; j < split.Length; j++)
|
||||
{
|
||||
float val = FloatUtil.Parse(split[j]);
|
||||
Write(val, data, offset);
|
||||
offset += sizeof(float);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void TraverseArray(XmlNode node, MetaBuilder mb, MetaStructureEntryInfo_s arrEntry, int offset, ArrayResults results)
|
||||
{
|
||||
switch (arrEntry.DataType)
|
||||
|
Loading…
Reference in New Issue
Block a user