Curtis L. Olson wwrites:

> David Megginson writes:
> > Curtis L. Olson writes:
> >
> >  > The preferences.xml file specifies the c172 as the default.  It
> >  > appears that even if you request a different aircraft as the default,
> >  > the c172 config files get loaded first anyway, then the alternate
> >  > config file is loaded with the correct aircraft.  This means that if
> >  > the c172 specifies any defaults such as aileron trim that isn't
> >  > specified in the desired aircraft config, it will inherit the c172
> >  > settings (i.e. they won't get overwritten, unless done so
> >  > explicitely.)
> >  >
> >  > Is this what we want the behavior to be?
> >
> > No.
>
> Ok, good to know.
>
> >  > I'm guessing it got this way for a reason, but I'm not sure we want
> >  > things to act this way.
> >
> > It's almost certainly an initialization-order problem.  We want the
> > aircraft settings to take precedence over preferences.xml and the
> > command-line options to take precedence over the aircraft settings.
> > Feel free to fix it, if you can think of a way to.
>
> I haven't actually looked into it beyond observing that an addition to
> the c172-set.xml file shows up no matter what aircraft I choose.  So,
> I haven't dug into the code at all to see what is actually going on.

Hmm... maybe this would help
untested - but it 'looks' like this will fix 'this' problem,
don't thin it will cause any new ones

// Read in configuration (file and command line)
bool fgInitConfig ( int argc, char **argv ) {

    // First, set some sane default values
    fgSetDefaults();

    // Read global preferences from $FG_ROOT/preferences.xml
    SGPath props_path(globals->get_fg_root());
    props_path.append("preferences.xml");
    SG_LOG(SG_INPUT, SG_INFO, "Reading global preferences");
    readProperties(props_path.str(), globals->get_props());
    SG_LOG(SG_INPUT, SG_INFO, "Finished Reading global preferences");

    // Attempt to locate and parse the various config files in order
    // from least precidence to greatest precidence

    // Check for $fg_root/system.fgfsrc
    SGPath config( globals->get_fg_root() );
    config.append( "system.fgfsrc" );
    fgParseOptions(config.str());

#if defined( unix ) || defined( __CYGWIN__ )
    char name[256];
    // Check for $fg_root/system.fgfsrc.hostname
    gethostname( name, 256 );
    config.concat( "." );
    config.concat( name );
    fgParseOptions(config.str());
#endif

    // Check for ~/.fgfsrc
    char* envp = ::getenv( "HOME" );
    if ( envp != NULL ) {
 config.set( envp );
 config.append( ".fgfsrc" );
 fgParseOptions(config.str());
    }

#if defined( unix ) || defined( __CYGWIN__ )
    // Check for ~/.fgfsrc.hostname
    gethostname( name, 256 );
    config.concat( "." );
    config.concat( name );
    fgParseOptions(config.str());
#endif

    // Parse remaining command line options
    // These will override anything specified in a config file
    fgParseArgs(argc, argv);

    // Read the default aircraft config file.
    string aircraft = fgGetString("/sim/aircraft", "");
    if (aircraft.size() > 0) {
        SGPath aircraft_path(globals->get_fg_root());
        aircraft_path.append("Aircraft");
        aircraft_path.append(aircraft);
        aircraft_path.concat("-set.xml");
        SG_LOG(SG_INPUT, SG_INFO, "Reading default aircraft: " << aircraft
               << " from " << aircraft_path.str());
        try {
            readProperties(aircraft_path.str(), globals->get_props());
        } catch (const sg_exception &e) {
            string message = "Error reading default aircraft: ";
            message += e.getFormattedMessage();
            SG_LOG(SG_INPUT, SG_ALERT, message);
            exit(2);
        }
    } else {
        SG_LOG(SG_INPUT, SG_ALERT, "No default aircraft specified");
    }

    return true;
}






_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to