]> git.lizzy.rs Git - minetest.git/blob - src/serialization.h
c87162e69ea6e5def223c3f9f055c859f5c3b6a3
[minetest.git] / src / serialization.h
1 /*
2 Minetest-c55
3 Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
4
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.
9
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.
14
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.
18 */
19
20 #ifndef SERIALIZATION_HEADER
21 #define SERIALIZATION_HEADER
22
23 #include "common_irrlicht.h"
24 #include "exceptions.h"
25 #include <iostream>
26 #include "utility.h"
27
28 /*
29         NOTE: The goal is to increment this so that saved maps will be
30               loadable by any version. Other compatibility is not
31                   maintained.
32         Serialization format versions (for raw map data (blocks, nodes, sectors)):
33         == Unsupported ==
34         0: original networked test with 1-byte nodes
35         1: update with 2-byte nodes
36         == Supported ==
37         2: lighting is transmitted in param
38         3: optional fetching of far blocks
39         4: block compression
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
48         13: (dev) Mapgen v2
49         14: (dev) NodeMetadata
50         15: (dev) StaticObjects
51 */
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 0
58
59 #define ser_ver_supported(v) (v >= SER_FMT_VER_LOWEST && v <= SER_FMT_VER_HIGHEST)
60
61 void compress(SharedBuffer<u8> data, std::ostream &os, u8 version);
62 void decompress(std::istream &is, std::ostream &os, u8 version);
63
64 /*class Serializable
65 {
66 public:
67         void serialize(std::ostream &os, u8 version) = 0;
68         void deSerialize(std::istream &istr);
69 };*/
70
71 #endif
72