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(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
429 if (!can_client_change_view()) {
430 return;
431 }
432
434 if (get_num_units_in_focus() > 0) {
436 } else if (client_has_player()
437 && NULL != (pcity = player_primary_capital(client_player()))) {
438 /* Else focus on the capital. */
440 } else if (NULL != client.conn.playing
441 && 0 < city_list_size(client.conn.playing->cities)) {
442 /* Just focus on any city. */
443 pcity = city_list_get(client.conn.playing->cities, 0);
444 fc_assert_ret(pcity != NULL);
446 } else if (NULL != client.conn.playing
447 && 0 < unit_list_size(client.conn.playing->units)) {
448 /* Just focus on any unit. */
449 punit = unit_list_get(client.conn.playing->units, 0);
450 fc_assert_ret(punit != NULL);
452 } else {
453 struct tile *ctile = native_pos_to_tile(&(wld.map), wld.map.xsize / 2, wld.map.ysize / 2);
454
455 /* Just any known tile will do; search near the middle first. */
456 /* Iterate outward from the center tile. We have to give a radius that
457 * is guaranteed to be larger than the map will be. Although this is
458 * a misuse of map.xsize and map.ysize (which are native dimensions),
459 * it should give a sufficiently large radius. */
460 iterate_outward(&(wld.map), ctile, wld.map.xsize + wld.map.ysize, ptile) {
461 if (client_tile_get_known(ptile) != TILE_UNKNOWN) {
462 ctile = ptile;
463 break;
464 }
466
468 }
469 can_slide = TRUE;
470}
471
472/**********************************************************************/
476{
477 return VUT_UTYPE == target.kind
478 ? B_LAST + utype_number(target.value.utype)
480}
481
482/**********************************************************************/
485cid cid_encode_unit(const struct unit_type *punittype)
486{
487 struct universal target = {
488 .kind = VUT_UTYPE,
489 .value = {.utype = punittype}};
490
491 return cid_encode(target);
492}
493
494/**********************************************************************/
497cid cid_encode_building(const struct impr_type *pimprove)
498{
499 struct universal target = {
500 .kind = VUT_IMPROVEMENT,
501 .value = {.building = pimprove}
502 };
503
504 return cid_encode(target);
505}
506
507/**********************************************************************/
510cid cid_encode_from_city(const struct city *pcity)
511{
512 return cid_encode(pcity->production);
513}
514
515/**********************************************************************/
519{
520 struct universal target;
521
522 if (id >= B_LAST) {
523 target.kind = VUT_UTYPE;
524 target.value.utype = utype_by_number(id - B_LAST);
525 } else {
526 target.kind = VUT_IMPROVEMENT;
528 }
529
530 return target;
531}
532
533/**********************************************************************/
537bool city_unit_supported(const struct city *pcity,
538 const struct universal *target)
539{
540 if (VUT_UTYPE == target->kind) {
541 const struct unit_type *tvtype = target->value.utype;
542
544 if (unit_type_get(punit) == tvtype) {
545 return TRUE;
546 }
548 }
549 return FALSE;
550}
551
552/**********************************************************************/
556bool city_unit_present(const struct city *pcity,
557 const struct universal *target)
558{
559 if (VUT_UTYPE == target->kind) {
560 const struct unit_type *tvtype = target->value.utype;
561
563 if (unit_type_get(punit) == tvtype) {
564 return TRUE;
565 }
566 }
568 }
569 return FALSE;
570}
571
572/**********************************************************************/
575bool city_building_present(const struct city *pcity,
576 const struct universal *target)
577{
578 return VUT_IMPROVEMENT == target->kind
579 && city_has_building(pcity, target->value.building);
580}
581
582/**********************************************************************/
585static int target_get_section(struct universal target)
586{
587 if (VUT_UTYPE == target.kind) {
588 if (utype_has_flag(target.value.utype, UTYF_CIVILIAN)) {
589 return 2;
590 } else {
591 return 3;
592 }
593 } else {
594 if (improvement_has_flag(target.value.building, IF_GOLD)) {
595 return 1;
596 } else if (is_small_wonder(target.value.building)) {
597 return 4;
598 } else if (is_great_wonder(target.value.building)) {
599 return 5;
600 } else {
601 return 0;
602 }
603 }
604}
605
606/**********************************************************************/
609static int fc_cmp(const void *p1, const void *p2)
610{
611 const struct item *i1 = p1, *i2 = p2;
612 int s1 = target_get_section(i1->item);
613 int s2 = target_get_section(i2->item);
614
615 if (s1 == s2) {
616 return fc_strcasecmp(i1->descr, i2->descr);
617 }
618
619 return s1 - s2;
620}
621
622/**********************************************************************/
633void name_and_sort_items(struct universal *targets, int num_targets,
634 struct item *items,
635 bool show_cost, struct city *pcity)
636{
637 int i;
638
639 for (i = 0; i < num_targets; i++) {
640 struct universal target = targets[i];
641 int cost;
642 struct item *pitem = &items[i];
643 const char *name;
644
645 pitem->item = target;
646
647 if (VUT_UTYPE == target.kind) {
650 } else {
652 if (improvement_has_flag(target.value.building, IF_GOLD)) {
653 cost = -1;
654 } else {
655 if (pcity != NULL) {
656 cost = impr_build_shield_cost(pcity, target.value.building);
657 } else {
658 cost = MAX(target.value.building->build_cost * game.info.shieldbox / 100, 1);
659 }
660 }
661 }
662
663 if (show_cost) {
664 if (cost < 0) {
665 fc_snprintf(pitem->descr, sizeof(pitem->descr), "%s (XX)", name);
666 } else {
667 fc_snprintf(pitem->descr, sizeof(pitem->descr),
668 "%s (%d)", name, cost);
669 }
670 } else {
671 (void) fc_strlcpy(pitem->descr, name, sizeof(pitem->descr));
672 }
673 }
674
675 qsort(items, num_targets, sizeof(struct item), fc_cmp);
676}
677
678/**********************************************************************/
684 struct city **selected_cities,
685 int num_selected_cities, bool append_units,
686 bool append_wonders, bool change_prod,
688{
689 cid first = append_units ? B_LAST : 0;
690 cid last = (append_units
691 ? utype_count() + B_LAST
693 cid id;
694 int items_used = 0;
695
696 for (id = first; id < last; id++) {
697 bool append = FALSE;
698 struct universal target = cid_decode(id);
699
700 if (!append_units && (append_wonders != is_wonder(target.value.building))) {
701 continue;
702 }
703
704 if (!change_prod) {
705 if (client_has_player()) {
707 append |= test_func(pcity, &target);
709 } else {
710 cities_iterate(pcity) {
711 append |= test_func(pcity, &target);
713 }
714 } else {
715 int i;
716
717 for (i = 0; i < num_selected_cities; i++) {
718 append |= test_func(selected_cities[i], &target);
719 }
720 }
721
722 if (!append) {
723 continue;
724 }
725
726 targets[items_used] = target;
727 items_used++;
728 }
729
730 return items_used;
731}
732
733/**********************************************************************/
740{
741 bool mapping[MAX_NUM_PRODUCTION_TARGETS];
742 int cids_used = 0;
743 cid id;
744
745 if (NULL == client.conn.playing) {
746 return 0;
747 }
748
749 memset(mapping, 0, sizeof(mapping));
751 mapping[cid_encode_from_city(pcity)] = TRUE;
752 }
754
755 for (id = 0; id < ARRAY_SIZE(mapping); id++) {
756 if (mapping[id]) {
757 targets[cids_used] = cid_decode(id);
758 cids_used++;
759 }
760 }
761
762 return cids_used;
763}
764
765/**********************************************************************/
772{
773 int cids_used = 0;
774
775 if (NULL == client.conn.playing) {
776 return 0;
777 }
778
779 improvement_iterate(pimprove) {
781 targets[cids_used].kind = VUT_IMPROVEMENT;
782 targets[cids_used].value.building = pimprove;
783 cids_used++;
784 }
786
787 unit_type_iterate(punittype) {
789 targets[cids_used].kind = VUT_UTYPE;
790 targets[cids_used].value.utype = punittype;
791 cids_used++;
792 }
794
795 return cids_used;
796}
797
798/**********************************************************************/
803 struct city *pcity,
804 bool advanced_tech)
805{
806 struct player *pplayer = client_player();
807 int cids_used = 0;
808
809 improvement_iterate(pimprove) {
810 bool can_build;
811 bool can_eventually_build;
812
813 if (NULL != pcity) {
814 /* Can the city build? */
815 can_build = can_city_build_improvement_now(pcity, pimprove);
816 can_eventually_build = can_city_build_improvement_later(pcity,
817 pimprove);
818 } else if (NULL != pplayer) {
819 /* Can our player build? */
820 can_build = can_player_build_improvement_now(pplayer, pimprove);
821 can_eventually_build = can_player_build_improvement_later(pplayer,
822 pimprove);
823 } else {
824 /* Global observer case: can any player build? */
825 can_build = FALSE;
826 players_iterate(aplayer) {
827 if (can_player_build_improvement_now(aplayer, pimprove)) {
828 can_build = TRUE;
829 break;
830 }
832
833 can_eventually_build = FALSE;
834 players_iterate(aplayer) {
835 if (can_player_build_improvement_later(aplayer, pimprove)) {
836 can_eventually_build = TRUE;
837 break;
838 }
840 }
841
842 if ((advanced_tech && can_eventually_build)
843 || (!advanced_tech && can_build)) {
844 targets[cids_used].kind = VUT_IMPROVEMENT;
845 targets[cids_used].value.building = pimprove;
846 cids_used++;
847 }
849
850 unit_type_iterate(punittype) {
851 bool can_build;
852 bool can_eventually_build;
853
854 if (NULL != pcity) {
855 /* Can the city build? */
856 can_build = can_city_build_unit_now(pcity, punittype);
857 can_eventually_build = can_city_build_unit_later(pcity, punittype);
858 } else if (NULL != pplayer) {
859 /* Can our player build? */
860 can_build = can_player_build_unit_now(pplayer, punittype);
861 can_eventually_build = can_player_build_unit_later(pplayer, punittype);
862 } else {
863 /* Global observer case: can any player build? */
864 can_build = FALSE;
865 players_iterate(aplayer) {
866 if (can_player_build_unit_now(aplayer, punittype)) {
867 can_build = TRUE;
868 break;
869 }
871
872 can_eventually_build = FALSE;
873 players_iterate(aplayer) {
874 if (can_player_build_unit_later(aplayer, punittype)) {
875 can_eventually_build = TRUE;
876 break;
877 }
879 }
880
881 if ((advanced_tech && can_eventually_build)
882 || (!advanced_tech && can_build)) {
883 targets[cids_used].kind = VUT_UTYPE;
884 targets[cids_used].value.utype = punittype;
885 cids_used++;
886 }
888
889 return cids_used;
890}
891
892/**********************************************************************/
896 struct city *pcity)
897{
898 int cids_used = 0;
899
900 fc_assert_ret_val(pcity != NULL, 0);
901
902 city_built_iterate(pcity, pimprove) {
903 targets[cids_used].kind = VUT_IMPROVEMENT;
904 targets[cids_used].value.building = pimprove;
905 cids_used++;
907
908 return cids_used;
909}
910
911/**********************************************************************/
916{
917 struct unit_list *plist;
918
920 /* Other players don't see inside the city (but observers do). */
921 plist = pcity->client.info_units_supported;
922 } else {
923 plist = pcity->units_supported;
924 }
925
926 return unit_list_size(plist);
927}
928
929/**********************************************************************/
934{
935 struct unit_list *plist;
936
938 /* Other players don't see inside the city (but observers do). */
939 plist = pcity->client.info_units_present;
940 } else {
941 plist = pcity->tile->units;
942 }
943
944 return unit_list_size(plist);
945}
946
947/**********************************************************************/
950void handle_event(const char *featured_text, struct tile *ptile,
951 enum event_type event, int turn, int phase, int conn_id)
952{
953 char plain_text[MAX_LEN_MSG];
954 struct text_tag_list *tags;
955 int where = MW_OUTPUT; /* where to display the message */
956 bool fallback_needed = FALSE; /* we want fallback if actual 'where' is not
957 * usable */
958 bool shown = FALSE; /* Message displayed somewhere at least */
959
960 if (!event_type_is_valid(event)) {
961 /* Server may have added a new event; leave as MW_OUTPUT */
962 log_verbose("Unknown event type %d!", event);
963 } else {
964 where = messages_where[event];
965 }
966
967 /* Get the original text. */
968 featured_text_to_plain_text(featured_text, plain_text,
969 sizeof(plain_text), &tags, conn_id != -1);
970
971 /* Display link marks when an user is pointed us something. */
972 if (conn_id != -1) {
973 text_tag_list_iterate(tags, ptag) {
974 if (text_tag_type(ptag) == TTT_LINK) {
976 }
978 }
979
980 /* Maybe highlight our player and user names if someone is talking
981 * about us. */
982 if (-1 != conn_id
983 && client.conn.id != conn_id
985 const char *username = client.conn.username;
986 size_t userlen = strlen(username);
987 const char *playername = ((client_player() && !client_is_observer())
988 ? player_name(client_player()) : NULL);
989 size_t playerlen = playername ? strlen(playername) : 0;
990 const char *p;
991
992 if (playername && playername[0] == '\0') {
993 playername = NULL;
994 }
995
996 if (username && username[0] == '\0') {
997 username = NULL;
998 }
999
1000 for (p = plain_text; *p != '\0'; p++) {
1001 if (NULL != username
1002 && 0 == fc_strncasecmp(p, username, userlen)) {
1003 struct text_tag *ptag = text_tag_new(TTT_COLOR, p - plain_text,
1004 p - plain_text + userlen,
1006
1007 fc_assert(ptag != NULL);
1008
1009 if (ptag != NULL) {
1010 /* Appends to be sure it will be applied at last. */
1011 text_tag_list_append(tags, ptag);
1012 }
1013 } else if (NULL != playername
1014 && 0 == fc_strncasecmp(p, playername, playerlen)) {
1015 struct text_tag *ptag = text_tag_new(TTT_COLOR, p - plain_text,
1016 p - plain_text + playerlen,
1018
1019 fc_assert(ptag != NULL);
1020
1021 if (ptag != NULL) {
1022 /* Appends to be sure it will be applied at last. */
1023 text_tag_list_append(tags, ptag);
1024 }
1025 }
1026 }
1027 }
1028
1029 /* Popup */
1030 if (BOOL_VAL(where & MW_POPUP)) {
1031 /* Popups are usually not shown if player is under AI control.
1032 * Server operator messages are shown always. */
1033 if (NULL == client.conn.playing
1035 || event == E_MESSAGE_WALL) {
1036 popup_notify_goto_dialog(_("Popup Request"), plain_text, tags, ptile);
1037 shown = TRUE;
1038 } else {
1039 /* Force to chatline so it will be visible somewhere at least.
1040 * Messages window may still handle this so chatline is not needed
1041 * after all. */
1042 fallback_needed = TRUE;
1043 }
1044 }
1045
1046 /* Message window */
1047 if (BOOL_VAL(where & MW_MESSAGES)) {
1048 /* When the game isn't running, the messages dialog isn't present. */
1049 if (C_S_RUNNING <= client_state()) {
1050 meswin_add(plain_text, tags, ptile, event, turn, phase);
1051 shown = TRUE;
1052 } else {
1053 /* Force to chatline instead. */
1054 fallback_needed = TRUE;
1055 }
1056 }
1057
1058 /* Chatline */
1059 if (BOOL_VAL(where & MW_OUTPUT) || (fallback_needed && !shown)) {
1060 output_window_event(plain_text, tags, conn_id);
1061 }
1062
1063 if (turn == game.info.turn) {
1065 }
1066
1067 /* Free tags */
1068 text_tag_list_destroy(tags);
1069}
1070
1071/**********************************************************************/
1075void create_event(struct tile *ptile, enum event_type event,
1076 const struct ft_color color, const char *format, ...)
1077{
1078 va_list ap;
1079 char message[MAX_LEN_MSG];
1080
1081 va_start(ap, format);
1082 fc_vsnprintf(message, sizeof(message), format, ap);
1083 va_end(ap);
1084
1086 char colored_text[MAX_LEN_MSG];
1087
1088 featured_text_apply_tag(message, colored_text, sizeof(colored_text),
1090 handle_event(colored_text, ptile, event, game.info.turn, game.info.phase, -1);
1091 } else {
1093 }
1094}
1095
1096/**********************************************************************/
1101struct city *get_nearest_city(const struct unit *punit, int *sq_dist)
1102{
1103 struct city *pcity_near;
1104 int pcity_near_dist;
1105
1106 if ((pcity_near = tile_city(unit_tile(punit)))) {
1107 pcity_near_dist = 0;
1108 } else {
1109 pcity_near = NULL;
1110 pcity_near_dist = -1;
1111 players_iterate(pplayer) {
1112 city_list_iterate(pplayer->cities, pcity_current) {
1113 int dist = sq_map_distance(pcity_current->tile, unit_tile(punit));
1114
1115 if (pcity_near_dist == -1 || dist < pcity_near_dist
1116 || (dist == pcity_near_dist
1117 && unit_owner(punit) == city_owner(pcity_current))) {
1118 pcity_near = pcity_current;
1119 pcity_near_dist = dist;
1120 }
1123 }
1124
1125 if (sq_dist) {
1126 *sq_dist = pcity_near_dist;
1127 }
1128
1129 return pcity_near;
1130}
1131
1132/**********************************************************************/
1137void cityrep_buy(struct city *pcity)
1138{
1139 int value;
1140
1141 if (city_production_has_flag(pcity, IF_GOLD)) {
1142 create_event(pcity->tile, E_BAD_COMMAND, ftc_client,
1143 _("You can't buy %s in %s!"),
1145 city_link(pcity));
1146 return;
1147 }
1148 value = pcity->client.buy_cost;
1149
1150 if (city_owner(pcity)->economic.gold >= value) {
1151 city_buy_production(pcity);
1152 } else {
1153 /* Split into two to allow localization of two pluralisations. */
1154 char buf[MAX_LEN_MSG];
1155
1156 /* TRANS: %s is a production type; this whole string is a sentence
1157 * fragment that is only ever included in one other string
1158 * (search comments for this string to find it) */
1159 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("%s costs %d gold",
1160 "%s costs %d gold", value),
1162 value);
1163 create_event(NULL, E_BAD_COMMAND, ftc_client,
1164 /* TRANS: %s is a pre-pluralised sentence fragment:
1165 * "%s costs %d gold" */
1166 PL_("%s and you only have %d gold.",
1167 "%s and you only have %d gold.",
1168 city_owner(pcity)->economic.gold),
1169 buf, city_owner(pcity)->economic.gold);
1170 }
1171}
1172
1173/**********************************************************************/
1176void common_taxrates_callback(int idx, bool reverse)
1177{
1178 int lux_end, sci_end, tax, lux, sci;
1179 int delta = 10;
1180
1181 if (!can_client_issue_orders()) {
1182 return;
1183 }
1184
1185 lux_end = client.conn.playing->economic.luxury;
1186 sci_end = lux_end + client.conn.playing->economic.science;
1187
1191
1192 idx *= 10;
1193
1194 if (reverse) {
1195 if (idx < lux_end) {
1196 lux -= delta;
1197 tax += delta;
1198 } else if (idx < sci_end) {
1199 sci -= delta;
1200 lux += delta;
1201 } else {
1202 tax -= delta;
1203 sci += delta;
1204 }
1205 } else {
1206 if (idx < lux_end) {
1207 lux -= delta;
1208 sci += delta;
1209 } else if (idx < sci_end) {
1210 sci -= delta;
1211 tax += delta;
1212 } else {
1213 tax -= delta;
1214 lux += delta;
1215 }
1216 }
1217
1218 dsend_packet_player_rates(&client.conn, tax, lux, sci);
1219}
1220
1221/**********************************************************************/
1224bool can_units_do_connect(struct unit_list *punits,
1225 enum unit_activity activity,
1226 struct extra_type *tgt)
1227{
1228 unit_list_iterate(punits, punit) {
1229 if (can_unit_do_connect(punit, activity, tgt)) {
1230 return TRUE;
1231 }
1233
1234 return FALSE;
1235}
1236
1237/**********************************************************************/
1242{
1243 /* A double init would cause a leak. */
1245
1248}
1249
1250/**********************************************************************/
1257enum unit_bg_color_type unit_color_type(const struct unit_type *punittype)
1258{
1259 struct unit_class *pclass = utype_class(punittype);
1260
1261 if (pclass->hp_loss_pct > 0) {
1262 return UNIT_BG_HP_LOSS;
1263 }
1264
1265 if (pclass->move_type == UMT_LAND) {
1266 return UNIT_BG_LAND;
1267 }
1268 if (pclass->move_type == UMT_SEA) {
1269 return UNIT_BG_SEA;
1270 }
1271
1272 fc_assert(pclass->move_type == UMT_BOTH);
1273
1274 if (uclass_has_flag(pclass, UCF_TERRAIN_SPEED)) {
1275 /* Unit moves on both sea and land by speed determined by terrain */
1276 return UNIT_BG_AMPHIBIOUS;
1277 }
1278
1279 return UNIT_BG_FLYING;
1280}
1281
1282/**********************************************************************/
1285static int city_buy_cost_compare(const void *a, const void *b)
1286{
1287 const struct city *ca, *cb;
1288
1289 ca = *((const struct city **) a);
1290 cb = *((const struct city **) b);
1291
1292 return ca->client.buy_cost - cb->client.buy_cost;
1293}
1294
1295/**********************************************************************/
1300{
1301 const struct player *pplayer = client_player();
1302 struct connection *pconn;
1303
1304 if (!pplayer || !pplayer->cities
1305 || city_list_size(pplayer->cities) < 1) {
1306 return;
1307 }
1308
1309 int gold = pplayer->economic.gold;
1310 if (gold < 1) {
1311 return;
1312 }
1313
1314 const int n = city_list_size(pplayer->cities);
1315 struct city *cities[n];
1316 int i, count = 0;
1317
1318 city_list_iterate(pplayer->cities, pcity) {
1319 if (!is_city_hilited(pcity) || !city_can_buy(pcity)) {
1320 continue;
1321 }
1322 cities[count++] = pcity;
1324
1325 if (count < 1) {
1326 return;
1327 }
1328
1329 qsort(cities, count, sizeof(*cities), city_buy_cost_compare);
1330
1331 pconn = &client.conn;
1332 connection_do_buffer(pconn);
1333
1334 for (i = 0; i < count && gold > 0; i++) {
1335 gold -= cities[i]->client.buy_cost;
1337 }
1338
1340}
1341
1342/**********************************************************************/
1345void unit_focus_set_status(struct player *pplayer)
1346{
1347 unit_list_iterate(pplayer->units, punit) {
1350}
1351
1352/**********************************************************************/
1355void client_player_init(struct player *pplayer)
1356{
1358 pplayer->client.tile_vision[v].vec = NULL;
1359 pplayer->client.tile_vision[v].bits = 0;
1361}
1362
1363/**********************************************************************/
1367{
1368 players_iterate(pplayer) {
1369 int new_size;
1370
1371 if (pplayer == client.conn.playing) {
1372 new_size = MAP_INDEX_SIZE;
1373 } else {
1374 /* We don't need (or have) information about players other
1375 * than user of the client. Allocate just one bit as that's
1376 * the minimum bitvector size (cannot allocate 0 bits)*/
1377 new_size = 1;
1378 }
1379
1381 dbv_resize(&pplayer->client.tile_vision[v], new_size);
1383
1384 dbv_resize(&pplayer->tile_known, new_size);
1386}
1387
1388/**********************************************************************/
1392{
1393 char str[MAX_LEN_MAPDEF];
1394 char mi_map[MAPIMG_LAYER_COUNT + 1];
1395 enum mapimg_layer layer;
1396 int map_pos = 0;
1397
1398 /* Only one definition allowed. */
1399 while (mapimg_count() != 0) {
1400 mapimg_delete(0);
1401 }
1402
1403 /* Map image definition: zoom, turns */
1404 fc_snprintf(str, sizeof(str), "zoom=%d:turns=0:format=%s",
1406
1407 /* Map image definition: show */
1409 cat_snprintf(str, sizeof(str), ":show=all");
1410 /* use all available knowledge */
1411 gui_options.mapimg_layer[MAPIMG_LAYER_KNOWLEDGE] = FALSE;
1412 } else {
1413 cat_snprintf(str, sizeof(str), ":show=plrid:plrid=%d",
1415 /* use only player knowledge */
1416 gui_options.mapimg_layer[MAPIMG_LAYER_KNOWLEDGE] = TRUE;
1417 }
1418
1419 /* Map image definition: map */
1420 for (layer = mapimg_layer_begin(); layer != mapimg_layer_end();
1421 layer = mapimg_layer_next(layer)) {
1422 if (gui_options.mapimg_layer[layer]) {
1423 mi_map[map_pos++] = mapimg_layer_name(layer)[0];
1424 }
1425 }
1426 mi_map[map_pos] = '\0';
1427
1428 if (map_pos == 0) {
1429 /* no value set - use dummy setting */
1430 sz_strlcpy(mi_map, "-");
1431 }
1432 cat_snprintf(str, sizeof(str), ":map=%s", mi_map);
1433
1434 log_debug("client map image definition: %s", str);
1435
1436 if (!mapimg_define(str, FALSE) || !mapimg_isvalid(0)) {
1437 /* An error in the definition string or an error validation the string.
1438 * The error message is available via mapimg_error(). */
1439 return FALSE;
1440 }
1441
1442 return TRUE;
1443}
1444
1445/**********************************************************************/
1448bool mapimg_client_createmap(const char *filename)
1449{
1450 struct mapdef *pmapdef;
1451 char mapimgfile[512];
1452
1453 if (NULL == filename || '\0' == filename[0]) {
1455 } else {
1456 sz_strlcpy(mapimgfile, filename);
1457 }
1458
1459 if (!mapimg_client_define()) {
1460 return FALSE;
1461 }
1462
1463 pmapdef = mapimg_isvalid(0);
1464 if (!pmapdef) {
1465 return FALSE;
1466 }
1467
1468 return mapimg_create(pmapdef, TRUE, mapimgfile, NULL);
1469}
1470
1471/**********************************************************************/
1475{
1476 struct option *poption = optset_option_by_name(server_optset, "nationset");
1477 const char *setting_str;
1478
1479 if (poption == NULL
1480 || option_type(poption) != OT_STRING
1481 || (setting_str = option_str_get(poption)) == NULL) {
1482 setting_str = "";
1483 }
1484
1485 return nation_set_by_setting_value(setting_str);
1486}
1487
1488/**********************************************************************/
1492{
1494}
1495
1496/**********************************************************************/
1501enum ai_level server_ai_level(void)
1502{
1503 enum ai_level lvl = game.info.skill_level;
1504
1505 players_iterate(pplayer) {
1506 if (is_ai(pplayer) && pplayer->ai_common.skill_level != lvl) {
1507 return ai_level_invalid();
1508 }
1510
1511 if (!is_settable_ai_level(lvl)) {
1512 return ai_level_invalid();
1513 }
1514
1515 return lvl;
1516}
#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 can_city_build_unit_later(const struct city *pcity, const struct unit_type *punittype)
Definition city.c:946
bool can_city_build_now(const struct city *pcity, const struct universal *target)
Definition city.c:989
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:1212
const char * city_name_get(const struct city *pcity)
Definition city.c:1111
void city_remove_improvement(struct city *pcity, const struct impr_type *pimprove)
Definition city.c:3280
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_improvement_later(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:856
bool can_city_build_unit_now(const struct city *pcity, const struct unit_type *punittype)
Definition city.c:928
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:801
#define city_built_iterate_end
Definition city.h:807
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:585
int collect_eventually_buildable_targets(struct universal *targets, struct city *pcity, bool advanced_tech)
Definition climisc.c:802
bool city_unit_supported(const struct city *pcity, const struct universal *target)
Definition climisc.c:537
enum ai_level server_ai_level(void)
Definition climisc.c:1501
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:497
void create_event(struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Definition climisc.c:1075
int collect_buildable_targets(struct universal *targets)
Definition climisc.c:771
void client_player_init(struct player *pplayer)
Definition climisc.c:1355
bool mapimg_client_createmap(const char *filename)
Definition climisc.c:1448
void client_remove_city(struct city *pcity)
Definition climisc.c:134
void client_unit_init_act_prob_cache(struct unit *punit)
Definition climisc.c:1241
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:1299
void common_taxrates_callback(int idx, bool reverse)
Definition climisc.c:1176
static int city_buy_cost_compare(const void *a, const void *b)
Definition climisc.c:1285
bool mapimg_client_define(void)
Definition climisc.c:1391
int collect_currently_building_targets(struct universal *targets)
Definition climisc.c:739
enum unit_bg_color_type unit_color_type(const struct unit_type *punittype)
Definition climisc.c:1257
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:1224
void cityrep_buy(struct city *pcity)
Definition climisc.c:1137
void global_warming_scaled(int *chance, int *rate, int max)
Definition climisc.c:328
void client_player_maps_reset(void)
Definition climisc.c:1366
bool client_nation_is_in_current_set(const struct nation_type *pnation)
Definition climisc.c:1491
cid cid_encode_from_city(const struct city *pcity)
Definition climisc.c:510
void name_and_sort_items(struct universal *targets, int num_targets, struct item *items, bool show_cost, struct city *pcity)
Definition climisc.c:633
static int fc_cmp(const void *p1, const void *p2)
Definition climisc.c:609
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:933
cid cid_encode(struct universal target)
Definition climisc.c:475
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:575
struct nation_set * client_current_nation_set(void)
Definition climisc.c:1474
int num_supported_units_in_city(struct city *pcity)
Definition climisc.c:915
int collect_already_built_targets(struct universal *targets, struct city *pcity)
Definition climisc.c:895
struct city * get_nearest_city(const struct unit *punit, int *sq_dist)
Definition climisc.c:1101
struct universal cid_decode(cid id)
Definition climisc.c:518
void unit_focus_set_status(struct player *pplayer)
Definition climisc.c:1345
void handle_event(const char *featured_text, struct tile *ptile, enum event_type event, int turn, int phase, int conn_id)
Definition climisc.c:950
void center_on_something(void)
Definition climisc.c:424
cid cid_encode_unit(const struct unit_type *punittype)
Definition climisc.c:485
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
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:556
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:683
#define MAX_NUM_PRODUCTION_TARGETS
Definition climisc.h:87
int cid
Definition climisc.h:31
bool(* TestCityFunc)(const struct city *, const struct universal *)
Definition climisc.h:85
unit_bg_color_type
Definition climisc.h:125
@ UNIT_BG_AMPHIBIOUS
Definition climisc.h:128
@ UNIT_BG_SEA
Definition climisc.h:127
@ UNIT_BG_FLYING
Definition climisc.h:129
@ UNIT_BG_LAND
Definition climisc.h:126
@ UNIT_BG_HP_LOSS
Definition climisc.h:125
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:392
struct unit_list * get_units_in_focus(void)
Definition control.c:177
void unit_focus_advance(void)
Definition control.c:671
bool can_unit_do_connect(struct unit *punit, enum unit_activity activity, struct extra_type *tgt)
Definition control.c:1384
void update_unit_pix_label(struct unit_list *punitlist)
Definition control.c:966
struct unit * head_of_units_in_focus(void)
Definition control.c:406
int get_num_units_in_focus(void)
Definition control.c:185
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:1612
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:80
struct universal item
Definition climisc.h:81
char descr[MAX_LEN_NAME+40]
Definition climisc.h:82
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:161
#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:6508
struct sprite * get_indicator_sprite(const struct tileset *t, enum indicator_type indicator, int idx)
Definition tilespec.c:6698
struct sprite * get_citizen_sprite(const struct tileset *t, enum citizen_category type, int citizen_index, const struct city *pcity)
Definition tilespec.c:6441
@ 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:1769
bool unit_transport_unload(struct unit *pcargo)
Definition unit.c:2376
struct unit_list * unit_transport_cargo(const struct unit *ptrans)
Definition unit.c:2437
#define unit_tile(_pu)
Definition unit.h:388
@ FOCUS_AVAIL
Definition unit.h:53
#define unit_owner(_pu)
Definition unit.h:387
#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:838
#define unit_type_iterate_end
Definition unittype.h:845
#define vision_layer_iterate(v)
Definition vision.h:77
#define vision_layer_iterate_end
Definition vision.h:80