Use future-proof SGPath APIs.
Remove uses of .str(), .c_str() and some other methods of SGPath. Pass SGPath directly where possible, or explicitly convert to the appropriate 8-bit encoding.
This commit is contained in:
parent
d9129cfe80
commit
6d0c2070fd
65 changed files with 646 additions and 621 deletions
src
AIModel
Aircraft
Canvas
Cockpit
Environment
GUI
CocoaFileDialog.mmCocoaMouseCursor.mmFGFontCache.cxxInstallSceneryDialog.cxxPUIFileDialog.cxxPathsDialog.cxxQtLauncher.cxxgui_funcs.cxxnew_gui.cxx
Input
Instrumentation
Main
fg_commands.cxxfg_init.cxxfg_props.cxxfg_props.hxxglobals.cxxlocale.cxxmain.cxxoptions.cxxoptions.hxxpositioninit.cxxutil.cxx
Model
Navaids
Network
Radio
Scripting
Sound
Systems
Time
Traffic
Viewer
utils
GPSsmooth
fgelev
fgpanel
fgviewer
|
@ -397,7 +397,7 @@ bool FGAIBase::init(bool search_in_AI_path)
|
||||||
BOOST_FOREACH(SGPath p, globals->get_data_paths("AI")) {
|
BOOST_FOREACH(SGPath p, globals->get_data_paths("AI")) {
|
||||||
p.append(model_path);
|
p.append(model_path);
|
||||||
if (p.exists()) {
|
if (p.exists()) {
|
||||||
f = p.str();
|
f = p.local8BitStr();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} // of AI data paths iteration
|
} // of AI data paths iteration
|
||||||
|
|
|
@ -817,12 +817,12 @@ loadRawReplayData(gzContainerReader& input, FGFlightRecorder* pRecorder, replay_
|
||||||
|
|
||||||
/** Write flight recorder tape with given filename and meta properties to disk */
|
/** Write flight recorder tape with given filename and meta properties to disk */
|
||||||
bool
|
bool
|
||||||
FGReplay::saveTape(const char* Filename, SGPropertyNode* MetaDataProps)
|
FGReplay::saveTape(const SGPath& Filename, SGPropertyNode* MetaDataProps)
|
||||||
{
|
{
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
|
|
||||||
/* open output stream *******************************************/
|
/* open output stream *******************************************/
|
||||||
gzContainerWriter output(Filename, FlightRecorderFileMagic);
|
gzContainerWriter output(Filename.local8BitStr(), FlightRecorderFileMagic);
|
||||||
if (!output.good())
|
if (!output.good())
|
||||||
{
|
{
|
||||||
SG_LOG(SG_SYSTEMS, SG_ALERT, "Cannot open file" << Filename);
|
SG_LOG(SG_SYSTEMS, SG_ALERT, "Cannot open file" << Filename);
|
||||||
|
@ -921,7 +921,7 @@ FGReplay::saveTape(const SGPropertyNode* ConfigData)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
ok &= saveTape(p.c_str(), myMetaData.get());
|
ok &= saveTape(p, myMetaData.get());
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
guiMessage("Flight recorder tape saved successfully!");
|
guiMessage("Flight recorder tape saved successfully!");
|
||||||
|
@ -935,12 +935,12 @@ FGReplay::saveTape(const SGPropertyNode* ConfigData)
|
||||||
* Actual data and signal configuration is not read when in "Preview" mode.
|
* Actual data and signal configuration is not read when in "Preview" mode.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
FGReplay::loadTape(const char* Filename, bool Preview, SGPropertyNode* UserData)
|
FGReplay::loadTape(const SGPath& Filename, bool Preview, SGPropertyNode* UserData)
|
||||||
{
|
{
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
|
|
||||||
/* open input stream ********************************************/
|
/* open input stream ********************************************/
|
||||||
gzContainerReader input(Filename, FlightRecorderFileMagic);
|
gzContainerReader input(Filename.local8BitStr(), FlightRecorderFileMagic);
|
||||||
if (input.eof() || !input.good())
|
if (input.eof() || !input.good())
|
||||||
{
|
{
|
||||||
SG_LOG(SG_SYSTEMS, SG_ALERT, "Cannot open file " << Filename);
|
SG_LOG(SG_SYSTEMS, SG_ALERT, "Cannot open file " << Filename);
|
||||||
|
@ -1142,6 +1142,6 @@ FGReplay::loadTape(const SGPropertyNode* ConfigData)
|
||||||
tapeDirectory.append(tape);
|
tapeDirectory.append(tape);
|
||||||
tapeDirectory.concat(".fgtape");
|
tapeDirectory.concat(".fgtape");
|
||||||
SG_LOG(SG_SYSTEMS, MY_SG_DEBUG, "Checking flight recorder file " << tapeDirectory << ", preview: " << Preview);
|
SG_LOG(SG_SYSTEMS, MY_SG_DEBUG, "Checking flight recorder file " << tapeDirectory << ", preview: " << Preview);
|
||||||
return loadTape(tapeDirectory.c_str(), Preview, UserData);
|
return loadTape(tapeDirectory, Preview, UserData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,8 +91,8 @@ private:
|
||||||
double get_end_time();
|
double get_end_time();
|
||||||
|
|
||||||
bool listTapes(bool SameAircraftFilter, const SGPath& tapeDirectory);
|
bool listTapes(bool SameAircraftFilter, const SGPath& tapeDirectory);
|
||||||
bool saveTape(const char* Filename, SGPropertyNode* MetaData);
|
bool saveTape(const SGPath& Filename, SGPropertyNode* MetaData);
|
||||||
bool loadTape(const char* Filename, bool Preview, SGPropertyNode* UserData);
|
bool loadTape(const SGPath& Filename, bool Preview, SGPropertyNode* UserData);
|
||||||
|
|
||||||
double sim_time;
|
double sim_time;
|
||||||
double last_mt_time;
|
double last_mt_time;
|
||||||
|
|
|
@ -91,7 +91,7 @@ namespace canvas
|
||||||
{
|
{
|
||||||
SGPath tpath = globals->resolve_resource_path(path);
|
SGPath tpath = globals->resolve_resource_path(path);
|
||||||
if( !tpath.isNull() )
|
if( !tpath.isNull() )
|
||||||
return osgDB::readRefImageFile(tpath.c_str());
|
return osgDB::readRefImageFile(tpath.local8BitStr());
|
||||||
|
|
||||||
SG_LOG(SG_IO, SG_ALERT, "canvas::Image: No such image: '" << path << "'");
|
SG_LOG(SG_IO, SG_ALERT, "canvas::Image: No such image: '" << path << "'");
|
||||||
}
|
}
|
||||||
|
|
|
@ -780,7 +780,7 @@ NavDisplay::updateFont()
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::ref_ptr<osgDB::ReaderWriter::Options> fontOptions = new osgDB::ReaderWriter::Options("monochrome");
|
osg::ref_ptr<osgDB::ReaderWriter::Options> fontOptions = new osgDB::ReaderWriter::Options("monochrome");
|
||||||
osg::ref_ptr<osgText::Font> font = osgText::readFontFile(tpath.c_str(), fontOptions.get());
|
osg::ref_ptr<osgText::Font> font = osgText::readFontFile(tpath.local8BitStr(), fontOptions.get());
|
||||||
|
|
||||||
if (font != 0) {
|
if (font != 0) {
|
||||||
_font = font;
|
_font = font;
|
||||||
|
|
|
@ -1084,7 +1084,7 @@ wxRadarBg::updateFont()
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::ref_ptr<osgDB::ReaderWriter::Options> fontOptions = new osgDB::ReaderWriter::Options("monochrome");
|
osg::ref_ptr<osgDB::ReaderWriter::Options> fontOptions = new osgDB::ReaderWriter::Options("monochrome");
|
||||||
osg::ref_ptr<osgText::Font> font = osgText::readFontFile(tpath.c_str(), fontOptions.get());
|
osg::ref_ptr<osgText::Font> font = osgText::readFontFile(tpath.local8BitStr(), fontOptions.get());
|
||||||
|
|
||||||
if (font != 0) {
|
if (font != 0) {
|
||||||
_font = font;
|
_font = font;
|
||||||
|
|
|
@ -52,7 +52,7 @@ void Ephemeris::init()
|
||||||
{
|
{
|
||||||
SGPath ephem_data_path(globals->get_fg_root());
|
SGPath ephem_data_path(globals->get_fg_root());
|
||||||
ephem_data_path.append("Astro");
|
ephem_data_path.append("Astro");
|
||||||
_impl = new SGEphemeris(ephem_data_path.c_str());
|
_impl = new SGEphemeris(ephem_data_path.local8BitStr());
|
||||||
|
|
||||||
tieStar("/ephemeris/sun/xs", _impl->get_sun(), &Star::getxs);
|
tieStar("/ephemeris/sun/xs", _impl->get_sun(), &Star::getxs);
|
||||||
tieStar("/ephemeris/sun/ys", _impl->get_sun(), &Star::getys);
|
tieStar("/ephemeris/sun/ys", _impl->get_sun(), &Star::getys);
|
||||||
|
|
|
@ -134,7 +134,7 @@ void CocoaFileDialog::exec()
|
||||||
if (result == NSFileHandlingPanelOKButton) {
|
if (result == NSFileHandlingPanelOKButton) {
|
||||||
completion_path = [[d->panel URL] path];
|
completion_path = [[d->panel URL] path];
|
||||||
//NSLog(@"the URL is: %@", d->panel URL]);
|
//NSLog(@"the URL is: %@", d->panel URL]);
|
||||||
completion_sgpath = ([completion_path UTF8String]);
|
completion_sgpath = SGPath::fromUtf8([completion_path UTF8String]);
|
||||||
_callback->onFileDialogDone(this, completion_sgpath);
|
_callback->onFileDialogDone(this, completion_sgpath);
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
|
@ -41,8 +41,8 @@ NSCursor* cocoaCursorForKey(FGMouseCursor::Cursor aKey)
|
||||||
{
|
{
|
||||||
NSImage* img = nil;
|
NSImage* img = nil;
|
||||||
|
|
||||||
NSString* path = [NSString stringWithCString:globals->get_fg_root().c_str()
|
std::string p = globals->get_fg_root().utf8Str();
|
||||||
encoding:NSUTF8StringEncoding];
|
NSString* path = [NSString stringWithCString:p.c_str() encoding:NSUTF8StringEncoding];
|
||||||
path = [path stringByAppendingPathComponent:@"gui"];
|
path = [path stringByAppendingPathComponent:@"gui"];
|
||||||
|
|
||||||
switch (aKey) {
|
switch (aKey) {
|
||||||
|
|
|
@ -207,7 +207,8 @@ bool FGFontCache::initializeFonts()
|
||||||
{
|
{
|
||||||
static std::string fontext("txf");
|
static std::string fontext("txf");
|
||||||
init();
|
init();
|
||||||
ulDir* fontdir = ulOpenDir(_path.c_str());
|
std::string fontPath = _path.local8BitStr();
|
||||||
|
ulDir* fontdir = ulOpenDir(fontPath.c_str());
|
||||||
if (!fontdir)
|
if (!fontdir)
|
||||||
return false;
|
return false;
|
||||||
const ulDirEnt *dirEntry;
|
const ulDirEnt *dirEntry;
|
||||||
|
@ -216,7 +217,8 @@ bool FGFontCache::initializeFonts()
|
||||||
path.append(dirEntry->d_name);
|
path.append(dirEntry->d_name);
|
||||||
if (path.extension() == fontext) {
|
if (path.extension() == fontext) {
|
||||||
fntTexFont* f = new fntTexFont;
|
fntTexFont* f = new fntTexFont;
|
||||||
if (f->load((char *)path.c_str()))
|
std::string ps = path.local8BitStr();
|
||||||
|
if (f->load(ps.c_str()))
|
||||||
_texFonts[std::string(dirEntry->d_name)] = f;
|
_texFonts[std::string(dirEntry->d_name)] = f;
|
||||||
else
|
else
|
||||||
delete f;
|
delete f;
|
||||||
|
|
|
@ -141,7 +141,7 @@ InstallSceneryDialog::InstallSceneryDialog(QWidget *parent, QString downloadDir)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
if (m_downloadDir.isEmpty()) {
|
if (m_downloadDir.isEmpty()) {
|
||||||
m_downloadDir = QString::fromStdString(flightgear::defaultDownloadDir());
|
m_downloadDir = QString::fromStdString(flightgear::defaultDownloadDir().utf8Str());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString baseIntroString = ui->introText->text();
|
QString baseIntroString = ui->introText->text();
|
||||||
|
|
|
@ -51,14 +51,14 @@ void PUIFileDialog::exec()
|
||||||
|
|
||||||
SGPropertyNode_ptr dlg = _dialogRoot->getChild("dialog", 0, true);
|
SGPropertyNode_ptr dlg = _dialogRoot->getChild("dialog", 0, true);
|
||||||
SGPath dlgXML = globals->resolve_resource_path("gui/dialogs/file-select.xml");
|
SGPath dlgXML = globals->resolve_resource_path("gui/dialogs/file-select.xml");
|
||||||
readProperties(dlgXML.str(), dlg);
|
readProperties(dlgXML, dlg);
|
||||||
|
|
||||||
dlg->setStringValue("name", name);
|
dlg->setStringValue("name", name);
|
||||||
gui->newDialog(dlg);
|
gui->newDialog(dlg);
|
||||||
|
|
||||||
_dialogRoot->setStringValue("title", _title);
|
_dialogRoot->setStringValue("title", _title);
|
||||||
_dialogRoot->setStringValue("button", _buttonText);
|
_dialogRoot->setStringValue("button", _buttonText);
|
||||||
_dialogRoot->setStringValue("directory", _initialPath.str());
|
_dialogRoot->setStringValue("directory", _initialPath.utf8Str());
|
||||||
_dialogRoot->setStringValue("selection", _placeholder);
|
_dialogRoot->setStringValue("selection", _placeholder);
|
||||||
|
|
||||||
// convert patterns vector into pattern nodes
|
// convert patterns vector into pattern nodes
|
||||||
|
|
|
@ -339,7 +339,7 @@ void AddOnsPage::updateUi()
|
||||||
{
|
{
|
||||||
QString s = m_downloadDir;
|
QString s = m_downloadDir;
|
||||||
if (s.isEmpty()) {
|
if (s.isEmpty()) {
|
||||||
s = QString::fromStdString(flightgear::defaultDownloadDir());
|
s = QString::fromStdString(flightgear::defaultDownloadDir().utf8Str());
|
||||||
s.append(tr(" (default)"));
|
s.append(tr(" (default)"));
|
||||||
m_ui->clearDownloadDir->setEnabled(false);
|
m_ui->clearDownloadDir->setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -649,7 +649,7 @@ void QtLauncher::setSceneryPaths()
|
||||||
// append the TerraSync path
|
// append the TerraSync path
|
||||||
QString downloadDir = settings.value("download-dir").toString();
|
QString downloadDir = settings.value("download-dir").toString();
|
||||||
if (downloadDir.isEmpty()) {
|
if (downloadDir.isEmpty()) {
|
||||||
downloadDir = QString::fromStdString(flightgear::defaultDownloadDir());
|
downloadDir = QString::fromStdString(flightgear::defaultDownloadDir().utf8Str());
|
||||||
}
|
}
|
||||||
|
|
||||||
SGPath terraSyncDir(downloadDir.toStdString());
|
SGPath terraSyncDir(downloadDir.toStdString());
|
||||||
|
@ -947,7 +947,7 @@ void QtLauncher::onToggleTerrasync(bool enabled)
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
QString downloadDir = settings.value("download-dir").toString();
|
QString downloadDir = settings.value("download-dir").toString();
|
||||||
if (downloadDir.isEmpty()) {
|
if (downloadDir.isEmpty()) {
|
||||||
downloadDir = QString::fromStdString(flightgear::defaultDownloadDir());
|
downloadDir = QString::fromStdString(flightgear::defaultDownloadDir().utf8Str());
|
||||||
}
|
}
|
||||||
|
|
||||||
QFileInfo info(downloadDir);
|
QFileInfo info(downloadDir);
|
||||||
|
|
|
@ -181,7 +181,7 @@ bool openBrowser(const std::string& aAddress)
|
||||||
SGPath path(address);
|
SGPath path(address);
|
||||||
path = globals->resolve_maybe_aircraft_path(address);
|
path = globals->resolve_maybe_aircraft_path(address);
|
||||||
if (!path.isNull())
|
if (!path.isNull())
|
||||||
address = path.str();
|
address = path.local8BitStr();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mkDialog ("Sorry, file not found!");
|
mkDialog ("Sorry, file not found!");
|
||||||
|
@ -521,7 +521,8 @@ namespace
|
||||||
// to be executed in graphics context (maybe separate thread)
|
// to be executed in graphics context (maybe separate thread)
|
||||||
void run(osg::GraphicsContext* gc)
|
void run(osg::GraphicsContext* gc)
|
||||||
{
|
{
|
||||||
_result = sg_glDumpWindow(_path.c_str(),
|
std::string ps = _path.local8BitStr();
|
||||||
|
_result = sg_glDumpWindow(ps.c_str(),
|
||||||
_xsize,
|
_xsize,
|
||||||
_ysize);
|
_ysize);
|
||||||
}
|
}
|
||||||
|
@ -533,7 +534,7 @@ namespace
|
||||||
{
|
{
|
||||||
globals->get_event_mgr()->removeTask("SnapShotTimer");
|
globals->get_event_mgr()->removeTask("SnapShotTimer");
|
||||||
|
|
||||||
fgSetString("/sim/paths/screenshot-last", _path.c_str());
|
fgSetString("/sim/paths/screenshot-last", _path.utf8Str());
|
||||||
fgSetBool("/sim/signals/screenshot", _result);
|
fgSetBool("/sim/signals/screenshot", _result);
|
||||||
|
|
||||||
fgSetMouseCursor(_mouse);
|
fgSetMouseCursor(_mouse);
|
||||||
|
|
|
@ -250,7 +250,7 @@ NewGUI::getDialogProperties (const string &name)
|
||||||
SGPath path = _dialog_names[name];
|
SGPath path = _dialog_names[name];
|
||||||
SGPropertyNode_ptr props = new SGPropertyNode;
|
SGPropertyNode_ptr props = new SGPropertyNode;
|
||||||
try {
|
try {
|
||||||
readProperties(path.str(), props);
|
readProperties(path, props);
|
||||||
} catch (const sg_exception &) {
|
} catch (const sg_exception &) {
|
||||||
SG_LOG(SG_INPUT, SG_ALERT, "Error parsing dialog " << path);
|
SG_LOG(SG_INPUT, SG_ALERT, "Error parsing dialog " << path);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -328,7 +328,7 @@ NewGUI::readDir (const SGPath& path)
|
||||||
simgear::Dir dir(path);
|
simgear::Dir dir(path);
|
||||||
if( !dir.exists() )
|
if( !dir.exists() )
|
||||||
{
|
{
|
||||||
SG_LOG(SG_INPUT, SG_INFO, "directory does not exist: " << path.str());
|
SG_LOG(SG_INPUT, SG_INFO, "directory does not exist: " << path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ NewGUI::readDir (const SGPath& path)
|
||||||
BOOST_FOREACH(SGPath xmlPath, xmls) {
|
BOOST_FOREACH(SGPath xmlPath, xmls) {
|
||||||
if (!cache->isCachedFileModified(xmlPath)) {
|
if (!cache->isCachedFileModified(xmlPath)) {
|
||||||
// cached, easy
|
// cached, easy
|
||||||
string name = cache->readStringProperty(xmlPath.str());
|
string name = cache->readStringProperty(xmlPath.utf8Str());
|
||||||
_dialog_names[name] = xmlPath;
|
_dialog_names[name] = xmlPath;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,7 @@ NewGUI::readDir (const SGPath& path)
|
||||||
// we need to parse the actual XML
|
// we need to parse the actual XML
|
||||||
SGPropertyNode_ptr props = new SGPropertyNode;
|
SGPropertyNode_ptr props = new SGPropertyNode;
|
||||||
try {
|
try {
|
||||||
readProperties(xmlPath.str(), props);
|
readProperties(xmlPath, props);
|
||||||
} catch (const sg_exception &) {
|
} catch (const sg_exception &) {
|
||||||
SG_LOG(SG_INPUT, SG_ALERT, "Error parsing dialog " << xmlPath);
|
SG_LOG(SG_INPUT, SG_ALERT, "Error parsing dialog " << xmlPath);
|
||||||
continue;
|
continue;
|
||||||
|
@ -364,7 +364,7 @@ NewGUI::readDir (const SGPath& path)
|
||||||
// update cached values
|
// update cached values
|
||||||
if (!cache->isReadOnly()) {
|
if (!cache->isReadOnly()) {
|
||||||
cache->stampCacheFile(xmlPath);
|
cache->stampCacheFile(xmlPath);
|
||||||
cache->writeStringProperty(xmlPath.str(), name);
|
cache->writeStringProperty(xmlPath.utf8Str(), name);
|
||||||
}
|
}
|
||||||
} // of directory children iteration
|
} // of directory children iteration
|
||||||
|
|
||||||
|
|
|
@ -75,8 +75,8 @@ FGDeviceConfigurationMap::configurationForDeviceName(const std::string& name)
|
||||||
|
|
||||||
SGPropertyNode_ptr result(new SGPropertyNode);
|
SGPropertyNode_ptr result(new SGPropertyNode);
|
||||||
try {
|
try {
|
||||||
readProperties(it->second.str(), result);
|
readProperties(it->second, result);
|
||||||
result->setStringValue("source", it->second.c_str());
|
result->setStringValue("source", it->second.utf8Str());
|
||||||
} catch (sg_exception&) {
|
} catch (sg_exception&) {
|
||||||
SG_LOG(SG_INPUT, SG_WARN, "parse failure reading:" << it->second);
|
SG_LOG(SG_INPUT, SG_WARN, "parse failure reading:" << it->second);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -126,7 +126,7 @@ void FGDeviceConfigurationMap::readCachedData(const SGPath& path)
|
||||||
{
|
{
|
||||||
flightgear::NavDataCache* cache = flightgear::NavDataCache::instance();
|
flightgear::NavDataCache* cache = flightgear::NavDataCache::instance();
|
||||||
NamePathMap::iterator it;
|
NamePathMap::iterator it;
|
||||||
BOOST_FOREACH(string s, cache->readStringListProperty(path.str())) {
|
BOOST_FOREACH(string s, cache->readStringListProperty(path.utf8Str())) {
|
||||||
// important - only insert if not already present. This ensures
|
// important - only insert if not already present. This ensures
|
||||||
// user configs can override those in the base package, since they are
|
// user configs can override those in the base package, since they are
|
||||||
// searched first.
|
// searched first.
|
||||||
|
@ -139,10 +139,10 @@ void FGDeviceConfigurationMap::readCachedData(const SGPath& path)
|
||||||
|
|
||||||
void FGDeviceConfigurationMap::refreshCacheForFile(const SGPath& path)
|
void FGDeviceConfigurationMap::refreshCacheForFile(const SGPath& path)
|
||||||
{
|
{
|
||||||
SG_LOG(SG_INPUT, SG_DEBUG, "Reading device file " << path.str());
|
SG_LOG(SG_INPUT, SG_DEBUG, "Reading device file " << path);
|
||||||
SGPropertyNode_ptr n(new SGPropertyNode);
|
SGPropertyNode_ptr n(new SGPropertyNode);
|
||||||
try {
|
try {
|
||||||
readProperties(path.str(), n);
|
readProperties(path, n);
|
||||||
} catch (sg_exception&) {
|
} catch (sg_exception&) {
|
||||||
SG_LOG(SG_INPUT, SG_ALERT, "parse failure reading:" << path);
|
SG_LOG(SG_INPUT, SG_ALERT, "parse failure reading:" << path);
|
||||||
return;
|
return;
|
||||||
|
@ -161,5 +161,5 @@ void FGDeviceConfigurationMap::refreshCacheForFile(const SGPath& path)
|
||||||
|
|
||||||
flightgear::NavDataCache* cache = flightgear::NavDataCache::instance();
|
flightgear::NavDataCache* cache = flightgear::NavDataCache::instance();
|
||||||
cache->stampCacheFile(path);
|
cache->stampCacheFile(path);
|
||||||
cache->writeStringListProperty(path.str(), names);
|
cache->writeStringListProperty(path.utf8Str(), names);
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,7 +258,7 @@ static string fgScanForOption( const string& option, int argc, char **argv ) {
|
||||||
|
|
||||||
// Scan the user config files for the specified option and return
|
// Scan the user config files for the specified option and return
|
||||||
// the value.
|
// the value.
|
||||||
static string fgScanForOption( const string& option, const string& path ) {
|
static string fgScanForOption( const string& option, const SGPath& path ) {
|
||||||
sg_gzifstream in( path );
|
sg_gzifstream in( path );
|
||||||
if ( !in.is_open() ) {
|
if ( !in.is_open() ) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -311,7 +311,7 @@ static string fgScanForOption( const string& option ) {
|
||||||
if ( homedir != NULL ) {
|
if ( homedir != NULL ) {
|
||||||
SGPath config( homedir );
|
SGPath config( homedir );
|
||||||
config.append( ".fgfsrc" );
|
config.append( ".fgfsrc" );
|
||||||
arg = fgScanForOption( option, config.str() );
|
arg = fgScanForOption( option, config );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include <simgear/constants.h>
|
#include <simgear/constants.h>
|
||||||
#include <simgear/misc/sg_path.hxx>
|
#include <simgear/misc/sg_path.hxx>
|
||||||
|
#include <simgear/misc/sgstream.hxx>
|
||||||
#include <simgear/props/props_io.hxx>
|
#include <simgear/props/props_io.hxx>
|
||||||
#include <osg/GLU>
|
#include <osg/GLU>
|
||||||
|
|
||||||
|
@ -374,9 +375,9 @@ int HUD::load(const char *file, float x, float y, int level, const string& inden
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
ifstream input(path.c_str());
|
sg_ifstream input(path);
|
||||||
if (!input.good()) {
|
if (!input.good()) {
|
||||||
SG_LOG(SG_INPUT, SG_ALERT, "HUD: Cannot read configuration from '" << path.c_str() << "'");
|
SG_LOG(SG_INPUT, SG_ALERT, "HUD: Cannot read configuration from '" << path << "'");
|
||||||
return 0x4;
|
return 0x4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include <simgear/sg_inlines.h>
|
#include <simgear/sg_inlines.h>
|
||||||
#include <simgear/misc/sg_path.hxx>
|
#include <simgear/misc/sg_path.hxx>
|
||||||
|
#include <simgear/misc/sgstream.hxx>
|
||||||
#include <simgear/timing/sg_time.hxx>
|
#include <simgear/timing/sg_time.hxx>
|
||||||
#include <simgear/magvar/magvar.hxx>
|
#include <simgear/magvar/magvar.hxx>
|
||||||
#include <simgear/structure/exception.hxx>
|
#include <simgear/structure/exception.hxx>
|
||||||
|
@ -652,10 +653,10 @@ void DCLGPS::LoadApproachData() {
|
||||||
GPSFlightPlan* fp;
|
GPSFlightPlan* fp;
|
||||||
const GPSWaypoint* cwp;
|
const GPSWaypoint* cwp;
|
||||||
|
|
||||||
std::ifstream fin;
|
sg_ifstream fin;
|
||||||
SGPath path = globals->get_fg_root();
|
SGPath path = globals->get_fg_root();
|
||||||
path.append("Navaids/rnav.dat");
|
path.append("Navaids/rnav.dat");
|
||||||
fin.open(path.c_str(), ios::in);
|
fin.open(path, ios::in);
|
||||||
if(!fin) {
|
if(!fin) {
|
||||||
//cout << "Unable to open input file " << path.c_str() << '\n';
|
//cout << "Unable to open input file " << path.c_str() << '\n';
|
||||||
return;
|
return;
|
||||||
|
@ -1614,4 +1615,3 @@ SGGeod AlignedProjection::ConvertFromLocal(const SGVec3d& pt) {
|
||||||
|
|
||||||
return SGGeod::fromRadM(_origin.getLongitudeRad()+delta_lon, _origin.getLatitudeRad()+delta_lat, pt.z());
|
return SGGeod::fromRadM(_origin.getLongitudeRad()+delta_lon, _origin.getLatitudeRad()+delta_lat, pt.z());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,10 +73,10 @@ void FGInstrumentMgr::init()
|
||||||
}
|
}
|
||||||
|
|
||||||
SGPath config = globals->resolve_aircraft_path(path_n->getStringValue());
|
SGPath config = globals->resolve_aircraft_path(path_n->getStringValue());
|
||||||
SG_LOG( SG_COCKPIT, SG_INFO, "Reading instruments from " << config.str() );
|
SG_LOG( SG_COCKPIT, SG_INFO, "Reading instruments from " << config );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
readProperties( config.str(), config_props );
|
readProperties( config, config_props );
|
||||||
if (!build(config_props)) {
|
if (!build(config_props)) {
|
||||||
throw sg_exception(
|
throw sg_exception(
|
||||||
"Detected an internal inconsistency in the instrumentation\n"
|
"Detected an internal inconsistency in the instrumentation\n"
|
||||||
|
@ -84,7 +84,7 @@ void FGInstrumentMgr::init()
|
||||||
}
|
}
|
||||||
} catch (const sg_exception& e) {
|
} catch (const sg_exception& e) {
|
||||||
SG_LOG(SG_COCKPIT, SG_ALERT, "Failed to load instrumentation system model: "
|
SG_LOG(SG_COCKPIT, SG_ALERT, "Failed to load instrumentation system model: "
|
||||||
<< config.str() << ":" << e.getFormattedMessage() );
|
<< config << ":" << e.getFormattedMessage() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -140,9 +140,9 @@ FGNavRadio::FGNavRadio(SGPropertyNode *node) :
|
||||||
SGPath high = path;
|
SGPath high = path;
|
||||||
high.append( "Navaids/range.high" );
|
high.append( "Navaids/range.high" );
|
||||||
|
|
||||||
static_terminalRangeInterp.reset(new SGInterpTable(term.str()));
|
static_terminalRangeInterp.reset(new SGInterpTable(term));
|
||||||
static_lowRangeInterp.reset(new SGInterpTable(low.str()));
|
static_lowRangeInterp.reset(new SGInterpTable(low));
|
||||||
static_highRangeInterp.reset(new SGInterpTable(high.str()));
|
static_highRangeInterp.reset(new SGInterpTable(high));
|
||||||
}
|
}
|
||||||
|
|
||||||
string branch("/instrumentation/" + _name);
|
string branch("/instrumentation/" + _name);
|
||||||
|
|
|
@ -307,12 +307,12 @@ void NavRadioComponent::update( double dt, const SGGeod & aircraftPosition )
|
||||||
|
|
||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
|
|
||||||
static std::string VORTablePath( const char * name )
|
static SGPath VORTablePath( const char * name )
|
||||||
{
|
{
|
||||||
SGPath path( globals->get_fg_root() );
|
SGPath path( globals->get_fg_root() );
|
||||||
path.append( "Navaids" );
|
path.append( "Navaids" );
|
||||||
path.append(name);
|
path.append(name);
|
||||||
return path.str();
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
class VOR : public NavRadioComponentWithIdent {
|
class VOR : public NavRadioComponentWithIdent {
|
||||||
|
|
|
@ -539,12 +539,12 @@ do_materials_reload (const SGPropertyNode * arg)
|
||||||
SGPath mpath( globals->get_fg_root() );
|
SGPath mpath( globals->get_fg_root() );
|
||||||
mpath.append( fgGetString("/sim/rendering/materials-file") );
|
mpath.append( fgGetString("/sim/rendering/materials-file") );
|
||||||
bool loaded = new_matlib->load(globals->get_fg_root().local8BitStr(),
|
bool loaded = new_matlib->load(globals->get_fg_root().local8BitStr(),
|
||||||
mpath.str(),
|
mpath.local8BitStr(),
|
||||||
globals->get_props());
|
globals->get_props());
|
||||||
|
|
||||||
if ( ! loaded ) {
|
if ( ! loaded ) {
|
||||||
SG_LOG( SG_GENERAL, SG_ALERT,
|
SG_LOG( SG_GENERAL, SG_ALERT,
|
||||||
"Error loading materials file " << mpath.str() );
|
"Error loading materials file " << mpath );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1121,7 +1121,7 @@ static bool
|
||||||
do_load_xml_to_proptree(const SGPropertyNode * arg)
|
do_load_xml_to_proptree(const SGPropertyNode * arg)
|
||||||
{
|
{
|
||||||
SGPath file(arg->getStringValue("filename"));
|
SGPath file(arg->getStringValue("filename"));
|
||||||
if (file.str().empty())
|
if (file.isNull())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (file.extension() != "xml")
|
if (file.extension() != "xml")
|
||||||
|
@ -1130,27 +1130,27 @@ do_load_xml_to_proptree(const SGPropertyNode * arg)
|
||||||
std::string icao = arg->getStringValue("icao");
|
std::string icao = arg->getStringValue("icao");
|
||||||
if (icao.empty()) {
|
if (icao.empty()) {
|
||||||
if (file.isRelative()) {
|
if (file.isRelative()) {
|
||||||
SGPath absPath = globals->resolve_maybe_aircraft_path(file.str());
|
SGPath absPath = globals->resolve_maybe_aircraft_path(file.utf8Str());
|
||||||
if (!absPath.isNull())
|
if (!absPath.isNull())
|
||||||
file = absPath;
|
file = absPath;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SG_LOG(SG_IO, SG_ALERT, "loadxml: Cannot find XML property file '"
|
SG_LOG(SG_IO, SG_ALERT, "loadxml: Cannot find XML property file '"
|
||||||
<< file.str() << "'.");
|
<< file << "'.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!XMLLoader::findAirportData(icao, file.str(), file)) {
|
if (!XMLLoader::findAirportData(icao, file.utf8Str(), file)) {
|
||||||
SG_LOG(SG_IO, SG_INFO, "loadxml: failed to find airport data for "
|
SG_LOG(SG_IO, SG_INFO, "loadxml: failed to find airport data for "
|
||||||
<< file.str() << " at ICAO:" << icao);
|
<< file << " at ICAO:" << icao);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string validated_path = fgValidatePath(file, false);
|
std::string validated_path = fgValidatePath(file, false);
|
||||||
if (validated_path.empty()) {
|
if (validated_path.empty()) {
|
||||||
SG_LOG(SG_IO, SG_ALERT, "loadxml: reading '" << file.str() << "' denied "
|
SG_LOG(SG_IO, SG_ALERT, "loadxml: reading '" << file << "' denied "
|
||||||
"(unauthorized directory - authorization no longer follows symlinks; to authorize reading additional directories, add them to --fg-aircraft)");
|
"(unauthorized directory - authorization no longer follows symlinks; to authorize reading additional directories, add them to --fg-aircraft)");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1225,7 +1225,7 @@ static bool
|
||||||
do_save_xml_from_proptree(const SGPropertyNode * arg)
|
do_save_xml_from_proptree(const SGPropertyNode * arg)
|
||||||
{
|
{
|
||||||
SGPath file(arg->getStringValue("filename"));
|
SGPath file(arg->getStringValue("filename"));
|
||||||
if (file.str().empty())
|
if (file.isNull())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (file.extension() != "xml")
|
if (file.extension() != "xml")
|
||||||
|
@ -1233,7 +1233,7 @@ do_save_xml_from_proptree(const SGPropertyNode * arg)
|
||||||
|
|
||||||
std::string validated_path = fgValidatePath(file, true);
|
std::string validated_path = fgValidatePath(file, true);
|
||||||
if (validated_path.empty()) {
|
if (validated_path.empty()) {
|
||||||
SG_LOG(SG_IO, SG_ALERT, "savexml: writing to '" << file.str() << "' denied "
|
SG_LOG(SG_IO, SG_ALERT, "savexml: writing to '" << file << "' denied "
|
||||||
"(unauthorized directory - authorization no longer follows symlinks)");
|
"(unauthorized directory - authorization no longer follows symlinks)");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1367,7 +1367,7 @@ do_set_scenery_paths(const SGPropertyNode* arg)
|
||||||
// no scenery paths set *at all*, use the data in FG_ROOT
|
// no scenery paths set *at all*, use the data in FG_ROOT
|
||||||
SGPath root(globals->get_fg_root());
|
SGPath root(globals->get_fg_root());
|
||||||
root.append("Scenery");
|
root.append("Scenery");
|
||||||
globals->append_fg_scenery(root.str());
|
globals->append_fg_scenery(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -210,7 +210,7 @@ public:
|
||||||
SG_LOG(SG_GENERAL, SG_INFO, "found aircraft in dir: " << aircraftDir );
|
SG_LOG(SG_GENERAL, SG_INFO, "found aircraft in dir: " << aircraftDir );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
readProperties(setFile.str(), globals->get_props());
|
readProperties(setFile, globals->get_props());
|
||||||
} catch ( const sg_exception &e ) {
|
} catch ( const sg_exception &e ) {
|
||||||
SG_LOG(SG_INPUT, SG_ALERT, "Error reading aircraft: " << e.getFormattedMessage());
|
SG_LOG(SG_INPUT, SG_ALERT, "Error reading aircraft: " << e.getFormattedMessage());
|
||||||
flightgear::fatalMessageBox("Error reading aircraft",
|
flightgear::fatalMessageBox("Error reading aircraft",
|
||||||
|
@ -234,7 +234,7 @@ public:
|
||||||
if (!checkCache()) {
|
if (!checkCache()) {
|
||||||
// prepare cache for re-scan
|
// prepare cache for re-scan
|
||||||
SGPropertyNode *n = _cache->getNode("fg-root", true);
|
SGPropertyNode *n = _cache->getNode("fg-root", true);
|
||||||
n->setStringValue(globals->get_fg_root().c_str());
|
n->setStringValue(globals->get_fg_root().utf8Str());
|
||||||
n->setAttribute(SGPropertyNode::USERARCHIVE, true);
|
n->setAttribute(SGPropertyNode::USERARCHIVE, true);
|
||||||
n = _cache->getNode("fg-aircraft", true);
|
n = _cache->getNode("fg-aircraft", true);
|
||||||
n->setStringValue(getAircraftPaths().c_str());
|
n->setStringValue(getAircraftPaths().c_str());
|
||||||
|
@ -244,7 +244,7 @@ public:
|
||||||
visitAircraftPaths();
|
visitAircraftPaths();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_foundPath.str().empty()) {
|
if (_foundPath.isNull()) {
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "Cannot find specified aircraft: " << aircraft );
|
SG_LOG(SG_GENERAL, SG_ALERT, "Cannot find specified aircraft: " << aircraft );
|
||||||
flightgear::fatalMessageBox("Aircraft not found",
|
flightgear::fatalMessageBox("Aircraft not found",
|
||||||
"The requested aircraft '" + aircraft + "' could not be found in any of the search paths");
|
"The requested aircraft '" + aircraft + "' could not be found in any of the search paths");
|
||||||
|
@ -252,15 +252,15 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SG_LOG(SG_GENERAL, SG_INFO, "Loading aircraft -set file from:" << _foundPath.str());
|
SG_LOG(SG_GENERAL, SG_INFO, "Loading aircraft -set file from:" << _foundPath);
|
||||||
fgSetString( "/sim/aircraft-dir", _foundPath.dir().c_str());
|
fgSetString( "/sim/aircraft-dir", _foundPath.dir().c_str());
|
||||||
if (!_foundPath.exists()) {
|
if (!_foundPath.exists()) {
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "Unable to find -set file:" << _foundPath.str());
|
SG_LOG(SG_GENERAL, SG_ALERT, "Unable to find -set file:" << _foundPath);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
readProperties(_foundPath.str(), globals->get_props());
|
readProperties(_foundPath, globals->get_props());
|
||||||
} catch ( const sg_exception &e ) {
|
} catch ( const sg_exception &e ) {
|
||||||
SG_LOG(SG_INPUT, SG_ALERT, "Error reading aircraft: " << e.getFormattedMessage());
|
SG_LOG(SG_INPUT, SG_ALERT, "Error reading aircraft: " << e.getFormattedMessage());
|
||||||
flightgear::fatalMessageBox("Error reading aircraft",
|
flightgear::fatalMessageBox("Error reading aircraft",
|
||||||
|
@ -400,10 +400,11 @@ bool fgInitHome()
|
||||||
|
|
||||||
char buf[16];
|
char buf[16];
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
std::string ps = pidPath.local8BitStr();
|
||||||
#if defined(SG_WINDOWS)
|
#if defined(SG_WINDOWS)
|
||||||
size_t len = snprintf(buf, 16, "%d", _getpid());
|
size_t len = snprintf(buf, 16, "%d", _getpid());
|
||||||
|
|
||||||
HANDLE f = CreateFileA(pidPath.c_str(), GENERIC_READ | GENERIC_WRITE,
|
HANDLE f = CreateFileA(ps.c_str(), GENERIC_READ | GENERIC_WRITE,
|
||||||
FILE_SHARE_READ, /* sharing */
|
FILE_SHARE_READ, /* sharing */
|
||||||
NULL, /* security attributes */
|
NULL, /* security attributes */
|
||||||
CREATE_NEW, /* error if already exists */
|
CREATE_NEW, /* error if already exists */
|
||||||
|
@ -419,10 +420,10 @@ bool fgInitHome()
|
||||||
// POSIX, do open+unlink trick to the file is deleted on exit, even if we
|
// POSIX, do open+unlink trick to the file is deleted on exit, even if we
|
||||||
// crash or exit(-1)
|
// crash or exit(-1)
|
||||||
ssize_t len = snprintf(buf, 16, "%d", getpid());
|
ssize_t len = snprintf(buf, 16, "%d", getpid());
|
||||||
int fd = ::open(pidPath.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0644);
|
int fd = ::open(ps.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0644);
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
result = ::write(fd, buf, len) == len;
|
result = ::write(fd, buf, len) == len;
|
||||||
if( ::unlink(pidPath.c_str()) != 0 ) // delete file when app quits
|
if( ::unlink(ps.c_str()) != 0 ) // delete file when app quits
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -432,7 +433,7 @@ bool fgInitHome()
|
||||||
if (!result) {
|
if (!result) {
|
||||||
flightgear::fatalMessageBox("File permissions problem",
|
flightgear::fatalMessageBox("File permissions problem",
|
||||||
"Can't write to user-data storage folder, check file permissions and FG_HOME.",
|
"Can't write to user-data storage folder, check file permissions and FG_HOME.",
|
||||||
"User-data at:" + dataPath.str());
|
"User-data at:" + dataPath.utf8Str());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -453,7 +454,7 @@ int fgInitConfig ( int argc, char **argv, bool reinit )
|
||||||
SGPropertyNode *home = fgGetNode("/sim", true);
|
SGPropertyNode *home = fgGetNode("/sim", true);
|
||||||
home->removeChild("fg-home", 0);
|
home->removeChild("fg-home", 0);
|
||||||
home = home->getChild("fg-home", 0, true);
|
home = home->getChild("fg-home", 0, true);
|
||||||
home->setStringValue(dataPath.c_str());
|
home->setStringValue(dataPath.utf8Str());
|
||||||
home->setAttribute(SGPropertyNode::WRITE, false);
|
home->setAttribute(SGPropertyNode::WRITE, false);
|
||||||
|
|
||||||
fgSetDefaults();
|
fgSetDefaults();
|
||||||
|
@ -540,7 +541,7 @@ int fgInitAircraft(bool reinit)
|
||||||
|
|
||||||
// set aircraft-dir to short circuit the search process
|
// set aircraft-dir to short circuit the search process
|
||||||
InstallRef acftInstall = acftPackage->install();
|
InstallRef acftInstall = acftPackage->install();
|
||||||
fgSetString("/sim/aircraft-dir", acftInstall->path().c_str());
|
fgSetString("/sim/aircraft-dir", acftInstall->path().utf8Str());
|
||||||
|
|
||||||
// overwrite the fully qualified ID with the aircraft one, so the
|
// overwrite the fully qualified ID with the aircraft one, so the
|
||||||
// code in FindAndCacheAircraft works as normal
|
// code in FindAndCacheAircraft works as normal
|
||||||
|
@ -649,7 +650,7 @@ bool fgInitGeneral() {
|
||||||
SGPropertyNode *curr = fgGetNode("/sim", true);
|
SGPropertyNode *curr = fgGetNode("/sim", true);
|
||||||
curr->removeChild("fg-current", 0);
|
curr->removeChild("fg-current", 0);
|
||||||
curr = curr->getChild("fg-current", 0, true);
|
curr = curr->getChild("fg-current", 0, true);
|
||||||
curr->setStringValue(cwd.path().str());
|
curr->setStringValue(cwd.path().utf8Str());
|
||||||
curr->setAttribute(SGPropertyNode::WRITE, false);
|
curr->setAttribute(SGPropertyNode::WRITE, false);
|
||||||
|
|
||||||
fgSetBool("/sim/startup/stdout-to-terminal", isatty(1) != 0 );
|
fgSetBool("/sim/startup/stdout-to-terminal", isatty(1) != 0 );
|
||||||
|
@ -731,7 +732,7 @@ void fgCreateSubsystems(bool duringReset) {
|
||||||
|
|
||||||
SGPath mpath( globals->get_fg_root() );
|
SGPath mpath( globals->get_fg_root() );
|
||||||
mpath.append( fgGetString("/sim/rendering/materials-file") );
|
mpath.append( fgGetString("/sim/rendering/materials-file") );
|
||||||
if ( ! globals->get_matlib()->load(globals->get_fg_root().local8BitStr(), mpath.str(),
|
if ( ! globals->get_matlib()->load(globals->get_fg_root().local8BitStr(), mpath.local8BitStr(),
|
||||||
globals->get_props()) ) {
|
globals->get_props()) ) {
|
||||||
throw sg_io_exception("Error loading materials file", mpath);
|
throw sg_io_exception("Error loading materials file", mpath);
|
||||||
}
|
}
|
||||||
|
@ -1137,7 +1138,7 @@ void fgInitPackageRoot()
|
||||||
|
|
||||||
packageAircraftDir.append("Aircraft");
|
packageAircraftDir.append("Aircraft");
|
||||||
|
|
||||||
SG_LOG(SG_GENERAL, SG_INFO, "init package root at:" << packageAircraftDir.str());
|
SG_LOG(SG_GENERAL, SG_INFO, "init package root at:" << packageAircraftDir);
|
||||||
|
|
||||||
|
|
||||||
SGSharedPtr<Root> pkgRoot(new Root(packageAircraftDir, FLIGHTGEAR_VERSION));
|
SGSharedPtr<Root> pkgRoot(new Root(packageAircraftDir, FLIGHTGEAR_VERSION));
|
||||||
|
|
|
@ -684,15 +684,15 @@ fgLoadFlight (std::istream &input)
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
fgLoadProps (const char * path, SGPropertyNode * props, bool in_fg_root, int default_mode)
|
fgLoadProps (const std::string& path, SGPropertyNode * props, bool in_fg_root, int default_mode)
|
||||||
{
|
{
|
||||||
string fullpath;
|
SGPath fullpath;
|
||||||
if (in_fg_root) {
|
if (in_fg_root) {
|
||||||
SGPath loadpath(globals->get_fg_root());
|
SGPath loadpath(globals->get_fg_root());
|
||||||
loadpath.append(path);
|
loadpath.append(path);
|
||||||
fullpath = loadpath.str();
|
fullpath = loadpath;
|
||||||
} else {
|
} else {
|
||||||
fullpath = path;
|
fullpath = SGPath::fromUtf8(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -79,7 +79,7 @@ extern bool fgLoadFlight (std::istream &input);
|
||||||
* @return true if the properties loaded successfully, false
|
* @return true if the properties loaded successfully, false
|
||||||
* otherwise.
|
* otherwise.
|
||||||
*/
|
*/
|
||||||
extern bool fgLoadProps (const char * path, SGPropertyNode * props,
|
extern bool fgLoadProps (const std::string& path, SGPropertyNode * props,
|
||||||
bool in_fg_root = true, int default_mode = 0);
|
bool in_fg_root = true, int default_mode = 0);
|
||||||
|
|
||||||
void setLoggingClasses (const char * c);
|
void setLoggingClasses (const char * c);
|
||||||
|
|
|
@ -361,7 +361,7 @@ void FGGlobals::append_fg_scenery (const SGPath &path, bool secure)
|
||||||
|
|
||||||
// tell the ResouceManager about the scenery path
|
// tell the ResouceManager about the scenery path
|
||||||
// needed to load Models from this scenery path
|
// needed to load Models from this scenery path
|
||||||
simgear::ResourceManager::instance()->addBasePath(abspath.str(),
|
simgear::ResourceManager::instance()->addBasePath(abspath.local8BitStr(),
|
||||||
simgear::ResourceManager::PRIORITY_DEFAULT);
|
simgear::ResourceManager::PRIORITY_DEFAULT);
|
||||||
|
|
||||||
simgear::Dir dir(abspath);
|
simgear::Dir dir(abspath);
|
||||||
|
@ -611,7 +611,7 @@ FGGlobals::resetPropertyRoot()
|
||||||
SGPropertyNode *n = props->getNode("/sim", true);
|
SGPropertyNode *n = props->getNode("/sim", true);
|
||||||
n->removeChild("fg-root", 0);
|
n->removeChild("fg-root", 0);
|
||||||
n = n->getChild("fg-root", 0, true);
|
n = n->getChild("fg-root", 0, true);
|
||||||
n->setStringValue(fg_root.c_str());
|
n->setStringValue(fg_root.utf8Str());
|
||||||
n->setAttribute(SGPropertyNode::WRITE, false);
|
n->setAttribute(SGPropertyNode::WRITE, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -637,9 +637,9 @@ FGGlobals::loadUserSettings(const SGPath& dataPath)
|
||||||
SGPath autosaveFile = simgear::Dir(dataPath).file(autosaveName());
|
SGPath autosaveFile = simgear::Dir(dataPath).file(autosaveName());
|
||||||
SGPropertyNode autosave;
|
SGPropertyNode autosave;
|
||||||
if (autosaveFile.exists()) {
|
if (autosaveFile.exists()) {
|
||||||
SG_LOG(SG_INPUT, SG_INFO, "Reading user settings from " << autosaveFile.str());
|
SG_LOG(SG_INPUT, SG_INFO, "Reading user settings from " << autosaveFile);
|
||||||
try {
|
try {
|
||||||
readProperties(autosaveFile.str(), &autosave, SGPropertyNode::USERARCHIVE);
|
readProperties(autosaveFile, &autosave, SGPropertyNode::USERARCHIVE);
|
||||||
} catch (sg_exception& e) {
|
} catch (sg_exception& e) {
|
||||||
SG_LOG(SG_INPUT, SG_WARN, "failed to read user settings:" << e.getMessage()
|
SG_LOG(SG_INPUT, SG_WARN, "failed to read user settings:" << e.getMessage()
|
||||||
<< "(from " << e.getOrigin() << ")");
|
<< "(from " << e.getOrigin() << ")");
|
||||||
|
@ -664,9 +664,9 @@ FGGlobals::saveUserSettings()
|
||||||
SGPath autosaveFile(globals->get_fg_home());
|
SGPath autosaveFile(globals->get_fg_home());
|
||||||
autosaveFile.append(autosaveName());
|
autosaveFile.append(autosaveName());
|
||||||
autosaveFile.create_dir( 0700 );
|
autosaveFile.create_dir( 0700 );
|
||||||
SG_LOG(SG_IO, SG_INFO, "Saving user settings to " << autosaveFile.str());
|
SG_LOG(SG_IO, SG_INFO, "Saving user settings to " << autosaveFile);
|
||||||
try {
|
try {
|
||||||
writeProperties(autosaveFile.str(), globals->get_props(), false, SGPropertyNode::USERARCHIVE);
|
writeProperties(autosaveFile, globals->get_props(), false, SGPropertyNode::USERARCHIVE);
|
||||||
} catch (const sg_exception &e) {
|
} catch (const sg_exception &e) {
|
||||||
guiErrorMessage("Error writing autosave:", e);
|
guiErrorMessage("Error writing autosave:", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,15 +216,15 @@ FGLocale::loadResource(SGPropertyNode* localeNode, const char* resource)
|
||||||
path.append(path_str);
|
path.append(path_str);
|
||||||
SG_LOG(SG_GENERAL, SG_INFO, "Reading localized strings for '" <<
|
SG_LOG(SG_GENERAL, SG_INFO, "Reading localized strings for '" <<
|
||||||
localeNode->getStringValue("lang", "<none>")
|
localeNode->getStringValue("lang", "<none>")
|
||||||
<<"' from " << path.str());
|
<<"' from " << path);
|
||||||
|
|
||||||
// load the actual file
|
// load the actual file
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
readProperties(path.str(), stringNode->getNode(resource, 0, true));
|
readProperties(path, stringNode->getNode(resource, 0, true));
|
||||||
} catch (const sg_exception &e)
|
} catch (const sg_exception &e)
|
||||||
{
|
{
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "Unable to read the localized strings from " << path.str() <<
|
SG_LOG(SG_GENERAL, SG_ALERT, "Unable to read the localized strings from " << path <<
|
||||||
". Error: " << e.getFormattedMessage());
|
". Error: " << e.getFormattedMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ static void initTerrasync()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fgSetString("/sim/terrasync/cache-path", tsyncCache.c_str());
|
fgSetString("/sim/terrasync/cache-path", tsyncCache.utf8Str());
|
||||||
|
|
||||||
simgear::SGTerraSync* terra_sync = new simgear::SGTerraSync();
|
simgear::SGTerraSync* terra_sync = new simgear::SGTerraSync();
|
||||||
terra_sync->setRoot(globals->get_props());
|
terra_sync->setRoot(globals->get_props());
|
||||||
|
@ -171,10 +171,10 @@ static void fgSetVideoOptions()
|
||||||
}
|
}
|
||||||
path.append(renderer+".xml");
|
path.append(renderer+".xml");
|
||||||
if (path.exists()) {
|
if (path.exists()) {
|
||||||
SG_LOG(SG_INPUT, SG_INFO, "Reading video settings from " << path.str());
|
SG_LOG(SG_INPUT, SG_INFO, "Reading video settings from " << path);
|
||||||
try {
|
try {
|
||||||
SGPropertyNode *r_prop = fgGetNode("/sim/rendering");
|
SGPropertyNode *r_prop = fgGetNode("/sim/rendering");
|
||||||
readProperties(path.str(), r_prop);
|
readProperties(path, r_prop);
|
||||||
} catch (sg_exception& e) {
|
} catch (sg_exception& e) {
|
||||||
SG_LOG(SG_INPUT, SG_WARN, "failed to read video settings:" << e.getMessage()
|
SG_LOG(SG_INPUT, SG_WARN, "failed to read video settings:" << e.getMessage()
|
||||||
<< "(from " << e.getOrigin() << ")");
|
<< "(from " << e.getOrigin() << ")");
|
||||||
|
|
|
@ -277,7 +277,7 @@ private:
|
||||||
{
|
{
|
||||||
SGPropertyNode root;
|
SGPropertyNode root;
|
||||||
try {
|
try {
|
||||||
readProperties(path.str(), &root);
|
readProperties(path, &root);
|
||||||
} catch (sg_exception& ) {
|
} catch (sg_exception& ) {
|
||||||
return VISIT_CONTINUE;
|
return VISIT_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -1455,7 +1455,7 @@ fgOptLoadTape(const char* arg)
|
||||||
class DelayedTapeLoader : SGPropertyChangeListener {
|
class DelayedTapeLoader : SGPropertyChangeListener {
|
||||||
public:
|
public:
|
||||||
DelayedTapeLoader( const char * tape ) :
|
DelayedTapeLoader( const char * tape ) :
|
||||||
_tape(tape)
|
_tape(SGPath::fromLocal8Bit(tape))
|
||||||
{
|
{
|
||||||
SGPropertyNode_ptr n = fgGetNode("/sim/signals/fdm-initialized", true);
|
SGPropertyNode_ptr n = fgGetNode("/sim/signals/fdm-initialized", true);
|
||||||
n->addChangeListener( this );
|
n->addChangeListener( this );
|
||||||
|
@ -1470,14 +1470,14 @@ fgOptLoadTape(const char* arg)
|
||||||
// tell the replay subsystem to load the tape
|
// tell the replay subsystem to load the tape
|
||||||
FGReplay* replay = (FGReplay*) globals->get_subsystem("replay");
|
FGReplay* replay = (FGReplay*) globals->get_subsystem("replay");
|
||||||
SGPropertyNode_ptr arg = new SGPropertyNode();
|
SGPropertyNode_ptr arg = new SGPropertyNode();
|
||||||
arg->setStringValue("tape", _tape );
|
arg->setStringValue("tape", _tape.utf8Str() );
|
||||||
arg->setBoolValue( "same-aircraft", 0 );
|
arg->setBoolValue( "same-aircraft", 0 );
|
||||||
replay->loadTape(arg);
|
replay->loadTape(arg);
|
||||||
|
|
||||||
delete this; // commence suicide
|
delete this; // commence suicide
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
std::string _tape;
|
SGPath _tape;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1952,9 +1952,9 @@ void Options::init(int argc, char **argv, const SGPath& appDataPath)
|
||||||
processArgResult(result);
|
processArgResult(result);
|
||||||
} else {
|
} else {
|
||||||
// XML properties file
|
// XML properties file
|
||||||
SGPath f(argv[i]);
|
SGPath f = SGPath::fromLocal8Bit(argv[i]);
|
||||||
if (!f.exists()) {
|
if (!f.exists()) {
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "config file not found:" << f.str());
|
SG_LOG(SG_GENERAL, SG_ALERT, "config file not found:" << f);
|
||||||
} else {
|
} else {
|
||||||
p->propertyFiles.push_back(f);
|
p->propertyFiles.push_back(f);
|
||||||
}
|
}
|
||||||
|
@ -1973,14 +1973,11 @@ void Options::init(int argc, char **argv, const SGPath& appDataPath)
|
||||||
|
|
||||||
// then config files
|
// then config files
|
||||||
SGPath config;
|
SGPath config;
|
||||||
std::string homedir;
|
|
||||||
if (getenv("HOME")) {
|
|
||||||
homedir = getenv("HOME");
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !homedir.empty() && !hostname.empty() ) {
|
|
||||||
|
if( !hostname.empty() ) {
|
||||||
// Check for ~/.fgfsrc.hostname
|
// Check for ~/.fgfsrc.hostname
|
||||||
config.set(homedir);
|
config = SGPath::home();
|
||||||
config.append(".fgfsrc");
|
config.append(".fgfsrc");
|
||||||
config.concat( "." );
|
config.concat( "." );
|
||||||
config.concat( hostname );
|
config.concat( hostname );
|
||||||
|
@ -1988,11 +1985,9 @@ void Options::init(int argc, char **argv, const SGPath& appDataPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for ~/.fgfsrc
|
// Check for ~/.fgfsrc
|
||||||
if( !homedir.empty() ) {
|
config = SGPath::home();
|
||||||
config.set(homedir);
|
|
||||||
config.append(".fgfsrc");
|
config.append(".fgfsrc");
|
||||||
readConfig(config);
|
readConfig(config);
|
||||||
}
|
|
||||||
|
|
||||||
// check for a config file in app data
|
// check for a config file in app data
|
||||||
SGPath appDataConfig(appDataPath);
|
SGPath appDataConfig(appDataPath);
|
||||||
|
@ -2006,7 +2001,7 @@ void Options::init(int argc, char **argv, const SGPath& appDataPath)
|
||||||
|
|
||||||
// system.fgfsrc is disabled, as we no longer allow anything in fgdata to set
|
// system.fgfsrc is disabled, as we no longer allow anything in fgdata to set
|
||||||
// fg-root/fg-home/fg-aircraft and hence control what files Nasal can access
|
// fg-root/fg-home/fg-aircraft and hence control what files Nasal can access
|
||||||
std::string name_for_error = homedir.empty() ? appDataConfig.str() : config.str();
|
std::string name_for_error = config.utf8Str();
|
||||||
if( ! hostname.empty() ) {
|
if( ! hostname.empty() ) {
|
||||||
config = globals->get_fg_root();
|
config = globals->get_fg_root();
|
||||||
config.append( "system.fgfsrc" );
|
config.append( "system.fgfsrc" );
|
||||||
|
@ -2014,7 +2009,7 @@ void Options::init(int argc, char **argv, const SGPath& appDataPath)
|
||||||
config.concat( hostname );
|
config.concat( hostname );
|
||||||
if (config.exists()) {
|
if (config.exists()) {
|
||||||
flightgear::fatalMessageBox("Unsupported configuration",
|
flightgear::fatalMessageBox("Unsupported configuration",
|
||||||
"You have a " + config.str() + " file, which is no longer processed for security reasons",
|
"You have a " + config.utf8Str() + " file, which is no longer processed for security reasons",
|
||||||
"If you created this file intentionally, please move it to " + name_for_error);
|
"If you created this file intentionally, please move it to " + name_for_error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2023,7 +2018,7 @@ void Options::init(int argc, char **argv, const SGPath& appDataPath)
|
||||||
config.append( "system.fgfsrc" );
|
config.append( "system.fgfsrc" );
|
||||||
if (config.exists()) {
|
if (config.exists()) {
|
||||||
flightgear::fatalMessageBox("Unsupported configuration",
|
flightgear::fatalMessageBox("Unsupported configuration",
|
||||||
"You have a " + config.str() + " file, which is no longer processed for security reasons",
|
"You have a " + config.utf8Str() + " file, which is no longer processed for security reasons",
|
||||||
"If you created this file intentionally, please move it to " + name_for_error);
|
"If you created this file intentionally, please move it to " + name_for_error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2132,12 +2127,12 @@ void Options::processArgResult(int result)
|
||||||
|
|
||||||
void Options::readConfig(const SGPath& path)
|
void Options::readConfig(const SGPath& path)
|
||||||
{
|
{
|
||||||
sg_gzifstream in( path.str() );
|
sg_gzifstream in( path );
|
||||||
if ( !in.is_open() ) {
|
if ( !in.is_open() ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SG_LOG( SG_GENERAL, SG_INFO, "Processing config file: " << path.str() );
|
SG_LOG( SG_GENERAL, SG_INFO, "Processing config file: " << path );
|
||||||
|
|
||||||
in >> skipcomment;
|
in >> skipcomment;
|
||||||
while ( ! in.eof() ) {
|
while ( ! in.eof() ) {
|
||||||
|
@ -2152,7 +2147,7 @@ void Options::readConfig(const SGPath& path)
|
||||||
line = line.substr( 0, i );
|
line = line.substr( 0, i );
|
||||||
|
|
||||||
if ( parseOption( line ) == FG_OPTIONS_ERROR ) {
|
if ( parseOption( line ) == FG_OPTIONS_ERROR ) {
|
||||||
cerr << endl << "Config file parse error: " << path.str() << " '"
|
cerr << endl << "Config file parse error: " << path << " '"
|
||||||
<< line << "'" << endl;
|
<< line << "'" << endl;
|
||||||
p->showHelp = true;
|
p->showHelp = true;
|
||||||
}
|
}
|
||||||
|
@ -2290,7 +2285,7 @@ string_list Options::valuesForOption(const std::string& key) const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
string defaultDownloadDir()
|
SGPath defaultDownloadDir()
|
||||||
{
|
{
|
||||||
#if defined(SG_WINDOWS)
|
#if defined(SG_WINDOWS)
|
||||||
SGPath p(SGPath::documents());
|
SGPath p(SGPath::documents());
|
||||||
|
@ -2298,7 +2293,7 @@ string defaultDownloadDir()
|
||||||
#else
|
#else
|
||||||
SGPath p(globals->get_fg_home());
|
SGPath p(globals->get_fg_home());
|
||||||
#endif
|
#endif
|
||||||
return p.str();
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
OptionResult Options::processOptions()
|
OptionResult Options::processOptions()
|
||||||
|
@ -2349,8 +2344,8 @@ OptionResult Options::processOptions()
|
||||||
|
|
||||||
BOOST_FOREACH(const SGPath& file, p->propertyFiles) {
|
BOOST_FOREACH(const SGPath& file, p->propertyFiles) {
|
||||||
SG_LOG(SG_GENERAL, SG_INFO,
|
SG_LOG(SG_GENERAL, SG_INFO,
|
||||||
"Reading command-line property file " << file.str());
|
"Reading command-line property file " << file);
|
||||||
readProperties(file.str(), globals->get_props());
|
readProperties(file, globals->get_props());
|
||||||
}
|
}
|
||||||
|
|
||||||
// now options are process, do supplemental fixup
|
// now options are process, do supplemental fixup
|
||||||
|
@ -2360,8 +2355,8 @@ OptionResult Options::processOptions()
|
||||||
}
|
}
|
||||||
|
|
||||||
// download dir fix-up
|
// download dir fix-up
|
||||||
string downloadDir = simgear::strutils::strip(fgGetString("/sim/paths/download-dir"));
|
SGPath downloadDir = SGPath::fromUtf8(fgGetString("/sim/paths/download-dir"));
|
||||||
if (downloadDir.empty()) {
|
if (downloadDir.isNull()) {
|
||||||
downloadDir = defaultDownloadDir();
|
downloadDir = defaultDownloadDir();
|
||||||
SG_LOG(SG_GENERAL, SG_INFO, "Using default download dir: " << downloadDir);
|
SG_LOG(SG_GENERAL, SG_INFO, "Using default download dir: " << downloadDir);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2373,11 +2368,11 @@ OptionResult Options::processOptions()
|
||||||
}
|
}
|
||||||
|
|
||||||
// terrasync directory fixup
|
// terrasync directory fixup
|
||||||
string terrasyncDir = simgear::strutils::strip(fgGetString("/sim/terrasync/scenery-dir"));
|
SGPath terrasyncDir = SGPath::fromUtf8(fgGetString("/sim/terrasync/scenery-dir"));
|
||||||
if (terrasyncDir.empty()) {
|
if (terrasyncDir.isNull()) {
|
||||||
SGPath p(downloadDir);
|
SGPath p(downloadDir);
|
||||||
p.append("TerraSync");
|
p.append("TerraSync");
|
||||||
terrasyncDir = p.str();
|
terrasyncDir = p;
|
||||||
|
|
||||||
simgear::Dir d(terrasyncDir);
|
simgear::Dir d(terrasyncDir);
|
||||||
if (!d.exists()) {
|
if (!d.exists()) {
|
||||||
|
@ -2385,7 +2380,7 @@ OptionResult Options::processOptions()
|
||||||
}
|
}
|
||||||
|
|
||||||
SG_LOG(SG_GENERAL, SG_INFO, "Using default TerraSync: " << terrasyncDir);
|
SG_LOG(SG_GENERAL, SG_INFO, "Using default TerraSync: " << terrasyncDir);
|
||||||
fgSetString("/sim/terrasync/scenery-dir", p.str());
|
fgSetString("/sim/terrasync/scenery-dir", p.utf8Str());
|
||||||
} else {
|
} else {
|
||||||
SG_LOG(SG_GENERAL, SG_INFO, "Using explicit TerraSync dir: " << terrasyncDir);
|
SG_LOG(SG_GENERAL, SG_INFO, "Using explicit TerraSync dir: " << terrasyncDir);
|
||||||
}
|
}
|
||||||
|
@ -2397,9 +2392,9 @@ OptionResult Options::processOptions()
|
||||||
// is enabled or not. This allows us to toggle terrasync on/off at
|
// is enabled or not. This allows us to toggle terrasync on/off at
|
||||||
// runtime and have things work as expected
|
// runtime and have things work as expected
|
||||||
const PathList& scenery_paths(globals->get_fg_scenery());
|
const PathList& scenery_paths(globals->get_fg_scenery());
|
||||||
if (std::find(scenery_paths.begin(), scenery_paths.end(), SGPath(terrasyncDir)) == scenery_paths.end()) {
|
if (std::find(scenery_paths.begin(), scenery_paths.end(), terrasyncDir) == scenery_paths.end()) {
|
||||||
// terrasync dir is not in the scenery paths, add it
|
// terrasync dir is not in the scenery paths, add it
|
||||||
globals->append_fg_scenery(SGPath(terrasyncDir));
|
globals->append_fg_scenery(terrasyncDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addFGDataScenery) {
|
if (addFGDataScenery) {
|
||||||
|
@ -2548,20 +2543,20 @@ void Options::showUsage() const
|
||||||
#if defined(__CYGWIN__)
|
#if defined(__CYGWIN__)
|
||||||
SGPath Options::platformDefaultRoot() const
|
SGPath Options::platformDefaultRoot() const
|
||||||
{
|
{
|
||||||
return "../data";
|
return SGPath::fromUtf8("../data");
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(SG_WINDOWS)
|
#elif defined(SG_WINDOWS)
|
||||||
SGPath Options::platformDefaultRoot() const
|
SGPath Options::platformDefaultRoot() const
|
||||||
{
|
{
|
||||||
return "..\\data";
|
return SGPath::fromUtf8("..\\data");
|
||||||
}
|
}
|
||||||
#elif defined(SG_MAC)
|
#elif defined(SG_MAC)
|
||||||
// platformDefaultRoot defined in CocoaHelpers.mm
|
// platformDefaultRoot defined in CocoaHelpers.mm
|
||||||
#else
|
#else
|
||||||
SGPath Options::platformDefaultRoot() const
|
SGPath Options::platformDefaultRoot() const
|
||||||
{
|
{
|
||||||
return SGPath(PKGLIBDIR);
|
return SGPath::fromUtf8(PKGLIBDIR);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2660,4 +2655,3 @@ bool Options::checkForArg(int argc, char* argv[], const char* checkArg)
|
||||||
}
|
}
|
||||||
|
|
||||||
} // of namespace flightgear
|
} // of namespace flightgear
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace flightgear
|
||||||
* Documents (FlightGear), on Unixes we default to FG_HOME, which is
|
* Documents (FlightGear), on Unixes we default to FG_HOME, which is
|
||||||
* typically invisible.
|
* typically invisible.
|
||||||
*/
|
*/
|
||||||
std::string defaultDownloadDir();
|
SGPath defaultDownloadDir();
|
||||||
|
|
||||||
/// option processing can have various result values
|
/// option processing can have various result values
|
||||||
/// depending on what the user requested. Note processOptions only
|
/// depending on what the user requested. Note processOptions only
|
||||||
|
|
|
@ -213,24 +213,24 @@ static bool fgSetPosFromAirportIDandParkpos( const string& id, const string& par
|
||||||
string acfile = fgGetString("/sim/aircraft") + string(".xml");
|
string acfile = fgGetString("/sim/aircraft") + string(".xml");
|
||||||
acData.append(acfile);
|
acData.append(acfile);
|
||||||
SGPropertyNode root;
|
SGPropertyNode root;
|
||||||
readProperties(acData.str(), &root);
|
readProperties(acData, &root);
|
||||||
SGPropertyNode * node = root.getNode("sim");
|
SGPropertyNode * node = root.getNode("sim");
|
||||||
fltType = node->getStringValue("aircraft-class", "NONE" );
|
fltType = node->getStringValue("aircraft-class", "NONE" );
|
||||||
acOperator = node->getStringValue("aircraft-operator", "NONE" );
|
acOperator = node->getStringValue("aircraft-operator", "NONE" );
|
||||||
} catch (const sg_exception &) {
|
} catch (const sg_exception &) {
|
||||||
SG_LOG(SG_GENERAL, SG_INFO,
|
SG_LOG(SG_GENERAL, SG_INFO,
|
||||||
"Could not load aircraft aircrat type and operator information from: " << acData.str() << ". Using defaults");
|
"Could not load aircraft aircrat type and operator information from: " << acData << ". Using defaults");
|
||||||
|
|
||||||
// cout << path.str() << endl;
|
// cout << path.str() << endl;
|
||||||
}
|
}
|
||||||
if (fltType.empty() || fltType == "NONE") {
|
if (fltType.empty() || fltType == "NONE") {
|
||||||
SG_LOG(SG_GENERAL, SG_INFO,
|
SG_LOG(SG_GENERAL, SG_INFO,
|
||||||
"Aircraft type information not found in: " << acData.str() << ". Using default value");
|
"Aircraft type information not found in: " << acData << ". Using default value");
|
||||||
fltType = fgGetString("/sim/aircraft-class" );
|
fltType = fgGetString("/sim/aircraft-class" );
|
||||||
}
|
}
|
||||||
if (acOperator.empty() || fltType == "NONE") {
|
if (acOperator.empty() || fltType == "NONE") {
|
||||||
SG_LOG(SG_GENERAL, SG_INFO,
|
SG_LOG(SG_GENERAL, SG_INFO,
|
||||||
"Aircraft operator information not found in: " << acData.str() << ". Using default value");
|
"Aircraft operator information not found in: " << acData << ". Using default value");
|
||||||
acOperator = fgGetString("/sim/aircraft-operator" );
|
acOperator = fgGetString("/sim/aircraft-operator" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -191,6 +191,6 @@ std::string fgValidatePath (const std::string& path, bool write)
|
||||||
// no match found
|
// no match found
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
std::string fgValidatePath(const SGPath& path, bool write) { return fgValidatePath(path.str(),write); }
|
std::string fgValidatePath(const SGPath& path, bool write) { return fgValidatePath(path.utf8Str(),write); }
|
||||||
// end of util.cxx
|
// end of util.cxx
|
||||||
|
|
||||||
|
|
|
@ -30,10 +30,10 @@
|
||||||
|
|
||||||
|
|
||||||
static osg::Node *
|
static osg::Node *
|
||||||
fgLoad3DModelPanel(const std::string &path, SGPropertyNode *prop_root)
|
fgLoad3DModelPanel(const SGPath &path, SGPropertyNode *prop_root)
|
||||||
{
|
{
|
||||||
bool loadPanels = true;
|
bool loadPanels = true;
|
||||||
osg::Node* node = simgear::SGModelLib::loadModel(path, prop_root, NULL, loadPanels);
|
osg::Node* node = simgear::SGModelLib::loadModel(path.local8BitStr(), prop_root, NULL, loadPanels);
|
||||||
if (node)
|
if (node)
|
||||||
node->setNodeMask(~SG_NODEMASK_TERRAIN_BIT);
|
node->setNodeMask(~SG_NODEMASK_TERRAIN_BIT);
|
||||||
return node;
|
return node;
|
||||||
|
@ -82,7 +82,7 @@ FGAircraftModel::init ()
|
||||||
|
|
||||||
osg::Node* node = NULL;
|
osg::Node* node = NULL;
|
||||||
try {
|
try {
|
||||||
node = fgLoad3DModelPanel( resolvedPath.str(), globals->get_props());
|
node = fgLoad3DModelPanel( resolvedPath, globals->get_props());
|
||||||
} catch (const sg_exception &ex) {
|
} catch (const sg_exception &ex) {
|
||||||
SG_LOG(SG_AIRCRAFT, SG_ALERT, "Failed to load aircraft from " << path << ':');
|
SG_LOG(SG_AIRCRAFT, SG_ALERT, "Failed to load aircraft from " << path << ':');
|
||||||
SG_LOG(SG_AIRCRAFT, SG_ALERT, " " << ex.getFormattedMessage());
|
SG_LOG(SG_AIRCRAFT, SG_ALERT, " " << ex.getFormattedMessage());
|
||||||
|
@ -110,7 +110,7 @@ FGAircraftModel::init ()
|
||||||
// no models loaded, load the glider instead
|
// no models loaded, load the glider instead
|
||||||
if (!_aircraft.get()) {
|
if (!_aircraft.get()) {
|
||||||
SG_LOG(SG_AIRCRAFT, SG_ALERT, "(Falling back to glider.ac.)");
|
SG_LOG(SG_AIRCRAFT, SG_ALERT, "(Falling back to glider.ac.)");
|
||||||
osg::Node* model = fgLoad3DModelPanel( "Models/Geometry/glider.ac",
|
osg::Node* model = fgLoad3DModelPanel( SGPath::fromLocal8Bit("Models/Geometry/glider.ac"),
|
||||||
globals->get_props());
|
globals->get_props());
|
||||||
_aircraft.reset(new SGModelPlacement);
|
_aircraft.reset(new SGModelPlacement);
|
||||||
_aircraft->init(model);
|
_aircraft->init(model);
|
||||||
|
|
|
@ -576,7 +576,7 @@ void FlightPlan::setApproach(flightgear::Approach *app)
|
||||||
|
|
||||||
bool FlightPlan::save(const SGPath& path)
|
bool FlightPlan::save(const SGPath& path)
|
||||||
{
|
{
|
||||||
SG_LOG(SG_NAVAID, SG_INFO, "Saving route to " << path.str());
|
SG_LOG(SG_NAVAID, SG_INFO, "Saving route to " << path);
|
||||||
try {
|
try {
|
||||||
SGPropertyNode_ptr d(new SGPropertyNode);
|
SGPropertyNode_ptr d(new SGPropertyNode);
|
||||||
d->setIntValue("version", 2);
|
d->setIntValue("version", 2);
|
||||||
|
@ -615,10 +615,10 @@ bool FlightPlan::save(const SGPath& path)
|
||||||
Waypt* wpt = _legs[i]->waypoint();
|
Waypt* wpt = _legs[i]->waypoint();
|
||||||
wpt->saveAsNode(routeNode->getChild("wp", i, true));
|
wpt->saveAsNode(routeNode->getChild("wp", i, true));
|
||||||
} // of waypoint iteration
|
} // of waypoint iteration
|
||||||
writeProperties(path.str(), d, true /* write-all */);
|
writeProperties(path, d, true /* write-all */);
|
||||||
return true;
|
return true;
|
||||||
} catch (sg_exception& e) {
|
} catch (sg_exception& e) {
|
||||||
SG_LOG(SG_NAVAID, SG_ALERT, "Failed to save flight-plan '" << path.str() << "'. " << e.getMessage());
|
SG_LOG(SG_NAVAID, SG_ALERT, "Failed to save flight-plan '" << path << "'. " << e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -627,12 +627,12 @@ bool FlightPlan::load(const SGPath& path)
|
||||||
{
|
{
|
||||||
if (!path.exists())
|
if (!path.exists())
|
||||||
{
|
{
|
||||||
SG_LOG(SG_NAVAID, SG_ALERT, "Failed to load flight-plan '" << path.str()
|
SG_LOG(SG_NAVAID, SG_ALERT, "Failed to load flight-plan '" << path
|
||||||
<< "'. The file does not exist.");
|
<< "'. The file does not exist.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SG_LOG(SG_NAVAID, SG_INFO, "going to read flight-plan from:" << path.str());
|
SG_LOG(SG_NAVAID, SG_INFO, "going to read flight-plan from:" << path);
|
||||||
|
|
||||||
bool Status = false;
|
bool Status = false;
|
||||||
lockDelegate();
|
lockDelegate();
|
||||||
|
@ -727,7 +727,7 @@ bool FlightPlan::loadGpxFormat(const SGPath& path)
|
||||||
GpxXmlVisitor gpxVistor(this);
|
GpxXmlVisitor gpxVistor(this);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
readXML(path.str(), gpxVistor);
|
readXML(path.local8BitStr(), gpxVistor);
|
||||||
} catch (sg_exception& e)
|
} catch (sg_exception& e)
|
||||||
{
|
{
|
||||||
// XML parsing fails => not a GPX XML file
|
// XML parsing fails => not a GPX XML file
|
||||||
|
@ -750,7 +750,7 @@ bool FlightPlan::loadXmlFormat(const SGPath& path)
|
||||||
{
|
{
|
||||||
SGPropertyNode_ptr routeData(new SGPropertyNode);
|
SGPropertyNode_ptr routeData(new SGPropertyNode);
|
||||||
try {
|
try {
|
||||||
readProperties(path.str(), routeData);
|
readProperties(path, routeData);
|
||||||
} catch (sg_exception& e) {
|
} catch (sg_exception& e) {
|
||||||
SG_LOG(SG_NAVAID, SG_ALERT, "Failed to load flight-plan '" << e.getOrigin()
|
SG_LOG(SG_NAVAID, SG_ALERT, "Failed to load flight-plan '" << e.getOrigin()
|
||||||
<< "'. " << e.getMessage());
|
<< "'. " << e.getMessage());
|
||||||
|
@ -949,7 +949,7 @@ bool FlightPlan::loadPlainTextFormat(const SGPath& path)
|
||||||
_legs.push_back(new Leg(this, w));
|
_legs.push_back(new Leg(this, w));
|
||||||
} // of line iteration
|
} // of line iteration
|
||||||
} catch (sg_exception& e) {
|
} catch (sg_exception& e) {
|
||||||
SG_LOG(SG_NAVAID, SG_ALERT, "Failed to load route from: '" << path.str() << "'. " << e.getMessage());
|
SG_LOG(SG_NAVAID, SG_ALERT, "Failed to load route from: '" << path << "'. " << e.getMessage());
|
||||||
_legs.clear();
|
_legs.clear();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ void NavdataVisitor::startElement(const char* name, const XMLAttributes &atts)
|
||||||
if (tag == "Airport") {
|
if (tag == "Airport") {
|
||||||
string icao(atts.getValue("ICAOcode"));
|
string icao(atts.getValue("ICAOcode"));
|
||||||
if (_airport->ident() != icao) {
|
if (_airport->ident() != icao) {
|
||||||
throw sg_format_exception("Airport and ICAO mismatch", icao, _path.str());
|
throw sg_format_exception("Airport and ICAO mismatch", icao, _path.utf8Str());
|
||||||
}
|
}
|
||||||
} else if (tag == "Sid") {
|
} else if (tag == "Sid") {
|
||||||
string ident(atts.getValue("Name"));
|
string ident(atts.getValue("Name"));
|
||||||
|
|
|
@ -91,9 +91,10 @@ namespace flightgear
|
||||||
void SHPParser::parsePolyLines(const SGPath& aPath, PolyLine::Type aTy,
|
void SHPParser::parsePolyLines(const SGPath& aPath, PolyLine::Type aTy,
|
||||||
PolyLineList& aResult, bool aClosed)
|
PolyLineList& aResult, bool aClosed)
|
||||||
{
|
{
|
||||||
gzFile file = gzopen(aPath.c_str(), "rb");
|
std::string s = aPath.local8BitStr();
|
||||||
|
gzFile file = gzopen(s.c_str(), "rb");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
throw sg_io_exception("couldn't open file:" + aPath.str());
|
throw sg_io_exception("couldn't open file:", aPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -129,10 +129,10 @@ void Airway::load(const SGPath& path)
|
||||||
//int airwayIndex = 0;
|
//int airwayIndex = 0;
|
||||||
//FGNode *n;
|
//FGNode *n;
|
||||||
|
|
||||||
sg_gzifstream in( path.str() );
|
sg_gzifstream in( path );
|
||||||
if ( !in.is_open() ) {
|
if ( !in.is_open() ) {
|
||||||
SG_LOG( SG_NAVAID, SG_ALERT, "Cannot open file: " << path.str() );
|
SG_LOG( SG_NAVAID, SG_ALERT, "Cannot open file: " << path );
|
||||||
throw sg_io_exception("Could not open airways data", sg_location(path.str()));
|
throw sg_io_exception("Could not open airways data", path);
|
||||||
}
|
}
|
||||||
// toss the first two lines of the file
|
// toss the first two lines of the file
|
||||||
in >> skipeol;
|
in >> skipeol;
|
||||||
|
|
|
@ -50,7 +50,7 @@ const unsigned int LINES_IN_FIX_DAT = 119724;
|
||||||
|
|
||||||
void loadFixes(const SGPath& path)
|
void loadFixes(const SGPath& path)
|
||||||
{
|
{
|
||||||
sg_gzifstream in( path.str() );
|
sg_gzifstream in( path );
|
||||||
if ( !in.is_open() ) {
|
if ( !in.is_open() ) {
|
||||||
throw sg_io_exception("Cannot open file:", path);
|
throw sg_io_exception("Cannot open file:", path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -265,9 +265,9 @@ const unsigned int LINES_IN_NAV_DAT = 26775;
|
||||||
// load and initialize the navigational databases
|
// load and initialize the navigational databases
|
||||||
bool navDBInit(const SGPath& path)
|
bool navDBInit(const SGPath& path)
|
||||||
{
|
{
|
||||||
sg_gzifstream in( path.str() );
|
sg_gzifstream in( path );
|
||||||
if ( !in.is_open() ) {
|
if ( !in.is_open() ) {
|
||||||
SG_LOG( SG_NAVAID, SG_ALERT, "Cannot open file: " << path.str() );
|
SG_LOG( SG_NAVAID, SG_ALERT, "Cannot open file: " << path );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,11 +299,11 @@ bool navDBInit(const SGPath& path)
|
||||||
|
|
||||||
bool loadCarrierNav(const SGPath& path)
|
bool loadCarrierNav(const SGPath& path)
|
||||||
{
|
{
|
||||||
SG_LOG( SG_NAVAID, SG_DEBUG, "opening file: " << path.str() );
|
SG_LOG( SG_NAVAID, SG_DEBUG, "opening file: " << path );
|
||||||
sg_gzifstream incarrier( path.str() );
|
sg_gzifstream incarrier( path );
|
||||||
|
|
||||||
if ( !incarrier.is_open() ) {
|
if ( !incarrier.is_open() ) {
|
||||||
SG_LOG( SG_NAVAID, SG_ALERT, "Cannot open file: " << path.str() );
|
SG_LOG( SG_NAVAID, SG_ALERT, "Cannot open file: " << path );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,11 +318,11 @@ bool loadCarrierNav(const SGPath& path)
|
||||||
|
|
||||||
bool loadTacan(const SGPath& path, FGTACANList *channellist)
|
bool loadTacan(const SGPath& path, FGTACANList *channellist)
|
||||||
{
|
{
|
||||||
SG_LOG( SG_NAVAID, SG_DEBUG, "opening file: " << path.str() );
|
SG_LOG( SG_NAVAID, SG_DEBUG, "opening file: " << path );
|
||||||
sg_gzifstream inchannel( path.str() );
|
sg_gzifstream inchannel( path );
|
||||||
|
|
||||||
if ( !inchannel.is_open() ) {
|
if ( !inchannel.is_open() ) {
|
||||||
SG_LOG( SG_NAVAID, SG_ALERT, "Cannot open file: " << path.str() );
|
SG_LOG( SG_NAVAID, SG_ALERT, "Cannot open file: " << path );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,9 +92,9 @@ static PositionedID readPOIFromStream(std::istream& aStream, NavDataCache* cache
|
||||||
// load and initialize the POI database
|
// load and initialize the POI database
|
||||||
bool poiDBInit(const SGPath& path)
|
bool poiDBInit(const SGPath& path)
|
||||||
{
|
{
|
||||||
sg_gzifstream in( path.str() );
|
sg_gzifstream in( path );
|
||||||
if ( !in.is_open() ) {
|
if ( !in.is_open() ) {
|
||||||
SG_LOG( SG_NAVAID, SG_ALERT, "Cannot open file: " << path.str() );
|
SG_LOG( SG_NAVAID, SG_ALERT, "Cannot open file: " << path );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -333,10 +333,9 @@ void Waypt::writeToProperties(SGPropertyNode_ptr aProp) const
|
||||||
void RouteBase::dumpRouteToKML(const WayptVec& aRoute, const std::string& aName)
|
void RouteBase::dumpRouteToKML(const WayptVec& aRoute, const std::string& aName)
|
||||||
{
|
{
|
||||||
SGPath p = "/Users/jmt/Desktop/" + aName + ".kml";
|
SGPath p = "/Users/jmt/Desktop/" + aName + ".kml";
|
||||||
std::fstream f;
|
sg_ofstream f(p);
|
||||||
f.open(p.str().c_str(), fstream::out | fstream::app);
|
|
||||||
if (!f.is_open()) {
|
if (!f.is_open()) {
|
||||||
SG_LOG(SG_NAVAID, SG_WARN, "unable to open:" << p.str());
|
SG_LOG(SG_NAVAID, SG_WARN, "unable to open:" << p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,12 +379,12 @@ void RouteBase::loadAirportProcedures(const SGPath& aPath, FGAirport* aApt)
|
||||||
assert(aApt);
|
assert(aApt);
|
||||||
try {
|
try {
|
||||||
NavdataVisitor visitor(aApt, aPath);
|
NavdataVisitor visitor(aApt, aPath);
|
||||||
readXML(aPath.str(), visitor);
|
readXML(aPath.local8BitStr(), visitor);
|
||||||
} catch (sg_io_exception& ex) {
|
} catch (sg_io_exception& ex) {
|
||||||
SG_LOG(SG_NAVAID, SG_WARN, "failure parsing procedures: " << aPath.str() <<
|
SG_LOG(SG_NAVAID, SG_WARN, "failure parsing procedures: " << aPath <<
|
||||||
"\n\t" << ex.getMessage() << "\n\tat:" << ex.getLocation().asString());
|
"\n\t" << ex.getMessage() << "\n\tat:" << ex.getLocation().asString());
|
||||||
} catch (sg_exception& ex) {
|
} catch (sg_exception& ex) {
|
||||||
SG_LOG(SG_NAVAID, SG_WARN, "failure parsing procedures: " << aPath.str() <<
|
SG_LOG(SG_NAVAID, SG_WARN, "failure parsing procedures: " << aPath <<
|
||||||
"\n\t" << ex.getMessage());
|
"\n\t" << ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,19 +151,19 @@ bool FGATCMain::open() {
|
||||||
exit( -1 );
|
exit( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( input0_path.str().length() ) {
|
if ( !input0_path.isNull() ) {
|
||||||
input0 = new FGATCInput( 0, input0_path );
|
input0 = new FGATCInput( 0, input0_path );
|
||||||
input0->open();
|
input0->open();
|
||||||
}
|
}
|
||||||
if ( input1_path.str().length() ) {
|
if ( !input1_path.isNull() ) {
|
||||||
input1 = new FGATCInput( 1, input1_path );
|
input1 = new FGATCInput( 1, input1_path );
|
||||||
input1->open();
|
input1->open();
|
||||||
}
|
}
|
||||||
if ( output0_path.str().length() ) {
|
if ( !output0_path.isNull() ) {
|
||||||
output0 = new FGATCOutput( 0, output0_path );
|
output0 = new FGATCOutput( 0, output0_path );
|
||||||
output0->open( lock0_fd );
|
output0->open( lock0_fd );
|
||||||
}
|
}
|
||||||
if ( output1_path.str().length() ) {
|
if ( !output1_path.isNull() ) {
|
||||||
output1 = new FGATCOutput( 1, output1_path );
|
output1 = new FGATCOutput( 1, output1_path );
|
||||||
output1->open( lock1_fd );
|
output1->open( lock1_fd );
|
||||||
}
|
}
|
||||||
|
|
|
@ -758,11 +758,11 @@ FGGeneric::reinit()
|
||||||
path.append(file_name.c_str());
|
path.append(file_name.c_str());
|
||||||
|
|
||||||
SG_LOG(SG_NETWORK, SG_INFO, "Reading communication protocol from "
|
SG_LOG(SG_NETWORK, SG_INFO, "Reading communication protocol from "
|
||||||
<< path.str());
|
<< path);
|
||||||
|
|
||||||
SGPropertyNode root;
|
SGPropertyNode root;
|
||||||
try {
|
try {
|
||||||
readProperties(path.str(), &root);
|
readProperties(path, &root);
|
||||||
} catch (const sg_exception & ex) {
|
} catch (const sg_exception & ex) {
|
||||||
SG_LOG(SG_NETWORK, SG_ALERT,
|
SG_LOG(SG_NETWORK, SG_ALERT,
|
||||||
"Unable to load the protocol configuration file: " << ex.getFormattedMessage() );
|
"Unable to load the protocol configuration file: " << ex.getFormattedMessage() );
|
||||||
|
|
|
@ -96,7 +96,8 @@ static cJSON * CatalogToJson( simgear::pkg::Catalog * c )
|
||||||
cJSON * json = cJSON_CreateObject();
|
cJSON * json = cJSON_CreateObject();
|
||||||
if( c ) {
|
if( c ) {
|
||||||
cJSON_AddItemToObject(json, "id", cJSON_CreateString( c->id().c_str() ));
|
cJSON_AddItemToObject(json, "id", cJSON_CreateString( c->id().c_str() ));
|
||||||
cJSON_AddItemToObject(json, "installRoot", cJSON_CreateString( c->installRoot().str().c_str() ));
|
std::string s = c->installRoot().utf8Str();
|
||||||
|
cJSON_AddItemToObject(json, "installRoot", cJSON_CreateString( s.c_str() ));
|
||||||
cJSON_AddItemToObject(json, "url", cJSON_CreateString( c->url().c_str() ));
|
cJSON_AddItemToObject(json, "url", cJSON_CreateString( c->url().c_str() ));
|
||||||
cJSON_AddItemToObject(json, "description", cJSON_CreateString( c->description().c_str() ));
|
cJSON_AddItemToObject(json, "description", cJSON_CreateString( c->description().c_str() ));
|
||||||
cJSON_AddItemToObject(json, "packages", PackageListToJson(c->packages()) );
|
cJSON_AddItemToObject(json, "packages", PackageListToJson(c->packages()) );
|
||||||
|
@ -112,8 +113,8 @@ static string PackageRootCommand( simgear::pkg::Root* packageRoot, const string
|
||||||
cJSON * json = cJSON_CreateObject();
|
cJSON * json = cJSON_CreateObject();
|
||||||
|
|
||||||
if( command == "path" ) {
|
if( command == "path" ) {
|
||||||
|
std::string p = packageRoot->path().utf8Str();
|
||||||
cJSON_AddItemToObject(json, "path", cJSON_CreateString( packageRoot->path().str().c_str() ));
|
cJSON_AddItemToObject(json, "path", cJSON_CreateString( p.c_str() ));
|
||||||
|
|
||||||
} else if( command == "version" ) {
|
} else if( command == "version" ) {
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <Scenery/scenery.hxx>
|
#include <Scenery/scenery.hxx>
|
||||||
|
#include <simgear/misc/sgstream.hxx>
|
||||||
|
|
||||||
#include "antenna.hxx"
|
#include "antenna.hxx"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -80,7 +82,7 @@ void FGRadioAntenna::load_NEC_antenna_pattern(string type) {
|
||||||
if (!pattern_file.exists()) {
|
if (!pattern_file.exists()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ifstream file_in(pattern_file.c_str());
|
sg_ifstream file_in(pattern_file);
|
||||||
int heading, elevation;
|
int heading, elevation;
|
||||||
double gain;
|
double gain;
|
||||||
while(!file_in.eof()) {
|
while(!file_in.eof()) {
|
||||||
|
|
|
@ -1736,7 +1736,8 @@ static naRef f_route(naContext c, naRef me, int argc, naRef* args)
|
||||||
flightgear::FlightPlan* fp = new flightgear::FlightPlan;
|
flightgear::FlightPlan* fp = new flightgear::FlightPlan;
|
||||||
SGPath path(naStr_data(args[0]));
|
SGPath path(naStr_data(args[0]));
|
||||||
if (!path.exists()) {
|
if (!path.exists()) {
|
||||||
naRuntimeError(c, "flightplan, no file at path %s", path.c_str());
|
std::string pdata = path.utf8Str();
|
||||||
|
naRuntimeError(c, "flightplan, no file at path %s", pdata.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fp->load(path)) {
|
if (!fp->load(path)) {
|
||||||
|
|
|
@ -42,12 +42,12 @@ SGPath::Permissions checkIORules(const SGPath& path)
|
||||||
// SGPath caches permissions, which breaks for relative paths
|
// SGPath caches permissions, which breaks for relative paths
|
||||||
// if the current directory changes
|
// if the current directory changes
|
||||||
SG_LOG(SG_NASAL, SG_ALERT, "os.path: file operation on '" <<
|
SG_LOG(SG_NASAL, SG_ALERT, "os.path: file operation on '" <<
|
||||||
path.str() << "' access denied (relative paths not accepted; use "
|
path<< "' access denied (relative paths not accepted; use "
|
||||||
"realpath() to make a path absolute)");
|
"realpath() to make a path absolute)");
|
||||||
}
|
}
|
||||||
|
|
||||||
perm.read = path.isAbsolute() && !fgValidatePath(path.str(), false).empty();
|
perm.read = path.isAbsolute() && !fgValidatePath(path, false).empty();
|
||||||
perm.write = path.isAbsolute() && !fgValidatePath(path.str(), true ).empty();
|
perm.write = path.isAbsolute() && !fgValidatePath(path, true ).empty();
|
||||||
|
|
||||||
return perm;
|
return perm;
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ SGPath::Permissions checkIORules(const SGPath& path)
|
||||||
static naRef validatedPathToNasal( const nasal::CallContext& ctx,
|
static naRef validatedPathToNasal( const nasal::CallContext& ctx,
|
||||||
const SGPath& p )
|
const SGPath& p )
|
||||||
{
|
{
|
||||||
return ctx.to_nasal( SGPathRef(new SGPath(p.str(), &checkIORules)) );
|
return ctx.to_nasal( SGPathRef(new SGPath(p.utf8Str(), &checkIORules)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,6 +73,11 @@ static int f_path_create_dir(SGPath& p, const nasal::CallContext& ctx)
|
||||||
return p.create_dir(ctx.getArg<mode_t>(0, 0755) & 0775);
|
return p.create_dir(ctx.getArg<mode_t>(0, 0755) & 0775);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void f_path_set(SGPath& p, const nasal::CallContext& ctx)
|
||||||
|
{
|
||||||
|
p = SGPath::fromUtf8(ctx.getArg<std::string>(0), p.getPermissionChecker());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* os.path.desktop()
|
* os.path.desktop()
|
||||||
*/
|
*/
|
||||||
|
@ -113,9 +118,8 @@ naRef initNasalSGPath(naRef globals, naContext c)
|
||||||
// See: http://docs.freeflightsim.org/simgear/classSGPath.html
|
// See: http://docs.freeflightsim.org/simgear/classSGPath.html
|
||||||
|
|
||||||
NasalSGPath::init("os.path")
|
NasalSGPath::init("os.path")
|
||||||
.method("set", &SGPath::set)
|
.method("set", &f_path_set)
|
||||||
.method("append", &SGPath::append)
|
.method("append", &SGPath::append)
|
||||||
.method("add", &SGPath::add)
|
|
||||||
.method("concat", &SGPath::concat)
|
.method("concat", &SGPath::concat)
|
||||||
|
|
||||||
.member("realpath", &SGPath::realpath)
|
.member("realpath", &SGPath::realpath)
|
||||||
|
@ -126,8 +130,7 @@ naRef initNasalSGPath(naRef globals, naContext c)
|
||||||
.member("extension", &SGPath::extension)
|
.member("extension", &SGPath::extension)
|
||||||
.member("lower_extension", &SGPath::lower_extension)
|
.member("lower_extension", &SGPath::lower_extension)
|
||||||
.member("complete_lower_extension", &SGPath::complete_lower_extension)
|
.member("complete_lower_extension", &SGPath::complete_lower_extension)
|
||||||
.member("str", &SGPath::str)
|
.member("str", &SGPath::utf8Str)
|
||||||
.member("str_native", &SGPath::str_native)
|
|
||||||
.member("mtime", &SGPath::modTime)
|
.member("mtime", &SGPath::modTime)
|
||||||
|
|
||||||
.method("exists", &SGPath::exists)
|
.method("exists", &SGPath::exists)
|
||||||
|
|
|
@ -608,8 +608,8 @@ static naRef f_resolveDataPath(naContext c, naRef me, int argc, naRef* args)
|
||||||
naRuntimeError(c, "bad arguments to resolveDataPath()");
|
naRuntimeError(c, "bad arguments to resolveDataPath()");
|
||||||
|
|
||||||
SGPath p = globals->resolve_maybe_aircraft_path(naStr_data(args[0]));
|
SGPath p = globals->resolve_maybe_aircraft_path(naStr_data(args[0]));
|
||||||
const char* pdata = p.c_str();
|
std::string pdata = p.utf8Str();
|
||||||
return naStr_fromdata(naNewString(c), const_cast<char*>(pdata), strlen(pdata));
|
return naStr_fromdata(naNewString(c), const_cast<char*>(pdata.c_str()), pdata.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
static naRef f_findDataDir(naContext c, naRef me, int argc, naRef* args)
|
static naRef f_findDataDir(naContext c, naRef me, int argc, naRef* args)
|
||||||
|
@ -618,8 +618,8 @@ static naRef f_findDataDir(naContext c, naRef me, int argc, naRef* args)
|
||||||
naRuntimeError(c, "bad arguments to findDataDir()");
|
naRuntimeError(c, "bad arguments to findDataDir()");
|
||||||
|
|
||||||
SGPath p = globals->find_data_dir(naStr_data(args[0]));
|
SGPath p = globals->find_data_dir(naStr_data(args[0]));
|
||||||
const char* pdata = p.c_str();
|
std::string pdata = p.utf8Str();
|
||||||
return naStr_fromdata(naNewString(c), const_cast<char*>(pdata), strlen(pdata));
|
return naStr_fromdata(naNewString(c), const_cast<char*>(pdata.c_str()), pdata.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
class NasalCommand : public SGCommandMgr::Command
|
class NasalCommand : public SGCommandMgr::Command
|
||||||
|
@ -1032,7 +1032,7 @@ void FGNasalSys::addModule(string moduleName, simgear::PathList scripts)
|
||||||
SGPropertyNode* module_node = nasal->getChild(moduleName,0,true);
|
SGPropertyNode* module_node = nasal->getChild(moduleName,0,true);
|
||||||
for (unsigned int i=0; i<scripts.size(); ++i) {
|
for (unsigned int i=0; i<scripts.size(); ++i) {
|
||||||
SGPropertyNode* pFileNode = module_node->getChild("file",i,true);
|
SGPropertyNode* pFileNode = module_node->getChild("file",i,true);
|
||||||
pFileNode->setStringValue(scripts[i].c_str());
|
pFileNode->setStringValue(scripts[i].utf8Str());
|
||||||
}
|
}
|
||||||
if (!module_node->hasChild("enabled",0))
|
if (!module_node->hasChild("enabled",0))
|
||||||
{
|
{
|
||||||
|
@ -1146,15 +1146,16 @@ void FGNasalSys::logError(naContext context)
|
||||||
bool FGNasalSys::loadModule(SGPath file, const char* module)
|
bool FGNasalSys::loadModule(SGPath file, const char* module)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
char* buf = readfile(file.c_str(), &len);
|
std::string pdata = file.local8BitStr();
|
||||||
|
char* buf = readfile(pdata.c_str(), &len);
|
||||||
if(!buf) {
|
if(!buf) {
|
||||||
SG_LOG(SG_NASAL, SG_ALERT,
|
SG_LOG(SG_NASAL, SG_ALERT,
|
||||||
"Nasal error: could not read script file " << file.c_str()
|
"Nasal error: could not read script file " << file
|
||||||
<< " into module " << module);
|
<< " into module " << module);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ok = createModule(module, file.c_str(), buf, len);
|
bool ok = createModule(module, pdata.c_str(), buf, len);
|
||||||
delete[] buf;
|
delete[] buf;
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,14 +116,14 @@ FGFX::init()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SG_LOG(SG_SOUND, SG_INFO, "Reading sound " << node->getName()
|
SG_LOG(SG_SOUND, SG_INFO, "Reading sound " << node->getName()
|
||||||
<< " from " << path.str());
|
<< " from " << path);
|
||||||
|
|
||||||
SGPropertyNode root;
|
SGPropertyNode root;
|
||||||
try {
|
try {
|
||||||
readProperties(path.str(), &root);
|
readProperties(path, &root);
|
||||||
} catch (const sg_exception &) {
|
} catch (const sg_exception &) {
|
||||||
SG_LOG(SG_SOUND, SG_ALERT,
|
SG_LOG(SG_SOUND, SG_ALERT,
|
||||||
"Error reading file '" << path.str() << '\'');
|
"Error reading file '" << path << '\'');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -382,7 +382,7 @@ void FGElectricalSystem::init () {
|
||||||
<< config.str() );
|
<< config.str() );
|
||||||
#endif
|
#endif
|
||||||
try {
|
try {
|
||||||
readProperties( config.str(), config_props );
|
readProperties( config, config_props );
|
||||||
|
|
||||||
if ( build(config_props) ) {
|
if ( build(config_props) ) {
|
||||||
enabled = true;
|
enabled = true;
|
||||||
|
@ -392,7 +392,7 @@ void FGElectricalSystem::init () {
|
||||||
} catch (const sg_exception&) {
|
} catch (const sg_exception&) {
|
||||||
SG_LOG( SG_SYSTEMS, SG_ALERT,
|
SG_LOG( SG_SYSTEMS, SG_ALERT,
|
||||||
"Failed to load electrical system model: "
|
"Failed to load electrical system model: "
|
||||||
<< config.str() );
|
<< config );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SG_LOG( SG_SYSTEMS, SG_INFO,
|
SG_LOG( SG_SYSTEMS, SG_INFO,
|
||||||
|
|
|
@ -38,16 +38,16 @@ FGSystemMgr::FGSystemMgr ()
|
||||||
SGPath config = globals->resolve_aircraft_path(path_n->getStringValue());
|
SGPath config = globals->resolve_aircraft_path(path_n->getStringValue());
|
||||||
|
|
||||||
SG_LOG( SG_SYSTEMS, SG_INFO, "Reading systems from "
|
SG_LOG( SG_SYSTEMS, SG_INFO, "Reading systems from "
|
||||||
<< config.str() );
|
<< config );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
readProperties( config.str(), config_props );
|
readProperties( config, config_props );
|
||||||
build(config_props);
|
build(config_props);
|
||||||
}
|
}
|
||||||
catch( const sg_exception& )
|
catch( const sg_exception& )
|
||||||
{
|
{
|
||||||
SG_LOG( SG_SYSTEMS, SG_ALERT, "Failed to load systems system model: "
|
SG_LOG( SG_SYSTEMS, SG_ALERT, "Failed to load systems system model: "
|
||||||
<< config.str() );
|
<< config );
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -335,7 +335,7 @@ void TimeManager::updateLocalTime()
|
||||||
{
|
{
|
||||||
SGPath zone(globals->get_fg_root());
|
SGPath zone(globals->get_fg_root());
|
||||||
zone.append("Timezone");
|
zone.append("Timezone");
|
||||||
_impl->updateLocal(globals->get_aircraft_position(), zone.str());
|
_impl->updateLocal(globals->get_aircraft_position(), zone.local8BitStr());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimeManager::initTimeOffset()
|
void TimeManager::initTimeOffset()
|
||||||
|
|
|
@ -105,20 +105,20 @@ void FGLight::init () {
|
||||||
// initialize ambient, diffuse and specular tables
|
// initialize ambient, diffuse and specular tables
|
||||||
SGPath ambient_path = path;
|
SGPath ambient_path = path;
|
||||||
ambient_path.append( "Lighting/ambient" );
|
ambient_path.append( "Lighting/ambient" );
|
||||||
_ambient_tbl = new SGInterpTable( ambient_path.str() );
|
_ambient_tbl = new SGInterpTable( ambient_path );
|
||||||
|
|
||||||
SGPath diffuse_path = path;
|
SGPath diffuse_path = path;
|
||||||
diffuse_path.append( "Lighting/diffuse" );
|
diffuse_path.append( "Lighting/diffuse" );
|
||||||
_diffuse_tbl = new SGInterpTable( diffuse_path.str() );
|
_diffuse_tbl = new SGInterpTable( diffuse_path );
|
||||||
|
|
||||||
SGPath specular_path = path;
|
SGPath specular_path = path;
|
||||||
specular_path.append( "Lighting/specular" );
|
specular_path.append( "Lighting/specular" );
|
||||||
_specular_tbl = new SGInterpTable( specular_path.str() );
|
_specular_tbl = new SGInterpTable( specular_path );
|
||||||
|
|
||||||
// initialize sky table
|
// initialize sky table
|
||||||
SGPath sky_path = path;
|
SGPath sky_path = path;
|
||||||
sky_path.append( "Lighting/sky" );
|
sky_path.append( "Lighting/sky" );
|
||||||
_sky_tbl = new SGInterpTable( sky_path.str() );
|
_sky_tbl = new SGInterpTable( sky_path );
|
||||||
|
|
||||||
globals->get_event_mgr()->addTask("updateSunPos", this,
|
globals->get_event_mgr()->addTask("updateSunPos", this,
|
||||||
&FGLight::updateSunPos, 0.5 );
|
&FGLight::updateSunPos, 0.5 );
|
||||||
|
|
|
@ -54,6 +54,7 @@
|
||||||
|
|
||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
#include <simgear/misc/sg_path.hxx>
|
#include <simgear/misc/sg_path.hxx>
|
||||||
|
#include <simgear/misc/sgstream.hxx>
|
||||||
#include <simgear/misc/sg_dir.hxx>
|
#include <simgear/misc/sg_dir.hxx>
|
||||||
#include <simgear/props/props.hxx>
|
#include <simgear/props/props.hxx>
|
||||||
#include <simgear/structure/subsystem_mgr.hxx>
|
#include <simgear/structure/subsystem_mgr.hxx>
|
||||||
|
@ -166,7 +167,7 @@ public:
|
||||||
SGPath path = globals->get_fg_root();
|
SGPath path = globals->get_fg_root();
|
||||||
path.append("/Traffic/");
|
path.append("/Traffic/");
|
||||||
path.append(attval);
|
path.append(attval);
|
||||||
readXML(path.str(), *this);
|
readXML(path.local8BitStr(), *this);
|
||||||
}
|
}
|
||||||
elementValueStack.push_back("");
|
elementValueStack.push_back("");
|
||||||
// cout << " " << atts.getName(i) << '=' << atts.getValue(i) << endl;
|
// cout << " " << atts.getName(i) << '=' << atts.getValue(i) << endl;
|
||||||
|
@ -384,7 +385,7 @@ private:
|
||||||
SG_LOG(SG_AI, SG_INFO, "parsing traffic in:" << p);
|
SG_LOG(SG_AI, SG_INFO, "parsing traffic in:" << p);
|
||||||
simgear::PathList trafficFiles = d2.children(simgear::Dir::TYPE_FILE, ".xml");
|
simgear::PathList trafficFiles = d2.children(simgear::Dir::TYPE_FILE, ".xml");
|
||||||
BOOST_FOREACH(SGPath xml, trafficFiles) {
|
BOOST_FOREACH(SGPath xml, trafficFiles) {
|
||||||
readXML(xml.str(), *this);
|
readXML(xml.local8BitStr(), *this);
|
||||||
if (_cancelThread) {
|
if (_cancelThread) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -450,7 +451,7 @@ void FGTrafficManager::shutdown()
|
||||||
|
|
||||||
// Save the heuristics data
|
// Save the heuristics data
|
||||||
bool saveData = false;
|
bool saveData = false;
|
||||||
std::ofstream cachefile;
|
sg_ofstream cachefile;
|
||||||
if (fgGetBool("/sim/traffic-manager/heuristics")) {
|
if (fgGetBool("/sim/traffic-manager/heuristics")) {
|
||||||
SGPath cacheData(globals->get_fg_home());
|
SGPath cacheData(globals->get_fg_home());
|
||||||
cacheData.append("ai");
|
cacheData.append("ai");
|
||||||
|
@ -468,12 +469,12 @@ void FGTrafficManager::shutdown()
|
||||||
// the trailing dir separator and then determines the directory part of the file path by searching
|
// the trailing dir separator and then determines the directory part of the file path by searching
|
||||||
// for the last dir separator. Effecively, this causes a full element of the directory tree to be
|
// for the last dir separator. Effecively, this causes a full element of the directory tree to be
|
||||||
// skipped.
|
// skipped.
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Trying to create dir for : " << cacheData.c_str());
|
SG_LOG(SG_GENERAL, SG_DEBUG, "Trying to create dir for : " << cacheData);
|
||||||
if (!cacheData.exists()) {
|
if (!cacheData.exists()) {
|
||||||
cacheData.create_dir(0755);
|
cacheData.create_dir(0755);
|
||||||
}
|
}
|
||||||
saveData = true;
|
saveData = true;
|
||||||
cachefile.open(cacheData.str().c_str());
|
cachefile.open(cacheData);
|
||||||
cachefile << "[TrafficManagerCachedata:ref:2011:09:04]" << endl;
|
cachefile << "[TrafficManagerCachedata:ref:2011:09:04]" << endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -563,7 +564,7 @@ void FGTrafficManager::init()
|
||||||
// use a SchedulerParser to parse, but run it in this thread,
|
// use a SchedulerParser to parse, but run it in this thread,
|
||||||
// i.e don't start it
|
// i.e don't start it
|
||||||
ScheduleParseThread parser(this);
|
ScheduleParseThread parser(this);
|
||||||
readXML(path.str(), parser);
|
readXML(path.local8BitStr(), parser);
|
||||||
}
|
}
|
||||||
} else if (path.extension() == "conf") {
|
} else if (path.extension() == "conf") {
|
||||||
if (path.exists()) {
|
if (path.exists()) {
|
||||||
|
@ -571,7 +572,7 @@ void FGTrafficManager::init()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SG_LOG(SG_AI, SG_ALERT,
|
SG_LOG(SG_AI, SG_ALERT,
|
||||||
"Unknown data format " << path.str()
|
"Unknown data format " << path
|
||||||
<< " for traffic");
|
<< " for traffic");
|
||||||
}
|
}
|
||||||
//exit(1);
|
//exit(1);
|
||||||
|
@ -627,11 +628,11 @@ void FGTrafficManager::loadHeuristics()
|
||||||
cacheData.append(airport + "-cache.txt");
|
cacheData.append(airport + "-cache.txt");
|
||||||
string revisionStr;
|
string revisionStr;
|
||||||
if (cacheData.exists()) {
|
if (cacheData.exists()) {
|
||||||
std::ifstream data(cacheData.c_str());
|
sg_ifstream data(cacheData);
|
||||||
data >> revisionStr;
|
data >> revisionStr;
|
||||||
if (revisionStr != "[TrafficManagerCachedata:ref:2011:09:04]") {
|
if (revisionStr != "[TrafficManagerCachedata:ref:2011:09:04]") {
|
||||||
SG_LOG(SG_AI, SG_ALERT,"Traffic Manager Warning: discarding outdated cachefile " <<
|
SG_LOG(SG_AI, SG_ALERT,"Traffic Manager Warning: discarding outdated cachefile " <<
|
||||||
cacheData.c_str() << " for Airport " << airport);
|
cacheData << " for Airport " << airport);
|
||||||
} else {
|
} else {
|
||||||
while (1) {
|
while (1) {
|
||||||
Heuristic h; // = new Heuristic;
|
Heuristic h; // = new Heuristic;
|
||||||
|
@ -761,7 +762,8 @@ void FGTrafficManager::readTimeTableFromFile(SGPath infileName)
|
||||||
string buffString;
|
string buffString;
|
||||||
vector <string> tokens, depTime,arrTime;
|
vector <string> tokens, depTime,arrTime;
|
||||||
vector <string>::iterator it;
|
vector <string>::iterator it;
|
||||||
std::ifstream infile(infileName.str().c_str());
|
|
||||||
|
sg_ifstream infile(infileName);
|
||||||
while (1) {
|
while (1) {
|
||||||
infile.getline(buffer, 256);
|
infile.getline(buffer, 256);
|
||||||
if (infile.eof()) {
|
if (infile.eof()) {
|
||||||
|
@ -778,7 +780,7 @@ void FGTrafficManager::readTimeTableFromFile(SGPath infileName)
|
||||||
if (!tokens.empty()) {
|
if (!tokens.empty()) {
|
||||||
if (tokens[0] == string("AC")) {
|
if (tokens[0] == string("AC")) {
|
||||||
if (tokens.size() != 13) {
|
if (tokens.size() != 13) {
|
||||||
throw sg_io_exception("Error parsing traffic file @ " + buffString, sg_location(infileName.str()));
|
throw sg_io_exception("Error parsing traffic file @ " + buffString, infileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -801,7 +803,7 @@ void FGTrafficManager::readTimeTableFromFile(SGPath infileName)
|
||||||
|
|
||||||
if (!FGAISchedule::validModelPath(model)) {
|
if (!FGAISchedule::validModelPath(model)) {
|
||||||
SG_LOG(SG_AI, SG_WARN, "TrafficMgr: Missing model path:" <<
|
SG_LOG(SG_AI, SG_WARN, "TrafficMgr: Missing model path:" <<
|
||||||
model << " from " << infileName.str());
|
model << " from " << infileName);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
SG_LOG(SG_AI, SG_INFO, "Adding Aircraft" << model << " " << livery << " " << homePort << " "
|
SG_LOG(SG_AI, SG_INFO, "Adding Aircraft" << model << " " << livery << " " << homePort << " "
|
||||||
|
@ -825,7 +827,7 @@ void FGTrafficManager::readTimeTableFromFile(SGPath infileName)
|
||||||
if (tokens[0] == string("FLIGHT")) {
|
if (tokens[0] == string("FLIGHT")) {
|
||||||
//cerr << "Found flight " << buffString << " size is : " << tokens.size() << endl;
|
//cerr << "Found flight " << buffString << " size is : " << tokens.size() << endl;
|
||||||
if (tokens.size() != 10) {
|
if (tokens.size() != 10) {
|
||||||
SG_LOG(SG_AI, SG_ALERT, "Error parsing traffic file " << infileName.str() << " at " << buffString);
|
SG_LOG(SG_AI, SG_ALERT, "Error parsing traffic file " << infileName << " at " << buffString);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
string callsign = tokens[1];
|
string callsign = tokens[1];
|
||||||
|
@ -920,5 +922,3 @@ void FGTrafficManager::Tokenize(const string& str,
|
||||||
pos = str.find_first_of(delimiters, lastPos);
|
pos = str.find_first_of(delimiters, lastPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,8 @@ fgviewerMain(int argc, char** argv)
|
||||||
|
|
||||||
SGPath mpath( globals->get_fg_root() );
|
SGPath mpath( globals->get_fg_root() );
|
||||||
mpath.append( fgGetString("/sim/rendering/materials-file") );
|
mpath.append( fgGetString("/sim/rendering/materials-file") );
|
||||||
if ( ! globals->get_matlib()->load(globals->get_fg_root().local8BitStr(), mpath.str(),
|
if ( ! globals->get_matlib()->load(globals->get_fg_root().local8BitStr(),
|
||||||
|
mpath.local8BitStr(),
|
||||||
globals->get_props()) ) {
|
globals->get_props()) ) {
|
||||||
throw sg_io_exception("Error loading materials file", mpath);
|
throw sg_io_exception("Error loading materials file", mpath);
|
||||||
}
|
}
|
||||||
|
|
|
@ -596,11 +596,11 @@ FGRenderer::init( void )
|
||||||
texture_path.append("Textures");
|
texture_path.append("Textures");
|
||||||
texture_path.append("Sky");
|
texture_path.append("Sky");
|
||||||
for (int i = 0; i < FGEnvironmentMgr::MAX_CLOUD_LAYERS; i++) {
|
for (int i = 0; i < FGEnvironmentMgr::MAX_CLOUD_LAYERS; i++) {
|
||||||
SGCloudLayer * layer = new SGCloudLayer(texture_path.str());
|
SGCloudLayer * layer = new SGCloudLayer(texture_path.local8BitStr());
|
||||||
_sky->add_cloud_layer(layer);
|
_sky->add_cloud_layer(layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
_sky->texture_path( texture_path.str() );
|
_sky->texture_path( texture_path.local8BitStr() );
|
||||||
|
|
||||||
if (!_classicalRenderer) {
|
if (!_classicalRenderer) {
|
||||||
eventHandler->setChangeStatsCameraRenderOrder( true );
|
eventHandler->setChangeStatsCameraRenderOrder( true );
|
||||||
|
|
|
@ -231,7 +231,7 @@ static osg::Node* fgCreateSplashCamera()
|
||||||
SGSharedPtr<SGPropertyNode> style = fgGetNode("/sim/gui/style[0]", true);
|
SGSharedPtr<SGPropertyNode> style = fgGetNode("/sim/gui/style[0]", true);
|
||||||
|
|
||||||
osg::Texture2D* splashTexture = new osg::Texture2D;
|
osg::Texture2D* splashTexture = new osg::Texture2D;
|
||||||
splashTexture->setImage(osgDB::readImageFile(tpath.c_str()));
|
splashTexture->setImage(osgDB::readImageFile(tpath.local8BitStr()));
|
||||||
|
|
||||||
osg::Camera* camera = new osg::Camera;
|
osg::Camera* camera = new osg::Camera;
|
||||||
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
|
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
|
||||||
|
@ -318,7 +318,7 @@ static osg::Node* fgCreateSplashCamera()
|
||||||
FGFontCache* fontCache = FGFontCache::instance();
|
FGFontCache* fontCache = FGFontCache::instance();
|
||||||
osgText::Text* text = new osgText::Text;
|
osgText::Text* text = new osgText::Text;
|
||||||
std::string fn = style->getStringValue("fonts/splash", "");
|
std::string fn = style->getStringValue("fonts/splash", "");
|
||||||
text->setFont(fontCache->getfntpath(fn).str());
|
text->setFont(fontCache->getfntpath(fn).local8BitStr());
|
||||||
text->setCharacterSize(0.06);
|
text->setCharacterSize(0.06);
|
||||||
text->setColor(osg::Vec4(1, 1, 1, 1));
|
text->setColor(osg::Vec4(1, 1, 1, 1));
|
||||||
text->setPosition(osg::Vec3(0, -0.92, 0));
|
text->setPosition(osg::Vec3(0, -0.92, 0));
|
||||||
|
@ -329,7 +329,7 @@ static osg::Node* fgCreateSplashCamera()
|
||||||
geode->addDrawable(text);
|
geode->addDrawable(text);
|
||||||
|
|
||||||
osgText::Text* spinnertext = new osgText::Text;
|
osgText::Text* spinnertext = new osgText::Text;
|
||||||
spinnertext->setFont(fontCache->getfntpath(fn).str());
|
spinnertext->setFont(fontCache->getfntpath(fn).local8BitStr());
|
||||||
spinnertext->setCharacterSize(0.06);
|
spinnertext->setCharacterSize(0.06);
|
||||||
spinnertext->setColor(osg::Vec4(1, 1, 1, 1));
|
spinnertext->setColor(osg::Vec4(1, 1, 1, 1));
|
||||||
spinnertext->setPosition(osg::Vec3(0, -0.97, 0));
|
spinnertext->setPosition(osg::Vec3(0, -0.97, 0));
|
||||||
|
@ -340,7 +340,7 @@ static osg::Node* fgCreateSplashCamera()
|
||||||
geode->addDrawable(spinnertext);
|
geode->addDrawable(spinnertext);
|
||||||
|
|
||||||
text = new osgText::Text;
|
text = new osgText::Text;
|
||||||
text->setFont(fontCache->getfntpath(fn).str());
|
text->setFont(fontCache->getfntpath(fn).local8BitStr());
|
||||||
text->setCharacterSize(0.08);
|
text->setCharacterSize(0.08);
|
||||||
text->setColor(osg::Vec4(1, 1, 1, 1));
|
text->setColor(osg::Vec4(1, 1, 1, 1));
|
||||||
text->setPosition(osg::Vec3(0, 0.92, 0));
|
text->setPosition(osg::Vec3(0, 0.92, 0));
|
||||||
|
@ -351,7 +351,7 @@ static osg::Node* fgCreateSplashCamera()
|
||||||
|
|
||||||
|
|
||||||
text = new osgText::Text;
|
text = new osgText::Text;
|
||||||
text->setFont(fontCache->getfntpath(fn).str());
|
text->setFont(fontCache->getfntpath(fn).local8BitStr());
|
||||||
text->setCharacterSize(0.06);
|
text->setCharacterSize(0.06);
|
||||||
text->setColor(osg::Vec4(1, 1, 1, 1));
|
text->setColor(osg::Vec4(1, 1, 1, 1));
|
||||||
text->setPosition(osg::Vec3(0, 0.82, 0));
|
text->setPosition(osg::Vec3(0, 0.82, 0));
|
||||||
|
|
|
@ -261,8 +261,10 @@ bool UGTrack::load_flight( const string &path ) {
|
||||||
|
|
||||||
// open the gps file
|
// open the gps file
|
||||||
file = path; file.append( "gps.dat.gz" );
|
file = path; file.append( "gps.dat.gz" );
|
||||||
if ( (fgps = gzopen( file.c_str(), "r" )) == NULL ) {
|
std::string fdata = file.local8BitStr();
|
||||||
printf("Cannot open %s\n", file.c_str());
|
|
||||||
|
if ( (fgps = gzopen( fdata.c_str(), "r" )) == NULL ) {
|
||||||
|
printf("Cannot open %s\n", fdata.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,8 +276,9 @@ bool UGTrack::load_flight( const string &path ) {
|
||||||
|
|
||||||
// open the imu file
|
// open the imu file
|
||||||
file = path; file.append( "imu.dat.gz" );
|
file = path; file.append( "imu.dat.gz" );
|
||||||
if ( (fimu = gzopen( file.c_str(), "r" )) == NULL ) {
|
fdata = file.local8BitStr();
|
||||||
printf("Cannot open %s\n", file.c_str());
|
if ( (fimu = gzopen( fdata.c_str(), "r" )) == NULL ) {
|
||||||
|
printf("Cannot open %s\n", fdata.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,8 +290,10 @@ bool UGTrack::load_flight( const string &path ) {
|
||||||
|
|
||||||
// open the nav file
|
// open the nav file
|
||||||
file = path; file.append( "nav.dat.gz" );
|
file = path; file.append( "nav.dat.gz" );
|
||||||
if ( (fnav = gzopen( file.c_str(), "r" )) == NULL ) {
|
fdata = file.local8BitStr();
|
||||||
printf("Cannot open %s\n", file.c_str());
|
|
||||||
|
if ( (fnav = gzopen( fdata.c_str(), "r" )) == NULL ) {
|
||||||
|
printf("Cannot open %s\n", fdata.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,8 +306,10 @@ bool UGTrack::load_flight( const string &path ) {
|
||||||
|
|
||||||
// open the servo file
|
// open the servo file
|
||||||
file = path; file.append( "servo.dat.gz" );
|
file = path; file.append( "servo.dat.gz" );
|
||||||
if ( (fservo = gzopen( file.c_str(), "r" )) == NULL ) {
|
fdata = file.local8BitStr();
|
||||||
printf("Cannot open %s\n", file.c_str());
|
|
||||||
|
if ( (fservo = gzopen( fdata.c_str(), "r" )) == NULL ) {
|
||||||
|
printf("Cannot open %s\n", fdata.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,8 +321,10 @@ bool UGTrack::load_flight( const string &path ) {
|
||||||
|
|
||||||
// open the health file
|
// open the health file
|
||||||
file = path; file.append( "health.dat.gz" );
|
file = path; file.append( "health.dat.gz" );
|
||||||
if ( (fhealth = gzopen( file.c_str(), "r" )) == NULL ) {
|
fdata = file.local8BitStr();
|
||||||
printf("Cannot open %s\n", file.c_str());
|
|
||||||
|
if ( (fhealth = gzopen( fdata.c_str(), "r" )) == NULL ) {
|
||||||
|
printf("Cannot open %s\n", fdata.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,21 +105,23 @@ main(int argc, char** argv)
|
||||||
fg_root = PKGLIBDIR;
|
fg_root = PKGLIBDIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string fg_scenery;
|
SGPath fg_scenery;
|
||||||
if (arguments.read("--fg-scenery", fg_scenery)) {
|
std::string s;
|
||||||
} else if (const char *fg_scenery_env = std::getenv("FG_SCENERY")) {
|
if (arguments.read("--fg-scenery", s)) {
|
||||||
fg_scenery = fg_scenery_env;
|
fg_scenery = SGPath::fromLocal8Bit(s.c_str());
|
||||||
|
} else if (std::getenv("FG_SCENERY")) {
|
||||||
|
fg_scenery = SGPath::fromEnv("FG_SCENERY");
|
||||||
} else {
|
} else {
|
||||||
SGPath path(fg_root);
|
SGPath path(fg_root);
|
||||||
path.append("Scenery");
|
path.append("Scenery");
|
||||||
fg_scenery = path.str();
|
fg_scenery = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
SGSharedPtr<SGPropertyNode> props = new SGPropertyNode;
|
SGSharedPtr<SGPropertyNode> props = new SGPropertyNode;
|
||||||
try {
|
try {
|
||||||
SGPath preferencesFile = fg_root;
|
SGPath preferencesFile = fg_root;
|
||||||
preferencesFile.append("preferences.xml");
|
preferencesFile.append("preferences.xml");
|
||||||
readProperties(preferencesFile.str(), props);
|
readProperties(preferencesFile, props);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
// In case of an error, at least make summer :)
|
// In case of an error, at least make summer :)
|
||||||
props->getNode("sim/startup/season", true)->setStringValue("summer");
|
props->getNode("sim/startup/season", true)->setStringValue("summer");
|
||||||
|
@ -140,7 +142,7 @@ main(int argc, char** argv)
|
||||||
SGPath mpath(fg_root);
|
SGPath mpath(fg_root);
|
||||||
mpath.append("Materials/default/materials.xml");
|
mpath.append("Materials/default/materials.xml");
|
||||||
try {
|
try {
|
||||||
ml->load(fg_root, mpath.str(), props);
|
ml->load(fg_root, mpath.local8BitStr(), props);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "Problems loading FlightGear materials.\n"
|
SG_LOG(SG_GENERAL, SG_ALERT, "Problems loading FlightGear materials.\n"
|
||||||
<< "Probably FG_ROOT is not properly set.");
|
<< "Probably FG_ROOT is not properly set.");
|
||||||
|
@ -153,7 +155,7 @@ main(int argc, char** argv)
|
||||||
options = new simgear::SGReaderWriterOptions(*ropt);
|
options = new simgear::SGReaderWriterOptions(*ropt);
|
||||||
else
|
else
|
||||||
options = new simgear::SGReaderWriterOptions;
|
options = new simgear::SGReaderWriterOptions;
|
||||||
osgDB::convertStringPathIntoFilePathList(fg_scenery,
|
osgDB::convertStringPathIntoFilePathList(fg_scenery.local8BitStr(),
|
||||||
options->getDatabasePathList());
|
options->getDatabasePathList());
|
||||||
options->setMaterialLib(ml);
|
options->setMaterialLib(ml);
|
||||||
options->setPropertyNode(props);
|
options->setPropertyNode(props);
|
||||||
|
|
|
@ -175,9 +175,9 @@ void FGFontCache::init()
|
||||||
if (!_initialized) {
|
if (!_initialized) {
|
||||||
char *envp = ::getenv("FG_FONTS");
|
char *envp = ::getenv("FG_FONTS");
|
||||||
if (envp != NULL) {
|
if (envp != NULL) {
|
||||||
_path.set(envp);
|
_path = SGPath::fromEnv("FG_FONTS");
|
||||||
} else {
|
} else {
|
||||||
_path.set(ApplicationProperties::GetRootPath("Fonts").str());
|
_path = ApplicationProperties::GetRootPath("Fonts");
|
||||||
}
|
}
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,8 @@ bool FGFontCache::initializeFonts()
|
||||||
{
|
{
|
||||||
static std::string fontext("txf");
|
static std::string fontext("txf");
|
||||||
init();
|
init();
|
||||||
ulDir* fontdir = ulOpenDir(_path.c_str());
|
std::string pdata = _path.local8BitStr();
|
||||||
|
ulDir* fontdir = ulOpenDir(pdata.c_str());
|
||||||
if (!fontdir)
|
if (!fontdir)
|
||||||
return false;
|
return false;
|
||||||
const ulDirEnt *dirEntry;
|
const ulDirEnt *dirEntry;
|
||||||
|
@ -212,8 +213,9 @@ bool FGFontCache::initializeFonts()
|
||||||
SGPath path(_path);
|
SGPath path(_path);
|
||||||
path.append(dirEntry->d_name);
|
path.append(dirEntry->d_name);
|
||||||
if (path.extension() == fontext) {
|
if (path.extension() == fontext) {
|
||||||
|
std::string fdata = path.local8BitStr();
|
||||||
fntTexFont* f = new fntTexFont;
|
fntTexFont* f = new fntTexFont;
|
||||||
if (f->load((char *)path.c_str()))
|
if (f->load((char *)fdata.c_str()))
|
||||||
_texFonts[std::string(dirEntry->d_name)] = f;
|
_texFonts[std::string(dirEntry->d_name)] = f;
|
||||||
else
|
else
|
||||||
delete f;
|
delete f;
|
||||||
|
|
|
@ -153,7 +153,7 @@ FGPanelApplication::FGPanelApplication( int argc, char ** argv ) :
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SGPath tpath = ApplicationProperties::GetRootPath( panelFilename.c_str() );
|
SGPath tpath = ApplicationProperties::GetRootPath( panelFilename.c_str() );
|
||||||
readProperties( tpath.str(), ApplicationProperties::Properties );
|
readProperties( tpath, ApplicationProperties::Properties );
|
||||||
}
|
}
|
||||||
catch( sg_io_exception & e ) {
|
catch( sg_io_exception & e ) {
|
||||||
cerr << e.getFormattedMessage() << endl;
|
cerr << e.getFormattedMessage() << endl;
|
||||||
|
@ -353,7 +353,7 @@ SGPath ApplicationProperties::GetCwd()
|
||||||
buf[511] = '\0';
|
buf[511] = '\0';
|
||||||
if (cwd)
|
if (cwd)
|
||||||
{
|
{
|
||||||
path = cwd;
|
path = SGPath::fromLocal8Bit(cwd);
|
||||||
}
|
}
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,8 +117,8 @@ void FGCroppedTexture::bind( bool doGLBind )
|
||||||
loader = textureLoader[extension];
|
loader = textureLoader[extension];
|
||||||
}
|
}
|
||||||
|
|
||||||
_texture = loader->loadTexture( tpath.c_str() );
|
_texture = loader->loadTexture( tpath.local8BitStr() );
|
||||||
SG_LOG( SG_COCKPIT, SG_DEBUG, "Texture " << tpath.c_str() << " loaded from file as #" << _texture );
|
SG_LOG( SG_COCKPIT, SG_DEBUG, "Texture " << tpath << " loaded from file as #" << _texture );
|
||||||
|
|
||||||
cache[_path] = _texture;
|
cache[_path] = _texture;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,29 +60,33 @@ main(int argc, char** argv)
|
||||||
sglog().set_log_classes(SG_ALL);
|
sglog().set_log_classes(SG_ALL);
|
||||||
sglog().set_log_priority(SG_ALERT);
|
sglog().set_log_priority(SG_ALERT);
|
||||||
|
|
||||||
std::string fg_root;
|
SGPath fg_root;
|
||||||
if (arguments.read("--fg-root", fg_root)) {
|
std::string r;
|
||||||
} else if (const char *fg_root_env = std::getenv("FG_ROOT")) {
|
if (arguments.read("--fg-root", r)) {
|
||||||
fg_root = fg_root_env;
|
fg_root = SGPath::fromLocal8Bit(r.c_str());
|
||||||
|
} else if (std::getenv("FG_ROOT")) {
|
||||||
|
fg_root = SGPath::fromEnv("FG_ROOT");
|
||||||
} else {
|
} else {
|
||||||
fg_root = PKGLIBDIR;
|
fg_root = SGPath(PKGLIBDIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string fg_scenery;
|
SGPath fg_scenery;
|
||||||
if (arguments.read("--fg-scenery", fg_scenery)) {
|
std::string s;
|
||||||
} else if (const char *fg_scenery_env = std::getenv("FG_SCENERY")) {
|
if (arguments.read("--fg-scenery", s)) {
|
||||||
fg_scenery = fg_scenery_env;
|
fg_scenery = SGPath::fromLocal8Bit(s.c_str());
|
||||||
|
} else if (std::getenv("FG_SCENERY")) {
|
||||||
|
fg_scenery = SGPath::fromEnv("FG_SCENERY");
|
||||||
} else {
|
} else {
|
||||||
SGPath path(fg_root);
|
SGPath path(fg_root);
|
||||||
path.append("Scenery");
|
path.append("Scenery");
|
||||||
fg_scenery = path.str();
|
fg_scenery = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
SGSharedPtr<SGPropertyNode> props = new SGPropertyNode;
|
SGSharedPtr<SGPropertyNode> props = new SGPropertyNode;
|
||||||
try {
|
try {
|
||||||
SGPath preferencesFile = fg_root;
|
SGPath preferencesFile = fg_root;
|
||||||
preferencesFile.append("preferences.xml");
|
preferencesFile.append("preferences.xml");
|
||||||
readProperties(preferencesFile.str(), props);
|
readProperties(preferencesFile, props);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
// In case of an error, at least make summer :)
|
// In case of an error, at least make summer :)
|
||||||
props->getNode("sim/startup/season", true)->setStringValue("summer");
|
props->getNode("sim/startup/season", true)->setStringValue("summer");
|
||||||
|
@ -183,12 +187,12 @@ main(int argc, char** argv)
|
||||||
SGPath mpath(fg_root);
|
SGPath mpath(fg_root);
|
||||||
mpath.append("Materials/default/materials.xml");
|
mpath.append("Materials/default/materials.xml");
|
||||||
try {
|
try {
|
||||||
ml->load(fg_root, mpath.str(), props);
|
ml->load(fg_root.local8BitStr(), mpath.local8BitStr(), props);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "Problems loading FlightGear materials.\n"
|
SG_LOG(SG_GENERAL, SG_ALERT, "Problems loading FlightGear materials.\n"
|
||||||
<< "Probably FG_ROOT is not properly set.");
|
<< "Probably FG_ROOT is not properly set.");
|
||||||
}
|
}
|
||||||
simgear::SGModelLib::init(fg_root, props);
|
simgear::SGModelLib::init(fg_root.local8BitStr(), props);
|
||||||
|
|
||||||
// Set up the reader/writer options
|
// Set up the reader/writer options
|
||||||
osg::ref_ptr<simgear::SGReaderWriterOptions> options;
|
osg::ref_ptr<simgear::SGReaderWriterOptions> options;
|
||||||
|
@ -196,11 +200,11 @@ main(int argc, char** argv)
|
||||||
options = new simgear::SGReaderWriterOptions(*ropt);
|
options = new simgear::SGReaderWriterOptions(*ropt);
|
||||||
else
|
else
|
||||||
options = new simgear::SGReaderWriterOptions;
|
options = new simgear::SGReaderWriterOptions;
|
||||||
osgDB::convertStringPathIntoFilePathList(fg_scenery,
|
osgDB::convertStringPathIntoFilePathList(fg_scenery.local8BitStr(),
|
||||||
options->getDatabasePathList());
|
options->getDatabasePathList());
|
||||||
options->setMaterialLib(ml);
|
options->setMaterialLib(ml);
|
||||||
options->setPropertyNode(props);
|
options->setPropertyNode(props);
|
||||||
options->setPluginStringData("SimGear::FG_ROOT", fg_root);
|
options->setPluginStringData("SimGear::FG_ROOT", fg_root.local8BitStr());
|
||||||
// Omit building bounding volume trees, as the viewer will not run a simulation
|
// Omit building bounding volume trees, as the viewer will not run a simulation
|
||||||
options->setPluginStringData("SimGear::BOUNDINGVOLUMES", "OFF");
|
options->setPluginStringData("SimGear::BOUNDINGVOLUMES", "OFF");
|
||||||
viewer.setReaderWriterOptions(options.get());
|
viewer.setReaderWriterOptions(options.get());
|
||||||
|
|
Loading…
Add table
Reference in a new issue