From 427a216babddac7173113d2e9289e4807933737b Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Fri, 2 Aug 2024 00:47:24 +0200 Subject: [PATCH] Small changes --- source/funkin/backend/utils/MathUtil.hx | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/source/funkin/backend/utils/MathUtil.hx b/source/funkin/backend/utils/MathUtil.hx index 46fe3559..e11352a0 100644 --- a/source/funkin/backend/utils/MathUtil.hx +++ b/source/funkin/backend/utils/MathUtil.hx @@ -23,7 +23,7 @@ class MathUtil { return min; } - public static function maxFloat(...args:Float):Float { + public static function max(...args:Float):Float { var max = args[0]; for(i in 1...args.length) { var arg = args[i]; @@ -33,7 +33,7 @@ class MathUtil { return max; } - public static function minFloat(...args:Float):Float { + public static function min(...args:Float):Float { var min = args[0]; for(i in 1...args.length) { var arg = args[i]; @@ -45,46 +45,31 @@ class MathUtil { /** * Shortcut to `Math.max` but with infinite amount of arguments - * Uses `CoolUtil.maxInt` if theres only int arguments * * Might not preserve the order of arguments, please test this. * * Dont use this in hscript, it doesnt work, it only works on compile time **/ @:dox(hide) public static macro function maxSmart(..._args:Expr):Expr { - return genericMinMaxSmart(_args.toArray(), true); + return genericMinMaxSmart(_args.toArray(), "Math.max"); } /** * Shortcut to `Math.min` but with infinite amount of arguments - * Uses `CoolUtil.minInt` if theres only int arguments * * Might not preserve the order of arguments, please test this. * * Dont use this in hscript, it doesnt work, it only works on compile time **/ @:dox(hide) public static macro function minSmart(..._args:Expr):Expr { - return genericMinMaxSmart(_args.toArray(), false); + return genericMinMaxSmart(_args.toArray(), "Math.min"); } #if macro - @:dox(hide) private static function genericMinMaxSmart(_args:Array, isMax:Bool):Expr { + @:dox(hide) private static function genericMinMaxSmart(_args:Array, funcPath:String):Expr { var args = _args.copy(); if (args.length == 0) return macro 0; - var isFloat = true; - var isInt = true; - - for(arg in args) { - if(isInt) - isInt = arg.expr.match(EConst(CInt(_))); - if(isFloat) - isFloat = arg.expr.match(EConst(CFloat(_))); - } - - var funcPath = isInt ? "funkin.backend.utils.CoolUtil.maxInt" : "Math.max"; - if (!isMax) funcPath = isInt ? "funkin.backend.utils.CoolUtil.minInt" : "Math.min"; - var func = funcPath.split("."); function nested(lst:Array):Expr {