diff --git a/src/Autopilot/autopilot.cxx b/src/Autopilot/autopilot.cxx index 089789d67..e8bb91b02 100644 --- a/src/Autopilot/autopilot.cxx +++ b/src/Autopilot/autopilot.cxx @@ -97,7 +97,7 @@ void Autopilot::add_component( Component * component ) std::string name = component->get_name(); for( unsigned i = 0; get_subsystem( name.c_str() ) != NULL; i++ ) { ostringstream buf; - buf << name << "_" << i; + buf << component->get_name() << "_" << i; name = buf.str(); } if( name != component->get_name() ) diff --git a/src/Autopilot/autopilotgroup.cxx b/src/Autopilot/autopilotgroup.cxx index 59d630800..347a39e0e 100644 --- a/src/Autopilot/autopilotgroup.cxx +++ b/src/Autopilot/autopilotgroup.cxx @@ -78,6 +78,9 @@ void FGXMLAutopilotGroupImplementation::init() }; for( unsigned i = 0; i < sizeof(nodeNames)/sizeof(nodeNames[0]); i++ ) initFrom( fgGetNode( "/sim/systems" ), nodeNames[i] ); + + SGSubsystemGroup::bind(); + SGSubsystemGroup::init(); } void FGXMLAutopilotGroupImplementation::initFrom( SGPropertyNode_ptr rootNode, const char * childName ) @@ -108,7 +111,7 @@ void FGXMLAutopilotGroupImplementation::initFrom( SGPropertyNode_ptr rootNode, c string name = apName; for( unsigned i = 0; get_subsystem( apName.c_str() ) != NULL; i++ ) { ostringstream buf; - buf << apName << "_" << i; + buf << name << "_" << i; apName = buf.str(); } if( apName != name ) @@ -135,9 +138,6 @@ void FGXMLAutopilotGroupImplementation::initFrom( SGPropertyNode_ptr rootNode, c continue; } } - - SGSubsystemGroup::bind(); - SGSubsystemGroup::init(); } FGXMLAutopilotGroup * FGXMLAutopilotGroup::createInstance()