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