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