Freeciv-3.1
Loading...
Searching...
No Matches
climisc.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
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/***********************************************************************
15 This module contains various general - mostly highlevel - functions
16 used throughout the client.
17***********************************************************************/
18
19#ifdef HAVE_CONFIG_H
20#include <fc_config.h>
21#endif
22
23#include <stdarg.h>
24#include <stdio.h>
25#include <stdlib.h>
26#include <string.h>
27
28/* utility */
29#include "bitvector.h"
30#include "fcintl.h"
31#include "log.h"
32#include "support.h"
33
34/* common */
35#include "city.h"
36#include "diptreaty.h"
37#include "featured_text.h"
38#include "game.h"
39#include "government.h"
40#include "map.h"
41#include "mapimg.h"
42#include "packets.h"
43#include "research.h"
44#include "spaceship.h"
45#include "unitlist.h"
46
47/* client/include */
48#include "chatline_g.h"
49#include "citydlg_g.h"
50#include "cityrep_g.h"
51#include "dialogs_g.h"
52#include "gui_main_g.h"
53#include "mapview_g.h"
54
55/* client */
56#include "client_main.h"
57#include "climap.h"
58#include "climisc.h"
59#include "control.h"
60#include "mapctrl_common.h"
61#include "mapview_common.h"
62#include "messagewin_common.h"
63#include "options.h"
64#include "packhand.h"
65#include "repodlgs_common.h"
66#include "tilespec.h"
67
68
69/**********************************************************************/
73{
74 struct city *pcity;
75 struct tile *ptile = unit_tile(punit);
76 int hc = punit->homecity;
77 struct unit old_unit = *punit;
78 int old = get_num_units_in_focus();
79 bool update;
80
81 log_debug("removing unit %d, %s %s (%d %d) hcity %d",
84
85 update = (get_focus_unit_on_tile(unit_tile(punit)) != NULL);
86
87 /* Check transport status. */
91 /* The server should take care that the unit is on the right terrain. */
94 }
95
98 punit = NULL;
99 if (old > 0 && get_num_units_in_focus() == 0) {
101 } else if (update) {
104 }
105
106 pcity = tile_city(ptile);
107 if (NULL != pcity) {
109 pcity->client.occupied = (0 < unit_list_size(pcity->tile->units));
110 refresh_city_dialog(pcity);
111 }
112
113 log_debug("map city %s, %s, (%d %d)",
115 TILE_XY(city_tile(pcity)));
116 }
117
118 if (!client_has_player() || unit_owner(&old_unit) == client_player()) {
119 pcity = game_city_by_number(hc);
120 if (NULL != pcity) {
121 refresh_city_dialog(pcity);
122 log_debug("home city %s, %s, (%d %d)",
124 TILE_XY(city_tile(pcity)));
125 }
126 }
127
128 refresh_unit_mapcanvas(&old_unit, ptile, TRUE, FALSE);
129}
130
131/**********************************************************************/
134void client_remove_city(struct city *pcity)
135{
136 bool effect_update;
137 struct tile *ptile = city_tile(pcity);
138 struct city old_city = *pcity;
139
140 log_debug("client_remove_city() %d, %s", pcity->id, city_name_get(pcity));
141
142 /* Explicitly remove all improvements, to properly remove any global effects
143 and to handle the preservation of "destroyed" effects. */
144 effect_update = FALSE;
145
146 city_built_iterate(pcity, pimprove) {
147 effect_update = TRUE;
148 city_remove_improvement(pcity, pimprove);
150
151 if (effect_update) {
152 /* nothing yet */
153 }
154
155 popdown_city_dialog(pcity);
156 game_remove_city(&wld, pcity);
158 refresh_city_mapcanvas(&old_city, ptile, TRUE, FALSE);
159}
160
161/**********************************************************************/
165void client_change_all(struct universal *from, struct universal *to)
166{
168 return;
169 }
170
171 create_event(NULL, E_CITY_PRODUCTION_CHANGED, ftc_client,
172 _("Changing production of every %s into %s."),
173 VUT_UTYPE == from->kind
176 VUT_UTYPE == to->kind
179
182 if (are_universals_equal(&pcity->production, from)
183 && can_city_build_now(&(wld.map), pcity, to)) {
184 city_change_production(pcity, to);
185 }
187
189}
190
191/**********************************************************************/
194const char *get_embassy_status(const struct player *me,
195 const struct player *them)
196{
197 if (!me || !them
198 || me == them
199 || !them->is_alive
200 || !me->is_alive) {
201 return "-";
202 }
203 if (player_has_embassy(me, them)) {
204 if (player_has_embassy(them, me)) {
205 return Q_("?embassy:Both");
206 } else {
207 return Q_("?embassy:Yes");
208 }
209 } else if (player_has_embassy(them, me)) {
210 return Q_("?embassy:With Us");
211 } else if (player_diplstate_get(me, them)->contact_turns_left > 0
212 || player_diplstate_get(them, me)->contact_turns_left > 0) {
213 return Q_("?embassy:Contact");
214 } else {
215 return Q_("?embassy:No Contact");
216 }
217}
218
219/**********************************************************************/
222const char *get_vision_status(const struct player *me,
223 const struct player *them)
224{
225 if (me && them && gives_shared_vision(me, them)) {
226 if (gives_shared_vision(them, me)) {
227 return Q_("?vision:Both");
228 } else {
229 return Q_("?vision:To Them");
230 }
231 } else if (me && them && gives_shared_vision(them, me)) {
232 return Q_("?vision:To Us");
233 } else {
234 return "";
235 }
236}
237
238/**********************************************************************/
241void client_diplomacy_clause_string(char *buf, int bufsiz,
242 struct Clause *pclause)
243{
244 struct city *pcity;
245
246 switch (pclause->type) {
247 case CLAUSE_ADVANCE:
248 fc_snprintf(buf, bufsiz, _("The %s give %s"),
251 break;
252 case CLAUSE_CITY:
253 pcity = game_city_by_number(pclause->value);
254 if (pcity) {
255 fc_snprintf(buf, bufsiz, _("The %s give %s"),
257 city_name_get(pcity));
258 } else {
259 fc_snprintf(buf, bufsiz,_("The %s give an unknown city"),
261 }
262 break;
263 case CLAUSE_GOLD:
264 fc_snprintf(buf, bufsiz, PL_("The %s give %d gold",
265 "The %s give %d gold", pclause->value),
267 pclause->value);
268 break;
269 case CLAUSE_MAP:
270 fc_snprintf(buf, bufsiz, _("The %s give their worldmap"),
272 break;
273 case CLAUSE_SEAMAP:
274 fc_snprintf(buf, bufsiz, _("The %s give their seamap"),
276 break;
277 case CLAUSE_CEASEFIRE:
278 fc_snprintf(buf, bufsiz, _("The parties agree on a cease-fire"));
279 break;
280 case CLAUSE_PEACE:
281 fc_snprintf(buf, bufsiz, _("The parties agree on a peace"));
282 break;
283 case CLAUSE_ALLIANCE:
284 fc_snprintf(buf, bufsiz, _("The parties create an alliance"));
285 break;
286 case CLAUSE_VISION:
287 fc_snprintf(buf, bufsiz, _("The %s give shared vision"),
289 break;
290 case CLAUSE_EMBASSY:
291 fc_snprintf(buf, bufsiz, _("The %s give an embassy"),
293 break;
294 default:
296 if (bufsiz > 0) {
297 *buf = '\0';
298 }
299 break;
300 }
301}
302
303/**********************************************************************/
308static void catastrophe_scaled(int *chance, int *rate, int max,
309 int current, int accum, int level)
310{
311 /* 20 from factor in update_environmental_upset() */
312 int numer = 20 * max;
313 int denom = map_num_tiles();
314
315 if (chance) {
316 *chance = CLIP(0,
317 (int)((((long)accum * numer) + (denom - 1)) / denom),
318 max);
319 }
320 if (rate) {
321 *rate = DIVIDE(((long)(current - level) * numer) + (denom - 1), denom);
322 }
323}
324
325/**********************************************************************/
328void global_warming_scaled(int *chance, int *rate, int max)
329{
330 return catastrophe_scaled(chance, rate, max,
333}
334
335/**********************************************************************/
338void nuclear_winter_scaled(int *chance, int *rate, int max)
339{
340 return catastrophe_scaled(chance, rate, max,
343}
344
345/**********************************************************************/
349{
350 if (NULL != client.conn.playing && can_client_change_view()) {
351 const struct research *presearch = research_get(client_player());
352 int idx = 0;
353
354 if (A_UNSET != presearch->researching) {
355 idx = (NUM_TILES_PROGRESS * presearch->bulbs_researched
356 / (presearch->client.researching_cost + 1));
357 }
358
359 /* This clipping can be necessary since we can end up with excess
360 * research */
361 idx = CLIP(0, idx, NUM_TILES_PROGRESS - 1);
363 } else {
365 }
366}
367
368/**********************************************************************/
372{
373 int idx;
374
376 /* Highest sprite kicks in at about 25% risk */
377 global_warming_scaled(&idx, NULL, (NUM_TILES_PROGRESS-1)*4);
378 idx = CLIP(0, idx, NUM_TILES_PROGRESS-1);
379 } else {
380 idx = 0;
381 }
383}
384
385/**********************************************************************/
389{
390 int idx;
391
393 /* Highest sprite kicks in at about 25% risk */
394 nuclear_winter_scaled(&idx, NULL, (NUM_TILES_PROGRESS-1)*4);
395 idx = CLIP(0, idx, NUM_TILES_PROGRESS-1);
396 } else {
397 idx = 0;
398 }
399
401}
402
403/**********************************************************************/
407{
409 && government_count() > 0) {
411
412 return get_government_sprite(tileset, gov);
413 } else {
414 /* HACK: the UNHAPPY citizen is used for the government
415 * when we don't know any better. */
417 }
418}
419
420/**********************************************************************/
425{
426 struct city *pcity;
427 struct unit *punit;
428 const struct civ_map *nmap = &(wld.map);
429
430 if (!can_client_change_view()) {
431 return;
432 }
433
435 if (get_num_units_in_focus() > 0) {
437 } else if (client_has_player()
438 && NULL != (pcity = player_primary_capital(client_player()))) {
439 /* Else focus on the capital. */
441 } else if (NULL != client.conn.playing
442 && 0 < city_list_size(client.conn.playing->cities)) {
443 /* Just focus on any city. */
444 pcity = city_list_get(client.conn.playing->cities, 0);
445 fc_assert_ret(pcity != NULL);
447 } else if (NULL != client.conn.playing
448 && 0 < unit_list_size(client.conn.playing->units)) {
449 /* Just focus on any unit. */
450 punit = unit_list_get(client.conn.playing->units, 0);
451 fc_assert_ret(punit != NULL);
453 } else {
454 struct tile *ctile = native_pos_to_tile(nmap, wld.map.xsize / 2, wld.map.ysize / 2);
455
456 /* Just any known tile will do; search near the middle first. */
457 /* Iterate outward from the center tile. We have to give a radius that
458 * is guaranteed to be larger than the map will be. Although this is
459 * a misuse of map.xsize and map.ysize (which are native dimensions),
460 * it should give a sufficiently large radius. */
461 iterate_outward(nmap, ctile, wld.map.xsize + wld.map.ysize, ptile) {
462 if (client_tile_get_known(ptile) != TILE_UNKNOWN) {
463 ctile = ptile;
464 break;
465 }
467
469 }
470 can_slide = TRUE;
471}
472
473/**********************************************************************/
477{
478 return VUT_UTYPE == target.kind
479 ? B_LAST + utype_number(target.value.utype)
481}
482
483/**********************************************************************/
486cid cid_encode_unit(const struct unit_type *punittype)
487{
488 struct universal target = {
489 .kind = VUT_UTYPE,
490 .value = {.utype = punittype}};
491
492 return cid_encode(target);
493}
494
495/**********************************************************************/
498cid cid_encode_building(const struct impr_type *pimprove)
499{
500 struct universal target = {
501 .kind = VUT_IMPROVEMENT,
502 .value = {.building = pimprove}
503 };
504
505 return cid_encode(target);
506}
507
508/**********************************************************************/
511cid cid_encode_from_city(const struct city *pcity)
512{
513 return cid_encode(pcity->production);
514}
515
516/**********************************************************************/
520{
521 struct universal target;
522
523 if (id >= B_LAST) {
524 target.kind = VUT_UTYPE;
525 target.value.utype = utype_by_number(id - B_LAST);
526 } else {
527 target.kind = VUT_IMPROVEMENT;
529 }
530
531 return target;
532}
533
534/**********************************************************************/
538bool city_unit_supported(const struct city *pcity,
539 const struct universal *target)
540{
541 if (VUT_UTYPE == target->kind) {
542 const struct unit_type *tvtype = target->value.utype;
543
545 if (unit_type_get(punit) == tvtype) {
546 return TRUE;
547 }
549 }
550 return FALSE;
551}
552
553/**********************************************************************/
557bool city_unit_present(const struct city *pcity,
558 const struct universal *target)
559{
560 if (VUT_UTYPE == target->kind) {
561 const struct unit_type *tvtype = target->value.utype;
562
564 if (unit_type_get(punit) == tvtype) {
565 return TRUE;
566 }
567 }
569 }
570 return FALSE;
571}
572
573/**********************************************************************/
576bool city_building_present(const struct city *pcity,
577 const struct universal *target)
578{
579 return VUT_IMPROVEMENT == target->kind
580 && city_has_building(pcity, target->value.building);
581}
582
583/**********************************************************************/
586bool can_city_build_now_client(const struct city *pcity,
587 const struct universal *target)
588{
589 return can_city_build_now(&(wld.map), pcity, target);
590}
591
592/**********************************************************************/
595static int target_get_section(struct universal target)
596{
597 if (VUT_UTYPE == target.kind) {
598 if (utype_has_flag(target.value.utype, UTYF_CIVILIAN)) {
599 return 2;
600 } else {
601 return 3;
602 }
603 } else {
604 if (improvement_has_flag(target.value.building, IF_GOLD)) {
605 return 1;
606 } else if (is_small_wonder(target.value.building)) {
607 return 4;
608 } else if (is_great_wonder(target.value.building)) {
609 return 5;
610 } else {
611 return 0;
612 }
613 }
614}
615
616/**********************************************************************/
619static int fc_cmp(const void *p1, const void *p2)
620{
621 const struct item *i1 = p1, *i2 = p2;
622 int s1 = target_get_section(i1->item);
623 int s2 = target_get_section(i2->item);
624
625 if (s1 == s2) {
626 return fc_strcasecmp(i1->descr, i2->descr);
627 }
628
629 return s1 - s2;
630}
631
632/**********************************************************************/
643void name_and_sort_items(struct universal *targets, int num_targets,
644 struct item *items,
645 bool show_cost, struct city *pcity)
646{
647 int i;
648
649 for (i = 0; i < num_targets; i++) {
650 struct universal target = targets[i];
651 int cost;
652 struct item *pitem = &items[i];
653 const char *name;
654
655 pitem->item = target;
656
657 if (VUT_UTYPE == target.kind) {
660 } else {
662 if (improvement_has_flag(target.value.building, IF_GOLD)) {
663 cost = -1;
664 } else {
665 if (pcity != NULL) {
666 cost = impr_build_shield_cost(pcity, target.value.building);
667 } else {
668 cost = MAX(target.value.building->build_cost * game.info.shieldbox / 100, 1);
669 }
670 }
671 }
672
673 if (show_cost) {
674 if (cost < 0) {
675 fc_snprintf(pitem->descr, sizeof(pitem->descr), "%s (XX)", name);
676 } else {
677 fc_snprintf(pitem->descr, sizeof(pitem->descr),
678 "%s (%d)", name, cost);
679 }
680 } else {
681 (void) fc_strlcpy(pitem->descr, name, sizeof(pitem->descr));
682 }
683 }
684
685 qsort(items, num_targets, sizeof(struct item), fc_cmp);
686}
687
688/**********************************************************************/
694 struct city **selected_cities,
695 int num_selected_cities, bool append_units,
696 bool append_wonders, bool change_prod,
698{
699 cid first = append_units ? B_LAST : 0;
700 cid last = (append_units
701 ? utype_count() + B_LAST
703 cid id;
704 int items_used = 0;
705
706 for (id = first; id < last; id++) {
707 bool append = FALSE;
708 struct universal target = cid_decode(id);
709
710 if (!append_units && (append_wonders != is_wonder(target.value.building))) {
711 continue;
712 }
713
714 if (!change_prod) {
715 if (client_has_player()) {
717 append |= test_func(pcity, &target);
719 } else {
720 cities_iterate(pcity) {
721 append |= test_func(pcity, &target);
723 }
724 } else {
725 int i;
726
727 for (i = 0; i < num_selected_cities; i++) {
728 append |= test_func(selected_cities[i], &target);
729 }
730 }
731
732 if (!append) {
733 continue;
734 }
735
736 targets[items_used] = target;
737 items_used++;
738 }
739
740 return items_used;
741}
742
743/**********************************************************************/
750{
751 bool mapping[MAX_NUM_PRODUCTION_TARGETS];
752 int cids_used = 0;
753 cid id;
754
755 if (NULL == client.conn.playing) {
756 return 0;
757 }
758
759 memset(mapping, 0, sizeof(mapping));
761 mapping[cid_encode_from_city(pcity)] = TRUE;
762 }
764
765 for (id = 0; id < ARRAY_SIZE(mapping); id++) {
766 if (mapping[id]) {
767 targets[cids_used] = cid_decode(id);
768 cids_used++;
769 }
770 }
771
772 return cids_used;
773}
774
775/**********************************************************************/
782{
783 int cids_used = 0;
784
785 if (NULL == client.conn.playing) {
786 return 0;
787 }
788
789 improvement_iterate(pimprove) {
791 targets[cids_used].kind = VUT_IMPROVEMENT;
792 targets[cids_used].value.building = pimprove;
793 cids_used++;
794 }
796
797 unit_type_iterate(punittype) {
799 targets[cids_used].kind = VUT_UTYPE;
800 targets[cids_used].value.utype = punittype;
801 cids_used++;
802 }
804
805 return cids_used;
806}
807
808/**********************************************************************/
813 struct city *pcity,
814 bool advanced_tech)
815{
816 struct player *pplayer = client_player();
817 int cids_used = 0;
818 const struct civ_map *nmap = &(wld.map);
819
820 improvement_iterate(pimprove) {
821 bool can_build;
822 bool can_eventually_build;
823
824 if (NULL != pcity) {
825 /* Can the city build? */
826 can_build = can_city_build_improvement_now(pcity, pimprove);
827 can_eventually_build = can_city_build_improvement_later(pcity,
828 pimprove);
829 } else if (NULL != pplayer) {
830 /* Can our player build? */
831 can_build = can_player_build_improvement_now(pplayer, pimprove);
832 can_eventually_build = can_player_build_improvement_later(pplayer,
833 pimprove);
834 } else {
835 /* Global observer case: can any player build? */
836 can_build = FALSE;
837 players_iterate(aplayer) {
838 if (can_player_build_improvement_now(aplayer, pimprove)) {
839 can_build = TRUE;
840 break;
841 }
843
844 can_eventually_build = FALSE;
845 players_iterate(aplayer) {
846 if (can_player_build_improvement_later(aplayer, pimprove)) {
847 can_eventually_build = TRUE;
848 break;
849 }
851 }
852
853 if ((advanced_tech && can_eventually_build)
854 || (!advanced_tech && can_build)) {
855 targets[cids_used].kind = VUT_IMPROVEMENT;
856 targets[cids_used].value.building = pimprove;
857 cids_used++;
858 }
860
861 unit_type_iterate(punittype) {
862 bool can_build;
863 bool can_eventually_build;
864
865 if (NULL != pcity) {
866 /* Can the city build? */
867 can_build = can_city_build_unit_now(nmap, pcity, punittype);
868 can_eventually_build = can_city_build_unit_later(nmap, pcity, punittype);
869 } else if (NULL != pplayer) {
870 /* Can our player build? */
871 can_build = can_player_build_unit_now(pplayer, punittype);
872 can_eventually_build = can_player_build_unit_later(pplayer, punittype);
873 } else {
874 /* Global observer case: can any player build? */
875 can_build = FALSE;
876 players_iterate(aplayer) {
877 if (can_player_build_unit_now(aplayer, punittype)) {
878 can_build = TRUE;
879 break;
880 }
882
883 can_eventually_build = FALSE;
884 players_iterate(aplayer) {
885 if (can_player_build_unit_later(aplayer, punittype)) {
886 can_eventually_build = TRUE;
887 break;
888 }
890 }
891
892 if ((advanced_tech && can_eventually_build)
893 || (!advanced_tech && can_build)) {
894 targets[cids_used].kind = VUT_UTYPE;
895 targets[cids_used].value.utype = punittype;
896 cids_used++;
897 }
899
900 return cids_used;
901}
902
903/**********************************************************************/
907 struct city *pcity)
908{
909 int cids_used = 0;
910
911 fc_assert_ret_val(pcity != NULL, 0);
912
913 city_built_iterate(pcity, pimprove) {
914 targets[cids_used].kind = VUT_IMPROVEMENT;
915 targets[cids_used].value.building = pimprove;
916 cids_used++;
918
919 return cids_used;
920}
921
922/**********************************************************************/
927{
928 struct unit_list *plist;
929
931 /* Other players don't see inside the city (but observers do). */
932 plist = pcity->client.info_units_supported;
933 } else {
934 plist = pcity->units_supported;
935 }
936
937 return unit_list_size(plist);
938}
939
940/**********************************************************************/
945{
946 struct unit_list *plist;
947
949 /* Other players don't see inside the city (but observers do). */
950 plist = pcity->client.info_units_present;
951 } else {
952 plist = pcity->tile->units;
953 }
954
955 return unit_list_size(plist);
956}
957
958/**********************************************************************/
961void handle_event(const char *featured_text, struct tile *ptile,
962 enum event_type event, int turn, int phase, int conn_id)
963{
964 char plain_text[MAX_LEN_MSG];
965 struct text_tag_list *tags;
966 int where = MW_OUTPUT; /* where to display the message */
967 bool fallback_needed = FALSE; /* we want fallback if actual 'where' is not
968 * usable */
969 bool shown = FALSE; /* Message displayed somewhere at least */
970
971 if (!event_type_is_valid(event)) {
972 /* Server may have added a new event; leave as MW_OUTPUT */
973 log_verbose("Unknown event type %d!", event);
974 } else {
975 where = messages_where[event];
976 }
977
978 /* Get the original text. */
979 featured_text_to_plain_text(featured_text, plain_text,
980 sizeof(plain_text), &tags, conn_id != -1);
981
982 /* Display link marks when an user is pointed us something. */
983 if (conn_id != -1) {
984 text_tag_list_iterate(tags, ptag) {
985 if (text_tag_type(ptag) == TTT_LINK) {
987 }
989 }
990
991 /* Maybe highlight our player and user names if someone is talking
992 * about us. */
993 if (-1 != conn_id
994 && client.conn.id != conn_id
996 const char *username = client.conn.username;
997 size_t userlen = strlen(username);
998 const char *playername = ((client_player() && !client_is_observer())
999 ? player_name(client_player()) : NULL);
1000 size_t playerlen = playername ? strlen(playername) : 0;
1001 const char *p;
1002
1003 if (playername && playername[0] == '\0') {
1004 playername = NULL;
1005 }
1006
1007 if (username && username[0] == '\0') {
1008 username = NULL;
1009 }
1010
1011 for (p = plain_text; *p != '\0'; p++) {
1012 if (NULL != username
1013 && 0 == fc_strncasecmp(p, username, userlen)) {
1014 struct text_tag *ptag = text_tag_new(TTT_COLOR, p - plain_text,
1015 p - plain_text + userlen,
1017
1018 fc_assert(ptag != NULL);
1019
1020 if (ptag != NULL) {
1021 /* Appends to be sure it will be applied at last. */
1022 text_tag_list_append(tags, ptag);
1023 }
1024 } else if (NULL != playername
1025 && 0 == fc_strncasecmp(p, playername, playerlen)) {
1026 struct text_tag *ptag = text_tag_new(TTT_COLOR, p - plain_text,
1027 p - plain_text + playerlen,
1029
1030 fc_assert(ptag != NULL);
1031
1032 if (ptag != NULL) {
1033 /* Appends to be sure it will be applied at last. */
1034 text_tag_list_append(tags, ptag);
1035 }
1036 }
1037 }
1038 }
1039
1040 /* Popup */
1041 if (BOOL_VAL(where & MW_POPUP)) {
1042 /* Popups are usually not shown if player is under AI control.
1043 * Server operator messages are shown always. */
1044 if (NULL == client.conn.playing
1046 || event == E_MESSAGE_WALL) {
1047 popup_notify_goto_dialog(_("Popup Request"), plain_text, tags, ptile);
1048 shown = TRUE;
1049 } else {
1050 /* Force to chatline so it will be visible somewhere at least.
1051 * Messages window may still handle this so chatline is not needed
1052 * after all. */
1053 fallback_needed = TRUE;
1054 }
1055 }
1056
1057 /* Message window */
1058 if (BOOL_VAL(where & MW_MESSAGES)) {
1059 /* When the game isn't running, the messages dialog isn't present. */
1060 if (C_S_RUNNING <= client_state()) {
1061 meswin_add(plain_text, tags, ptile, event, turn, phase);
1062 shown = TRUE;
1063 } else {
1064 /* Force to chatline instead. */
1065 fallback_needed = TRUE;
1066 }
1067 }
1068
1069 /* Chatline */
1070 if (BOOL_VAL(where & MW_OUTPUT) || (fallback_needed && !shown)) {
1071 output_window_event(plain_text, tags, conn_id);
1072 }
1073
1074 if (turn == game.info.turn) {
1076 }
1077
1078 /* Free tags */
1079 text_tag_list_destroy(tags);
1080}
1081
1082/**********************************************************************/
1086void create_event(struct tile *ptile, enum event_type event,
1087 const struct ft_color color, const char *format, ...)
1088{
1089 va_list ap;
1090 char message[MAX_LEN_MSG];
1091
1092 va_start(ap, format);
1093 fc_vsnprintf(message, sizeof(message), format, ap);
1094 va_end(ap);
1095
1097 char colored_text[MAX_LEN_MSG];
1098
1099 featured_text_apply_tag(message, colored_text, sizeof(colored_text),
1101 handle_event(colored_text, ptile, event, game.info.turn, game.info.phase, -1);
1102 } else {
1104 }
1105}
1106
1107/**********************************************************************/
1112struct city *get_nearest_city(const struct unit *punit, int *sq_dist)
1113{
1114 struct city *pcity_near;
1115 int pcity_near_dist;
1116
1117 if ((pcity_near = tile_city(unit_tile(punit)))) {
1118 pcity_near_dist = 0;
1119 } else {
1120 pcity_near = NULL;
1121 pcity_near_dist = -1;
1122 players_iterate(pplayer) {
1123 city_list_iterate(pplayer->cities, pcity_current) {
1124 int dist = sq_map_distance(pcity_current->tile, unit_tile(punit));
1125
1126 if (pcity_near_dist == -1 || dist < pcity_near_dist
1127 || (dist == pcity_near_dist
1128 && unit_owner(punit) == city_owner(pcity_current))) {
1129 pcity_near = pcity_current;
1130 pcity_near_dist = dist;
1131 }
1134 }
1135
1136 if (sq_dist) {
1137 *sq_dist = pcity_near_dist;
1138 }
1139
1140 return pcity_near;
1141}
1142
1143/**********************************************************************/
1148void cityrep_buy(struct city *pcity)
1149{
1150 int value;
1151
1152 if (city_production_has_flag(pcity, IF_GOLD)) {
1153 create_event(pcity->tile, E_BAD_COMMAND, ftc_client,
1154 _("You can't buy %s in %s!"),
1156 city_link(pcity));
1157 return;
1158 }
1159 value = pcity->client.buy_cost;
1160
1161 if (city_owner(pcity)->economic.gold >= value) {
1162 city_buy_production(pcity);
1163 } else {
1164 /* Split into two to allow localization of two pluralisations. */
1165 char buf[MAX_LEN_MSG];
1166
1167 /* TRANS: %s is a production type; this whole string is a sentence
1168 * fragment that is only ever included in one other string
1169 * (search comments for this string to find it) */
1170 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("%s costs %d gold",
1171 "%s costs %d gold", value),
1173 value);
1174 create_event(NULL, E_BAD_COMMAND, ftc_client,
1175 /* TRANS: %s is a pre-pluralised sentence fragment:
1176 * "%s costs %d gold" */
1177 PL_("%s and you only have %d gold.",
1178 "%s and you only have %d gold.",
1179 city_owner(pcity)->economic.gold),
1180 buf, city_owner(pcity)->economic.gold);
1181 }
1182}
1183
1184/**********************************************************************/
1187void common_taxrates_callback(int idx, bool reverse)
1188{
1189 int lux_end, sci_end, tax, lux, sci;
1190 int delta = 10;
1191
1192 if (!can_client_issue_orders()) {
1193 return;
1194 }
1195
1196 lux_end = client.conn.playing->economic.luxury;
1197 sci_end = lux_end + client.conn.playing->economic.science;
1198
1202
1203 idx *= 10;
1204
1205 if (reverse) {
1206 if (idx < lux_end) {
1207 lux -= delta;
1208 tax += delta;
1209 } else if (idx < sci_end) {
1210 sci -= delta;
1211 lux += delta;
1212 } else {
1213 tax -= delta;
1214 sci += delta;
1215 }
1216 } else {
1217 if (idx < lux_end) {
1218 lux -= delta;
1219 sci += delta;
1220 } else if (idx < sci_end) {
1221 sci -= delta;
1222 tax += delta;
1223 } else {
1224 tax -= delta;
1225 lux += delta;
1226 }
1227 }
1228
1229 dsend_packet_player_rates(&client.conn, tax, lux, sci);
1230}
1231
1232/**********************************************************************/
1235bool can_units_do_connect(struct unit_list *punits,
1236 enum unit_activity activity,
1237 struct extra_type *tgt)
1238{
1239 unit_list_iterate(punits, punit) {
1240 if (can_unit_do_connect(punit, activity, tgt)) {
1241 return TRUE;
1242 }
1244
1245 return FALSE;
1246}
1247
1248/**********************************************************************/
1253{
1254 /* A double init would cause a leak. */
1256
1259}
1260
1261/**********************************************************************/
1268enum unit_bg_color_type unit_color_type(const struct unit_type *punittype)
1269{
1270 struct unit_class *pclass = utype_class(punittype);
1271
1272 if (pclass->hp_loss_pct > 0) {
1273 return UNIT_BG_HP_LOSS;
1274 }
1275
1276 if (pclass->move_type == UMT_LAND) {
1277 return UNIT_BG_LAND;
1278 }
1279 if (pclass->move_type == UMT_SEA) {
1280 return UNIT_BG_SEA;
1281 }
1282
1283 fc_assert(pclass->move_type == UMT_BOTH);
1284
1285 if (uclass_has_flag(pclass, UCF_TERRAIN_SPEED)) {
1286 /* Unit moves on both sea and land by speed determined by terrain */
1287 return UNIT_BG_AMPHIBIOUS;
1288 }
1289
1290 return UNIT_BG_FLYING;
1291}
1292
1293/**********************************************************************/
1296static int city_buy_cost_compare(const void *a, const void *b)
1297{
1298 const struct city *ca, *cb;
1299
1300 ca = *((const struct city **) a);
1301 cb = *((const struct city **) b);
1302
1303 return ca->client.buy_cost - cb->client.buy_cost;
1304}
1305
1306/**********************************************************************/
1311{
1312 const struct player *pplayer = client_player();
1313 struct connection *pconn;
1314
1315 if (!pplayer || !pplayer->cities
1316 || city_list_size(pplayer->cities) < 1) {
1317 return;
1318 }
1319
1320 int gold = pplayer->economic.gold;
1321 if (gold < 1) {
1322 return;
1323 }
1324
1325 const int n = city_list_size(pplayer->cities);
1326 struct city *cities[n];
1327 int i, count = 0;
1328
1329 city_list_iterate(pplayer->cities, pcity) {
1330 if (!is_city_hilited(pcity) || !city_can_buy(pcity)) {
1331 continue;
1332 }
1333 cities[count++] = pcity;
1335
1336 if (count < 1) {
1337 return;
1338 }
1339
1340 qsort(cities, count, sizeof(*cities), city_buy_cost_compare);
1341
1342 pconn = &client.conn;
1343 connection_do_buffer(pconn);
1344
1345 for (i = 0; i < count && gold > 0; i++) {
1346 gold -= cities[i]->client.buy_cost;
1348 }
1349
1351}
1352
1353/**********************************************************************/
1356void unit_focus_set_status(struct player *pplayer)
1357{
1358 unit_list_iterate(pplayer->units, punit) {
1361}
1362
1363/**********************************************************************/
1366void client_player_init(struct player *pplayer)
1367{
1369 pplayer->client.tile_vision[v].vec = NULL;
1370 pplayer->client.tile_vision[v].bits = 0;
1372}
1373
1374/**********************************************************************/
1378{
1379 players_iterate(pplayer) {
1380 int new_size;
1381
1382 if (pplayer == client.conn.playing) {
1383 new_size = MAP_INDEX_SIZE;
1384 } else {
1385 /* We don't need (or have) information about players other
1386 * than user of the client. Allocate just one bit as that's
1387 * the minimum bitvector size (cannot allocate 0 bits)*/
1388 new_size = 1;
1389 }
1390
1392 dbv_resize(&pplayer->client.tile_vision[v], new_size);
1394
1395 dbv_resize(&pplayer->tile_known, new_size);
1397}
1398
1399/**********************************************************************/
1403{
1404 char str[MAX_LEN_MAPDEF];
1405 char mi_map[MAPIMG_LAYER_COUNT + 1];
1406 enum mapimg_layer layer;
1407 int map_pos = 0;
1408
1409 /* Only one definition allowed. */
1410 while (mapimg_count() != 0) {
1411 mapimg_delete(0);
1412 }
1413
1414 /* Map image definition: zoom, turns */
1415 fc_snprintf(str, sizeof(str), "zoom=%d:turns=0:format=%s",
1417
1418 /* Map image definition: show */
1420 cat_snprintf(str, sizeof(str), ":show=all");
1421 /* use all available knowledge */
1422 gui_options.mapimg_layer[MAPIMG_LAYER_KNOWLEDGE] = FALSE;
1423 } else {
1424 cat_snprintf(str, sizeof(str), ":show=plrid:plrid=%d",
1426 /* use only player knowledge */
1427 gui_options.mapimg_layer[MAPIMG_LAYER_KNOWLEDGE] = TRUE;
1428 }
1429
1430 /* Map image definition: map */
1431 for (layer = mapimg_layer_begin(); layer != mapimg_layer_end();
1432 layer = mapimg_layer_next(layer)) {
1433 if (gui_options.mapimg_layer[layer]) {
1434 mi_map[map_pos++] = mapimg_layer_name(layer)[0];
1435 }
1436 }
1437 mi_map[map_pos] = '\0';
1438
1439 if (map_pos == 0) {
1440 /* no value set - use dummy setting */
1441 sz_strlcpy(mi_map, "-");
1442 }
1443 cat_snprintf(str, sizeof(str), ":map=%s", mi_map);
1444
1445 log_debug("client map image definition: %s", str);
1446
1447 if (!mapimg_define(str, FALSE) || !mapimg_isvalid(0)) {
1448 /* An error in the definition string or an error validation the string.
1449 * The error message is available via mapimg_error(). */
1450 return FALSE;
1451 }
1452
1453 return TRUE;
1454}
1455
1456/**********************************************************************/
1459bool mapimg_client_createmap(const char *filename)
1460{
1461 struct mapdef *pmapdef;
1462 char mapimgfile[512];
1463
1464 if (NULL == filename || '\0' == filename[0]) {
1466 } else {
1467 sz_strlcpy(mapimgfile, filename);
1468 }
1469
1470 if (!mapimg_client_define()) {
1471 return FALSE;
1472 }
1473
1474 pmapdef = mapimg_isvalid(0);
1475 if (!pmapdef) {
1476 return FALSE;
1477 }
1478
1479 return mapimg_create(pmapdef, TRUE, mapimgfile, NULL);
1480}
1481
1482/**********************************************************************/
1486{
1487 struct option *poption = optset_option_by_name(server_optset, "nationset");
1488 const char *setting_str;
1489
1490 if (poption == NULL
1491 || option_type(poption) != OT_STRING
1492 || (setting_str = option_str_get(poption)) == NULL) {
1493 setting_str = "";
1494 }
1495
1496 return nation_set_by_setting_value(setting_str);
1497}
1498
1499/**********************************************************************/
1503{
1505}
1506
1507/**********************************************************************/
1512enum ai_level server_ai_level(void)
1513{
1514 enum ai_level lvl = game.info.skill_level;
1515
1516 players_iterate(pplayer) {
1517 if (is_ai(pplayer) && pplayer->ai_common.skill_level != lvl) {
1518 return ai_level_invalid();
1519 }
1521
1522 if (!is_settable_ai_level(lvl)) {
1523 return ai_level_invalid();
1524 }
1525
1526 return lvl;
1527}
#define NUM_ACTIONS
Definition actions.h:297
#define str
Definition astring.c:76
#define n
Definition astring.c:77
void dbv_resize(struct dbv *pdbv, int bits)
Definition bitvector.c:71
void output_window_event(const char *plain_text, const struct text_tag_list *tags, int conn_id)
const char * city_improvement_name_translation(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:658
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:1216
const char * city_name_get(const struct city *pcity)
Definition city.c:1115
void city_remove_improvement(struct city *pcity, const struct impr_type *pimprove)
Definition city.c:3284
bool city_production_has_flag(const struct city *pcity, enum impr_flag_id flag)
Definition city.c:712
bool can_city_build_improvement_now(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:839
bool can_city_build_now(const struct civ_map *nmap, const struct city *pcity, const struct universal *target)
Definition city.c:991
bool can_city_build_unit_now(const struct civ_map *nmap, const struct city *pcity, const struct unit_type *punittype)
Definition city.c:927
bool can_city_build_improvement_later(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:856
bool can_city_build_unit_later(const struct civ_map *nmap, const struct city *pcity, const struct unit_type *punittype)
Definition city.c:948
const char * city_production_name_translation(const struct city *pcity)
Definition city.c:695
#define cities_iterate_end
Definition city.h:497
#define city_list_iterate(citylist, pcity)
Definition city.h:488
#define city_tile(_pcity_)
Definition city.h:544
#define cities_iterate(pcity)
Definition city.h:492
@ CITIZEN_UNHAPPY
Definition city.h:262
#define city_owner(_pcity_)
Definition city.h:543
#define city_list_iterate_end
Definition city.h:490
#define city_built_iterate(_pcity, _p)
Definition city.h:810
#define city_built_iterate_end
Definition city.h:816
int city_buy_production(struct city *pcity)
int city_change_production(struct city *pcity, struct universal *target)
bool city_can_buy(const struct city *pcity)
void refresh_city_dialog(struct city *pcity)
void city_report_dialog_update(void)
bool client_is_global_observer(void)
bool client_is_observer(void)
struct civclient client
enum client_states client_state(void)
bool can_client_issue_orders(void)
bool client_has_player(void)
bool can_client_change_view(void)
#define client_player()
@ C_S_RUNNING
Definition client_main.h:47
enum known_type client_tile_get_known(const struct tile *ptile)
Definition climap.c:36
static int target_get_section(struct universal target)
Definition climisc.c:595
int collect_eventually_buildable_targets(struct universal *targets, struct city *pcity, bool advanced_tech)
Definition climisc.c:812
bool city_unit_supported(const struct city *pcity, const struct universal *target)
Definition climisc.c:538
enum ai_level server_ai_level(void)
Definition climisc.c:1512
void client_change_all(struct universal *from, struct universal *to)
Definition climisc.c:165
cid cid_encode_building(const struct impr_type *pimprove)
Definition climisc.c:498
void create_event(struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Definition climisc.c:1086
int collect_buildable_targets(struct universal *targets)
Definition climisc.c:781
void client_player_init(struct player *pplayer)
Definition climisc.c:1366
bool mapimg_client_createmap(const char *filename)
Definition climisc.c:1459
void client_remove_city(struct city *pcity)
Definition climisc.c:134
void client_unit_init_act_prob_cache(struct unit *punit)
Definition climisc.c:1252
void nuclear_winter_scaled(int *chance, int *rate, int max)
Definition climisc.c:338
const char * get_embassy_status(const struct player *me, const struct player *them)
Definition climisc.c:194
void buy_production_in_selected_cities(void)
Definition climisc.c:1310
void common_taxrates_callback(int idx, bool reverse)
Definition climisc.c:1187
static int city_buy_cost_compare(const void *a, const void *b)
Definition climisc.c:1296
bool mapimg_client_define(void)
Definition climisc.c:1402
int collect_currently_building_targets(struct universal *targets)
Definition climisc.c:749
enum unit_bg_color_type unit_color_type(const struct unit_type *punittype)
Definition climisc.c:1268
struct sprite * client_warming_sprite(void)
Definition climisc.c:371
bool can_units_do_connect(struct unit_list *punits, enum unit_activity activity, struct extra_type *tgt)
Definition climisc.c:1235
void cityrep_buy(struct city *pcity)
Definition climisc.c:1148
void global_warming_scaled(int *chance, int *rate, int max)
Definition climisc.c:328
void client_player_maps_reset(void)
Definition climisc.c:1377
bool client_nation_is_in_current_set(const struct nation_type *pnation)
Definition climisc.c:1502
cid cid_encode_from_city(const struct city *pcity)
Definition climisc.c:511
void name_and_sort_items(struct universal *targets, int num_targets, struct item *items, bool show_cost, struct city *pcity)
Definition climisc.c:643
static int fc_cmp(const void *p1, const void *p2)
Definition climisc.c:619
struct sprite * client_cooling_sprite(void)
Definition climisc.c:388
struct sprite * client_research_sprite(void)
Definition climisc.c:348
int num_present_units_in_city(struct city *pcity)
Definition climisc.c:944
cid cid_encode(struct universal target)
Definition climisc.c:476
void client_remove_unit(struct unit *punit)
Definition climisc.c:72
bool city_building_present(const struct city *pcity, const struct universal *target)
Definition climisc.c:576
struct nation_set * client_current_nation_set(void)
Definition climisc.c:1485
int num_supported_units_in_city(struct city *pcity)
Definition climisc.c:926
int collect_already_built_targets(struct universal *targets, struct city *pcity)
Definition climisc.c:906
struct city * get_nearest_city(const struct unit *punit, int *sq_dist)
Definition climisc.c:1112
struct universal cid_decode(cid id)
Definition climisc.c:519
void unit_focus_set_status(struct player *pplayer)
Definition climisc.c:1356
void handle_event(const char *featured_text, struct tile *ptile, enum event_type event, int turn, int phase, int conn_id)
Definition climisc.c:961
void center_on_something(void)
Definition climisc.c:424
cid cid_encode_unit(const struct unit_type *punittype)
Definition climisc.c:486
void client_diplomacy_clause_string(char *buf, int bufsiz, struct Clause *pclause)
Definition climisc.c:241
const char * get_vision_status(const struct player *me, const struct player *them)
Definition climisc.c:222
bool can_city_build_now_client(const struct city *pcity, const struct universal *target)
Definition climisc.c:586
struct sprite * client_government_sprite(void)
Definition climisc.c:406
static void catastrophe_scaled(int *chance, int *rate, int max, int current, int accum, int level)
Definition climisc.c:308
bool city_unit_present(const struct city *pcity, const struct universal *target)
Definition climisc.c:557
int collect_production_targets(struct universal *targets, struct city **selected_cities, int num_selected_cities, bool append_units, bool append_wonders, bool change_prod, TestCityFunc test_func)
Definition climisc.c:693
#define MAX_NUM_PRODUCTION_TARGETS
Definition climisc.h:89
int cid
Definition climisc.h:31
bool(* TestCityFunc)(const struct city *, const struct universal *)
Definition climisc.h:87
unit_bg_color_type
Definition climisc.h:127
@ UNIT_BG_AMPHIBIOUS
Definition climisc.h:130
@ UNIT_BG_SEA
Definition climisc.h:129
@ UNIT_BG_FLYING
Definition climisc.h:131
@ UNIT_BG_LAND
Definition climisc.h:128
@ UNIT_BG_HP_LOSS
Definition climisc.h:127
void connection_do_buffer(struct connection *pc)
Definition connection.c:323
void connection_do_unbuffer(struct connection *pc)
Definition connection.c:335
struct unit * get_focus_unit_on_tile(const struct tile *ptile)
Definition control.c:397
struct unit_list * get_units_in_focus(void)
Definition control.c:177
bool can_unit_do_connect(struct unit *punit, enum unit_activity activity, struct extra_type *tgt)
Definition control.c:1410
void update_unit_pix_label(struct unit_list *punitlist)
Definition control.c:984
struct unit * head_of_units_in_focus(void)
Definition control.c:411
int get_num_units_in_focus(void)
Definition control.c:185
void unit_focus_advance(bool accept_current)
Definition control.c:689
void control_unit_killed(struct unit *punit)
Definition control.c:226
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
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 int cost
Definition dialogs_g.h:73
int int id
Definition editgui_g.h:28
enum event_type event
Definition events.c:81
#define Q_(String)
Definition fcintl.h:70
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
size_t featured_text_apply_tag(const char *text_source, char *featured_text, size_t featured_text_len, enum text_tag_type tag_type, ft_offset_t start_offset, ft_offset_t stop_offset,...)
enum text_link_type text_tag_link_type(const struct text_tag *ptag)
size_t featured_text_to_plain_text(const char *featured_text, char *plain_text, size_t plain_text_len, struct text_tag_list **tags, bool replace_link_text)
const struct ft_color ftc_client
const char * city_link(const struct city *pcity)
int text_tag_link_id(const struct text_tag *ptag)
struct text_tag * text_tag_new(enum text_tag_type tag_type, ft_offset_t start_offset, ft_offset_t stop_offset,...)
#define text_tag_list_iterate_end
#define text_tag_list_iterate(tags, ptag)
#define FT_OFFSET_UNSET
static bool ft_color_requested(const struct ft_color color)
text_tag_type
@ TTT_LINK
@ TTT_COLOR
struct civ_game game
Definition game.c:57
struct world wld
Definition game.c:58
void game_remove_unit(struct world *gworld, struct unit *punit)
Definition game.c:119
void game_remove_city(struct world *gworld, struct city *pcity)
Definition game.c:173
struct city * game_city_by_number(int id)
Definition game.c:102
Government_type_id government_count(void)
Definition government.c:70
struct government * government_of_player(const struct player *pplayer)
Definition government.c:113
void popdown_city_dialog(struct city *pcity)
Definition citydlg.c:587
void popup_notify_goto_dialog(const char *headline, const char *lines, const struct text_tag_list *tags, struct tile *ptile)
Definition dialogs.c:194
void update_unit_info_label(struct unit_list *punits)
Definition mapview.c:258
struct impr_type * improvement_by_number(const Impr_type_id id)
bool can_player_build_improvement_later(const struct player *p, const struct impr_type *pimprove)
bool can_player_build_improvement_now(const struct player *p, struct impr_type *pimprove)
Impr_type_id improvement_number(const struct impr_type *pimprove)
int impr_build_shield_cost(const struct city *pcity, const struct impr_type *pimprove)
bool is_wonder(const struct impr_type *pimprove)
bool is_great_wonder(const struct impr_type *pimprove)
bool improvement_has_flag(const struct impr_type *pimprove, enum impr_flag_id flag)
const char * improvement_name_translation(const struct impr_type *pimprove)
Impr_type_id improvement_count(void)
bool is_small_wonder(const struct impr_type *pimprove)
#define improvement_iterate_end
#define improvement_iterate(_p)
#define B_LAST
Definition improvement.h:42
const char * name
Definition inputfile.c:127
#define fc_assert_ret(condition)
Definition log.h:191
#define log_verbose(message,...)
Definition log.h:109
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_ret_val(condition, val)
Definition log.h:194
#define log_debug(message,...)
Definition log.h:115
int sq_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:639
int map_num_tiles(void)
Definition map.c:1012
struct tile * native_pos_to_tile(const struct civ_map *nmap, int nat_x, int nat_y)
Definition map.c:441
#define iterate_outward(nmap, start_tile, max_dist, itr_tile)
Definition map.h:361
#define iterate_outward_end
Definition map.h:365
#define MAP_INDEX_SIZE
Definition map.h:131
bool is_city_hilited(struct city *pcity)
struct mapdef * mapimg_isvalid(int id)
Definition mapimg.c:1120
bool mapimg_define(const char *maparg, bool check)
Definition mapimg.c:768
bool mapimg_delete(int id)
Definition mapimg.c:1203
int mapimg_count(void)
Definition mapimg.c:572
bool mapimg_create(struct mapdef *pmapdef, bool force, const char *savename, const char *path)
Definition mapimg.c:1331
#define MAX_LEN_MAPDEF
Definition mapimg.h:65
void refresh_city_mapcanvas(struct city *pcity, struct tile *ptile, bool full_refresh, bool write_to_screen)
void center_tile_mapcanvas(const struct tile *ptile)
void link_mark_add_new(enum text_link_type type, int id)
bool can_slide
void refresh_unit_mapcanvas(struct unit *punit, struct tile *ptile, bool full_refresh, bool write_to_screen)
#define fc_malloc(sz)
Definition mem.h:34
void meswin_add(const char *message, const struct text_tag_list *tags, struct tile *ptile, enum event_type event, int turn, int phase)
const char * nation_rule_name(const struct nation_type *pnation)
Definition nation.c:137
struct nation_type * nation_of_unit(const struct unit *punit)
Definition nation.c:462
struct nation_type * nation_of_city(const struct city *pcity)
Definition nation.c:453
bool nation_is_in_set(const struct nation_type *pnation, const struct nation_set *pset)
Definition nation.c:836
struct nation_set * nation_set_by_setting_value(const char *setting)
Definition nation.c:858
const char * nation_plural_for_player(const struct player *pplayer)
Definition nation.c:177
const struct option_set * server_optset
Definition options.c:4009
const char * option_str_get(const struct option *poption)
Definition options.c:868
enum option_type option_type(const struct option *poption)
Definition options.c:633
int messages_where[E_COUNT]
Definition options.c:5028
struct client_options gui_options
Definition options.c:71
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:406
#define MW_POPUP
Definition options.h:556
#define MW_OUTPUT
Definition options.h:554
#define MW_MESSAGES
Definition options.h:555
#define MAX_LEN_MSG
Definition packets.h:43
int dsend_packet_player_rates(struct connection *pc, int tax, int luxury, int science)
void play_sound_for_event(enum event_type type)
Definition packhand.c:1613
struct city_list * cities
Definition packhand.c:117
bool is_settable_ai_level(enum ai_level level)
Definition player.c:1883
const char * player_name(const struct player *pplayer)
Definition player.c:886
struct city * player_primary_capital(const struct player *pplayer)
Definition player.c:1313
int player_index(const struct player *pplayer)
Definition player.c:820
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Definition player.c:317
bool can_player_see_units_in_city(const struct player *pplayer, const struct city *pcity)
Definition player.c:1113
bool can_player_see_city_internals(const struct player *pplayer, const struct city *pcity)
Definition player.c:1129
bool player_has_embassy(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:202
bool gives_shared_vision(const struct player *me, const struct player *them)
Definition player.c:1461
#define players_iterate_end
Definition player.h:535
#define players_iterate(_pplayer)
Definition player.h:530
#define is_ai(plr)
Definition player.h:234
#define is_human(plr)
Definition player.h:233
bool are_universals_equal(const struct universal *psource1, const struct universal *psource2)
struct research * research_get(const struct player *pplayer)
Definition research.c:126
struct setting_list * level[OLEVELS_NUM]
Definition settings.c:183
#define CLIP(lower, current, upper)
Definition shared.h:57
#define DIVIDE(n, d)
Definition shared.h:78
#define ARRAY_SIZE(x)
Definition shared.h:85
#define BOOL_VAL(x)
Definition shared.h:70
#define MAX(x, y)
Definition shared.h:54
enum clause_type type
Definition diptreaty.h:71
struct player * from
Definition diptreaty.h:72
int value
Definition diptreaty.h:73
Definition city.h:309
int id
Definition city.h:315
struct unit_list * info_units_present
Definition city.h:457
struct unit_list * info_units_supported
Definition city.h:456
bool occupied
Definition city.h:443
struct universal production
Definition city.h:382
int buy_cost
Definition city.h:449
struct tile * tile
Definition city.h:311
struct unit_list * units_supported
Definition city.h:391
struct city::@17::@20 client
struct packet_game_info info
Definition game.h:89
int xsize
Definition map_types.h:77
int ysize
Definition map_types.h:77
struct connection conn
Definition client_main.h:96
bool mapimg_layer[MAPIMG_LAYER_COUNT]
Definition options.h:219
struct ft_color highlight_our_names
Definition options.h:169
char mapimg_format[64]
Definition options.h:217
char mapimg_filename[512]
Definition options.h:220
Definition colors.h:20
struct player * playing
Definition connection.h:156
char username[MAX_LEN_NAME]
Definition connection.h:169
int bits
Definition bitvector.h:33
unsigned char * vec
Definition bitvector.h:34
int build_cost
Definition improvement.h:77
Definition climisc.h:82
struct universal item
Definition climisc.h:83
char descr[MAX_LEN_NAME+40]
Definition climisc.h:84
enum ai_level skill_level
struct city_list * cities
Definition player.h:281
struct dbv tile_vision[V_COUNT]
Definition player.h:359
struct player::@69::@72 client
struct unit_list * units
Definition player.h:282
bool is_alive
Definition player.h:268
struct player_economic economic
Definition player.h:284
Tech_type_id researching
Definition research.h:52
struct research::@75::@77 client
int researching_cost
Definition research.h:98
int bulbs_researched
Definition research.h:53
Definition tile.h:49
struct unit_list * units
Definition tile.h:57
int hp_loss_pct
Definition unittype.h:142
enum unit_move_type move_type
Definition unittype.h:140
Definition unit.h:138
int id
Definition unit.h:145
struct unit::@80::@82 client
struct act_prob * act_prob_cache
Definition unit.h:225
int homecity
Definition unit.h:146
enum unit_focus_status focus_status
Definition unit.h:211
enum universals_n kind
Definition fc_types.h:758
universals_u value
Definition fc_types.h:757
struct civ_map map
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
size_t fc_strlcpy(char *dest, const char *src, size_t n)
Definition support.c:787
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:189
int cat_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:995
int fc_vsnprintf(char *str, size_t n, const char *format, va_list ap)
Definition support.c:896
int fc_strncasecmp(const char *str0, const char *str1, size_t n)
Definition support.c:238
#define sz_strlcpy(dest, src)
Definition support.h:167
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:107
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:290
#define A_UNSET
Definition tech.h:48
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
@ TILE_UNKNOWN
Definition tile.h:35
#define TILE_XY(ptile)
Definition tile.h:42
struct sprite * get_government_sprite(const struct tileset *t, const struct government *gov)
Definition tilespec.c:6504
struct sprite * get_indicator_sprite(const struct tileset *t, enum indicator_type indicator, int idx)
Definition tilespec.c:6694
struct sprite * get_citizen_sprite(const struct tileset *t, enum citizen_category type, int citizen_index, const struct city *pcity)
Definition tilespec.c:6437
@ INDICATOR_COOLING
Definition tilespec.h:305
@ INDICATOR_WARMING
Definition tilespec.h:304
@ INDICATOR_BULB
Definition tilespec.h:303
#define NUM_TILES_PROGRESS
Definition tilespec.h:194
const struct unit_type * utype
Definition fc_types.h:604
const struct impr_type * building
Definition fc_types.h:598
int get_transporter_occupancy(const struct unit *ptrans)
Definition unit.c:1767
bool unit_transport_unload(struct unit *pcargo)
Definition unit.c:2374
struct unit_list * unit_transport_cargo(const struct unit *ptrans)
Definition unit.c:2435
#define unit_tile(_pu)
Definition unit.h:395
@ FOCUS_AVAIL
Definition unit.h:53
#define unit_owner(_pu)
Definition unit.h:394
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const char * unit_rule_name(const struct unit *punit)
Definition unittype.c:1639
Unit_type_id utype_count(void)
Definition unittype.c:80
struct unit_type * utype_by_number(const Unit_type_id id)
Definition unittype.c:112
Unit_type_id utype_number(const struct unit_type *punittype)
Definition unittype.c:100
bool can_player_build_unit_later(const struct player *p, const struct unit_type *punittype)
Definition unittype.c:2150
int utype_build_shield_cost(const struct city *pcity, const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1490
bool can_player_build_unit_now(const struct player *p, const struct unit_type *punittype)
Definition unittype.c:2131
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1612
const char * utype_values_translation(const struct unit_type *punittype)
Definition unittype.c:1669
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
Definition unittype.h:753
#define utype_class(_t_)
Definition unittype.h:736
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:604
#define unit_type_iterate(_p)
Definition unittype.h:841
#define unit_type_iterate_end
Definition unittype.h:848
#define vision_layer_iterate(v)
Definition vision.h:77
#define vision_layer_iterate_end
Definition vision.h:80