X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Ftileanimation.cpp;h=025d27d91054b81df9745f06a7670c5466c82d82;hb=5c248c2d7de3db54e85f7c388743a2eb8e36fee4;hp=930fd94731013089bda7a8dde8c243f4c92eba77;hpb=bba4563d89b6708d75a4053c69873dff0d747538;p=minetest.git diff --git a/src/tileanimation.cpp b/src/tileanimation.cpp index 930fd9473..025d27d91 100644 --- a/src/tileanimation.cpp +++ b/src/tileanimation.cpp @@ -19,21 +19,27 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "tileanimation.h" #include "util/serialize.h" -void TileAnimationParams::serialize(std::ostream &os, u8 tiledef_version) const +void TileAnimationParams::serialize(std::ostream &os, u16 protocol_ver) const { + // The particle code overloads the length parameter so that negative numbers + // indicate an extra feature which old clients don't understand (crash). + // In hindsight it would have been better to use an extra parameter for this + // but we're stuck with this now. + const bool need_abs = protocol_ver < 40; + writeU8(os, type); if (type == TAT_VERTICAL_FRAMES) { writeU16(os, vertical_frames.aspect_w); writeU16(os, vertical_frames.aspect_h); - writeF32(os, vertical_frames.length); + writeF32(os, need_abs ? fabs(vertical_frames.length) : vertical_frames.length); } else if (type == TAT_SHEET_2D) { writeU8(os, sheet_2d.frames_w); writeU8(os, sheet_2d.frames_h); - writeF32(os, sheet_2d.frame_length); + writeF32(os, need_abs ? fabs(sheet_2d.frame_length) : sheet_2d.frame_length); } } -void TileAnimationParams::deSerialize(std::istream &is, u8 tiledef_version) +void TileAnimationParams::deSerialize(std::istream &is, u16 protocol_ver) { type = (TileAnimationType) readU8(is);