From 77bbca0a163b93b3cb584a78d43cc2476bfc1122 Mon Sep 17 00:00:00 2001 From: Adrien Guinet Date: Tue, 2 Jun 2020 01:53:53 +0200 Subject: [PATCH] ErgFile: fix distance precision issues (#3435) When parsing a "distance slope wind" type, a truncate to integers was done after computation to meters. This involved rounding issues that were accumulated, and were quite visible when such a file was used to synchronized with an RLV video (the slope changes happened "too early"). --- src/Train/ErgFile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Train/ErgFile.cpp b/src/Train/ErgFile.cpp index 9799cb199..22ee62028 100644 --- a/src/Train/ErgFile.cpp +++ b/src/Train/ErgFile.cpp @@ -620,7 +620,7 @@ void ErgFile::parseComputrainer(QString p) // distance guff add.x = rdist; - int distance = absoluteSlope.cap(1).toDouble() * 1000; // convert to meters + double distance = absoluteSlope.cap(1).toDouble() * 1000.; // convert to meters if (!bIsMetric) distance *= KM_PER_MILE; rdist += distance; @@ -628,7 +628,7 @@ void ErgFile::parseComputrainer(QString p) // gradient and altitude add.val = absoluteSlope.cap(2).toDouble(); add.y = ralt; - ralt += distance * add.val / 100; /* paused */ + ralt += distance * add.val / 100.; /* paused */ Points.append(add); if (add.y > MaxWatts) MaxWatts=add.y;