File: BlockDecoder.h

package info (click to toggle)
minetestmapper 20241111-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 300 kB
  • sloc: cpp: 2,635; python: 143; sh: 68; ansic: 30; makefile: 9
file content (28 lines) | stat: -rw-r--r-- 589 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#pragma once

#include <cstdint>
#include <unordered_map>
#include "types.h"
#include <ZstdDecompressor.h>

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;

private:
	typedef std::unordered_map<uint16_t, std::string> NameMap;
	NameMap m_nameMap;
	uint16_t m_blockAirId, m_blockIgnoreId;

	u8 m_version, m_contentWidth;
	ustring m_mapData;

	// one instance for performance
	ZstdDecompressor m_zstd_decompressor;
};