From 19819bd23a8d0ee6d72290a657a0313375a81814 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sun, 18 Feb 2024 16:29:03 +0100 Subject: [PATCH] Reduce needless use of wchar / stringw --- include/ILogger.h | 21 -------------------- include/IVideoDriver.h | 2 +- include/path.h | 8 +++----- source/Irrlicht/CLogger.cpp | 32 ------------------------------- source/Irrlicht/CLogger.h | 9 --------- source/Irrlicht/CNullDriver.cpp | 6 +++--- source/Irrlicht/CNullDriver.h | 2 +- source/Irrlicht/COGLES2Driver.cpp | 14 +++++++------- source/Irrlicht/COGLES2Driver.h | 4 ++-- source/Irrlicht/COGLESDriver.cpp | 2 +- source/Irrlicht/COGLESDriver.h | 4 ++-- source/Irrlicht/COpenGLDriver.cpp | 6 +++--- source/Irrlicht/COpenGLDriver.h | 4 ++-- source/Irrlicht/OpenGL/Driver.cpp | 14 +++++++------- source/Irrlicht/OpenGL/Driver.h | 4 ++-- source/Irrlicht/os.cpp | 6 ------ 16 files changed, 34 insertions(+), 104 deletions(-) diff --git a/include/ILogger.h b/include/ILogger.h index 4b595b6..335c59b 100644 --- a/include/ILogger.h +++ b/include/ILogger.h @@ -73,27 +73,6 @@ public: filtered with these levels. If you want to be a text displayed, independent on what level filter is set, use ELL_NONE. */ virtual void log(const c8* text, const c8* hint, ELOG_LEVEL ll=ELL_INFORMATION) = 0; - virtual void log(const c8* text, const wchar_t* hint, ELOG_LEVEL ll=ELL_INFORMATION) = 0; - - //! Prints out a text into the log - /** \param text: Text to print out. - \param hint: Additional info. This string is added after a " :" to the - string. - \param ll: Log level of the text. If the text is an error, set - it to ELL_ERROR, if it is warning set it to ELL_WARNING, and if it - is just an informational text, set it to ELL_INFORMATION. Texts are - filtered with these levels. If you want to be a text displayed, - independent on what level filter is set, use ELL_NONE. */ - virtual void log(const wchar_t* text, const wchar_t* hint, ELOG_LEVEL ll=ELL_INFORMATION) = 0; - - //! Prints out a text into the log - /** \param text: Text to print out. - \param ll: Log level of the text. If the text is an error, set - it to ELL_ERROR, if it is warning set it to ELL_WARNING, and if it - is just an informational text, set it to ELL_INFORMATION. Texts are - filtered with these levels. If you want to be a text displayed, - independent on what level filter is set, use ELL_NONE. */ - virtual void log(const wchar_t* text, ELOG_LEVEL ll=ELL_INFORMATION) = 0; }; } // end namespace diff --git a/include/IVideoDriver.h b/include/IVideoDriver.h index 9cc293d..150591a 100644 --- a/include/IVideoDriver.h +++ b/include/IVideoDriver.h @@ -869,7 +869,7 @@ namespace video //! Gets name of this video driver. /** \return Returns the name of the video driver, e.g. in case of the Direct3D8 driver, it would return "Direct3D 8.1". */ - virtual const wchar_t* getName() const =0; + virtual const char* getName() const =0; //! Adds an external image loader to the engine. /** This is useful if the Irrlicht Engine should be able to load diff --git a/include/path.h b/include/path.h index 5bda3e4..4fa117d 100644 --- a/include/path.h +++ b/include/path.h @@ -17,6 +17,9 @@ namespace io */ typedef core::string path; +// Type only exists for historcal reasons, paths are always char now. +static_assert(sizeof(fschar_t) == sizeof(char)); + //! Used in places where we identify objects by a filename, but don't actually work with the real filename /** Irrlicht is internally not case-sensitive when it comes to names. Also this class is a first step towards support for correctly serializing renamed objects. @@ -62,11 +65,6 @@ struct SNamedPath { return core::stringc(getPath()); } - //! Implicit cast to io::path - operator core::stringw() const - { - return core::stringw(getPath()); - } protected: // convert the given path string to a name string. diff --git a/source/Irrlicht/CLogger.cpp b/source/Irrlicht/CLogger.cpp index 7ef40ec..5e3400e 100644 --- a/source/Irrlicht/CLogger.cpp +++ b/source/Irrlicht/CLogger.cpp @@ -59,38 +59,6 @@ namespace irr log (s.c_str(), ll); } - //! Prints out a text into the log - void CLogger::log(const wchar_t* text, ELOG_LEVEL ll) - { - if (ll < LogLevel) - return; - - core::stringc s = text; - log(s.c_str(), ll); - } - - - //! Prints out a text into the log - void CLogger::log(const wchar_t* text, const wchar_t* hint, ELOG_LEVEL ll) - { - if (ll < LogLevel) - return; - - core::stringc s1 = text; - core::stringc s2 = hint; - log(s1.c_str(), s2.c_str(), ll); - } - - //! Prints out a text into the log - void CLogger::log(const c8* text, const wchar_t* hint, ELOG_LEVEL ll) - { - if (ll < LogLevel) - return; - - core::stringc s2 = hint; - log( text, s2.c_str(), ll); - } - //! Sets a new event receiver void CLogger::setReceiver(IEventReceiver* r) { diff --git a/source/Irrlicht/CLogger.h b/source/Irrlicht/CLogger.h index df576e8..c1f02c6 100644 --- a/source/Irrlicht/CLogger.h +++ b/source/Irrlicht/CLogger.h @@ -28,18 +28,9 @@ public: //! Prints out a text into the log void log(const c8* text, ELOG_LEVEL ll=ELL_INFORMATION) override; - //! Prints out a text into the log - void log(const wchar_t* text, ELOG_LEVEL ll=ELL_INFORMATION) override; - //! Prints out a text into the log void log(const c8* text, const c8* hint, ELOG_LEVEL ll=ELL_INFORMATION) override; - //! Prints out a text into the log - void log(const c8* text, const wchar_t* hint, ELOG_LEVEL ll=ELL_INFORMATION) override; - - //! Prints out a text into the log - void log(const wchar_t* text, const wchar_t* hint, ELOG_LEVEL ll=ELL_INFORMATION) override; - //! Sets a new event receiver void setReceiver(IEventReceiver* r); diff --git a/source/Irrlicht/CNullDriver.cpp b/source/Irrlicht/CNullDriver.cpp index bd6d17a..79ebea1 100644 --- a/source/Irrlicht/CNullDriver.cpp +++ b/source/Irrlicht/CNullDriver.cpp @@ -839,9 +839,9 @@ const SColorf& CNullDriver::getAmbientLight() const //! \return Returns the name of the video driver. Example: In case of the DIRECT3D8 //! driver, it would return "Direct3D8". -const wchar_t* CNullDriver::getName() const +const char* CNullDriver::getName() const { - return L"Irrlicht NullDevice"; + return "Irrlicht NullDevice"; } @@ -1929,7 +1929,7 @@ IImage* CNullDriver::createScreenShot(video::ECOLOR_FORMAT format, video::E_REND // prints renderer version void CNullDriver::printVersion() { - core::stringw namePrint = L"Using renderer: "; + core::stringc namePrint = "Using renderer: "; namePrint += getName(); os::Printer::log(namePrint.c_str(), ELL_INFORMATION); } diff --git a/source/Irrlicht/CNullDriver.h b/source/Irrlicht/CNullDriver.h index 66141c3..59a0126 100644 --- a/source/Irrlicht/CNullDriver.h +++ b/source/Irrlicht/CNullDriver.h @@ -241,7 +241,7 @@ namespace video //! \return Returns the name of the video driver. Example: In case of the DIRECT3D8 //! driver, it would return "Direct3D8.1". - const wchar_t* getName() const override; + const char* getName() const override; //! Sets the dynamic ambient light color. The default color is //! (0,0,0,0) which means it is dark. diff --git a/source/Irrlicht/COGLES2Driver.cpp b/source/Irrlicht/COGLES2Driver.cpp index 58d0860..9ee7c6b 100644 --- a/source/Irrlicht/COGLES2Driver.cpp +++ b/source/Irrlicht/COGLES2Driver.cpp @@ -159,9 +159,9 @@ COGLES2Driver::~COGLES2Driver() io::IReadFile* vsFile = FileSystem->createAndOpenFile(vsPath); if ( !vsFile ) { - core::stringw warning(L"Warning: Missing shader files needed to simulate fixed function materials:\n"); - warning += core::stringw(vsPath) + L"\n"; - warning += L"Shaderpath can be changed in SIrrCreationParamters::OGLES2ShaderPath"; + std::string warning("Warning: Missing shader files needed to simulate fixed function materials:\n"); + warning.append(vsPath.c_str()).append("\n"); + warning += "The path can be changed in SIrrCreationParamters::OGLES2ShaderPath"; os::Printer::log(warning.c_str(), ELL_WARNING); return; } @@ -169,9 +169,9 @@ COGLES2Driver::~COGLES2Driver() io::IReadFile* fsFile = FileSystem->createAndOpenFile(fsPath); if ( !fsFile ) { - core::stringw warning(L"Warning: Missing shader files needed to simulate fixed function materials:\n"); - warning += core::stringw(fsPath) + L"\n"; - warning += L"Shaderpath can be changed in SIrrCreationParamters::OGLES2ShaderPath"; + std::string warning("Warning: Missing shader files needed to simulate fixed function materials:\n"); + warning.append(fsPath.c_str()).append("\n"); + warning += "The path can be changed in SIrrCreationParamters::OGLES2ShaderPath"; os::Printer::log(warning.c_str(), ELL_WARNING); return; } @@ -1858,7 +1858,7 @@ COGLES2Driver::~COGLES2Driver() //! \return Returns the name of the video driver. - const wchar_t* COGLES2Driver::getName() const + const char* COGLES2Driver::getName() const { return Name.c_str(); } diff --git a/source/Irrlicht/COGLES2Driver.h b/source/Irrlicht/COGLES2Driver.h index 81223ad..40cb9a1 100644 --- a/source/Irrlicht/COGLES2Driver.h +++ b/source/Irrlicht/COGLES2Driver.h @@ -145,7 +145,7 @@ namespace video // virtual void drawPixel(u32 x, u32 y, const SColor & color); //! Returns the name of the video driver. - const wchar_t* getName() const override; + const char* getName() const override; //! Returns the maximum texture size supported. core::dimension2du getMaxTextureSize() const override; @@ -352,7 +352,7 @@ namespace video virtual void setViewPortRaw(u32 width, u32 height); COGLES2CacheHandler* CacheHandler; - core::stringw Name; + core::stringc Name; core::stringc VendorName; SIrrlichtCreationParameters Params; diff --git a/source/Irrlicht/COGLESDriver.cpp b/source/Irrlicht/COGLESDriver.cpp index 3fa1417..e52fdbb 100644 --- a/source/Irrlicht/COGLESDriver.cpp +++ b/source/Irrlicht/COGLESDriver.cpp @@ -2041,7 +2041,7 @@ void COGLES1Driver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh //! \return Returns the name of the video driver. -const wchar_t* COGLES1Driver::getName() const +const char* COGLES1Driver::getName() const { return Name.c_str(); } diff --git a/source/Irrlicht/COGLESDriver.h b/source/Irrlicht/COGLESDriver.h index 1d5e1b3..d32f6c1 100644 --- a/source/Irrlicht/COGLESDriver.h +++ b/source/Irrlicht/COGLESDriver.h @@ -136,7 +136,7 @@ namespace video SColor color = SColor(255,255,255,255)) override; //! Returns the name of the video driver. - const wchar_t* getName() const override; + const char* getName() const override; //! Sets the dynamic ambient light color. void setAmbientLight(const SColorf& color) override; @@ -318,7 +318,7 @@ namespace video COGLES1CacheHandler* CacheHandler; - core::stringw Name; + core::stringc Name; core::matrix4 Matrices[ETS_COUNT]; core::array ColorBuffer; diff --git a/source/Irrlicht/COpenGLDriver.cpp b/source/Irrlicht/COpenGLDriver.cpp index bcad09d..e337cbb 100644 --- a/source/Irrlicht/COpenGLDriver.cpp +++ b/source/Irrlicht/COpenGLDriver.cpp @@ -90,9 +90,9 @@ bool COpenGLDriver::genericDriverInit() if (ContextManager) ContextManager->grab(); - Name=L"OpenGL "; + Name="OpenGL "; Name.append(glGetString(GL_VERSION)); - s32 pos=Name.findNext(L' ', 7); + s32 pos=Name.findNext(' ', 7); if (pos != -1) Name=Name.subString(0, pos); printVersion(); @@ -2920,7 +2920,7 @@ void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh //! \return Returns the name of the video driver. -const wchar_t* COpenGLDriver::getName() const +const char* COpenGLDriver::getName() const { return Name.c_str(); } diff --git a/source/Irrlicht/COpenGLDriver.h b/source/Irrlicht/COpenGLDriver.h index 9d82e43..5fef5cd 100644 --- a/source/Irrlicht/COpenGLDriver.h +++ b/source/Irrlicht/COpenGLDriver.h @@ -205,7 +205,7 @@ namespace video //! \return Returns the name of the video driver. Example: In case of the Direct3D8 //! driver, it would return "Direct3D8.1". - const wchar_t* getName() const override; + const char* getName() const override; //! Sets the dynamic ambient light color. The default color is //! (0,0,0,0) which means it is dark. @@ -439,7 +439,7 @@ namespace video COpenGLCacheHandler* CacheHandler; - core::stringw Name; + core::stringc Name; core::matrix4 Matrices[ETS_COUNT]; core::array ColorBuffer; diff --git a/source/Irrlicht/OpenGL/Driver.cpp b/source/Irrlicht/OpenGL/Driver.cpp index bf5aacb..7a94792 100644 --- a/source/Irrlicht/OpenGL/Driver.cpp +++ b/source/Irrlicht/OpenGL/Driver.cpp @@ -290,9 +290,9 @@ COpenGL3DriverBase::~COpenGL3DriverBase() io::IReadFile* vsFile = FileSystem->createAndOpenFile(vsPath); if ( !vsFile ) { - core::stringw warning(L"Warning: Missing shader files needed to simulate fixed function materials:\n"); - warning += core::stringw(vsPath) + L"\n"; - warning += L"Shaderpath can be changed in SIrrCreationParamters::OGLES2ShaderPath"; + std::string warning("Warning: Missing shader files needed to simulate fixed function materials:\n"); + warning.append(vsPath.c_str()).append("\n"); + warning += "Shaderpath can be changed in SIrrCreationParamters::OGLES2ShaderPath"; os::Printer::log(warning.c_str(), ELL_WARNING); return; } @@ -300,9 +300,9 @@ COpenGL3DriverBase::~COpenGL3DriverBase() io::IReadFile* fsFile = FileSystem->createAndOpenFile(fsPath); if ( !fsFile ) { - core::stringw warning(L"Warning: Missing shader files needed to simulate fixed function materials:\n"); - warning += core::stringw(fsPath) + L"\n"; - warning += L"Shaderpath can be changed in SIrrCreationParamters::OGLES2ShaderPath"; + std::string warning("Warning: Missing shader files needed to simulate fixed function materials:\n"); + warning.append(fsPath.c_str()).append("\n"); + warning += "Shaderpath can be changed in SIrrCreationParamters::OGLES2ShaderPath"; os::Printer::log(warning.c_str(), ELL_WARNING); return; } @@ -1619,7 +1619,7 @@ COpenGL3DriverBase::~COpenGL3DriverBase() //! \return Returns the name of the video driver. - const wchar_t* COpenGL3DriverBase::getName() const + const char* COpenGL3DriverBase::getName() const { return Name.c_str(); } diff --git a/source/Irrlicht/OpenGL/Driver.h b/source/Irrlicht/OpenGL/Driver.h index 862c79d..b15890d 100644 --- a/source/Irrlicht/OpenGL/Driver.h +++ b/source/Irrlicht/OpenGL/Driver.h @@ -136,7 +136,7 @@ namespace video // virtual void drawPixel(u32 x, u32 y, const SColor & color); //! Returns the name of the video driver. - const wchar_t* getName() const override; + const char* getName() const override; //! Returns the maximum texture size supported. core::dimension2du getMaxTextureSize() const override; @@ -345,7 +345,7 @@ namespace video void endDraw(const VertexType &vertexType); COpenGL3CacheHandler* CacheHandler; - core::stringw Name; + core::stringc Name; core::stringc VendorName; SIrrlichtCreationParameters Params; OpenGLVersion Version; diff --git a/source/Irrlicht/os.cpp b/source/Irrlicht/os.cpp index 9de3908..a2d8834 100644 --- a/source/Irrlicht/os.cpp +++ b/source/Irrlicht/os.cpp @@ -263,12 +263,6 @@ namespace os Logger->log(message, ll); } - void Printer::log(const wchar_t* message, ELOG_LEVEL ll) - { - if (Logger) - Logger->log(message, ll); - } - void Printer::log(const c8* message, const c8* hint, ELOG_LEVEL ll) { if (Logger)