diff options
author | Aaron Franke <arnfranke@yahoo.com> | 2018-10-27 16:12:27 -0400 |
---|---|---|
committer | Aaron Franke <arnfranke@yahoo.com> | 2019-07-18 16:33:43 -0400 |
commit | a60f242982d70e85a5b2c182eb3289b2fa7812e1 (patch) | |
tree | 212cd72bf8e9b157de9b35ec8ccda3337f30bbbc /modules/gdscript/gdscript_functions.cpp | |
parent | 20a3bb9c484431439ffa60a158d7563c466cd530 (diff) |
Add integer posmod and rename default arg names
"posmod" is the integer version of "fposmod". We do not need a "mod" because of the % operator.
I changed the default arg names from "x" and "y" to "a" and "b" because they are not coordinates. I also changed pow's arg names to "base" and "exp". Also, I reorganized the code in the VS built-in funcs switch statement.
Diffstat (limited to 'modules/gdscript/gdscript_functions.cpp')
-rw-r--r-- | modules/gdscript/gdscript_functions.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp index 0736f3d010..8c33d6613c 100644 --- a/modules/gdscript/gdscript_functions.cpp +++ b/modules/gdscript/gdscript_functions.cpp @@ -58,6 +58,7 @@ const char *GDScriptFunctions::get_func_name(Function p_func) { "sqrt", "fmod", "fposmod", + "posmod", "floor", "ceil", "round", @@ -243,6 +244,12 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_ VALIDATE_ARG_NUM(1); r_ret = Math::fposmod((double)*p_args[0], (double)*p_args[1]); } break; + case MATH_POSMOD: { + VALIDATE_ARG_COUNT(2); + VALIDATE_ARG_NUM(0); + VALIDATE_ARG_NUM(1); + r_ret = Math::posmod((int)*p_args[0], (int)*p_args[1]); + } break; case MATH_FLOOR: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); @@ -1456,6 +1463,7 @@ bool GDScriptFunctions::is_deterministic(Function p_func) { case MATH_SQRT: case MATH_FMOD: case MATH_FPOSMOD: + case MATH_POSMOD: case MATH_FLOOR: case MATH_CEIL: case MATH_ROUND: @@ -1568,15 +1576,20 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) { return mi; } break; case MATH_FMOD: { - MethodInfo mi("fmod", PropertyInfo(Variant::REAL, "x"), PropertyInfo(Variant::REAL, "y")); + MethodInfo mi("fmod", PropertyInfo(Variant::REAL, "a"), PropertyInfo(Variant::REAL, "b")); mi.return_val.type = Variant::REAL; return mi; } break; case MATH_FPOSMOD: { - MethodInfo mi("fposmod", PropertyInfo(Variant::REAL, "x"), PropertyInfo(Variant::REAL, "y")); + MethodInfo mi("fposmod", PropertyInfo(Variant::REAL, "a"), PropertyInfo(Variant::REAL, "b")); mi.return_val.type = Variant::REAL; return mi; } break; + case MATH_POSMOD: { + MethodInfo mi("posmod", PropertyInfo(Variant::INT, "a"), PropertyInfo(Variant::INT, "b")); + mi.return_val.type = Variant::INT; + return mi; + } break; case MATH_FLOOR: { MethodInfo mi("floor", PropertyInfo(Variant::REAL, "s")); mi.return_val.type = Variant::REAL; @@ -1603,7 +1616,7 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) { return mi; } break; case MATH_POW: { - MethodInfo mi("pow", PropertyInfo(Variant::REAL, "x"), PropertyInfo(Variant::REAL, "y")); + MethodInfo mi("pow", PropertyInfo(Variant::REAL, "base"), PropertyInfo(Variant::REAL, "exp")); mi.return_val.type = Variant::REAL; return mi; } break; |