LCOV - code coverage report
Current view: top level - src - serialization.h (source / functions) Hit Total Coverage
Test: report Lines: 2 2 100.0 %
Date: 2015-07-11 18:23:49 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             : Minetest
       3             : Copyright (C) 2013 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 Lesser General Public License as published by
       7             : the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
      14             : 
      15             : You should have received a copy of the GNU Lesser 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 "irrlichttypes.h"
      24             : #include "exceptions.h"
      25             : #include <iostream>
      26             : #include "util/pointer.h"
      27             : 
      28             : /*
      29             :         Map format serialization version
      30             :         --------------------------------
      31             : 
      32             :         For map data (blocks, nodes, sectors).
      33             :         
      34             :         NOTE: The goal is to increment this so that saved maps will be
      35             :               loadable by any version. Other compatibility is not
      36             :                   maintained.
      37             :                   
      38             :         0: original networked test with 1-byte nodes
      39             :         1: update with 2-byte nodes
      40             :         2: lighting is transmitted in param
      41             :         3: optional fetching of far blocks
      42             :         4: block compression
      43             :         5: sector objects NOTE: block compression was left accidentally out
      44             :         6: failed attempt at switching block compression on again
      45             :         7: block compression switched on again
      46             :         8: server-initiated block transfers and all kinds of stuff
      47             :         9: block objects
      48             :         10: water pressure
      49             :         11: zlib'd blocks, block flags
      50             :         12: UnlimitedHeightmap now uses interpolated areas
      51             :         13: Mapgen v2
      52             :         14: NodeMetadata
      53             :         15: StaticObjects
      54             :         16: larger maximum size of node metadata, and compression
      55             :         17: MapBlocks contain timestamp
      56             :         18: new generator (not really necessary, but it's there)
      57             :         19: new content type handling
      58             :         20: many existing content types translated to extended ones
      59             :         21: dynamic content type allocation
      60             :         22: minerals removed, facedir & wallmounted changed
      61             :         23: new node metadata format
      62             :         24: 16-bit node ids and node timers (never released as stable)
      63             :         25: Improved node timer format
      64             :         26: Never written; read the same as 25
      65             : */
      66             : // This represents an uninitialized or invalid format
      67             : #define SER_FMT_VER_INVALID 255
      68             : // Highest supported serialization version
      69             : #define SER_FMT_VER_HIGHEST_READ 26
      70             : // Saved on disk version
      71             : #define SER_FMT_VER_HIGHEST_WRITE 25
      72             : // Lowest supported serialization version
      73             : #define SER_FMT_VER_LOWEST 0
      74             : // Lowest client supported serialization version
      75             : // Can't do < 24 anymore; we have 16-bit dynamically allocated node IDs
      76             : // in memory; conversion just won't work in this direction.
      77             : #define SER_FMT_CLIENT_VER_LOWEST 24
      78             : 
      79        1720 : inline bool ser_ver_supported(s32 v) {
      80        1720 :         return v >= SER_FMT_VER_LOWEST && v <= SER_FMT_VER_HIGHEST_READ;
      81             : }
      82             : 
      83             : /*
      84             :         Misc. serialization functions
      85             : */
      86             : 
      87             : void compressZlib(SharedBuffer<u8> data, std::ostream &os, int level = -1);
      88             : void compressZlib(const std::string &data, std::ostream &os, int level = -1);
      89             : void decompressZlib(std::istream &is, std::ostream &os);
      90             : 
      91             : // These choose between zlib and a self-made one according to version
      92             : void compress(SharedBuffer<u8> data, std::ostream &os, u8 version);
      93             : //void compress(const std::string &data, std::ostream &os, u8 version);
      94             : void decompress(std::istream &is, std::ostream &os, u8 version);
      95             : 
      96             : #endif
      97             : 

Generated by: LCOV version 1.11