aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2022-01-12 18:49:14 +0100
committerGitHub <noreply@github.com>2022-01-12 18:49:14 +0100
commitb2eb44afc50976dc0954c868977b5829f3ff8a19 (patch)
tree0d584ea84b0c570a24fea585897921122c1dc9da
parent4c8c6497799c83cb5bac773ac4eac7ea572ec78f (diff)
downloadminetest-b2eb44afc50976dc0954c868977b5829f3ff8a19.tar.gz
minetest-b2eb44afc50976dc0954c868977b5829f3ff8a19.tar.bz2
minetest-b2eb44afc50976dc0954c868977b5829f3ff8a19.zip
Fix NodeDef backwards compatibility to 5.3.0 (#11942)
1. Fixes crashes on older clients when [png is used as base image 2. Fixes liquid type assertion fails on debug builds
-rw-r--r--src/nodedef.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/nodedef.cpp b/src/nodedef.cpp
index 6f52b608b..8a5542837 100644
--- a/src/nodedef.cpp
+++ b/src/nodedef.cpp
@@ -207,7 +207,17 @@ void TileDef::serialize(std::ostream &os, u16 protocol_version) const
u8 version = 6;
writeU8(os, version);
- os << serializeString16(name);
+ if (protocol_version > 39) {
+ os << serializeString16(name);
+ } else {
+ // Before f018737, TextureSource::getTextureAverageColor did not handle
+ // missing textures. "[png" can be used as base texture, but is not known
+ // on older clients. Hence use "blank.png" to avoid this problem.
+ if (!name.empty() && name[0] == '[')
+ os << serializeString16("blank.png^" + name);
+ else
+ os << serializeString16(name);
+ }
animation.serialize(os, version);
bool has_scale = scale > 0;
u16 flags = 0;
@@ -491,7 +501,16 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version) const
writeU32(os, damage_per_second);
// liquid
- writeU8(os, liquid_type);
+ LiquidType liquid_type_bc = liquid_type;
+ if (protocol_version <= 39) {
+ // Since commit 7f25823, liquid drawtypes can be used even with LIQUID_NONE
+ // solution: force liquid type accordingly to accepted values
+ if (drawtype == NDT_LIQUID)
+ liquid_type_bc = LIQUID_SOURCE;
+ else if (drawtype == NDT_FLOWINGLIQUID)
+ liquid_type_bc = LIQUID_FLOWING;
+ }
+ writeU8(os, liquid_type_bc);
os << serializeString16(liquid_alternative_flowing);
os << serializeString16(liquid_alternative_source);
writeU8(os, liquid_viscosity);