3 Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef SERIALIZATION_HEADER
21 #define SERIALIZATION_HEADER
23 #include "common_irrlicht.h"
24 #include "exceptions.h"
29 NOTE: The goal is to increment this so that saved maps will be
30 loadable by any version. Other compatibility is not
32 Serialization format versions:
34 0: original networked test with 1-byte nodes
35 1: update with 2-byte nodes
37 2: lighting is transmitted in param
38 3: optional fetching of far blocks
40 5: sector objects NOTE: block compression was left accidentally out
41 6: failed attempt at switching block compression on again
42 7: block compression switched on again
43 8: (dev) server-initiated block transfers and all kinds of stuff
44 9: (dev) block objects
45 10: (dev) water pressure
46 11: (dev) zlib'd blocks, block flags
47 12: (dev) UnlimitedHeightmap now uses interpolated areas
49 14: (dev) NodeMetadata
50 15: (dev) StaticObjects
52 // This represents an uninitialized or invalid format
53 #define SER_FMT_VER_INVALID 255
54 // Highest supported serialization version
55 #define SER_FMT_VER_HIGHEST 15
56 // Lowest supported serialization version
57 #define SER_FMT_VER_LOWEST 2
59 #define ser_ver_supported(v) (v >= SER_FMT_VER_LOWEST && v <= SER_FMT_VER_HIGHEST)
61 void compress(SharedBuffer<u8> data, std::ostream &os, u8 version);
62 void decompress(std::istream &is, std::ostream &os, u8 version);
67 void serialize(std::ostream &os, u8 version) = 0;
68 void deSerialize(std::istream &istr);