1
0
Fork 0

Further path -> UTF8 fixes for Windows

Requires corresponding SimGear change. With this last round, we work
with FGData on non-Latin1 path on Windows. (Final fixes are for
Nasal io.readfile, which needed io.stat to work, and SGSky allowing
correct SGPath use)
This commit is contained in:
James Turner 2020-03-15 15:00:55 +00:00
parent 36ba1e3dce
commit 2dcf9c30bb
6 changed files with 17 additions and 21 deletions

View file

@ -516,7 +516,7 @@ void FGAIBase::Transform() {
*/
std::vector<std::string> FGAIBase::resolveModelPath(ModelSearchOrder searchOrder)
{
std::vector<std::string> path_list;
string_list path_list;
if (searchOrder == DATA_ONLY) {
SG_LOG(SG_AI, SG_DEBUG, "Resolving model path: DATA only");
@ -536,7 +536,8 @@ std::vector<std::string> FGAIBase::resolveModelPath(ModelSearchOrder searchOrder
}
} else {
// No model, so fall back to the default
path_list.push_back(fgGetString("/sim/multiplay/default-model", default_model));
const SGPath defaultModelPath = SGPath::fromUtf8(fgGetString("/sim/multiplay/default-model", default_model));
path_list.push_back(defaultModelPath.utf8Str());
}
} else {
SG_LOG(SG_AI, SG_DEBUG, "Resolving model path: PREFER_AI/PREFER_DATA");
@ -545,7 +546,7 @@ std::vector<std::string> FGAIBase::resolveModelPath(ModelSearchOrder searchOrder
p.append(model_path);
if (p.exists()) {
SG_LOG(SG_AI, SG_DEBUG, "Found AI model: " << p);
path_list.push_back(p.local8BitStr());
path_list.push_back(p.utf8Str());
break;
}
}
@ -566,8 +567,8 @@ std::vector<std::string> FGAIBase::resolveModelPath(ModelSearchOrder searchOrder
for (SGPath p : globals->get_data_paths()) {
p.append(fallback_path);
if (p.exists()) {
SG_LOG(SG_AI, SG_DEBUG, "Found fallback model path for index " << _fallback_model_index << ": " << p.local8BitStr());
path_list.push_back(p.local8BitStr());
SG_LOG(SG_AI, SG_DEBUG, "Found fallback model path for index " << _fallback_model_index << ": " << p);
path_list.push_back(p.utf8Str());
break;
}
}

View file

@ -822,7 +822,7 @@ FGReplay::saveTape(const SGPath& Filename, SGPropertyNode* MetaDataProps)
bool ok = true;
/* open output stream *******************************************/
gzContainerWriter output(Filename.local8BitStr(), FlightRecorderFileMagic);
gzContainerWriter output(Filename, FlightRecorderFileMagic);
if (!output.good())
{
SG_LOG(SG_SYSTEMS, SG_ALERT, "Cannot open file" << Filename);
@ -940,7 +940,7 @@ FGReplay::loadTape(const SGPath& Filename, bool Preview, SGPropertyNode* UserDat
bool ok = true;
/* open input stream ********************************************/
gzContainerReader input(Filename.local8BitStr(), FlightRecorderFileMagic);
gzContainerReader input(Filename, FlightRecorderFileMagic);
if (input.eof() || !input.good())
{
SG_LOG(SG_SYSTEMS, SG_ALERT, "Cannot open file " << Filename);

View file

@ -47,9 +47,8 @@ static int CALLBACK BrowseFolderCallback(
if (uMsg == BFFM_INITIALIZED) {
// set the initial directory now
WindowsFileDialog* dlg = reinterpret_cast<WindowsFileDialog*>(lpData);
std::string s = dlg->getDirectory().local8BitStr();
LPCTSTR path = s.c_str();
::SendMessage(hwnd, BFFM_SETSELECTION, true, (LPARAM) path);
const auto w = dlg->getDirectory().wstr();
::SendMessageW(hwnd, BFFM_SETSELECTIONW, true, (LPARAM) w.c_str());
}
return 0;
}

View file

@ -82,7 +82,7 @@ void FGPgtTerrain::init( osg::Group* terrain ) {
fp.push_back(it->local8BitStr());
}
options->setPluginStringData("SimGear::FG_ROOT", globals->get_fg_root().local8BitStr());
options->setPluginStringData("SimGear::FG_ROOT", globals->get_fg_root().utf8Str());
options->setPluginStringData("SimGear::BARE_LOD_RANGE", fgGetString("/sim/rendering/static-lod/bare-delta", boost::lexical_cast<string>(SG_OBJECT_RANGE_BARE)));
options->setPluginStringData("SimGear::ROUGH_LOD_RANGE", fgGetString("/sim/rendering/static-lod/rough-delta", boost::lexical_cast<string>(SG_OBJECT_RANGE_ROUGH)));

View file

@ -451,15 +451,13 @@ FGRenderer::init( void )
// on other subsystems to be inited, eg Ephemeris
_sky = new SGSky;
SGPath texture_path(globals->get_fg_root());
texture_path.append("Textures");
texture_path.append("Sky");
const SGPath texture_path = globals->get_fg_root() / "Textures" / "Sky";
for (int i = 0; i < FGEnvironmentMgr::MAX_CLOUD_LAYERS; i++) {
SGCloudLayer * layer = new SGCloudLayer(texture_path.local8BitStr());
SGCloudLayer * layer = new SGCloudLayer(texture_path);
_sky->add_cloud_layer(layer);
}
_sky->texture_path( texture_path.local8BitStr() );
_sky->set_texture_path( texture_path );
// XXX: Should always be true
eventHandler->setChangeStatsCameraRenderOrder( true );

8
src/Viewer/renderer_legacy.cxx Normal file → Executable file
View file

@ -555,15 +555,13 @@ FGRenderer::init( void )
// on other subsystems to be inited, eg Ephemeris
_sky = new SGSky;
SGPath texture_path(globals->get_fg_root());
texture_path.append("Textures");
texture_path.append("Sky");
const SGPath texture_path = globals->get_fg_root() / "Textures" / "Sky";
for (int i = 0; i < FGEnvironmentMgr::MAX_CLOUD_LAYERS; i++) {
SGCloudLayer * layer = new SGCloudLayer(texture_path.local8BitStr());
SGCloudLayer * layer = new SGCloudLayer(texture_path);
_sky->add_cloud_layer(layer);
}
_sky->texture_path( texture_path.local8BitStr() );
_sky->set_texture_path( texture_path );
if (!_classicalRenderer) {
eventHandler->setChangeStatsCameraRenderOrder( true );