From bf8f56bda81bbf5f20de5ec6769c8f94485b619b Mon Sep 17 00:00:00 2001 From: TwinFan Date: Wed, 17 Jan 2024 00:37:34 +0100 Subject: [PATCH] Update/XPMP2: relOp.txt, Multicast across interfaces --- CMakeLists.txt | 2 +- XPMP2-Remote.xcodeproj/project.pbxproj | 4 ++-- .../xcshareddata/xcschemes/XPMP2.xcscheme | 4 ++++ lib/XPMP2 | 2 +- src/Client.cpp | 10 +++----- src/XPMP2-Remote.cpp | 23 +++++++++++++++++-- 6 files changed, 32 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 36439c6..7da2b9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ else() endif() project(XPMP2RemoteClient - VERSION 3.1.0 + VERSION 3.4.0 DESCRIPTION "XPMP2-Remote client plugin for X-Plane") # Provide compile macros from the above project version definition diff --git a/XPMP2-Remote.xcodeproj/project.pbxproj b/XPMP2-Remote.xcodeproj/project.pbxproj index 9b495be..01d2773 100644 --- a/XPMP2-Remote.xcodeproj/project.pbxproj +++ b/XPMP2-Remote.xcodeproj/project.pbxproj @@ -363,7 +363,7 @@ ); XPLANE11_ROOT = "$(USER_APPS_DIR)/X-Plane/11"; XPMP2_RC_VER_MAJOR = 3; - XPMP2_RC_VER_MINOR = 1; + XPMP2_RC_VER_MINOR = 4; XPMP2_RC_VER_PATCH = 0; XPSDK_ROOT = lib/XPMP2/lib/SDK; }; @@ -472,7 +472,7 @@ ); XPLANE11_ROOT = "$(USER_APPS_DIR)/X-Plane/11"; XPMP2_RC_VER_MAJOR = 3; - XPMP2_RC_VER_MINOR = 1; + XPMP2_RC_VER_MINOR = 4; XPMP2_RC_VER_PATCH = 0; XPSDK_ROOT = lib/XPMP2/lib/SDK; }; diff --git a/XPMP2-Remote.xcodeproj/xcshareddata/xcschemes/XPMP2.xcscheme b/XPMP2-Remote.xcodeproj/xcshareddata/xcschemes/XPMP2.xcscheme index 2b2d96d..d8d6621 100644 --- a/XPMP2-Remote.xcodeproj/xcshareddata/xcschemes/XPMP2.xcscheme +++ b/XPMP2-Remote.xcodeproj/xcshareddata/xcschemes/XPMP2.xcscheme @@ -68,6 +68,10 @@ debugDocumentVersioning = "YES" debugServiceExtension = "internal" allowLocationSimulation = "YES"> + + 0 || - XPMP2::RemoteGetStatus() == XPMP2::REMOTE_OFF) + (nForce == 0 && XPMP2::RemoteGetStatus() == XPMP2::REMOTE_OFF)) { - // Try already to get TCAS control so we have it before others can snatch it away. - // This is not in accordance with what is laid out in "TCAS Override" - // https://developer.x-plane.com/article/overriding-tcas-and-providing-traffic-information/#Plugin_coordination - // but we serve a good deed here: We can combine several plugins' TCAS needs, - // but only if we are in control: + // Try (potentially again) to get AI control ClientTryGetAI(); // Start the listener to receive message @@ -626,7 +622,7 @@ void ClientToggleActive (int nForce) } // Need to stop? else if (nForce < 0 || - XPMP2::RemoteGetStatus() != XPMP2::REMOTE_OFF) + (nForce == 0 && XPMP2::RemoteGetStatus() != XPMP2::REMOTE_OFF)) { // Release the data access lock, just a safety measure so that we don't hinder shutdown in case we f--- up try { glockDataMain.unlock(); } diff --git a/src/XPMP2-Remote.cpp b/src/XPMP2-Remote.cpp index 0b83521..46c7b4c 100644 --- a/src/XPMP2-Remote.cpp +++ b/src/XPMP2-Remote.cpp @@ -258,6 +258,8 @@ void MenuLabelsCB (void* /*inMenuRef*/, void* inItemRef) /// ID of our flight loop callback for regular tasks XPLMFlightLoopID flId = nullptr; +/// Flag to perform one-time init in flight loop +static bool bDoOneTimeInit = false; /// Regular tasks, called by flight loop float FlightLoopCallback(float, float, int, void*) @@ -265,6 +267,16 @@ float FlightLoopCallback(float, float, int, void*) // entry point into plugin...catch exceptions latest here try { GetMiscNetwTime(); // update rcGlob.now, e.g. for logging from worker threads + + // --- One Time Init + if (bDoOneTimeInit) { + bDoOneTimeInit = false; + // Activate the listener + ClientToggleActive(); + } + + // --- Regular Tasks + // if there aren't any planes yet then the XPMP2 library won't call ClientFlightLoopBegins(), instead we do if (XPMPCountPlanes() == 0) { try { @@ -403,8 +415,15 @@ PLUGIN_API int XPluginEnable(void) flId = XPLMCreateFlightLoop(&flParams); XPLMScheduleFlightLoop(flId, 1.0f, true); - // Activate the listener - ClientToggleActive(); + // Try already to get TCAS control so we have it before others can snatch it away. + // This is not in accordance with what is laid out in "TCAS Override" + // https://developer.x-plane.com/article/overriding-tcas-and-providing-traffic-information/#Plugin_coordination + // but we serve a good deed here: We can combine several plugins' TCAS needs, + // but only if we are in control: + ClientTryGetAI(); + + // Activate the listener in the first flight loop callback + bDoOneTimeInit = true; MenuUpdateCheckmarks(); // Success