mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-04-18 18:45:09 +02:00
Newtypes are cumbersome in C++, so this is mostly documentation for now. Also replace lots of questionable uses of size_t with int or types with explicit width and add a few comments for constants.
42 lines
840 B
C++
42 lines
840 B
C++
// SPDX-License-Identifier: BSD-2-Clause
|
|
/*
|
|
Copyright (c) 2015-2021, Matthias Schiffer <mschiffer@universe-factory.net>
|
|
All rights reserved.
|
|
*/
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "Chunk.hpp"
|
|
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <stdexcept>
|
|
#include <tuple>
|
|
#include <unordered_map>
|
|
|
|
|
|
namespace MinedMap {
|
|
namespace World {
|
|
|
|
class Region {
|
|
public:
|
|
// Number of chunks in a region in each dimension
|
|
static const uint32_t SIZE = 32;
|
|
|
|
typedef std::function<void (chunk_idx_t, chunk_idx_t, const ChunkData *)> ChunkVisitor;
|
|
|
|
Region() = delete;
|
|
|
|
private:
|
|
typedef std::tuple<chunk_idx_t, chunk_idx_t, uint8_t> ChunkDesc;
|
|
typedef std::unordered_map<uint32_t, ChunkDesc> ChunkMap;
|
|
|
|
static ChunkMap processHeader(const uint8_t header[4096]);
|
|
|
|
public:
|
|
static void visitChunks(const char *filename, const ChunkVisitor &visitor);
|
|
};
|
|
|
|
}
|
|
}
|