From c8d802bc1d7d26e5d017c41c7612db34e9c0a5cb Mon Sep 17 00:00:00 2001 From: James Turner Date: Sun, 15 Mar 2020 14:26:32 +0000 Subject: [PATCH] More SGPath / UTF-8 fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use SGPath in more public APIs, so FlightGear doesn’t have to convert and guess the conversion itself. --- simgear/io/iostreams/gzcontainerfile.cxx | 8 ++++---- simgear/io/iostreams/gzcontainerfile.hxx | 4 ++-- simgear/scene/sky/cloud.cxx | 2 +- simgear/scene/sky/cloud.hxx | 3 ++- simgear/scene/sky/sky.cxx | 5 +++-- simgear/scene/sky/sky.hxx | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/simgear/io/iostreams/gzcontainerfile.cxx b/simgear/io/iostreams/gzcontainerfile.cxx index c60650a8..d5dd4afd 100644 --- a/simgear/io/iostreams/gzcontainerfile.cxx +++ b/simgear/io/iostreams/gzcontainerfile.cxx @@ -71,10 +71,10 @@ static const uint32_t EndianMagic = 0x11223344; * gzContainerWriter **************************************************************************/ -gzContainerWriter::gzContainerWriter(const std::string& name, +gzContainerWriter::gzContainerWriter(const SGPath& name, const std::string& fileMagic) : sg_gzofstream(name, ios_out | ios_binary), - filename(name) + filename(name.utf8Str()) { /* write byte-order marker **************************************/ write((char*)&EndianMagic, sizeof(EndianMagic)); @@ -138,10 +138,10 @@ gzContainerWriter::writeContainer(ContainerType Type, SGPropertyNode* root) * gzContainerReader **************************************************************************/ -gzContainerReader::gzContainerReader(const std::string& name, +gzContainerReader::gzContainerReader(const SGPath& name, const std::string& fileMagic) : sg_gzifstream(SGPath(name), ios_in | ios_binary), - filename(name) + filename(name.utf8Str()) { bool ok = (good() && !eof()); diff --git a/simgear/io/iostreams/gzcontainerfile.hxx b/simgear/io/iostreams/gzcontainerfile.hxx index 79c5563a..40af7a13 100644 --- a/simgear/io/iostreams/gzcontainerfile.hxx +++ b/simgear/io/iostreams/gzcontainerfile.hxx @@ -35,7 +35,7 @@ typedef int ContainerType; class gzContainerReader : public sg_gzifstream { public: - gzContainerReader( const std::string& name, + gzContainerReader( const SGPath& name, const std::string& fileMagic); bool readContainerHeader(ContainerType* pType, size_t* pSize); @@ -48,7 +48,7 @@ private: class gzContainerWriter : public sg_gzofstream { public: - gzContainerWriter( const std::string& name, + gzContainerWriter( const SGPath& name, const std::string& fileMagic); bool writeContainerHeader(ContainerType Type, size_t Size); diff --git a/simgear/scene/sky/cloud.cxx b/simgear/scene/sky/cloud.cxx index 103f7e4e..08649e1e 100644 --- a/simgear/scene/sky/cloud.cxx +++ b/simgear/scene/sky/cloud.cxx @@ -93,7 +93,7 @@ SGMakeState(const SGPath &path, const char* colorTexture, } // Constructor -SGCloudLayer::SGCloudLayer( const string &tex_path ) : +SGCloudLayer::SGCloudLayer( const SGPath &tex_path ) : cloud_root(new osg::Switch), layer_root(new osg::Switch), group_top(new osg::Group), diff --git a/simgear/scene/sky/cloud.hxx b/simgear/scene/sky/cloud.hxx index fb4cf3c5..65b525fa 100644 --- a/simgear/scene/sky/cloud.hxx +++ b/simgear/scene/sky/cloud.hxx @@ -42,6 +42,7 @@ #include class SGCloudField; +class SGPath; /** * A class layer to model a single cloud layer @@ -73,7 +74,7 @@ public: * Constructor * @param tex_path the path to the set of cloud textures */ - SGCloudLayer( const std::string &tex_path ); + SGCloudLayer( const SGPath &tex_path ); /** * Destructor diff --git a/simgear/scene/sky/sky.cxx b/simgear/scene/sky/sky.cxx index 25df35d7..796b1522 100644 --- a/simgear/scene/sky/sky.cxx +++ b/simgear/scene/sky/sky.cxx @@ -296,8 +296,9 @@ void SGSky::set_3dCloudUseImpostors(bool imp) SGCloudField::setUseImpostors(imp); } -void SGSky::texture_path( const std::string& path ) { - tex_path = SGPath( path ); +void SGSky::set_texture_path( const SGPath& path ) +{ + tex_path = path; } // modify the current visibility based on cloud layers, thickness, diff --git a/simgear/scene/sky/sky.hxx b/simgear/scene/sky/sky.hxx index a824b74a..a07d9d0c 100644 --- a/simgear/scene/sky/sky.hxx +++ b/simgear/scene/sky/sky.hxx @@ -326,7 +326,7 @@ public: * * @param path Base path to texture locations */ - void texture_path( const std::string& path ); + void set_texture_path( const SGPath& path ); /** * Get the current sun color