 |
Crossfire Client, Trunk
|
Go to the documentation of this file.
45 #define FOG_MAP_SIZE 512
51 #define FOG_BORDER_MIN 128
56 #define MAX_FACE_SIZE 16
63 #define CURRENT_MAX_VIEW 33
122 int clear_cells_i, j;
125 for (clear_cells_i = 0; clear_cells_i < (len_y); clear_cells_i++) {
221 for (sdx=-1; sdx<2; sdx++)
222 for (sdy=-1; sdy<2; sdy++)
253 for (dx = 0; dx < w; dx++) {
254 for (dy = !dx; dy < h; dy++) {
345 for (dx = 0; dx < w; dx++) {
346 for (dy = !dx; dy < h; dy++) {
383 for (dx = 0; dx < w && dx <= x; dx++) {
384 for (dy = !dx; dy < h && dy <= y; dy++) {
386 assert(0 <= x-dx && x-dx <
MAX_VIEW);
387 assert(0 <= y-dy && y-dy <
MAX_VIEW);
400 if (0 <= x-dx && x-dx <
width
401 && 0 <= y-dy && y-dy <
height) {
404 if (set_need_update) {
435 head = &headcell->
head;
436 if (head->
face != 0) {
440 if (headcell->
prev != NULL) {
443 if (headcell->
next != NULL) {
447 assert(headcell->
prev == NULL);
450 assert(headcell->
prev != NULL);
452 headcell->
prev = NULL;
453 headcell->
next = NULL;
458 assert(head->
size_x == 1);
459 assert(head->
size_y == 1);
483 head = &headcell->
head;
490 assert(headcell->
prev == NULL);
491 assert(headcell->
next == NULL);
508 for (dx = 0; dx < w && dx <= x; dx++) {
509 for (dy = !dx; dy < h && dy <= y; dy++) {
511 assert(0 <= x-dx && x-dx <
MAX_VIEW);
512 assert(0 <= y-dy && y-dy <
MAX_VIEW);
519 if (0 <= x-dx && x-dx <
width
520 && 0 <= y-dy && y-dy <
height) {
548 for (dx = 0; dx < w; dx++) {
549 for (dy = 0; dy < h; dy++) {
573 if (head->
face != 0) {
576 assert(head->
size_x == 1);
577 assert(head->
size_y == 1);
587 g_assert(
map->_cells != NULL);
599 for (
int i = 0; i <
map->width; i++) {
600 map->_cells[i] =
map->_cells[0]+i*
map->height;
667 return(x >= 0 && x < width && y >= 0 && y <
height);
780 static int dx[8]= {0,1,1,1,0,-1,-1,-1};
781 static int dy[8]= {-1,-1,0,1,1,1,0,-1};
782 int rx, ry, px, py, i;
793 for (i=0; i<8; i++) {
824 new->label = g_strdup(
label);
907 int i, face, animation, phase, speed_left;
923 if (num_animations == 0) {
925 "animating object with zero animations");
928 phase = g_random_int() % num_animations;
930 speed_left = anim_speed % g_random_int();
1000 for (
x = 0;
x < -dx;
x++) {
1014 for (
y = 0;
y < -dy;
y++) {
1090 if (head->
face != 0) {
1094 }
else if (tail->
face != 0) {
1129 assert(0 <= dx && dx < w);
1130 assert(0 <= dy && dy < h);
1157 if (!clear_bigface) {
1174 assert(0 <= dx && dx < w);
1175 assert(0 <= dy && dy < h);
1226 int shift_x, shift_y;
1271 if (shift_x == 0 && shift_y == 0) {
1298 if (shift_x <= -the_map.width || shift_x >=
the_map.
width
1299 || shift_y <= -the_map.height || shift_y >=
the_map.
height) {
1335 for (sx = src_x, dx = dst_x, i = 0; i < len_x; sx++, dx++, i++) {
1341 }
else if (shift_x > 0) {
1342 for (sx = src_x+len_x-1, dx = dst_x+len_x-1, i = 0; i < len_x; sx--, dx--, i++) {
1349 assert(src_x == dst_x);
1350 for (dx = src_x, i = 0; i < len_x; dx++, i++) {
1359 for (dx = 0; dx < dst_x; dx++) {
1366 for (dx = 0; dx < len_x; dx++) {
1369 }
else if (shift_y < 0) {
1370 for (dx = 0; dx < len_x; dx++) {
1402 int x, y, layer,
face;
1436 for (layer=0; layer<
MAXLAYERS; layer++) {
1438 cell = &map_space->
heads[layer];
struct MapCell * mapdata_cell(const int x, const int y)
Get the stored map cell at the given map coordinate.
void mapdata_clear_space(int x, int y)
int relative_direction(int dx, int dy)
Given a relative tile coordinate, determine its compass direction.
@ LOG_WARNING
Warning that something might not work.
gint16 mapdata_bigface(int x, int y, int layer, int *ww, int *hh)
Return the face number of a multi-square pixmap at the given map tile.
void mapdata_set_face_layer(int x, int y, gint16 face, int layer)
void mapdata_clear_label(int px, int py)
int move_to_x
Move to coordinates on the current map.
void mapdata_newmap(void)
Clears the map view.
gint16 mapdata_face(int x, int y, int layer)
Return the face number of a single-square pixmap at the given map tile.
static void expand_need_update(int x, int y, int w, int h)
Mark a face as "need_update".
guint8 num_animations
Number of animations.
void mapdata_set_smooth(int x, int y, guint8 smooth, int layer)
static struct BigCell * bigfaces_head
Contains the head of a list of all currently active big faces outside the view area.
void mapdata_set_check_space(int x, int y)
bool mapdata_can_smooth(int x, int y, int layer)
static void expand_clear_face(int x, int y, int w, int h, int layer)
Clear a face from the_map.cells[].
#define FOG_MAP_SIZE
Size of virtual map.
static void mapdata_alloc(struct Map *const map, const int width, const int height)
Allocate and set up pointers for a map, with cells represented as a C-style multi-dimensional array.
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.
static void expand_need_update_from_layer(int x, int y, int layer)
Mark a face as "need_update".
int display_mapscroll(int dx, int dy)
#define FOG_BORDER_MIN
After shifting the virtual map: new minimum distance of the view area to the new virtual map border.
static void expand_set_bigface(int x, int y, int layer, gint16 face, int clear)
Update a face into bigfaces[].
static void mapdata_init(void)
static void recenter_virtual_map_view(int diff_x, int diff_y)
Check if current map position is out of bounds if shifted by (dx, dy).
struct MapCellLayer heads[MAXLAYERS]
static void mapdata_get_image_size(int face, guint8 *w, guint8 *h)
Return the size of a face in tiles.
void mapdata_size(int *x, int *y)
Determine the size of the internal fog-of-war map.
void mapdata_free(void)
Deallocate map data.
#define CONFIG_MAPSCROLL
Use bitmap operations for map scrolling.
static bool mapdata_has_tile(int x, int y, int layer)
Check if the given map tile is a valid slot in the map array.
void mapdata_set_anim_layer(int x, int y, guint16 anim, guint8 anim_speed, int layer)
void LOG(LogLevel level, const char *origin, const char *format,...)
Log messages of a certain importance to stderr.
gint16 mapdata_bigface_head(int x, int y, int layer, int *ww, int *hh)
static struct Map the_map
gint16 want_config[CONFIG_NUMS]
static void expand_clear_bigface_from_layer(int x, int y, int layer, int set_need_update)
Clear a face from bigfaces[].
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...
The heads[] in the mapcell is used for single part objects or the head piece for multipart.
void mapdata_clear(int x, int y)
Mark the given cell as cleared in response to a Map2 clear command.
static void mark_resmooth(int x, int y, int layer)
void get_map_image_size(int face, guint8 *w, guint8 *h)
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)...
bool mapdata_contains(int x, int y)
Determine whether the map data contains the given cell.
static void expand_clear_bigface(int x, int y, int w, int h, int layer, int set_need_update)
Clear a face from bigfaces[].
void set_move_to(int dx, int dy)
struct MapCellTailLayer tails[MAXLAYERS]
#define MAX_FACE_SIZE
Maximum size of a big face image in tiles.
static void set_darkness(int x, int y, int darkness)
Update darkness information.
static struct BigCell bigfaces[MAX_VIEW][MAX_VIEW][MAXLAYERS]
The variable bigfaces[] contains information about big faces (faces with a width or height >1).
void mapdata_scroll(int dx, int dy)
Scrolls the map view.
#define ANIM_MASK
AND'ing this with data from server gets us just the animation id.
void mapdata_set_size(int viewx, int viewy)
Initializes the module.
void mapdata_add_label(int x, int y, int subtype, const char *label)
static void expand_clear_face_from_layer(int x, int y, int layer)
Clear a face from the_map.cells[].
void pl_mpos(int *px, int *py)
Compute player position in map coordinates.
void mapdata_set_darkness(int x, int y, int darkness)
gint16 use_config[CONFIG_NUMS]
#define MAXLAYERS
The protocol supports 10 layers, so set MAXLAYERS accordingly.
PlayerPosition pl_pos
Position of the player on the internal map.
Animations animations[MAXANIM]
#define ANIM_FLAGS_MASK
Used only by the client.
static void clear_cells(int x, int y, int len_y)
Clear cells the_map.cells[x][y..y+len_y-1].
static void expand_set_face(int x, int y, int layer, gint16 face, int clear)
Update a face into the_map.cells[].
The struct BigCell describes a tile outside the view area.
#define MAX_VIEW
Maximum size of view area a server could support.
struct MapCellTailLayer tail
void mapdata_animation(void)
PlayerPosition script_pos
Position of the player reported to client scripts.