From d26cf7db713c352a9465c875d80b221cc2cfd897 Mon Sep 17 00:00:00 2001 From: Justin Wai Date: Sun, 14 Jul 2024 21:01:35 +0800 Subject: [PATCH] Edit missed approach alarm scratchpad behaviour * Immediately clear message strings to avoid clogging space --- MissedApproach/MissedApproachAlarm.cpp | 7 +++++-- MissedApproach/MissedApproachPlugin.cpp | 25 +++++++++++++------------ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/MissedApproach/MissedApproachAlarm.cpp b/MissedApproach/MissedApproachAlarm.cpp index bf5fbda7..0a258417 100644 --- a/MissedApproach/MissedApproachAlarm.cpp +++ b/MissedApproach/MissedApproachAlarm.cpp @@ -461,9 +461,10 @@ void MissedApproachAlarm::OnFlightPlanControllerAssignedDataUpdate(CFlightPlan F MissedApproachPlugin ma; CFlightPlanData data = FlightPlan.GetFlightPlanData(); CFlightPlanControllerAssignedData controllerData = FlightPlan.GetControllerAssignedData(); + string scratchPadString = controllerData.GetScratchPadString(); //Filter from scratchpad message - if (strstr(controllerData.GetScratchPadString(), "\\MISS") == NULL) return; + if (scratchPadString.find("MISAP_") == string::npos) return; //Handle tower case first if (!selectedAcftData.empty()) { @@ -476,7 +477,9 @@ void MissedApproachAlarm::OnFlightPlanControllerAssignedDataUpdate(CFlightPlan F //Don't add to vector unless runway is selected and active if (find(activeMAPPRunways.begin(), activeMAPPRunways.end(), data.GetArrivalRwy()) == activeMAPPRunways.end()) return; - missedAcftData.push_back(FlightPlan.GetCallsign()); + scratchPadString.erase(0, strlen("MISAP_")); + controllerData.SetScratchPadString(scratchPadString.c_str()); +; missedAcftData.push_back(FlightPlan.GetCallsign()); missedAcftData.push_back(data.GetDestination()); missedAcftData.push_back(data.GetArrivalRwy()); } diff --git a/MissedApproach/MissedApproachPlugin.cpp b/MissedApproach/MissedApproachPlugin.cpp index 09e55cfd..e23c84ec 100644 --- a/MissedApproach/MissedApproachPlugin.cpp +++ b/MissedApproach/MissedApproachPlugin.cpp @@ -40,7 +40,7 @@ void MissedApproachPlugin::initMissedApproach(const char* callsign) { data = fpl.GetFlightPlanData(); controllerData = fpl.GetControllerAssignedData(); string buf = controllerData.GetScratchPadString(); - buf.append("\\MISS"); + buf.insert(0, "MISAP_"); controllerData.SetScratchPadString(buf.c_str()); } @@ -53,11 +53,9 @@ void MissedApproachPlugin::ackMissedApproach(const char* callsign) { controllerData = fpl.GetControllerAssignedData(); string buf = controllerData.GetScratchPadString(); - if (buf.find("\\MISS") != string::npos) { - buf.append("\\ACK\\"); - buf.append(myself.GetPositionId()); - controllerData.SetScratchPadString(buf.c_str()); - } + buf.append("MISAP-ACK_"); + buf.append(myself.GetPositionId()); + controllerData.SetScratchPadString(buf.c_str()); //couldn't find it, handle error } @@ -69,15 +67,15 @@ void MissedApproachPlugin::resetMissedApproach(const char* callsign) { controllerData = fpl.GetControllerAssignedData(); string buf = controllerData.GetScratchPadString(); size_t index; - string miss = "\\MISS"; - string ack = "\\ACK"; + string miss = "MISAP_"; + string ack = "ACK_"; index = buf.find(miss); if (index != string::npos) { buf.erase(index, miss.length()); } index = buf.find(ack); if (index != string::npos) { - buf.erase(index, ack.length()+4); + buf.erase(index, ack.length()+3); } controllerData.SetScratchPadString(buf.c_str()); //couldn't find it, handle error @@ -121,10 +119,13 @@ bool MissedApproachPlugin::matchArrivalAirport(const char* arrivalArpt) { const char* MissedApproachPlugin::checkForAck(const char* callsign) { CFlightPlanControllerAssignedData controllerData = FlightPlanSelect(callsign).GetControllerAssignedData(); - const char* ptr = strstr(controllerData.GetScratchPadString(), "\\MISS\\ACK\\"); + const char* ptr = strstr(controllerData.GetScratchPadString(), "MISAP-ACK_"); if (ptr != NULL) { - ptr = ptr + strlen("\\MISS\\ACK\\"); - return (ptr != NULL && strlen(ptr) == 3) ? ptr : "???"; + string scratchPadString = ptr; + ptr = ptr + strlen("MISAP-ACK_"); + scratchPadString.erase(0, strlen("MISAP-ACK_AP")); + controllerData.SetScratchPadString(scratchPadString.c_str()); + return (ptr != NULL && strlen(ptr) == 3) ? ptr : "??"; } return NULL; }