From 0f00b806a74027d71a3e758bbb1e177e4b6130f2 Mon Sep 17 00:00:00 2001 From: Sean McLeod Date: Sat, 12 Oct 2024 12:59:11 +0200 Subject: [PATCH] Simplify code slightly in roundmultiple (#1172) --- src/math/FGFunction.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/math/FGFunction.cpp b/src/math/FGFunction.cpp index d0ac0fa33f..8b06bc5293 100644 --- a/src/math/FGFunction.cpp +++ b/src/math/FGFunction.cpp @@ -528,14 +528,15 @@ void FGFunction::Load(Element* el, FGPropertyValue* var, FGFDMExec* fdmex, }; Parameters.push_back(new aFunc(f, fdmex, element, Prefix, var)); } else if (operation == "roundmultiple") { - auto f = [](const decltype(Parameters)& p)->double { - double multiple = p.size() == 1 ? 1.0 : p[1]->GetValue(); - return round((p[0]->GetValue() / multiple)) * multiple; - }; if (element->GetNumElements() == 1) Parameters.push_back(make_MathFn(round, fdmex, element, Prefix, var)); - else + else { + auto f = [](const decltype(Parameters)& p)->double { + double multiple = p[1]->GetValue(); + return round((p[0]->GetValue() / multiple)) * multiple; + }; Parameters.push_back(new aFunc(f, fdmex, element, Prefix, var, 2)); + } } else if (operation == "atan2") { auto f = [](const decltype(Parameters)& p)->double { return atan2(p[0]->GetValue(), p[1]->GetValue());