Crossfire Client, Trunk
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 
37  gint16 face;
38  gint8 size_x;
39  gint8 size_y;
40 };
41 
44  EMPTY, //< No data from server, and no fog data
45  VISIBLE, //< Data from server
46  FOG //< No longer visible, but saved as fog of war data
47 };
48 
62 struct MapCell
63 {
66  struct MapLabel *label;
67  guint8 smooth[MAXLAYERS];
68  guint8 darkness; /* darkness: 0=fully illuminated, 255=pitch black */
69  guint8 need_update:1; /* set if tile should be redrawn */
70  guint8 need_resmooth:1; /* same has need update but for smoothing only */
72 };
73 
74 struct MapLabel {
75  int subtype;
76  char *label;
77  struct MapLabel *next;
78 };
79 
80 struct Map
81 {
82  struct MapCell **_cells; //< data, access via mapdata_cells()
83  int width; //< width of cells array
84  int height; //< height of cells array
85 };
86 
87 struct MapCell *mapdata_cell(int x, int y);
88 bool mapdata_contains(int x, int y);
89 void mapdata_size(int *x, int *y);
90 bool mapdata_can_smooth(int x, int y, int layer);
91 
97 void mapdata_set_size(int viewx, int viewy);
98 
103 void mapdata_free(void);
104 
109 void mapdata_scroll(int dx, int dy);
110 
115 void mapdata_newmap(void);
116 
121 int mapdata_is_inside(int x, int y);
122 
127 gint16 mapdata_face(int x, int y, int layer) __attribute__((deprecated));
128 
141 gint16 mapdata_face_info(int mx, int my, int layer, int *dx, int *dy);
142 
155 gint16 mapdata_bigface(int x, int y, int layer, int *ww, int *hh);
156 
157 void mapdata_clear_space(int x, int y);
158 void mapdata_set_check_space(int x, int y);
159 void mapdata_set_darkness(int x, int y, int darkness);
160 void mapdata_set_smooth(int x, int y, guint8 smooth, int layer);
161 void mapdata_clear_label(int px, int py);
162 void mapdata_add_label(int x, int y, int subtype, const char *label);
163 void mapdata_clear_old(int x, int y);
164 void mapdata_set_face_layer(int x, int y, gint16 face, int layer);
165 void mapdata_set_anim_layer(int x, int y, guint16 anim, guint8 anim_speed, int layer);
166 gint16 mapdata_bigface_head(int x, int y, int layer, int *ww, int *hh);
167 void mapdata_animation(void);
168 int relative_direction(int dx, int dy);
169 
171 
172 void pl_mpos(int *px, int *py);
173 void set_move_to(int dx, int dy);
174 void clear_move_to(void);
175 bool is_at_moveto(void);
176 void run_move_to(void);
177 
178 extern int move_to_x, move_to_y;
179 extern bool move_to_attack;
182 
183 #endif
Map::height
int height
Definition: mapdata.h:84
mapdata_bigface_head
gint16 mapdata_bigface_head(int x, int y, int layer, int *ww, int *hh)
Definition: mapdata.c:1194
MapCellTailLayer::size_x
gint8 size_x
Definition: mapdata.h:38
relative_direction
int relative_direction(int dx, int dy)
Given a relative tile coordinate, determine its compass direction.
Definition: map.c:560
want_offset_x
int want_offset_x
Definition: mapdata.h:180
Map
Definition: mapdata.h:80
MapCellState
MapCellState
A map cell can be in one of three states:
Definition: mapdata.h:43
mapdata_face_info
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:1087
script_pos
PlayerPosition script_pos
Position of the player reported to client scripts.
Definition: mapdata.c:36
mapdata_newmap
void mapdata_newmap(void)
Clears the map view.
Definition: mapdata.c:1028
VISIBLE
@ VISIBLE
Definition: mapdata.h:45
mapdata_bigface
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:1113
move_to_x
int move_to_x
Move to coordinates on the current map.
Definition: mapdata.c:39
mapdata_set_check_space
void mapdata_set_check_space(int x, int y)
Definition: mapdata.c:707
move_to_attack
bool move_to_attack
Definition: mapdata.c:40
MapCellTailLayer::face
gint16 face
Definition: mapdata.h:37
is_at_moveto
bool is_at_moveto(void)
Definition: mapdata.c:1516
MapCell::state
enum MapCellState state
Definition: mapdata.h:71
mapdata_clear_old
void mapdata_clear_old(int x, int y)
Prepare a map cell, which may contain old fog of war data, for new visible map data.
Definition: mapdata.c:844
MapLabel::subtype
int subtype
Definition: mapdata.h:75
want_offset_y
int want_offset_y
Definition: mapdata.h:181
run_move_to
void run_move_to(void)
Definition: mapdata.c:1526
MapCellLayer::face
gint16 face
Definition: mapdata.h:19
mapdata_free
void mapdata_free(void)
Deallocate map data.
Definition: mapdata.c:645
mapdata_scroll
void mapdata_scroll(int dx, int dy)
Scrolls the map view.
Definition: mapdata.c:955
MapCellTailLayer::size_y
gint8 size_y
Definition: mapdata.h:39
MapCell::heads
struct MapCellLayer heads[MAXLAYERS]
Definition: mapdata.h:64
mapdata_set_size
void mapdata_set_size(int viewx, int viewy)
Initializes the module.
Definition: mapdata.c:654
MapCellLayer::animation_phase
guint8 animation_phase
Definition: mapdata.h:33
Map::_cells
struct MapCell ** _cells
Definition: mapdata.h:82
move_to_y
int move_to_y
Definition: mapdata.h:178
mapdata_set_darkness
void mapdata_set_darkness(int x, int y, int darkness)
Definition: mapdata.c:755
MapCell::smooth
guint8 smooth[MAXLAYERS]
Definition: mapdata.h:67
MapLabel
Definition: mapdata.h:74
MapCell::darkness
guint8 darkness
Definition: mapdata.h:68
MapLabel::label
char * label
Definition: mapdata.h:76
mapdata_animation
void mapdata_animation(void)
Definition: mapdata.c:1400
MapCell
The heads[] in the mapcell is used for single part objects or the head piece for multipart.
Definition: mapdata.h:62
Map::width
int width
Definition: mapdata.h:83
mapdata_clear_label
void mapdata_clear_label(int px, int py)
Definition: mapdata.c:830
pl_mpos
void pl_mpos(int *px, int *py)
Compute player position in map coordinates.
Definition: mapdata.c:1487
FOG
@ FOG
Definition: mapdata.h:46
MapCell::need_resmooth
guint8 need_resmooth
Definition: mapdata.h:70
MapCellTailLayer
Definition: mapdata.h:36
MapCell::tails
struct MapCellTailLayer tails[MAXLAYERS]
Definition: mapdata.h:65
mapdata_is_inside
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:665
mapdata_contains
bool mapdata_contains(int x, int y)
Determine whether the map data contains the given cell.
Definition: mapdata.c:146
MapCellLayer
Definition: mapdata.h:18
mapdata_clear_space
void mapdata_clear_space(int x, int y)
Definition: mapdata.c:674
EMPTY
@ EMPTY
Definition: mapdata.h:44
set_move_to
void set_move_to(int dx, int dy)
Definition: mapdata.c:1494
mapdata_can_smooth
bool mapdata_can_smooth(int x, int y, int layer)
Definition: mapdata.c:154
MapCellLayer::size_x
gint8 size_x
Definition: mapdata.h:20
mapdata_face
gint16 mapdata_face(int x, int y, int layer) __attribute__((deprecated))
Returns the face to display at a given location.
Definition: mapdata.c:1079
MapCellLayer::animation_left
guint8 animation_left
Definition: mapdata.h:32
MapCellLayer::size_y
gint8 size_y
Definition: mapdata.h:21
PlayerPosition
Definition: client.h:527
mapdata_set_face_layer
void mapdata_set_face_layer(int x, int y, gint16 face, int layer)
Definition: mapdata.c:875
mapdata_add_label
void mapdata_add_label(int x, int y, int subtype, const char *label)
Definition: mapdata.c:806
global_offset_x
int global_offset_x
Definition: mapdata.c:90
MAXLAYERS
#define MAXLAYERS
The protocol supports 10 layers, so set MAXLAYERS accordingly.
Definition: mapdata.h:6
global_offset_y
int global_offset_y
Definition: mapdata.c:91
MapLabel::next
struct MapLabel * next
Definition: mapdata.h:77
mapdata_set_smooth
void mapdata_set_smooth(int x, int y, guint8 smooth, int layer)
Definition: mapdata.c:778
mapdata_size
void mapdata_size(int *x, int *y)
Determine the size of the internal fog-of-war map.
Definition: mapdata.c:162
MapCellLayer::animation_speed
guint8 animation_speed
Definition: mapdata.h:31
MapCell::need_update
guint8 need_update
Definition: mapdata.h:69
MapCell::label
struct MapLabel * label
Definition: mapdata.h:66
MapCellLayer::animation
gint16 animation
Definition: mapdata.h:30
mapdata_cell
struct MapCell * mapdata_cell(int x, int y)
Get the stored map cell at the given map coordinate.
Definition: mapdata.c:139
mapdata_set_anim_layer
void mapdata_set_anim_layer(int x, int y, guint16 anim, guint8 anim_speed, int layer)
Definition: mapdata.c:904
clear_move_to
void clear_move_to(void)
Definition: mapdata.c:1510