diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/content_cao.cpp | 16 | ||||
-rw-r--r-- | src/client/content_cao.h | 4 | ||||
-rw-r--r-- | src/client/guiscalingfilter.cpp | 2 | ||||
-rw-r--r-- | src/client/guiscalingfilter.h | 2 | ||||
-rw-r--r-- | src/client/hud.cpp | 2 | ||||
-rw-r--r-- | src/client/hud.h | 2 | ||||
-rw-r--r-- | src/client/tile.cpp | 3 |
7 files changed, 21 insertions, 10 deletions
diff --git a/src/client/content_cao.cpp b/src/client/content_cao.cpp index b169ba75f..cf22aa0ed 100644 --- a/src/client/content_cao.cpp +++ b/src/client/content_cao.cpp @@ -1062,7 +1062,7 @@ void GenericCAO::updateTexturePos() } } -void GenericCAO::updateTextures(std::string mod) +void GenericCAO::updateTextures(const std::string &modref) { ITextureSource *tsrc = m_client->tsrc(); @@ -1071,9 +1071,21 @@ void GenericCAO::updateTextures(std::string mod) bool use_anisotropic_filter = g_settings->getBool("anisotropic_filter"); m_previous_texture_modifier = m_current_texture_modifier; - m_current_texture_modifier = mod; + m_current_texture_modifier = modref; m_glow = m_prop.glow; + // Create a reference to the copy of "modref" just created. The + // following code will then use this reference instead of the + // original parameter which was passed by reference. This is + // necessary as "modref" can be a class member and there is a swap on + // those class members which can get triggered by the rest of the + // code of this method. This is faster than passing the "mod" by + // value because it reuses the copy made by the assignment to + // m_current_texture_modifier for the "mod" instead of having two + // copies, one for "mod" and another one (created from "mod") for + // the m_current_texture_modifier class member. + const std::string &mod = m_current_texture_modifier; + video::E_MATERIAL_TYPE material_type = (m_prop.use_texture_alpha) ? video::EMT_TRANSPARENT_ALPHA_CHANNEL : video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; diff --git a/src/client/content_cao.h b/src/client/content_cao.h index 3ce628d30..320607061 100644 --- a/src/client/content_cao.h +++ b/src/client/content_cao.h @@ -225,9 +225,7 @@ public: void updateTexturePos(); - // std::string copy is mandatory as mod can be a class member and there is a swap - // on those class members... do NOT pass by reference - void updateTextures(std::string mod); + void updateTextures(const std::string &modref); void updateAnimation(); diff --git a/src/client/guiscalingfilter.cpp b/src/client/guiscalingfilter.cpp index 3b4377da5..312f93939 100644 --- a/src/client/guiscalingfilter.cpp +++ b/src/client/guiscalingfilter.cpp @@ -39,7 +39,7 @@ std::map<io::path, video::ITexture *> g_txrCache; /* Manually insert an image into the cache, useful to avoid texture-to-image * conversion whenever we can intercept it. */ -void guiScalingCache(io::path key, video::IVideoDriver *driver, video::IImage *value) +void guiScalingCache(const io::path &key, video::IVideoDriver *driver, video::IImage *value) { if (!g_settings->getBool("gui_scaling_filter")) return; diff --git a/src/client/guiscalingfilter.h b/src/client/guiscalingfilter.h index 4661bf8da..a5cd78511 100644 --- a/src/client/guiscalingfilter.h +++ b/src/client/guiscalingfilter.h @@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., /* Manually insert an image into the cache, useful to avoid texture-to-image * conversion whenever we can intercept it. */ -void guiScalingCache(io::path key, video::IVideoDriver *driver, video::IImage *value); +void guiScalingCache(const io::path &key, video::IVideoDriver *driver, video::IImage *value); // Manually clear the cache, e.g. when switching to different worlds. void guiScalingCacheClear(); diff --git a/src/client/hud.cpp b/src/client/hud.cpp index 1a2287a13..cb58fb500 100644 --- a/src/client/hud.cpp +++ b/src/client/hud.cpp @@ -372,7 +372,7 @@ void Hud::drawLuaElements(const v3s16 &camera_offset) } -void Hud::drawStatbar(v2s32 pos, u16 corner, u16 drawdir, std::string texture, +void Hud::drawStatbar(v2s32 pos, u16 corner, u16 drawdir, const std::string &texture, s32 count, v2s32 offset, v2s32 size) { const video::SColor color(255, 255, 255, 255); diff --git a/src/client/hud.h b/src/client/hud.h index e9bcdf4e2..693d2adee 100644 --- a/src/client/hud.h +++ b/src/client/hud.h @@ -81,7 +81,7 @@ public: void drawLuaElements(const v3s16 &camera_offset); private: - void drawStatbar(v2s32 pos, u16 corner, u16 drawdir, std::string texture, + void drawStatbar(v2s32 pos, u16 corner, u16 drawdir, const std::string &texture, s32 count, v2s32 offset, v2s32 size = v2s32()); void drawItems(v2s32 upperleftpos, v2s32 screen_offset, s32 itemcount, diff --git a/src/client/tile.cpp b/src/client/tile.cpp index 4911013ae..72f7358b1 100644 --- a/src/client/tile.cpp +++ b/src/client/tile.cpp @@ -131,7 +131,8 @@ std::string getTexturePath(const std::string &filename) Check from texture_path */ for (const auto &path : getTextureDirs()) { - std::string testpath = path + DIR_DELIM + filename; + std::string testpath = path + DIR_DELIM; + testpath.append(filename); // Check all filename extensions. Returns "" if not found. fullpath = getImagePath(testpath); if (!fullpath.empty()) |