Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/mapctrl_common.c Source File

Freeciv-3.1

Loading...
Searching...
No Matches
mapctrl_common.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2002 - The Freeciv Project
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#include <stdlib.h> /* qsort */
19
20/* utility */
21#include "fcintl.h"
22#include "log.h"
23#include "support.h"
24
25/* common */
26#include "combat.h"
27#include "game.h"
28#include "unitlist.h"
29
30/* client */
31#include "agents.h"
32#include "chatline_common.h"
33#include "cityrep_g.h"
34#include "client_main.h"
35#include "climisc.h"
36#include "cma_core.h"
37#include "control.h"
38#include "editor.h"
39#include "fcintl.h"
40#include "goto.h"
41#include "mapctrl_common.h"
42#include "mapctrl_g.h"
43#include "mapview_g.h"
44#include "options.h"
45#include "overview_common.h"
46#include "tilespec.h"
47#include "zoom.h"
48
49/* Selection Rectangle */
50 static float rec_anchor_x, rec_anchor_y; /* canvas coordinates for anchor */
51 static struct tile *rec_canvas_center_tile;
52 static int rec_corner_x, rec_corner_y; /* corner to iterate from */
53 static int rec_w, rec_h; /* width, heigth in pixels */
54
55 bool rbutton_down = FALSE;
56 bool rectangle_active = FALSE;
57
58/* This changes the behaviour of left mouse
59 button in Area Selection mode. */
60 bool tiles_hilited_cities = FALSE;
61
62/* The mapcanvas clipboard */
63 struct universal clipboard =
64{ .kind = VUT_NONE,
65 .value = {.building = NULL}
66};
67
68/* Goto with drag and drop. */
69 bool keyboardless_goto_button_down = FALSE;
70 bool keyboardless_goto_active = FALSE;
71 struct tile *keyboardless_goto_start_tile;
72
73/* Update the workers for a city on the map, when the update is received */
74 struct city *city_workers_display = NULL;
75
76/*************************************************************************/
77
78static void clipboard_send_production_packet(struct city *pcity);
79static void define_tiles_within_rectangle(bool append);
80
81/**********************************************************************/
87 void anchor_selection_rectangle(int canvas_x, int canvas_y)
88{
89 struct tile *ptile = canvas_pos_to_nearest_tile(canvas_x, canvas_y,
90 mouse_zoom);
91
92 tile_to_canvas_pos(&rec_anchor_x, &rec_anchor_y, map_zoom, ptile);
93 rec_anchor_x += tileset_tile_width(tileset) / 2;
94 rec_anchor_y += tileset_tile_height(tileset) / 2;
95 /* FIXME: This may be off-by-one. */
96 rec_canvas_center_tile = get_center_tile_mapcanvas();
97 rec_w = rec_h = 0;
98}
99
100/**********************************************************************/
114 static void define_tiles_within_rectangle(bool append)
115{
116 const int W = tileset_tile_width(tileset), half_W = W / 2;
117 const int H = tileset_tile_height(tileset), half_H = H / 2;
118 const int segments_x = abs(rec_w / half_W);
119 const int segments_y = abs(rec_h / half_H);
120
121 /* Iteration direction */
122 const int inc_x = (rec_w > 0 ? half_W : -half_W);
123 const int inc_y = (rec_h > 0 ? half_H : -half_H);
124 int x, y, xx, yy;
125 float x2, y2;
126 struct unit_list *units = unit_list_new();
127 const struct city *pcity;
128 bool found_any_cities = FALSE;
129
130 if (!append) {
131 cancel_tile_hiliting();
132 }
133
134 y = rec_corner_y;
135 for (yy = 0; yy <= segments_y; yy++, y += inc_y) {
136 x = rec_corner_x;
137 for (xx = 0; xx <= segments_x; xx++, x += inc_x) {
138 struct tile *ptile;
139
140 /* For diamond shaped tiles, every other row is indented.
141 */
142 if ((yy % 2 ^ xx % 2) != 0) {
143 continue;
144 }
145
146 ptile = canvas_pos_to_tile(x, y, map_zoom);
147 if (!ptile) {
148 continue;
149 }
150
151 /* "Half-tile" indentation must match, or we'll process
152 * some tiles twice in the case of rectangular shape tiles.
153 */
154 tile_to_canvas_pos(&x2, &y2, map_zoom, ptile);
155
156 if ((yy % 2) != 0 && ((rec_corner_x % W) ^ abs((int)x2 % W)) != 0) {
157 continue;
158 }
159
160 /* Tile passed all tests; process it.
161 */
162 pcity = tile_city(ptile);
163 if (pcity != NULL && city_owner(pcity) == client_player()) {
164 mapdeco_set_highlight(ptile, TRUE);
165 found_any_cities = tiles_hilited_cities = TRUE;
166 }
167 unit_list_iterate(ptile->units, punit) {
168 if (unit_owner(punit) == client.conn.playing) {
169 unit_list_append(units, punit);
170 }
171 } unit_list_iterate_end;
172 }
173 }
174
175 if (!(gui_options.separate_unit_selection && found_any_cities)
176 && unit_list_size(units) > 0) {
177 if (!append) {
178 struct unit *punit = unit_list_get(units, 0);
179
180 unit_focus_set(punit);
181 unit_list_remove(units, punit);
182 }
183 unit_list_iterate(units, punit) {
184 unit_focus_add(punit);
185 } unit_list_iterate_end;
186 }
187 unit_list_destroy(units);
188
189 /* Clear previous rectangle. */
190 draw_selection_rectangle(rec_corner_x, rec_corner_y, rec_w, rec_h);
191
192 /* Hilite in City List Window */
193 if (tiles_hilited_cities) {
194 hilite_cities_from_canvas(); /* cityrep.c */
195 }
196}
197
198/**********************************************************************/
201 void update_selection_rectangle(float canvas_x, float canvas_y)
202{
203 const int W = tileset_tile_width(tileset), half_W = W / 2;
204 const int H = tileset_tile_height(tileset), half_H = H / 2;
205 static struct tile *rec_tile = NULL;
206 int diff_x, diff_y;
207 struct tile *center_tile;
208 struct tile *ptile;
209
210 ptile = canvas_pos_to_nearest_tile(canvas_x, canvas_y, mouse_zoom);
211
212 /* Did mouse pointer move beyond the current tile's
213 * boundaries? Avoid macros; tile may be unreal!
214 */
215 if (ptile == rec_tile) {
216 return;
217 }
218 rec_tile = ptile;
219
220 /* Clear previous rectangle. */
221 draw_selection_rectangle(rec_corner_x, rec_corner_y, rec_w, rec_h);
222
223 /* Fix canvas coords to the center of the tile. */
224 tile_to_canvas_pos(&canvas_x, &canvas_y, map_zoom, ptile);
225 canvas_x += half_W;
226 canvas_y += half_H;
227
228 rec_w = rec_anchor_x - canvas_x; /* width */
229 rec_h = rec_anchor_y - canvas_y; /* height */
230
231 /* FIXME: This may be off-by-one. */
232 center_tile = get_center_tile_mapcanvas();
233 map_distance_vector(&diff_x, &diff_y, center_tile, rec_canvas_center_tile);
234
235 /* Adjust width, height if mapview has recentered.
236 */
237 if (diff_x != 0 || diff_y != 0) {
238
239 if (tileset_is_isometric(tileset)) {
240 rec_w += (diff_x - diff_y) * half_W;
241 rec_h += (diff_x + diff_y) * half_H;
242
243 /* Iso wrapping */
244 if (abs(rec_w) > wld.map.xsize * half_W / 2) {
245 int wx = wld.map.xsize * half_W, wy = wld.map.xsize * half_H;
246
247 rec_w > 0 ? (rec_w -= wx, rec_h -= wy) : (rec_w += wx, rec_h += wy);
248 }
249
250 } else {
251 rec_w += diff_x * W;
252 rec_h += diff_y * H;
253
254 /* X wrapping */
255 if (abs(rec_w) > wld.map.xsize * half_W) {
256 int wx = wld.map.xsize * W;
257
258 rec_w > 0 ? (rec_w -= wx) : (rec_w += wx);
259 }
260 }
261 }
262
263 if (rec_w == 0 && rec_h == 0) {
264 rectangle_active = FALSE;
265 return;
266 }
267
268 /* It is currently drawn only to the screen, not backing store */
269 rectangle_active = TRUE;
270 draw_selection_rectangle(canvas_x, canvas_y, rec_w, rec_h);
271 rec_corner_x = canvas_x;
272 rec_corner_y = canvas_y;
273}
274
275/**********************************************************************/
278 void redraw_selection_rectangle(void)
279{
280 if (rectangle_active) {
281 draw_selection_rectangle(rec_corner_x, rec_corner_y, rec_w, rec_h);
282 }
283}
284
285/**********************************************************************/
288 void cancel_selection_rectangle(void)
289{
290 if (rectangle_active) {
291 rectangle_active = FALSE;
292 rbutton_down = FALSE;
293
294 /* Erase the previously drawn selection rectangle. */
295 draw_selection_rectangle(rec_corner_x, rec_corner_y, rec_w, rec_h);
296 }
297}
298
299/**********************************************************************/
302 bool is_city_hilited(struct city *pcity)
303{
304 return pcity && mapdeco_is_highlight_set(city_tile(pcity));
305}
306
307/**********************************************************************/
310 void cancel_tile_hiliting(void)
311{
312 if (tiles_hilited_cities) {
313 tiles_hilited_cities = FALSE;
314 mapdeco_clear_highlights();
315 }
316}
317
318/**********************************************************************/
322 void release_right_button(int canvas_x, int canvas_y, bool shift)
323{
324 if (rectangle_active) {
325 define_tiles_within_rectangle(shift);
326 } else {
327 cancel_tile_hiliting();
328 recenter_button_pressed(canvas_x, canvas_y);
329 }
330 rectangle_active = FALSE;
331 rbutton_down = FALSE;
332}
333
334/**********************************************************************/
337 void toggle_tile_hilite(struct tile *ptile)
338{
339 struct city *pcity = tile_city(ptile);
340
341 if (mapdeco_is_highlight_set(ptile)) {
342 mapdeco_set_highlight(ptile, FALSE);
343 if (pcity) {
344 toggle_city_hilite(pcity, FALSE); /* cityrep.c */
345 }
346 }
347 else if (NULL != pcity && city_owner(pcity) == client.conn.playing) {
348 mapdeco_set_highlight(ptile, TRUE);
349 tiles_hilited_cities = TRUE;
350 toggle_city_hilite(pcity, TRUE);
351 } else {
352 return;
353 }
354}
355
356/**********************************************************************/
360 void key_city_overlay(int canvas_x, int canvas_y)
361{
362 struct tile *ptile = canvas_pos_to_tile(canvas_x, canvas_y, mouse_zoom);
363
364 if (can_client_change_view() && ptile) {
365 struct unit *punit;
366 struct city *pcity = find_city_or_settler_near_tile(ptile, &punit);
367
368 if (pcity) {
369 toggle_city_color(pcity);
370 } else if (punit) {
371 toggle_unit_color(punit);
372 }
373 }
374}
375
376/**********************************************************************/
380 bool clipboard_copy_production(struct tile *ptile)
381{
382 char buffer[256];
383 struct city *pcity = tile_city(ptile);
384
385 if (!can_client_issue_orders()) {
386 return FALSE;
387 }
388
389 if (pcity) {
390 if (city_owner(pcity) != client.conn.playing) {
391 return FALSE;
392 }
393 clipboard = pcity->production;
394 } else {
395 struct unit *punit = find_visible_unit(ptile);
396 if (!punit) {
397 return FALSE;
398 }
399 if (!can_player_build_unit_direct(client.conn.playing,
400 unit_type_get(punit))) {
401 create_event(ptile, E_BAD_COMMAND, ftc_client,
402 _("You don't know how to build %s!"),
403 unit_name_translation(punit));
404 return TRUE;
405 }
406 clipboard.kind = VUT_UTYPE;
407 clipboard.value.utype = unit_type_get(punit);
408 }
409 upgrade_canvas_clipboard();
410
411 create_event(ptile, E_CITY_PRODUCTION_CHANGED, /* ? */
412 ftc_client, _("Copy %s to clipboard."),
413 universal_name_translation(&clipboard, buffer, sizeof(buffer)));
414 return TRUE;
415}
416
417/**********************************************************************/
421 void clipboard_paste_production(struct city *pcity)
422{
423 if (!can_client_issue_orders()) {
424 return;
425 }
426 if (NULL == clipboard.value.building) {
427 create_event(city_tile(pcity), E_BAD_COMMAND, ftc_client,
428 _("Clipboard is empty."));
429 return;
430 }
431 if (!tiles_hilited_cities) {
432 if (NULL != pcity && city_owner(pcity) == client.conn.playing) {
433 clipboard_send_production_packet(pcity);
434 }
435 return;
436 } else {
437 connection_do_buffer(&client.conn);
438 city_list_iterate(client.conn.playing->cities, hilicity) {
439 if (is_city_hilited(hilicity)) {
440 clipboard_send_production_packet(hilicity);
441 }
442 } city_list_iterate_end;
443 connection_do_unbuffer(&client.conn);
444 }
445}
446
447/**********************************************************************/
450 static void clipboard_send_production_packet(struct city *pcity)
451{
452 if (are_universals_equal(&pcity->production, &clipboard)
453 || !can_city_build_now(pcity, &clipboard)) {
454 return;
455 }
456
457 dsend_packet_city_change(&client.conn, pcity->id, pcity->id,
458 clipboard.kind,
459 universal_number(&clipboard));
460}
461
462/**********************************************************************/
466 void upgrade_canvas_clipboard(void)
467{
468 if (!can_client_issue_orders()) {
469 return;
470 }
471 if (VUT_UTYPE == clipboard.kind) {
472 const struct unit_type *u =
473 can_upgrade_unittype(client.conn.playing, clipboard.value.utype);
474
475 if (u) {
476 clipboard.value.utype = u;
477 }
478 }
479}
480
481/**********************************************************************/
484 void release_goto_button(int canvas_x, int canvas_y)
485{
486 struct tile *ptile = canvas_pos_to_tile(canvas_x, canvas_y, mouse_zoom);
487
488 if (keyboardless_goto_active
489 && (hover_state == HOVER_GOTO || hover_state == HOVER_GOTO_SEL_TGT)
490 && ptile) {
491 do_unit_goto(ptile);
492 clear_hover_state();
493 update_unit_info_label(get_units_in_focus());
494 }
495 keyboardless_goto_active = FALSE;
496 keyboardless_goto_button_down = FALSE;
497 keyboardless_goto_start_tile = NULL;
498}
499
500/**********************************************************************/
504 void maybe_activate_keyboardless_goto(int canvas_x, int canvas_y)
505{
506 struct tile *ptile = canvas_pos_to_tile(canvas_x, canvas_y, mouse_zoom);
507
508 if (ptile && get_num_units_in_focus() > 0
509 && !same_pos(keyboardless_goto_start_tile, ptile)
510 && can_client_issue_orders()) {
511 keyboardless_goto_active = TRUE;
512 request_unit_goto(ORDER_LAST, ACTION_NONE, -1);
513 }
514}
515
516/**********************************************************************/
519 bool get_turn_done_button_state(void)
520{
521 return can_end_turn()
522 && (is_human(client.conn.playing) || gui_options.ai_manual_turn_done);
523}
524
525/**********************************************************************/
528 bool can_end_turn(void)
529{
530 struct option *opt;
531
532 opt = optset_option_by_name(server_optset, "fixedlength");
533 if (opt != NULL && option_bool_get(opt)) {
534 return FALSE;
535 }
536
537 return (can_client_issue_orders()
538 && client.conn.playing->is_alive
539 && !client.conn.playing->phase_done
540 && !is_server_busy()
541 && is_player_phase(client.conn.playing, game.info.phase)
542 && !agents_busy());
543}
544
545/**********************************************************************/
549 void scroll_mapview(enum direction8 gui_dir)
550{
551 int gui_x = mapview.gui_x0, gui_y = mapview.gui_y0;
552
553 if (!can_client_change_view()) {
554 return;
555 }
556
557 gui_x += DIR_DX[gui_dir] * mapview.width / 2;
558 gui_y += DIR_DY[gui_dir] * mapview.height / 2;
559 set_mapview_origin(gui_x, gui_y, map_zoom);
560}
561
562/**********************************************************************/
567 void action_button_pressed(int canvas_x, int canvas_y,
568 enum quickselect_type qtype)
569{
570 struct tile *ptile = canvas_pos_to_tile(canvas_x, canvas_y, mouse_zoom);
571
572 if (can_client_change_view() && ptile) {
573 /* FIXME: Some actions here will need to check can_client_issue_orders.
574 * But all we can check is the lowest common requirement. */
575 do_map_click(ptile, qtype);
576 }
577}
578
579/**********************************************************************/
582 void wakeup_button_pressed(int canvas_x, int canvas_y)
583{
584 struct tile *ptile = canvas_pos_to_tile(canvas_x, canvas_y, mouse_zoom);
585
586 if (can_client_issue_orders() && ptile) {
587 wakeup_sentried_units(ptile);
588 }
589}
590
591/**********************************************************************/
594 void adjust_workers_button_pressed(int canvas_x, int canvas_y)
595{
596 struct tile *ptile = canvas_pos_to_tile(canvas_x, canvas_y, mouse_zoom);
597
598 if (NULL != ptile && can_client_issue_orders()) {
599 struct city *pcity = find_city_near_tile(ptile);
600
601 if (pcity && !cma_is_city_under_agent(pcity, NULL)) {
602#ifndef FREECIV_NDEBUG
603 int city_x, city_y;
604#endif
605
606 fc_assert_ret(city_base_to_city_map(&city_x, &city_y, pcity, ptile));
607
608 if (NULL != tile_worked(ptile) && tile_worked(ptile) == pcity) {
609 dsend_packet_city_make_specialist(&client.conn,
610 pcity->id, pcity->id, ptile->index);
611 } else if (city_can_work_tile(pcity, ptile)) {
612 dsend_packet_city_make_worker(&client.conn,
613 pcity->id, pcity->id, ptile->index);
614 } else {
615 return;
616 }
617
618 /* When the city info packet is received, update the workers on the
619 * map. This is a bad hack used to selectively update the mapview
620 * when we receive the corresponding city packet. */
621 city_workers_display = pcity;
622 }
623 }
624}
625
626/**********************************************************************/
630 void recenter_button_pressed(int canvas_x, int canvas_y)
631{
632 /* We use the "nearest" tile here so off-map clicks will still work. */
633 struct tile *ptile = canvas_pos_to_nearest_tile(canvas_x, canvas_y,
634 mouse_zoom);
635
636 if (can_client_change_view() && ptile) {
637 center_tile_mapcanvas(ptile);
638 }
639}
640
641/**********************************************************************/
644 void update_turn_done_button_state(void)
645{
646 bool turn_done_state = get_turn_done_button_state();
647
648 set_turn_done_button_state(turn_done_state);
649
650 if (can_end_turn()) {
651 if (waiting_for_end_turn) {
652 send_turn_done();
653 } else {
654 update_turn_done_button(TRUE);
655 }
656 }
657}
658
659/**********************************************************************/
662 void update_line(int canvas_x, int canvas_y)
663{
664 struct tile *ptile;
665 struct unit_list *punits;
666
667 switch (hover_state) {
668 case HOVER_GOTO:
669 case HOVER_PATROL:
670 case HOVER_CONNECT:
671 ptile = canvas_pos_to_tile(canvas_x, canvas_y, mouse_zoom);
672
673 is_valid_goto_draw_line(ptile);
674 break;
675 case HOVER_GOTO_SEL_TGT:
676 ptile = canvas_pos_to_tile(canvas_x, canvas_y, mouse_zoom);
677 punits = get_units_in_focus();
678
679 set_hover_state(punits, hover_state, connect_activity, connect_tgt,
680 ptile->index, goto_last_sub_tgt,
681 goto_last_action, goto_last_order);
682 break;
683 case HOVER_NONE:
684 case HOVER_PARADROP:
685 case HOVER_ACT_SEL_TGT:
686 break;
687 };
688}
689
690/**********************************************************************/
693 void overview_update_line(int overview_x, int overview_y)
694{
695 struct tile *ptile;
696 struct unit_list *punits;
697 int x, y;
698
699 switch (hover_state) {
700 case HOVER_GOTO:
701 case HOVER_PATROL:
702 case HOVER_CONNECT:
703 overview_to_map_pos(&x, &y, overview_x, overview_y);
704 ptile = map_pos_to_tile(&(wld.map), x, y);
705
706 is_valid_goto_draw_line(ptile);
707 break;
708 case HOVER_GOTO_SEL_TGT:
709 overview_to_map_pos(&x, &y, overview_x, overview_y);
710 ptile = map_pos_to_tile(&(wld.map), x, y);
711 punits = get_units_in_focus();
712
713 set_hover_state(punits, hover_state, connect_activity, connect_tgt,
714 ptile->index, goto_last_sub_tgt,
715 goto_last_action, goto_last_order);
716 break;
717 case HOVER_NONE:
718 case HOVER_PARADROP:
719 case HOVER_ACT_SEL_TGT:
720 break;
721 };
722}
723
724/**********************************************************************/
731 static int unit_list_compare(const void *a, const void *b)
732{
733 const struct unit *punit1 = *(struct unit **)a;
734 const struct unit *punit2 = *(struct unit **)b;
735
736 if (unit_transport_get(punit1) == unit_transport_get(punit2)) {
737 /* For units with the same transporter or no transporter: sort by id. */
738 /* Perhaps we should sort by name instead? */
739 return punit1->id - punit2->id;
740 } else if (unit_transport_get(punit1) == punit2) {
741 return 1;
742 } else if (unit_transport_get(punit2) == punit1) {
743 return -1;
744 } else {
745 /* If the transporters aren't the same, put in order by the
746 * transporters. */
747 const struct unit *ptrans1 = unit_transport_get(punit1);
748 const struct unit *ptrans2 = unit_transport_get(punit2);
749
750 if (!ptrans1) {
751 ptrans1 = punit1;
752 }
753 if (!ptrans2) {
754 ptrans2 = punit2;
755 }
756
757 return unit_list_compare(&ptrans1, &ptrans2);
758 }
759}
760
761/**********************************************************************/
764 void fill_tile_unit_list(const struct tile *ptile, struct unit **unit_list)
765{
766 int i = 0;
767
768 /* First populate the unit list. */
769 unit_list_iterate(ptile->units, punit) {
770 unit_list[i] = punit;
771 i++;
772 } unit_list_iterate_end;
773
774 /* Then sort it. */
775 qsort(unit_list, i, sizeof(*unit_list), unit_list_compare);
776}
ACTION_NONE
#define ACTION_NONE
Definition actions.h:293
agents_busy
bool agents_busy(void)
Definition agents.c:799
agents.h
canvas_y
struct canvas int int canvas_y
Definition canvas_g.h:43
canvas_x
struct canvas int canvas_x
Definition canvas_g.h:43
chatline_common.h
can_city_build_now
bool can_city_build_now(const struct city *pcity, const struct universal *target)
Definition city.c:989
city_base_to_city_map
bool city_base_to_city_map(int *city_map_x, int *city_map_y, const struct city *const pcity, const struct tile *map_tile)
Definition city.c:276
city_can_work_tile
bool city_can_work_tile(const struct city *pcity, const struct tile *ptile)
Definition city.c:1425
city_list_iterate
#define city_list_iterate(citylist, pcity)
Definition city.h:488
city_tile
#define city_tile(_pcity_)
Definition city.h:544
city_owner
#define city_owner(_pcity_)
Definition city.h:543
city_list_iterate_end
#define city_list_iterate_end
Definition city.h:490
cityrep_g.h
waiting_for_end_turn
bool waiting_for_end_turn
Definition client_main.c:154
send_turn_done
void send_turn_done(void)
Definition client_main.c:809
client
struct civclient client
Definition client_main.c:149
can_client_issue_orders
bool can_client_issue_orders(void)
Definition client_main.c:1265
is_server_busy
bool is_server_busy(void)
Definition client_main.c:1338
can_client_change_view
bool can_client_change_view(void)
Definition client_main.c:1313
client_main.h
client_player
#define client_player()
Definition client_main.h:106
create_event
void create_event(struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Definition climisc.c:1075
climisc.h
cma_is_city_under_agent
bool cma_is_city_under_agent(const struct city *pcity, struct cm_parameter *parameter)
Definition cma_core.c:550
cma_core.h
combat.h
connection_do_buffer
void connection_do_buffer(struct connection *pc)
Definition connection.c:323
connection_do_unbuffer
void connection_do_unbuffer(struct connection *pc)
Definition connection.c:335
goto_last_order
enum unit_orders goto_last_order
Definition control.c:96
clear_hover_state
void clear_hover_state(void)
Definition control.c:323
do_map_click
void do_map_click(struct tile *ptile, enum quickselect_type qtype)
Definition control.c:2768
unit_focus_add
void unit_focus_add(struct unit *punit)
Definition control.c:557
unit_focus_set
void unit_focus_set(struct unit *punit)
Definition control.c:502
request_unit_goto
void request_unit_goto(enum unit_orders last_order, action_id act_id, int sub_tgt_id)
Definition control.c:1103
connect_tgt
struct extra_type * connect_tgt
Definition control.c:91
get_units_in_focus
struct unit_list * get_units_in_focus(void)
Definition control.c:177
connect_activity
enum unit_activity connect_activity
Definition control.c:90
set_hover_state
void set_hover_state(struct unit_list *punits, enum cursor_hover_state state, enum unit_activity activity, struct extra_type *tgt, int last_tgt, int last_sub_tgt, action_id action, enum unit_orders order)
Definition control.c:285
hover_state
enum cursor_hover_state hover_state
Definition control.c:89
goto_last_sub_tgt
int goto_last_sub_tgt
Definition control.c:95
find_visible_unit
struct unit * find_visible_unit(struct tile *ptile)
Definition control.c:805
get_num_units_in_focus
int get_num_units_in_focus(void)
Definition control.c:185
wakeup_sentried_units
void wakeup_sentried_units(struct tile *ptile)
Definition control.c:1552
goto_last_action
action_id goto_last_action
Definition control.c:93
do_unit_goto
void do_unit_goto(struct tile *ptile)
Definition control.c:2978
control.h
quickselect_type
quickselect_type
Definition control.h:36
HOVER_GOTO
@ HOVER_GOTO
Definition control.h:27
HOVER_PARADROP
@ HOVER_PARADROP
Definition control.h:28
HOVER_ACT_SEL_TGT
@ HOVER_ACT_SEL_TGT
Definition control.h:31
HOVER_NONE
@ HOVER_NONE
Definition control.h:26
HOVER_CONNECT
@ HOVER_CONNECT
Definition control.h:29
HOVER_PATROL
@ HOVER_PATROL
Definition control.h:30
HOVER_GOTO_SEL_TGT
@ HOVER_GOTO_SEL_TGT
Definition control.h:32
punit
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:73
editor.h
fcintl.h
_
#define _(String)
Definition fcintl.h:67
ftc_client
const struct ft_color ftc_client
Definition featured_text.c:78
game
struct civ_game game
Definition game.c:57
is_player_phase
bool is_player_phase(const struct player *pplayer, int phase)
Definition game.c:687
wld
struct world wld
Definition game.c:58
game.h
is_valid_goto_draw_line
bool is_valid_goto_draw_line(struct tile *dest_tile)
Definition goto.c:1335
goto.h
toggle_city_hilite
void toggle_city_hilite(struct city *pcity, bool on_off)
Definition cityrep.c:2092
hilite_cities_from_canvas
void hilite_cities_from_canvas(void)
Definition cityrep.c:2067
set_turn_done_button_state
void set_turn_done_button_state(bool state)
Definition mapctrl.c:207
update_turn_done_button
void update_turn_done_button(bool do_restore)
Definition mapview.c:75
draw_selection_rectangle
void draw_selection_rectangle(int canvas_x, int canvas_y, int w, int h)
Definition mapview.c:728
update_unit_info_label
void update_unit_info_label(struct unit_list *punits)
Definition mapview.c:258
log.h
fc_assert_ret
#define fc_assert_ret(condition)
Definition log.h:191
DIR_DY
const int DIR_DY[8]
Definition map.c:87
DIR_DX
const int DIR_DX[8]
Definition map.c:86
map_pos_to_tile
struct tile * map_pos_to_tile(const struct civ_map *nmap, int map_x, int map_y)
Definition map.c:417
same_pos
bool same_pos(const struct tile *tile1, const struct tile *tile2)
Definition map.c:938
map_distance_vector
void map_distance_vector(int *dx, int *dy, const struct tile *tile0, const struct tile *tile1)
Definition map.c:1071
cancel_selection_rectangle
void cancel_selection_rectangle(void)
Definition mapctrl_common.c:288
update_line
void update_line(int canvas_x, int canvas_y)
Definition mapctrl_common.c:662
maybe_activate_keyboardless_goto
void maybe_activate_keyboardless_goto(int canvas_x, int canvas_y)
Definition mapctrl_common.c:504
adjust_workers_button_pressed
void adjust_workers_button_pressed(int canvas_x, int canvas_y)
Definition mapctrl_common.c:594
rbutton_down
bool rbutton_down
Definition mapctrl_common.c:55
rec_corner_y
static int rec_corner_y
Definition mapctrl_common.c:52
rectangle_active
bool rectangle_active
Definition mapctrl_common.c:56
release_goto_button
void release_goto_button(int canvas_x, int canvas_y)
Definition mapctrl_common.c:484
rec_h
static int rec_h
Definition mapctrl_common.c:53
tiles_hilited_cities
bool tiles_hilited_cities
Definition mapctrl_common.c:60
clipboard
struct universal clipboard
Definition mapctrl_common.c:63
redraw_selection_rectangle
void redraw_selection_rectangle(void)
Definition mapctrl_common.c:278
recenter_button_pressed
void recenter_button_pressed(int canvas_x, int canvas_y)
Definition mapctrl_common.c:630
upgrade_canvas_clipboard
void upgrade_canvas_clipboard(void)
Definition mapctrl_common.c:466
update_turn_done_button_state
void update_turn_done_button_state(void)
Definition mapctrl_common.c:644
action_button_pressed
void action_button_pressed(int canvas_x, int canvas_y, enum quickselect_type qtype)
Definition mapctrl_common.c:567
wakeup_button_pressed
void wakeup_button_pressed(int canvas_x, int canvas_y)
Definition mapctrl_common.c:582
city_workers_display
struct city * city_workers_display
Definition mapctrl_common.c:74
rec_anchor_y
static float rec_anchor_y
Definition mapctrl_common.c:50
get_turn_done_button_state
bool get_turn_done_button_state(void)
Definition mapctrl_common.c:519
scroll_mapview
void scroll_mapview(enum direction8 gui_dir)
Definition mapctrl_common.c:549
release_right_button
void release_right_button(int canvas_x, int canvas_y, bool shift)
Definition mapctrl_common.c:322
keyboardless_goto_button_down
bool keyboardless_goto_button_down
Definition mapctrl_common.c:69
rec_corner_x
static int rec_corner_x
Definition mapctrl_common.c:52
key_city_overlay
void key_city_overlay(int canvas_x, int canvas_y)
Definition mapctrl_common.c:360
rec_anchor_x
static float rec_anchor_x
Definition mapctrl_common.c:50
update_selection_rectangle
void update_selection_rectangle(float canvas_x, float canvas_y)
Definition mapctrl_common.c:201
can_end_turn
bool can_end_turn(void)
Definition mapctrl_common.c:528
overview_update_line
void overview_update_line(int overview_x, int overview_y)
Definition mapctrl_common.c:693
anchor_selection_rectangle
void anchor_selection_rectangle(int canvas_x, int canvas_y)
Definition mapctrl_common.c:87
cancel_tile_hiliting
void cancel_tile_hiliting(void)
Definition mapctrl_common.c:310
keyboardless_goto_active
bool keyboardless_goto_active
Definition mapctrl_common.c:70
clipboard_paste_production
void clipboard_paste_production(struct city *pcity)
Definition mapctrl_common.c:421
rec_canvas_center_tile
static struct tile * rec_canvas_center_tile
Definition mapctrl_common.c:51
fill_tile_unit_list
void fill_tile_unit_list(const struct tile *ptile, struct unit **unit_list)
Definition mapctrl_common.c:764
define_tiles_within_rectangle
static void define_tiles_within_rectangle(bool append)
Definition mapctrl_common.c:114
clipboard_send_production_packet
static void clipboard_send_production_packet(struct city *pcity)
Definition mapctrl_common.c:450
clipboard_copy_production
bool clipboard_copy_production(struct tile *ptile)
Definition mapctrl_common.c:380
rec_w
static int rec_w
Definition mapctrl_common.c:53
is_city_hilited
bool is_city_hilited(struct city *pcity)
Definition mapctrl_common.c:302
unit_list_compare
static int unit_list_compare(const void *a, const void *b)
Definition mapctrl_common.c:731
keyboardless_goto_start_tile
struct tile * keyboardless_goto_start_tile
Definition mapctrl_common.c:71
toggle_tile_hilite
void toggle_tile_hilite(struct tile *ptile)
Definition mapctrl_common.c:337
mapctrl_common.h
mapctrl_g.h
mapdeco_set_highlight
void mapdeco_set_highlight(const struct tile *ptile, bool highlight)
Definition mapview_common.c:3341
find_city_or_settler_near_tile
struct city * find_city_or_settler_near_tile(const struct tile *ptile, struct unit **punit)
Definition mapview_common.c:2804
set_mapview_origin
void set_mapview_origin(float gui_x0, float gui_y0, float zoom)
Definition mapview_common.c:992
mapview
struct view mapview
Definition mapview_common.c:74
get_center_tile_mapcanvas
struct tile * get_center_tile_mapcanvas(void)
Definition mapview_common.c:1212
canvas_pos_to_tile
struct tile * canvas_pos_to_tile(float canvas_x, float canvas_y, float zoom)
Definition mapview_common.c:751
find_city_near_tile
struct city * find_city_near_tile(const struct tile *ptile)
Definition mapview_common.c:2895
mapdeco_is_highlight_set
bool mapdeco_is_highlight_set(const struct tile *ptile)
Definition mapview_common.c:3364
center_tile_mapcanvas
void center_tile_mapcanvas(const struct tile *ptile)
Definition mapview_common.c:1222
toggle_city_color
void toggle_city_color(struct city *pcity)
Definition mapview_common.c:1476
canvas_pos_to_nearest_tile
struct tile * canvas_pos_to_nearest_tile(float canvas_x, float canvas_y, float zoom)
Definition mapview_common.c:768
center_tile
const struct tile * center_tile
Definition mapview_common.c:79
mapdeco_clear_highlights
void mapdeco_clear_highlights(void)
Definition mapview_common.c:3376
toggle_unit_color
void toggle_unit_color(struct unit *punit)
Definition mapview_common.c:1494
tile_to_canvas_pos
bool tile_to_canvas_pos(float *canvas_x, float *canvas_y, float zoom, const struct tile *ptile)
Definition mapview_common.c:694
mapview_g.h
H
#define H(x, y, z)
Definition md5.c:92
server_optset
const struct option_set * server_optset
Definition options.c:4009
option_bool_get
bool option_bool_get(const struct option *poption)
Definition options.c:772
gui_options
struct client_options gui_options
Definition options.c:71
optset_option_by_name
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:406
options.h
overview_to_map_pos
void overview_to_map_pos(int *map_x, int *map_y, int overview_x, int overview_y)
Definition overview_common.c:356
overview_common.h
dsend_packet_city_make_worker
int dsend_packet_city_make_worker(struct connection *pc, int city_id16, int city_id32, int tile_id)
Definition packets_gen.c:28461
dsend_packet_city_make_specialist
int dsend_packet_city_make_specialist(struct connection *pc, int city_id16, int city_id32, int tile_id)
Definition packets_gen.c:28092
dsend_packet_city_change
int dsend_packet_city_change(struct connection *pc, int city_id16, int city_id32, int production_kind, int production_value)
Definition packets_gen.c:27353
is_human
#define is_human(plr)
Definition player.h:233
are_universals_equal
bool are_universals_equal(const struct universal *psource1, const struct universal *psource2)
Definition requirements.c:5278
universal_number
int universal_number(const struct universal *source)
Definition requirements.c:790
universal_name_translation
const char * universal_name_translation(const struct universal *psource, char *buf, size_t bufsz)
Definition requirements.c:5529
city
Definition city.h:309
city::id
int id
Definition city.h:315
city::production
struct universal production
Definition city.h:382
civ_game::info
struct packet_game_info info
Definition game.h:89
civ_map::xsize
int xsize
Definition map_types.h:77
civclient::conn
struct connection conn
Definition client_main.h:96
client_options::ai_manual_turn_done
bool ai_manual_turn_done
Definition options.h:147
client_options::separate_unit_selection
bool separate_unit_selection
Definition options.h:167
connection::playing
struct player * playing
Definition connection.h:156
option
Definition options.c:454
packet_game_info::phase
int phase
Definition packets_gen.h:206
player::cities
struct city_list * cities
Definition player.h:281
player::is_alive
bool is_alive
Definition player.h:268
player::phase_done
bool phase_done
Definition player.h:263
tile
Definition tile.h:49
tile::index
int index
Definition tile.h:50
tile::units
struct unit_list * units
Definition tile.h:57
tileset
Definition tilespec.c:459
unit_type
Definition unittype.h:481
unit
Definition unit.h:138
unit::id
int id
Definition unit.h:145
universal
Definition fc_types.h:756
universal::kind
enum universals_n kind
Definition fc_types.h:758
universal::value
universals_u value
Definition fc_types.h:757
view::height
int height
Definition mapview_common.h:38
view::gui_x0
float gui_x0
Definition mapview_common.h:37
view::gui_y0
float gui_y0
Definition mapview_common.h:37
view::width
int width
Definition mapview_common.h:38
world::map
struct civ_map map
Definition world_object.h:38
support.h
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
tile_city
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
tile_worked
#define tile_worked(_tile)
Definition tile.h:113
tileset_is_isometric
bool tileset_is_isometric(const struct tileset *t)
Definition tilespec.c:675
tileset_tile_height
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:728
tileset_tile_width
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:716
tilespec.h
universals_u::utype
const struct unit_type * utype
Definition fc_types.h:604
universals_u::building
const struct impr_type * building
Definition fc_types.h:598
unit_transport_get
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2427
ORDER_LAST
@ ORDER_LAST
Definition unit.h:49
unit_owner
#define unit_owner(_pu)
Definition unit.h:387
unitlist.h
unit_list_iterate
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
unit_list_iterate_end
#define unit_list_iterate_end
Definition unitlist.h:33
unit_type_get
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
unit_name_translation
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c:1621
can_upgrade_unittype
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1755
can_player_build_unit_direct
bool can_player_build_unit_direct(const struct player *p, const struct unit_type *punittype)
Definition unittype.c:2015
mouse_zoom
float mouse_zoom
Definition zoom.c:28
map_zoom
float map_zoom
Definition zoom.c:25
zoom.h