1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Fix new texture properties not being sent for minetest.add_particle (#14760)

Co-authored-by: Lars Müller <appgurulars@gmx.de>
This commit is contained in:
grorp 2024-07-01 20:41:54 +02:00 committed by GitHub
parent 95e77bd7cb
commit ea827e4c5d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 7 deletions

View file

@ -197,7 +197,8 @@ enum class ParticleTextureFlags : u8 {
* decltype everywhere */
using FlagT = std::underlying_type_t<ParticleTextureFlags>;
void ServerParticleTexture::serialize(std::ostream &os, u16 protocol_ver, bool newPropertiesOnly) const
void ServerParticleTexture::serialize(std::ostream &os, u16 protocol_ver,
bool newPropertiesOnly, bool skipAnimation) const
{
/* newPropertiesOnly is used to de/serialize parameters of the legacy texture
* field, which are encoded separately from the texspec string */
@ -213,14 +214,19 @@ void ServerParticleTexture::serialize(std::ostream &os, u16 protocol_ver, bool n
if (!newPropertiesOnly)
os << serializeString32(string);
if (animated)
if (!skipAnimation && animated)
animation.serialize(os, protocol_ver);
}
void ServerParticleTexture::deSerialize(std::istream &is, u16 protocol_ver, bool newPropertiesOnly)
void ServerParticleTexture::deSerialize(std::istream &is, u16 protocol_ver,
bool newPropertiesOnly, bool skipAnimation)
{
FlagT flags = 0;
deSerializeParameterValue(is, flags);
// new texture properties were missing in ParticleParameters::serialize
// before Minetest 5.9.0
if (is.eof())
return;
animated = !!(flags & FlagT(ParticleTextureFlags::animated));
blendmode = BlendMode((flags & FlagT(ParticleTextureFlags::blend)) >> 1);
@ -230,7 +236,7 @@ void ServerParticleTexture::deSerialize(std::istream &is, u16 protocol_ver, bool
if (!newPropertiesOnly)
string = deSerializeString32(is);
if (animated)
if (!skipAnimation && animated)
animation.deSerialize(is, protocol_ver);
}
@ -254,6 +260,7 @@ void ParticleParameters::serialize(std::ostream &os, u16 protocol_ver) const
writeV3F32(os, drag);
jitter.serialize(os);
bounce.serialize(os);
texture.serialize(os, protocol_ver, true, true);
}
template <typename T, T (reader)(std::istream& is)>
@ -291,4 +298,5 @@ void ParticleParameters::deSerialize(std::istream &is, u16 protocol_ver)
return;
jitter.deSerialize(is);
bounce.deSerialize(is);
texture.deSerialize(is, protocol_ver, true, true);
}