|
1 /** |
|
2 * Data structure for defining a map. Note that most maps also depend on the |
|
3 * random seed passed to the engine, if you store that in addition to the |
|
4 * flib_map structure you have the whole recipe to exactly recreate a particular |
|
5 * map. For named maps, you also need the corresponding files. |
|
6 */ |
|
7 |
|
8 #ifndef MODEL_MAP_H_ |
|
9 #define MODEL_MAP_H_ |
|
10 |
|
11 #include <stdint.h> |
|
12 |
|
13 #define MAPGEN_REGULAR 0 |
|
14 #define MAPGEN_MAZE 1 |
|
15 #define MAPGEN_DRAWN 2 |
|
16 #define MAPGEN_NAMED 3 |
|
17 |
|
18 #define TEMPLATEFILTER_ALL 0 |
|
19 #define TEMPLATEFILTER_SMALL 1 |
|
20 #define TEMPLATEFILTER_MEDIUM 2 |
|
21 #define TEMPLATEFILTER_LARGE 3 |
|
22 #define TEMPLATEFILTER_CAVERN 4 |
|
23 #define TEMPLATEFILTER_WACKY 5 |
|
24 |
|
25 #define MAZE_SIZE_SMALL_TUNNELS 0 |
|
26 #define MAZE_SIZE_MEDIUM_TUNNELS 1 |
|
27 #define MAZE_SIZE_LARGE_TUNNELS 2 |
|
28 #define MAZE_SIZE_SMALL_ISLANDS 3 |
|
29 #define MAZE_SIZE_MEDIUM_ISLANDS 4 |
|
30 #define MAZE_SIZE_LARGE_ISLANDS 5 |
|
31 |
|
32 typedef struct { |
|
33 int mapgen; // Always one of the MAPGEN_ constants |
|
34 char *theme; // Used for all except MAPGEN_NAMED |
|
35 char *name; // Used for MAPGEN_NAMED |
|
36 uint8_t *drawData; // Used for MAPGEN_DRAWN |
|
37 int drawDataSize; // Used for MAPGEN_DRAWN |
|
38 int templateFilter; // Used for MAPGEN_REGULAR |
|
39 int mazeSize; // Used for MAPGEN_MAZE |
|
40 } flib_map; |
|
41 |
|
42 /** |
|
43 * Create a generated map. theme should be the name of a |
|
44 * directory in "Themes" and templateFilter should be one of the |
|
45 * TEMPLATEFILTER_* constants, but this is not checked before |
|
46 * passing it to the engine. |
|
47 * |
|
48 * Use flib_map_destroy to free the returned object. |
|
49 * No NULL parameters allowed, returns NULL on failure. |
|
50 */ |
|
51 flib_map *flib_map_create_regular(const char *theme, int templateFilter); |
|
52 |
|
53 /** |
|
54 * Create a generated maze-type map. theme should be the name of a |
|
55 * directory in "Themes" and mazeSize should be one of the |
|
56 * MAZE_SIZE_* constants, but this is not checked before |
|
57 * passing it to the engine. |
|
58 * |
|
59 * Use flib_map_destroy to free the returned object. |
|
60 * No NULL parameters allowed, returns NULL on failure. |
|
61 */ |
|
62 flib_map *flib_map_create_maze(const char *theme, int mazeSize); |
|
63 |
|
64 /** |
|
65 * Create a map from the Maps-Directory. name should be the name of a |
|
66 * directory in "Maps", but this is not checked before |
|
67 * passing it to the engine. If this is a mission, the corresponding |
|
68 * script is used automatically. |
|
69 * |
|
70 * Use flib_map_destroy to free the returned object. |
|
71 * No NULL parameters allowed, returns NULL on failure. |
|
72 */ |
|
73 flib_map *flib_map_create_named(const char *name); |
|
74 |
|
75 /** |
|
76 * Create a hand-drawn map. Use flib_map_destroy to free the returned object. |
|
77 * No NULL parameters allowed, returns NULL on failure. |
|
78 */ |
|
79 flib_map *flib_map_create_drawn(const char *theme, const uint8_t *drawData, int drawDataSize); |
|
80 |
|
81 /** |
|
82 * Free the memory taken up by the map. Passing NULL is allowed and does nothing. |
|
83 */ |
|
84 void flib_map_destroy(flib_map *map); |
|
85 |
|
86 |
|
87 #endif |