From 92010f9f9483082bbf83638a49e08053f53c5daa Mon Sep 17 00:00:00 2001 From: curt <curt> Date: Fri, 2 Apr 2004 01:54:38 +0000 Subject: [PATCH] Clean up a couple bugs in the multiengine handling of the net_fdm.hxx external interface. --- src/Network/atc610x.cxx | 4 ++++ src/Network/native_ctrls.cxx | 23 ++++++++++++++++------- src/Network/native_fdm.cxx | 6 +++--- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/Network/atc610x.cxx b/src/Network/atc610x.cxx index e0111eb28..5720972fb 100644 --- a/src/Network/atc610x.cxx +++ b/src/Network/atc610x.cxx @@ -1801,6 +1801,7 @@ bool FGATC610x::do_switches() { mag1 = magnetos; if ( mag1 == mag2 && mag2 == mag3 ) { fgSetInt( "/controls/engines/engine[0]/magnetos", magnetos ); + fgSetInt( "/controls/engines/engine[1]/magnetos", magnetos ); } static bool start1, start2, start3; start3 = start2; @@ -1808,12 +1809,15 @@ bool FGATC610x::do_switches() { start1 = starter; if ( start1 == start2 && start2 == start3 ) { fgSetBool( "/controls/engines/engine[0]/starter", starter ); + fgSetBool( "/controls/engines/engine[1]/starter", starter ); } } // other toggle switches fgSetBool( "/controls/engines/engine[0]/fuel-pump", switch_matrix[board][0][2] ); + fgSetBool( "/controls/engines/engine[1]/fuel-pump", + switch_matrix[board][0][2] ); fgSetBool( "/controls/switches/flashing-beacon", switch_matrix[board][1][2] ); fgSetBool( "/controls/switches/landing-light", switch_matrix[board][2][2] ); diff --git a/src/Network/native_ctrls.cxx b/src/Network/native_ctrls.cxx index 5261d339a..ace029444 100644 --- a/src/Network/native_ctrls.cxx +++ b/src/Network/native_ctrls.cxx @@ -103,6 +103,8 @@ void FGProps2NetCtrls( FGNetCtrls *net, bool honor_freezes, { int i; SGPropertyNode *node; + SGPropertyNode *starter; + SGPropertyNode *fuelpump; SGPropertyNode *tempnode; // fill in values @@ -121,7 +123,9 @@ void FGProps2NetCtrls( FGNetCtrls *net, bool honor_freezes, for ( i = 0; i < FGNetCtrls::FG_MAX_ENGINES; ++i ) { // Controls node = fgGetNode("/controls/engines/engine", i ); - net->throttle[i] = node->getDoubleValue( "throttle", 0.0 ); + starter = fgGetNode("/systems/electrical/outputs/starter", i ); + fuelpump = fgGetNode("/systems/electrical/outputs/fuel-pump", i ); + net->throttle[i] = node->getDoubleValue( "throttle", 0.0 ); net->mixture[i] = node->getDoubleValue( "mixture", 0.0 ); net->prop_advance[i] = node->getDoubleValue( "propeller-pitch", 0.0 ); net->magnetos[i] = node->getIntValue( "magnetos", 0 ); @@ -132,13 +136,18 @@ void FGProps2NetCtrls( FGNetCtrls *net, bool honor_freezes, // cout << "Starter -> " << node->getIntValue( "starter", false ) // << endl; } - net->fuel_pump_power[i] - = node->getDoubleValue( "/systems/electrical/outputs/fuel-pump", - 1.0 ) >= 1.0; - net->starter_power[i] - = node->getDoubleValue( "/systems/electrical/outputs/starter", - 1.0 ) >= 1.0; + if ( fuelpump != NULL ) { + net->fuel_pump_power[i] = ( fuelpump->getDoubleValue() >= 1.0 ); + } else { + net->fuel_pump_power[i] = 0.0; + } + + if ( starter != NULL ) { + net->starter_power[i] = ( starter->getDoubleValue() >= 1.0 ); + } else { + net->starter_power[i] = 0.0; + } // Faults SGPropertyNode *faults = node->getChild( "faults", 0, true ); diff --git a/src/Network/native_fdm.cxx b/src/Network/native_fdm.cxx index 58fb2d8a6..c80c41056 100644 --- a/src/Network/native_fdm.cxx +++ b/src/Network/native_fdm.cxx @@ -163,11 +163,11 @@ void FGProps2NetFDM( FGNetFDM *net, bool net_byte_order ) { for ( i = 0; i < net->num_engines; ++i ) { SGPropertyNode *node = fgGetNode("engines/engine", i, true); if ( node->getBoolValue( "running" ) ) { - net->eng_state[0] = 2; + net->eng_state[i] = 2; } else if ( node->getBoolValue( "cranking" ) ) { - net->eng_state[0] = 1; + net->eng_state[i] = 1; } else { - net->eng_state[0] = 0; + net->eng_state[i] = 0; } net->rpm[i] = node->getDoubleValue( "rpm" ); net->fuel_flow[i] = node->getDoubleValue( "fuel-flow-gph" );