Skip to content

Commit

Permalink
Move Math.ToFixed and FromFixed to RSDK.Math
Browse files Browse the repository at this point in the history
  • Loading branch information
Axanery committed Nov 16, 2024
1 parent 997e3ef commit dda6579
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions source/Engine/Bytecode/StandardLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit dda6579

Please sign in to comment.