Freeciv-3.3: /fast/freeciv/nightly/main/client/mapctrl_common.c Source File

Freeciv-3.3

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 if (diff_x != 0 || diff_y != 0) {
237
238 if (tileset_is_isometric(tileset)) {
239 rec_w += (diff_x - diff_y) * half_W;
240 rec_h += (diff_x + diff_y) * half_H;
241
242 /* Iso wrapping */
243 if (abs(rec_w) > MAP_NATIVE_WIDTH * half_W / 2) {
244 int wx = MAP_NATIVE_WIDTH * half_W, wy = MAP_NATIVE_WIDTH * half_H;
245
246 rec_w > 0 ? (rec_w -= wx, rec_h -= wy) : (rec_w += wx, rec_h += wy);
247 }
248
249 } else {
250 rec_w += diff_x * W;
251 rec_h += diff_y * H;
252
253 /* X wrapping */
254 if (abs(rec_w) > MAP_NATIVE_WIDTH * half_W) {
255 int wx = MAP_NATIVE_WIDTH * W;
256
257 rec_w > 0 ? (rec_w -= wx) : (rec_w += wx);
258 }
259 }
260 }
261
262 if (rec_w == 0 && rec_h == 0) {
263 rectangle_active = FALSE;
264 return;
265 }
266
267 /* It is currently drawn only to the screen, not backing store */
268 rectangle_active = TRUE;
269 draw_selection_rectangle(canvas_x, canvas_y, rec_w, rec_h);
270 rec_corner_x = canvas_x;
271 rec_corner_y = canvas_y;
272}
273
274/**********************************************************************/
277 void redraw_selection_rectangle(void)
278{
279 if (rectangle_active) {
280 draw_selection_rectangle(rec_corner_x, rec_corner_y, rec_w, rec_h);
281 }
282}
283
284/**********************************************************************/
287 void cancel_selection_rectangle(void)
288{
289 if (rectangle_active) {
290 rectangle_active = FALSE;
291 rbutton_down = FALSE;
292
293 /* Erase the previously drawn selection rectangle. */
294 draw_selection_rectangle(rec_corner_x, rec_corner_y, rec_w, rec_h);
295 }
296}
297
298/**********************************************************************/
301 bool is_city_hilited(struct city *pcity)
302{
303 return pcity && mapdeco_is_highlight_set(city_tile(pcity));
304}
305
306/**********************************************************************/
309 void cancel_tile_hiliting(void)
310{
311 if (tiles_hilited_cities) {
312 tiles_hilited_cities = FALSE;
313 mapdeco_clear_highlights();
314 }
315}
316
317/**********************************************************************/
321 void release_right_button(int canvas_x, int canvas_y, bool shift)
322{
323 if (rectangle_active) {
324 define_tiles_within_rectangle(shift);
325 } else {
326 cancel_tile_hiliting();
327 recenter_button_pressed(canvas_x, canvas_y);
328 }
329 rectangle_active = FALSE;
330 rbutton_down = FALSE;
331}
332
333/**********************************************************************/
336 void toggle_tile_hilite(struct tile *ptile)
337{
338 struct city *pcity = tile_city(ptile);
339
340 if (mapdeco_is_highlight_set(ptile)) {
341 mapdeco_set_highlight(ptile, FALSE);
342 if (pcity) {
343 toggle_city_hilite(pcity, FALSE); /* cityrep.c */
344 }
345 }
346 else if (NULL != pcity && city_owner(pcity) == client.conn.playing) {
347 mapdeco_set_highlight(ptile, TRUE);
348 tiles_hilited_cities = TRUE;
349 toggle_city_hilite(pcity, TRUE);
350 } else {
351 return;
352 }
353}
354
355/**********************************************************************/
359 void key_city_overlay(int canvas_x, int canvas_y)
360{
361 struct tile *ptile = canvas_pos_to_tile(canvas_x, canvas_y, mouse_zoom);
362
363 if (can_client_change_view() && ptile) {
364 struct unit *punit;
365 struct city *pcity = find_city_or_settler_near_tile(ptile, &punit);
366
367 if (pcity) {
368 toggle_city_color(pcity);
369 } else if (punit) {
370 toggle_unit_color(punit);
371 }
372 }
373}
374
375/**********************************************************************/
379 bool clipboard_copy_production(struct tile *ptile)
380{
381 char buffer[256];
382 struct city *pcity = tile_city(ptile);
383
384 if (!can_client_issue_orders()) {
385 return FALSE;
386 }
387
388 if (pcity) {
389 if (city_owner(pcity) != client.conn.playing) {
390 return FALSE;
391 }
392 clipboard = pcity->production;
393 } else {
394 struct unit *punit = find_visible_unit(ptile);
395
396 if (!punit) {
397 return FALSE;
398 }
399
400 if (!can_player_build_unit_direct(client.conn.playing,
401 unit_type_get(punit),
402 FALSE)) {
403 create_event(ptile, E_BAD_COMMAND, ftc_client,
404 _("You don't know how to build %s!"),
405 unit_name_translation(punit));
406 return TRUE;
407 }
408
409 clipboard.kind = VUT_UTYPE;
410 clipboard.value.utype = unit_type_get(punit);
411 }
412 upgrade_canvas_clipboard();
413
414 create_event(ptile, E_CITY_PRODUCTION_CHANGED, /* ? */
415 ftc_client, _("Copy %s to clipboard."),
416 universal_name_translation(&clipboard, buffer, sizeof(buffer)));
417 return TRUE;
418}
419
420/**********************************************************************/
424 void clipboard_paste_production(struct city *pcity)
425{
426 if (!can_client_issue_orders()) {
427 return;
428 }
429 if (NULL == clipboard.value.building) {
430 create_event(city_tile(pcity), E_BAD_COMMAND, ftc_client,
431 _("Clipboard is empty."));
432 return;
433 }
434 if (!tiles_hilited_cities) {
435 if (NULL != pcity && city_owner(pcity) == client.conn.playing) {
436 clipboard_send_production_packet(pcity);
437 }
438 return;
439 } else {
440 connection_do_buffer(&client.conn);
441 city_list_iterate(client.conn.playing->cities, hilicity) {
442 if (is_city_hilited(hilicity)) {
443 clipboard_send_production_packet(hilicity);
444 }
445 } city_list_iterate_end;
446 connection_do_unbuffer(&client.conn);
447 }
448}
449
450/**********************************************************************/
453 static void clipboard_send_production_packet(struct city *pcity)
454{
455 if (are_universals_equal(&pcity->production, &clipboard)
456 || !can_city_build_now(pcity, &clipboard)) {
457 return;
458 }
459
460 dsend_packet_city_change(&client.conn, pcity->id,
461 clipboard.kind,
462 universal_number(&clipboard));
463}
464
465/**********************************************************************/
469 void upgrade_canvas_clipboard(void)
470{
471 if (!can_client_issue_orders()) {
472 return;
473 }
474 if (VUT_UTYPE == clipboard.kind) {
475 const struct unit_type *u =
476 can_upgrade_unittype(client.conn.playing, clipboard.value.utype);
477
478 if (u) {
479 clipboard.value.utype = u;
480 }
481 }
482}
483
484/**********************************************************************/
487 void release_goto_button(int canvas_x, int canvas_y)
488{
489 struct tile *ptile = canvas_pos_to_tile(canvas_x, canvas_y, mouse_zoom);
490
491 if (keyboardless_goto_active
492 && (hover_state == HOVER_GOTO || hover_state == HOVER_GOTO_SEL_TGT)
493 && ptile) {
494 do_unit_goto(ptile);
495 clear_hover_state();
496 update_unit_info_label(get_units_in_focus());
497 }
498 keyboardless_goto_active = FALSE;
499 keyboardless_goto_button_down = FALSE;
500 keyboardless_goto_start_tile = NULL;
501}
502
503/**********************************************************************/
507 void maybe_activate_keyboardless_goto(int canvas_x, int canvas_y)
508{
509 struct tile *ptile = canvas_pos_to_tile(canvas_x, canvas_y, mouse_zoom);
510
511 if (ptile && get_num_units_in_focus() > 0
512 && !same_pos(keyboardless_goto_start_tile, ptile)
513 && can_client_issue_orders()) {
514 keyboardless_goto_active = TRUE;
515 request_unit_goto(ORDER_LAST, ACTION_NONE, -1);
516 }
517}
518
519/**********************************************************************/
522 bool get_turn_done_button_state(void)
523{
524 return can_end_turn()
525 && (is_human(client.conn.playing) || gui_options.ai_manual_turn_done);
526}
527
528/**********************************************************************/
531 bool can_end_turn(void)
532{
533 struct option *opt;
534
535 opt = optset_option_by_name(server_optset, "fixedlength");
536 if (opt != NULL && option_bool_get(opt)) {
537 return FALSE;
538 }
539
540 return (can_client_issue_orders()
541 && client.conn.playing->is_alive
542 && !client.conn.playing->phase_done
543 && !is_server_busy()
544 && is_player_phase(client.conn.playing, game.info.phase)
545 && !agents_busy());
546}
547
548/**********************************************************************/
552 void scroll_mapview(enum direction8 gui_dir)
553{
554 int gui_x = mapview.gui_x0, gui_y = mapview.gui_y0;
555
556 if (!can_client_change_view()) {
557 return;
558 }
559
560 gui_x += DIR_DX[gui_dir] * mapview.width / 2;
561 gui_y += DIR_DY[gui_dir] * mapview.height / 2;
562 set_mapview_origin(gui_x, gui_y, map_zoom);
563}
564
565/**********************************************************************/
570 void action_button_pressed(int canvas_x, int canvas_y,
571 enum quickselect_type qtype)
572{
573 struct tile *ptile = canvas_pos_to_tile(canvas_x, canvas_y, mouse_zoom);
574
575 if (can_client_change_view() && ptile) {
576 /* FIXME: Some actions here will need to check can_client_issue_orders.
577 * But all we can check is the lowest common requirement. */
578 do_map_click(ptile, qtype);
579 }
580}
581
582/**********************************************************************/
585 void wakeup_button_pressed(int canvas_x, int canvas_y)
586{
587 struct tile *ptile = canvas_pos_to_tile(canvas_x, canvas_y, mouse_zoom);
588
589 if (can_client_issue_orders() && ptile) {
590 wakeup_sentried_units(ptile);
591 }
592}
593
594/**********************************************************************/
597 void adjust_workers_button_pressed(int canvas_x, int canvas_y)
598{
599 struct tile *ptile = canvas_pos_to_tile(canvas_x, canvas_y, mouse_zoom);
600
601 if (NULL != ptile && can_client_issue_orders()) {
602 struct city *pcity = find_city_near_tile(ptile);
603
604 if (pcity && !cma_is_city_under_agent(pcity, NULL)) {
605#ifndef FREECIV_NDEBUG
606 int city_x, city_y;
607#endif
608
609 fc_assert_ret(city_base_to_city_map(&city_x, &city_y, pcity, ptile));
610
611 if (NULL != tile_worked(ptile) && tile_worked(ptile) == pcity) {
612 dsend_packet_city_make_specialist(&client.conn,
613 pcity->id, ptile->index);
614 } else if (city_can_work_tile(pcity, ptile)) {
615 dsend_packet_city_make_worker(&client.conn,
616 pcity->id, ptile->index);
617 } else {
618 return;
619 }
620
621 /* When the city info packet is received, update the workers on the
622 * map. This is a bad hack used to selectively update the mapview
623 * when we receive the corresponding city packet. */
624 city_workers_display = pcity;
625 }
626 }
627}
628
629/**********************************************************************/
633 void recenter_button_pressed(int canvas_x, int canvas_y)
634{
635 /* We use the "nearest" tile here so off-map clicks will still work. */
636 struct tile *ptile = canvas_pos_to_nearest_tile(canvas_x, canvas_y,
637 mouse_zoom);
638
639 if (can_client_change_view() && ptile) {
640 center_tile_mapcanvas(ptile);
641 }
642}
643
644/**********************************************************************/
647 void update_turn_done_button_state(void)
648{
649 bool turn_done_state = get_turn_done_button_state();
650
651 set_turn_done_button_state(turn_done_state);
652
653 if (can_end_turn()) {
654 if (waiting_for_end_turn) {
655 send_turn_done();
656 } else {
657 update_turn_done_button(TRUE);
658 }
659 }
660}
661
662/**********************************************************************/
665 void update_line(int canvas_x, int canvas_y)
666{
667 struct tile *ptile;
668 struct unit_list *punits;
669
670 switch (hover_state) {
671 case HOVER_GOTO:
672 case HOVER_PATROL:
673 case HOVER_CONNECT:
674 ptile = canvas_pos_to_tile(canvas_x, canvas_y, mouse_zoom);
675
676 is_valid_goto_draw_line(ptile);
677 break;
678 case HOVER_GOTO_SEL_TGT:
679 ptile = canvas_pos_to_tile(canvas_x, canvas_y, mouse_zoom);
680 punits = get_units_in_focus();
681
682 set_hover_state(punits, hover_state, connect_activity, connect_tgt,
683 ptile->index, goto_last_sub_tgt,
684 goto_last_action, goto_last_order);
685 break;
686 case HOVER_NONE:
687 case HOVER_TELEPORT:
688 case HOVER_PARADROP:
689 case HOVER_ACT_SEL_TGT:
690 break;
691 };
692}
693
694/**********************************************************************/
697 void overview_update_line(int overview_x, int overview_y)
698{
699 struct tile *ptile;
700 struct unit_list *punits;
701 int x, y;
702
703 switch (hover_state) {
704 case HOVER_GOTO:
705 case HOVER_PATROL:
706 case HOVER_CONNECT:
707 overview_to_map_pos(&x, &y, overview_x, overview_y);
708 ptile = map_pos_to_tile(&(wld.map), x, y);
709
710 is_valid_goto_draw_line(ptile);
711 break;
712 case HOVER_GOTO_SEL_TGT:
713 overview_to_map_pos(&x, &y, overview_x, overview_y);
714 ptile = map_pos_to_tile(&(wld.map), x, y);
715 punits = get_units_in_focus();
716
717 set_hover_state(punits, hover_state, connect_activity, connect_tgt,
718 ptile->index, goto_last_sub_tgt,
719 goto_last_action, goto_last_order);
720 break;
721 case HOVER_NONE:
722 case HOVER_TELEPORT:
723 case HOVER_PARADROP:
724 case HOVER_ACT_SEL_TGT:
725 break;
726 };
727}
728
729/**********************************************************************/
736 static int unit_list_compare(const void *a, const void *b)
737{
738 const struct unit *punit1 = *(struct unit **)a;
739 const struct unit *punit2 = *(struct unit **)b;
740
741 if (unit_transport_get(punit1) == unit_transport_get(punit2)) {
742 /* For units with the same transporter or no transporter: sort by id. */
743 /* Perhaps we should sort by name instead? */
744 return punit1->id - punit2->id;
745 } else if (unit_transport_get(punit1) == punit2) {
746 return 1;
747 } else if (unit_transport_get(punit2) == punit1) {
748 return -1;
749 } else {
750 /* If the transporters aren't the same, put in order by the
751 * transporters. */
752 const struct unit *ptrans1 = unit_transport_get(punit1);
753 const struct unit *ptrans2 = unit_transport_get(punit2);
754
755 if (!ptrans1) {
756 ptrans1 = punit1;
757 }
758 if (!ptrans2) {
759 ptrans2 = punit2;
760 }
761
762 return unit_list_compare(&ptrans1, &ptrans2);
763 }
764}
765
766/**********************************************************************/
769 void fill_tile_unit_list(const struct tile *ptile, struct unit **unit_list)
770{
771 int i = 0;
772
773 /* First populate the unit list. */
774 unit_list_iterate(ptile->units, punit) {
775 unit_list[i] = punit;
776 i++;
777 } unit_list_iterate_end;
778
779 /* Then sort it. */
780 qsort(unit_list, i, sizeof(*unit_list), unit_list_compare);
781}
ACTION_NONE
#define ACTION_NONE
Definition actions.h:55
agents_busy
bool agents_busy(void)
Definition agents.c:804
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:1011
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:281
city_can_work_tile
bool city_can_work_tile(const struct city *pcity, const struct tile *ptile)
Definition city.c:1452
city_list_iterate
#define city_list_iterate(citylist, pcity)
Definition city.h:508
city_tile
#define city_tile(_pcity_)
Definition city.h:564
city_owner
#define city_owner(_pcity_)
Definition city.h:563
city_list_iterate_end
#define city_list_iterate_end
Definition city.h:510
cityrep_g.h
waiting_for_end_turn
bool waiting_for_end_turn
Definition client_main.c:158
send_turn_done
void send_turn_done(void)
Definition client_main.c:814
client
struct civclient client
Definition client_main.c:153
can_client_issue_orders
bool can_client_issue_orders(void)
Definition client_main.c:1272
is_server_busy
bool is_server_busy(void)
Definition client_main.c:1345
can_client_change_view
bool can_client_change_view(void)
Definition client_main.c:1320
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:1082
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:551
cma_core.h
combat.h
incite_cost
char * incite_cost
Definition comments.c:74
connection_do_buffer
void connection_do_buffer(struct connection *pc)
Definition connection.c:324
connection_do_unbuffer
void connection_do_unbuffer(struct connection *pc)
Definition connection.c:336
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:2882
unit_focus_add
void unit_focus_add(struct unit *punit)
Definition control.c:556
unit_focus_set
void unit_focus_set(struct unit *punit)
Definition control.c:501
request_unit_goto
void request_unit_goto(enum unit_orders last_order, action_id act_id, int sub_tgt_id)
Definition control.c:1104
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:804
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:1557
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:3097
control.h
quickselect_type
quickselect_type
Definition control.h:37
HOVER_GOTO
@ HOVER_GOTO
Definition control.h:27
HOVER_PARADROP
@ HOVER_PARADROP
Definition control.h:29
HOVER_TELEPORT
@ HOVER_TELEPORT
Definition control.h:28
HOVER_ACT_SEL_TGT
@ HOVER_ACT_SEL_TGT
Definition control.h:32
HOVER_NONE
@ HOVER_NONE
Definition control.h:26
HOVER_CONNECT
@ HOVER_CONNECT
Definition control.h:30
HOVER_PATROL
@ HOVER_PATROL
Definition control.h:31
HOVER_GOTO_SEL_TGT
@ HOVER_GOTO_SEL_TGT
Definition control.h:33
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:74
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:61
is_player_phase
bool is_player_phase(const struct player *pplayer, int phase)
Definition game.c:710
wld
struct world wld
Definition game.c:62
game.h
is_valid_goto_draw_line
bool is_valid_goto_draw_line(struct tile *dest_tile)
Definition goto.c:1342
goto.h
toggle_city_hilite
void toggle_city_hilite(struct city *pcity, bool on_off)
Definition cityrep.c:2089
hilite_cities_from_canvas
void hilite_cities_from_canvas(void)
Definition cityrep.c:2066
set_turn_done_button_state
void set_turn_done_button_state(bool state)
Definition mapctrl.c:210
update_turn_done_button
void update_turn_done_button(bool do_restore)
Definition mapview.c:76
draw_selection_rectangle
void draw_selection_rectangle(int canvas_x, int canvas_y, int w, int h)
Definition mapview.c:749
update_unit_info_label
void update_unit_info_label(struct unit_list *punits)
Definition mapview.c:275
log.h
fc_assert_ret
#define fc_assert_ret(condition)
Definition log.h:191
DIR_DY
const int DIR_DY[8]
Definition map.c:86
DIR_DX
const int DIR_DX[8]
Definition map.c:85
map_pos_to_tile
struct tile * map_pos_to_tile(const struct civ_map *nmap, int map_x, int map_y)
Definition map.c:425
same_pos
bool same_pos(const struct tile *tile1, const struct tile *tile2)
Definition map.c:950
map_distance_vector
void map_distance_vector(int *dx, int *dy, const struct tile *tile0, const struct tile *tile1)
Definition map.c:1087
cancel_selection_rectangle
void cancel_selection_rectangle(void)
Definition mapctrl_common.c:287
update_line
void update_line(int canvas_x, int canvas_y)
Definition mapctrl_common.c:665
maybe_activate_keyboardless_goto
void maybe_activate_keyboardless_goto(int canvas_x, int canvas_y)
Definition mapctrl_common.c:507
adjust_workers_button_pressed
void adjust_workers_button_pressed(int canvas_x, int canvas_y)
Definition mapctrl_common.c:597
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:487
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:277
recenter_button_pressed
void recenter_button_pressed(int canvas_x, int canvas_y)
Definition mapctrl_common.c:633
upgrade_canvas_clipboard
void upgrade_canvas_clipboard(void)
Definition mapctrl_common.c:469
update_turn_done_button_state
void update_turn_done_button_state(void)
Definition mapctrl_common.c:647
action_button_pressed
void action_button_pressed(int canvas_x, int canvas_y, enum quickselect_type qtype)
Definition mapctrl_common.c:570
wakeup_button_pressed
void wakeup_button_pressed(int canvas_x, int canvas_y)
Definition mapctrl_common.c:585
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:522
scroll_mapview
void scroll_mapview(enum direction8 gui_dir)
Definition mapctrl_common.c:552
release_right_button
void release_right_button(int canvas_x, int canvas_y, bool shift)
Definition mapctrl_common.c:321
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:359
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:531
overview_update_line
void overview_update_line(int overview_x, int overview_y)
Definition mapctrl_common.c:697
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:309
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:424
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:769
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:453
clipboard_copy_production
bool clipboard_copy_production(struct tile *ptile)
Definition mapctrl_common.c:379
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:301
unit_list_compare
static int unit_list_compare(const void *a, const void *b)
Definition mapctrl_common.c:736
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:336
mapctrl_common.h
mapctrl_g.h
mapdeco_set_highlight
void mapdeco_set_highlight(const struct tile *ptile, bool highlight)
Definition mapview_common.c:3312
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:2774
set_mapview_origin
void set_mapview_origin(float gui_x0, float gui_y0, float zoom)
Definition mapview_common.c:1008
mapview
struct view mapview
Definition mapview_common.c:75
get_center_tile_mapcanvas
struct tile * get_center_tile_mapcanvas(void)
Definition mapview_common.c:1227
canvas_pos_to_tile
struct tile * canvas_pos_to_tile(float canvas_x, float canvas_y, float zoom)
Definition mapview_common.c:763
find_city_near_tile
struct city * find_city_near_tile(const struct tile *ptile)
Definition mapview_common.c:2865
mapdeco_is_highlight_set
bool mapdeco_is_highlight_set(const struct tile *ptile)
Definition mapview_common.c:3335
center_tile_mapcanvas
void center_tile_mapcanvas(const struct tile *ptile)
Definition mapview_common.c:1237
toggle_city_color
void toggle_city_color(struct city *pcity)
Definition mapview_common.c:1491
canvas_pos_to_nearest_tile
struct tile * canvas_pos_to_nearest_tile(float canvas_x, float canvas_y, float zoom)
Definition mapview_common.c:780
center_tile
const struct tile * center_tile
Definition mapview_common.c:80
mapdeco_clear_highlights
void mapdeco_clear_highlights(void)
Definition mapview_common.c:3347
toggle_unit_color
void toggle_unit_color(struct unit *punit)
Definition mapview_common.c:1509
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:706
mapview_g.h
H
#define H(x, y, z)
Definition md5.c:92
server_optset
const struct option_set * server_optset
Definition options.c:4281
option_bool_get
bool option_bool_get(const struct option *poption)
Definition options.c:832
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:466
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:358
overview_common.h
dsend_packet_city_make_specialist
int dsend_packet_city_make_specialist(struct connection *pc, int city_id, int tile_id)
Definition packets_gen.c:22235
dsend_packet_city_change
int dsend_packet_city_change(struct connection *pc, int city_id, int production_kind, int production_value)
Definition packets_gen.c:21742
dsend_packet_city_make_worker
int dsend_packet_city_make_worker(struct connection *pc, int city_id, int tile_id)
Definition packets_gen.c:22481
is_human
#define is_human(plr)
Definition player.h:231
are_universals_equal
bool are_universals_equal(const struct universal *psource1, const struct universal *psource2)
Definition requirements.c:6769
universal_number
int universal_number(const struct universal *source)
Definition requirements.c:881
universal_name_translation
const char * universal_name_translation(const struct universal *psource, char *buf, size_t bufsz)
Definition requirements.c:7064
y
struct sprite int int y
Definition sprite_g.h:31
x
struct sprite int x
Definition sprite_g.h:31
city
Definition city.h:320
city::id
int id
Definition city.h:326
city::production
struct universal production
Definition city.h:396
civ_game::info
struct packet_game_info info
Definition game.h:89
civclient::conn
struct connection conn
Definition client_main.h:96
client_options::ai_manual_turn_done
bool ai_manual_turn_done
Definition options.h:155
client_options::separate_unit_selection
bool separate_unit_selection
Definition options.h:175
connection::playing
struct player * playing
Definition connection.h:151
option
Definition options.c:514
packet_game_info::phase
int phase
Definition packets_gen.h:210
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:50
tile::index
int index
Definition tile.h:51
tile::units
struct unit_list * units
Definition tile.h:58
tileset
Definition tilespec.c:482
unit_type
Definition unittype.h:507
unit
Definition unit.h:140
unit::id
int id
Definition unit.h:147
universal
Definition fc_types.h:878
universal::kind
enum universals_n kind
Definition fc_types.h:880
universal::value
universals_u value
Definition fc_types.h:879
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:115
tileset_is_isometric
bool tileset_is_isometric(const struct tileset *t)
Definition tilespec.c:713
tileset_tile_height
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:766
tileset_tile_width
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:754
tilespec.h
universals_u::utype
const struct unit_type * utype
Definition fc_types.h:698
universals_u::building
const struct impr_type * building
Definition fc_types.h:691
unit_transport_get
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2499
ORDER_LAST
@ ORDER_LAST
Definition unit.h:50
unit_owner
#define unit_owner(_pu)
Definition unit.h:396
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:1569
can_player_build_unit_direct
bool can_player_build_unit_direct(const struct player *p, const struct unit_type *punittype, bool consider_reg_impr_req)
Definition unittype.c:1968
can_upgrade_unittype
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1703
MAP_NATIVE_WIDTH
#define MAP_NATIVE_WIDTH
Definition world_object.h:55
mouse_zoom
float mouse_zoom
Definition zoom.c:28
map_zoom
float map_zoom
Definition zoom.c:25
zoom.h