X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fserialization.h;h=caa1a66da058b0483ccd6fb19a1175f94309e194;hb=7289d61e99625b46eb2c4d6b90a2a5de42f207e6;hp=b899971557e97743f84c665df296af90dabec5ce;hpb=497ff1ecd64c8908f988e15ca879824f2781e3fd;p=minetest.git diff --git a/src/serialization.h b/src/serialization.h index b89997155..caa1a66da 100644 --- a/src/serialization.h +++ b/src/serialization.h @@ -1,6 +1,6 @@ /* Minetest -Copyright (C) 2010 celeron55, Perttu Ahola +Copyright (C) 2013 celeron55, Perttu Ahola This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -61,22 +61,27 @@ with this program; if not, write to the Free Software Foundation, Inc., 23: new node metadata format 24: 16-bit node ids and node timers (never released as stable) 25: Improved node timer format + 26: Never written; read the same as 25 */ // This represents an uninitialized or invalid format #define SER_FMT_VER_INVALID 255 // Highest supported serialization version -#define SER_FMT_VER_HIGHEST 25 +#define SER_FMT_VER_HIGHEST_READ 26 +// Saved on disk version +#define SER_FMT_VER_HIGHEST_WRITE 25 // Lowest supported serialization version #define SER_FMT_VER_LOWEST 0 -#define ser_ver_supported(v) (v >= SER_FMT_VER_LOWEST && v <= SER_FMT_VER_HIGHEST) +inline bool ser_ver_supported(s32 v) { + return v >= SER_FMT_VER_LOWEST && v <= SER_FMT_VER_HIGHEST_READ; +} /* Misc. serialization functions */ -void compressZlib(SharedBuffer data, std::ostream &os); -void compressZlib(const std::string &data, std::ostream &os); +void compressZlib(SharedBuffer data, std::ostream &os, int level = -1); +void compressZlib(const std::string &data, std::ostream &os, int level = -1); void decompressZlib(std::istream &is, std::ostream &os); // These choose between zlib and a self-made one according to version