From dda6579d2829ef6a4fa57b0aff0bddef86ab6d75 Mon Sep 17 00:00:00 2001 From: Axanery <41282531+Axanery@users.noreply.github.com> Date: Sat, 16 Nov 2024 16:25:57 -0600 Subject: [PATCH] Move Math.ToFixed and FromFixed to RSDK.Math --- source/Engine/Bytecode/StandardLibrary.cpp | 48 +++++++++++----------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/source/Engine/Bytecode/StandardLibrary.cpp b/source/Engine/Bytecode/StandardLibrary.cpp index e30d843..1bfeaeb 100644 --- a/source/Engine/Bytecode/StandardLibrary.cpp +++ b/source/Engine/Bytecode/StandardLibrary.cpp @@ -7936,28 +7936,6 @@ VMValue Math_Clamp(int argCount, VMValue* args, Uint32 threadID) { else return DECIMAL_VAL(Math::Clamp(GET_ARG(0, GetDecimal), GET_ARG(1, GetDecimal), GET_ARG(2, GetDecimal))); } -/*** - * Math.ToFixed - * \desc Converts a decimal number to its fixed-point equivalent. - * \param n (Number): Number value. - * \return Returns the converted fixed-point Number value. - * \ns Math - */ -VMValue Math_ToFixed(int argCount, VMValue* args, Uint32 threadID) { - CHECK_ARGCOUNT(1); - return INTEGER_VAL((int)(GET_ARG(0, GetDecimal) * 65536.0f)); -} -/*** - * Math.FromFixed - * \desc Converts a fixed-point number to its decimal equivalent. - * \param n (Number): Number value. - * \return Returns the converted decimal Number value. - * \ns Math - */ -VMValue Math_FromFixed(int argCount, VMValue* args, Uint32 threadID) { - CHECK_ARGCOUNT(1); - return DECIMAL_VAL((float)GET_ARG(0, GetInteger) / 65536.0f); -} /*** * Math.Sign * \desc Gets the sign associated with a Decimal value. @@ -8384,6 +8362,28 @@ VMValue Math_IntegerToRadian(int argCount, VMValue* args, Uint32 threadID) { CHECK_ARGCOUNT(1); return DECIMAL_VAL((float)(GET_ARG(0, GetInteger) * M_PI / 256.0)); } +/*** + * RSDK.Math.ToFixed + * \desc Converts a decimal number to its fixed-point equivalent. + * \param n (Number): Number value. + * \return Returns the converted fixed-point Number value. + * \ns Math + */ +VMValue Math_ToFixed(int argCount, VMValue* args, Uint32 threadID) { + CHECK_ARGCOUNT(1); + return INTEGER_VAL((int)(GET_ARG(0, GetDecimal) * 65536.0f)); +} +/*** + * RSDK.Math.FromFixed + * \desc Converts a fixed-point number to its decimal equivalent. + * \param n (Number): Number value. + * \return Returns the converted decimal Number value. + * \ns Math + */ +VMValue Math_FromFixed(int argCount, VMValue* args, Uint32 threadID) { + CHECK_ARGCOUNT(1); + return DECIMAL_VAL((float)GET_ARG(0, GetInteger) / 65536.0f); +} // #endregion // #region Matrix @@ -17972,8 +17972,6 @@ void StandardLibrary::Link() { DEF_NATIVE(Math, Min); DEF_NATIVE(Math, Max); DEF_NATIVE(Math, Clamp); - DEF_NATIVE(Math, ToFixed); - DEF_NATIVE(Math, FromFixed); DEF_NATIVE(Math, Sign); DEF_NATIVE(Math, Uint8); DEF_NATIVE(Math, Uint16); @@ -18016,6 +18014,8 @@ void StandardLibrary::Link() { DEF_NAMESPACED_NATIVE(Math, SetRandSeed); DEF_NAMESPACED_NATIVE(Math, RandomInteger); DEF_NAMESPACED_NATIVE(Math, RandomIntegerSeeded); + DEF_NAMESPACED_NATIVE(Math, ToFixed); + DEF_NAMESPACED_NATIVE(Math, FromFixed); // #endregion // #region Matrix