1
0
Fork 0
cuberite-2a/src/WorldStorage/MapSerializer.h

86 lines
1.1 KiB
C
Raw Normal View History

2014-02-13 15:13:09 +00:00
// MapSerializer.h
// Declares the cMapSerializer class that is used for saving maps into NBT format used by Anvil
#pragma once
// fwd:
class cFastNBTWriter;
class cParsedNBT;
class cMap;
2014-02-19 13:28:48 +00:00
/** Utility class used to serialize maps. */
2014-02-13 15:13:09 +00:00
class cMapSerializer
{
public:
cMapSerializer(const AString & a_WorldName, cMap * a_Map);
2014-02-13 15:13:09 +00:00
2014-09-26 12:31:52 +00:00
/** Try to load the map */
2014-02-13 15:13:09 +00:00
bool Load(void);
2014-09-26 12:31:52 +00:00
/** Try to save the map */
2014-02-13 15:13:09 +00:00
bool Save(void);
private:
void SaveMapToNBT(cFastNBTWriter & a_Writer);
bool LoadMapFromNBT(const cParsedNBT & a_NBT);
cMap * m_Map;
AString m_Path;
} ;
2014-02-23 13:03:40 +00:00
/** Utility class used to serialize item ID counts.
2014-07-17 21:15:53 +00:00
In order to perform bounds checking (while loading),
the last registered ID of each item is serialized to an NBT file.
*/
2014-02-13 19:36:24 +00:00
class cIDCountSerializer
{
public:
cIDCountSerializer(const AString & a_WorldName);
2014-02-17 14:27:12 +00:00
/** Try to load the ID counts */
2014-02-13 19:36:24 +00:00
bool Load(void);
2014-02-17 14:27:12 +00:00
/** Try to save the ID counts */
2014-02-13 19:36:24 +00:00
bool Save(void);
inline unsigned int GetMapCount(void) const { return m_MapCount; }
inline void SetMapCount(unsigned int a_MapCount) { m_MapCount = a_MapCount; }
private:
AString m_Path;
unsigned int m_MapCount;
2014-02-17 14:27:12 +00:00
2014-02-13 19:36:24 +00:00
};