#include <simgear/props/props.hxx>
#include <simgear/structure/event_mgr.hxx>
#include <simgear/sound/soundmgr_openal.hxx>
+#include <simgear/timing/sg_time.hxx>
#include <Cockpit/panel.hxx>
#include <Cockpit/panel_io.hxx>
-#include <Cockpit/hud.hxx>
#include <Environment/environment.hxx>
#include <FDM/flight.hxx>
#include <GUI/gui.h>
#include <GUI/new_gui.hxx>
#include <GUI/dialog.hxx>
#include <Aircraft/replay.hxx>
-#include <Scenery/tilemgr.hxx>
#include <Scenery/scenery.hxx>
#include <Scripting/NasalSys.hxx>
#include <Sound/sample_queue.hxx>
#include <Time/sunsolver.hxx>
-#include <Time/tmp.hxx>
#include "fg_init.hxx"
#include "fg_io.hxx"
SG_LOG(SG_INPUT, SG_DEBUG, "Finished Saving user settings");
}
}
- fgExit(arg->getIntValue("status", 0));
+
+ fgOSExit(arg->getIntValue("status", 0));
return true;
}
static bool
do_reset (const SGPropertyNode * arg)
{
- reInit();
+ doSimulatorReset();
return true;
}
do_panel_load (const SGPropertyNode * arg)
{
string panel_path =
- arg->getStringValue("path",
- fgGetString("/sim/panel/path",
- "Panels/Default/default.xml"));
+ arg->getStringValue("path", fgGetString("/sim/panel/path"));
+ if (panel_path.empty()) {
+ return false;
+ }
+
FGPanel * new_panel = fgReadPanel(panel_path);
if (new_panel == 0) {
SG_LOG(SG_INPUT, SG_ALERT,
return true;
}
-
-static void
-fix_hud_visibility()
-{
- if ( !strcmp(fgGetString("/sim/flight-model"), "ada") ) {
- globals->get_props()->setBoolValue( "/sim/hud/visibility", true );
- if ( globals->get_viewmgr()->get_current() == 1 ) {
- globals->get_props()->setBoolValue( "/sim/hud/visibility", false );
- }
- }
-}
-
static void
do_view_next( bool )
{
globals->get_current_view()->setHeadingOffset_deg(0.0);
globals->get_viewmgr()->next_view();
- fix_hud_visibility();
}
static void
{
globals->get_current_view()->setHeadingOffset_deg(0.0);
globals->get_viewmgr()->prev_view();
- fix_hud_visibility();
}
/**
{
globals->get_current_view()->setHeadingOffset_deg(0.0);
globals->get_viewmgr()->next_view();
- fix_hud_visibility();
return true;
}
return true;
}
+static bool
+do_print_visible_scene_info(const SGPropertyNode*)
+{
+ fgPrintVisibleSceneInfoCommand();
+ return true;
+}
+
/**
* Built-in command: hires capture screen.
*/
if ( !freeze ) {
fgSetBool("/sim/freeze/master", true);
}
- if ( globals->get_tile_mgr()->init() ) {
- // Load the local scenery data
- double visibility_meters = fgGetDouble("/environment/visibility-m");
- globals->get_tile_mgr()->update( visibility_meters );
- } else {
- SG_LOG( SG_GENERAL, SG_ALERT,
- "Error in Tile Manager initialization!" );
- exit(-1);
- }
+
+ globals->get_subsystem("tile-manager")->reinit();
+
if ( !freeze ) {
fgSetBool("/sim/freeze/master", false);
}
* boundary and aloft environment layers.
*/
static bool
-do_set_sea_level_degc (const SGPropertyNode * arg)
+do_set_sea_level_degc ( double temp_sea_level_degc)
{
- double temp_sea_level_degc = arg->getDoubleValue("temp-degc", 15.0);
-
SGPropertyNode *node, *child;
// boundary layers
return true;
}
+static bool
+do_set_sea_level_degc (const SGPropertyNode * arg)
+{
+ return do_set_sea_level_degc( arg->getDoubleValue("temp-degc", 15.0) );
+}
+
/**
* Set the outside air temperature at the "current" altitude by first
static bool
do_set_oat_degc (const SGPropertyNode * arg)
{
- const string &temp_str = arg->getStringValue("temp-degc", "15.0");
-
+ double oat_degc = arg->getDoubleValue("temp-degc", 15.0);
// check for an altitude specified in the arguments, otherwise use
// current aircraft altitude.
const SGPropertyNode *altitude_ft = arg->getChild("altitude-ft");
FGEnvironment dummy; // instantiate a dummy so we can leech a method
dummy.set_elevation_ft( altitude_ft->getDoubleValue() );
- dummy.set_temperature_degc( atof( temp_str.c_str() ) );
- double temp_sea_level_degc = dummy.get_temperature_sea_level_degc();
-
- //cout << "Altitude = " << altitude_ft->getDoubleValue() << endl;
- //cout << "Temp at alt (C) = " << atof( temp_str.c_str() ) << endl;
- //cout << "Temp sea level (C) = " << temp_sea_level_degc << endl;
-
- SGPropertyNode *node, *child;
-
- // boundary layers
- node = fgGetNode( "/environment/config/boundary" );
- if ( node != NULL ) {
- int i = 0;
- while ( ( child = node->getNode( "entry", i ) ) != NULL ) {
- child->setDoubleValue( "temperature-sea-level-degc",
- temp_sea_level_degc );
- ++i;
- }
- }
-
- // aloft layers
- node = fgGetNode( "/environment/config/aloft" );
- if ( node != NULL ) {
- int i = 0;
- while ( ( child = node->getNode( "entry", i ) ) != NULL ) {
- child->setDoubleValue( "temperature-sea-level-degc",
- temp_sea_level_degc );
- ++i;
- }
- }
-
- return true;
+ dummy.set_temperature_degc( oat_degc );
+ return do_set_sea_level_degc( dummy.get_temperature_sea_level_degc());
}
/**
* boundary and aloft environment layers.
*/
static bool
-do_set_dewpoint_sea_level_degc (const SGPropertyNode * arg)
+do_set_dewpoint_sea_level_degc (double dewpoint_sea_level_degc)
{
- double dewpoint_sea_level_degc = arg->getDoubleValue("dewpoint-degc", 5.0);
SGPropertyNode *node, *child;
return true;
}
+static bool
+do_set_dewpoint_sea_level_degc (const SGPropertyNode * arg)
+{
+ return do_set_dewpoint_sea_level_degc(arg->getDoubleValue("dewpoint-degc", 5.0));
+}
/**
* Set the outside air dewpoint at the "current" altitude by first
static bool
do_set_dewpoint_degc (const SGPropertyNode * arg)
{
- const string &dewpoint_str = arg->getStringValue("dewpoint-degc", "5.0");
+ double dewpoint_degc = arg->getDoubleValue("dewpoint-degc", 5.0);
// check for an altitude specified in the arguments, otherwise use
// current aircraft altitude.
FGEnvironment dummy; // instantiate a dummy so we can leech a method
dummy.set_elevation_ft( altitude_ft->getDoubleValue() );
- dummy.set_dewpoint_degc( atof( dewpoint_str.c_str() ) );
- double dewpoint_sea_level_degc = dummy.get_dewpoint_sea_level_degc();
-
- //cout << "Altitude = " << altitude_ft->getDoubleValue() << endl;
- //cout << "Dewpoint at alt (C) = " << atof( dewpoint_str.c_str() ) << endl;
- //cout << "Dewpoint at sea level (C) = " << dewpoint_sea_level_degc << endl;
-
- SGPropertyNode *node, *child;
-
- // boundary layers
- node = fgGetNode( "/environment/config/boundary" );
- if ( node != NULL ) {
- int i = 0;
- while ( ( child = node->getNode( "entry", i ) ) != NULL ) {
- child->setDoubleValue( "dewpoint-sea-level-degc",
- dewpoint_sea_level_degc );
- ++i;
- }
- }
-
- // aloft layers
- node = fgGetNode( "/environment/config/aloft" );
- if ( node != NULL ) {
- int i = 0;
- while ( ( child = node->getNode( "entry", i ) ) != NULL ) {
- child->setDoubleValue( "dewpoint-sea-level-degc",
- dewpoint_sea_level_degc );
- ++i;
- }
- }
-
- return true;
+ dummy.set_dewpoint_degc( dewpoint_degc );
+ return do_set_dewpoint_sea_level_degc(dummy.get_dewpoint_sea_level_degc());
}
/**
= fgGetNode("/position/longitude-deg");
static const SGPropertyNode *latitude
= fgGetNode("/position/latitude-deg");
- static const SGPropertyNode *cur_time_override
- = fgGetNode("/sim/time/cur-time-override", true);
int orig_warp = globals->get_warp();
SGTime *t = globals->get_time_params();
* SGD_DEGREES_TO_RADIANS,
180.0, false );
}
- // cout << "warp = " << warp << endl;
- globals->set_warp( orig_warp + warp );
-
- t->update( longitude->getDoubleValue() * SGD_DEGREES_TO_RADIANS,
- latitude->getDoubleValue() * SGD_DEGREES_TO_RADIANS,
- cur_time_override->getLongValue(),
- globals->get_warp() );
+
+ fgSetInt("/sim/time/warp", orig_warp + warp);
+
return true;
}
queue->tie_to_listener();
}
- SGSoundSample *msg = new SGSoundSample(path.c_str(), file.c_str());
+ SGSoundSample *msg = new SGSoundSample(file.c_str(), path);
msg->set_volume( volume );
queue->add( msg );
static bool
do_presets_commit (const SGPropertyNode * arg)
{
- // 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();
-
- // set position from presets
- fgInitPosition();
-
- fgReInitSubsystems();
-
- globals->get_tile_mgr()->update( fgGetDouble("/environment/visibility-m") );
-
-#if 0
- if ( ! fgGetBool("/sim/presets/onground") ) {
- fgSetBool( "/sim/freeze/master", true );
- fgSetBool( "/sim/freeze/clock", true );
+ if (fgGetBool("/sim/initialized", false)) {
+ fgReInitSubsystems();
+ } else {
+ // Nasal can trigger this during initial init, which confuses
+ // the logic in ReInitSubsystems, since initial state has not been
+ // saved at that time. Short-circuit everything here.
+ fgInitPosition();
}
-#endif
-
+
return true;
}
return true;
}
-static bool
-do_hud_init(const SGPropertyNode *)
-{
- fgHUDInit(0); // minimal HUD
- return true;
-}
-
-static bool
-do_hud_init2(const SGPropertyNode *)
-{
- fgHUDInit2(0); // normal HUD
- return true;
-}
-
-
/**
* An fgcommand to allow loading of xml files via nasal,
* the xml file's structure will be made available within
if (file.extension() != "xml")
file.concat(".xml");
+ if (file.isRelative()) {
+ file = globals->resolve_maybe_aircraft_path(file.str());
+ }
+
if (!fgValidatePath(file.c_str(), false)) {
SG_LOG(SG_IO, SG_ALERT, "loadxml: reading '" << file.str() << "' denied "
"(unauthorized access)");
{ "replay", do_replay },
{ "decrease-visibility", do_decrease_visibility },
{ "increase-visibility", do_increase_visibility },
- { "hud-init", do_hud_init },
- { "hud-init2", do_hud_init2 },
{ "loadxml", do_load_xml_to_proptree},
{ "savexml", do_save_xml_from_proptree },
{ "press-cockpit-button", do_press_cockpit_button },
{ "release-cockpit-button", do_release_cockpit_button },
{ "dump-scenegraph", do_dump_scene_graph },
{ "dump-terrainbranch", do_dump_terrain_branch },
+ { "print-visible-scene", do_print_visible_scene_info },
{ "reload-shaders", do_reload_shaders },
{ 0, 0 } // zero-terminated
};