-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
worldloader.h
54 lines (41 loc) · 1.42 KB
/
worldloader.h
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef WORLDLOADER_H_
#define WORLDLOADER_H_
#include "./chunk.h"
#include "./helper.h"
#include <filesystem>
#include <map.hpp>
#include <nbt/nbt.hpp>
namespace Terrain {
struct Data {
using Chunk = mcmap::Chunk;
using ChunkCoordinates = mcmap::Chunk::coordinates;
using ChunkStore = std::map<ChunkCoordinates, Chunk>;
// The coordinates of the loaded chunks. This coordinates maps
// the CHUNKS loaded, not the blocks
World::Coordinates map;
// The loaded chunks, organized as a map of coordinatesxchunk
ChunkStore chunks;
fs::path regionDir;
const Colors::Palette &palette;
// Default constructor
explicit Data(const World::Coordinates &coords,
const std::filesystem::path &dir, const Colors::Palette &p)
: regionDir(dir), palette(p) {
map.minX = CHUNK(coords.minX);
map.minZ = CHUNK(coords.minZ);
map.maxX = CHUNK(coords.maxX);
map.maxZ = CHUNK(coords.maxZ);
}
// Chunk pre-processing methods
void stripChunk(std::vector<nbt::NBT> *);
void inflateChunk(std::vector<nbt::NBT> *);
// Chunk loading - should never be used, called by chunkAt in case of chunk
// fault
void loadChunk(const ChunkCoordinates);
// Access a chunk from the save file
const Chunk &chunkAt(const ChunkCoordinates, const Map::Orientation, bool);
// Mark a chunk as done and ready for deletion
void free_chunk(const ChunkCoordinates);
};
} // namespace Terrain
#endif // WORLDLOADER_H_