forked from Cubitect/cubiomes
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutil.h
58 lines (45 loc) · 1.82 KB
/
util.h
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef UTIL_H_
#define UTIL_H_
#include <stdint.h>
#ifdef __cplusplus
extern "C"
{
#endif
/* Loads a list of seeds from a file. The seeds should be written as decimal
* ASCII numbers separated by newlines.
* @fnam: file path
* @scnt: number of valid seeds found in the file, which is also the number of
* elements in the returned buffer
*
* Return a pointer to a dynamically allocated seed list.
*/
uint64_t *loadSavedSeeds(const char *fnam, uint64_t *scnt);
/// convert between version enum and text
const char* mc2str(int mc);
int str2mc(const char *s);
/// get the resource id name for a biome (for versions 1.13+)
const char *biome2str(int mc, int id);
/// initialize a biome colormap with some defaults
void initBiomeColors(unsigned char biomeColors[256][3]);
void initBiomeTypeColors(unsigned char biomeColors[256][3]);
/* Attempts to parse a biome-color mappings from a text buffer.
* The parser makes one attempt per line and is not very picky regarding a
* combination of biomeID/name with a color, represented as either a single
* number or as a triplet in decimal or as hex (preceeded by 0x or #).
* Returns the number of successfully mapped biome ids
*/
int parseBiomeColors(unsigned char biomeColors[256][3], const char *buf);
int biomesToImage(unsigned char *pixels,
unsigned char biomeColors[256][3], const int *biomes,
const unsigned int sx, const unsigned int sy,
const unsigned int pixscale, const int flip);
/* Save the pixel buffer (e.g. from biomesToImage) to the given path as an PPM
* image file. Returns 0 if successful, or -1 if the file could not be opened,
* or 1 if not all the pixel data could be written to the file.
*/
int savePPM(const char* path, const unsigned char *pixels,
const unsigned int sx, const unsigned int sy);
#ifdef __cplusplus
}
#endif
#endif