mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
T37 Avoid division by zero in case time offset is zero.
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "blackmisc/pq/units.h"
|
||||
#include "blackmisc/pq/length.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/verify.h"
|
||||
#include <QDateTime>
|
||||
#include <QStringBuilder>
|
||||
|
||||
@@ -228,6 +229,10 @@ namespace BlackMisc
|
||||
Q_ASSERT(secondsSinceTakeoff >= 0.0);
|
||||
Q_ASSERT(secondsUntilLanding >= 0.0);
|
||||
|
||||
//! \fixme In future, will we need to be able to support time offsets of zero?
|
||||
BLACK_VERIFY(predictableFutureSecs != 0);
|
||||
if (predictableFutureSecs == 0) { break; } // avoid divide by zero
|
||||
|
||||
const double takeoffFactor = secondsSinceTakeoff / significantPastSecs;
|
||||
const double landingFactor = secondsUntilLanding / predictableFutureSecs;
|
||||
const double airborneFactor = std::min(std::min(takeoffFactor, landingFactor), 1.0);
|
||||
|
||||
Reference in New Issue
Block a user