Fix number marshaling for PDT variable memory.
This commit is contained in:
@@ -46,7 +46,7 @@ namespace Cryville.Common.Pdt {
|
|||||||
/// <returns>A number.</returns>
|
/// <returns>A number.</returns>
|
||||||
/// <exception cref="InvalidCastException">The span at the offset does not represent a number.</exception>
|
/// <exception cref="InvalidCastException">The span at the offset does not represent a number.</exception>
|
||||||
public float AsNumber(int offset = 0) {
|
public float AsNumber(int offset = 0) {
|
||||||
if (Type != PdtInternalType.Number)
|
if (Type != PdtInternalType.Number && Type != PdtInternalType.Vector)
|
||||||
throw new InvalidCastException("Not a number");
|
throw new InvalidCastException("Not a number");
|
||||||
float value;
|
float value;
|
||||||
byte* ptr = (byte*)&value;
|
byte* ptr = (byte*)&value;
|
||||||
@@ -62,7 +62,7 @@ namespace Cryville.Common.Pdt {
|
|||||||
/// <exception cref="InvalidCastException">The span at the offset does not represent a number.</exception>
|
/// <exception cref="InvalidCastException">The span at the offset does not represent a number.</exception>
|
||||||
/// <exception cref="InvalidOperationException">The length of the span is not sufficient.</exception>
|
/// <exception cref="InvalidOperationException">The length of the span is not sufficient.</exception>
|
||||||
public void SetNumber(float value, int offset = 0) {
|
public void SetNumber(float value, int offset = 0) {
|
||||||
if (Type != PdtInternalType.Number)
|
if (Type != PdtInternalType.Number && Type != PdtInternalType.Vector)
|
||||||
throw new InvalidCastException("Not a number");
|
throw new InvalidCastException("Not a number");
|
||||||
if (Length < sizeof(float) + offset)
|
if (Length < sizeof(float) + offset)
|
||||||
throw new InvalidOperationException("Frame length not sufficient");
|
throw new InvalidOperationException("Frame length not sufficient");
|
||||||
|
Reference in New Issue
Block a user