Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/climisc.c Source File

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/**********************************************************************/
72 void client_remove_unit(struct unit *punit)
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",
82 punit->id, nation_rule_name(nation_of_unit(punit)),
83 unit_rule_name(punit), TILE_XY(unit_tile(punit)), hc);
84
85 update = (get_focus_unit_on_tile(unit_tile(punit)) != NULL);
86
87 /* Check transport status. */
88 unit_transport_unload(punit);
89 if (get_transporter_occupancy(punit) > 0) {
90 unit_list_iterate(unit_transport_cargo(punit), pcargo) {
91 /* The server should take care that the unit is on the right terrain. */
92 unit_transport_unload(pcargo);
93 } unit_list_iterate_end;
94 }
95
96 control_unit_killed(punit);
97 game_remove_unit(&wld, punit);
98 punit = NULL;
99 if (old > 0 && get_num_units_in_focus() == 0) {
100 unit_focus_advance();
101 } else if (update) {
102 update_unit_pix_label(get_units_in_focus());
103 update_unit_info_label(get_units_in_focus());
104 }
105
106 pcity = tile_city(ptile);
107 if (NULL != pcity) {
108 if (can_player_see_units_in_city(client_player(), 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)",
114 city_name_get(pcity), nation_rule_name(nation_of_city(pcity)),
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)",
123 city_name_get(pcity), nation_rule_name(nation_of_city(pcity)),
124 TILE_XY(city_tile(pcity)));
125 }
126 }
127
128 refresh_unit_mapcanvas(&old_unit, ptile, TRUE, FALSE);
129}
130
131/**********************************************************************/
134 void 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);
149 } city_built_iterate_end;
150
151 if (effect_update) {
152 /* nothing yet */
153 }
154
155 popdown_city_dialog(pcity);
156 game_remove_city(&wld, pcity);
157 city_report_dialog_update();
158 refresh_city_mapcanvas(&old_city, ptile, TRUE, FALSE);
159}
160
161/**********************************************************************/
165 void client_change_all(struct universal *from, struct universal *to)
166{
167 if (!can_client_issue_orders()) {
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
174 ? utype_name_translation(from->value.utype)
175 : improvement_name_translation(from->value.building),
176 VUT_UTYPE == to->kind
177 ? utype_name_translation(to->value.utype)
178 : improvement_name_translation(to->value.building));
179
180 connection_do_buffer(&client.conn);
181 city_list_iterate (client.conn.playing->cities, pcity) {
182 if (are_universals_equal(&pcity->production, from)
183 && can_city_build_now(pcity, to)) {
184 city_change_production(pcity, to);
185 }
186 } city_list_iterate_end;
187
188 connection_do_unbuffer(&client.conn);
189}
190
191/**********************************************************************/
194 const 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/**********************************************************************/
222 const 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/**********************************************************************/
241 void 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"),
249 nation_plural_for_player(pclause->from),
250 advance_name_translation(advance_by_number(pclause->value)));
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"),
256 nation_plural_for_player(pclause->from),
257 city_name_get(pcity));
258 } else {
259 fc_snprintf(buf, bufsiz,_("The %s give an unknown city"),
260 nation_plural_for_player(pclause->from));
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),
266 nation_plural_for_player(pclause->from),
267 pclause->value);
268 break;
269 case CLAUSE_MAP:
270 fc_snprintf(buf, bufsiz, _("The %s give their worldmap"),
271 nation_plural_for_player(pclause->from));
272 break;
273 case CLAUSE_SEAMAP:
274 fc_snprintf(buf, bufsiz, _("The %s give their seamap"),
275 nation_plural_for_player(pclause->from));
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"),
288 nation_plural_for_player(pclause->from));
289 break;
290 case CLAUSE_EMBASSY:
291 fc_snprintf(buf, bufsiz, _("The %s give an embassy"),
292 nation_plural_for_player(pclause->from));
293 break;
294 default:
295 fc_assert(FALSE);
296 if (bufsiz > 0) {
297 *buf = '\0';
298 }
299 break;
300 }
301}
302
303/**********************************************************************/
308 static 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/**********************************************************************/
328 void global_warming_scaled(int *chance, int *rate, int max)
329{
330 return catastrophe_scaled(chance, rate, max,
331 game.info.heating, game.info.globalwarming,
332 game.info.warminglevel);
333}
334
335/**********************************************************************/
338 void nuclear_winter_scaled(int *chance, int *rate, int max)
339{
340 return catastrophe_scaled(chance, rate, max,
341 game.info.cooling, game.info.nuclearwinter,
342 game.info.coolinglevel);
343}
344
345/**********************************************************************/
348 struct sprite *client_research_sprite(void)
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);
362 return get_indicator_sprite(tileset, INDICATOR_BULB, idx);
363 } else {
364 return get_indicator_sprite(tileset, INDICATOR_BULB, 0);
365 }
366}
367
368/**********************************************************************/
371 struct sprite *client_warming_sprite(void)
372{
373 int idx;
374
375 if (can_client_change_view()) {
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 }
382 return get_indicator_sprite(tileset, INDICATOR_WARMING, idx);
383}
384
385/**********************************************************************/
388 struct sprite *client_cooling_sprite(void)
389{
390 int idx;
391
392 if (can_client_change_view()) {
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
400 return get_indicator_sprite(tileset, INDICATOR_COOLING, idx);
401}
402
403/**********************************************************************/
406 struct sprite *client_government_sprite(void)
407{
408 if (NULL != client.conn.playing && can_client_change_view()
409 && government_count() > 0) {
410 struct government *gov = government_of_player(client.conn.playing);
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. */
416 return get_citizen_sprite(tileset, CITIZEN_UNHAPPY, 0, NULL);
417 }
418}
419
420/**********************************************************************/
424 void center_on_something(void)
425{
426 struct city *pcity;
427 struct unit *punit;
428
429 if (!can_client_change_view()) {
430 return;
431 }
432
433 can_slide = FALSE;
434 if (get_num_units_in_focus() > 0) {
435 center_tile_mapcanvas(unit_tile(head_of_units_in_focus()));
436 } else if (client_has_player()
437 && NULL != (pcity = player_primary_capital(client_player()))) {
438 /* Else focus on the capital. */
439 center_tile_mapcanvas(pcity->tile);
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);
445 center_tile_mapcanvas(pcity->tile);
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);
451 center_tile_mapcanvas(unit_tile(punit));
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 }
465 } iterate_outward_end;
466
467 center_tile_mapcanvas(ctile);
468 }
469 can_slide = TRUE;
470}
471
472/**********************************************************************/
475 cid cid_encode(struct universal target)
476{
477 return VUT_UTYPE == target.kind
478 ? B_LAST + utype_number(target.value.utype)
479 : improvement_number(target.value.building);
480}
481
482/**********************************************************************/
485 cid 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/**********************************************************************/
497 cid 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/**********************************************************************/
510 cid cid_encode_from_city(const struct city *pcity)
511{
512 return cid_encode(pcity->production);
513}
514
515/**********************************************************************/
518 struct universal cid_decode(cid id)
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;
527 target.value.building = improvement_by_number(id);
528 }
529
530 return target;
531}
532
533/**********************************************************************/
537 bool 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
543 unit_list_iterate(pcity->units_supported, punit) {
544 if (unit_type_get(punit) == tvtype) {
545 return TRUE;
546 }
547 } unit_list_iterate_end;
548 }
549 return FALSE;
550}
551
552/**********************************************************************/
556 bool 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
562 unit_list_iterate(pcity->tile->units, punit) {
563 if (unit_type_get(punit) == tvtype) {
564 return TRUE;
565 }
566 }
567 unit_list_iterate_end;
568 }
569 return FALSE;
570}
571
572/**********************************************************************/
575 bool 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/**********************************************************************/
585 static 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/**********************************************************************/
609 static 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/**********************************************************************/
633 void 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) {
648 name = utype_values_translation(target.value.utype);
649 cost = utype_build_shield_cost(pcity, client_player(), target.value.utype);
650 } else {
651 name = city_improvement_name_translation(pcity, target.value.building);
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/**********************************************************************/
683 int collect_production_targets(struct universal *targets,
684 struct city **selected_cities,
685 int num_selected_cities, bool append_units,
686 bool append_wonders, bool change_prod,
687 TestCityFunc test_func)
688{
689 cid first = append_units ? B_LAST : 0;
690 cid last = (append_units
691 ? utype_count() + B_LAST
692 : improvement_count());
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()) {
706 city_list_iterate(client_player()->cities, pcity) {
707 append |= test_func(pcity, &target);
708 } city_list_iterate_end;
709 } else {
710 cities_iterate(pcity) {
711 append |= test_func(pcity, &target);
712 } cities_iterate_end;
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/**********************************************************************/
739 int collect_currently_building_targets(struct universal *targets)
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));
750 city_list_iterate(client.conn.playing->cities, pcity) {
751 mapping[cid_encode_from_city(pcity)] = TRUE;
752 }
753 city_list_iterate_end;
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/**********************************************************************/
771 int collect_buildable_targets(struct universal *targets)
772{
773 int cids_used = 0;
774
775 if (NULL == client.conn.playing) {
776 return 0;
777 }
778
779 improvement_iterate(pimprove) {
780 if (can_player_build_improvement_now(client.conn.playing, pimprove)) {
781 targets[cids_used].kind = VUT_IMPROVEMENT;
782 targets[cids_used].value.building = pimprove;
783 cids_used++;
784 }
785 } improvement_iterate_end;
786
787 unit_type_iterate(punittype) {
788 if (can_player_build_unit_now(client.conn.playing, punittype)) {
789 targets[cids_used].kind = VUT_UTYPE;
790 targets[cids_used].value.utype = punittype;
791 cids_used++;
792 }
793 } unit_type_iterate_end
794
795 return cids_used;
796}
797
798/**********************************************************************/
802 int collect_eventually_buildable_targets(struct universal *targets,
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 }
831 } players_iterate_end;
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 }
839 } players_iterate_end;
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 }
848 } improvement_iterate_end;
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 }
870 } players_iterate_end;
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 }
878 } players_iterate_end;
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 }
887 } unit_type_iterate_end;
888
889 return cids_used;
890}
891
892/**********************************************************************/
895 int collect_already_built_targets(struct universal *targets,
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++;
906 } city_built_iterate_end;
907
908 return cids_used;
909}
910
911/**********************************************************************/
915 int num_supported_units_in_city(struct city *pcity)
916{
917 struct unit_list *plist;
918
919 if (can_player_see_city_internals(client.conn.playing, pcity)) {
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/**********************************************************************/
933 int num_present_units_in_city(struct city *pcity)
934{
935 struct unit_list *plist;
936
937 if (can_player_see_units_in_city(client.conn.playing, pcity)) {
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/**********************************************************************/
950 void 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) {
975 link_mark_add_new(text_tag_link_type(ptag), text_tag_link_id(ptag));
976 }
977 } text_tag_list_iterate_end;
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
984 && ft_color_requested(gui_options.highlight_our_names)) {
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,
1005 gui_options.highlight_our_names);
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,
1017 gui_options.highlight_our_names);
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
1034 || is_human(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) {
1064 play_sound_for_event(event);
1065 }
1066
1067 /* Free tags */
1068 text_tag_list_destroy(tags);
1069}
1070
1071/**********************************************************************/
1075 void 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
1085 if (ft_color_requested(color)) {
1086 char colored_text[MAX_LEN_MSG];
1087
1088 featured_text_apply_tag(message, colored_text, sizeof(colored_text),
1089 TTT_COLOR, 0, FT_OFFSET_UNSET, color);
1090 handle_event(colored_text, ptile, event, game.info.turn, game.info.phase, -1);
1091 } else {
1092 handle_event(message, ptile, event, game.info.turn, game.info.phase, -1);
1093 }
1094}
1095
1096/**********************************************************************/
1101 struct 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 }
1121 } city_list_iterate_end;
1122 } players_iterate_end;
1123 }
1124
1125 if (sq_dist) {
1126 *sq_dist = pcity_near_dist;
1127 }
1128
1129 return pcity_near;
1130}
1131
1132/**********************************************************************/
1137 void 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!"),
1144 improvement_name_translation(pcity->production.value.building),
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),
1161 city_production_name_translation(pcity),
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/**********************************************************************/
1176 void 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
1188 lux = client.conn.playing->economic.luxury;
1189 sci = client.conn.playing->economic.science;
1190 tax = client.conn.playing->economic.tax;
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/**********************************************************************/
1224 bool 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 }
1232 } unit_list_iterate_end;
1233
1234 return FALSE;
1235}
1236
1237/**********************************************************************/
1241 void client_unit_init_act_prob_cache(struct unit *punit)
1242{
1243 /* A double init would cause a leak. */
1244 fc_assert_ret(punit->client.act_prob_cache == NULL);
1245
1246 punit->client.act_prob_cache = (struct act_prob*)fc_malloc(
1247 NUM_ACTIONS * sizeof(*punit->client.act_prob_cache));
1248}
1249
1250/**********************************************************************/
1257 enum 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/**********************************************************************/
1285 static 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/**********************************************************************/
1299 void buy_production_in_selected_cities(void)
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;
1323 } city_list_iterate_end;
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;
1336 city_buy_production(cities[i]);
1337 }
1338
1339 connection_do_unbuffer(pconn);
1340}
1341
1342/**********************************************************************/
1345 void unit_focus_set_status(struct player *pplayer)
1346{
1347 unit_list_iterate(pplayer->units, punit) {
1348 punit->client.focus_status = FOCUS_AVAIL;
1349 } unit_list_iterate_end;
1350}
1351
1352/**********************************************************************/
1355 void client_player_init(struct player *pplayer)
1356{
1357 vision_layer_iterate(v) {
1358 pplayer->client.tile_vision[v].vec = NULL;
1359 pplayer->client.tile_vision[v].bits = 0;
1360 } vision_layer_iterate_end;
1361}
1362
1363/**********************************************************************/
1366 void client_player_maps_reset(void)
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
1380 vision_layer_iterate(v) {
1381 dbv_resize(&pplayer->client.tile_vision[v], new_size);
1382 } vision_layer_iterate_end;
1383
1384 dbv_resize(&pplayer->tile_known, new_size);
1385 } players_iterate_end;
1386}
1387
1388/**********************************************************************/
1391 bool mapimg_client_define(void)
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",
1405 gui_options.mapimg_zoom, gui_options.mapimg_format);
1406
1407 /* Map image definition: show */
1408 if (client_is_global_observer()) {
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",
1414 player_index(client.conn.playing));
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/**********************************************************************/
1448 bool mapimg_client_createmap(const char *filename)
1449{
1450 struct mapdef *pmapdef;
1451 char mapimgfile[512];
1452
1453 if (NULL == filename || '\0' == filename[0]) {
1454 sz_strlcpy(mapimgfile, gui_options.mapimg_filename);
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/**********************************************************************/
1474 struct nation_set *client_current_nation_set(void)
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/**********************************************************************/
1491 bool client_nation_is_in_current_set(const struct nation_type *pnation)
1492{
1493 return nation_is_in_set(pnation, client_current_nation_set());
1494}
1495
1496/**********************************************************************/
1501 enum 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 }
1509 } players_iterate_end;
1510
1511 if (!is_settable_ai_level(lvl)) {
1512 return ai_level_invalid();
1513 }
1514
1515 return lvl;
1516}
NUM_ACTIONS
#define NUM_ACTIONS
Definition actions.h:297
str
#define str
Definition astring.c:76
n
#define n
Definition astring.c:77
dbv_resize
void dbv_resize(struct dbv *pdbv, int bits)
Definition bitvector.c:71
bitvector.h
output_window_event
void output_window_event(const char *plain_text, const struct text_tag_list *tags, int conn_id)
Definition chatline_common.c:166
chatline_g.h
city_improvement_name_translation
const char * city_improvement_name_translation(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:658
can_city_build_unit_later
bool can_city_build_unit_later(const struct city *pcity, const struct unit_type *punittype)
Definition city.c:946
can_city_build_now
bool can_city_build_now(const struct city *pcity, const struct universal *target)
Definition city.c:989
city_has_building
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:1212
city_name_get
const char * city_name_get(const struct city *pcity)
Definition city.c:1111
city_remove_improvement
void city_remove_improvement(struct city *pcity, const struct impr_type *pimprove)
Definition city.c:3280
city_production_has_flag
bool city_production_has_flag(const struct city *pcity, enum impr_flag_id flag)
Definition city.c:712
can_city_build_improvement_now
bool can_city_build_improvement_now(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:839
can_city_build_improvement_later
bool can_city_build_improvement_later(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:856
can_city_build_unit_now
bool can_city_build_unit_now(const struct city *pcity, const struct unit_type *punittype)
Definition city.c:928
city_production_name_translation
const char * city_production_name_translation(const struct city *pcity)
Definition city.c:695
city.h
cities_iterate_end
#define cities_iterate_end
Definition city.h:497
city_list_iterate
#define city_list_iterate(citylist, pcity)
Definition city.h:488
city_tile
#define city_tile(_pcity_)
Definition city.h:544
cities_iterate
#define cities_iterate(pcity)
Definition city.h:492
CITIZEN_UNHAPPY
@ CITIZEN_UNHAPPY
Definition city.h:262
city_owner
#define city_owner(_pcity_)
Definition city.h:543
city_list_iterate_end
#define city_list_iterate_end
Definition city.h:490
city_built_iterate
#define city_built_iterate(_pcity, _p)
Definition city.h:801
city_built_iterate_end
#define city_built_iterate_end
Definition city.h:807
city_buy_production
int city_buy_production(struct city *pcity)
Definition citydlg_common.c:1525
city_change_production
int city_change_production(struct city *pcity, struct universal *target)
Definition citydlg_common.c:1261
city_can_buy
bool city_can_buy(const struct city *pcity)
Definition citydlg_common.c:1497
citydlg_g.h
refresh_city_dialog
void refresh_city_dialog(struct city *pcity)
Definition update_queue.c:632
cityrep_g.h
city_report_dialog_update
void city_report_dialog_update(void)
Definition update_queue.c:666
client_is_global_observer
bool client_is_global_observer(void)
Definition client_main.c:1346
client_is_observer
bool client_is_observer(void)
Definition client_main.c:1086
client
struct civclient client
Definition client_main.c:149
client_state
enum client_states client_state(void)
Definition client_main.c:1029
can_client_issue_orders
bool can_client_issue_orders(void)
Definition client_main.c:1265
client_has_player
bool client_has_player(void)
Definition client_main.c:1365
can_client_change_view
bool can_client_change_view(void)
Definition client_main.c:1313
client_main.h
client_player
#define client_player()
Definition client_main.h:106
C_S_RUNNING
@ C_S_RUNNING
Definition client_main.h:47
client_tile_get_known
enum known_type client_tile_get_known(const struct tile *ptile)
Definition climap.c:36
climap.h
target_get_section
static int target_get_section(struct universal target)
Definition climisc.c:585
collect_eventually_buildable_targets
int collect_eventually_buildable_targets(struct universal *targets, struct city *pcity, bool advanced_tech)
Definition climisc.c:802
city_unit_supported
bool city_unit_supported(const struct city *pcity, const struct universal *target)
Definition climisc.c:537
server_ai_level
enum ai_level server_ai_level(void)
Definition climisc.c:1501
client_change_all
void client_change_all(struct universal *from, struct universal *to)
Definition climisc.c:165
cid_encode_building
cid cid_encode_building(const struct impr_type *pimprove)
Definition climisc.c:497
create_event
void create_event(struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Definition climisc.c:1075
collect_buildable_targets
int collect_buildable_targets(struct universal *targets)
Definition climisc.c:771
client_player_init
void client_player_init(struct player *pplayer)
Definition climisc.c:1355
mapimg_client_createmap
bool mapimg_client_createmap(const char *filename)
Definition climisc.c:1448
client_remove_city
void client_remove_city(struct city *pcity)
Definition climisc.c:134
client_unit_init_act_prob_cache
void client_unit_init_act_prob_cache(struct unit *punit)
Definition climisc.c:1241
nuclear_winter_scaled
void nuclear_winter_scaled(int *chance, int *rate, int max)
Definition climisc.c:338
get_embassy_status
const char * get_embassy_status(const struct player *me, const struct player *them)
Definition climisc.c:194
buy_production_in_selected_cities
void buy_production_in_selected_cities(void)
Definition climisc.c:1299
common_taxrates_callback
void common_taxrates_callback(int idx, bool reverse)
Definition climisc.c:1176
city_buy_cost_compare
static int city_buy_cost_compare(const void *a, const void *b)
Definition climisc.c:1285
mapimg_client_define
bool mapimg_client_define(void)
Definition climisc.c:1391
collect_currently_building_targets
int collect_currently_building_targets(struct universal *targets)
Definition climisc.c:739
unit_color_type
enum unit_bg_color_type unit_color_type(const struct unit_type *punittype)
Definition climisc.c:1257
client_warming_sprite
struct sprite * client_warming_sprite(void)
Definition climisc.c:371
can_units_do_connect
bool can_units_do_connect(struct unit_list *punits, enum unit_activity activity, struct extra_type *tgt)
Definition climisc.c:1224
cityrep_buy
void cityrep_buy(struct city *pcity)
Definition climisc.c:1137
global_warming_scaled
void global_warming_scaled(int *chance, int *rate, int max)
Definition climisc.c:328
client_player_maps_reset
void client_player_maps_reset(void)
Definition climisc.c:1366
client_nation_is_in_current_set
bool client_nation_is_in_current_set(const struct nation_type *pnation)
Definition climisc.c:1491
cid_encode_from_city
cid cid_encode_from_city(const struct city *pcity)
Definition climisc.c:510
name_and_sort_items
void name_and_sort_items(struct universal *targets, int num_targets, struct item *items, bool show_cost, struct city *pcity)
Definition climisc.c:633
fc_cmp
static int fc_cmp(const void *p1, const void *p2)
Definition climisc.c:609
client_cooling_sprite
struct sprite * client_cooling_sprite(void)
Definition climisc.c:388
client_research_sprite
struct sprite * client_research_sprite(void)
Definition climisc.c:348
num_present_units_in_city
int num_present_units_in_city(struct city *pcity)
Definition climisc.c:933
cid_encode
cid cid_encode(struct universal target)
Definition climisc.c:475
client_remove_unit
void client_remove_unit(struct unit *punit)
Definition climisc.c:72
city_building_present
bool city_building_present(const struct city *pcity, const struct universal *target)
Definition climisc.c:575
client_current_nation_set
struct nation_set * client_current_nation_set(void)
Definition climisc.c:1474
num_supported_units_in_city
int num_supported_units_in_city(struct city *pcity)
Definition climisc.c:915
collect_already_built_targets
int collect_already_built_targets(struct universal *targets, struct city *pcity)
Definition climisc.c:895
get_nearest_city
struct city * get_nearest_city(const struct unit *punit, int *sq_dist)
Definition climisc.c:1101
cid_decode
struct universal cid_decode(cid id)
Definition climisc.c:518
unit_focus_set_status
void unit_focus_set_status(struct player *pplayer)
Definition climisc.c:1345
handle_event
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
center_on_something
void center_on_something(void)
Definition climisc.c:424
cid_encode_unit
cid cid_encode_unit(const struct unit_type *punittype)
Definition climisc.c:485
client_diplomacy_clause_string
void client_diplomacy_clause_string(char *buf, int bufsiz, struct Clause *pclause)
Definition climisc.c:241
get_vision_status
const char * get_vision_status(const struct player *me, const struct player *them)
Definition climisc.c:222
client_government_sprite
struct sprite * client_government_sprite(void)
Definition climisc.c:406
catastrophe_scaled
static void catastrophe_scaled(int *chance, int *rate, int max, int current, int accum, int level)
Definition climisc.c:308
city_unit_present
bool city_unit_present(const struct city *pcity, const struct universal *target)
Definition climisc.c:556
collect_production_targets
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
climisc.h
MAX_NUM_PRODUCTION_TARGETS
#define MAX_NUM_PRODUCTION_TARGETS
Definition climisc.h:87
cid
int cid
Definition climisc.h:31
TestCityFunc
bool(* TestCityFunc)(const struct city *, const struct universal *)
Definition climisc.h:85
unit_bg_color_type
unit_bg_color_type
Definition climisc.h:125
UNIT_BG_AMPHIBIOUS
@ UNIT_BG_AMPHIBIOUS
Definition climisc.h:128
UNIT_BG_SEA
@ UNIT_BG_SEA
Definition climisc.h:127
UNIT_BG_FLYING
@ UNIT_BG_FLYING
Definition climisc.h:129
UNIT_BG_LAND
@ UNIT_BG_LAND
Definition climisc.h:126
UNIT_BG_HP_LOSS
@ UNIT_BG_HP_LOSS
Definition climisc.h:125
connection_do_buffer
void connection_do_buffer(struct connection *pc)
Definition connection.c:323
connection_do_unbuffer
void connection_do_unbuffer(struct connection *pc)
Definition connection.c:335
get_focus_unit_on_tile
struct unit * get_focus_unit_on_tile(const struct tile *ptile)
Definition control.c:392
get_units_in_focus
struct unit_list * get_units_in_focus(void)
Definition control.c:177
unit_focus_advance
void unit_focus_advance(void)
Definition control.c:671
can_unit_do_connect
bool can_unit_do_connect(struct unit *punit, enum unit_activity activity, struct extra_type *tgt)
Definition control.c:1384
update_unit_pix_label
void update_unit_pix_label(struct unit_list *punitlist)
Definition control.c:966
head_of_units_in_focus
struct unit * head_of_units_in_focus(void)
Definition control.c:406
get_num_units_in_focus
int get_num_units_in_focus(void)
Definition control.c:185
control_unit_killed
void control_unit_killed(struct unit *punit)
Definition control.c:226
control.h
dialogs_g.h
punit
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:73
cost
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
diptreaty.h
id
int int id
Definition editgui_g.h:28
event
enum event_type event
Definition events.c:81
fcintl.h
Q_
#define Q_(String)
Definition fcintl.h:70
PL_
#define PL_(String1, String2, n)
Definition fcintl.h:71
_
#define _(String)
Definition fcintl.h:67
featured_text_apply_tag
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,...)
Definition featured_text.c:993
text_tag_link_type
enum text_link_type text_tag_link_type(const struct text_tag *ptag)
Definition featured_text.c:741
featured_text_to_plain_text
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)
Definition featured_text.c:864
ftc_client
const struct ft_color ftc_client
Definition featured_text.c:78
city_link
const char * city_link(const struct city *pcity)
Definition featured_text.c:1072
text_tag_link_id
int text_tag_link_id(const struct text_tag *ptag)
Definition featured_text.c:756
text_tag_new
struct text_tag * text_tag_new(enum text_tag_type tag_type, ft_offset_t start_offset, ft_offset_t stop_offset,...)
Definition featured_text.c:638
featured_text.h
text_tag_list_iterate_end
#define text_tag_list_iterate_end
Definition featured_text.h:116
text_tag_list_iterate
#define text_tag_list_iterate(tags, ptag)
Definition featured_text.h:114
FT_OFFSET_UNSET
#define FT_OFFSET_UNSET
Definition featured_text.h:104
ft_color_requested
static bool ft_color_requested(const struct ft_color color)
Definition featured_text.h:160
text_tag_type
text_tag_type
Definition featured_text.h:120
TTT_LINK
@ TTT_LINK
Definition featured_text.h:126
TTT_COLOR
@ TTT_COLOR
Definition featured_text.h:125
game
struct civ_game game
Definition game.c:57
wld
struct world wld
Definition game.c:58
game_remove_unit
void game_remove_unit(struct world *gworld, struct unit *punit)
Definition game.c:119
game_remove_city
void game_remove_city(struct world *gworld, struct city *pcity)
Definition game.c:173
game_city_by_number
struct city * game_city_by_number(int id)
Definition game.c:102
game.h
government_count
Government_type_id government_count(void)
Definition government.c:70
government_of_player
struct government * government_of_player(const struct player *pplayer)
Definition government.c:113
government.h
popdown_city_dialog
void popdown_city_dialog(struct city *pcity)
Definition citydlg.c:587
popup_notify_goto_dialog
void popup_notify_goto_dialog(const char *headline, const char *lines, const struct text_tag_list *tags, struct tile *ptile)
Definition dialogs.c:194
update_unit_info_label
void update_unit_info_label(struct unit_list *punits)
Definition mapview.c:258
gui_main_g.h
improvement_by_number
struct impr_type * improvement_by_number(const Impr_type_id id)
Definition improvement.c:192
can_player_build_improvement_later
bool can_player_build_improvement_later(const struct player *p, const struct impr_type *pimprove)
Definition improvement.c:734
can_player_build_improvement_now
bool can_player_build_improvement_now(const struct player *p, struct impr_type *pimprove)
Definition improvement.c:717
improvement_number
Impr_type_id improvement_number(const struct impr_type *pimprove)
Definition improvement.c:182
impr_build_shield_cost
int impr_build_shield_cost(const struct city *pcity, const struct impr_type *pimprove)
Definition improvement.c:292
is_wonder
bool is_wonder(const struct impr_type *pimprove)
Definition improvement.c:341
is_great_wonder
bool is_great_wonder(const struct impr_type *pimprove)
Definition improvement.c:767
improvement_has_flag
bool improvement_has_flag(const struct impr_type *pimprove, enum impr_flag_id flag)
Definition improvement.c:381
improvement_name_translation
const char * improvement_name_translation(const struct impr_type *pimprove)
Definition improvement.c:241
improvement_count
Impr_type_id improvement_count(void)
Definition improvement.c:162
is_small_wonder
bool is_small_wonder(const struct impr_type *pimprove)
Definition improvement.c:775
improvement_iterate_end
#define improvement_iterate_end
Definition improvement.h:211
improvement_iterate
#define improvement_iterate(_p)
Definition improvement.h:205
B_LAST
#define B_LAST
Definition improvement.h:42
name
const char * name
Definition inputfile.c:127
log.h
fc_assert_ret
#define fc_assert_ret(condition)
Definition log.h:191
log_verbose
#define log_verbose(message,...)
Definition log.h:109
fc_assert
#define fc_assert(condition)
Definition log.h:176
fc_assert_ret_val
#define fc_assert_ret_val(condition, val)
Definition log.h:194
log_debug
#define log_debug(message,...)
Definition log.h:115
sq_map_distance
int sq_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:639
map_num_tiles
int map_num_tiles(void)
Definition map.c:1012
native_pos_to_tile
struct tile * native_pos_to_tile(const struct civ_map *nmap, int nat_x, int nat_y)
Definition map.c:441
map.h
iterate_outward
#define iterate_outward(nmap, start_tile, max_dist, itr_tile)
Definition map.h:361
iterate_outward_end
#define iterate_outward_end
Definition map.h:365
MAP_INDEX_SIZE
#define MAP_INDEX_SIZE
Definition map.h:131
is_city_hilited
bool is_city_hilited(struct city *pcity)
Definition mapctrl_common.c:302
mapctrl_common.h
mapimg_isvalid
struct mapdef * mapimg_isvalid(int id)
Definition mapimg.c:1120
mapimg_define
bool mapimg_define(const char *maparg, bool check)
Definition mapimg.c:768
mapimg_delete
bool mapimg_delete(int id)
Definition mapimg.c:1203
mapimg_count
int mapimg_count(void)
Definition mapimg.c:572
mapimg_create
bool mapimg_create(struct mapdef *pmapdef, bool force, const char *savename, const char *path)
Definition mapimg.c:1331
mapimg.h
MAX_LEN_MAPDEF
#define MAX_LEN_MAPDEF
Definition mapimg.h:65
refresh_city_mapcanvas
void refresh_city_mapcanvas(struct city *pcity, struct tile *ptile, bool full_refresh, bool write_to_screen)
Definition mapview_common.c:531
center_tile_mapcanvas
void center_tile_mapcanvas(const struct tile *ptile)
Definition mapview_common.c:1222
link_mark_add_new
void link_mark_add_new(enum text_link_type type, int id)
Definition mapview_common.c:3976
can_slide
bool can_slide
Definition mapview_common.c:75
refresh_unit_mapcanvas
void refresh_unit_mapcanvas(struct unit *punit, struct tile *ptile, bool full_refresh, bool write_to_screen)
Definition mapview_common.c:510
mapview_common.h
mapview_g.h
fc_malloc
#define fc_malloc(sz)
Definition mem.h:34
meswin_add
void meswin_add(const char *message, const struct text_tag_list *tags, struct tile *ptile, enum event_type event, int turn, int phase)
Definition messagewin_common.c:100
messagewin_common.h
nation_rule_name
const char * nation_rule_name(const struct nation_type *pnation)
Definition nation.c:137
nation_of_unit
struct nation_type * nation_of_unit(const struct unit *punit)
Definition nation.c:462
nation_of_city
struct nation_type * nation_of_city(const struct city *pcity)
Definition nation.c:453
nation_is_in_set
bool nation_is_in_set(const struct nation_type *pnation, const struct nation_set *pset)
Definition nation.c:836
nation_set_by_setting_value
struct nation_set * nation_set_by_setting_value(const char *setting)
Definition nation.c:858
nation_plural_for_player
const char * nation_plural_for_player(const struct player *pplayer)
Definition nation.c:177
server_optset
const struct option_set * server_optset
Definition options.c:4009
option_str_get
const char * option_str_get(const struct option *poption)
Definition options.c:868
option_type
enum option_type option_type(const struct option *poption)
Definition options.c:633
messages_where
int messages_where[E_COUNT]
Definition options.c:5028
gui_options
struct client_options gui_options
Definition options.c:71
optset_option_by_name
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:406
options.h
MW_POPUP
#define MW_POPUP
Definition options.h:556
MW_OUTPUT
#define MW_OUTPUT
Definition options.h:554
MW_MESSAGES
#define MW_MESSAGES
Definition options.h:555
packets.h
MAX_LEN_MSG
#define MAX_LEN_MSG
Definition packets.h:43
dsend_packet_player_rates
int dsend_packet_player_rates(struct connection *pc, int tax, int luxury, int science)
Definition packets_gen.c:35401
play_sound_for_event
void play_sound_for_event(enum event_type type)
Definition packhand.c:1612
cities
struct city_list * cities
Definition packhand.c:117
packhand.h
is_settable_ai_level
bool is_settable_ai_level(enum ai_level level)
Definition player.c:1883
player_name
const char * player_name(const struct player *pplayer)
Definition player.c:886
player_primary_capital
struct city * player_primary_capital(const struct player *pplayer)
Definition player.c:1313
player_index
int player_index(const struct player *pplayer)
Definition player.c:820
player_diplstate_get
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Definition player.c:317
can_player_see_units_in_city
bool can_player_see_units_in_city(const struct player *pplayer, const struct city *pcity)
Definition player.c:1113
can_player_see_city_internals
bool can_player_see_city_internals(const struct player *pplayer, const struct city *pcity)
Definition player.c:1129
player_has_embassy
bool player_has_embassy(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:202
gives_shared_vision
bool gives_shared_vision(const struct player *me, const struct player *them)
Definition player.c:1461
players_iterate_end
#define players_iterate_end
Definition player.h:535
players_iterate
#define players_iterate(_pplayer)
Definition player.h:530
is_ai
#define is_ai(plr)
Definition player.h:234
is_human
#define is_human(plr)
Definition player.h:233
repodlgs_common.h
are_universals_equal
bool are_universals_equal(const struct universal *psource1, const struct universal *psource2)
Definition requirements.c:5278
research_get
struct research * research_get(const struct player *pplayer)
Definition research.c:126
research.h
level
struct setting_list * level[OLEVELS_NUM]
Definition settings.c:183
CLIP
#define CLIP(lower, current, upper)
Definition shared.h:57
DIVIDE
#define DIVIDE(n, d)
Definition shared.h:78
ARRAY_SIZE
#define ARRAY_SIZE(x)
Definition shared.h:85
BOOL_VAL
#define BOOL_VAL(x)
Definition shared.h:70
MAX
#define MAX(x, y)
Definition shared.h:54
spaceship.h
Clause
Definition diptreaty.h:70
Clause::type
enum clause_type type
Definition diptreaty.h:71
Clause::from
struct player * from
Definition diptreaty.h:72
Clause::value
int value
Definition diptreaty.h:73
act_prob
Definition fc_types.h:1092
city
Definition city.h:309
city::id
int id
Definition city.h:315
city::info_units_present
struct unit_list * info_units_present
Definition city.h:457
city::info_units_supported
struct unit_list * info_units_supported
Definition city.h:456
city::occupied
bool occupied
Definition city.h:443
city::production
struct universal production
Definition city.h:382
city::buy_cost
int buy_cost
Definition city.h:449
city::tile
struct tile * tile
Definition city.h:311
city::units_supported
struct unit_list * units_supported
Definition city.h:391
city::client
struct city::@17::@20 client
civ_game::info
struct packet_game_info info
Definition game.h:89
civ_map::xsize
int xsize
Definition map_types.h:77
civ_map::ysize
int ysize
Definition map_types.h:77
civclient::conn
struct connection conn
Definition client_main.h:96
client_options::mapimg_layer
bool mapimg_layer[MAPIMG_LAYER_COUNT]
Definition options.h:219
client_options::highlight_our_names
struct ft_color highlight_our_names
Definition options.h:169
client_options::mapimg_zoom
int mapimg_zoom
Definition options.h:218
client_options::mapimg_format
char mapimg_format[64]
Definition options.h:217
client_options::mapimg_filename
char mapimg_filename[512]
Definition options.h:220
color
Definition colors.h:20
connection
Definition connection.h:141
connection::playing
struct player * playing
Definition connection.h:156
connection::username
char username[MAX_LEN_NAME]
Definition connection.h:169
connection::id
int id
Definition connection.h:142
dbv::bits
int bits
Definition bitvector.h:33
dbv::vec
unsigned char * vec
Definition bitvector.h:34
extra_type
Definition extras.h:85
ft_color
Definition featured_text.h:141
government
Definition government.h:52
impr_type
Definition improvement.h:68
impr_type::build_cost
int build_cost
Definition improvement.h:77
item
Definition climisc.h:80
item::item
struct universal item
Definition climisc.h:81
item::descr
char descr[MAX_LEN_NAME+40]
Definition climisc.h:82
mapdef
Definition mapimg.c:320
message
Definition messagewin_common.h:29
nation_set
Definition nation.c:40
nation_type
Definition nation.h:97
option
Definition options.c:454
packet_game_info::coolinglevel
int coolinglevel
Definition packets_gen.h:149
packet_game_info::shieldbox
int shieldbox
Definition packets_gen.h:221
packet_game_info::globalwarming
int globalwarming
Definition packets_gen.h:165
packet_game_info::nuclearwinter
int nuclearwinter
Definition packets_gen.h:205
packet_game_info::cooling
int cooling
Definition packets_gen.h:148
packet_game_info::warminglevel
int warminglevel
Definition packets_gen.h:242
packet_game_info::skill_level
enum ai_level skill_level
Definition packets_gen.h:222
packet_game_info::heating
int heating
Definition packets_gen.h:178
packet_game_info::turn
int turn
Definition packets_gen.h:241
packet_game_info::phase
int phase
Definition packets_gen.h:206
player_economic::luxury
int luxury
Definition player.h:73
player_economic::science
int science
Definition player.h:72
player_economic::tax
int tax
Definition player.h:71
player_economic::gold
int gold
Definition player.h:70
player
Definition player.h:249
player::cities
struct city_list * cities
Definition player.h:281
player::tile_vision
struct dbv tile_vision[V_COUNT]
Definition player.h:359
player::client
struct player::@69::@72 client
player::units
struct unit_list * units
Definition player.h:282
player::is_alive
bool is_alive
Definition player.h:268
player::economic
struct player_economic economic
Definition player.h:284
research
Definition research.h:39
research::researching
Tech_type_id researching
Definition research.h:52
research::client
struct research::@75::@77 client
research::researching_cost
int researching_cost
Definition research.h:98
research::bulbs_researched
int bulbs_researched
Definition research.h:53
sprite
Definition sprite.h:22
test_func
Definition mapgen.c:679
text_tag
Definition featured_text.c:49
tile
Definition tile.h:49
tile::units
struct unit_list * units
Definition tile.h:57
tileset
Definition tilespec.c:459
unit_class
Definition unittype.h:136
unit_class::hp_loss_pct
int hp_loss_pct
Definition unittype.h:142
unit_class::move_type
enum unit_move_type move_type
Definition unittype.h:140
unit_type
Definition unittype.h:481
unit
Definition unit.h:138
unit::id
int id
Definition unit.h:145
unit::client
struct unit::@80::@82 client
unit::act_prob_cache
struct act_prob * act_prob_cache
Definition unit.h:225
unit::homecity
int homecity
Definition unit.h:146
unit::focus_status
enum unit_focus_status focus_status
Definition unit.h:211
universal
Definition fc_types.h:756
universal::kind
enum universals_n kind
Definition fc_types.h:758
universal::value
universals_u value
Definition fc_types.h:757
world::map
struct civ_map map
Definition world_object.h:38
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
fc_strlcpy
size_t fc_strlcpy(char *dest, const char *src, size_t n)
Definition support.c:787
fc_strcasecmp
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:189
cat_snprintf
int cat_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:995
fc_vsnprintf
int fc_vsnprintf(char *str, size_t n, const char *format, va_list ap)
Definition support.c:896
fc_strncasecmp
int fc_strncasecmp(const char *str0, const char *str1, size_t n)
Definition support.c:238
support.h
sz_strlcpy
#define sz_strlcpy(dest, src)
Definition support.h:161
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
advance_by_number
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:107
advance_name_translation
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:290
A_UNSET
#define A_UNSET
Definition tech.h:48
tile_city
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
TILE_UNKNOWN
@ TILE_UNKNOWN
Definition tile.h:35
TILE_XY
#define TILE_XY(ptile)
Definition tile.h:42
get_government_sprite
struct sprite * get_government_sprite(const struct tileset *t, const struct government *gov)
Definition tilespec.c:6508
get_indicator_sprite
struct sprite * get_indicator_sprite(const struct tileset *t, enum indicator_type indicator, int idx)
Definition tilespec.c:6698
get_citizen_sprite
struct sprite * get_citizen_sprite(const struct tileset *t, enum citizen_category type, int citizen_index, const struct city *pcity)
Definition tilespec.c:6441
tilespec.h
INDICATOR_COOLING
@ INDICATOR_COOLING
Definition tilespec.h:305
INDICATOR_WARMING
@ INDICATOR_WARMING
Definition tilespec.h:304
INDICATOR_BULB
@ INDICATOR_BULB
Definition tilespec.h:303
NUM_TILES_PROGRESS
#define NUM_TILES_PROGRESS
Definition tilespec.h:194
universals_u::utype
const struct unit_type * utype
Definition fc_types.h:604
universals_u::building
const struct impr_type * building
Definition fc_types.h:598
get_transporter_occupancy
int get_transporter_occupancy(const struct unit *ptrans)
Definition unit.c:1769
unit_transport_unload
bool unit_transport_unload(struct unit *pcargo)
Definition unit.c:2376
unit_transport_cargo
struct unit_list * unit_transport_cargo(const struct unit *ptrans)
Definition unit.c:2437
unit_tile
#define unit_tile(_pu)
Definition unit.h:388
FOCUS_AVAIL
@ FOCUS_AVAIL
Definition unit.h:53
unit_owner
#define unit_owner(_pu)
Definition unit.h:387
unitlist.h
unit_list_iterate
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
unit_list_iterate_end
#define unit_list_iterate_end
Definition unitlist.h:33
unit_type_get
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
unit_rule_name
const char * unit_rule_name(const struct unit *punit)
Definition unittype.c:1639
utype_count
Unit_type_id utype_count(void)
Definition unittype.c:80
utype_by_number
struct unit_type * utype_by_number(const Unit_type_id id)
Definition unittype.c:112
utype_number
Unit_type_id utype_number(const struct unit_type *punittype)
Definition unittype.c:100
can_player_build_unit_later
bool can_player_build_unit_later(const struct player *p, const struct unit_type *punittype)
Definition unittype.c:2150
utype_build_shield_cost
int utype_build_shield_cost(const struct city *pcity, const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1490
can_player_build_unit_now
bool can_player_build_unit_now(const struct player *p, const struct unit_type *punittype)
Definition unittype.c:2131
utype_name_translation
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1612
utype_values_translation
const char * utype_values_translation(const struct unit_type *punittype)
Definition unittype.c:1669
uclass_has_flag
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
Definition unittype.h:753
utype_class
#define utype_class(_t_)
Definition unittype.h:736
utype_has_flag
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:604
unit_type_iterate
#define unit_type_iterate(_p)
Definition unittype.h:838
unit_type_iterate_end
#define unit_type_iterate_end
Definition unittype.h:845
vision_layer_iterate
#define vision_layer_iterate(v)
Definition vision.h:77
vision_layer_iterate_end
#define vision_layer_iterate_end
Definition vision.h:80