Freeciv-3.3: /fast/freeciv/nightly/main/client/mapview_common.c File Reference

Freeciv-3.3

Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions | Variables
mapview_common.c File Reference
`#include "fcintl.h"`
`#include "log.h"`
`#include "rand.h"`
`#include "support.h"`
`#include "timing.h"`
`#include "featured_text.h"`
`#include "game.h"`
`#include "map.h"`
`#include "traderoutes.h"`
`#include "unitlist.h"`
`#include "graphics_g.h"`
`#include "gui_main_g.h"`
`#include "mapctrl_g.h"`
`#include "mapview_g.h"`
`#include "client_main.h"`
`#include "climap.h"`
`#include "control.h"`
`#include "editor.h"`
`#include "goto.h"`
`#include "citydlg_common.h"`
`#include "overview_common.h"`
`#include "svgflag.h"`
`#include "tilespec.h"`
`#include "zoom.h"`
`#include "mapview_common.h"`
`#include "spechash.h"`
`#include "speclist.h"`

Go to the source code of this file.

## Data Structures

struct | gotoline_counter
struct | trade_route_line
struct | animation
struct | link_mark

## Macros

#define | SPECHASH_TAG gotoline
#define | SPECHASH_IKEY_TYPE struct tile *
#define | SPECHASH_IDATA_TYPE struct gotoline_counter *
#define | SPECHASH_IDATA_FREE gotoline_counter_destroy
#define | gotoline_hash_iterate(hash, ptile, pglc)
#define | gotoline_hash_iterate_end HASH_ITERATE_END
#define | SPECLIST_TAG animation
#define | SPECLIST_TYPE struct animation
#define | NUM_CITY_COLORS tileset_num_city_colors(tileset)
#define | COLOR_MAPVIEW_TILELABEL COLOR_MAPVIEW_CITYTEXT
#define | SPECLIST_TAG link_mark
#define | SPECLIST_TYPE struct link_mark
#define | link_marks_iterate(pmark) TYPED_LIST_ITERATE(struct link_mark, link_marks, pmark)
#define | link_marks_iterate_end LIST_ITERATE_END

## Enumerations

enum | update_type { UPDATE_NONE = 0 , UPDATE_CITY_DESCRIPTIONS = 1 , UPDATE_MAP_CANVAS_VISIBLE = 2 , UPDATE_TILE_LABELS = 4 }
enum | tile_update_type { TILE_UPDATE_TILE_SINGLE , TILE_UPDATE_TILE_FULL , TILE_UPDATE_UNIT , TILE_UPDATE_CITY_DESC , TILE_UPDATE_CITYMAP , TILE_UPDATE_TILE_LABEL , TILE_UPDATE_COUNT }
enum | animation_type { ANIM_MOVEMENT , ANIM_BATTLE , ANIM_EXPL , ANIM_NUKE }

## Functions

static struct gotoline_counter * | gotoline_counter_new (void)
static void | gotoline_counter_destroy (struct gotoline_counter *pglc)
static void | base_canvas_to_map_pos (float zoom, int *map_x, int *map_y, float canvas_x, float canvas_y)
static void | show_full_citybar (struct canvas *pcanvas, const int canvas_x0, const int canvas_y0, struct city *pcity, int *width, int *height) fc__attribute((nonnull(5
static void static void | show_city_desc (struct canvas *pcanvas, int canvas_x, int canvas_y, struct city *pcity, int *width, int *height) fc__attribute((nonnull(5
static void | queue_mapview_update (enum update_type update)
static void | queue_mapview_tile_update (struct tile *ptile, enum tile_update_type type)
void | animations_init (void)
void | animations_free (void)
static void | anim_timer_renew (void)
static void | animation_add (struct animation *anim)
static bool | movement_animation (struct animation *anim, double time_gone)
static bool | battle_animation (struct animation *anim, double time_gone)
static bool | explosion_animation (struct animation *anim, double time_gone)
static bool | nuke_animation (struct animation *anim, double time_gone)
void | update_animation (void)
void | refresh_tile_mapcanvas (struct tile *ptile, bool full_refresh, bool write_to_screen)
void | refresh_unit_mapcanvas (struct unit *punit, struct tile *ptile, bool full_refresh, bool write_to_screen)
void | refresh_city_mapcanvas (struct city *pcity, struct tile *ptile, bool full_refresh, bool write_to_screen)
void | map_to_gui_vector (const struct tileset *t, float zoom, float *gui_dx, float *gui_dy, int map_dx, int map_dy)
static void | map_to_gui_pos (const struct tileset *t, float zoom, float *gui_x, float *gui_y, int map_x, int map_y)
static void | gui_to_map_pos (const struct tileset *t, float zoom, int *map_x, int *map_y, float gui_x, float gui_y)
bool | tile_to_canvas_pos (float *canvas_x, float *canvas_y, float zoom, const struct tile *ptile)
struct tile * | canvas_pos_to_tile (float canvas_x, float canvas_y, float zoom)
struct tile * | canvas_pos_to_nearest_tile (float canvas_x, float canvas_y, float zoom)
static void | normalize_gui_pos (const struct tileset *t, float zoom, float *gui_x, float *gui_y)
static void | gui_distance_vector (const struct tileset *t, float zoom, float *gui_dx, float *gui_dy, float gui_x0, float gui_y0, float gui_x1, float gui_y1)
static void | base_set_mapview_origin (float gui_x0, float gui_y0, float zoom)
static bool | calc_mapview_origin (float *gui_x0, float *gui_y0, float zoom)
void | set_mapview_origin (float gui_x0, float gui_y0, float zoom)
void | get_mapview_scroll_window (float *xmin, float *ymin, float *xmax, float *ymax, int *xsize, int *ysize)
void | get_mapview_scroll_step (int *xstep, int *ystep)
void | get_mapview_scroll_pos (int *scroll_x, int *scroll_y)
void | set_mapview_scroll_pos (int scroll_x, int scroll_y, float zoom)
struct tile * | get_center_tile_mapcanvas (void)
void | center_tile_mapcanvas (const struct tile *ptile)
bool | tile_visible_mapcanvas (struct tile *ptile)
bool | tile_visible_and_not_on_border_mapcanvas (struct tile *ptile)
void | put_drawn_sprites (struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y, int count, struct drawn_sprite *pdrawn, bool fog)
void | put_one_element (struct canvas *pcanvas, float zoom, enum mapview_layer layer, const struct tile *ptile, const struct tile_edge *pedge, const struct tile_corner *pcorner, const struct unit *punit, const struct city *pcity, int canvas_x, int canvas_y, const struct city *citymode, const struct unit_type *putype)
void | put_unit (const struct unit *punit, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
void | put_unittype (const struct unit_type *putype, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
void | put_city (struct city *pcity, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
void | put_terrain (struct tile *ptile, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
void | put_unit_city_overlays (struct unit *punit, struct canvas *pcanvas, int canvas_x, int canvas_y, int *upkeep_cost, int happy_cost)
void | toggle_city_color (struct city *pcity)
void | toggle_unit_color (struct unit *punit)
void | put_nuke_mushroom_pixmaps (struct tile *ptile)
static void | put_one_tile (struct canvas *pcanvas, enum mapview_layer layer, struct tile *ptile, int canvas_x, int canvas_y, const struct city *citymode)
static int | trade_route_to_canvas_lines (const struct tile *ptile1, const struct tile *ptile2, struct trade_route_line *lines)
static void | draw_trade_route_line (const struct tile *ptile1, const struct tile *ptile2, enum color_std color)
static void | draw_trade_routes_for_city (const struct city *pcity_src)
static void | draw_trade_routes (void)
void | update_map_canvas (int canvas_x, int canvas_y, int width, int height)
void | update_map_canvas_visible (void)
void | update_city_description (struct city *pcity)
void | update_tile_label (struct tile *ptile)
static void | show_small_citybar (struct canvas *pcanvas, int canvas_x, int canvas_y, struct city *pcity, int *width, int *height)
static void | show_tile_label (struct canvas *pcanvas, int canvas_x, int canvas_y, struct tile *ptile, int *width, int *height)
void | show_city_descriptions (int canvas_base_x, int canvas_base_y, int width_base, int height_base)
void | show_tile_labels (int canvas_base_x, int canvas_base_y, int width_base, int height_base)
void | draw_segment (struct tile *src_tile, enum direction8 dir)
void | decrease_unit_hp_smooth (struct unit *punit0, int hp0, struct unit *punit1, int hp1)
void | move_unit_map_canvas (struct unit *punit, struct tile *src_tile, int dx, int dy)
struct city * | find_city_or_settler_near_tile (const struct tile *ptile, struct unit **punit)
struct city * | find_city_near_tile (const struct tile *ptile)
static void | append_city_buycost_string (const struct city *pcity, char *buffer, int buffer_len)
void | get_city_mapview_production (struct city *pcity, char *buffer, size_t buffer_len)
void | get_city_mapview_trade_routes (struct city *pcity, char *trade_routes_buffer, size_t trade_routes_buffer_len, enum color_std *pcolor)
static void | queue_callback (void *data)
static void | queue_add_callback (void)
void | unqueue_mapview_updates (bool write_to_screen)
void | get_city_mapview_name_and_growth (struct city *pcity, char *name_buffer, size_t name_buffer_len, char *growth_buffer, size_t growth_buffer_len, enum color_std *growth_color, enum color_std *production_color)
static bool | can_do_cached_drawing (void)
void | mapdeco_init (void)
void | mapdeco_free (void)
void | mapdeco_set_highlight (const struct tile *ptile, bool highlight)
bool | mapdeco_is_highlight_set (const struct tile *ptile)
void | mapdeco_clear_highlights (void)
void | mapdeco_set_crosshair (const struct tile *ptile, bool crosshair)
bool | mapdeco_is_crosshair_set (const struct tile *ptile)
void | mapdeco_clear_crosshairs (void)
void | mapdeco_add_gotoline (const struct tile *ptile, enum direction8 dir)
void | mapdeco_remove_gotoline (const struct tile *ptile, enum direction8 dir)
void | mapdeco_set_gotoroute (const struct unit *punit)
bool | mapdeco_is_gotoline_set (const struct tile *ptile, enum direction8 dir)
void | mapdeco_clear_gotoroutes (void)
bool | map_canvas_resized (int width, int height)
void | init_mapcanvas_and_overview (void)
void | free_mapcanvas_and_overview (void)
void | get_spaceship_dimensions (int *width, int *height)
void | put_spaceship (struct canvas *pcanvas, int canvas_x, int canvas_y, const struct player *pplayer)
static struct link_mark * | link_mark_find (enum text_link_type type, int id)
static struct link_mark * | link_mark_new (enum text_link_type type, int id, int turns)
static void | link_mark_destroy (struct link_mark *pmark)
static struct tile * | link_mark_tile (const struct link_mark *pmark)
static struct color * | link_mark_color (const struct link_mark *pmark)
static void | link_mark_draw (const struct link_mark *pmark)
void | link_marks_init (void)
void | link_marks_free (void)
void | link_marks_draw_all (void)
void | link_marks_clear_all (void)
void | link_marks_decrease_turn_counters (void)
void | link_mark_add_new (enum text_link_type type, int id)
void | link_mark_restore (enum text_link_type type, int id)
enum topo_comp_lvl | tileset_map_topo_compatible (int topology_id, struct tileset *tset, int *tset_topo)
const char * | describe_topology (int topo)
void | set_frame_by_frame_animation (void)
struct tile * | client_infratile (void)
void | client_infratile_set (struct tile *ptile)

## Variables

struct tile_hash * | mapdeco_highlight_table
struct tile_hash * | mapdeco_crosshair_table
struct gotoline_hash * | mapdeco_gotoline_table
struct view | mapview
bool | can_slide = TRUE
static bool | frame_by_frame_animation = FALSE
const struct tile * | center_tile = NULL
struct tile * | infratile = NULL
static const int | MAX_TRADE_ROUTE_DRAW_LINES = 2
static struct timer * | anim_timer = NULL
struct animation_list * | animations = NULL
static int | color_index = 0
static int | max_desc_width = 0
static int | max_desc_height = 0
static int | max_label_width = 0
static int | max_label_height = 0
static enum update_type | needed_updates = UPDATE_NONE
static bool | callback_queued = FALSE
struct tile_list * | tile_updates [TILE_UPDATE_COUNT]
static struct link_mark_list * | link_marks = NULL

## Macro Definition Documentation

## ◆ COLOR_MAPVIEW_TILELABEL

#define COLOR_MAPVIEW_TILELABEL COLOR_MAPVIEW_CITYTEXT

## ◆ gotoline_hash_iterate

#define gotoline_hash_iterate | ( |  | hash,
|  |  | ptile,
|  |  | pglc
| ) |  |

Value:
TYPED_HASH_ITERATE(struct tile *, struct gotoline_counter *, \
hash, ptile, pglc)
incite_cost
char * incite_cost
Definition comments.c:74
hash
static GHashTable * hash
Definition wldlg.c:322
TYPED_HASH_ITERATE
#define TYPED_HASH_ITERATE(TYPE_key, TYPE_data, ARG_ht, NAME_key, NAME_data)
Definition spechash.h:726
gotoline_counter
Definition mapview_common.c:56
tile
Definition tile.h:50

Definition at line 68 of file mapview_common.c.

## ◆ gotoline_hash_iterate_end

#define gotoline_hash_iterate_end HASH_ITERATE_END

Definition at line 71 of file mapview_common.c.

## ◆ link_marks_iterate

#define link_marks_iterate | ( |  | pmark | ) | TYPED_LIST_ITERATE(struct link_mark, link_marks, pmark)

Definition at line 3766 of file mapview_common.c.

## ◆ link_marks_iterate_end

#define link_marks_iterate_end LIST_ITERATE_END

Definition at line 3768 of file mapview_common.c.

## ◆ NUM_CITY_COLORS

#define NUM_CITY_COLORS tileset_num_city_colors(tileset)

Definition at line 1483 of file mapview_common.c.

## ◆ SPECHASH_IDATA_FREE

#define SPECHASH_IDATA_FREE gotoline_counter_destroy

Definition at line 66 of file mapview_common.c.

## ◆ SPECHASH_IDATA_TYPE

#define SPECHASH_IDATA_TYPE struct gotoline_counter *

Definition at line 65 of file mapview_common.c.

## ◆ SPECHASH_IKEY_TYPE

#define SPECHASH_IKEY_TYPE struct tile *

Definition at line 64 of file mapview_common.c.

## ◆ SPECHASH_TAG

#define SPECHASH_TAG gotoline

Definition at line 63 of file mapview_common.c.

## ◆ SPECLIST_TAG [1/2]

#define SPECLIST_TAG animation

Definition at line 171 of file mapview_common.c.

## ◆ SPECLIST_TAG [2/2]

#define SPECLIST_TAG link_mark

Definition at line 171 of file mapview_common.c.

## ◆ SPECLIST_TYPE [1/2]

#define SPECLIST_TYPE struct animation

Definition at line 172 of file mapview_common.c.

## ◆ SPECLIST_TYPE [2/2]

#define SPECLIST_TYPE struct link_mark

Definition at line 172 of file mapview_common.c.

## Enumeration Type Documentation

## ◆ animation_type

enum animation_type

Enumerator
ANIM_MOVEMENT |
ANIM_BATTLE |
ANIM_EXPL |
ANIM_NUKE |

Definition at line 130 of file mapview_common.c.

## ◆ tile_update_type

enum tile_update_type

Enumerator
TILE_UPDATE_TILE_SINGLE |
TILE_UPDATE_TILE_FULL |
TILE_UPDATE_UNIT |
TILE_UPDATE_CITY_DESC |
TILE_UPDATE_CITYMAP |
TILE_UPDATE_TILE_LABEL |
TILE_UPDATE_COUNT |

Definition at line 106 of file mapview_common.c.

## ◆ update_type

enum update_type

Enumerator
UPDATE_NONE |
UPDATE_CITY_DESCRIPTIONS |
UPDATE_MAP_CANVAS_VISIBLE |
UPDATE_TILE_LABELS |

Definition at line 96 of file mapview_common.c.

## Function Documentation

## ◆ anim_timer_renew()

static void anim_timer_renew | ( | void |  | ) |

static

Start or renew animation timer.

Definition at line 222 of file mapview_common.c.

Referenced by animation_add(), decrease_unit_hp_smooth(), move_unit_map_canvas(), set_mapview_origin(), and update_animation().

## ◆ animation_add()

static void animation_add | ( | struct animation * | anim | ) |

static

Add new animation to the queue.

Definition at line 232 of file mapview_common.c.

Referenced by decrease_unit_hp_smooth(), move_unit_map_canvas(), and put_nuke_mushroom_pixmaps().

## ◆ animations_free()

void animations_free | ( | void |  | ) |

Clean up animations system.

Definition at line 188 of file mapview_common.c.

Referenced by client_game_free().

## ◆ animations_init()

void animations_init | ( | void |  | ) |

Initialize animations system.

Definition at line 180 of file mapview_common.c.

Referenced by client_game_init().

## ◆ append_city_buycost_string()

static void append_city_buycost_string | ( | const struct city * | pcity,
|  | char * | buffer,
|  | int | buffer_len
| ) |  |

static

Append the buy cost of the current production of the given city to the already NULL-terminated buffer. Does nothing if draw_city_buycost is set to FALSE, or if it does not make sense to buy the current production (e.g. coinage).

Definition at line 2875 of file mapview_common.c.

Referenced by get_city_mapview_production().

## ◆ base_canvas_to_map_pos()

static void base_canvas_to_map_pos | ( | float | zoom,
|  | int * | map_x,
|  | int * | map_y,
|  | float | canvas_x,
|  | float | canvas_y
| ) |  |

static

Finds the map coordinates corresponding to pixel coordinates. The resulting position is unwrapped and may be unreal.

Definition at line 751 of file mapview_common.c.

Referenced by canvas_pos_to_nearest_tile(), canvas_pos_to_tile(), and tile_to_canvas_pos().

## ◆ base_set_mapview_origin()

static void base_set_mapview_origin | ( | float | gui_x0,
|  | float | gui_y0,
|  | float | zoom
| ) |  |

static

Move the GUI origin to the given normalized, clipped origin. This may be called many times when sliding the mapview.

Definition at line 874 of file mapview_common.c.

Referenced by set_mapview_origin().

## ◆ battle_animation()

static bool battle_animation | ( | struct animation * | anim,
|  | double | time_gone
| ) |  |

static

Progress animation of type 'battle'

Definition at line 288 of file mapview_common.c.

Referenced by update_animation().

## ◆ calc_mapview_origin()

static bool calc_mapview_origin | ( | float * | gui_x0,
|  | float * | gui_y0,
|  | float | zoom
| ) |  |

static

Adjust mapview origin values. Returns TRUE iff values are different from current mapview.

Definition at line 978 of file mapview_common.c.

Referenced by map_canvas_resized(), and set_mapview_origin().

## ◆ can_do_cached_drawing()

static bool can_do_cached_drawing | ( | void |  | ) |

static

Returns TRUE if cached drawing is possible. If the mapview is too large we have to turn it off.

Definition at line 3201 of file mapview_common.c.

Referenced by map_canvas_resized(), and mapdeco_init().

## ◆ canvas_pos_to_nearest_tile()

struct tile * canvas_pos_to_nearest_tile | ( | float | canvas_x,
|  | float | canvas_y,
|  | float | zoom
| ) |  |

Finds the tile corresponding to pixel coordinates. Returns that tile, or the one nearest is the position is off the map. Will never return NULL.

Definition at line 780 of file mapview_common.c.

Referenced by anchor_selection_rectangle(), get_center_tile_mapcanvas(), recenter_button_pressed(), and update_selection_rectangle().

## ◆ canvas_pos_to_tile()

struct tile * canvas_pos_to_tile | ( | float | canvas_x,
|  | float | canvas_y,
|  | float | zoom
| ) |  |

Finds the tile corresponding to pixel coordinates. Returns that tile, or NULL if the position is off the map.

Definition at line 763 of file mapview_common.c.

Referenced by action_button_pressed(), adjust_workers_button_pressed(), butt_down_mapcanvas(), button_down_on_map(), button_up_on_map(), define_tiles_within_rectangle(), editor_end_selection_rectangle(), editor_mouse_button_press(), editor_mouse_move(), key_city_overlay(), leave_mapcanvas(), left_butt_down_mapcanvas(), main_finger_down_handler(), main_mouse_button_down_handler(), main_mouse_motion_handler(), maybe_activate_keyboardless_goto(), middle_butt_down_mapcanvas(), mouse_scroll_mapcanvas(), mouse_scroll_mapcanvas(), map_view::mouseMoveEvent(), move_mapcanvas(), move_mapcanvas(), popup_find_dialog(), popupinfo_positioning_callback(), release_goto_button(), right_butt_down_mapcanvas(), map_view::shortcut_pressed(), update_line(), and wakeup_button_pressed().

## ◆ center_tile_mapcanvas()

void center_tile_mapcanvas | ( | const struct tile * | ptile | ) |

Centers the mapview around ptile.

Definition at line 1237 of file mapview_common.c.

Referenced by act_sel_location_callback(), activate_and_exit_units_orders_city_dlg_callback(), chatwdg::anchor_clicked(), auto_center_on_focus_unit(), butt_down_overviewcanvas(), city_widget::center(), center_iterate(), center_next_enemy_city(), center_next_player_capital(), center_next_player_city(), center_on_something(), city_widget::city_view(), goto_dialog::close_dlg(), cycle_enemy_units(), do_move_unit(), event_after(), event_after(), exit_find_city_dlg_callback(), find_city_callback(), find_destroy_callback(), find_selection_callback(), goto_cmd_callback(), goto_selection_callback(), notify_goto::goto_tile(), handle_unit_combat_info(), goto_dialog::item_selected(), key_center_capital(), meswin_goto(), meswin_popup_city(), minimap_window_callback(), hud_unit_combat::mousePressEvent(), minimap_view::mousePressEvent(), city_dialog::next_city(), notify_goto_dialog_goto_callback(), notify_goto_response(), popup_iterate(), city_dialog::prev_city(), recenter_button_pressed(), request_center_focus_unit(), right_butt_down_overviewcanvas(), select_unit_image_callback(), select_unit_pic_callback(), switch_city_callback(), themespec_reread(), tilespec_reread(), unit_center_callback(), unit_center_callback(), unit_focus_advance(), units_orders_city_dlg_callback(), units_report_command_callback(), usdlg_cmd_center(), and usdlg_tile().

## ◆ client_infratile()

struct tile * client_infratile | ( | void |  | ) |

Return currently selected infratile, if any

Definition at line 4070 of file mapview_common.c.

Referenced by fill_sprite_array().

## ◆ client_infratile_set()

void client_infratile_set | ( | struct tile * | ptile | ) |

Select specific infratile

Definition at line 4078 of file mapview_common.c.

Referenced by infra_placement_set_tile(), and infra_response_callback().

## ◆ decrease_unit_hp_smooth()

void decrease_unit_hp_smooth | ( | struct unit * | punit0,
|  | int | hp0,
|  | struct unit * | punit1,
|  | int | hp1
| ) |  |

This function is called to decrease a unit's HP smoothly in battle when combat_animation is turned on.

Definition at line 2519 of file mapview_common.c.

Referenced by handle_unit_combat_info().

## ◆ describe_topology()

const char * describe_topology | ( | int | topo | ) |

Return string describing topology id.

Definition at line 4044 of file mapview_common.c.

Referenced by handle_map_info(), and tilespec_reread().

## ◆ draw_segment()

void draw_segment | ( | struct tile * | src_tile,
|  | enum direction8 | dir
| ) |  |

Draw a goto line at the given location and direction. The line goes from the source tile to the adjacent tile in the given direction.

Definition at line 2481 of file mapview_common.c.

Referenced by update_map_canvas().

## ◆ draw_trade_route_line()

static void draw_trade_route_line | ( | const struct tile * | ptile1,
|  | const struct tile * | ptile2,
|  | enum color_std | color
| ) |  |

static

Draw a colored trade route line from one tile to another.

Definition at line 1640 of file mapview_common.c.

Referenced by draw_trade_routes_for_city().

## ◆ draw_trade_routes()

static void draw_trade_routes | ( | void |  | ) |

static

Draw trade routes between cities as lines on the main map canvas.

Definition at line 1698 of file mapview_common.c.

Referenced by update_map_canvas().

## ◆ draw_trade_routes_for_city()

static void draw_trade_routes_for_city | ( | const struct city * | pcity_src | ) |

static

Draw all trade routes for the given city.

Definition at line 1681 of file mapview_common.c.

Referenced by draw_trade_routes().

## ◆ explosion_animation()

static bool explosion_animation | ( | struct animation * | anim,
|  | double | time_gone
| ) |  |

static

Progress animation of type 'explosion'

Definition at line 348 of file mapview_common.c.

Referenced by update_animation().

## ◆ find_city_near_tile()

struct city * find_city_near_tile | ( | const struct tile * | ptile | ) |

Find the nearest/best city that owns the tile.

Definition at line 2864 of file mapview_common.c.

Referenced by adjust_workers_button_pressed().

## ◆ find_city_or_settler_near_tile()

struct city * find_city_or_settler_near_tile | ( | const struct tile * | ptile,
|  | struct unit ** | punit
| ) |  |

Find the "best" city/settlers to associate with the selected tile. a. If a visible city is working the tile, return that city. b. If another player's city is working the tile, return NULL. c. If any selected cities are within range, return the closest one. d. If any cities are within range, return the closest one. e. If any active (with color) settler could work it if they founded a city, choose the closest one (only if punit != NULL). f. If any settler could work it if they founded a city, choose the closest one (only if punit != NULL). g. If nobody can work it, return NULL.

Definition at line 2774 of file mapview_common.c.

Referenced by fill_city_overlays_sprite_array(), find_city_near_tile(), and key_city_overlay().

## ◆ free_mapcanvas_and_overview()

void free_mapcanvas_and_overview | ( | void |  | ) |

Frees resources allocated for mapview and overview.

Definition at line 3663 of file mapview_common.c.

Referenced by fc_client::fc_main(), ui_main(), and ui_main().

## ◆ get_center_tile_mapcanvas()

struct tile * get_center_tile_mapcanvas | ( | void |  | ) |

Finds the current center tile of the mapcanvas.

Definition at line 1227 of file mapview_common.c.

Referenced by anchor_selection_rectangle(), create_goto_dialog(), find_a_focus_unit_tile_to_center_on(), find_best_focus_candidate(), goto_dialog::init(), popup_find_dialog(), property_page_create_objects(), themespec_reread(), tilespec_reread(), units_report_command_callback(), update_selection_rectangle(), and usdlg_tile().

## ◆ get_city_mapview_name_and_growth()

void get_city_mapview_name_and_growth | ( | struct city * | pcity,
|  | char * | name_buffer,
|  | size_t | name_buffer_len,
|  | char * | growth_buffer,
|  | size_t | growth_buffer_len,
|  | enum color_std * | growth_color,
|  | enum color_std * | production_color
| ) |  |

Fill the two buffers which information about the city which is shown below it. It does not take draw_city_names/draw_city_growth into account.

Definition at line 3156 of file mapview_common.c.

Referenced by show_full_citybar(), and show_small_citybar().

## ◆ get_city_mapview_production()

void get_city_mapview_production | ( | struct city * | pcity,
|  | char * | buffer,
|  | size_t | buffer_len
| ) |  |

Find the mapview city production text for the given city, and place it into the buffer.

Definition at line 2893 of file mapview_common.c.

Referenced by show_full_citybar(), and show_small_citybar().

## ◆ get_city_mapview_trade_routes()

void get_city_mapview_trade_routes | ( | struct city * | pcity,
|  | char * | trade_routes_buffer,
|  | size_t | trade_routes_buffer_len,
|  | enum color_std * | pcolor
| ) |  |

Find the mapview city trade routes text for the given city, and place it into the buffer. Sets 'pcolor' to the preferred color the text should be drawn in if it is non-NULL.

Definition at line 2919 of file mapview_common.c.

Referenced by show_full_citybar(), and show_small_citybar().

## ◆ get_mapview_scroll_pos()

void get_mapview_scroll_pos | ( | int * | scroll_x,
|  | int * | scroll_y
| ) |  |

Find the current scroll position (origin) of the mapview.

Definition at line 1206 of file mapview_common.c.

Referenced by mouse_scroll_mapcanvas(), mouse_scroll_mapcanvas(), scrollbar_jump_callback(), tile_visible_and_not_on_border_mapcanvas(), and update_map_canvas_scrollbars().

## ◆ get_mapview_scroll_step()

void get_mapview_scroll_step | ( | int * | xstep,
|  | int * | ystep
| ) |  |

Find the scroll step for the mapview. This is the amount to scroll (in scroll coordinates) on each "step". See also get_mapview_scroll_window().

Definition at line 1192 of file mapview_common.c.

Referenced by mouse_scroll_mapcanvas(), mouse_scroll_mapcanvas(), and update_map_canvas_scrollbars_size().

## ◆ get_mapview_scroll_window()

void get_mapview_scroll_window | ( | float * | xmin,
|  | float * | ymin,
|  | float * | xmax,
|  | float * | ymax,
|  | int * | xsize,
|  | int * | ysize
| ) |  |

Return the scroll dimensions of the clipping window for the mapview window..

Imagine the entire map in scroll coordinates. It is a rectangle. Now imagine the mapview "window" sliding around through this rectangle. How far can it slide? In most cases it has to be able to slide past the ends of the map rectangle so that it's capable of reaching the whole area.

This function gives constraints on how far the window is allowed to slide. xmin and ymin are the minimum values for the window origin. xsize and ysize give the scroll dimensions of the mapview window. xmax and ymax give the maximum values that the bottom/left ends of the window may reach. The constraints, therefore, are that:

get_mapview_scroll_pos(&scroll_x, &scroll_y); xmin <= scroll_x < xmax - xsize ymin <= scroll_y < ymax - ysize

This function should be used anywhere and everywhere that scrolling is constrained.

Note that scroll coordinates, not map coordinates, are used. Currently these correspond to native coordinates.

Definition at line 1108 of file mapview_common.c.

Referenced by calc_mapview_origin(), tile_visible_and_not_on_border_mapcanvas(), and update_map_canvas_scrollbars_size().

## ◆ get_spaceship_dimensions()

void get_spaceship_dimensions | ( | int * | width,
|  | int * | height
| ) |  |

Return the desired width of the spaceship canvas.

Definition at line 3672 of file mapview_common.c.

Referenced by create_spaceship_dialog(), and ss_report::ss_report().

## ◆ gotoline_counter_destroy()

static void gotoline_counter_destroy | ( | struct gotoline_counter * | pglc | ) |

static

Create a new goto line counter.

Definition at line 495 of file mapview_common.c.

## ◆ gotoline_counter_new()

static struct gotoline_counter * gotoline_counter_new | ( | void |  | ) |

inlinestatic

Create a new goto line counter.

Definition at line 486 of file mapview_common.c.

Referenced by mapdeco_add_gotoline().

## ◆ gui_distance_vector()

static void gui_distance_vector | ( | const struct tileset * | t,
|  | float | zoom,
|  | float * | gui_dx,
|  | float * | gui_dy,
|  | float | gui_x0,
|  | float | gui_y0,
|  | float | gui_x1,
|  | float | gui_y1
| ) |  |

static

Find the vector with minimum "real" distance between two GUI positions. This corresponds to map_to_distance_vector but works for GUI coordinates.

Definition at line 830 of file mapview_common.c.

Referenced by base_set_mapview_origin(), and set_mapview_origin().

## ◆ gui_to_map_pos()

static void gui_to_map_pos | ( | const struct tileset * | t,
|  | float | zoom,
|  | int * | map_x,
|  | int * | map_y,
|  | float | gui_x,
|  | float | gui_y
| ) |  |

static

Translate from gui to map coordinate systems. See map_to_gui_pos().

Note that you lose some information in this conversion. If you convert from a gui position to a map position and back, you will probably not get the same value you started with.

Definition at line 607 of file mapview_common.c.

Referenced by base_canvas_to_map_pos(), gui_distance_vector(), and normalize_gui_pos().

## ◆ init_mapcanvas_and_overview()

void init_mapcanvas_and_overview | ( | void |  | ) |

Sets up data for the mapview and overview.

Definition at line 3654 of file mapview_common.c.

Referenced by activate_gui(), fc_client::init(), ui_main(), and ui_main().

## ◆ link_mark_add_new()

void link_mark_add_new | ( | enum text_link_type | type,
|  | int | id
| ) |  |

Add a visible link for 2 turns.

Definition at line 3956 of file mapview_common.c.

Referenced by handle_event().

## ◆ link_mark_color()

static struct color * link_mark_color | ( | const struct link_mark * | pmark | ) |

static

Returns the color of the pointed mark.

Definition at line 3835 of file mapview_common.c.

Referenced by link_mark_draw().

## ◆ link_mark_destroy()

static void link_mark_destroy | ( | struct link_mark * | pmark | ) |

static

Remove a link mark.

Definition at line 3804 of file mapview_common.c.

Referenced by link_marks_init().

## ◆ link_mark_draw()

static void link_mark_draw | ( | const struct link_mark * | pmark | ) |

static

Print a link mark.

Definition at line 3852 of file mapview_common.c.

Referenced by link_marks_draw_all().

## ◆ link_mark_find()

static struct link_mark * link_mark_find | ( | enum text_link_type | type,
|  | int | id
| ) |  |

static

Find a link mark in the list.

Definition at line 3775 of file mapview_common.c.

Referenced by link_mark_add_new(), and link_mark_restore().

## ◆ link_mark_new()

static struct link_mark * link_mark_new | ( | enum text_link_type | type,
|  | int | id,
|  | int | turns
| ) |  |

static

Create a new link mark.

Definition at line 3789 of file mapview_common.c.

Referenced by link_mark_add_new(), and link_mark_restore().

## ◆ link_mark_restore()

void link_mark_restore | ( | enum text_link_type | type,
|  | int | id
| ) |  |

Add a visible link for 1 turn.

Definition at line 3978 of file mapview_common.c.

Referenced by chatwdg::anchor_clicked(), event_after(), and event_after().

## ◆ link_mark_tile()

static struct tile * link_mark_tile | ( | const struct link_mark * | pmark | ) |

static

Returns the location of the pointed mark.

Definition at line 3812 of file mapview_common.c.

Referenced by link_mark_add_new(), link_mark_draw(), and link_mark_restore().

## ◆ link_marks_clear_all()

void link_marks_clear_all | ( | void |  | ) |

Clear all visible links.

Definition at line 3933 of file mapview_common.c.

Referenced by chatwdg::rm_links(), and setup_widgets().

## ◆ link_marks_decrease_turn_counters()

void link_marks_decrease_turn_counters | ( | void |  | ) |

Clear all visible links.

Definition at line 3942 of file mapview_common.c.

Referenced by handle_new_year().

## ◆ link_marks_draw_all()

void link_marks_draw_all | ( | void |  | ) |

Draw all link marks.

Definition at line 3923 of file mapview_common.c.

Referenced by update_map_canvas().

## ◆ link_marks_free()

void link_marks_free | ( | void |  | ) |

Free the link marks.

Definition at line 3910 of file mapview_common.c.

Referenced by client_game_free(), client_game_reset(), and link_marks_init().

## ◆ link_marks_init()

void link_marks_init | ( | void |  | ) |

Initialize the link marks.

Definition at line 3898 of file mapview_common.c.

Referenced by client_game_init(), and client_game_reset().

## ◆ map_canvas_resized()

bool map_canvas_resized | ( | int | width,
|  | int | height
| ) |  |

Called if the map in the GUI is resized.

Returns TRUE iff the canvas was redrawn.

Definition at line 3563 of file mapview_common.c.

Referenced by init_mapcanvas_and_overview(), map_canvas_configure(), map_canvas_size_refresh(), overview_size_changed(), real_resize_window_callback(), fc_game_tab_widget::resizeEvent(), mr_menu::save_image(), zoom_1_0(), and zoom_set().

## ◆ map_to_gui_pos()

static void map_to_gui_pos | ( | const struct tileset * | t,
|  | float | zoom,
|  | float * | gui_x,
|  | float * | gui_y,
|  | int | map_x,
|  | int | map_y
| ) |  |

static

Translate from map to gui coordinate systems.

GUI coordinates are comparable to canvas coordinates but extend in all directions. gui(0,0) == map(0,0).

Definition at line 592 of file mapview_common.c.

Referenced by center_tile_mapcanvas(), get_mapview_scroll_window(), gui_distance_vector(), map_canvas_resized(), normalize_gui_pos(), tile_to_canvas_pos(), and trade_route_to_canvas_lines().

## ◆ map_to_gui_vector()

void map_to_gui_vector | ( | const struct tileset * | t,
|  | float | zoom,
|  | float * | gui_dx,
|  | float * | gui_dy,
|  | int | map_dx,
|  | int | map_dy
| ) |  |

Translate from a cartesian system to the GUI system. This function works on vectors, meaning it can be passed a (dx,dy) pair and will return the change in GUI coordinates corresponding to this vector. It is thus more general than map_to_gui_pos().

Note that a gui_to_map_vector function is not possible, since the resulting map vector may differ based on the origin of the gui vector.

Definition at line 563 of file mapview_common.c.

Referenced by city_to_canvas_pos(), draw_calculated_trade_routes(), draw_segment(), generate_citydlg_dimensions(), map_to_gui_pos(), and move_unit_map_canvas().

## ◆ mapdeco_add_gotoline()

void mapdeco_add_gotoline | ( | const struct tile * | ptile,
|  | enum direction8 | dir
| ) |  |

Add a goto line from the given tile 'ptile' in the direction 'dir'. If there was no previously drawn line there, a mapview update is queued for the source and destination tiles.

Definition at line 3415 of file mapview_common.c.

Referenced by goto_path_redraw(), and mapdeco_set_gotoroute().

## ◆ mapdeco_clear_crosshairs()

void mapdeco_clear_crosshairs | ( | void |  | ) |

Clears all previous set tile crosshair decorations. Marks the affected tiles as needing a mapview update.

Definition at line 3397 of file mapview_common.c.

Referenced by fc_client::popdown_tile_info(), and popupinfo_popdown_callback().

## ◆ mapdeco_clear_gotoroutes()

void mapdeco_clear_gotoroutes | ( | void |  | ) |

Clear all goto line map decorations and queues mapview updates for the affected tiles.

Definition at line 3541 of file mapview_common.c.

Referenced by fc_client::popdown_tile_info(), and popupinfo_popdown_callback().

## ◆ mapdeco_clear_highlights()

void mapdeco_clear_highlights | ( | void |  | ) |

Clears all highlighting. Marks the previously highlighted tiles as needing a mapview update.

Definition at line 3346 of file mapview_common.c.

Referenced by cancel_tile_hiliting().

## ◆ mapdeco_free()

void mapdeco_free | ( | void |  | ) |

Free all memory used for map decorations.

Definition at line 3291 of file mapview_common.c.

Referenced by mapdeco_init().

## ◆ mapdeco_init()

void mapdeco_init | ( | void |  | ) |

Called when we receive map dimensions. It initialized the mapview decorations.

Definition at line 3277 of file mapview_common.c.

Referenced by handle_map_info().

## ◆ mapdeco_is_crosshair_set()

bool mapdeco_is_crosshair_set | ( | const struct tile * | ptile | ) |

Returns TRUE if there is a "crosshair" decoration set at the given tile.

Definition at line 3385 of file mapview_common.c.

Referenced by fill_sprite_array().

## ◆ mapdeco_is_gotoline_set()

bool mapdeco_is_gotoline_set | ( | const struct tile * | ptile,
|  | enum direction8 | dir
| ) |  |

Returns TRUE if a goto line should be drawn from the given tile in the given direction.

Definition at line 3520 of file mapview_common.c.

Referenced by update_map_canvas().

## ◆ mapdeco_is_highlight_set()

bool mapdeco_is_highlight_set | ( | const struct tile * | ptile | ) |

Return TRUE if the given tile is highlighted.

Definition at line 3334 of file mapview_common.c.

Referenced by fill_grid_sprite_array(), find_city_or_settler_near_tile(), is_city_hilited(), and toggle_tile_hilite().

## ◆ mapdeco_remove_gotoline()

void mapdeco_remove_gotoline | ( | const struct tile * | ptile,
|  | enum direction8 | dir
| ) |  |

Removes a goto line from the given tile 'ptile' going in the direction 'dir'. If this was the last line there, a mapview update is queued to erase the drawn line.

Definition at line 3449 of file mapview_common.c.

Referenced by goto_path_redraw(), and goto_path_undraw().

## ◆ mapdeco_set_crosshair()

void mapdeco_set_crosshair | ( | const struct tile * | ptile,
|  | bool | crosshair
| ) |  |

Marks the given tile as having a "crosshair" map decoration.

Definition at line 3362 of file mapview_common.c.

Referenced by popit(), popit(), and fc_client::popup_tile_info().

## ◆ mapdeco_set_gotoroute()

void mapdeco_set_gotoroute | ( | const struct unit * | punit | ) |

Set the map decorations for the given unit's goto route. A goto route consists of one or more goto lines, with each line being from the center of one tile to the center of another tile.

Definition at line 3485 of file mapview_common.c.

Referenced by popit(), popit(), and fc_client::popup_tile_info().

## ◆ mapdeco_set_highlight()

void mapdeco_set_highlight | ( | const struct tile * | ptile,
|  | bool | highlight
| ) |  |

Set the given tile's map decoration as either highlighted or not, depending on the value of 'highlight'.

Definition at line 3311 of file mapview_common.c.

Referenced by define_tiles_within_rectangle(), and toggle_tile_hilite().

## ◆ move_unit_map_canvas()

void move_unit_map_canvas | ( | struct unit * | punit,
|  | struct tile * | src_tile,
|  | int | dx,
|  | int | dy
| ) |  |

Animates punit's "smooth" move from (x0, y0) to (x0 + dx, y0 + dy). Note: Works only for adjacent-tile moves.

Definition at line 2655 of file mapview_common.c.

Referenced by do_move_unit().

## ◆ movement_animation()

static bool movement_animation | ( | struct animation * | anim,
|  | double | time_gone
| ) |  |

static

Progress animation of type 'movement'

Definition at line 246 of file mapview_common.c.

Referenced by update_animation().

## ◆ normalize_gui_pos()

static void normalize_gui_pos | ( | const struct tileset * | t,
|  | float | zoom,
|  | float * | gui_x,
|  | float * | gui_y
| ) |  |

static

Normalize (wrap) the GUI position. This is equivalent to a map wrapping, but in GUI coordinates so that pixel accuracy is preserved.

Definition at line 794 of file mapview_common.c.

Referenced by base_set_mapview_origin(), calc_mapview_origin(), and gui_distance_vector().

## ◆ nuke_animation()

static bool nuke_animation | ( | struct animation * | anim,
|  | double | time_gone
| ) |  |

static

Progress animation of type 'nuke'

Definition at line 400 of file mapview_common.c.

Referenced by update_animation().

## ◆ put_city()

void put_city | ( | struct city * | pcity,
|  | struct canvas * | pcanvas,
|  | float | zoom,
|  | int | canvas_x,
|  | int | canvas_y
| ) |  |

Draw the given city onto the canvas store at the given location. The area of drawing is tileset_full_tile_height(tileset) x tileset_full_tile_width(tileset).

Definition at line 1418 of file mapview_common.c.

## ◆ put_drawn_sprites()

void put_drawn_sprites | ( | struct canvas * | pcanvas,
|  | float | zoom,
|  | int | canvas_x,
|  | int | canvas_y,
|  | int | count,
|  | struct drawn_sprite * | pdrawn,
|  | bool | fog
| ) |  |

Draw an array of drawn sprites onto the canvas.

Definition at line 1328 of file mapview_common.c.

Referenced by create_extra_pixbuf(), create_terrain_pixbuf(), put_one_element(), set_help_tile_from_extra(), set_help_tile_from_terrain(), help_widget::set_topic_extra(), and terrain_canvas().

## ◆ put_nuke_mushroom_pixmaps()

void put_nuke_mushroom_pixmaps | ( | struct tile * | ptile | ) |

Animate the nuke explosion at map(x, y).

Definition at line 1525 of file mapview_common.c.

Referenced by handle_nuke_tile_info().

## ◆ put_one_element()

void put_one_element | ( | struct canvas * | pcanvas,
|  | float | zoom,
|  | enum mapview_layer | layer,
|  | const struct tile * | ptile,
|  | const struct tile_edge * | pedge,
|  | const struct tile_corner * | pcorner,
|  | const struct unit * | punit,
|  | const struct city * | pcity,
|  | int | canvas_x,
|  | int | canvas_y,
|  | const struct city * | citymode,
|  | const struct unit_type * | putype
| ) |  |

Draw one layer of a tile, edge, corner, unit, and/or city onto the canvas at the given position.

Definition at line 1364 of file mapview_common.c.

Referenced by city_dialog_redraw_map(), create_pixbuf_from_layers(), put_city(), put_one_tile(), put_terrain(), put_unit(), put_unittype(), and update_map_canvas().

## ◆ put_one_tile()

static void put_one_tile | ( | struct canvas * | pcanvas,
|  | enum mapview_layer | layer,
|  | struct tile * | ptile,
|  | int | canvas_x,
|  | int | canvas_y,
|  | const struct city * | citymode
| ) |  |

static

Draw some or all of a tile onto the canvas.

Definition at line 1576 of file mapview_common.c.

Referenced by update_map_canvas().

## ◆ put_spaceship()

void put_spaceship | ( | struct canvas * | pcanvas,
|  | int | canvas_x,
|  | int | canvas_y,
|  | const struct player * | pplayer
| ) |  |

Draw the spaceship onto the canvas.

Definition at line 3685 of file mapview_common.c.

Referenced by spaceship_image_canvas_draw(), spaceship_image_canvas_expose(), and ss_report::update_report().

## ◆ put_terrain()

void put_terrain | ( | struct tile * | ptile,
|  | struct canvas * | pcanvas,
|  | float | zoom,
|  | int | canvas_x,
|  | int | canvas_y
| ) |  |

Draw the given tile terrain onto the canvas store at the given location. The area of drawing is tileset_full_tile_height(tileset) x tileset_full_tile_width(tileset) (even though most tiles are not this tall).

Definition at line 1435 of file mapview_common.c.

Referenced by get_terrain_surface(), and hud_units::update_actions().

## ◆ put_unit()

void put_unit | ( | const struct unit * | punit,
|  | struct canvas * | pcanvas,
|  | float | zoom,
|  | int | canvas_x,
|  | int | canvas_y
| ) |  |

Draw the given unit onto the canvas store at the given location. The area of drawing is tileset_unit_height(tileset) x tileset_unit_width(tileset).

Definition at line 1389 of file mapview_common.c.

Referenced by battle_animation(), units_select::create_pixmap(), create_unit_surface(), hud_unit_combat::init_images(), move_unit_map_canvas(), movement_animation(), choice_dialog::next_unit(), choice_dialog::prev_unit(), put_unit_image(), put_unit_image_city_overlays(), put_unit_picture(), put_unit_picture_city_overlays(), redraw_unit_info_label(), choice_dialog::set_layout(), unit_item::unit_item(), hud_units::update_actions(), and usdlg_get_unit_image().

## ◆ put_unit_city_overlays()

void put_unit_city_overlays | ( | struct unit * | punit,
|  | struct canvas * | pcanvas,
|  | int | canvas_x,
|  | int | canvas_y,
|  | int * | upkeep_cost,
|  | int | happy_cost
| ) |  |

Draw food, gold, and shield upkeep values on the unit.

The proper way to do this is probably something like what Civ II does (one sprite drawn N times on top of itself), but we just use separate sprites (limiting the number of combinations).

Definition at line 1453 of file mapview_common.c.

Referenced by put_unit_image_city_overlays(), put_unit_picture_city_overlays(), and unit_item::unit_item().

## ◆ put_unittype()

void put_unittype | ( | const struct unit_type * | putype,
|  | struct canvas * | pcanvas,
|  | float | zoom,
|  | int | canvas_x,
|  | int | canvas_y
| ) |  |

Draw the given unit onto the canvas store at the given location. The area of drawing is tileset_unit_height(tileset) x tileset_unit_width(tileset).

Definition at line 1403 of file mapview_common.c.

Referenced by hud_unit_combat::init_images(), help_widget::set_topic_unit(), and usdlg_tab_append_utype().

## ◆ queue_add_callback()

static void queue_add_callback | ( | void |  | ) |

static

When a mapview update is queued this function should be called to prepare an idle-time callback to unqueue the updates.

Definition at line 2982 of file mapview_common.c.

Referenced by queue_mapview_tile_update(), and queue_mapview_update().

## ◆ queue_callback()

static void queue_callback | ( | void * | data | ) |

static

This callback is called during an idle moment to unqueue any pending mapview updates.

Definition at line 2972 of file mapview_common.c.

Referenced by queue_add_callback().

## ◆ queue_mapview_tile_update()

void queue_mapview_tile_update | ( | struct tile * | ptile,
|  | enum tile_update_type | type
| ) |  |

static

Queue this tile to be refreshed. The refresh will be done some time soon thereafter, and grouped with other needed refreshes.

Note this should only be called for tiles. For cities or units use queue_mapview_xxx_update() instead.

Definition at line 3022 of file mapview_common.c.

Referenced by refresh_city_mapcanvas(), refresh_tile_mapcanvas(), refresh_unit_mapcanvas(), update_city_description(), and update_tile_label().

## ◆ queue_mapview_update()

void queue_mapview_update | ( | enum update_type | update | ) |

static

This function, along with unqueue_mapview_update(), helps in updating the mapview when a packet is received. Previously, we just called update_map_canvas() when (for instance) a city update was received. Not only would this often end up with a lot of duplicated work, but it would also draw over the city descriptions, which would then just "disappear" from the mapview. The hack is to instead call queue_mapview_update in place of this update, and later (after all packets have been read) call unqueue_mapview_update(). The functions don't track which areas of the screen need updating, rather when the unqueue is done we just update the whole visible mapqueue, and redraw the city descriptions.

Using these functions, updates are done correctly, and are probably faster too. But it's a bit of a hack to insert this code into the packet-handling code.

Definition at line 3007 of file mapview_common.c.

Referenced by refresh_unit_mapcanvas(), and update_map_canvas_visible().

## ◆ refresh_city_mapcanvas()

void refresh_city_mapcanvas | ( | struct city * | pcity,
|  | struct tile * | ptile,
|  | bool | full_refresh,
|  | bool | write_to_screen
| ) |  |

Refreshes a single city on the map canvas.

If full_refresh is given then the citymap area and the city text will also be refreshed. Otherwise only the base city sprite is refreshed.

Definition at line 541 of file mapview_common.c.

Referenced by city_packet_common(), client_remove_city(), handle_unit_packet_common(), and toggle_city_color().

## ◆ refresh_tile_mapcanvas()

void refresh_tile_mapcanvas | ( | struct tile * | ptile,
|  | bool | full_refresh,
|  | bool | write_to_screen
| ) |  |

Refreshes a single tile on the map canvas.

Definition at line 504 of file mapview_common.c.

Referenced by client_infratile_set(), editor_end_selection_rectangle(), goto_add_waypoint(), handle_edit_startpos(), handle_edit_startpos_full(), handle_tile_info(), link_mark_add_new(), link_mark_restore(), mapdeco_add_gotoline(), mapdeco_clear_crosshairs(), mapdeco_clear_gotoroutes(), mapdeco_clear_highlights(), mapdeco_remove_gotoline(), mapdeco_set_crosshair(), and mapdeco_set_highlight().

## ◆ refresh_unit_mapcanvas()

void refresh_unit_mapcanvas | ( | struct unit * | punit,
|  | struct tile * | ptile,
|  | bool | full_refresh,
|  | bool | write_to_screen
| ) |  |

Refreshes a single unit on the map canvas.

Definition at line 520 of file mapview_common.c.

Referenced by blink_active_unit(), client_remove_unit(), current_focus_append(), current_focus_remove(), decrease_unit_hp_smooth(), do_move_unit(), handle_unit_combat_info(), handle_unit_packet_common(), key_unit_assign_battlegroup(), toggle_unit_color(), and unit_focus_set().

## ◆ set_frame_by_frame_animation()

void set_frame_by_frame_animation | ( | void |  | ) |

Set frame by frame animation mode on.

Definition at line 4062 of file mapview_common.c.

Referenced by ui_init().

## ◆ set_mapview_origin()

void set_mapview_origin | ( | float | gui_x0,
|  | float | gui_y0,
|  | float | zoom
| ) |  |

Change the mapview origin, clip it, and update everything.

Definition at line 1008 of file mapview_common.c.

Referenced by center_tile_mapcanvas(), scroll_mapview(), and set_mapview_scroll_pos().

## ◆ set_mapview_scroll_pos()

void set_mapview_scroll_pos | ( | int | scroll_x,
|  | int | scroll_y,
|  | float | zoom
| ) |  |

Set the scroll position (origin) of the mapview, and update the GUI.

Definition at line 1215 of file mapview_common.c.

Referenced by mouse_scroll_mapcanvas(), mouse_scroll_mapcanvas(), and scrollbar_jump_callback().

## ◆ show_city_desc()

static void show_city_desc | ( | struct canvas * | pcanvas,
|  | int | canvas_x,
|  | int | canvas_y,
|  | struct city * | pcity,
|  | int * | width,
|  | int * | height
| ) |  |

static

Draw a description for the given city. This description may include the name, turns-to-grow, production, and city turns-to-build (depending on client options).

(canvas_x, canvas_y) gives the location on the given canvas at which to draw the description. This is the location of the city itself so the text must be drawn underneath it. pcity gives the city to be drawn, while (*width, *height) should be set by show_city_desc() to contain the width and height of the text block (centered directly underneath the city's tile).

Definition at line 2321 of file mapview_common.c.

Referenced by show_city_descriptions().

## ◆ show_city_descriptions()

void show_city_descriptions | ( | int | canvas_base_x,
|  | int | canvas_base_y,
|  | int | width_base,
|  | int | height_base
| ) |  |

Show descriptions for all cities visible on the map canvas.

Definition at line 2363 of file mapview_common.c.

Referenced by update_city_descriptions(), and update_map_canvas().

## ◆ show_full_citybar()

static void show_full_citybar | ( | struct canvas * | pcanvas,
|  | const int | canvas_x0,
|  | const int | canvas_y0,
|  | struct city * | pcity,
|  | int * | width,
|  | int * | height
| ) |  |

static

Draw a "full" city bar for the city. This is a subcase of show_city_desc() (see that function for more info) for tilesets that have a full city bar.

Definition at line 1897 of file mapview_common.c.

Referenced by show_city_desc().

## ◆ show_small_citybar()

static void show_small_citybar | ( | struct canvas * | pcanvas,
|  | int | canvas_x,
|  | int | canvas_y,
|  | struct city * | pcity,
|  | int * | width,
|  | int * | height
| ) |  |

static

Draw a "small" city bar for the city. This is a subcase of show_city_desc() (see that function for more info) for tilesets that do not have a full city bar.

Definition at line 2201 of file mapview_common.c.

Referenced by show_city_desc().

## ◆ show_tile_label()

static void show_tile_label | ( | struct canvas * | pcanvas,
|  | int | canvas_x,
|  | int | canvas_y,
|  | struct tile * | ptile,
|  | int * | width,
|  | int * | height
| ) |  |

static

Draw a label for the given tile.

(canvas_x, canvas_y) gives the location on the given canvas at which to draw the label. This is the location of the tile itself so the text must be drawn underneath it. pcity gives the city to be drawn, while (*width, *height) should be set by show_tile_label() to contain the width and height of the text block (centered directly underneath the city's tile).

Definition at line 2342 of file mapview_common.c.

Referenced by show_tile_labels().

## ◆ show_tile_labels()

void show_tile_labels | ( | int | canvas_base_x,
|  | int | canvas_base_y,
|  | int | width_base,
|  | int | height_base
| ) |  |

Show labels for all tiles visible on the map canvas.

Definition at line 2437 of file mapview_common.c.

Referenced by update_map_canvas().

## ◆ tile_to_canvas_pos()

bool tile_to_canvas_pos | ( | float * | canvas_x,
|  | float * | canvas_y,
|  | float | zoom,
|  | const struct tile * | ptile
| ) |  |

Finds the canvas coordinates for a map position. Beside setting the results in canvas_x, canvas_y it returns whether the tile is inside the visible mapview canvas.

The result represents the upper left pixel (origin) of the bounding box of the tile. Note that in iso-view this origin is not a part of the tile itself - so to make the operation reversible you would have to call canvas_to_map_pos on the center of the tile, not the origin.

The center of a tile is defined as: { tile_to_canvas_pos(&canvas_x, &canvas_y, map_zoom, ptile); canvas_x += tileset_tile_width(tileset) * map_zoom / 2; canvas_y += tileset_tile_height(tileset) * map_zoom / 2; }

This pixel is one position closer to the lower right, which may be important to remember when doing some round-off operations. Other parts of the code assume tileset_tile_width(tileset) and tileset_tile_height(tileset) to be even numbers.

Definition at line 706 of file mapview_common.c.

Referenced by anchor_selection_rectangle(), battle_animation(), info_tile::calc_size(), decrease_unit_hp_smooth(), define_tiles_within_rectangle(), draw_calculated_trade_routes(), draw_segment(), explosion_animation(), link_mark_draw(), move_unit_map_canvas(), movement_animation(), nuke_animation(), popit(), popupinfo_positioning_callback(), put_cross_overlay_tile(), put_nuke_mushroom_pixmaps(), put_window_near_map_tile(), tile_visible_and_not_on_border_mapcanvas(), tile_visible_mapcanvas(), trade_route_to_canvas_lines(), unqueue_mapview_updates(), and update_selection_rectangle().

## ◆ tile_visible_and_not_on_border_mapcanvas()

bool tile_visible_and_not_on_border_mapcanvas | ( | struct tile * | ptile | ) |

Return TRUE iff the given map position has a tile visible within the interior of the map canvas. This information is used to determine when we need to recenter the map canvas.

The logic of this function is simple: if a tile is within 1.5 tiles of a border of the canvas and that border is not aligned with the edge of the map, then the tile is on the "border" of the map canvas.

This function is only correct for the current topology.

Definition at line 1282 of file mapview_common.c.

Referenced by auto_center_on_focus_unit(), do_move_unit(), and unit_focus_advance().

## ◆ tile_visible_mapcanvas()

bool tile_visible_mapcanvas | ( | struct tile * | ptile | ) |

Return TRUE iff the given map position has a tile visible on the map canvas.

Definition at line 1264 of file mapview_common.c.

Referenced by handle_unit_combat_info(), link_mark_add_new(), link_mark_restore(), and move_unit_map_canvas().

## ◆ tileset_map_topo_compatible()

enum topo_comp_lvl tileset_map_topo_compatible | ( | int | topology_id,
|  | struct tileset * | tset,
|  | int * | tset_topo
| ) |  |

Are the topology and tileset compatible?

Definition at line 3998 of file mapview_common.c.

Referenced by handle_map_info(), handle_set_topology(), and tilespec_reread().

## ◆ toggle_city_color()

void toggle_city_color | ( | struct city * | pcity | ) |

Toggle the city color. This cycles through the possible colors for the citymap as shown on the mapview. These colors are listed in the city_colors array; above.

Definition at line 1491 of file mapview_common.c.

Referenced by key_city_overlay().

## ◆ toggle_unit_color()

void toggle_unit_color | ( | struct unit * | punit | ) |

Toggle the unit color. This cycles through the possible colors for the citymap as shown on the mapview. These colors are listed in the city_colors array; above.

Definition at line 1509 of file mapview_common.c.

Referenced by key_city_overlay().

## ◆ trade_route_to_canvas_lines()

static int trade_route_to_canvas_lines | ( | const struct tile * | ptile1,
|  | const struct tile * | ptile2,
|  | struct trade_route_line * | lines
| ) |  |

static

Depending on where ptile1 and ptile2 are on the map canvas, a trade route line may need to be drawn as two disjointed line segments. This function fills the given line array 'lines' with the necessary line segments.

The return value is the number of line segments that need to be drawn.

NB: It is assumed ptile1 and ptile2 are already consistently ordered. NB: 'lines' must be able to hold least MAX_TRADE_ROUTE_DRAW_LINES elements.

Definition at line 1610 of file mapview_common.c.

Referenced by draw_trade_route_line().

## ◆ unqueue_mapview_updates()

void unqueue_mapview_updates | ( | bool | write_to_screen | ) |

See comment for queue_mapview_update().

Definition at line 3037 of file mapview_common.c.

Referenced by decrease_unit_hp_smooth(), map_canvas_draw(), map_canvas_draw(), map_canvas_resized(), move_unit_map_canvas(), put_nuke_mushroom_pixmaps(), queue_callback(), refresh_city_mapcanvas(), refresh_tile_mapcanvas(), refresh_unit_mapcanvas(), and set_mapview_origin().

## ◆ update_animation()

void update_animation | ( | void |  | ) |

Progress current animation

Definition at line 439 of file mapview_common.c.

Referenced by animation_idle_cb(), and map_canvas_draw().

## ◆ update_city_description()

void update_city_description | ( | struct city * | pcity | ) |

Update the city description for the given city.

Definition at line 1880 of file mapview_common.c.

Referenced by do_move_unit(), handle_city_info(), handle_city_short_info(), handle_city_update_counters(), handle_trade_route_info(), handle_unit_packet_common(), and show_city_descriptions().

## ◆ update_map_canvas()

void update_map_canvas | ( | int | canvas_x,
|  | int | canvas_y,
|  | int | width,
|  | int | height
| ) |  |

Update (refresh) the map canvas starting at the given tile (in map coordinates) and with the given dimensions (also in map coordinates).

In non-iso view, this is easy. In iso view, we have to use the Painter's Algorithm to draw the tiles in back first. When we draw a tile, we tell the GUI which part of the tile to draw - which is necessary unless we have an extra buffering step.

After refreshing the backing store tile-by-tile, we write the store out to the display if write_to_screen is specified.

x, y, width, and height are in map coordinates; they need not be normalized or even real.

Definition at line 1736 of file mapview_common.c.

Referenced by base_set_mapview_origin(), editor_end_selection_rectangle(), explosion_animation(), movement_animation(), unqueue_mapview_updates(), and update_animation().

## ◆ update_map_canvas_visible()

void update_map_canvas_visible | ( | void |  | ) |

Update (only) the visible part of the map

Definition at line 1860 of file mapview_common.c.

Referenced by editor_start_selection_rectangle(), handle_city_info(), handle_player_info(), handle_start_phase(), handle_trade_route_info(), link_marks_clear_all(), map_canvas_resized(), nuke_animation(), put_nuke_mushroom_pixmaps(), request_toggle_bases(), request_toggle_cities(), request_toggle_city_buycost(), request_toggle_city_full_bar(), request_toggle_city_growth(), request_toggle_city_names(), request_toggle_city_outlines(), request_toggle_city_output(), request_toggle_city_productions(), request_toggle_city_trade_routes(), request_toggle_coastline(), request_toggle_focus_unit(), request_toggle_fog_of_war(), request_toggle_huts(), request_toggle_irrigation(), request_toggle_map_borders(), request_toggle_map_grid(), request_toggle_map_native(), request_toggle_mines(), request_toggle_paths(), request_toggle_pollution(), request_toggle_resources(), request_toggle_terrain(), request_toggle_unit_shields(), request_toggle_unit_solid_bg(), request_toggle_unit_stack_size(), request_toggle_units(), set_client_state(), themespec_reread(), tilespec_reread(), update_city_descriptions(), and map_view::update_font().

## ◆ update_tile_label()

void update_tile_label | ( | struct tile * | ptile | ) |

Update the label for the given tile

Definition at line 1888 of file mapview_common.c.

Referenced by show_tile_labels().

## Variable Documentation

## ◆ anim_timer

struct timer* anim_timer = NULL

static

Definition at line 128 of file mapview_common.c.

Referenced by anim_timer_renew(), decrease_unit_hp_smooth(), move_unit_map_canvas(), set_mapview_origin(), and update_animation().

## ◆ animations

struct animation_list* animations = NULL

Definition at line 175 of file mapview_common.c.

Referenced by animation_add(), animations_free(), animations_init(), put_one_tile(), and update_animation().

## ◆ callback_queued

bool callback_queued = FALSE

static

Definition at line 2958 of file mapview_common.c.

Referenced by queue_add_callback(), and queue_callback().

## ◆ can_slide

bool can_slide = TRUE

Definition at line 76 of file mapview_common.c.

Referenced by center_on_something(), center_tile_mapcanvas(), find_destroy_callback(), find_selection_callback(), set_client_state(), set_mapview_origin(), set_mapview_scroll_pos(), switch_city_callback(), themespec_reread(), and tilespec_reread().

## ◆ center_tile

const struct tile* center_tile = NULL

Definition at line 80 of file mapview_common.c.

Referenced by center_tile_mapcanvas(), map_canvas_resized(), themespec_reread(), tilespec_reread(), and update_selection_rectangle().

## ◆ color_index

int color_index = 0

static

Definition at line 1482 of file mapview_common.c.

Referenced by toggle_city_color(), and toggle_unit_color().

## ◆ frame_by_frame_animation

bool frame_by_frame_animation = FALSE

static

Definition at line 78 of file mapview_common.c.

Referenced by decrease_unit_hp_smooth(), move_unit_map_canvas(), put_nuke_mushroom_pixmaps(), set_frame_by_frame_animation(), and set_mapview_origin().

## ◆ infratile

struct tile* infratile = NULL

Definition at line 82 of file mapview_common.c.

Referenced by client_infratile(), and client_infratile_set().

## ◆ link_marks

struct link_mark_list* link_marks = NULL

static

Definition at line 3770 of file mapview_common.c.

Referenced by link_mark_add_new(), link_mark_restore(), link_marks_clear_all(), link_marks_decrease_turn_counters(), link_marks_free(), and link_marks_init().

## ◆ mapdeco_crosshair_table

struct tile_hash* mapdeco_crosshair_table

Definition at line 54 of file mapview_common.c.

Referenced by mapdeco_clear_crosshairs(), mapdeco_free(), mapdeco_init(), mapdeco_is_crosshair_set(), and mapdeco_set_crosshair().

## ◆ mapdeco_gotoline_table

struct gotoline_hash* mapdeco_gotoline_table

Definition at line 73 of file mapview_common.c.

Referenced by mapdeco_add_gotoline(), mapdeco_clear_gotoroutes(), mapdeco_free(), mapdeco_init(), mapdeco_is_gotoline_set(), and mapdeco_remove_gotoline().

## ◆ mapdeco_highlight_table

struct tile_hash* mapdeco_highlight_table

Definition at line 53 of file mapview_common.c.

Referenced by mapdeco_clear_highlights(), mapdeco_free(), mapdeco_init(), mapdeco_is_highlight_set(), and mapdeco_set_highlight().

## ◆ mapview

struct view mapview

Definition at line 75 of file mapview_common.c.

Referenced by base_canvas_to_map_pos(), base_set_mapview_origin(), battle_animation(), calc_mapview_origin(), can_do_cached_drawing(), center_tile_mapcanvas(), center_tile_overviewcanvas(), create_line_at_mouse_pos(), decrease_unit_hp_smooth(), draw_segment(), draw_selection_rectangle(), draw_trade_route_line(), minimap_view::draw_viewport(), editor_end_selection_rectangle(), explosion_animation(), flush_mapcanvas(), free_mapcanvas_and_overview(), get_center_tile_mapcanvas(), get_mapview_scroll_pos(), get_mapview_scroll_window(), gui_flush(), leave_mapcanvas(), link_mark_draw(), map_canvas_draw(), map_canvas_draw(), map_canvas_resized(), mapdeco_init(), minimap_view::mouseMoveEvent(), move_unit_map_canvas(), hud_battle_log::moveEvent(), movement_animation(), nuke_animation(), overview_size_changed(), map_view::paint(), popupinfo_positioning_callback(), put_nuke_mushroom_pixmaps(), redraw_overview(), fc_game_tab_widget::resizeEvent(), minimap_view::resizeEvent(), mr_menu::save_image(), minimap_view::scale_point(), scroll_mapview(), set_mapview_origin(), show_city_descriptions(), show_tile_labels(), tile_to_canvas_pos(), tile_visible_and_not_on_border_mapcanvas(), unqueue_mapview_updates(), unscale_point(), update_city_descriptions(), update_map_canvas(), zoom_1_0(), and zoom_set().

## ◆ max_desc_height

int max_desc_height = 0

static

Definition at line 1872 of file mapview_common.c.

Referenced by show_city_descriptions(), and unqueue_mapview_updates().

## ◆ max_desc_width

int max_desc_width = 0

static

Definition at line 1872 of file mapview_common.c.

Referenced by show_city_descriptions(), and unqueue_mapview_updates().

## ◆ max_label_height

int max_label_height = 0

static

Definition at line 1875 of file mapview_common.c.

Referenced by show_tile_labels(), and unqueue_mapview_updates().

## ◆ max_label_width

int max_label_width = 0

static

Definition at line 1875 of file mapview_common.c.

Referenced by popup_load_game_dialog(), show_tile_labels(), and unqueue_mapview_updates().

## ◆ MAX_TRADE_ROUTE_DRAW_LINES

const int MAX_TRADE_ROUTE_DRAW_LINES = 2

static

Definition at line 126 of file mapview_common.c.

Referenced by draw_trade_route_line().

## ◆ needed_updates

enum update_type needed_updates = UPDATE_NONE

static

Definition at line 2957 of file mapview_common.c.

Referenced by queue_mapview_update(), and unqueue_mapview_updates().

## ◆ tile_updates

struct tile_list* tile_updates[TILE_UPDATE_COUNT]

Definition at line 2966 of file mapview_common.c.

Referenced by queue_mapview_tile_update(), and unqueue_mapview_updates().