Skip to content

Commit

Permalink
correct float compare
Browse files Browse the repository at this point in the history
found below log shows NAV1 actually is no changing at all

 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4
 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4
 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4
 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4
 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4
 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4
 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4
 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4
 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4
 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4
 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4
 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4
 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4
 MobiFlight[Client_328838310]: SimVar (A:NAV ACTIVE FREQUENCY:1,MHz) with ID 21056 has value 108.4
  • Loading branch information
cpuwolf committed Mar 15, 2024
1 parent 27254a7 commit ac04712
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Sources/Code/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,11 @@ void ReadSimVarFloat(ReadRPNCode &rpn) {
execute_calculator_code(std::string(rpn.Code).c_str(), &floatVal, nullptr, nullptr);

for (auto& simVar : rpn.SimVars) {
if (simVar.Value == floatVal) continue;
if ((simVar.Value > floatVal) && (simVar.Value - floatVal < 0.00001F)) {
continue;
} else if ((simVar.Value < floatVal) && (floatVal - simVar.Value < 0.00001F)) {
continue;
}
simVar.Value = floatVal;

WriteSimVar(simVar, simVar.clint);
Expand Down

0 comments on commit ac04712

Please sign in to comment.