Merge branch 'next' of D:\Git_New\flightgear into next
This commit is contained in:
commit
8c4c223db5
8 changed files with 85 additions and 162 deletions
|
@ -14,8 +14,8 @@
|
|||
//
|
||||
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
|
||||
#include <simgear/xml/easyxml.hxx>
|
||||
#include <simgear/misc/strutils.hxx>
|
||||
|
||||
#include <Main/globals.hxx>
|
||||
#include <Main/fg_props.hxx>
|
||||
|
@ -84,11 +84,16 @@ void XMLLoader::load(FGSidStar* p) {
|
|||
bool XMLLoader::findAirportData(const std::string& aICAO,
|
||||
const std::string& aFileName, SGPath& aPath)
|
||||
{
|
||||
string fileName(aFileName);
|
||||
if (!simgear::strutils::ends_with(aFileName, ".xml")) {
|
||||
fileName.append(".xml");
|
||||
}
|
||||
|
||||
string_list sc = globals->get_fg_scenery();
|
||||
char buffer[128];
|
||||
::snprintf(buffer, 128, "%c/%c/%c/%s.%s.xml",
|
||||
::snprintf(buffer, 128, "%c/%c/%c/%s.%s",
|
||||
aICAO[0], aICAO[1], aICAO[2],
|
||||
aICAO.c_str(), aFileName.c_str());
|
||||
aICAO.c_str(), fileName.c_str());
|
||||
|
||||
for (string_list_iterator it = sc.begin(); it != sc.end(); ++it) {
|
||||
SGPath path(*it);
|
||||
|
|
|
@ -224,6 +224,15 @@ void FGRouteMgr::init() {
|
|||
|
||||
void FGRouteMgr::postinit()
|
||||
{
|
||||
SGPath path(_pathNode->getStringValue());
|
||||
if (path.exists()) {
|
||||
SG_LOG(SG_AUTOPILOT, SG_INFO, "loading flight-plan from:" << path.str());
|
||||
loadRoute();
|
||||
}
|
||||
|
||||
// this code only matters for the --wp option now - perhaps the option
|
||||
// should be deprecated in favour of an explicit flight-plan file?
|
||||
// then the global initial waypoint list could die.
|
||||
string_list *waypoints = globals->get_initial_waypoints();
|
||||
if (waypoints) {
|
||||
string_list::iterator it;
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <Scenery/scenery.hxx>
|
||||
#include <Scripting/NasalSys.hxx>
|
||||
#include <Sound/sample_queue.hxx>
|
||||
#include <Time/sunsolver.hxx>
|
||||
#include <Airports/xmlloader.hxx>
|
||||
|
||||
#include "fg_init.hxx"
|
||||
#include "fg_io.hxx"
|
||||
|
@ -698,85 +698,6 @@ do_set_dewpoint_degc (const SGPropertyNode * arg)
|
|||
return do_set_dewpoint_sea_level_degc(dummy.get_dewpoint_sea_level_degc());
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* Update the lighting manually.
|
||||
*/
|
||||
static bool
|
||||
do_timeofday (const SGPropertyNode * arg)
|
||||
{
|
||||
const string &offset_type = arg->getStringValue("timeofday", "noon");
|
||||
|
||||
static const SGPropertyNode *longitude
|
||||
= fgGetNode("/position/longitude-deg");
|
||||
static const SGPropertyNode *latitude
|
||||
= fgGetNode("/position/latitude-deg");
|
||||
|
||||
int orig_warp = globals->get_warp();
|
||||
SGTime *t = globals->get_time_params();
|
||||
time_t cur_time = t->get_cur_time();
|
||||
// cout << "cur_time = " << cur_time << endl;
|
||||
// cout << "orig_warp = " << orig_warp << endl;
|
||||
|
||||
int warp = 0;
|
||||
if ( offset_type == "real" ) {
|
||||
warp = -orig_warp;
|
||||
} else if ( offset_type == "dawn" ) {
|
||||
warp = fgTimeSecondsUntilSunAngle( cur_time,
|
||||
longitude->getDoubleValue()
|
||||
* SGD_DEGREES_TO_RADIANS,
|
||||
latitude->getDoubleValue()
|
||||
* SGD_DEGREES_TO_RADIANS,
|
||||
90.0, true );
|
||||
} else if ( offset_type == "morning" ) {
|
||||
warp = fgTimeSecondsUntilSunAngle( cur_time,
|
||||
longitude->getDoubleValue()
|
||||
* SGD_DEGREES_TO_RADIANS,
|
||||
latitude->getDoubleValue()
|
||||
* SGD_DEGREES_TO_RADIANS,
|
||||
75.0, true );
|
||||
} else if ( offset_type == "noon" ) {
|
||||
warp = fgTimeSecondsUntilSunAngle( cur_time,
|
||||
longitude->getDoubleValue()
|
||||
* SGD_DEGREES_TO_RADIANS,
|
||||
latitude->getDoubleValue()
|
||||
* SGD_DEGREES_TO_RADIANS,
|
||||
0.0, true );
|
||||
} else if ( offset_type == "afternoon" ) {
|
||||
warp = fgTimeSecondsUntilSunAngle( cur_time,
|
||||
longitude->getDoubleValue()
|
||||
* SGD_DEGREES_TO_RADIANS,
|
||||
latitude->getDoubleValue()
|
||||
* SGD_DEGREES_TO_RADIANS,
|
||||
60.0, false );
|
||||
} else if ( offset_type == "dusk" ) {
|
||||
warp = fgTimeSecondsUntilSunAngle( cur_time,
|
||||
longitude->getDoubleValue()
|
||||
* SGD_DEGREES_TO_RADIANS,
|
||||
latitude->getDoubleValue()
|
||||
* SGD_DEGREES_TO_RADIANS,
|
||||
90.0, false );
|
||||
} else if ( offset_type == "evening" ) {
|
||||
warp = fgTimeSecondsUntilSunAngle( cur_time,
|
||||
longitude->getDoubleValue()
|
||||
* SGD_DEGREES_TO_RADIANS,
|
||||
latitude->getDoubleValue()
|
||||
* SGD_DEGREES_TO_RADIANS,
|
||||
100.0, false );
|
||||
} else if ( offset_type == "midnight" ) {
|
||||
warp = fgTimeSecondsUntilSunAngle( cur_time,
|
||||
longitude->getDoubleValue()
|
||||
* SGD_DEGREES_TO_RADIANS,
|
||||
latitude->getDoubleValue()
|
||||
* SGD_DEGREES_TO_RADIANS,
|
||||
180.0, false );
|
||||
}
|
||||
|
||||
|
||||
fgSetInt("/sim/time/warp", orig_warp + warp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Built-in command: toggle a bool property value.
|
||||
|
@ -1301,11 +1222,20 @@ do_load_xml_to_proptree(const SGPropertyNode * arg)
|
|||
|
||||
if (file.extension() != "xml")
|
||||
file.concat(".xml");
|
||||
|
||||
if (file.isRelative()) {
|
||||
file = globals->resolve_maybe_aircraft_path(file.str());
|
||||
|
||||
std::string icao = arg->getStringValue("icao");
|
||||
if (icao.empty()) {
|
||||
if (file.isRelative()) {
|
||||
file = globals->resolve_maybe_aircraft_path(file.str());
|
||||
}
|
||||
} else {
|
||||
if (!XMLLoader::findAirportData(icao, file.str(), file)) {
|
||||
SG_LOG(SG_IO, SG_INFO, "loadxml: failed to find airport data for "
|
||||
<< file.str() << " at ICAO:" << icao);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!fgValidatePath(file.c_str(), false)) {
|
||||
SG_LOG(SG_IO, SG_ALERT, "loadxml: reading '" << file.str() << "' denied "
|
||||
"(unauthorized access)");
|
||||
|
@ -1458,7 +1388,6 @@ static struct {
|
|||
{ "set-dewpoint-sea-level-air-temp-degc", do_set_dewpoint_sea_level_degc },
|
||||
{ "set-dewpoint-temp-degc", do_set_dewpoint_degc },
|
||||
*/
|
||||
{ "timeofday", do_timeofday },
|
||||
{ "property-toggle", do_property_toggle },
|
||||
{ "property-assign", do_property_assign },
|
||||
{ "property-adjust", do_property_adjust },
|
||||
|
|
|
@ -241,7 +241,8 @@ void FGGlobals::set_fg_scenery (const string &scenery)
|
|||
|
||||
string_list path_list = sgPathSplit( s.str() );
|
||||
fg_scenery.clear();
|
||||
|
||||
SGPropertyNode* sim = fgGetNode("/sim", true);
|
||||
|
||||
for (unsigned i = 0; i < path_list.size(); i++) {
|
||||
SGPath path(path_list[i]);
|
||||
if (!path.exists()) {
|
||||
|
@ -271,6 +272,12 @@ void FGGlobals::set_fg_scenery (const string &scenery)
|
|||
// FG_SCENERY=A:B becomes list ["A/Terrain", "A/Objects", "",
|
||||
// "B/Terrain", "B/Objects", ""]
|
||||
fg_scenery.push_back("");
|
||||
|
||||
// make scenery dirs available to Nasal
|
||||
sim->removeChild("fg-scenery", i, false);
|
||||
SGPropertyNode* n = sim->getChild("fg-scenery", i, true);
|
||||
n->setStringValue(path.str());
|
||||
n->setAttribute(SGPropertyNode::WRITE, false);
|
||||
} // of path list iteration
|
||||
}
|
||||
|
||||
|
|
|
@ -555,54 +555,6 @@ add_channel( const string& type, const string& channel_str ) {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
// The parse wp and parse flight-plan options don't work anymore, because
|
||||
// the route manager and the airport subsystems have not yet been initialized
|
||||
// at this stage.
|
||||
|
||||
// Parse --wp=ID[@alt]
|
||||
static void
|
||||
parse_wp( const string& arg ) {
|
||||
string_list *waypoints = globals->get_initial_waypoints();
|
||||
if (!waypoints) {
|
||||
waypoints = new string_list;
|
||||
globals->set_initial_waypoints(waypoints);
|
||||
}
|
||||
waypoints->push_back(arg);
|
||||
}
|
||||
|
||||
|
||||
// Parse --flight-plan=[file]
|
||||
static bool
|
||||
parse_flightplan(const string& arg)
|
||||
{
|
||||
string_list *waypoints = globals->get_initial_waypoints();
|
||||
if (!waypoints) {
|
||||
waypoints = new string_list;
|
||||
globals->set_initial_waypoints(waypoints);
|
||||
}
|
||||
|
||||
sg_gzifstream in(arg.c_str());
|
||||
if ( !in.is_open() )
|
||||
return false;
|
||||
|
||||
while ( true ) {
|
||||
string line;
|
||||
getline( in, line, '\n' );
|
||||
|
||||
// catch extraneous (DOS) line ending character
|
||||
if ( line[line.length() - 1] < 32 )
|
||||
line = line.substr( 0, line.length()-1 );
|
||||
|
||||
if ( in.eof() )
|
||||
break;
|
||||
|
||||
waypoints->push_back(line);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
fgOptLanguage( const char *arg )
|
||||
{
|
||||
|
@ -1067,14 +1019,12 @@ fgOptCeiling( const char *arg )
|
|||
static int
|
||||
fgOptWp( const char *arg )
|
||||
{
|
||||
parse_wp( arg );
|
||||
return FG_OPTIONS_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
fgOptFlightPlan( const char *arg )
|
||||
{
|
||||
parse_flightplan ( arg );
|
||||
string_list *waypoints = globals->get_initial_waypoints();
|
||||
if (!waypoints) {
|
||||
waypoints = new string_list;
|
||||
globals->set_initial_waypoints(waypoints);
|
||||
}
|
||||
waypoints->push_back(arg);
|
||||
return FG_OPTIONS_OK;
|
||||
}
|
||||
|
||||
|
@ -1496,7 +1446,7 @@ struct OptionDesc {
|
|||
{"turbulence", true, OPTION_FUNC, "", false, "", fgOptTurbulence },
|
||||
{"ceiling", true, OPTION_FUNC, "", false, "", fgOptCeiling },
|
||||
{"wp", true, OPTION_FUNC, "", false, "", fgOptWp },
|
||||
{"flight-plan", true, OPTION_FUNC, "", false, "", fgOptFlightPlan },
|
||||
{"flight-plan", true, OPTION_STRING, "/autopilot/route-manager/file-path", false, "", NULL },
|
||||
{"config", true, OPTION_FUNC, "", false, "", fgOptConfig },
|
||||
{"aircraft", true, OPTION_STRING, "/sim/aircraft", false, "", 0 },
|
||||
{"vehicle", true, OPTION_STRING, "/sim/aircraft", false, "", 0 },
|
||||
|
|
|
@ -772,7 +772,6 @@ FGRenderer::update( bool refresh_camera_settings ) {
|
|||
// Handle new window size or exposure
|
||||
void
|
||||
FGRenderer::resize( int width, int height ) {
|
||||
int view_h = height;
|
||||
|
||||
// the following breaks aspect-ratio of the main 3D scenery window when 2D panels are moved
|
||||
// in y direction - causing issues for aircraft with 2D panels (/sim/virtual_cockpit=false).
|
||||
|
@ -782,20 +781,20 @@ FGRenderer::resize( int width, int height ) {
|
|||
// view_h = (int)(height * (globals->get_current_panel()->getViewHeight() -
|
||||
// globals->get_current_panel()->getYOffset()) / 768.0);
|
||||
// }
|
||||
static int lastwidth = 0;
|
||||
static int lastheight = 0;
|
||||
if (width != lastwidth)
|
||||
_xsize->setIntValue(lastwidth = width);
|
||||
if (height != lastheight)
|
||||
_ysize->setIntValue(lastheight = height);
|
||||
|
||||
int curWidth = _xsize->getIntValue(),
|
||||
curHeight = _ysize->getIntValue();
|
||||
|
||||
_xsize->setIntValue(width);
|
||||
_ysize->setIntValue(height);
|
||||
double aspect = height / (double) width;
|
||||
|
||||
// for all views
|
||||
FGViewMgr *viewmgr = globals->get_viewmgr();
|
||||
if (viewmgr) {
|
||||
for ( int i = 0; i < viewmgr->size(); ++i ) {
|
||||
viewmgr->get_view(i)->
|
||||
set_aspect_ratio((float)view_h / (float)width);
|
||||
}
|
||||
for ( int i = 0; i < viewmgr->size(); ++i ) {
|
||||
viewmgr->get_view(i)->set_aspect_ratio(aspect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,16 +35,32 @@
|
|||
#include <simgear/structure/event_mgr.hxx>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/timing/lowleveltime.h>
|
||||
#include <simgear/structure/commands.hxx>
|
||||
|
||||
#include <Main/fg_props.hxx>
|
||||
#include <Main/globals.hxx>
|
||||
#include <Time/sunsolver.hxx>
|
||||
|
||||
static bool do_timeofday (const SGPropertyNode * arg)
|
||||
{
|
||||
const string &offset_type = arg->getStringValue("timeofday", "noon");
|
||||
int offset = arg->getIntValue("offset", 0);
|
||||
TimeManager* self = (TimeManager*) globals->get_subsystem("time");
|
||||
if (offset_type == "real") {
|
||||
// without this, setting 'real' time is a no-op, since the current
|
||||
// wrap value (orig_warp) is retained in setTimeOffset. Ick.
|
||||
fgSetInt("/sim/time/warp", 0);
|
||||
}
|
||||
|
||||
self->setTimeOffset(offset_type, offset);
|
||||
return true;
|
||||
}
|
||||
|
||||
TimeManager::TimeManager() :
|
||||
_inited(false),
|
||||
_impl(NULL)
|
||||
{
|
||||
|
||||
SGCommandMgr::instance()->addCommand("timeofday", do_timeofday);
|
||||
}
|
||||
|
||||
void TimeManager::init()
|
||||
|
@ -345,6 +361,14 @@ void TimeManager::updateLocalTime()
|
|||
}
|
||||
|
||||
void TimeManager::initTimeOffset()
|
||||
{
|
||||
|
||||
int offset = fgGetInt("/sim/startup/time-offset");
|
||||
string offset_type = fgGetString("/sim/startup/time-offset-type");
|
||||
setTimeOffset(offset_type, offset);
|
||||
}
|
||||
|
||||
void TimeManager::setTimeOffset(const std::string& offset_type, int offset)
|
||||
{
|
||||
// Handle potential user specified time offsets
|
||||
int orig_warp = _warp->getIntValue();
|
||||
|
@ -355,8 +379,6 @@ void TimeManager::initTimeOffset()
|
|||
sgTimeGetGMT( fgLocaltime(&cur_time, _impl->get_zonename() ) );
|
||||
|
||||
// Okay, we now have several possible scenarios
|
||||
int offset = fgGetInt("/sim/startup/time-offset");
|
||||
string offset_type = fgGetString("/sim/startup/time-offset-type");
|
||||
double lon = _longitudeDeg->getDoubleValue() * SG_DEGREES_TO_RADIANS;
|
||||
double lat = _latitudeDeg->getDoubleValue() * SG_DEGREES_TO_RADIANS;
|
||||
int warp = 0;
|
||||
|
@ -394,12 +416,12 @@ void TimeManager::initTimeOffset()
|
|||
warp = offset - (aircraftLocalTime - currGMT)- cur_time;
|
||||
} else {
|
||||
SG_LOG( SG_GENERAL, SG_ALERT,
|
||||
"TimeManager::initTimeOffset: unsupported offset: " << offset_type );
|
||||
"TimeManager::setTimeOffset: unsupported offset: " << offset_type );
|
||||
warp = 0;
|
||||
}
|
||||
|
||||
_warp->setIntValue( orig_warp + warp );
|
||||
|
||||
SG_LOG( SG_GENERAL, SG_INFO, "After fgInitTimeOffset(): warp = "
|
||||
SG_LOG( SG_GENERAL, SG_INFO, "After TimeManager::setTimeOffset(): warp = "
|
||||
<< _warp->getIntValue() );
|
||||
}
|
||||
|
|
|
@ -43,6 +43,8 @@ public:
|
|||
|
||||
// SGPropertyChangeListener overrides
|
||||
virtual void valueChanged(SGPropertyNode *);
|
||||
|
||||
void setTimeOffset(const std::string& offset_type, int offset);
|
||||
private:
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue