From 415f03efc32ba0951f7d5010dcbaff7ae5d4e35f Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 22 Sep 2019 13:30:54 +0200 Subject: [PATCH] Fixed NumericEvalValues always being evaluated as integers. --- PorygonSharp/EvalValues/EvalValue.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/PorygonSharp/EvalValues/EvalValue.cs b/PorygonSharp/EvalValues/EvalValue.cs index 602f6c7..1ddeb63 100644 --- a/PorygonSharp/EvalValues/EvalValue.cs +++ b/PorygonSharp/EvalValues/EvalValue.cs @@ -74,7 +74,10 @@ namespace PorygonSharp.EvalValues case TypeClass.Nil: return null; case TypeClass.Number: - return EvaluateInteger(); + if (IsNumericValueFloat(Handle) == 1) + return EvaluateFloat(); + else + return EvaluateInteger(); case TypeClass.Bool: return EvaluateBool(); case TypeClass.String: @@ -98,6 +101,10 @@ namespace PorygonSharp.EvalValues private static extern int GetTypeClass(IntPtr ptr); [DllImport("PorygonLang", EntryPoint = "GetEvalValueType", CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr GetScriptType(IntPtr ptr); + + [DllImport("PorygonLang", EntryPoint = "IsNumericValueFloat", CallingConvention = CallingConvention.Cdecl)] + private static extern byte IsNumericValueFloat(IntPtr ptr); + [DllImport("PorygonLang", EntryPoint = "EvaluateEvalValueInteger", CallingConvention = CallingConvention.Cdecl)] private static extern long EvaluateInteger(IntPtr ptr); [DllImport("PorygonLang", EntryPoint = "EvaluateEvalValueFloat", CallingConvention = CallingConvention.Cdecl)]