project_files/frontlib/model/map.h
author Medo <smaxein@googlemail.com>
Mon, 25 Jun 2012 00:42:07 +0200
changeset 7271 5608ac657362
parent 7230 240620f46dd7
child 7275 15f722e0b96f
permissions -rw-r--r--
frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7177
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
     1
/**
7271
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
     2
 * Data structure for defining a map. This contains the whole recipe to
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
     3
 * exactly recreate a particular map. For named maps, you also need the
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
     4
 * corresponding files.
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
     5
 *
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
     6
 * The required fields depend on the map generator, see the comments
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
     7
 * at the struct for details.
7177
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
     8
 */
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
     9
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    10
#ifndef MODEL_MAP_H_
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    11
#define MODEL_MAP_H_
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    12
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    13
#include <stdint.h>
7271
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
    14
#include <stdbool.h>
7177
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    15
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    16
#define MAPGEN_REGULAR 0
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    17
#define MAPGEN_MAZE 1
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    18
#define MAPGEN_DRAWN 2
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    19
#define MAPGEN_NAMED 3
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    20
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    21
#define TEMPLATEFILTER_ALL 0
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    22
#define TEMPLATEFILTER_SMALL 1
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    23
#define TEMPLATEFILTER_MEDIUM 2
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    24
#define TEMPLATEFILTER_LARGE 3
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    25
#define TEMPLATEFILTER_CAVERN 4
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    26
#define TEMPLATEFILTER_WACKY 5
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    27
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    28
#define MAZE_SIZE_SMALL_TUNNELS 0
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    29
#define MAZE_SIZE_MEDIUM_TUNNELS 1
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    30
#define MAZE_SIZE_LARGE_TUNNELS 2
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    31
#define MAZE_SIZE_SMALL_ISLANDS 3
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    32
#define MAZE_SIZE_MEDIUM_ISLANDS 4
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    33
#define MAZE_SIZE_LARGE_ISLANDS 5
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    34
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    35
typedef struct {
7230
240620f46dd7 Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents: 7177
diff changeset
    36
	int _referenceCount;
7177
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    37
	int mapgen;				// Always one of the MAPGEN_ constants
7271
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
    38
	char *name;				// The name of the map for MAPGEN_NAMED, otherwise one of "+rnd+", "+maze+" or "+drawn+".
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
    39
	char *seed;				// Used for all maps
7177
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    40
	char *theme;			// Used for all except MAPGEN_NAMED
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    41
	uint8_t *drawData;		// Used for MAPGEN_DRAWN
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    42
	int drawDataSize;		// Used for MAPGEN_DRAWN
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    43
	int templateFilter;		// Used for MAPGEN_REGULAR
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    44
	int mazeSize;			// Used for MAPGEN_MAZE
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    45
} flib_map;
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    46
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    47
/**
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    48
 * Create a generated map. theme should be the name of a
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    49
 * directory in "Themes" and templateFilter should be one of the
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    50
 * TEMPLATEFILTER_* constants, but this is not checked before
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    51
 * passing it to the engine.
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    52
 *
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    53
 * Use flib_map_destroy to free the returned object.
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    54
 * No NULL parameters allowed, returns NULL on failure.
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    55
 */
7271
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
    56
flib_map *flib_map_create_regular(const char *seed, const char *theme, int templateFilter);
7177
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    57
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    58
/**
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    59
 * Create a generated maze-type map. theme should be the name of a
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    60
 * directory in "Themes" and mazeSize should be one of the
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    61
 * MAZE_SIZE_* constants, but this is not checked before
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    62
 * passing it to the engine.
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    63
 *
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    64
 * Use flib_map_destroy to free the returned object.
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    65
 * No NULL parameters allowed, returns NULL on failure.
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    66
 */
7271
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
    67
flib_map *flib_map_create_maze(const char *seed, const char *theme, int mazeSize);
7177
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    68
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    69
/**
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    70
 * Create a map from the Maps-Directory. name should be the name of a
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    71
 * directory in "Maps", but this is not checked before
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    72
 * passing it to the engine. If this is a mission, the corresponding
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    73
 * script is used automatically.
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    74
 *
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    75
 * Use flib_map_destroy to free the returned object.
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    76
 * No NULL parameters allowed, returns NULL on failure.
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    77
 */
7271
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
    78
flib_map *flib_map_create_named(const char *seed, const char *name);
7177
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    79
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    80
/**
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    81
 * Create a hand-drawn map. Use flib_map_destroy to free the returned object.
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    82
 * No NULL parameters allowed, returns NULL on failure.
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    83
 */
7271
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
    84
flib_map *flib_map_create_drawn(const char *seed, const char *theme, const uint8_t *drawData, int drawDataSize);
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
    85
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
    86
/**
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
    87
 * Create a deep copy of the map. Returns NULL on failure or if NULL was passed.
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
    88
 */
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
    89
flib_map *flib_map_copy(const flib_map *map);
7177
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    90
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    91
/**
7230
240620f46dd7 Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents: 7177
diff changeset
    92
 * Increase the reference count of the object. Call this if you store a pointer to it somewhere.
240620f46dd7 Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents: 7177
diff changeset
    93
 * Returns the parameter.
7177
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    94
 */
7230
240620f46dd7 Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents: 7177
diff changeset
    95
flib_map *flib_map_retain(flib_map *map);
240620f46dd7 Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents: 7177
diff changeset
    96
240620f46dd7 Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents: 7177
diff changeset
    97
/**
240620f46dd7 Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents: 7177
diff changeset
    98
 * Decrease the reference count of the object and free it if this was the last reference.
240620f46dd7 Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents: 7177
diff changeset
    99
 */
240620f46dd7 Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents: 7177
diff changeset
   100
void flib_map_release(flib_map *map);
7177
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
   101
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
   102
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
   103
#endif