Fixed sbyte types in handler of ArrayOfBytes

This commit is contained in:
Carmine 2018-03-02 01:15:55 +01:00
parent 8baef77ecd
commit e2b59d2ca5
2 changed files with 18 additions and 2 deletions

View File

@ -432,7 +432,6 @@ namespace CodeWalker.GameFiles
switch (arrEntry.DataType)
{
default:
case MetaStructureEntryDataType.SignedByte:
for (int n = 0; n < byteArrLen; n++)
{
var bidx = eoffset + n;
@ -440,6 +439,15 @@ namespace CodeWalker.GameFiles
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++)

View File

@ -301,12 +301,20 @@ namespace CodeWalker.GameFiles
switch (arrEntry.DataType)
{
default:
case MetaStructureEntryDataType.SignedByte:
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;