File: cave_parse.h

package info (click to toggle)
libstb 0.0~git20180212.15.e6afb9c-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,440 kB
  • sloc: ansic: 65,656; cpp: 1,020; makefile: 54
file content (41 lines) | stat: -rw-r--r-- 973 bytes parent folder | download | duplicates (5)
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
#ifndef INCLUDE_CAVE_PARSE_H
#define INCLUDE_CAVE_PARSE_H

typedef struct
{
   unsigned char block;
   unsigned char data;
   unsigned char light:4;
   unsigned char skylight:4;
} raw_block;

// this is the old fully-decoded chunk
typedef struct
{
   int xpos, zpos, max_y;
   int height[16][16];
   raw_block rb[16][16][256]; // [z][x][y] which becomes [y][x][z] in stb
} chunk;

chunk *get_decoded_chunk(int chunk_x, int chunk_z);

#define NUM_SEGMENTS  16
typedef struct
{
   int max_y, xpos, zpos;

   unsigned char *blockdata[NUM_SEGMENTS];
   unsigned char *data[NUM_SEGMENTS];
   unsigned char *skylight[NUM_SEGMENTS];
   unsigned char *light[NUM_SEGMENTS];
   
   void *pointer_to_free;   

   int refcount; // this allows multi-threaded building without wrapping in ANOTHER struct
} fast_chunk;

fast_chunk *get_decoded_fastchunk(int chunk_x, int chunk_z); // cache, never call free()

fast_chunk *get_decoded_fastchunk_uncached(int chunk_x, int chunk_z);

#endif