Freeciv-3.2
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
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
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
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. */
145
146 city_built_iterate(pcity, pimprove) {
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);
159}
160
161/**********************************************************************/
165void client_change_all(struct universal *from, struct universal *to)
166{
168 return;
169 }
170
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)) {
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/**********************************************************************/
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 return;
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 return;
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 return;
269 case CLAUSE_MAP:
270 fc_snprintf(buf, bufsiz, _("The %s give their worldmap"),
272 return;
273 case CLAUSE_SEAMAP:
274 fc_snprintf(buf, bufsiz, _("The %s give their seamap"),
276 return;
277 case CLAUSE_CEASEFIRE:
278 fc_snprintf(buf, bufsiz, _("The parties agree on a cease-fire"));
279 return;
280 case CLAUSE_PEACE:
281 fc_snprintf(buf, bufsiz, _("The parties agree on a peace"));
282 return;
283 case CLAUSE_ALLIANCE:
284 fc_snprintf(buf, bufsiz, _("The parties create an alliance"));
285 return;
286 case CLAUSE_VISION:
287 fc_snprintf(buf, bufsiz, _("The %s give shared vision"),
289 return;
290 case CLAUSE_EMBASSY:
291 fc_snprintf(buf, bufsiz, _("The %s give an embassy"),
293 return;
295 fc_snprintf(buf, bufsiz, _("The %s share tiles"),
297 return;
298 case CLAUSE_COUNT:
300 return;
301 }
302
304 if (bufsiz > 0) {
305 *buf = '\0';
306 }
307}
308
309/**********************************************************************/
314static void catastrophe_scaled(int *chance, int *rate, int max,
315 int current, int accum, int level)
316{
317 /* 20 from factor in update_environmental_upset() */
318 int numer = 20 * max;
319 int denom = map_num_tiles();
320
321 if (chance) {
322 *chance = CLIP(0,
323 (int)((((long)accum * numer) + (denom - 1)) / denom),
324 max);
325 }
326 if (rate) {
327 *rate = DIVIDE(((long)(current - level) * numer) + (denom - 1), denom);
328 }
329}
330
331/**********************************************************************/
334void global_warming_scaled(int *chance, int *rate, int max)
335{
336 return catastrophe_scaled(chance, rate, max,
339}
340
341/**********************************************************************/
344void nuclear_winter_scaled(int *chance, int *rate, int max)
345{
346 return catastrophe_scaled(chance, rate, max,
349}
350
351/**********************************************************************/
355{
357 const struct research *presearch = research_get(client_player());
358 int idx = 0;
359
360 if (A_UNSET != presearch->researching) {
361 idx = (NUM_TILES_PROGRESS * presearch->bulbs_researched
362 / (presearch->client.researching_cost + 1));
363 }
364
365 /* This clipping can be necessary since we can end up with excess
366 * research */
367 idx = CLIP(0, idx, NUM_TILES_PROGRESS - 1);
369 } else {
371 }
372}
373
374/**********************************************************************/
378{
379 int idx;
380
382 /* Highest sprite kicks in at about 25% risk */
384 idx = CLIP(0, idx, NUM_TILES_PROGRESS-1);
385 } else {
386 idx = 0;
387 }
389}
390
391/**********************************************************************/
395{
396 int idx;
397
399 /* Highest sprite kicks in at about 25% risk */
401 idx = CLIP(0, idx, NUM_TILES_PROGRESS-1);
402 } else {
403 idx = 0;
404 }
405
407}
408
409/**********************************************************************/
413{
415 && government_count() > 0) {
417
418 return get_government_sprite(tileset, gov);
419 } else {
420 /* HACK: the UNHAPPY citizen is used for the government
421 * when we don't know any better. */
423 }
424}
425
426/**********************************************************************/
431{
432 struct city *pcity;
433 struct unit *punit;
434 const struct civ_map *nmap = &(wld.map);
435
436 if (!can_client_change_view()) {
437 return;
438 }
439
441 if (get_num_units_in_focus() > 0) {
443 } else if (client_has_player()
444 && NULL != (pcity = player_primary_capital(client_player()))) {
445 /* Else focus on the capital. */
447 } else if (NULL != client.conn.playing
449 /* Just focus on any city. */
451 fc_assert_ret(pcity != NULL);
453 } else if (NULL != client.conn.playing
455 /* Just focus on any unit. */
459 } else {
460 struct tile *ctile = native_pos_to_tile(nmap, wld.map.xsize / 2, wld.map.ysize / 2);
461
462 /* Just any known tile will do; search near the middle first. */
463 /* Iterate outward from the center tile. We have to give a radius that
464 * is guaranteed to be larger than the map will be. Although this is
465 * a misuse of map.xsize and map.ysize (which are native dimensions),
466 * it should give a sufficiently large radius. */
468 if (client_tile_get_known(ptile) != TILE_UNKNOWN) {
469 ctile = ptile;
470 break;
471 }
473
475 }
476 can_slide = TRUE;
477}
478
479/**********************************************************************/
483{
484 return VUT_UTYPE == target.kind
485 ? B_LAST + utype_number(target.value.utype)
487}
488
489/**********************************************************************/
493{
494 struct universal target = {
495 .kind = VUT_UTYPE,
496 .value = {.utype = punittype}};
497
498 return cid_encode(target);
499}
500
501/**********************************************************************/
504cid cid_encode_building(const struct impr_type *pimprove)
505{
506 struct universal target = {
508 .value = {.building = pimprove}
509 };
510
511 return cid_encode(target);
512}
513
514/**********************************************************************/
517cid cid_encode_from_city(const struct city *pcity)
518{
519 return cid_encode(pcity->production);
520}
521
522/**********************************************************************/
526{
527 struct universal target;
528
529 if (id >= B_LAST) {
530 target.kind = VUT_UTYPE;
531 target.value.utype = utype_by_number(id - B_LAST);
532 } else {
533 target.kind = VUT_IMPROVEMENT;
535 }
536
537 return target;
538}
539
540/**********************************************************************/
544bool city_unit_supported(const struct city *pcity,
545 const struct universal *target)
546{
547 if (VUT_UTYPE == target->kind) {
548 const struct unit_type *tvtype = target->value.utype;
549
551 if (unit_type_get(punit) == tvtype) {
552 return TRUE;
553 }
555 }
556 return FALSE;
557}
558
559/**********************************************************************/
563bool city_unit_present(const struct city *pcity,
564 const struct universal *target)
565{
566 if (VUT_UTYPE == target->kind) {
567 const struct unit_type *tvtype = target->value.utype;
568
570 if (unit_type_get(punit) == tvtype) {
571 return TRUE;
572 }
573 }
575 }
576 return FALSE;
577}
578
579/**********************************************************************/
582bool city_building_present(const struct city *pcity,
583 const struct universal *target)
584{
585 return VUT_IMPROVEMENT == target->kind
586 && city_has_building(pcity, target->value.building);
587}
588
589/**********************************************************************/
592bool can_city_build_now_client(const struct city *pcity,
593 const struct universal *target)
594{
595 return can_city_build_now(&(wld.map), pcity, target);
596}
597
598/**********************************************************************/
601static int target_get_section(struct universal target)
602{
603 if (VUT_UTYPE == target.kind) {
605 return 2;
606 } else {
607 return 3;
608 }
609 } else {
611 return 1;
612 } else if (is_small_wonder(target.value.building)) {
613 return 4;
614 } else if (is_great_wonder(target.value.building)) {
615 return 5;
616 } else {
617 return 0;
618 }
619 }
620}
621
622/**********************************************************************/
625static int fc_cmp(const void *p1, const void *p2)
626{
627 const struct item *i1 = p1, *i2 = p2;
628 int s1 = target_get_section(i1->item);
629 int s2 = target_get_section(i2->item);
630
631 if (s1 == s2) {
632 return fc_strcasecmp(i1->descr, i2->descr);
633 }
634
635 return s1 - s2;
636}
637
638/**********************************************************************/
649void name_and_sort_items(struct universal *targets, int num_targets,
650 struct item *items,
651 bool show_cost, struct city *pcity)
652{
653 int i;
654
655 for (i = 0; i < num_targets; i++) {
656 struct universal target = targets[i];
657 int cost;
658 struct item *pitem = &items[i];
659 const char *name;
660
661 pitem->item = target;
662
663 if (VUT_UTYPE == target.kind) {
666 } else {
669 cost = -1;
670 } else {
671 if (pcity != NULL) {
672 cost = impr_build_shield_cost(pcity, target.value.building);
673 } else {
674 cost = MAX(target.value.building->build_cost * game.info.shieldbox / 100, 1);
675 }
676 }
677 }
678
679 if (show_cost) {
680 if (cost < 0) {
681 fc_snprintf(pitem->descr, sizeof(pitem->descr), "%s (XX)", name);
682 } else {
683 fc_snprintf(pitem->descr, sizeof(pitem->descr),
684 "%s (%d)", name, cost);
685 }
686 } else {
687 (void) fc_strlcpy(pitem->descr, name, sizeof(pitem->descr));
688 }
689 }
690
691 qsort(items, num_targets, sizeof(struct item), fc_cmp);
692}
693
694/**********************************************************************/
700 struct city **selected_cities,
702 bool append_wonders, bool change_prod,
704{
705 cid first = append_units ? B_LAST : 0;
706 cid last = (append_units
707 ? utype_count() + B_LAST
709 cid id;
710 int items_used = 0;
711
712 for (id = first; id < last; id++) {
713 bool append = FALSE;
714 struct universal target = cid_decode(id);
715
716 if (!append_units && (append_wonders != is_wonder(target.value.building))) {
717 continue;
718 }
719
720 if (!change_prod) {
721 if (client_has_player()) {
723 append |= test_func(pcity, &target);
725 } else {
726 cities_iterate(pcity) {
727 append |= test_func(pcity, &target);
729 }
730 } else {
731 int i;
732
733 for (i = 0; i < num_selected_cities; i++) {
734 append |= test_func(selected_cities[i], &target);
735 }
736 }
737
738 if (!append) {
739 continue;
740 }
741
742 targets[items_used] = target;
743 items_used++;
744 }
745
746 return items_used;
747}
748
749/**********************************************************************/
756{
758 int cids_used = 0;
759 cid id;
760
761 if (NULL == client.conn.playing) {
762 return 0;
763 }
764
765 memset(mapping, 0, sizeof(mapping));
768 }
770
771 for (id = 0; id < ARRAY_SIZE(mapping); id++) {
772 if (mapping[id]) {
773 targets[cids_used] = cid_decode(id);
774 cids_used++;
775 }
776 }
777
778 return cids_used;
779}
780
781/**********************************************************************/
788{
789 int cids_used = 0;
790
791 if (NULL == client.conn.playing) {
792 return 0;
793 }
794
795 improvement_iterate(pimprove) {
797 targets[cids_used].kind = VUT_IMPROVEMENT;
798 targets[cids_used].value.building = pimprove;
799 cids_used++;
800 }
802
805 targets[cids_used].kind = VUT_UTYPE;
806 targets[cids_used].value.utype = punittype;
807 cids_used++;
808 }
810
811 return cids_used;
812}
813
814/**********************************************************************/
819 struct city *pcity,
820 bool advanced_tech)
821{
822 struct player *pplayer = client_player();
823 int cids_used = 0;
824 const struct civ_map *nmap = &(wld.map);
825
826 improvement_iterate(pimprove) {
827 bool can_build;
829
830 if (NULL != pcity) {
831 /* Can the city build? */
832 can_build = can_city_build_improvement_now(pcity, pimprove);
834 pimprove);
835 } else if (NULL != pplayer) {
836 /* Can our player build? */
837 can_build = can_player_build_improvement_now(pplayer, pimprove);
839 pimprove);
840 } else {
841 /* Global observer case: can any player build? */
845 can_build = TRUE;
846 break;
847 }
849
854 break;
855 }
857 }
858
860 || (!advanced_tech && can_build)) {
861 targets[cids_used].kind = VUT_IMPROVEMENT;
862 targets[cids_used].value.building = pimprove;
863 cids_used++;
864 }
866
868 bool can_build;
870
871 if (NULL != pcity) {
872 /* Can the city build? */
875 } else if (NULL != pplayer) {
876 /* Can our player build? */
879 } else {
880 /* Global observer case: can any player build? */
884 can_build = TRUE;
885 break;
886 }
888
893 break;
894 }
896 }
897
899 || (!advanced_tech && can_build)) {
900 targets[cids_used].kind = VUT_UTYPE;
901 targets[cids_used].value.utype = punittype;
902 cids_used++;
903 }
905
906 return cids_used;
907}
908
909/**********************************************************************/
913 struct city *pcity)
914{
915 int cids_used = 0;
916
917 fc_assert_ret_val(pcity != NULL, 0);
918
919 city_built_iterate(pcity, pimprove) {
920 targets[cids_used].kind = VUT_IMPROVEMENT;
921 targets[cids_used].value.building = pimprove;
922 cids_used++;
924
925 return cids_used;
926}
927
928/**********************************************************************/
933{
934 struct unit_list *plist;
935
937 /* Other players don't see inside the city (but observers do). */
939 } else {
940 plist = pcity->units_supported;
941 }
942
943 return unit_list_size(plist);
944}
945
946/**********************************************************************/
951{
952 struct unit_list *plist;
953
955 /* Other players don't see inside the city (but observers do). */
957 } else {
958 plist = pcity->tile->units;
959 }
960
961 return unit_list_size(plist);
962}
963
964/**********************************************************************/
967void handle_event(const char *featured_text, struct tile *ptile,
968 enum event_type event, int turn, int phase, int conn_id)
969{
971 struct text_tag_list *tags;
972 int where = MW_OUTPUT; /* where to display the message */
973 bool fallback_needed = FALSE; /* we want fallback if actual 'where' is not
974 * usable */
975 bool shown = FALSE; /* Message displayed somewhere at least */
976
978 /* Server may have added a new event; leave as MW_OUTPUT */
979 log_verbose("Unknown event type %d!", event);
980 } else {
982 }
983
984 /* Get the original text. */
986 sizeof(plain_text), &tags, conn_id != -1);
987
988 /* Display link marks when an user is pointed us something. */
989 if (conn_id != -1) {
991 if (text_tag_type(ptag) == TTT_LINK) {
993 }
995 }
996
997 /* Maybe highlight our player and user names if someone is talking
998 * about us. */
999 if (-1 != conn_id
1000 && client.conn.id != conn_id
1002 const char *username = client.conn.username;
1003 size_t userlen = strlen(username);
1004 const char *playername = ((client_player() && !client_is_observer())
1006 size_t playerlen = playername ? strlen(playername) : 0;
1007 const char *p;
1008
1009 if (playername && playername[0] == '\0') {
1010 playername = NULL;
1011 }
1012
1013 if (username && username[0] == '\0') {
1014 username = NULL;
1015 }
1016
1017 for (p = plain_text; *p != '\0'; p++) {
1018 if (NULL != username
1019 && 0 == fc_strncasecmp(p, username, userlen)) {
1021 p - plain_text + userlen,
1023
1024 fc_assert(ptag != NULL);
1025
1026 if (ptag != NULL) {
1027 /* Appends to be sure it will be applied at last. */
1029 }
1030 } else if (NULL != playername
1031 && 0 == fc_strncasecmp(p, playername, playerlen)) {
1033 p - plain_text + playerlen,
1035
1036 fc_assert(ptag != NULL);
1037
1038 if (ptag != NULL) {
1039 /* Appends to be sure it will be applied at last. */
1041 }
1042 }
1043 }
1044 }
1045
1046 /* Popup */
1047 if (BOOL_VAL(where & MW_POPUP)) {
1048 /* Popups are usually not shown if player is under AI control.
1049 * Server operator messages are shown always. */
1050 if (NULL == client.conn.playing
1052 || event == E_MESSAGE_WALL) {
1053 popup_notify_goto_dialog(_("Popup Request"), plain_text, tags, ptile);
1054 shown = TRUE;
1055 } else {
1056 /* Force to chatline so it will be visible somewhere at least.
1057 * Messages window may still handle this so chatline is not needed
1058 * after all. */
1060 }
1061 }
1062
1063 /* Message window */
1064 if (BOOL_VAL(where & MW_MESSAGES)) {
1065 /* When the game isn't running, the messages dialog isn't present. */
1066 if (C_S_RUNNING <= client_state()) {
1067 meswin_add(plain_text, tags, ptile, event, turn, phase);
1068 shown = TRUE;
1069 } else {
1070 /* Force to chatline instead. */
1072 }
1073 }
1074
1075 /* Chatline */
1076 if (BOOL_VAL(where & MW_OUTPUT) || (fallback_needed && !shown)) {
1077 output_window_event(plain_text, tags, conn_id);
1078 }
1079
1080 if (turn == game.info.turn) {
1082 }
1083
1084 /* Free tags */
1086}
1087
1088/**********************************************************************/
1092void create_event(struct tile *ptile, enum event_type event,
1093 const struct ft_color color, const char *format, ...)
1094{
1095 va_list ap;
1096 char message[MAX_LEN_MSG];
1097
1098 va_start(ap, format);
1099 fc_vsnprintf(message, sizeof(message), format, ap);
1100 va_end(ap);
1101
1104
1108 } else {
1110 }
1111}
1112
1113/**********************************************************************/
1118struct city *get_nearest_city(const struct unit *punit, int *sq_dist)
1119{
1120 struct city *pcity_near;
1121 int pcity_near_dist;
1122
1123 if ((pcity_near = tile_city(unit_tile(punit)))) {
1124 pcity_near_dist = 0;
1125 } else {
1126 pcity_near = NULL;
1127 pcity_near_dist = -1;
1128 players_iterate(pplayer) {
1129 city_list_iterate(pplayer->cities, pcity_current) {
1130 int dist = sq_map_distance(pcity_current->tile, unit_tile(punit));
1131
1132 if (pcity_near_dist == -1 || dist < pcity_near_dist
1133 || (dist == pcity_near_dist
1136 pcity_near_dist = dist;
1137 }
1140 }
1141
1142 if (sq_dist) {
1144 }
1145
1146 return pcity_near;
1147}
1148
1149/**********************************************************************/
1154void cityrep_buy(struct city *pcity)
1155{
1156 int value;
1157
1160 _("You can't buy %s in %s!"),
1162 city_link(pcity));
1163 return;
1164 }
1165 value = pcity->client.buy_cost;
1166
1167 if (city_owner(pcity)->economic.gold >= value) {
1168 city_buy_production(pcity);
1169 } else {
1170 /* Split into two to allow localization of two pluralisations. */
1171 char buf[MAX_LEN_MSG];
1172
1173 /* TRANS: %s is a production type; this whole string is a sentence
1174 * fragment that is only ever included in one other string
1175 * (search comments for this string to find it) */
1176 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("%s costs %d gold",
1177 "%s costs %d gold", value),
1179 value);
1181 /* TRANS: %s is a pre-pluralised sentence fragment:
1182 * "%s costs %d gold" */
1183 PL_("%s and you only have %d gold.",
1184 "%s and you only have %d gold.",
1185 city_owner(pcity)->economic.gold),
1186 buf, city_owner(pcity)->economic.gold);
1187 }
1188}
1189
1190/**********************************************************************/
1194{
1195 int lux_end, sci_end, tax, lux, sci;
1196 int delta = 10;
1197
1198 if (!can_client_issue_orders()) {
1199 return;
1200 }
1201
1204
1208
1209 idx *= 10;
1210
1211 if (reverse) {
1212 if (idx < lux_end) {
1213 lux -= delta;
1214 tax += delta;
1215 } else if (idx < sci_end) {
1216 sci -= delta;
1217 lux += delta;
1218 } else {
1219 tax -= delta;
1220 sci += delta;
1221 }
1222 } else {
1223 if (idx < lux_end) {
1224 lux -= delta;
1225 sci += delta;
1226 } else if (idx < sci_end) {
1227 sci -= delta;
1228 tax += delta;
1229 } else {
1230 tax -= delta;
1231 lux += delta;
1232 }
1233 }
1234
1236}
1237
1238/**********************************************************************/
1241bool can_units_do_connect(struct unit_list *punits,
1242 enum unit_activity activity,
1243 struct extra_type *tgt)
1244{
1246 if (can_unit_do_connect(punit, activity, tgt)) {
1247 return TRUE;
1248 }
1250
1251 return FALSE;
1252}
1253
1254/**********************************************************************/
1259{
1260 /* A double init would cause a leak. */
1262
1265}
1266
1267/**********************************************************************/
1275{
1277
1278 if (pclass->hp_loss_pct > 0) {
1279 return UNIT_BG_HP_LOSS;
1280 }
1281
1282 if (pclass->move_type == UMT_LAND) {
1283 return UNIT_BG_LAND;
1284 }
1285 if (pclass->move_type == UMT_SEA) {
1286 return UNIT_BG_SEA;
1287 }
1288
1289 fc_assert(pclass->move_type == UMT_BOTH);
1290
1292 /* Unit moves on both sea and land by speed determined by terrain */
1293 return UNIT_BG_AMPHIBIOUS;
1294 }
1295
1296 return UNIT_BG_FLYING;
1297}
1298
1299/**********************************************************************/
1302static int city_buy_cost_compare(const void *a, const void *b)
1303{
1304 const struct city *ca, *cb;
1305
1306 ca = *((const struct city **) a);
1307 cb = *((const struct city **) b);
1308
1309 return ca->client.buy_cost - cb->client.buy_cost;
1310}
1311
1312/**********************************************************************/
1317{
1318 const struct player *pplayer = client_player();
1319 struct connection *pconn;
1320
1321 if (!pplayer || !pplayer->cities
1322 || city_list_size(pplayer->cities) < 1) {
1323 return;
1324 }
1325
1326 int gold = pplayer->economic.gold;
1327 if (gold < 1) {
1328 return;
1329 }
1330
1331 const int n = city_list_size(pplayer->cities);
1332 struct city *cities[n];
1333 int i, count = 0;
1334
1335 city_list_iterate(pplayer->cities, pcity) {
1336 if (!is_city_hilited(pcity) || !city_can_buy(pcity)) {
1337 continue;
1338 }
1339 cities[count++] = pcity;
1341
1342 if (count < 1) {
1343 return;
1344 }
1345
1346 qsort(cities, count, sizeof(*cities), city_buy_cost_compare);
1347
1348 pconn = &client.conn;
1350
1351 for (i = 0; i < count && gold > 0; i++) {
1352 gold -= cities[i]->client.buy_cost;
1354 }
1355
1357}
1358
1359/**********************************************************************/
1362void unit_focus_set_status(struct player *pplayer)
1363{
1364 unit_list_iterate(pplayer->units, punit) {
1367}
1368
1369/**********************************************************************/
1372void client_player_init(struct player *pplayer)
1373{
1375 pplayer->client.tile_vision[v].vec = NULL;
1376 pplayer->client.tile_vision[v].bits = 0;
1378}
1379
1380/**********************************************************************/
1384{
1385 players_iterate(pplayer) {
1386 int new_size;
1387
1388 if (pplayer == client.conn.playing) {
1390 } else {
1391 /* We don't need (or have) information about players other
1392 * than user of the client. Allocate just one bit as that's
1393 * the minimum bitvector size (cannot allocate 0 bits)*/
1394 new_size = 1;
1395 }
1396
1398 dbv_resize(&pplayer->client.tile_vision[v], new_size);
1400
1401 dbv_resize(&pplayer->tile_known, new_size);
1403}
1404
1405/**********************************************************************/
1409{
1410 char str[MAX_LEN_MAPDEF];
1411 char mi_map[MAPIMG_LAYER_COUNT + 1];
1412 enum mapimg_layer layer;
1413 int map_pos = 0;
1414
1415 /* Only one definition allowed. */
1416 while (mapimg_count() != 0) {
1417 mapimg_delete(0);
1418 }
1419
1420 /* Map image definition: zoom, turns */
1421 fc_snprintf(str, sizeof(str), "zoom=%d:turns=0:format=%s",
1423
1424 /* Map image definition: show */
1426 cat_snprintf(str, sizeof(str), ":show=all");
1427 /* use all available knowledge */
1429 } else {
1430 cat_snprintf(str, sizeof(str), ":show=plrid:plrid=%d",
1432 /* use only player knowledge */
1434 }
1435
1436 /* Map image definition: map */
1437 for (layer = mapimg_layer_begin(); layer != mapimg_layer_end();
1438 layer = mapimg_layer_next(layer)) {
1439 if (gui_options.mapimg_layer[layer]) {
1440 mi_map[map_pos++] = mapimg_layer_name(layer)[0];
1441 }
1442 }
1443 mi_map[map_pos] = '\0';
1444
1445 if (map_pos == 0) {
1446 /* no value set - use dummy setting */
1447 sz_strlcpy(mi_map, "-");
1448 }
1449 cat_snprintf(str, sizeof(str), ":map=%s", mi_map);
1450
1451 log_debug("client map image definition: %s", str);
1452
1453 if (!mapimg_define(str, FALSE) || !mapimg_isvalid(0)) {
1454 /* An error in the definition string or an error validation the string.
1455 * The error message is available via mapimg_error(). */
1456 return FALSE;
1457 }
1458
1459 return TRUE;
1460}
1461
1462/**********************************************************************/
1465bool mapimg_client_createmap(const char *filename)
1466{
1467 struct mapdef *pmapdef;
1468 char mapimgfile[512];
1469
1470 if (NULL == filename || '\0' == filename[0]) {
1472 } else {
1473 sz_strlcpy(mapimgfile, filename);
1474 }
1475
1476 if (!mapimg_client_define()) {
1477 return FALSE;
1478 }
1479
1481 if (!pmapdef) {
1482 return FALSE;
1483 }
1484
1486}
1487
1488/**********************************************************************/
1492{
1493 struct option *poption = optset_option_by_name(server_optset, "nationset");
1494 const char *setting_str;
1495
1496 if (poption == NULL
1499 setting_str = "";
1500 }
1501
1503}
1504
1505/**********************************************************************/
1509{
1511}
1512
1513/**********************************************************************/
1518enum ai_level server_ai_level(void)
1519{
1520 enum ai_level lvl = game.info.skill_level;
1521
1522 players_iterate(pplayer) {
1523 if (is_ai(pplayer) && pplayer->ai_common.skill_level != lvl) {
1524 return ai_level_invalid();
1525 }
1527
1528 if (!is_settable_ai_level(lvl)) {
1529 return ai_level_invalid();
1530 }
1531
1532 return lvl;
1533}
#define NUM_ACTIONS
Definition actions.h:315
#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:663
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:1240
const char * city_name_get(const struct city *pcity)
Definition city.c:1137
void city_remove_improvement(struct city *pcity, const struct impr_type *pimprove)
Definition city.c:3371
bool can_city_build_improvement_now(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:854
bool can_city_build_now(const struct civ_map *nmap, const struct city *pcity, const struct universal *target)
Definition city.c:1013
bool can_city_build_unit_now(const struct civ_map *nmap, const struct city *pcity, const struct unit_type *punittype)
Definition city.c:947
bool city_production_is_genus(const struct city *pcity, enum impr_genus_id genus)
Definition city.c:717
bool can_city_build_improvement_later(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:871
bool can_city_build_unit_later(const struct civ_map *nmap, const struct city *pcity, const struct unit_type *punittype)
Definition city.c:970
const char * city_production_name_translation(const struct city *pcity)
Definition city.c:700
#define cities_iterate_end
Definition city.h:517
#define city_list_iterate(citylist, pcity)
Definition city.h:508
#define city_tile(_pcity_)
Definition city.h:564
#define cities_iterate(pcity)
Definition city.h:512
@ CITIZEN_UNHAPPY
Definition city.h:270
#define city_owner(_pcity_)
Definition city.h:563
#define city_list_iterate_end
Definition city.h:510
#define city_built_iterate(_pcity, _p)
Definition city.h:834
#define city_built_iterate_end
Definition city.h:840
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:601
int collect_eventually_buildable_targets(struct universal *targets, struct city *pcity, bool advanced_tech)
Definition climisc.c:818
bool city_unit_supported(const struct city *pcity, const struct universal *target)
Definition climisc.c:544
enum ai_level server_ai_level(void)
Definition climisc.c:1518
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:504
void create_event(struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Definition climisc.c:1092
int collect_buildable_targets(struct universal *targets)
Definition climisc.c:787
void client_player_init(struct player *pplayer)
Definition climisc.c:1372
bool mapimg_client_createmap(const char *filename)
Definition climisc.c:1465
void client_remove_city(struct city *pcity)
Definition climisc.c:134
void client_unit_init_act_prob_cache(struct unit *punit)
Definition climisc.c:1258
void nuclear_winter_scaled(int *chance, int *rate, int max)
Definition climisc.c:344
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:1316
void common_taxrates_callback(int idx, bool reverse)
Definition climisc.c:1193
static int city_buy_cost_compare(const void *a, const void *b)
Definition climisc.c:1302
bool mapimg_client_define(void)
Definition climisc.c:1408
int collect_currently_building_targets(struct universal *targets)
Definition climisc.c:755
enum unit_bg_color_type unit_color_type(const struct unit_type *punittype)
Definition climisc.c:1274
struct sprite * client_warming_sprite(void)
Definition climisc.c:377
bool can_units_do_connect(struct unit_list *punits, enum unit_activity activity, struct extra_type *tgt)
Definition climisc.c:1241
void cityrep_buy(struct city *pcity)
Definition climisc.c:1154
void global_warming_scaled(int *chance, int *rate, int max)
Definition climisc.c:334
void client_player_maps_reset(void)
Definition climisc.c:1383
bool client_nation_is_in_current_set(const struct nation_type *pnation)
Definition climisc.c:1508
cid cid_encode_from_city(const struct city *pcity)
Definition climisc.c:517
void name_and_sort_items(struct universal *targets, int num_targets, struct item *items, bool show_cost, struct city *pcity)
Definition climisc.c:649
static int fc_cmp(const void *p1, const void *p2)
Definition climisc.c:625
struct sprite * client_cooling_sprite(void)
Definition climisc.c:394
struct sprite * client_research_sprite(void)
Definition climisc.c:354
int num_present_units_in_city(struct city *pcity)
Definition climisc.c:950
cid cid_encode(struct universal target)
Definition climisc.c:482
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:582
struct nation_set * client_current_nation_set(void)
Definition climisc.c:1491
int num_supported_units_in_city(struct city *pcity)
Definition climisc.c:932
int collect_already_built_targets(struct universal *targets, struct city *pcity)
Definition climisc.c:912
struct city * get_nearest_city(const struct unit *punit, int *sq_dist)
Definition climisc.c:1118
struct universal cid_decode(cid id)
Definition climisc.c:525
void unit_focus_set_status(struct player *pplayer)
Definition climisc.c:1362
void handle_event(const char *featured_text, struct tile *ptile, enum event_type event, int turn, int phase, int conn_id)
Definition climisc.c:967
void center_on_something(void)
Definition climisc.c:430
cid cid_encode_unit(const struct unit_type *punittype)
Definition climisc.c:492
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:592
struct sprite * client_government_sprite(void)
Definition climisc.c:412
static void catastrophe_scaled(int *chance, int *rate, int max, int current, int accum, int level)
Definition climisc.c:314
bool city_unit_present(const struct city *pcity, const struct universal *target)
Definition climisc.c:563
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:699
#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
char * incite_cost
Definition comments.c:75
#define MAX_LEN_MSG
Definition conn_types.h:37
void connection_do_buffer(struct connection *pc)
Definition connection.c:324
void connection_do_unbuffer(struct connection *pc)
Definition connection.c:336
struct unit * get_focus_unit_on_tile(const struct tile *ptile)
Definition control.c:396
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:1415
void update_unit_pix_label(struct unit_list *punitlist)
Definition control.c:985
struct unit * head_of_units_in_focus(void)
Definition control.c:410
int get_num_units_in_focus(void)
Definition control.c:185
void unit_focus_advance(bool accept_current)
Definition control.c:688
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:74
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:74
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:62
struct world wld
Definition game.c:63
void game_remove_unit(struct world *gworld, struct unit *punit)
Definition game.c:124
void game_remove_city(struct world *gworld, struct city *pcity)
Definition game.c:178
struct city * game_city_by_number(int id)
Definition game.c:107
Government_type_id government_count(void)
Definition government.c:71
struct government * government_of_player(const struct player *pplayer)
Definition government.c:114
void popdown_city_dialog(struct city *pcity)
Definition citydlg.c:595
void popup_notify_goto_dialog(const char *headline, const char *lines, const struct text_tag_list *tags, struct tile *ptile)
Definition dialogs.c:196
void update_unit_info_label(struct unit_list *punits)
Definition mapview.c:275
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 is_convert_improvement(const struct impr_type *pimprove)
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:641
int map_num_tiles(void)
Definition map.c:1014
struct tile * native_pos_to_tile(const struct civ_map *nmap, int nat_x, int nat_y)
Definition map.c:443
#define iterate_outward(nmap, start_tile, max_dist, itr_tile)
Definition map.h:367
#define iterate_outward_end
Definition map.h:371
#define MAP_INDEX_SIZE
Definition map.h:137
bool is_city_hilited(struct city *pcity)
struct mapdef * mapimg_isvalid(int id)
Definition mapimg.c:1121
bool mapimg_define(const char *maparg, bool check)
Definition mapimg.c:769
bool mapimg_delete(int id)
Definition mapimg.c:1204
int mapimg_count(void)
Definition mapimg.c:573
bool mapimg_create(struct mapdef *pmapdef, bool force, const char *savename, const char *path)
Definition mapimg.c:1332
#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:138
struct nation_type * nation_of_unit(const struct unit *punit)
Definition nation.c:463
struct nation_type * nation_of_city(const struct city *pcity)
Definition nation.c:454
bool nation_is_in_set(const struct nation_type *pnation, const struct nation_set *pset)
Definition nation.c:837
struct nation_set * nation_set_by_setting_value(const char *setting)
Definition nation.c:859
const char * nation_plural_for_player(const struct player *pplayer)
Definition nation.c:178
const struct option_set * server_optset
Definition options.c:4016
const char * option_str_get(const struct option *poption)
Definition options.c:893
enum option_type option_type(const struct option *poption)
Definition options.c:658
int messages_where[E_COUNT]
Definition options.c:5037
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:431
#define MW_POPUP
Definition options.h:579
#define MW_OUTPUT
Definition options.h:577
#define MW_MESSAGES
Definition options.h:578
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:1517
struct city_list * cities
Definition packhand.c:119
bool is_settable_ai_level(enum ai_level level)
Definition player.c:1919
const char * player_name(const struct player *pplayer)
Definition player.c:895
struct city * player_primary_capital(const struct player *pplayer)
Definition player.c:1337
int player_index(const struct player *pplayer)
Definition player.c:829
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Definition player.c:324
bool can_player_see_units_in_city(const struct player *pplayer, const struct city *pcity)
Definition player.c:1133
bool can_player_see_city_internals(const struct player *pplayer, const struct city *pcity)
Definition player.c:1149
bool player_has_embassy(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:208
bool gives_shared_vision(const struct player *me, const struct player *them)
Definition player.c:1485
#define players_iterate_end
Definition player.h:537
#define players_iterate(_pplayer)
Definition player.h:532
#define is_ai(plr)
Definition player.h:230
#define is_human(plr)
Definition player.h:229
bool are_universals_equal(const struct universal *psource1, const struct universal *psource2)
struct research * research_get(const struct player *pplayer)
Definition research.c:128
struct setting_list * level[OLEVELS_NUM]
Definition settings.c:190
#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
Definition city.h:320
int id
Definition city.h:326
struct unit_list * info_units_present
Definition city.h:474
struct unit_list * info_units_supported
Definition city.h:473
bool occupied
Definition city.h:460
struct universal production
Definition city.h:396
int buy_cost
Definition city.h:466
struct tile * tile
Definition city.h:322
struct unit_list * units_supported
Definition city.h:406
struct city::@17::@20 client
struct packet_game_info info
Definition game.h:89
int xsize
Definition map_types.h:78
int ysize
Definition map_types.h:78
struct connection conn
Definition client_main.h:96
bool mapimg_layer[MAPIMG_LAYER_COUNT]
Definition options.h:227
struct ft_color highlight_our_names
Definition options.h:176
char mapimg_format[64]
Definition options.h:225
char mapimg_filename[512]
Definition options.h:228
Definition colors.h:21
struct player * playing
Definition connection.h:151
char username[MAX_LEN_NAME]
Definition connection.h:164
int bits
Definition bitvector.h:33
unsigned char * vec
Definition bitvector.h:34
int build_cost
Definition improvement.h:60
Definition climisc.h:82
struct universal item
Definition climisc.h:83
enum ai_level skill_level
struct city_list * cities
Definition player.h:279
struct dbv tile_vision[V_COUNT]
Definition player.h:357
struct unit_list * units
Definition player.h:280
struct player::@70::@73 client
struct player_economic economic
Definition player.h:282
Definition tile.h:50
struct unit_list * units
Definition tile.h:58
Definition unit.h:138
struct unit::@81::@83 client
int id
Definition unit.h:145
struct act_prob * act_prob_cache
Definition unit.h:228
int homecity
Definition unit.h:146
enum unit_focus_status focus_status
Definition unit.h:214
enum universals_n kind
Definition fc_types.h:902
universals_u value
Definition fc_types.h:901
struct civ_map map
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
size_t fc_strlcpy(char *dest, const char *src, size_t n)
Definition support.c:791
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:1000
int fc_vsnprintf(char *str, size_t n, const char *format, va_list ap)
Definition support.c:900
int fc_strncasecmp(const char *str0, const char *str1, size_t n)
Definition support.c:238
#define sz_strlcpy(dest, src)
Definition support.h:195
#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:36
#define TILE_XY(ptile)
Definition tile.h:43
struct sprite * get_government_sprite(const struct tileset *t, const struct government *gov)
Definition tilespec.c:6793
struct sprite * get_indicator_sprite(const struct tileset *t, enum indicator_type indicator, int idx)
Definition tilespec.c:6999
struct sprite * get_citizen_sprite(const struct tileset *t, enum citizen_category type, int citizen_index, const struct city *pcity)
Definition tilespec.c:6722
@ INDICATOR_COOLING
Definition tilespec.h:308
@ INDICATOR_WARMING
Definition tilespec.h:307
@ INDICATOR_BULB
Definition tilespec.h:306
#define NUM_TILES_PROGRESS
Definition tilespec.h:195
const struct unit_type * utype
Definition fc_types.h:721
const struct impr_type * building
Definition fc_types.h:714
int get_transporter_occupancy(const struct unit *ptrans)
Definition unit.c:1783
bool unit_transport_unload(struct unit *pcargo)
Definition unit.c:2390
struct unit_list * unit_transport_cargo(const struct unit *ptrans)
Definition unit.c:2451
#define unit_tile(_pu)
Definition unit.h:397
@ FOCUS_AVAIL
Definition unit.h:53
#define unit_owner(_pu)
Definition unit.h:396
#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:1587
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:2099
int utype_build_shield_cost(const struct city *pcity, const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1438
bool can_player_build_unit_now(const struct player *p, const struct unit_type *punittype)
Definition unittype.c:2078
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1560
const char * utype_values_translation(const struct unit_type *punittype)
Definition unittype.c:1617
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
Definition unittype.h:766
#define utype_class(_t_)
Definition unittype.h:749
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:617
#define unit_type_iterate(_p)
Definition unittype.h:855
#define unit_type_iterate_end
Definition unittype.h:862
#define vision_layer_iterate(v)
Definition vision.h:77
#define vision_layer_iterate_end
Definition vision.h:80