]> git.lizzy.rs Git - dragonfireclient.git/blob - src/serialization.h
Initial files
[dragonfireclient.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         0: original networked test with 1-byte nodes
19         1: update with 2-byte nodes
20         2: lighting is transmitted in param
21         3: optional fetching of far blocks
22         4: block compression
23         5: sector objects NOTE: block compression was left accidentally out
24         6: failed attempt at switching block compression on again
25         7: block compression switched on again
26         8: (dev) server-initiated block transfers and all kinds of stuff
27         9: (dev) block objects
28 */
29 // This represents an uninitialized or invalid format
30 #define SER_FMT_VER_INVALID 255
31 // Highest supported serialization version
32 #define SER_FMT_VER_HIGHEST 9
33 // Lowest supported serialization version
34 #define SER_FMT_VER_LOWEST 0
35
36 #define ser_ver_supported(v) (v >= SER_FMT_VER_LOWEST && v <= SER_FMT_VER_HIGHEST)
37
38 void compress(SharedBuffer<u8> data, std::ostream &os, u8 version);
39 void decompress(std::istream &is, std::ostream &os, u8 version);
40
41 /*class Serializable
42 {
43 public:
44         void serialize(std::ostream &os, u8 version) = 0;
45         void deSerialize(std::istream &istr);
46 };*/
47
48 #endif
49