- FGPath path( globals->get_fg_root() );
- path.append( "Airports" );
- path.append( "simple.mk4" );
- FGAirports airports( path.c_str() );
-
- FGAirport a;
-
- int freeze = globals->get_freeze();
- if(!freeze)
- globals->set_freeze( true );
-
- char *s;
- AptDialogInput->getValue(&s);
- string AptId(s);
-
- cout << "AptDialog_OK " << AptId << " " << AptId.length() << endl;
-
- AptDialog_Cancel( NULL );
-
- if ( AptId.length() ) {
- // set initial position from airport id
- SG_LOG( SG_GENERAL, SG_INFO,
- "Attempting to set starting position from airport code "
- << AptId );
-
- if ( airports.search( AptId, &a ) )
- {
- fgSetString("/sim/startup/airport-id", AptId.c_str() );
- // fgSetDouble("/position/altitude", -9999.0 );
- // fgSetPosFromAirportID( AptId );
- fgSetPosFromAirportIDandHdg( AptId,
- cur_fdm_state->get_Psi() *
- SGD_RADIANS_TO_DEGREES);
- BusyCursor(0);
- fgReInitSubsystems();
- BusyCursor(1);
- } else {
- AptId += " not in database.";
- mkDialog(AptId.c_str());
- }
- }
- if(!freeze)
- globals->set_freeze( false );
+ static const SGPropertyNode *longitude
+ = fgGetNode("/position/longitude-deg");
+ static const SGPropertyNode *latitude
+ = fgGetNode("/position/latitude-deg");
+
+ SGPath path( globals->get_fg_root() );
+ path.append( "Airports" );
+ path.append( "simple.mk4" );
+ FGAirports airports( path.c_str() );
+
+ FGAirport a;
+
+ int freeze = globals->get_freeze();
+ if(!freeze)
+ globals->set_freeze( true );
+
+ char *s;
+ AptDialogInput->getValue(&s);
+ string AptId(s);
+
+ cout << "AptDialog_OK " << AptId << " " << AptId.length() << endl;
+
+ AptDialog_Cancel( NULL );
+
+ if ( AptId.length() ) {
+ // set initial position from airport id
+ SG_LOG( SG_GENERAL, SG_INFO,
+ "Attempting to set starting position from airport code "
+ << AptId );
+
+ if ( airports.search( AptId, &a ) )
+ {
+ // unbind the current fdm state so property changes
+ // don't get lost when we subsequently delete this fdm
+ // and create a new one.
+ cur_fdm_state->unbind();
+
+ AptId = a.id.c_str(); /// NHV fix wrong case crash
+ fgSetString("/sim/startup/airport-id", AptId.c_str() );
+ // fgSetDouble("/position/altitude-ft", -9999.0 );
+ // fgSetPosFromAirportID( AptId );
+ fgSetPosFromAirportIDandHdg( AptId,
+ cur_fdm_state->get_Psi() *
+ SGD_RADIANS_TO_DEGREES);
+ // BusyCursor(0);
+ fgReInitSubsystems();
+ // if ( global_tile_mgr.init() ) {
+ // Load the local scenery data
+ global_tile_mgr.update( longitude->getDoubleValue(),
+ latitude->getDoubleValue() );
+ // } else {
+ // SG_LOG( SG_GENERAL, SG_ALERT,
+ // "Error in Tile Manager initialization!" );
+ // exit(-1);
+ // }
+ // BusyCursor(1);
+ } else {
+ AptId += " not in database.";
+ mkDialog(AptId.c_str());
+ }
+ }
+ if ( !freeze ) {
+ globals->set_freeze( false );
+ }