WorldFiles region format and magic check
This commit is contained in:
+12
-4
@@ -15,12 +15,13 @@
|
||||
#include "../typedefs.h"
|
||||
#include "../settings.h"
|
||||
|
||||
const uint REGION_HEADER_SIZE = 10;
|
||||
const uint REGION_LAYER_VOXELS = 0;
|
||||
const uint REGION_LAYER_LIGHTS = 1;
|
||||
const uint REGION_SIZE_BIT = 5;
|
||||
const uint REGION_SIZE = (1 << (REGION_SIZE_BIT));
|
||||
const uint REGION_CHUNKS_COUNT = ((REGION_SIZE) * (REGION_SIZE));
|
||||
const uint REGION_FORMAT_VERSION = 1;
|
||||
const uint REGION_FORMAT_VERSION = 2;
|
||||
const uint WORLD_FORMAT_VERSION = 1;
|
||||
const uint MAX_OPEN_REGION_FILES = 16;
|
||||
|
||||
@@ -52,9 +53,16 @@ public:
|
||||
uint32_t* getSizes() const;
|
||||
};
|
||||
|
||||
struct regfile {
|
||||
files::rafile file;
|
||||
int version;
|
||||
|
||||
regfile(std::filesystem::path filename);
|
||||
};
|
||||
|
||||
typedef std::unordered_map<glm::ivec2, std::unique_ptr<WorldRegion>> regionsmap;
|
||||
class WorldFiles {
|
||||
std::unordered_map<glm::ivec3, std::unique_ptr<files::rafile>> openRegFiles;
|
||||
std::unordered_map<glm::ivec3, std::unique_ptr<regfile>> openRegFiles;
|
||||
|
||||
void writeWorldInfo(const World* world);
|
||||
std::filesystem::path getLightsFolder() const;
|
||||
@@ -98,8 +106,8 @@ class WorldFiles {
|
||||
const std::filesystem::path& folder,
|
||||
int x, int z, int layer);
|
||||
|
||||
files::rafile* getRegFile(glm::ivec3 coord,
|
||||
const std::filesystem::path& folder);
|
||||
regfile* getRegFile(glm::ivec3 coord,
|
||||
const std::filesystem::path& folder);
|
||||
public:
|
||||
static bool parseRegionFilename(const std::string& name, int& x, int& y);
|
||||
std::filesystem::path getRegionsFolder() const;
|
||||
|
||||
Reference in New Issue
Block a user