project_files/frontlib/model/map.h
author Medo <smaxein@googlemail.com>
Thu, 05 Jul 2012 00:33:24 +0200
changeset 7316 f7b49b2c5d84
parent 7314 6171f0bad318
child 7482 d70a5b0d1190
permissions -rw-r--r--
frontlib: Improved and unified parameter checking, moved the cmdlineClient out of the frontlib code.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7314
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
     1
/*
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
     2
 * Hedgewars, a free turn based strategy game
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
     3
 * Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
     4
 *
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
     5
 * This program is free software; you can redistribute it and/or
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
     6
 * modify it under the terms of the GNU General Public License
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
     7
 * as published by the Free Software Foundation; either version 2
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
     8
 * of the License, or (at your option) any later version.
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
     9
 *
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
    13
 * GNU General Public License for more details.
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
    14
 *
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
    15
 * You should have received a copy of the GNU General Public License
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
    16
 * along with this program; if not, write to the Free Software
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
    17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
    18
 */
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
    19
7177
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    20
#ifndef MODEL_MAP_H_
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    21
#define MODEL_MAP_H_
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    22
7316
f7b49b2c5d84 frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents: 7314
diff changeset
    23
#include <stddef.h>
7177
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    24
#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
    25
#include <stdbool.h>
7177
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    26
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    27
#define MAPGEN_REGULAR 0
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    28
#define MAPGEN_MAZE 1
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    29
#define MAPGEN_DRAWN 2
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    30
#define MAPGEN_NAMED 3
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    31
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    32
#define TEMPLATEFILTER_ALL 0
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    33
#define TEMPLATEFILTER_SMALL 1
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    34
#define TEMPLATEFILTER_MEDIUM 2
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    35
#define TEMPLATEFILTER_LARGE 3
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    36
#define TEMPLATEFILTER_CAVERN 4
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    37
#define TEMPLATEFILTER_WACKY 5
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    38
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    39
#define MAZE_SIZE_SMALL_TUNNELS 0
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    40
#define MAZE_SIZE_MEDIUM_TUNNELS 1
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    41
#define MAZE_SIZE_LARGE_TUNNELS 2
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    42
#define MAZE_SIZE_SMALL_ISLANDS 3
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    43
#define MAZE_SIZE_MEDIUM_ISLANDS 4
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    44
#define MAZE_SIZE_LARGE_ISLANDS 5
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    45
7275
15f722e0b96f frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents: 7271
diff changeset
    46
/**
15f722e0b96f frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents: 7271
diff changeset
    47
 * Data structure for defining a map. This contains the whole recipe to
15f722e0b96f frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents: 7271
diff changeset
    48
 * exactly recreate a particular map. For named maps, you also need the
15f722e0b96f frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents: 7271
diff changeset
    49
 * corresponding files.
15f722e0b96f frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents: 7271
diff changeset
    50
 *
15f722e0b96f frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents: 7271
diff changeset
    51
 * The required fields depend on the map generator, see the comments
15f722e0b96f frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents: 7271
diff changeset
    52
 * at the struct for details.
15f722e0b96f frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents: 7271
diff changeset
    53
 */
7177
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    54
typedef struct {
7230
240620f46dd7 Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents: 7177
diff changeset
    55
	int _referenceCount;
7177
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    56
	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
    57
	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
    58
	char *seed;				// Used for all maps
7275
15f722e0b96f frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents: 7271
diff changeset
    59
	char *theme;			// Used for all maps
7177
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    60
	uint8_t *drawData;		// Used for MAPGEN_DRAWN
7316
f7b49b2c5d84 frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents: 7314
diff changeset
    61
	int drawDataSize;		// Used for MAPGEN_DRAWN TODO size_t
7177
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    62
	int templateFilter;		// Used for MAPGEN_REGULAR
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    63
	int mazeSize;			// Used for MAPGEN_MAZE
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    64
} flib_map;
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    65
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    66
/**
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    67
 * 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
    68
 * 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
    69
 * 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
    70
 * passing it to the engine.
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    71
 *
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    72
 * 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
    73
 * 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
    74
 */
7271
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
    75
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
    76
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    77
/**
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    78
 * 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
    79
 * 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
    80
 * 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
    81
 * passing it to the engine.
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    82
 *
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    83
 * 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
    84
 * 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
    85
 */
7271
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
    86
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
    87
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    88
/**
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    89
 * 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
    90
 * 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
    91
 * 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
    92
 * script is used automatically.
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    93
 *
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    94
 * 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
    95
 * 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
    96
 */
7271
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
    97
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
    98
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
    99
/**
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
   100
 * 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
   101
 * 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
   102
 */
7316
f7b49b2c5d84 frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents: 7314
diff changeset
   103
flib_map *flib_map_create_drawn(const char *seed, const char *theme, const uint8_t *drawData, size_t drawDataSize);
7271
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
   104
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
   105
/**
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
   106
 * 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
   107
 */
5608ac657362 frontlib: Intermittent commit. Things are still in flux but we're getting there :)
Medo <smaxein@googlemail.com>
parents: 7230
diff changeset
   108
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
   109
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
   110
/**
7230
240620f46dd7 Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents: 7177
diff changeset
   111
 * 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
   112
 * Returns the parameter.
7177
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
   113
 */
7230
240620f46dd7 Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents: 7177
diff changeset
   114
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
   115
240620f46dd7 Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents: 7177
diff changeset
   116
/**
240620f46dd7 Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents: 7177
diff changeset
   117
 * 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
   118
 */
240620f46dd7 Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents: 7177
diff changeset
   119
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
   120
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
   121
bf6cf4dd847a Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff changeset
   122
#endif