Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
[Changelog v0.14.3]

>[!NOTE]
> Feedback from users with consecutive SID letters welcome to validate proper matching
> e.g. WERRA vs WERA / PAZZE vs PAZE

:new: **New Features**
* FPLN - temporarily added scratch pad info which callsign used the sync command
* CONF - collapsing SID or TRANS base when consecutive characters are the same as new Navigraph data collapses those names which are then present in the sector file (#358)

:gear: **Changed Features / Behaviour**
* GEN - changed topsky and ccams lookup check to lower case
* FPLN - added checks to _CTL_ and _AUTO_ scratch pad entries to not trigger sync queue processing
* FPLN - moved clearance flag sync release to flight plan data update

:lady_beetle: **Fixes**
* CONF - fixed a crash when SID health check was triggered for different SID numbers due to an accidentally wrong type assignment

[Changelog v0.14.2]

:new: **New Features**
Expand Down
24 changes: 24 additions & 0 deletions sid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,30 @@ bool vsid::Sid::empty() const
return base == "";
}

bool vsid::Sid::collapsedBaseMatch(std::string_view other, std::optional<std::string_view> trans)
{
std::string collapsed;
std::string_view s;

if (!trans)
{
collapsed.reserve(this->base.size());
s = this->base;
}
else
{
collapsed.reserve(trans.value().size());
s = trans.value();
}

for (char c : s)
{
if (collapsed.empty() || collapsed.back() != c) collapsed.push_back(c);
}

return collapsed == other;
}

bool vsid::Sid::operator==(const Sid& sid)
{
if (this->designator != "")
Expand Down
14 changes: 13 additions & 1 deletion sid.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <string>
#include <map>
#include <vector>
#include <optional>

namespace vsid
{
Expand Down Expand Up @@ -128,7 +129,18 @@ namespace vsid
*/
bool empty() const;

bool isExactly(const vsid::Sid& other) const;
//************************************
// Description: Collapses sid / trans bases with consecutive letters for a match
// Method: collapsedBaseMatch
// FullName: vsid::Sid::collapsedBaseMatch
// Access: public
// Returns: bool
// Qualifier:
// Parameter: std::string_view other - the other string to compare to (usually from .ese file)
// Parameter: std::optional<std::string_view> trans - as multiple transitions can be held it has to be specified
// for the check, if nullopt the sid base is checked
//************************************
bool collapsedBaseMatch(std::string_view other, std::optional<std::string_view> trans = std::nullopt);
/**
* @brief Compares if two SIDs are the same
*
Expand Down
59 changes: 54 additions & 5 deletions vSIDPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4978,7 +4978,23 @@ void vsid::VSIDPlugin::UpdateActiveAirports()

for (vsid::Sid& sid : this->activeAirports[sectionSid.apt].sids)
{
if (sid.base != sectionSid.base) continue;
if (sid.base != sectionSid.base)
{
// skip unmatching first two char comparison (filter)
if (sid.base.length() > 2 && sectionSid.base.length() > 2)
{
if (sid.base[0] != sectionSid.base[0]) continue;
if (sid.base[1] != sectionSid.base[1]) continue;
if (sid.base[2] != sectionSid.base[2]) continue;
}

if (!sid.collapsedBaseMatch(sectionSid.base))
{
messageHandler->writeMessage("DEBUG", "[" + sid.base + "] sid collapsed didn't match [" + sectionSid.base + "]", vsid::MessageHandler::DebugArea::Dev);
continue;
}
else messageHandler->writeMessage("DEBUG", "[" + sid.base + "] sid collapsed matched [" + sectionSid.base + "]", vsid::MessageHandler::DebugArea::Dev);
}
if (sid.designator != (sectionSid.desig ? std::string(1, *sectionSid.desig) : "")) continue;
if (!vsid::utils::contains(sid.rwys, sectionSid.rwy)) continue;

Expand All @@ -5003,7 +5019,24 @@ void vsid::VSIDPlugin::UpdateActiveAirports()
}
else if (sid.number != "") // health check for possible errors in .ese config
{
int currNumber = std::stoi(sid.number);
int currNumber = -1;

try
{
currNumber = std::stoi(sid.number); // #dev - removed int -> debugging
}
catch (const std::invalid_argument& e)
{
messageHandler->writeMessage("ERROR", "Collapsing SID [" + sid.idName() + "] caused an error while collapsing base for section SID [" +
sectionSid.base + "]. Error: " + e.what());
}
catch (const std::out_of_range& e)
{
messageHandler->writeMessage("ERROR", "Collapsing SID [" + sid.idName() + "] caused an error while collapsing base for section SID [" +
sectionSid.base + "]. Error: " + e.what());
}
if (currNumber == -1) continue;

int newNumber = sectionSid.number - '0';

if (currNumber > newNumber || (currNumber == 1 && newNumber == 9))
Expand All @@ -5018,15 +5051,15 @@ void vsid::VSIDPlugin::UpdateActiveAirports()
std::to_string(currNumber) + " (ID: " + sid.id + "). Now found additional number: " + std::to_string(newNumber) +
" - (Runway: " + sectionSid.rwy + ") . Setting additional number (is higher or after restarting count) due to possible sectore file error!");

sid.number = newNumber;
sid.number = std::to_string(newNumber);
}
else if (currNumber != newNumber)
{
messageHandler->writeMessage("WARNING", "[" + sectionSid.apt + "] Check your .ese-file for " + sid.base + "?" + sid.designator + " SID! Already set number: " +
std::to_string(currNumber) + " (ID: " + sid.id + "). Now found additional number: " + std::to_string(newNumber) +
" - (Runway: " + sectionSid.rwy + ") . Setting additional number as it couldn't be determined which one is more likely to be correct!");

sid.number = newNumber;
sid.number = std::to_string(newNumber);
}
}

Expand All @@ -5039,7 +5072,23 @@ void vsid::VSIDPlugin::UpdateActiveAirports()

for (auto& [transBase, trans] : sid.transition)
{
if (transBase != sectionSid.trans.base) continue;
if (transBase != sectionSid.trans.base)
{
// skip unmatching first two char comparison (filter)
if (transBase.length() > 2 && sectionSid.trans.base.length() > 2)
{
if (transBase[0] != sectionSid.trans.base[0]) continue;
if (transBase[1] != sectionSid.trans.base[1]) continue;
if (transBase[2] != sectionSid.trans.base[2]) continue;
}

if (!sid.collapsedBaseMatch(sectionSid.trans.base, transBase))
{
messageHandler->writeMessage("DEBUG", "[" + transBase + "] trans collapsed didn't match [" + sectionSid.trans.base + "]", vsid::MessageHandler::DebugArea::Dev);
continue;
}
else messageHandler->writeMessage("DEBUG", "[" + transBase + "] trans collapsed matched [" + sectionSid.trans.base + "]", vsid::MessageHandler::DebugArea::Dev);
}
if (trans.designator != (sectionSid.trans.desig ? std::string(1, *sectionSid.trans.desig) : "")) continue;
if (trans.number != "") // #refactor .number to char
{
Expand Down