2020-05-08 22:10:49 +02:00
|
|
|
#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;
|
2020-05-08 22:10:49 +02:00
|
|
|
// 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:
|
2020-05-08 22:10:49 +02:00
|
|
|
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
|
|
|
|
2020-05-06 22:31:50 +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
|
|
|
};
|