Freeciv21
Develop your civilization from humble roots to a global empire
mapimg.h
Go to the documentation of this file.
1 /***********************************************************************
2 Copyright (c) 1996-2021 Freeciv21 and Freeciv contributors. This file is
3  /\/\ part of Freeciv21. Freeciv21 is free software: you can
4  \_\ _..._ redistribute it and/or modify it under the terms of the
5  (" )(_..._) GNU General Public License as published by the Free
6  ^^ // \\ Software Foundation, either version 3 of the License,
7  or (at your option) any later version. You should have
8 received a copy of the GNU General Public License along with Freeciv21.
9  If not, see https://www.gnu.org/licenses/.
10 ***********************************************************************/
11 
12 /****************************************************************************
13  Map images:
14 
15  * Basic functions:
16 
17  mapimg_init() Initialise the map images.
18  mapimg_reset() Reset the map images.
19  mapimg_free() Free all memory needed for map images.
20  mapimg_count() Return the number of map image definitions.
21  mapimg_error() Return the last error message.
22  mapimg_help() Return a help text.
23 
24  * Advanced functions:
25 
26  mapimg_define() Define a new map image.
27  mapimg_delete() Delete a map image definition.
28  mapimg_show() Show the map image definition.
29  mapimg_id2str() Convert the map image definition to a string. Usefull
30  to save the definitions.
31  mapimg_create() ...
32  mapimg_colortest() ...
33 
34  These functions return TRUE on success and FALSE on error. In the later
35  case the error message is available with mapimg_error().
36 
37  * ...
38 
39  mapimg_isvalid() Check if the map image is valid. This is only
40  possible after the game is started or a savegame was
41  loaded. For a valid map image definition the
42  definition is returned. The struct is freed by
43  mapimg_reset() or mapimg_free().
44 
45  mapimg_get_format_list() ...
46 
47 ****************************************************************************/
48 
49 #pragma once
50 
51 #include "tile.h"
52 #define MAX_LEN_MAPDEF 256
53 
54 // map image layers
55 #define SPECENUM_NAME mapimg_layer
56 #define SPECENUM_VALUE0 MAPIMG_LAYER_AREA
57 #define SPECENUM_VALUE0NAME "a"
58 #define SPECENUM_VALUE1 MAPIMG_LAYER_BORDERS
59 #define SPECENUM_VALUE1NAME "b"
60 #define SPECENUM_VALUE2 MAPIMG_LAYER_CITIES
61 #define SPECENUM_VALUE2NAME "c"
62 #define SPECENUM_VALUE3 MAPIMG_LAYER_FOGOFWAR
63 #define SPECENUM_VALUE3NAME "f"
64 #define SPECENUM_VALUE4 MAPIMG_LAYER_KNOWLEDGE
65 #define SPECENUM_VALUE4NAME "k"
66 #define SPECENUM_VALUE5 MAPIMG_LAYER_TERRAIN
67 #define SPECENUM_VALUE5NAME "t"
68 #define SPECENUM_VALUE6 MAPIMG_LAYER_UNITS
69 #define SPECENUM_VALUE6NAME "u"
70 // used a possible dummy value
71 #define SPECENUM_COUNT MAPIMG_LAYER_COUNT
72 #define SPECENUM_COUNTNAME "-"
73 #include "specenum_gen.h"
74 /* If you change this enum, the default values for the client have to be
75  * adapted (see options.c). */
76 
77 typedef enum known_type (*mapimg_tile_known_func)(
78  const struct tile *ptile, const struct player *pplayer, bool knowledge);
79 typedef struct terrain *(*mapimg_tile_terrain_func)(
80  const struct tile *ptile, const struct player *pplayer, bool knowledge);
81 typedef struct player *(*mapimg_tile_player_func)(
82  const struct tile *ptile, const struct player *pplayer, bool knowledge);
83 
84 typedef int (*mapimg_plrcolor_count_func)();
85 typedef struct rgbcolor *(*mapimg_plrcolor_get_func)(int);
86 
87 // map definition
88 struct mapdef;
89 
97 void mapimg_reset();
98 void mapimg_free();
99 int mapimg_count();
100 char *mapimg_help(const char *cmdname);
101 const char *mapimg_error();
102 
103 bool mapimg_define(const char *maparg, bool check);
104 bool mapimg_delete(int id);
105 bool mapimg_show(int id, char *str, size_t str_len, bool detail);
106 bool mapimg_id2str(int id, char *str, size_t str_len);
107 bool mapimg_create(struct mapdef *pmapdef, bool force, const char *savename,
108  const char *path);
109 bool mapimg_colortest(const char *savename, const char *path);
110 
111 struct mapdef *mapimg_isvalid(int id);
mapimg_tile_player_func mapimg_tile_owner
Definition: mapimg.cpp:333
mapimg_tile_terrain_func mapimg_tile_terrain
Definition: mapimg.cpp:332
mapimg_tile_player_func mapimg_tile_city
Definition: mapimg.cpp:334
mapimg_tile_player_func mapimg_tile_unit
Definition: mapimg.cpp:335
mapimg_tile_known_func mapimg_tile_known
Definition: mapimg.cpp:331
mapimg_plrcolor_get_func mapimg_plrcolor_get
Definition: mapimg.cpp:337
mapimg_plrcolor_count_func mapimg_plrcolor_count
Definition: mapimg.cpp:336
int(* mapimg_plrcolor_count_func)()
Definition: mapimg.h:84
bool mapimg_id2str(int id, char *str, size_t str_len)
Return the map image definition 'id' as a mapdef string.
Definition: mapimg.cpp:1029
void mapimg_reset()
Reset the map image subsystem.
Definition: mapimg.cpp:386
struct player *(* mapimg_tile_player_func)(const struct tile *ptile, const struct player *pplayer, bool knowledge)
Definition: mapimg.h:81
bool mapimg_colortest(const char *savename, const char *path)
Create images which shows all map colors (playercolor, terrain colors).
Definition: mapimg.cpp:1156
int mapimg_count()
Return the number of map image definitions.
Definition: mapimg.cpp:420
const char * mapimg_error()
Returns the last error.
Definition: mapimg.cpp:585
struct mapdef * mapimg_isvalid(int id)
Check if a map image definition is valid.
Definition: mapimg.cpp:886
void mapimg_init(mapimg_tile_known_func mapimg_tile_known, mapimg_tile_terrain_func mapimg_tile_terrain, mapimg_tile_player_func mapimg_tile_owner, mapimg_tile_player_func mapimg_tile_city, mapimg_tile_player_func mapimg_tile_unit, mapimg_plrcolor_count_func mapimg_plrcolor_count, mapimg_plrcolor_get_func mapimg_plrcolor_get)
Initialisation of the map image subsystem.
Definition: mapimg.cpp:351
void mapimg_free()
Free all memory allocated by the map image subsystem.
Definition: mapimg.cpp:405
bool mapimg_define(const char *maparg, bool check)
Define on map image.
Definition: mapimg.cpp:590
bool mapimg_delete(int id)
Delete a map image definition.
Definition: mapimg.cpp:918
enum known_type(* mapimg_tile_known_func)(const struct tile *ptile, const struct player *pplayer, bool knowledge)
Definition: mapimg.h:77
char * mapimg_help(const char *cmdname)
Return a help string for the 'mapimg' command.
Definition: mapimg.cpp:457
bool mapimg_create(struct mapdef *pmapdef, bool force, const char *savename, const char *path)
Create the requested map image.
Definition: mapimg.cpp:1050
struct rgbcolor *(* mapimg_plrcolor_get_func)(int)
Definition: mapimg.h:85
struct terrain *(* mapimg_tile_terrain_func)(const struct tile *ptile, const struct player *pplayer, bool knowledge)
Definition: mapimg.h:79
bool mapimg_show(int id, char *str, size_t str_len, bool detail)
Show a map image definition.
Definition: mapimg.cpp:937
char maparg[MAX_LEN_MAPARG]
Definition: mapimg.cpp:229
Definition: player.h:231
Definition: tile.h:42
known_type
Definition: tile.h:28