b55625a4bb075630434ba83540945dca5041b97f
[oweals/minetest.git] / src / serialization.h
1 /*
2 (c) 2010 Perttu Ahola <celeron55@gmail.com>
3 */
4
5 #ifndef SERIALIZATION_HEADER
6 #define SERIALIZATION_HEADER
7
8 #include "common_irrlicht.h"
9 #include "exceptions.h"
10 #include <iostream>
11 #include "utility.h"
12
13 /*
14         NOTE: The goal is to increment this so that saved maps will be
15               loadable by any version. Other compatibility is not
16                   maintained.
17         Serialization format versions:
18         == Unsupported ==
19         0: original networked test with 1-byte nodes
20         1: update with 2-byte nodes
21         == Supported ==
22         2: lighting is transmitted in param
23         3: optional fetching of far blocks
24         4: block compression
25         5: sector objects NOTE: block compression was left accidentally out
26         6: failed attempt at switching block compression on again
27         7: block compression switched on again
28         8: (dev) server-initiated block transfers and all kinds of stuff
29         9: (dev) block objects
30 */
31 // This represents an uninitialized or invalid format
32 #define SER_FMT_VER_INVALID 255
33 // Highest supported serialization version
34 #define SER_FMT_VER_HIGHEST 9
35 // Lowest supported serialization version
36 #define SER_FMT_VER_LOWEST 2
37
38 #define ser_ver_supported(v) (v >= SER_FMT_VER_LOWEST && v <= SER_FMT_VER_HIGHEST)
39
40 void compress(SharedBuffer<u8> data, std::ostream &os, u8 version);
41 void decompress(std::istream &is, std::ostream &os, u8 version);
42
43 /*class Serializable
44 {
45 public:
46         void serialize(std::ostream &os, u8 version) = 0;
47         void deSerialize(std::istream &istr);
48 };*/
49
50 #endif
51