Atrinik Client  4.0
region_map.h
Go to the documentation of this file.
1 /*************************************************************************
2  * Atrinik, a Multiplayer Online Role Playing Game *
3  * *
4  * Copyright (C) 2009-2014 Alex Tokar and Atrinik Development Team *
5  * *
6  * Fork from Crossfire (Multiplayer game for X-windows). *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the Free Software *
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
21  * *
22  * The author can be reached at admin@atrinik.org *
23  ************************************************************************/
24 
32 #ifndef REGION_MAP_H
33 #define REGION_MAP_H
34 
35 #include <toolkit/curl.h>
36 
38 #define RM_ZOOM_DEFAULT 100
39 
40 #define RM_ZOOM_MIN 50
41 
42 #define RM_ZOOM_MAX 200
43 
44 #define RM_ZOOM_PROGRESS 10
45 
49 typedef struct region_map_def_map {
51  char *path;
52 
53  char **regions;
54  size_t regions_num;
55 
57  int xpos;
58 
60  int ypos;
62 
66 typedef struct region_map_def_label {
68  int x;
69 
71  int y;
72 
74  char *name;
75 
77  char *text;
79 
83 typedef struct region_map_def_tooltip {
85  int x;
86 
88  int y;
89 
91  int w;
92 
94  int h;
95 
97  char *name;
98 
100  char *text;
101 
103  uint8_t outline;
104 
106  SDL_Color outline_color;
107 
109  uint8_t outline_size;
111 
112 /*
113  * Map region definitions.
114  */
115 typedef struct region_map_def {
118 
120  size_t num_maps;
121 
124 
126  size_t num_tooltips;
127 
130 
132  size_t num_labels;
133 
136 
139 
142 
144  int refcount;
146 
151 typedef struct region_map_fow_tile {
152  char *path;
153  int x;
154  int y;
156 
160 typedef struct region_map_fow {
162  int refcount;
163 
164  char *path;
165 
166  SDL_Surface *surface;
167 
168  uint32_t *bitmap;
169 
170  UT_array *tiles;
172 
176 typedef struct region_map {
182  SDL_Surface *surface;
183 
189  SDL_Surface *zoomed;
190 
199  SDL_Surface *fow_zoomed;
200 
207 
208  /*
209  * Fog of war.
210  *
211  * @internal
212  * @warning This structure is refcounted.
213  */
214  region_map_fow_t *fow;
215 
219  int zoom;
220 
224  SDL_Rect pos;
225 
229  curl_request_t *request_png;
230 
234  curl_request_t *request_def;
235 } region_map_t;
236 
237 #define RM_MAP_FOW_BITMAP_SIZE(region_map) \
238  (sizeof(*(region_map)->fow->bitmap) * \
239  (((region_map)->surface->w / (region_map)->def->pixel_size + 31) / 32) * \
240  ((region_map)->surface->h / (region_map)->def->pixel_size))
241 
242 /* Prototypes */
243 
245  const char *map_path);
246 void region_map_resize(region_map_t *region_map, int adjust);
248 void region_map_pan(region_map_t *region_map);
249 void region_map_render_marker(region_map_t *region_map, SDL_Surface *surface,
250  int x, int y);
251 void region_map_render_fow(region_map_t *region, SDL_Surface *surface,
252  int x, int y);
258 void region_map_update(region_map_t *region_map, const char *region_name);
259 void region_map_fow_update(region_map_t *region_map);
260 bool region_map_fow_set_visited(region_map_t *region_map,
261  region_map_def_map_t *map, const char *map_path, int x, int y);
263 bool region_map_fow_is_visited(region_map_t *region_map, int x, int y);
264 bool region_map_fow_is_visible(region_map_t *region_map, int x, int y);
265 
266 #endif
char ** regions
Regions this map belongs to.
Definition: region_map.h:53
size_t regions_num
Number of entries in 'regions'.
Definition: region_map.h:54
struct region_map_def_map region_map_def_map_t
SDL_Surface * region_map_surface(region_map_t *region_map)
Definition: region_map.c:319
size_t num_tooltips
Definition: region_map.h:126
struct region_map_def_label region_map_def_label_t
struct region_map_fow_tile region_map_fow_tile_t
SDL_Surface * zoomed
Definition: region_map.h:189
struct region_map_fow region_map_fow_t
region_map_def_map_t * maps
Definition: region_map.h:117
region_map_t * region_map_clone(region_map_t *region_map)
Definition: region_map.c:73
void region_map_resize(region_map_t *region_map, int adjust)
Definition: region_map.c:362
region_map_def_t * def
Definition: region_map.h:206
SDL_Rect pos
Definition: region_map.h:224
size_t num_labels
Definition: region_map.h:132
curl_request_t * request_def
Definition: region_map.h:234
void region_map_render_marker(region_map_t *region_map, SDL_Surface *surface, int x, int y)
Definition: region_map.c:417
SDL_Surface * region_map_fow_surface(region_map_t *region_map)
Definition: region_map.c:1025
int y
Y coordinate.
Definition: region_map.h:154
region_map_t * region_map_create(void)
Definition: region_map.c:54
int x
X coordinate.
Definition: region_map.h:153
char * path
Map path.
Definition: region_map.h:152
size_t num_maps
Definition: region_map.h:120
SDL_Surface * fow_zoomed
Definition: region_map.h:199
SDL_Surface * surface
Definition: region_map.h:182
bool region_map_ready(region_map_t *region_map)
Definition: region_map.c:200
void region_map_reset(region_map_t *region_map)
Definition: region_map.c:110
region_map_def_map_t * region_map_find_map(region_map_t *region_map, const char *map_path)
Definition: region_map.c:295
region_map_def_label_t * labels
Definition: region_map.h:129
region_map_def_tooltip_t * tooltips
Definition: region_map.h:123
struct region_map region_map_t
curl_request_t * request_png
Definition: region_map.h:229
void region_map_free(region_map_t *region_map)
Definition: region_map.c:93
struct region_map_def_tooltip region_map_def_tooltip_t