Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
Reduce needless use of wchar / stringw
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Feb 18, 2024
1 parent 666f8e2 commit 7ba1ea2
Show file tree
Hide file tree
Showing 16 changed files with 28 additions and 98 deletions.
21 changes: 0 additions & 21 deletions include/ILogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,6 @@ class ILogger : public virtual IReferenceCounted
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
Expand Down
2 changes: 1 addition & 1 deletion include/IVideoDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions include/path.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ namespace io
*/
typedef core::string<fschar_t> 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.
Expand Down Expand Up @@ -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.
Expand Down
32 changes: 0 additions & 32 deletions source/Irrlicht/CLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
9 changes: 0 additions & 9 deletions source/Irrlicht/CLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,9 @@ class CLogger : public ILogger
//! 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);

Expand Down
6 changes: 3 additions & 3 deletions source/Irrlicht/CNullDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}


Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion source/Irrlicht/CNullDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion source/Irrlicht/COGLES2Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions source/Irrlicht/COGLES2Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion source/Irrlicht/COGLESDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions source/Irrlicht/COGLESDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -318,7 +318,7 @@ namespace video

COGLES1CacheHandler* CacheHandler;

core::stringw Name;
core::stringc Name;
core::matrix4 Matrices[ETS_COUNT];
core::array<u8> ColorBuffer;

Expand Down
6 changes: 3 additions & 3 deletions source/Irrlicht/COpenGLDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions source/Irrlicht/COpenGLDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -439,7 +439,7 @@ namespace video

COpenGLCacheHandler* CacheHandler;

core::stringw Name;
core::stringc Name;
core::matrix4 Matrices[ETS_COUNT];
core::array<u8> ColorBuffer;

Expand Down
14 changes: 7 additions & 7 deletions source/Irrlicht/OpenGL/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,19 +290,19 @@ 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;
}

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;
}
Expand Down Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions source/Irrlicht/OpenGL/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 0 additions & 6 deletions source/Irrlicht/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7ba1ea2

Please sign in to comment.