From d6dc179df73a4f38a29185bc9b4a2319fd8cd06d Mon Sep 17 00:00:00 2001 From: NovaRain Date: Sun, 12 May 2024 13:53:45 +0800 Subject: [PATCH] Removed duplicate implementation in round() script function * C++11 lroundf can do the same thing. --- sfall/Modules/Scripting/Handlers/Math.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/sfall/Modules/Scripting/Handlers/Math.cpp b/sfall/Modules/Scripting/Handlers/Math.cpp index ca6eb1f1..9d481ef0 100644 --- a/sfall/Modules/Scripting/Handlers/Math.cpp +++ b/sfall/Modules/Scripting/Handlers/Math.cpp @@ -96,12 +96,7 @@ void op_ceil(OpcodeContext& ctx) { } void op_round(OpcodeContext& ctx) { - float arg = ctx.arg(0).asFloat(); - - int argI = static_cast(arg); - float mod = arg - static_cast(argI); - if (abs(mod) >= 0.5) argI += (mod > 0 ? 1 : -1); - ctx.setReturn(argI); + ctx.setReturn(lroundf(ctx.arg(0).asFloat())); } void mf_floor2(OpcodeContext& ctx) {