Freeciv-3.2: /fast/freeciv/nightly/S3_2/client/mapctrl_common.c Source File

Freeciv-3.2

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
397 if (!punit) {
398 return FALSE;
399 }
400
401 if (!can_player_build_unit_direct(client.conn.playing,
402 unit_type_get(punit),
403 FALSE)) {
404 create_event(ptile, E_BAD_COMMAND, ftc_client,
405 _("You don't know how to build %s!"),
406 unit_name_translation(punit));
407 return TRUE;
408 }
409
410 clipboard.kind = VUT_UTYPE;
411 clipboard.value.utype = unit_type_get(punit);
412 }
413 upgrade_canvas_clipboard();
414
415 create_event(ptile, E_CITY_PRODUCTION_CHANGED, /* ? */
416 ftc_client, _("Copy %s to clipboard."),
417 universal_name_translation(&clipboard, buffer, sizeof(buffer)));
418 return TRUE;
419}
420
421/**********************************************************************/
425 void clipboard_paste_production(struct city *pcity)
426{
427 if (!can_client_issue_orders()) {
428 return;
429 }
430 if (NULL == clipboard.value.building) {
431 create_event(city_tile(pcity), E_BAD_COMMAND, ftc_client,
432 _("Clipboard is empty."));
433 return;
434 }
435 if (!tiles_hilited_cities) {
436 if (NULL != pcity && city_owner(pcity) == client.conn.playing) {
437 clipboard_send_production_packet(pcity);
438 }
439 return;
440 } else {
441 connection_do_buffer(&client.conn);
442 city_list_iterate(client.conn.playing->cities, hilicity) {
443 if (is_city_hilited(hilicity)) {
444 clipboard_send_production_packet(hilicity);
445 }
446 } city_list_iterate_end;
447 connection_do_unbuffer(&client.conn);
448 }
449}
450
451/**********************************************************************/
454 static void clipboard_send_production_packet(struct city *pcity)
455{
456 if (are_universals_equal(&pcity->production, &clipboard)
457 || !can_city_build_now(pcity, &clipboard)) {
458 return;
459 }
460
461 dsend_packet_city_change(&client.conn, pcity->id,
462 clipboard.kind,
463 universal_number(&clipboard));
464}
465
466/**********************************************************************/
470 void upgrade_canvas_clipboard(void)
471{
472 if (!can_client_issue_orders()) {
473 return;
474 }
475 if (VUT_UTYPE == clipboard.kind) {
476 const struct unit_type *u =
477 can_upgrade_unittype(client.conn.playing, clipboard.value.utype);
478
479 if (u) {
480 clipboard.value.utype = u;
481 }
482 }
483}
484
485/**********************************************************************/
488 void release_goto_button(int canvas_x, int canvas_y)
489{
490 struct tile *ptile = canvas_pos_to_tile(canvas_x, canvas_y, mouse_zoom);
491
492 if (keyboardless_goto_active
493 && (hover_state == HOVER_GOTO || hover_state == HOVER_GOTO_SEL_TGT)
494 && ptile) {
495 do_unit_goto(ptile);
496 clear_hover_state();
497 update_unit_info_label(get_units_in_focus());
498 }
499 keyboardless_goto_active = FALSE;
500 keyboardless_goto_button_down = FALSE;
501 keyboardless_goto_start_tile = NULL;
502}
503
504/**********************************************************************/
508 void maybe_activate_keyboardless_goto(int canvas_x, int canvas_y)
509{
510 struct tile *ptile = canvas_pos_to_tile(canvas_x, canvas_y, mouse_zoom);
511
512 if (ptile && get_num_units_in_focus() > 0
513 && !same_pos(keyboardless_goto_start_tile, ptile)
514 && can_client_issue_orders()) {
515 keyboardless_goto_active = TRUE;
516 request_unit_goto(ORDER_LAST, ACTION_NONE, -1);
517 }
518}
519
520/**********************************************************************/
523 bool get_turn_done_button_state(void)
524{
525 return can_end_turn()
526 && (is_human(client.conn.playing) || gui_options.ai_manual_turn_done);
527}
528
529/**********************************************************************/
532 bool can_end_turn(void)
533{
534 struct option *opt;
535
536 opt = optset_option_by_name(server_optset, "fixedlength");
537 if (opt != NULL && option_bool_get(opt)) {
538 return FALSE;
539 }
540
541 return (can_client_issue_orders()
542 && client.conn.playing->is_alive
543 && !client.conn.playing->phase_done
544 && !is_server_busy()
545 && is_player_phase(client.conn.playing, game.info.phase)
546 && !agents_busy());
547}
548
549/**********************************************************************/
553 void scroll_mapview(enum direction8 gui_dir)
554{
555 int gui_x = mapview.gui_x0, gui_y = mapview.gui_y0;
556
557 if (!can_client_change_view()) {
558 return;
559 }
560
561 gui_x += DIR_DX[gui_dir] * mapview.width / 2;
562 gui_y += DIR_DY[gui_dir] * mapview.height / 2;
563 set_mapview_origin(gui_x, gui_y, map_zoom);
564}
565
566/**********************************************************************/
571 void action_button_pressed(int canvas_x, int canvas_y,
572 enum quickselect_type qtype)
573{
574 struct tile *ptile = canvas_pos_to_tile(canvas_x, canvas_y, mouse_zoom);
575
576 if (can_client_change_view() && ptile) {
577 /* FIXME: Some actions here will need to check can_client_issue_orders.
578 * But all we can check is the lowest common requirement. */
579 do_map_click(ptile, qtype);
580 }
581}
582
583/**********************************************************************/
586 void wakeup_button_pressed(int canvas_x, int canvas_y)
587{
588 struct tile *ptile = canvas_pos_to_tile(canvas_x, canvas_y, mouse_zoom);
589
590 if (can_client_issue_orders() && ptile) {
591 wakeup_sentried_units(ptile);
592 }
593}
594
595/**********************************************************************/
598 void adjust_workers_button_pressed(int canvas_x, int canvas_y)
599{
600 struct tile *ptile = canvas_pos_to_tile(canvas_x, canvas_y, mouse_zoom);
601
602 if (NULL != ptile && can_client_issue_orders()) {
603 struct city *pcity = find_city_near_tile(ptile);
604
605 if (pcity && !cma_is_city_under_agent(pcity, NULL)) {
606#ifndef FREECIV_NDEBUG
607 int city_x, city_y;
608#endif
609
610 fc_assert_ret(city_base_to_city_map(&city_x, &city_y, pcity, ptile));
611
612 if (NULL != tile_worked(ptile) && tile_worked(ptile) == pcity) {
613 dsend_packet_city_make_specialist(&client.conn,
614 pcity->id, ptile->index);
615 } else if (city_can_work_tile(pcity, ptile)) {
616 dsend_packet_city_make_worker(&client.conn,
617 pcity->id, ptile->index);
618 } else {
619 return;
620 }
621
622 /* When the city info packet is received, update the workers on the
623 * map. This is a bad hack used to selectively update the mapview
624 * when we receive the corresponding city packet. */
625 city_workers_display = pcity;
626 }
627 }
628}
629
630/**********************************************************************/
634 void recenter_button_pressed(int canvas_x, int canvas_y)
635{
636 /* We use the "nearest" tile here so off-map clicks will still work. */
637 struct tile *ptile = canvas_pos_to_nearest_tile(canvas_x, canvas_y,
638 mouse_zoom);
639
640 if (can_client_change_view() && ptile) {
641 center_tile_mapcanvas(ptile);
642 }
643}
644
645/**********************************************************************/
648 void update_turn_done_button_state(void)
649{
650 bool turn_done_state = get_turn_done_button_state();
651
652 set_turn_done_button_state(turn_done_state);
653
654 if (can_end_turn()) {
655 if (waiting_for_end_turn) {
656 send_turn_done();
657 } else {
658 update_turn_done_button(TRUE);
659 }
660 }
661}
662
663/**********************************************************************/
666 void update_line(int canvas_x, int canvas_y)
667{
668 struct tile *ptile;
669 struct unit_list *punits;
670
671 switch (hover_state) {
672 case HOVER_GOTO:
673 case HOVER_PATROL:
674 case HOVER_CONNECT:
675 ptile = canvas_pos_to_tile(canvas_x, canvas_y, mouse_zoom);
676
677 is_valid_goto_draw_line(ptile);
678 break;
679 case HOVER_GOTO_SEL_TGT:
680 ptile = canvas_pos_to_tile(canvas_x, canvas_y, mouse_zoom);
681 punits = get_units_in_focus();
682
683 set_hover_state(punits, hover_state, connect_activity, connect_tgt,
684 ptile->index, goto_last_sub_tgt,
685 goto_last_action, goto_last_order);
686 break;
687 case HOVER_NONE:
688 case HOVER_TELEPORT:
689 case HOVER_PARADROP:
690 case HOVER_ACT_SEL_TGT:
691 break;
692 };
693}
694
695/**********************************************************************/
698 void overview_update_line(int overview_x, int overview_y)
699{
700 struct tile *ptile;
701 struct unit_list *punits;
702 int x, y;
703
704 switch (hover_state) {
705 case HOVER_GOTO:
706 case HOVER_PATROL:
707 case HOVER_CONNECT:
708 overview_to_map_pos(&x, &y, overview_x, overview_y);
709 ptile = map_pos_to_tile(&(wld.map), x, y);
710
711 is_valid_goto_draw_line(ptile);
712 break;
713 case HOVER_GOTO_SEL_TGT:
714 overview_to_map_pos(&x, &y, overview_x, overview_y);
715 ptile = map_pos_to_tile(&(wld.map), x, y);
716 punits = get_units_in_focus();
717
718 set_hover_state(punits, hover_state, connect_activity, connect_tgt,
719 ptile->index, goto_last_sub_tgt,
720 goto_last_action, goto_last_order);
721 break;
722 case HOVER_NONE:
723 case HOVER_TELEPORT:
724 case HOVER_PARADROP:
725 case HOVER_ACT_SEL_TGT:
726 break;
727 };
728}
729
730/**********************************************************************/
737 static int unit_list_compare(const void *a, const void *b)
738{
739 const struct unit *punit1 = *(struct unit **)a;
740 const struct unit *punit2 = *(struct unit **)b;
741
742 if (unit_transport_get(punit1) == unit_transport_get(punit2)) {
743 /* For units with the same transporter or no transporter: sort by id. */
744 /* Perhaps we should sort by name instead? */
745 return punit1->id - punit2->id;
746 } else if (unit_transport_get(punit1) == punit2) {
747 return 1;
748 } else if (unit_transport_get(punit2) == punit1) {
749 return -1;
750 } else {
751 /* If the transporters aren't the same, put in order by the
752 * transporters. */
753 const struct unit *ptrans1 = unit_transport_get(punit1);
754 const struct unit *ptrans2 = unit_transport_get(punit2);
755
756 if (!ptrans1) {
757 ptrans1 = punit1;
758 }
759 if (!ptrans2) {
760 ptrans2 = punit2;
761 }
762
763 return unit_list_compare(&ptrans1, &ptrans2);
764 }
765}
766
767/**********************************************************************/
770 void fill_tile_unit_list(const struct tile *ptile, struct unit **unit_list)
771{
772 int i = 0;
773
774 /* First populate the unit list. */
775 unit_list_iterate(ptile->units, punit) {
776 unit_list[i] = punit;
777 i++;
778 } unit_list_iterate_end;
779
780 /* Then sort it. */
781 qsort(unit_list, i, sizeof(*unit_list), unit_list_compare);
782}
ACTION_NONE
#define ACTION_NONE
Definition actions.h:309
agents_busy
bool agents_busy(void)
Definition agents.c:803
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:1006
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:280
city_can_work_tile
bool city_can_work_tile(const struct city *pcity, const struct tile *ptile)
Definition city.c:1447
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:155
send_turn_done
void send_turn_done(void)
Definition client_main.c:806
client
struct civclient client
Definition client_main.c:150
can_client_issue_orders
bool can_client_issue_orders(void)
Definition client_main.c:1264
is_server_busy
bool is_server_busy(void)
Definition client_main.c:1337
can_client_change_view
bool can_client_change_view(void)
Definition client_main.c:1312
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:1081
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:2880
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:3095
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:62
is_player_phase
bool is_player_phase(const struct player *pplayer, int phase)
Definition game.c:705
wld
struct world wld
Definition game.c:63
game.h
is_valid_goto_draw_line
bool is_valid_goto_draw_line(struct tile *dest_tile)
Definition goto.c:1338
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: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:419
same_pos
bool same_pos(const struct tile *tile1, const struct tile *tile2)
Definition map.c:940
map_distance_vector
void map_distance_vector(int *dx, int *dy, const struct tile *tile0, const struct tile *tile1)
Definition map.c:1073
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:666
maybe_activate_keyboardless_goto
void maybe_activate_keyboardless_goto(int canvas_x, int canvas_y)
Definition mapctrl_common.c:508
adjust_workers_button_pressed
void adjust_workers_button_pressed(int canvas_x, int canvas_y)
Definition mapctrl_common.c:598
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:488
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:634
upgrade_canvas_clipboard
void upgrade_canvas_clipboard(void)
Definition mapctrl_common.c:470
update_turn_done_button_state
void update_turn_done_button_state(void)
Definition mapctrl_common.c:648
action_button_pressed
void action_button_pressed(int canvas_x, int canvas_y, enum quickselect_type qtype)
Definition mapctrl_common.c:571
wakeup_button_pressed
void wakeup_button_pressed(int canvas_x, int canvas_y)
Definition mapctrl_common.c:586
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:523
scroll_mapview
void scroll_mapview(enum direction8 gui_dir)
Definition mapctrl_common.c:553
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:532
overview_update_line
void overview_update_line(int overview_x, int overview_y)
Definition mapctrl_common.c:698
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:425
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:770
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:454
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:737
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:3355
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:2819
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:2909
mapdeco_is_highlight_set
bool mapdeco_is_highlight_set(const struct tile *ptile)
Definition mapview_common.c:3378
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:3390
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:4019
option_bool_get
bool option_bool_get(const struct option *poption)
Definition options.c:796
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:430
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:357
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:19041
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:18610
dsend_packet_city_make_worker
int dsend_packet_city_make_worker(struct connection *pc, int city_id, int tile_id)
Definition packets_gen.c:19256
is_human
#define is_human(plr)
Definition player.h:229
are_universals_equal
bool are_universals_equal(const struct universal *psource1, const struct universal *psource2)
Definition requirements.c:6466
universal_number
int universal_number(const struct universal *source)
Definition requirements.c:872
universal_name_translation
const char * universal_name_translation(const struct universal *psource, char *buf, size_t bufsz)
Definition requirements.c:6755
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
civ_map::xsize
int xsize
Definition map_types.h:78
civclient::conn
struct connection conn
Definition client_main.h:96
client_options::ai_manual_turn_done
bool ai_manual_turn_done
Definition options.h:154
client_options::separate_unit_selection
bool separate_unit_selection
Definition options.h:174
connection::playing
struct player * playing
Definition connection.h:151
option
Definition options.c:478
packet_game_info::phase
int phase
Definition packets_gen.h:206
player::cities
struct city_list * cities
Definition player.h:279
player::is_alive
bool is_alive
Definition player.h:266
player::phase_done
bool phase_done
Definition player.h:261
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:481
unit_type
Definition unittype.h:500
unit
Definition unit.h:138
unit::id
int id
Definition unit.h:145
universal
Definition fc_types.h:901
universal::kind
enum universals_n kind
Definition fc_types.h:903
universal::value
universals_u value
Definition fc_types.h:902
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:114
tileset_is_isometric
bool tileset_is_isometric(const struct tileset *t)
Definition tilespec.c:712
tileset_tile_height
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:765
tileset_tile_width
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:753
tilespec.h
universals_u::utype
const struct unit_type * utype
Definition fc_types.h:724
universals_u::building
const struct impr_type * building
Definition fc_types.h:717
unit_transport_get
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2437
ORDER_LAST
@ ORDER_LAST
Definition unit.h:49
unit_owner
#define unit_owner(_pu)
Definition unit.h:389
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
mouse_zoom
float mouse_zoom
Definition zoom.c:28
map_zoom
float map_zoom
Definition zoom.c:25
zoom.h