libclod
C library for interacting with NBTs, region files, LOD data and other things.
Loading...
Searching...
No Matches
chunk_location.h
1#ifndef LIBCLOD_CHUNK_LOCATION_H
2#define LIBCLOD_CHUNK_LOCATION_H
3
4#include <stdint.h>
5
6typedef struct {
7 uint32_t offset : 24;
8 uint8_t size : 8;
10
11static inline chunk_loc chunk_loc_dec(uint8_t ptr[4]) {
12 chunk_loc loc;
13 loc.offset = (uint32_t)(ptr[0] << 16 | ptr[1] << 8 | ptr[2]);
14 loc.size = ptr[3];
15 return loc;
16}
17static inline void chunk_loc_enc(uint8_t ptr[4], chunk_loc loc) {
18 ptr[0] = (uint8_t)(loc.offset >> 16);
19 ptr[1] = (uint8_t)(loc.offset >> 8);
20 ptr[2] = (uint8_t)loc.offset;
21 ptr[3] = loc.size;
22}
23
24#endif