From 7c2a5e9e99118f2b9aa0f90e01d4ba4caa53f54e Mon Sep 17 00:00:00 2001 From: James Turner Date: Sun, 24 Mar 2019 17:59:23 +0000 Subject: [PATCH] FlightGear support for queued commands This enables queued commands to be processed once per main event loop. At present this is done after subsystem updates. --- src/Main/fg_commands.cxx | 4 ++++ src/Main/fg_init.cxx | 3 +++ src/Main/main.cxx | 5 ++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx index cc8ad6732..ff8c057ec 100644 --- a/src/Main/fg_commands.cxx +++ b/src/Main/fg_commands.cxx @@ -970,6 +970,10 @@ static struct { void fgInitCommands () { + // set our property root as the implicit default root for the + // command managr + SGCommandMgr::instance()->setImplicitRoot(globals->get_props()); + SG_LOG(SG_GENERAL, SG_BULK, "Initializing basic built-in commands:"); for (int i = 0; built_ins[i].name != 0; i++) { SG_LOG(SG_GENERAL, SG_BULK, " " << built_ins[i].name); diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index b60739c0f..9d1d65dda 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -1194,6 +1194,9 @@ void fgStartNewReset() fgInitConfig(0, NULL, true); fgInitGeneral(); // all of this? + // set out new property root on the command manager + SGCommandMgr::instance()->setImplicitRoot(globals->get_props()); + flightgear::Options::sharedInstance()->processOptions(); // Rebuild the lists of allowed paths for cases where a path comes from an diff --git a/src/Main/main.cxx b/src/Main/main.cxx index f98dc4c36..b0a0dbcd0 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -55,6 +55,7 @@ extern bool global_crashRptEnabled; #include #include #include +#include #include #include
@@ -122,6 +123,8 @@ static void fgMainLoop( void ) // update all subsystems globals->get_subsystem_mgr()->update(sim_dt); + // flush commands waiting in the queue + SGCommandMgr::instance()->executedQueuedCommands(); simgear::AtomicChangeListener::fireChangeListeners(); } @@ -290,7 +293,7 @@ static void fgIdleFunction ( void ) { // Initialize the property-based built-in commands //////////////////////////////////////////////////////////////////// fgInitCommands(); - fgInitSceneCommands(); + fgInitSceneCommands(); flightgear::registerSubsystemCommands(globals->get_commands());