Crossfire Client, Branches
R11627
|
#include <assert.h>
#include <stdlib.h>
#include "client.h"
#include "external.h"
#include "mapdata.h"
Go to the source code of this file.
Data Structures | |
struct | BigCell |
Macros | |
#define | CLEAR_CELLS(x, y, len_y) |
#define | CURRENT_MAX_VIEW 33 |
#define | FOG_BORDER_MIN 128 |
#define | FOG_MAP_SIZE 512 |
#define | MAX_FACE_SIZE 16 |
Functions | |
static void | expand_clear_bigface (int x, int y, int w, int h, int layer, int set_need_update) |
static void | expand_clear_bigface_from_layer (int x, int y, int layer, int set_need_update) |
static void | expand_clear_face (int x, int y, int w, int h, int layer) |
static void | expand_clear_face_from_layer (int x, int y, int layer) |
static void | expand_need_update (int x, int y, int w, int h) |
static void | expand_need_update_from_layer (int x, int y, int layer) |
static void | expand_set_bigface (int x, int y, int layer, sint16 face, int clear) |
static void | expand_set_face (int x, int y, int layer, sint16 face, int clear) |
void | mapdata_animation (void) |
sint16 | mapdata_bigface (int x, int y, int layer, int *ww, int *hh) |
sint16 | mapdata_bigface_head (int x, int y, int layer, int *ww, int *hh) |
void | mapdata_clear_old (int x, int y) |
void | mapdata_clear_space (int x, int y) |
sint16 | mapdata_face (int x, int y, int layer) |
static void | mapdata_get_image_size (int face, uint8 *w, uint8 *h) |
void | mapdata_init (void) |
int | mapdata_is_inside (int x, int y) |
void | mapdata_newmap (void) |
void | mapdata_reset (void) |
void | mapdata_scroll (int dx, int dy) |
void | mapdata_set_anim_layer (int x, int y, uint16 anim, uint8 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, sint16 face, int layer) |
void | mapdata_set_size (int viewx, int viewy) |
void | mapdata_set_smooth (int x, int y, int smooth, int layer) |
static void | mark_resmooth (int x, int y, int layer) |
static void | recenter_virtual_map_view (int diff_x, int diff_y) |
static void | set_darkness (int x, int y, int darkness) |
Variables | |
static struct BigCell | bigfaces [MAX_VIEW][MAX_VIEW][MAXLAYERS] |
static struct BigCell * | bigfaces_head |
static int | height |
struct Map | the_map |
static int | width |
#define CLEAR_CELLS | ( | x, | |
y, | |||
len_y | |||
) |
Clear cells the_map.cells[x][y..y+len_y-1].
Definition at line 35 of file mapdata.c.
Referenced by mapdata_init(), mapdata_newmap(), and recenter_virtual_map_view().
#define CURRENT_MAX_VIEW 33 |
Definition at line 70 of file mapdata.c.
Referenced by mapdata_animation().
#define FOG_BORDER_MIN 128 |
After shifting the virtual map: new minimum distance of the view area to the new virtual map border.
Definition at line 58 of file mapdata.c.
Referenced by recenter_virtual_map_view().
#define FOG_MAP_SIZE 512 |
Size of virtual map.
Definition at line 52 of file mapdata.c.
Referenced by expand_clear_bigface(), expand_clear_face(), expand_clear_face_from_layer(), expand_need_update(), expand_need_update_from_layer(), expand_set_bigface(), expand_set_face(), mapdata_clear_old(), mapdata_clear_space(), mapdata_init(), mapdata_newmap(), mapdata_set_anim_layer(), mapdata_set_check_space(), mapdata_set_darkness(), mapdata_set_face_layer(), mapdata_set_size(), mapdata_set_smooth(), mark_resmooth(), and recenter_virtual_map_view().
#define MAX_FACE_SIZE 16 |
Maximum size of a big face image in tiles. Larger faces will be clipped top/left.
Definition at line 63 of file mapdata.c.
Referenced by expand_clear_bigface(), expand_clear_face(), expand_need_update(), expand_set_bigface(), expand_set_face(), mapdata_bigface(), mapdata_get_image_size(), and recenter_virtual_map_view().
|
static |
Clear a face from bigfaces[].
x, y, and layer are the coordinates and layer of the head relative to pl_pos.
w and h give the width and height of the face to clear.
If set_need_update is set, all affected tiles are marked as "need_update".
Definition at line 306 of file mapdata.c.
References bigfaces, Map::cells, MapCellLayer::face, FOG_MAP_SIZE, BigCell::head, height, MAX_FACE_SIZE, MAX_VIEW, MAXLAYERS, MapCell::need_update, pl_pos, MapCellLayer::size_x, MapCellLayer::size_y, BigCell::tail, the_map, width, PlayerPosition::x, and PlayerPosition::y.
Referenced by expand_clear_bigface_from_layer().
|
static |
Clear a face from bigfaces[].
x, y, and layer are the coordinates and layer of the head relative to pl_pos.
If set_need_update is set, all affected tiles are marked as "need_update".
Definition at line 360 of file mapdata.c.
References bigfaces, expand_clear_bigface(), MapCellLayer::face, BigCell::head, MAX_VIEW, MAXLAYERS, BigCell::next, BigCell::prev, MapCellLayer::size_x, and MapCellLayer::size_y.
Referenced by expand_set_bigface(), mapdata_newmap(), and mapdata_scroll().
|
static |
Clear a face from the_map.cells[].
x, y, and layer are the coordinates of the head and layer relative to pl_pos.
w and h give the width and height of the face to clear.
Definition at line 175 of file mapdata.c.
References MapCellLayer::animation, MapCellLayer::animation_left, MapCellLayer::animation_phase, MapCellLayer::animation_speed, Map::cells, MapCellLayer::face, FOG_MAP_SIZE, MapCell::heads, mark_resmooth(), MAX_FACE_SIZE, MAXLAYERS, MapCell::need_resmooth, MapCell::need_update, MapCellLayer::size_x, MapCellLayer::size_y, MapCell::tails, and the_map.
Referenced by expand_clear_face_from_layer().
|
static |
Clear a face from the_map.cells[].
x, y, and layer are the coordinates of the head and layer relative to pl_pos.
Definition at line 230 of file mapdata.c.
References Map::cells, expand_clear_face(), FOG_MAP_SIZE, MapCell::heads, MAXLAYERS, MapCellLayer::size_x, MapCellLayer::size_y, and the_map.
Referenced by expand_set_face(), mapdata_animation(), mapdata_bigface(), mapdata_clear_old(), mapdata_set_anim_layer(), and mapdata_set_face_layer().
|
static |
Mark a face as "need_update".
x and y are the coordinates of the head relative to pl_pos.
w and h is the size of the face.
Definition at line 468 of file mapdata.c.
References Map::cells, FOG_MAP_SIZE, MAX_FACE_SIZE, MapCell::need_update, and the_map.
Referenced by expand_need_update_from_layer().
|
static |
Mark a face as "need_update".
x, y, and layer are the coordinates and layer of the head relative to pl_pos.
Definition at line 496 of file mapdata.c.
References Map::cells, expand_need_update(), MapCellLayer::face, FOG_MAP_SIZE, MapCell::heads, MAXLAYERS, MapCellLayer::size_x, MapCellLayer::size_y, and the_map.
Referenced by mapdata_clear_space(), and mapdata_set_check_space().
|
static |
Update a face into bigfaces[].
x, y, and layer are the coordinates and layer of the head relative to pl_pos.
face is the new face to set.
Definition at line 404 of file mapdata.c.
References bigfaces, bigfaces_head, Map::cells, expand_clear_bigface_from_layer(), MapCellLayer::face, FOG_MAP_SIZE, BigCell::head, height, mapdata_get_image_size(), MAX_FACE_SIZE, MAX_VIEW, MAXLAYERS, MapCell::need_update, BigCell::next, pl_pos, BigCell::prev, MapCellLayer::size_x, MapCellLayer::size_y, BigCell::tail, the_map, width, PlayerPosition::x, and PlayerPosition::y.
Referenced by mapdata_animation(), mapdata_clear_space(), mapdata_set_anim_layer(), and mapdata_set_face_layer().
|
static |
Update a face into the_map.cells[].
x, y, and layer are the coordinates and layer of the head relative to pl_pos.
face is the new face to set. if clear is set, clear this face. If not set, don't clear. the reason clear may not be set is because this is an animation update - animations must all be the same size, so when we set the data for the space, we will just overwrite the old data. Problem with clearing is that clobbers the animation data.
Definition at line 256 of file mapdata.c.
References Map::cells, expand_clear_face_from_layer(), MapCellLayer::face, FOG_MAP_SIZE, MapCell::heads, mapdata_get_image_size(), mark_resmooth(), MAX_FACE_SIZE, MAXLAYERS, MapCell::need_update, MapCellLayer::size_x, MapCellLayer::size_y, MapCell::tails, and the_map.
Referenced by mapdata_animation(), mapdata_set_anim_layer(), and mapdata_set_face_layer().
void mapdata_animation | ( | void | ) |
Definition at line 1264 of file mapdata.c.
References MapCellLayer::animation, MapCellLayer::animation_left, MapCellLayer::animation_phase, MapCellLayer::animation_speed, animations, bigfaces, Map::cells, MapCell::cleared, CURRENT_MAX_VIEW, expand_clear_face_from_layer(), expand_set_bigface(), expand_set_face(), Animations::faces, FALSE, BigCell::head, MapCell::heads, BigCell::layer, MAXANIM, MAXLAYERS, Animations::num_animations, Animations::phase, pl_pos, MapCell::smooth, Animations::speed_left, the_map, BigCell::x, PlayerPosition::x, BigCell::y, and PlayerPosition::y.
Referenced by client_tick(), and do_timeout().
sint16 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.
Definition at line 966 of file mapdata.c.
References bigfaces, Map::cells, MapCell::cleared, expand_clear_face_from_layer(), MapCellLayer::face, BigCell::head, MapCell::heads, height, BigCell::layer, MAX_FACE_SIZE, MAXLAYERS, pl_pos, MapCellLayer::size_x, MapCellLayer::size_y, BigCell::tail, MapCell::tails, the_map, width, BigCell::x, PlayerPosition::x, BigCell::y, and PlayerPosition::y.
Referenced by display_mapcell().
sint16 mapdata_bigface_head | ( | int | x, |
int | y, | ||
int | layer, | ||
int * | ww, | ||
int * | hh | ||
) |
Definition at line 1052 of file mapdata.c.
References bigfaces, MapCellLayer::face, BigCell::head, BigCell::layer, MAX_VIEW, MAXLAYERS, MapCellLayer::size_x, MapCellLayer::size_y, width, BigCell::x, and BigCell::y.
void mapdata_clear_old | ( | int | x, |
int | y | ||
) |
Definition at line 744 of file mapdata.c.
References Map::cells, MapCell::cleared, MapCell::darkness, expand_clear_face_from_layer(), FOG_MAP_SIZE, MapCell::have_darkness, height, MAX_VIEW, MAXLAYERS, pl_pos, the_map, width, PlayerPosition::x, and PlayerPosition::y.
Referenced by Map2Cmd().
void mapdata_clear_space | ( | int | x, |
int | y | ||
) |
Definition at line 596 of file mapdata.c.
References Map::cells, MapCell::cleared, expand_need_update_from_layer(), expand_set_bigface(), MapCellLayer::face, FOG_MAP_SIZE, MapCell::heads, height, MAX_VIEW, MAXLAYERS, MapCell::need_update, pl_pos, the_map, TRUE, width, PlayerPosition::x, and PlayerPosition::y.
Referenced by Map2Cmd().
sint16 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.
Definition at line 955 of file mapdata.c.
References Map::cells, MapCellLayer::face, MapCell::heads, height, MAXLAYERS, pl_pos, the_map, width, PlayerPosition::x, and PlayerPosition::y.
Referenced by display_mapcell().
Return the size of a face in tiles. The returned size is at between 1 and MAX_FACE_SIZE (inclusive).
Definition at line 1252 of file mapdata.c.
References get_map_image_size(), and MAX_FACE_SIZE.
Referenced by expand_set_bigface(), and expand_set_face().
void mapdata_init | ( | void | ) |
Initializes the module. Allocates memory for the_map. This functions must be called before any other function is used.
Definition at line 514 of file mapdata.c.
References bigfaces, Map::cells, CLEAR_CELLS, MapCellLayer::face, FOG_MAP_SIZE, BigCell::head, height, BigCell::layer, LOG(), LOG_ERROR, MAX_VIEW, MAXLAYERS, BigCell::next, pl_pos, BigCell::prev, MapCellLayer::size_x, MapCellLayer::size_y, BigCell::tail, the_map, width, BigCell::x, Map::x, PlayerPosition::x, BigCell::y, Map::y, and PlayerPosition::y.
Referenced by init_windows(), mapdata_reset(), mapdata_set_size(), and parse_args().
int mapdata_is_inside | ( | int | x, |
int | y | ||
) |
void mapdata_newmap | ( | void | ) |
Clears the map view. Must be called whenever a newmap command was received from the server.
Definition at line 935 of file mapdata.c.
References Map::cells, CLEAR_CELLS, display_map_newmap(), expand_clear_bigface_from_layer(), FOG_MAP_SIZE, BigCell::layer, MapCell::need_update, the_map, BigCell::x, and BigCell::y.
Referenced by NewmapCmd().
void mapdata_reset | ( | void | ) |
Resets all stored information.
Definition at line 572 of file mapdata.c.
References mapdata_init().
Referenced by main().
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 859 of file mapdata.c.
References Map::cells, MapCell::cleared, CONFIG_MAPSCROLL, display_mapscroll(), expand_clear_bigface_from_layer(), BigCell::head, height, BigCell::layer, MapCell::need_update, BigCell::next, pl_pos, recenter_virtual_map_view(), MapCellLayer::size_x, MapCellLayer::size_y, the_map, want_config, width, BigCell::x, PlayerPosition::x, BigCell::y, and PlayerPosition::y.
Referenced by Map2Cmd(), and map_scrollCmd().
Definition at line 802 of file mapdata.c.
References ANIM_FLAGS_MASK, ANIM_MASK, ANIM_RANDOM, ANIM_SYNC, MapCellLayer::animation, MapCellLayer::animation_left, MapCellLayer::animation_phase, MapCellLayer::animation_speed, animations, Map::cells, MapCell::cleared, MapCell::darkness, expand_clear_face_from_layer(), expand_set_bigface(), expand_set_face(), Animations::faces, FOG_MAP_SIZE, MapCell::have_darkness, MapCell::heads, height, MAX_VIEW, MAXLAYERS, MapCell::need_update, Animations::num_animations, Animations::phase, pl_pos, Animations::speed, Animations::speed_left, the_map, TRUE, width, PlayerPosition::x, and PlayerPosition::y.
Referenced by Map2Cmd().
void mapdata_set_check_space | ( | int | x, |
int | y | ||
) |
Definition at line 638 of file mapdata.c.
References Map::cells, MapCell::cleared, expand_need_update_from_layer(), MapCellLayer::face, FOG_MAP_SIZE, MapCell::have_darkness, MapCell::heads, height, MAX_VIEW, MAXLAYERS, MapCell::need_update, pl_pos, MapCell::tails, the_map, width, PlayerPosition::x, and PlayerPosition::y.
Referenced by Map2Cmd().
void mapdata_set_darkness | ( | int | x, |
int | y, | ||
int | darkness | ||
) |
Definition at line 688 of file mapdata.c.
References FOG_MAP_SIZE, height, MAX_VIEW, pl_pos, set_darkness(), width, PlayerPosition::x, and PlayerPosition::y.
Referenced by Map2Cmd().
void mapdata_set_face_layer | ( | int | x, |
int | y, | ||
sint16 | face, | ||
int | layer | ||
) |
Definition at line 770 of file mapdata.c.
References Map::cells, MapCell::cleared, expand_clear_face_from_layer(), expand_set_bigface(), expand_set_face(), FOG_MAP_SIZE, height, MAX_VIEW, MapCell::need_update, pl_pos, the_map, TRUE, width, PlayerPosition::x, and PlayerPosition::y.
Referenced by Map2Cmd().
void mapdata_set_size | ( | int | viewx, |
int | viewy | ||
) |
Sets the current display size. Must be called whenever a new display size was negotiated with the server.
Definition at line 577 of file mapdata.c.
References FOG_MAP_SIZE, height, mapdata_init(), pl_pos, width, PlayerPosition::x, and PlayerPosition::y.
Referenced by negotiate_connection(), on_drawingarea_map_configure_event(), and SetupCmd().
void mapdata_set_smooth | ( | int | x, |
int | y, | ||
int | smooth, | ||
int | layer | ||
) |
Definition at line 711 of file mapdata.c.
References Map::cells, FOG_MAP_SIZE, MAX_VIEW, MapCell::need_resmooth, pl_pos, MapCell::smooth, the_map, Map::x, PlayerPosition::x, Map::y, and PlayerPosition::y.
Referenced by Map2Cmd().
|
static |
Definition at line 156 of file mapdata.c.
References Map::cells, FOG_MAP_SIZE, MapCell::need_resmooth, MapCell::smooth, and the_map.
Referenced by expand_clear_face(), and expand_set_face().
|
static |
Check if current map position is out of bounds if shifted by (dx, dy). If so, shift the virtual map so that the map view is within bounds again.
Assures that [pl_pos.x-MAX_FACE_SIZE..pl_pos.x+MAX_VIEW+1] is within the bounds of the virtual map area. This covers the area a map1a command may affect plus a one tile border.
Definition at line 1084 of file mapdata.c.
References Map::cells, CLEAR_CELLS, FOG_BORDER_MIN, FOG_MAP_SIZE, height, MAX_FACE_SIZE, MAX_VIEW, pl_pos, the_map, width, PlayerPosition::x, and PlayerPosition::y.
Referenced by mapdata_scroll().
|
static |
Update darkness information. This function is called whenever a map1a command from the server was received.
x and y are absolute coordinates into the_map.cells[].
darkness is the new darkness value.
Definition at line 132 of file mapdata.c.
References Map::cells, CFG_DM_SDL, CFG_LT_PIXEL, CFG_LT_PIXEL_BEST, CONFIG_DISPLAYMODE, CONFIG_LIGHTING, MapCell::darkness, MapCell::have_darkness, height, MapCell::need_update, the_map, use_config, width, Map::x, and Map::y.
Referenced by mapdata_set_darkness().
The variable bigfaces[] contains information about big faces (faces with a width or height >1). The viewable area bigfaces[0..width-1][0..height-1] is unused.
Definition at line 118 of file mapdata.c.
Referenced by expand_clear_bigface(), expand_clear_bigface_from_layer(), expand_set_bigface(), mapdata_animation(), mapdata_bigface(), mapdata_bigface_head(), and mapdata_init().
|
static |
Contains the head of a list of all currently active big faces outside the view area. All entries are part of bigfaces[].
Definition at line 111 of file mapdata.c.
Referenced by expand_set_bigface().
|
static |
Definition at line 104 of file mapdata.c.
Referenced by configure_event(), expand_clear_bigface(), expand_set_bigface(), mapdata_bigface(), mapdata_clear_old(), mapdata_clear_space(), mapdata_face(), mapdata_init(), mapdata_is_inside(), mapdata_scroll(), mapdata_set_anim_layer(), mapdata_set_check_space(), mapdata_set_darkness(), mapdata_set_face_layer(), mapdata_set_size(), png_to_data(), png_to_gdkpixmap(), png_to_xpixmap(), recenter_virtual_map_view(), resize_map_window(), resize_win_info(), resize_win_message(), rgba_to_gdkpixbuf(), rgba_to_gdkpixmap(), rgba_to_xpixmap(), and set_darkness().
struct Map the_map |
Definition at line 121 of file mapdata.c.
Referenced by display_map_doneupdate(), display_mapcell(), drawsmooth(), expand_clear_bigface(), expand_clear_face(), expand_clear_face_from_layer(), expand_need_update(), expand_need_update_from_layer(), expand_set_bigface(), expand_set_face(), ExtSmooth(), gtk_draw_map(), mapdata_animation(), mapdata_bigface(), mapdata_clear_old(), mapdata_clear_space(), mapdata_face(), mapdata_init(), mapdata_newmap(), mapdata_scroll(), mapdata_set_anim_layer(), mapdata_set_check_space(), mapdata_set_face_layer(), mapdata_set_smooth(), mark_resmooth(), recenter_virtual_map_view(), script_process_cmd(), send_map(), and set_darkness().
|
static |
Viewable map size.
Definition at line 104 of file mapdata.c.
Referenced by configure_event(), expand_clear_bigface(), expand_set_bigface(), mapdata_bigface(), mapdata_bigface_head(), mapdata_clear_old(), mapdata_clear_space(), mapdata_face(), mapdata_init(), mapdata_scroll(), mapdata_set_anim_layer(), mapdata_set_check_space(), mapdata_set_darkness(), mapdata_set_face_layer(), mapdata_set_size(), png_to_gdkpixmap(), png_to_xpixmap(), recenter_virtual_map_view(), rescale_rgba_data(), resize_map_window(), resize_win_info(), resize_win_message(), resize_win_root(), rgba_to_gdkpixbuf(), rgba_to_gdkpixmap(), rgba_to_xpixmap(), and set_darkness().