Skip to content

Commit a1459a9

Browse files
committedMay 26, 2019
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
1 parent 40dadec commit a1459a9

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed
 

‎src/client/content_cao.cpp

+3-14
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,8 @@ void GenericCAO::updateTexturePos()
10621062
}
10631063
}
10641064

1065-
void GenericCAO::updateTextures(const std::string &modref)
1065+
// Do not pass by reference, see header.
1066+
void GenericCAO::updateTextures(std::string mod)
10661067
{
10671068
ITextureSource *tsrc = m_client->tsrc();
10681069

@@ -1071,21 +1072,9 @@ void GenericCAO::updateTextures(const std::string &modref)
10711072
bool use_anisotropic_filter = g_settings->getBool("anisotropic_filter");
10721073

10731074
m_previous_texture_modifier = m_current_texture_modifier;
1074-
m_current_texture_modifier = modref;
1075+
m_current_texture_modifier = mod;
10751076
m_glow = m_prop.glow;
10761077

1077-
// Create a reference to the copy of "modref" just created. The
1078-
// following code will then use this reference instead of the
1079-
// original parameter which was passed by reference. This is
1080-
// necessary as "modref" can be a class member and there is a swap on
1081-
// those class members which can get triggered by the rest of the
1082-
// code of this method. This is faster than passing the "mod" by
1083-
// value because it reuses the copy made by the assignment to
1084-
// m_current_texture_modifier for the "mod" instead of having two
1085-
// copies, one for "mod" and another one (created from "mod") for
1086-
// the m_current_texture_modifier class member.
1087-
const std::string &mod = m_current_texture_modifier;
1088-
10891078
video::E_MATERIAL_TYPE material_type = (m_prop.use_texture_alpha) ?
10901079
video::EMT_TRANSPARENT_ALPHA_CHANNEL : video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
10911080

‎src/client/content_cao.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ class GenericCAO : public ClientActiveObject
225225

226226
void updateTexturePos();
227227

228-
void updateTextures(const std::string &modref);
228+
// ffs this HAS TO BE a string copy! See #5739 if you think otherwise
229+
// Reason: updateTextures(m_previous_texture_modifier);
230+
void updateTextures(std::string mod);
229231

230232
void updateAnimation();
231233

0 commit comments

Comments
 (0)
Please sign in to comment.