10015
|
1 |
/*
|
|
2 |
* Hedgewars, a free turn based strategy game
|
|
3 |
* Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
|
|
4 |
*
|
|
5 |
* This program is free software; you can redistribute it and/or
|
|
6 |
* modify it under the terms of the GNU General Public License
|
|
7 |
* as published by the Free Software Foundation; either version 2
|
|
8 |
* of the License, or (at your option) any later version.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
18 |
*/
|
|
19 |
|
|
20 |
#ifndef MODEL_MAP_H_
|
|
21 |
#define MODEL_MAP_H_
|
|
22 |
|
|
23 |
#include <stddef.h>
|
|
24 |
#include <stdint.h>
|
|
25 |
#include <stdbool.h>
|
|
26 |
|
|
27 |
#define MAPGEN_REGULAR 0
|
|
28 |
#define MAPGEN_MAZE 1
|
|
29 |
#define MAPGEN_DRAWN 2
|
|
30 |
#define MAPGEN_NAMED 3
|
|
31 |
|
|
32 |
#define TEMPLATEFILTER_ALL 0
|
|
33 |
#define TEMPLATEFILTER_SMALL 1
|
|
34 |
#define TEMPLATEFILTER_MEDIUM 2
|
|
35 |
#define TEMPLATEFILTER_LARGE 3
|
|
36 |
#define TEMPLATEFILTER_CAVERN 4
|
|
37 |
#define TEMPLATEFILTER_WACKY 5
|
|
38 |
|
|
39 |
#define MAZE_SIZE_SMALL_TUNNELS 0
|
|
40 |
#define MAZE_SIZE_MEDIUM_TUNNELS 1
|
|
41 |
#define MAZE_SIZE_LARGE_TUNNELS 2
|
|
42 |
#define MAZE_SIZE_SMALL_ISLANDS 3
|
|
43 |
#define MAZE_SIZE_MEDIUM_ISLANDS 4
|
|
44 |
#define MAZE_SIZE_LARGE_ISLANDS 5
|
|
45 |
|
|
46 |
/**
|
|
47 |
* Data structure for defining a map. This contains the whole recipe to
|
|
48 |
* exactly recreate a particular map.
|
|
49 |
*
|
|
50 |
* The required fields depend on the map generator, see the comments
|
|
51 |
* at the struct for details.
|
|
52 |
*/
|
|
53 |
typedef struct {
|
|
54 |
int mapgen; //!< Always one of the MAPGEN_ constants
|
|
55 |
char *name; //!< The name of the map for MAPGEN_NAMED (e.g. "Cogs"), otherwise one of "+rnd+", "+maze+" or "+drawn+".
|
|
56 |
char *seed; //!< Used for all maps. This is a random seed for all (non-AI) entropy in the round. Typically a random UUID, but can be any string.
|
|
57 |
char *theme; //!< Used for all maps. This is the name of a directory in Data/Themes (e.g. "Beach")
|
|
58 |
uint8_t *drawData; //!< Used for MAPGEN_DRAWN
|
|
59 |
size_t drawDataSize; //!< Used for MAPGEN_DRAWN
|
|
60 |
int templateFilter; //!< Used for MAPGEN_REGULAR. One of the TEMPLATEFILTER_xxx constants.
|
|
61 |
int mazeSize; //!< Used for MAPGEN_MAZE. One of the MAZE_SIZE_xxx constants.
|
|
62 |
} flib_map;
|
|
63 |
|
|
64 |
/**
|
|
65 |
* Create a generated map. theme should be the name of a
|
|
66 |
* directory in "Themes" and templateFilter should be one of the
|
|
67 |
* TEMPLATEFILTER_* constants, but this is not checked before
|
|
68 |
* passing it to the engine.
|
|
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_regular(const char *seed, const char *theme, int templateFilter);
|
|
74 |
|
|
75 |
/**
|
|
76 |
* Create a generated maze-type map. theme should be the name of a
|
|
77 |
* directory in "Themes" and mazeSize should be one of the
|
|
78 |
* MAZE_SIZE_* constants, but this is not checked before
|
|
79 |
* passing it to the engine.
|
|
80 |
*
|
|
81 |
* Use flib_map_destroy to free the returned object.
|
|
82 |
* No NULL parameters allowed, returns NULL on failure.
|
|
83 |
*/
|
|
84 |
flib_map *flib_map_create_maze(const char *seed, const char *theme, int mazeSize);
|
|
85 |
|
|
86 |
/**
|
|
87 |
* Create a map from the Maps-Directory. name should be the name of a
|
|
88 |
* directory in "Maps", but this is not checked before
|
|
89 |
* passing it to the engine. If this is a mission, the corresponding
|
|
90 |
* script is used automatically.
|
|
91 |
*
|
|
92 |
* Use flib_map_destroy to free the returned object.
|
|
93 |
* No NULL parameters allowed, returns NULL on failure.
|
|
94 |
*/
|
|
95 |
flib_map *flib_map_create_named(const char *seed, const char *name);
|
|
96 |
|
|
97 |
/**
|
|
98 |
* Create a hand-drawn map. Use flib_map_destroy to free the returned object.
|
|
99 |
* No NULL parameters allowed, returns NULL on failure.
|
|
100 |
*/
|
|
101 |
flib_map *flib_map_create_drawn(const char *seed, const char *theme, const uint8_t *drawData, size_t drawDataSize);
|
|
102 |
|
|
103 |
/**
|
|
104 |
* Create a deep copy of the map. Returns NULL on failure or if NULL was passed.
|
|
105 |
*/
|
|
106 |
flib_map *flib_map_copy(const flib_map *map);
|
|
107 |
|
|
108 |
/**
|
|
109 |
* Decrease the reference count of the object and free it if this was the last reference.
|
|
110 |
*/
|
|
111 |
void flib_map_destroy(flib_map *map);
|
|
112 |
|
|
113 |
|
|
114 |
#endif
|