Crossfire Client, Trunk  R20507
mapdata.h
Go to the documentation of this file.
1 #ifndef MAP_H
2 #define MAP_H
3 
6 #define MAXLAYERS 10
7 
11 #define MAX_VIEW 64
12 
13 /* Map1 only used 3 layers. Trying to use 10 seems to cause
14  * problems for that code.
15  */
16 #define MAP1_LAYERS 3
17 
18 struct MapCellLayer {
19  gint16 face;
20  gint8 size_x;
21  gint8 size_y;
22 
23  /* Link into animation information.
24  * animation is provided to us from the server in the map2 command.
25  * animation_speed is also provided.
26  * animation_left is how many ticks until animation changes - generated
27  * by client.
28  * animation_phase is current phase.
29  */
30  gint16 animation;
34 };
35 
49 struct MapCell
50 {
51  struct MapCellLayer heads[MAXLAYERS];
52  struct MapCellLayer tails[MAXLAYERS];
53  guint16 smooth[MAXLAYERS];
54  guint8 darkness; /* darkness: 0=fully illuminated, 255=pitch black */
55  guint8 need_update:1; /* set if tile should be redrawn */
56  guint8 have_darkness:1; /* set if darkness information was set */
57  guint8 need_resmooth:1; /* same has need update but for smoothing only */
58  guint8 cleared:1; /* If set, this is a fog cell. */
59 };
60 
61 struct Map
62 {
63  /* Store size of map so we know if map_size has changed
64  * since the last time we allocated this;
65  */
66  int x;
67  int y;
68 
69  struct MapCell **cells;
70 };
71 
72 struct MapCell *mapdata_cell(int x, int y);
73 bool mapdata_contains(int x, int y);
74 void mapdata_size(int *x, int *y);
75 bool mapdata_can_smooth(int x, int y, int layer);
76 
81 void mapdata_init(void);
82 
87 void mapdata_set_size(int viewx, int viewy);
88 
93 void mapdata_scroll(int dx, int dy);
94 
99 void mapdata_newmap(void);
100 
105 int mapdata_is_inside(int x, int y);
106 
111 gint16 mapdata_face(int x, int y, int layer) __attribute__((deprecated));
112 
125 gint16 mapdata_face_info(int mx, int my, int layer, int *dx, int *dy);
126 
139 gint16 mapdata_bigface(int x, int y, int layer, int *ww, int *hh);
140 
141 void mapdata_clear_space(int x, int y);
142 void mapdata_set_check_space(int x, int y);
143 void mapdata_set_darkness(int x, int y, int darkness);
144 void mapdata_set_smooth(int x, int y, int smooth, int layer);
145 void mapdata_clear_old(int x, int y);
146 void mapdata_set_face_layer(int x, int y, gint16 face, int layer);
147 void mapdata_set_anim_layer(int x, int y, guint16 anim, guint8 anim_speed, int layer);
148 gint16 mapdata_bigface_head(int x, int y, int layer, int *ww, int *hh);
149 void mapdata_animation(void);
150 
151 #endif
gint16 mapdata_face_info(int mx, int my, int layer, int *dx, int *dy)
Return the face number of the pixmap in the given map cell and set the offset pointers to indicate wh...
Definition: mapdata.c:1021
The heads[] in the mapcell is used for single part objects or the head piece for multipart.
Definition: mapdata.h:49
struct MapCell * mapdata_cell(int x, int y)
Get the stored map cell at the given map coordinate.
Definition: mapdata.c:119
int y
Definition: mapdata.h:67
guint8 have_darkness
Definition: mapdata.h:56
void mapdata_set_check_space(int x, int y)
Definition: mapdata.c:675
gint16 mapdata_bigface(int x, int y, int layer, int *ww, int *hh)
Returns the face to display at a given location.
Definition: mapdata.c:1047
guint16 smooth[MAXLAYERS]
Definition: mapdata.h:53
void mapdata_newmap(void)
Clears the map view.
Definition: mapdata.c:975
gint16 animation
Definition: mapdata.h:30
gint8 size_x
Definition: mapdata.h:20
void mapdata_scroll(int dx, int dy)
Scrolls the map view.
Definition: mapdata.c:902
guint8 cleared
Definition: mapdata.h:58
Definition: mapdata.h:61
gint8 size_y
Definition: mapdata.h:21
void mapdata_init(void)
Initializes the module.
Definition: mapdata.c:556
struct MapCell ** cells
Definition: mapdata.h:69
guint8 need_resmooth
Definition: mapdata.h:57
void mapdata_clear_old(int x, int y)
Definition: mapdata.c:787
int x
Definition: mapdata.h:66
void mapdata_set_size(int viewx, int viewy)
Sets the current display size.
Definition: mapdata.c:614
gint16 mapdata_face(int x, int y, int layer) __attribute__((deprecated))
Returns the face to display at a given location.
Definition: mapdata.c:1013
void mapdata_set_darkness(int x, int y, int darkness)
Definition: mapdata.c:730
bool mapdata_contains(int x, int y)
Determine whether the map data contains the given cell.
Definition: mapdata.c:126
guint8 animation_speed
Definition: mapdata.h:31
#define MAXLAYERS
The protocol supports 10 layers, so set MAXLAYERS accordingly.
Definition: mapdata.h:6
guint8 need_update
Definition: mapdata.h:55
void mapdata_animation(void)
Definition: mapdata.c:1334
void mapdata_clear_space(int x, int y)
Definition: mapdata.c:633
void mapdata_set_anim_layer(int x, int y, guint16 anim, guint8 anim_speed, int layer)
Definition: mapdata.c:846
int mapdata_is_inside(int x, int y)
Checks whether the given coordinates are within the current display size (as set by mapdata_set_size)...
Definition: mapdata.c:624
guint8 animation_phase
Definition: mapdata.h:33
gint16 mapdata_bigface_head(int x, int y, int layer, int *ww, int *hh)
Definition: mapdata.c:1128
void mapdata_set_smooth(int x, int y, int smooth, int layer)
Definition: mapdata.c:753
void mapdata_set_face_layer(int x, int y, gint16 face, int layer)
Definition: mapdata.c:815
gint16 face
Definition: mapdata.h:19
bool mapdata_can_smooth(int x, int y, int layer)
Definition: mapdata.c:134
guint8 animation_left
Definition: mapdata.h:32
guint8 darkness
Definition: mapdata.h:54
void mapdata_size(int *x, int *y)
Determine the size of the internal fog-of-war map.
Definition: mapdata.c:142