mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-22 20:43:09 +00:00
BCSV : Add check for float values
This commit is contained in:
parent
241833ca8f
commit
c36eb67acf
1 changed files with 15 additions and 12 deletions
|
@ -75,9 +75,9 @@ namespace FirstPlugin
|
||||||
if (size == 1)
|
if (size == 1)
|
||||||
type = DataType.Byte;
|
type = DataType.Byte;
|
||||||
if (size == 2)
|
if (size == 2)
|
||||||
type = DataType.Uint16;
|
type = DataType.Int16;
|
||||||
if (size == 4)
|
if (size == 4)
|
||||||
type = DataType.Uint32;
|
type = DataType.Int32;
|
||||||
|
|
||||||
reader.SeekBegin(pos + fields[f].Offset);
|
reader.SeekBegin(pos + fields[f].Offset);
|
||||||
object value = 0;
|
object value = 0;
|
||||||
|
@ -90,11 +90,16 @@ namespace FirstPlugin
|
||||||
case DataType.Float:
|
case DataType.Float:
|
||||||
value = reader.ReadSingle();
|
value = reader.ReadSingle();
|
||||||
break;
|
break;
|
||||||
case DataType.Uint16:
|
case DataType.Int16:
|
||||||
value = reader.ReadUInt16();
|
value = reader.ReadInt16();
|
||||||
break;
|
break;
|
||||||
case DataType.Uint32:
|
case DataType.Int32:
|
||||||
value = reader.ReadUInt32();
|
value = reader.ReadInt32();
|
||||||
|
if (IsFloatValue((int)value))
|
||||||
|
{
|
||||||
|
reader.Seek(-4);
|
||||||
|
value = reader.ReadSingle();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case DataType.String:
|
case DataType.String:
|
||||||
value = reader.ReadZeroTerminatedString(Encoding.UTF8);
|
value = reader.ReadZeroTerminatedString(Encoding.UTF8);
|
||||||
|
@ -111,18 +116,16 @@ namespace FirstPlugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsFloatValue(int value)
|
private bool IsFloatValue(int value) {
|
||||||
{
|
|
||||||
// Use a very dumb "algorithm" to check if the resulting integer would be "too long".
|
|
||||||
return value.ToString().Length > 6;
|
return value.ToString().Length > 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum DataType
|
public enum DataType
|
||||||
{
|
{
|
||||||
Byte,
|
Byte,
|
||||||
Uint16,
|
Int16,
|
||||||
Uint32,
|
Int32,
|
||||||
Uint64,
|
Int64,
|
||||||
Float,
|
Float,
|
||||||
String,
|
String,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue