libclod
C library for interacting with NBTs, region files, LOD data and other things.
Loading...
Searching...
No Matches
region_impl.h
1#ifndef CLOD_REGION_IMPL_H
2#define CLOD_REGION_IMPL_H
3
4#include <clod/region.h>
5#include "platform/platform.h"
6
7#include <assert.h>
8#include <stdint.h>
9#include <string.h>
10#include <time.h>
11
13 struct clod_region_opts opts;
14
15 atomic int32_t inside;
16 mutex mtx;
17 dir d;
18
19 size_t cache_len;
20 struct file_cache *cache;
21};
22
23enum clod_region_result file_cache_destroy(struct clod_region *r);
24
25#define REGION_PUBLIC_ENTER(region) do {\
26 assert((region) != nullptr);\
27 const int32_t inside = ++(region)->inside;\
28 assert(inside > 0);\
29} while (0)
30
31#define REGION_PUBLIC_LEAVE(region) do {\
32 const int32_t inside = (region)->inside--;\
33 assert(inside > 0);\
34} while(0)
35
36static bool is_vanilla_compatible(struct clod_region_opts *opts) {
37 return
38 opts->dims == 2 &&
39 memcmp(opts->prefix, "region", strlen("region")) == 0 &&
40 (
41 memcmp(opts->region_ext, "mca", strlen("mca")) == 0 ||
42 memcmp(opts->region_ext, "mcr", strlen("mcr")) == 0
43 );
44}
45
46#endif
clod_region_result
Definition region.h:43
uint8_t dims
Definition region.h:173
char region_ext[10+1]
Definition region.h:203
char prefix[30+1]
Definition region.h:199