minetestmapper/include/BlockDecoder.h

29 lines
589 B
C
Raw Normal View History

#pragma once
2018-03-25 15:19:48 +02:00
2021-09-01 23:55:32 +02:00
#include <cstdint>
2018-03-25 15:19:48 +02:00
#include <unordered_map>
#include "types.h"
2021-09-01 23:55:32 +02:00
#include <ZstdDecompressor.h>
2018-03-25 15:19:48 +02:00
class BlockDecoder {
public:
BlockDecoder();
void reset();
void decode(const ustring &data);
bool isEmpty() const;
// returns "" for air, ignore and invalid nodes
const std::string &getNode(u8 x, u8 y, u8 z) const;
2018-03-25 15:19:48 +02:00
private:
typedef std::unordered_map<uint16_t, std::string> NameMap;
2018-03-25 15:19:48 +02:00
NameMap m_nameMap;
2021-09-01 23:55:32 +02:00
uint16_t m_blockAirId, m_blockIgnoreId;
2018-03-25 15:19:48 +02:00
u8 m_version, m_contentWidth;
2018-03-25 15:19:48 +02:00
ustring m_mapData;
2021-09-01 23:55:32 +02:00
// one instance for performance
ZstdDecompressor m_zstd_decompressor;
2018-03-25 15:19:48 +02:00
};