]> git.mxchange.org Git - flightgear.git/blobdiff - src/Autopilot/autopilot.cxx
Fix bug 191, uninitialised HUD color.
[flightgear.git] / src / Autopilot / autopilot.cxx
index d37c38d7db00b1f9b060a566429c37f26c4478b9..e8bb91b02bc857bf090267e962e67e2dc8d8f135 100644 (file)
@@ -93,11 +93,16 @@ void Autopilot::add_component( Component * component )
 {
   if( component == NULL ) return;
 
+  // check for duplicate name
   std::string name = component->get_name();
-  if( get_subsystem( name.c_str() ) != NULL ) {
-    SG_LOG( SG_ALL, SG_ALERT, "Duplicate autopilot component " << name << " ignored" );
-    return;
+  for( unsigned i = 0; get_subsystem( name.c_str() ) != NULL; i++ ) {
+      ostringstream buf;
+      buf <<  component->get_name() << "_" << i;
+      name = buf.str();
   }
+  if( name != component->get_name() )
+    SG_LOG( SG_ALL, SG_WARN, "Duplicate autopilot component " << component->get_name() << ", renamed to " << name );
+
   set_subsystem( name.c_str(), component );
 }