Crossfire Client, Trunk
mapdata.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Map
 
struct  MapCell
 
struct  MapCellLayer
 
struct  MapCellTailLayer
 

Macros

#define MAP1_LAYERS   3
 
#define MAX_VIEW   64
 
#define MAXLAYERS   10
 

Functions

void clear_move_to (void)
 
bool is_at_moveto (void)
 
void mapdata_animation (void)
 
gint16 mapdata_bigface (int x, int y, int layer, int *ww, int *hh)
 
gint16 mapdata_bigface_head (int x, int y, int layer, int *ww, int *hh)
 
bool mapdata_can_smooth (int x, int y, int layer)
 
struct MapCellmapdata_cell (int x, int y)
 
void mapdata_clear_old (int x, int y)
 
void mapdata_clear_space (int x, int y)
 
bool mapdata_contains (int x, int y)
 
gint16 mapdata_face (int x, int y, int layer) __attribute__((deprecated))
 
gint16 mapdata_face_info (int mx, int my, int layer, int *dx, int *dy)
 
void mapdata_free (void)
 
int mapdata_is_inside (int x, int y)
 
void mapdata_newmap (void)
 
void mapdata_scroll (int dx, int dy)
 
void mapdata_set_anim_layer (int x, int y, guint16 anim, guint8 anim_speed, int layer)
 
void mapdata_set_check_space (int x, int y)
 
void mapdata_set_darkness (int x, int y, int darkness)
 
void mapdata_set_face_layer (int x, int y, gint16 face, int layer)
 
void mapdata_set_size (int viewx, int viewy)
 
void mapdata_set_smooth (int x, int y, guint8 smooth, int layer)
 
void mapdata_size (int *x, int *y)
 
void pl_mpos (int *px, int *py)
 
int relative_direction (int dx, int dy)
 
void run_move_to (void)
 
void set_move_to (int dx, int dy)
 

Variables

int global_offset_x
 
int global_offset_y
 
bool move_to_attack
 
int move_to_x
 
int move_to_y
 
PlayerPosition script_pos
 
int want_offset_x
 
int want_offset_y
 

Macro Definition Documentation

◆ MAP1_LAYERS

#define MAP1_LAYERS   3

Definition at line 16 of file mapdata.h.

◆ MAX_VIEW

#define MAX_VIEW   64

Maximum size of view area a server could support.

Definition at line 11 of file mapdata.h.

◆ MAXLAYERS

#define MAXLAYERS   10

The protocol supports 10 layers, so set MAXLAYERS accordingly.

Definition at line 6 of file mapdata.h.

Function Documentation

◆ clear_move_to()

void clear_move_to ( void  )

Definition at line 1478 of file mapdata.c.

References move_to_attack, move_to_x, and move_to_y.

Referenced by mapdata_newmap(), run_move_to(), and send_command().

+ Here is the caller graph for this function:

◆ is_at_moveto()

bool is_at_moveto ( void  )

Definition at line 1484 of file mapdata.c.

References move_to_x, move_to_y, and pl_mpos().

Referenced by gtk_map_redraw(), and run_move_to().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mapdata_animation()

◆ mapdata_bigface()

gint16 mapdata_bigface ( int  x,
int  y,
int  layer,
int *  ww,
int *  hh 
)

Returns the face to display at a given location. This function returns the "tail" information, i.e. big faces expanded by the client.

*ww and *hh return the offset of the current tile relative to the head; 0 <= *ww < (width of face), 0 <= *hh < (height of face).

When drawing the map view, this function must be used instead than a direct access to the_map.cells[]. This is because the_map.cells[] eventually still contains obsolete (fog of war) big face information; this function detects and clears such faces.

Return the face number of a multi-square pixmap at the given map tile.

Parameters
xX-coordinate of tile on-screen
yY-coordinate of tile on-screen
layer
ww
hh
Returns
Pixmap face number, or zero if the tile does not exist

Definition at line 1081 of file mapdata.c.

References bigfaces, MapCell::cleared, expand_clear_face_from_layer(), MapCellLayer::face, MapCellTailLayer::face, BigCell::head, MapCell::heads, height, mapdata_cell(), mapdata_has_tile(), MAX_FACE_SIZE, pl_pos, MapCellLayer::size_x, MapCellTailLayer::size_x, MapCellLayer::size_y, MapCellTailLayer::size_y, BigCell::tail, MapCell::tails, width, PlayerPosition::x, and PlayerPosition::y.

+ Here is the call graph for this function:

◆ mapdata_bigface_head()

gint16 mapdata_bigface_head ( int  x,
int  y,
int  layer,
int *  ww,
int *  hh 
)

Definition at line 1162 of file mapdata.c.

References bigfaces, MapCellLayer::face, BigCell::head, mapdata_has_tile(), MapCellLayer::size_x, and MapCellLayer::size_y.

+ Here is the call graph for this function:

◆ mapdata_can_smooth()

bool mapdata_can_smooth ( int  x,
int  y,
int  layer 
)

Definition at line 150 of file mapdata.c.

References MapCell::heads, mapdata_cell(), and MapCell::smooth.

Referenced by drawsmooth().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mapdata_cell()

◆ mapdata_clear_old()

void mapdata_clear_old ( int  x,
int  y 
)

Definition at line 798 of file mapdata.c.

References MapCell::cleared, MapCell::darkness, expand_clear_face_from_layer(), MapCell::have_darkness, Map::height, height, mapdata_cell(), MAX_VIEW, MAXLAYERS, pl_pos, the_map, Map::width, width, PlayerPosition::x, and PlayerPosition::y.

Referenced by Map2Cmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mapdata_clear_space()

void mapdata_clear_space ( int  x,
int  y 
)

Definition at line 644 of file mapdata.c.

References MapCell::cleared, expand_need_update_from_layer(), expand_set_bigface(), MapCell::heads, Map::height, height, mapdata_cell(), MAX_VIEW, MAXLAYERS, MapCell::need_update, pl_pos, the_map, Map::width, width, PlayerPosition::x, and PlayerPosition::y.

Referenced by Map2Cmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mapdata_contains()

bool mapdata_contains ( int  x,
int  y 
)

Determine whether the map data contains the given cell.

Definition at line 142 of file mapdata.c.

References Map::height, the_map, and Map::width.

Referenced by drawsmooth(), ExtSmooth(), and send_map().

+ Here is the caller graph for this function:

◆ mapdata_face()

gint16 mapdata_face ( int  x,
int  y,
int  layer 
)

Returns the face to display at a given location. This function returns the "head" information, i.e. the face information sent by the server.

Return the face number of a single-square pixmap at the given map tile.

Parameters
xX-coordinate of tile on-screen
yY-coordinate of tile on-screen
layer
Returns
Pixmap face number, or zero if the tile does not exist

Definition at line 1047 of file mapdata.c.

References MapCellLayer::face, MapCell::heads, BigCell::layer, mapdata_cell(), mapdata_has_tile(), pl_pos, BigCell::x, PlayerPosition::x, BigCell::y, and PlayerPosition::y.

+ Here is the call graph for this function:

◆ 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 where to correctly draw the face. Offsets are zero for single-tile maps and negative for multi-tile maps. This provides a consistent way to draw tiles no matter single or multi part.

Parameters
mxVirtual map x-coordinate
myVirtual map y-coordinate
layerMap layer number
dxPointer to store x-offset
dyPointer to store y-offset
Returns
Pixmap face number, zero if the tile does not exist

Definition at line 1055 of file mapdata.c.

References MapCellLayer::face, MapCellTailLayer::face, MapCell::heads, height, mapdata_cell(), MapCellLayer::size_x, MapCellTailLayer::size_x, MapCellLayer::size_y, MapCellTailLayer::size_y, MapCell::tails, and width.

Referenced by map_draw_layer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mapdata_free()

void mapdata_free ( void  )

Deallocate map data. Do not call functions other than mapdata_set_size() after calling mapdata_free().

Definition at line 615 of file mapdata.c.

References Map::_cells, Map::height, the_map, and Map::width.

Referenced by mapdata_set_size(), and reset_vars_common().

+ Here is the caller graph for this function:

◆ 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 at line 635 of file mapdata.c.

References height.

◆ mapdata_newmap()

void mapdata_newmap ( void  )

Clears the map view. Must be called whenever a newmap command was received from the server.

Definition at line 996 of file mapdata.c.

References bigfaces_head, clear_cells(), clear_move_to(), csocket, ClientSocket::dir, expand_clear_bigface_from_layer(), global_offset_x, global_offset_y, Map::height, BigCell::layer, mapdata_cell(), MapCell::need_update, script_pos, the_map, want_offset_x, want_offset_y, Map::width, BigCell::x, PlayerPosition::x, BigCell::y, and PlayerPosition::y.

Referenced by NewmapCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mapdata_scroll()

void mapdata_scroll ( int  dx,
int  dy 
)

Scrolls the map view. Must be called whenever a map_scroll command was received from the server.

Definition at line 919 of file mapdata.c.

References bigfaces_head, MapCell::cleared, CONFIG_MAPSCROLL, display_mapscroll(), expand_clear_bigface_from_layer(), BigCell::head, height, BigCell::layer, mapdata_cell(), MapCell::need_update, BigCell::next, pl_pos, recenter_virtual_map_view(), run_move_to(), script_pos, MapCellLayer::size_x, MapCellLayer::size_y, want_config, width, BigCell::x, PlayerPosition::x, BigCell::y, and PlayerPosition::y.

Referenced by Map2Cmd(), and map_scrollCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mapdata_set_anim_layer()

◆ mapdata_set_check_space()

void mapdata_set_check_space ( int  x,
int  y 
)

◆ mapdata_set_darkness()

void mapdata_set_darkness ( int  x,
int  y,
int  darkness 
)

Definition at line 741 of file mapdata.c.

References MapCell::darkness, Map::height, height, MAX_VIEW, pl_pos, set_darkness(), the_map, Map::width, width, PlayerPosition::x, and PlayerPosition::y.

Referenced by Map2Cmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mapdata_set_face_layer()

void mapdata_set_face_layer ( int  x,
int  y,
gint16  face,
int  layer 
)

Definition at line 826 of file mapdata.c.

References MapCell::cleared, expand_clear_face_from_layer(), expand_set_bigface(), expand_set_face(), Map::height, height, mapdata_cell(), MAX_VIEW, MapCell::need_update, pl_pos, the_map, Map::width, width, PlayerPosition::x, and PlayerPosition::y.

Referenced by Map2Cmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mapdata_set_size()

void mapdata_set_size ( int  viewx,
int  viewy 
)

Initializes the module. Allocates memory for the_map. This functions must be called before any other function is used, and whenever a new display size was negotiated with the server.

Definition at line 624 of file mapdata.c.

References Map::height, height, mapdata_free(), mapdata_init(), pl_pos, the_map, Map::width, width, PlayerPosition::x, and PlayerPosition::y.

Referenced by SetupCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mapdata_set_smooth()

void mapdata_set_smooth ( int  x,
int  y,
guint8  smooth,
int  layer 
)

Definition at line 764 of file mapdata.c.

References Map::height, mapdata_cell(), MAX_VIEW, MapCell::need_resmooth, pl_pos, MapCell::smooth, the_map, Map::width, PlayerPosition::x, and PlayerPosition::y.

Referenced by Map2Cmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mapdata_size()

void mapdata_size ( int *  x,
int *  y 
)

Determine the size of the internal fog-of-war map.

Definition at line 158 of file mapdata.c.

References Map::height, the_map, and Map::width.

Referenced by script_process_cmd().

+ Here is the caller graph for this function:

◆ pl_mpos()

void pl_mpos ( int *  px,
int *  py 
)

Compute player position in map coordinates. Unlike pl_pos.x and pl_pos.y which store the top left corner of the virtual map, this returns the actual position of the player.

Definition at line 1455 of file mapdata.c.

References CONFIG_MAPHEIGHT, CONFIG_MAPWIDTH, pl_pos, use_config, PlayerPosition::x, and PlayerPosition::y.

Referenced by is_at_moveto(), run_move_to(), and set_move_to().

+ Here is the caller graph for this function:

◆ relative_direction()

int relative_direction ( int  dx,
int  dy 
)

Given a relative tile coordinate, determine its compass direction.

Parameters
dxRelative 'x' coordinate
dyRelative 'y' coordinate
Returns
0 if x and y are both zero, 1-8 for each compass direction

Definition at line 511 of file map.c.

Referenced by map_button_event(), and run_move_to().

+ Here is the caller graph for this function:

◆ run_move_to()

void run_move_to ( void  )

Definition at line 1494 of file mapdata.c.

References clear_move_to(), is_at_moveto(), move_to_attack, move_to_x, move_to_y, pl_mpos(), relative_direction(), run_dir(), stop_run(), and walk_dir().

Referenced by map_button_event(), and mapdata_scroll().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_move_to()

void set_move_to ( int  dx,
int  dy 
)

Definition at line 1462 of file mapdata.c.

References move_to_attack, move_to_x, move_to_y, and pl_mpos().

Referenced by map_button_event().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ global_offset_x

◆ global_offset_y

◆ move_to_attack

bool move_to_attack

Definition at line 40 of file mapdata.c.

Referenced by clear_move_to(), gtk_map_redraw(), run_move_to(), and set_move_to().

◆ move_to_x

int move_to_x

Move to coordinates on the current map. (0, 0) means no destination.

Definition at line 39 of file mapdata.c.

Referenced by clear_move_to(), gtk_map_redraw(), is_at_moveto(), run_move_to(), and set_move_to().

◆ move_to_y

int move_to_y

Definition at line 163 of file mapdata.h.

◆ script_pos

PlayerPosition script_pos

Position of the player reported to client scripts. It resets to (0, 0) after a 'newmap' command.

Definition at line 36 of file mapdata.c.

Referenced by mapdata_newmap(), mapdata_scroll(), and script_process_cmd().

◆ want_offset_x

int want_offset_x

Definition at line 165 of file mapdata.h.

◆ want_offset_y

int want_offset_y

Definition at line 166 of file mapdata.h.