diff options
author | SmallJoker <mk939@ymail.com> | 2019-05-26 09:54:23 +0200 |
---|---|---|
committer | SmallJoker <mk939@ymail.com> | 2019-05-26 09:54:26 +0200 |
commit | a1459a9eac4eeb35a6c578a8b8f96393f87ed53d (patch) | |
tree | c4a69c8d6434f2be5d2c38f43d75eb711240f1e0 /src | |
parent | 40dadecb6ece6c9bbf7739e3a44ace25c0716dec (diff) | |
download | minetest-a1459a9eac4eeb35a6c578a8b8f96393f87ed53d.tar.gz minetest-a1459a9eac4eeb35a6c578a8b8f96393f87ed53d.tar.bz2 minetest-a1459a9eac4eeb35a6c578a8b8f96393f87ed53d.zip |
Fix persistent ^[brighten after damage again (#5739)
The old texture modifier is restored by passing `m_previous_texture_modifier`.
Either copy it manually or let the function parameter do that.
Victims so far:
8e0b80a Apr 2018
eb2bda7 May 2019
Diffstat (limited to 'src')
-rw-r--r-- | src/client/content_cao.cpp | 17 | ||||
-rw-r--r-- | src/client/content_cao.h | 4 |
2 files changed, 6 insertions, 15 deletions
diff --git a/src/client/content_cao.cpp b/src/client/content_cao.cpp index cf22aa0ed..388a71873 100644 --- a/src/client/content_cao.cpp +++ b/src/client/content_cao.cpp @@ -1062,7 +1062,8 @@ void GenericCAO::updateTexturePos() } } -void GenericCAO::updateTextures(const std::string &modref) +// Do not pass by reference, see header. +void GenericCAO::updateTextures(std::string mod) { ITextureSource *tsrc = m_client->tsrc(); @@ -1071,21 +1072,9 @@ void GenericCAO::updateTextures(const std::string &modref) bool use_anisotropic_filter = g_settings->getBool("anisotropic_filter"); m_previous_texture_modifier = m_current_texture_modifier; - m_current_texture_modifier = modref; + m_current_texture_modifier = mod; 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 320607061..ca1518fb2 100644 --- a/src/client/content_cao.h +++ b/src/client/content_cao.h @@ -225,7 +225,9 @@ public: void updateTexturePos(); - void updateTextures(const std::string &modref); + // ffs this HAS TO BE a string copy! See #5739 if you think otherwise + // Reason: updateTextures(m_previous_texture_modifier); + void updateTextures(std::string mod); void updateAnimation(); |