From fe26cb8f240276a8c6604c30f040bfdf767f3520 Mon Sep 17 00:00:00 2001 From: earthjasonlin Date: Sun, 8 May 2022 17:55:48 +0800 Subject: [PATCH] fix cleared alt to adapt china rvsm --- TinyEurocat/TinyEurocat.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/TinyEurocat/TinyEurocat.cpp b/TinyEurocat/TinyEurocat.cpp index de88f90..977fe94 100644 --- a/TinyEurocat/TinyEurocat.cpp +++ b/TinyEurocat/TinyEurocat.cpp @@ -30,14 +30,23 @@ void TinyEurocat::OnGetTagItem( CFlightPlan FlightPlan, char tmpstr[15]; case TAG_ITEM_MET_ASS_ALT: maalt = FlightPlan.GetClearedAltitude() * 0.3048; - if (maalt != 0) + if (maalt > 0) { maalt /= 100; - if (maalt % 3 == 1) - maalt -= 1; - else if (maalt % 3 == 2) - maalt += 1; - + if (maalt <= 84) + { + if (maalt % 3 == 1) + maalt -= 1; + else if (maalt % 3 == 2) + maalt += 1; + } + else if (maalt <= 125) + { + if ((maalt + 1) % 3 == 1) + maalt -= 1; + else if ((maalt + 1) % 3 == 2) + maalt += 1; + } itoa(maalt * 10, tmpstr, 10); sprintf(sItemString, "%04s", tmpstr); }