Freeciv-3.3
Loading...
Searching...
No Matches
text.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2002 - The Freeciv Project
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#include <stdarg.h>
19#include <string.h>
20#include <math.h> /* ceil */
21
22/* utility */
23#include "astring.h"
24#include "bitvector.h"
25#include "fcintl.h"
26#include "log.h"
27#include "support.h"
28
29/* common */
30#include "calendar.h"
31#include "citizens.h"
32#include "clientutils.h"
33#include "combat.h"
34#include "culture.h"
35#include "fc_types.h" /* LINE_BREAK */
36#include "game.h"
37#include "government.h"
38#include "map.h"
39#include "nation.h"
40#include "research.h"
41#include "traderoutes.h"
42#include "unitlist.h"
43
44/* client */
45#include "client_main.h"
46#include "climap.h"
47#include "climisc.h"
48#include "control.h"
49#include "goto.h"
50#include "helpdata.h"
51
52#include "text.h"
53
54
55static int get_bulbs_per_turn(int *pours, bool *pteam, int *ptheirs);
56static const char *format_duration(int duration);
57
58/************************************************************************/
63const char *get_tile_output_text(const struct tile *ptile)
64{
65 static struct astring str = ASTRING_INIT;
66 int i;
67 char output_text[O_LAST][16];
68
69 for (i = 0; i < O_LAST; i++) {
70 int before_penalty = 0;
71 int x = city_tile_output(NULL, ptile, FALSE, i);
72
73 if (NULL != client.conn.playing) {
77 }
78
79 if (before_penalty > 0 && x > before_penalty) {
80 fc_snprintf(output_text[i], sizeof(output_text[i]), "%d(-1)", x);
81 } else {
82 fc_snprintf(output_text[i], sizeof(output_text[i]), "%d", x);
83 }
84 }
85
86 astr_set(&str, "%s/%s/%s", output_text[O_FOOD],
88
89 return astr_str(&str);
90}
91
92/************************************************************************/
96static inline void get_full_username(char *buf, int buflen,
97 const struct player *pplayer)
98{
99 if (!buf || buflen < 1) {
100 return;
101 }
102
103 if (!pplayer) {
104 buf[0] = '\0';
105 return;
106 }
107
108 if (is_ai(pplayer)) {
109 /* TRANS: "AI <player name>" */
110 fc_snprintf(buf, buflen, _("AI %s"), pplayer->name);
111 } else {
112 fc_strlcpy(buf, pplayer->username, buflen);
113 }
114}
115
116/************************************************************************/
120static inline void get_full_nation(char *buf, int buflen,
121 const struct player *pplayer)
122{
123 if (!buf || buflen < 1) {
124 return;
125 }
126
127 if (!pplayer) {
128 buf[0] = '\0';
129 return;
130 }
131
132 if (pplayer->team) {
133 /* TRANS: "<nation adjective>, team <team name>" */
134 fc_snprintf(buf, buflen, _("%s, team %s"),
136 team_name_translation(pplayer->team));
137 } else {
139 }
140}
141
142/************************************************************************/
147const char *popup_info_text(struct tile *ptile)
148{
149 const char *activity_text;
150 struct city *pcity = tile_city(ptile);
151 struct unit *punit = find_visible_unit(ptile);
153 {"" /* unused, DS_ARMISTICE */, Q_("?nation:Hostile"),
154 "" /* unused, DS_CEASEFIRE */,
155 Q_("?nation:Peaceful"), Q_("?nation:Friendly"),
156 Q_("?nation:Mysterious"), Q_("?nation:Friendly(team)")};
157 const char *diplo_city_adjectives[DS_LAST] =
158 {"" /* unused, DS_ARMISTICE */, Q_("?city:Hostile"),
159 "" /* unused, DS_CEASEFIRE */,
160 Q_("?city:Peaceful"), Q_("?city:Friendly"), Q_("?city:Mysterious"),
161 Q_("?city:Friendly(team)")};
162 static struct astring str = ASTRING_INIT;
163 char username[MAX_LEN_NAME + 32];
164 char nation[2 * MAX_LEN_NAME + 32];
165 int tile_x, tile_y, nat_x, nat_y;
166 bool first;
167 struct player *plr = client_player();
168 bool flaggy_unit = (punit != nullptr
169 && !is_flagless_to_player(punit, plr));
170 Continent_id cont = tile_continent(ptile);
171
172 astr_clear(&str);
174 astr_add_line(&str, _("Location: (%d, %d) [%d]"),
175 tile_x, tile_y, cont);
177 astr_add_line(&str, _("Native coordinates: (%d, %d)"),
178 nat_x, nat_y);
179
180 if (cont > 0) {
181 int size = get_continent_size(cont);
183
184 if (is_whole_continent_known(cont)) {
185 astr_add_line(&str, _("Continent size: %d"), size);
186 if (surrounder < 0) {
187 astr_add_line(&str, _("Surrounded by ocean %d"), -surrounder);
188 }
189 } else {
190 astr_add_line(&str, _("Continent size: at least %d"), size);
191 if (surrounder < 0) {
192 astr_add_line(&str, _("Maybe surrounded by ocean %d"), -surrounder);
193 }
194 }
195 } else if (cont < 0) {
196 int size = get_ocean_size(-cont);
198
199 if (is_whole_ocean_known(-cont)) {
200 astr_add_line(&str, _("Ocean size: %d"), size);
201 if (surrounder > 0) {
202 astr_add_line(&str, _("Surrounded by continent %d"), surrounder);
203 }
204 } else {
205 astr_add_line(&str, _("Ocean size: at least %d"), size);
206 if (surrounder > 0) {
207 astr_add_line(&str, _("Maybe surrounded by continent %d"),
208 surrounder);
209 }
210 }
211 }
212 astr_add_line(&str, _("Latitude: %d"),
213 map_signed_latitude(ptile));
214
215 if (client_tile_get_known(ptile) == TILE_UNKNOWN) {
216 astr_add(&str, _("Unknown"));
217 return astr_str(&str);
218 }
219 astr_add_line(&str, _("Terrain: %s"), tile_get_info_text(ptile, TRUE, 0));
220 astr_add_line(&str, _("Food/Prod/Trade: %s"),
221 get_tile_output_text(ptile));
222 first = TRUE;
223 extra_type_iterate(pextra) {
224 if (pextra->category == ECAT_BONUS && tile_has_visible_extra(ptile, pextra)) {
225 if (!first) {
226 astr_add(&str, ",%s", extra_name_translation(pextra));
227 } else {
229 first = FALSE;
230 }
231 }
233
235 struct player *owner = tile_owner(ptile);
236
239
240 if (plr != nullptr && owner == plr) {
241 astr_add_line(&str, _("Our territory"));
242 } else if (owner != nullptr && plr == nullptr) {
243 /* TRANS: "Territory of <username> (<nation + team>)" */
244 astr_add_line(&str, _("Territory of %s (%s)"), username, nation);
245 } else if (owner != nullptr) {
247
248 if (ds->type == DS_CEASEFIRE) {
249 int turns = ds->turns_left;
250
252 /* TRANS: "Territory of <username> (<nation + team>)
253 * (<number> turn cease-fire)" */
254 PL_("Territory of %s (%s) (%d turn cease-fire)",
255 "Territory of %s (%s) (%d turn cease-fire)",
256 turns),
257 username, nation, turns);
258 } else if (ds->type == DS_ARMISTICE) {
259 int turns = ds->turns_left;
260
262 /* TRANS: "Territory of <username> (<nation + team>)
263 * (<number> turn armistice)" */
264 PL_("Territory of %s (%s) (%d turn armistice)",
265 "Territory of %s (%s) (%d turn armistice)",
266 turns),
267 username, nation, turns);
268 } else {
269 int type = ds->type;
270
271 /* TRANS: "Territory of <username>
272 * (<nation + team> | <diplomatic state>)" */
273 astr_add_line(&str, _("Territory of %s (%s | %s)"),
274 username, nation,
276 }
277 } else {
278 astr_add_line(&str, _("Unclaimed territory"));
279 }
280 }
281
282 if (pcity != nullptr) {
283 /* Look at city owner, not tile owner (the two should be the same, if
284 * borders are in use). */
285 struct player *owner = city_owner(pcity);
286 const char *improvements[improvement_count()];
287 int has_improvements = 0;
288
291
292 if (plr == nullptr || owner == plr) {
293 /* TRANS: "City: <city name> | <username> (<nation + team>)" */
294 astr_add_line(&str, _("City: %s | %s (%s)"),
296 } else {
298
299 if (ds->type == DS_CEASEFIRE) {
300 int turns = ds->turns_left;
301
302 /* TRANS: "City: <city name> | <username>
303 * (<nation + team>, <number> turn cease-fire)" */
304 astr_add_line(&str, PL_("City: %s | %s (%s, %d turn cease-fire)",
305 "City: %s | %s (%s, %d turn cease-fire)",
306 turns),
307 city_name_get(pcity), username, nation, turns);
308 } else if (ds->type == DS_ARMISTICE) {
309 int turns = ds->turns_left;
310
311 /* TRANS: "City: <city name> | <username>
312 * (<nation + team>, <number> turn armistice)" */
313 astr_add_line(&str, PL_("City: %s | %s (%s, %d turn armistice)",
314 "City: %s | %s (%s, %d turn armistice)",
315 turns),
316 city_name_get(pcity), username, nation, turns);
317 } else {
318 /* TRANS: "City: <city name> | <username>
319 * (<nation + team>, <diplomatic state>)" */
320 astr_add_line(&str, _("City: %s | %s (%s, %s)"),
321 city_name_get(pcity), username, nation,
323 }
324 }
325
327 int count = unit_list_size(ptile->units);
328
329 if (count > 0) {
330 /* TRANS: preserve leading space */
331 astr_add(&str, PL_(" | Occupied with %d unit.",
332 " | Occupied with %d units.", count), count);
333 } else {
334 /* TRANS: preserve leading space */
335 astr_add(&str, _(" | Not occupied."));
336 }
337 } else {
338 if (city_is_occupied(pcity)) {
339 /* TRANS: preserve leading space */
340 astr_add(&str, _(" | Occupied."));
341 } else {
342 /* TRANS: preserve leading space */
343 astr_add(&str, _(" | Not occupied."));
344 }
345 }
346
347 improvement_iterate(pimprove) {
348 if (is_improvement_visible(pimprove)
349 && city_has_building(pcity, pimprove)) {
350 improvements[has_improvements++] =
352 }
354
355 if (0 < has_improvements) {
356 struct astring list = ASTRING_INIT;
357
359 /* TRANS: %s is a list of "and"-separated improvements. */
360 astr_add_line(&str, _(" with %s."), astr_str(&list));
361 astr_free(&list);
362 }
363
365 struct city *hcity = game_city_by_number(pfocus_unit->homecity);
366
371 hcity)->replace_priority)) {
372 /* TRANS: "Trade from Warsaw: 5" */
373 astr_add_line(&str, _("Trade from %s: %d"),
376 }
378 }
379 {
380 const char *infratext = get_infrastructure_text(ptile->extras);
381
382 if (*infratext != '\0') {
383 astr_add_line(&str, _("Infrastructure: %s"), infratext);
384 }
385 }
387 if (strlen(activity_text) > 0) {
388 astr_add_line(&str, _("Activity: %s"), activity_text);
389 }
390
391 if (punit != nullptr && pcity == nullptr) {
392 struct player *owner = unit_owner(punit);
393 const struct unit_type *ptype = unit_type_get(punit);
394
395 if (flaggy_unit) {
396 get_full_username(username, sizeof(username), owner);
397 get_full_nation(nation, sizeof(nation), owner);
398
399 if (plr == nullptr || owner == plr) {
401
402 /* TRANS: "Unit: <unit type> | <username> (<nation + team>)" */
403 astr_add_line(&str, _("Unit: %s | %s (%s)"),
404 utype_name_translation(ptype), username, nation);
405
408 if (hcity != nullptr) {
409 /* TRANS: on own line immediately following \n, "from <city> |
410 * <nationality> people" */
411 astr_add_line(&str, _("from %s | %s people"), city_name_get(hcity),
413 } else {
414 /* TRANS: Nationality of the people comprising a unit, if
415 * different from owner. */
416 astr_add_line(&str, _("%s people"),
418 }
419 } else if (hcity != nullptr) {
420 /* TRANS: on own line immediately following \n, ... <city> */
421 astr_add_line(&str, _("from %s"), city_name_get(hcity));
422 }
423 } else if (owner != nullptr) {
425
426 if (ds->type == DS_CEASEFIRE) {
427 int turns = ds->turns_left;
428
429 /* TRANS: "Unit: <unit type> | <username> (<nation + team>,
430 * <number> turn cease-fire)" */
431 astr_add_line(&str, PL_("Unit: %s | %s (%s, %d turn cease-fire)",
432 "Unit: %s | %s (%s, %d turn cease-fire)",
433 turns),
435 username, nation, turns);
436 } else if (ds->type == DS_ARMISTICE) {
437 int turns = ds->turns_left;
438
439 /* TRANS: "Unit: <unit type> | <username> (<nation + team>,
440 * <number> turn armistice)" */
441 astr_add_line(&str, PL_("Unit: %s | %s (%s, %d turn armistice)",
442 "Unit: %s | %s (%s, %d turn armistice)",
443 turns),
445 username, nation, turns);
446 } else {
447 /* TRANS: "Unit: <unit type> | <username> (<nation + team>,
448 * <diplomatic state>)" */
449 astr_add_line(&str, _("Unit: %s | %s (%s, %s)"),
450 utype_name_translation(ptype), username, nation,
452 }
453 }
454 } else {
456 }
457
459
460 if (owner == plr || client_is_global_observer()) {
461 /* Show bribe cost for own units. */
462 astr_add_line(&str, _("Probable bribe cost: %d"),
463 unit_bribe_cost(punit, nullptr, nullptr));
464 } else {
465 /* We can only give an (lower) boundary for units of other players. */
466 astr_add_line(&str, _("Estimated bribe cost: > %d"),
467 unit_bribe_cost(punit, plr, nullptr));
468 }
469
470 if ((plr == nullptr || owner == plr)
471 && unit_list_size(ptile->units) >= 2) {
472 /* TRANS: "5 more" units on this tile */
473 astr_add(&str, _(" (%d more)"), unit_list_size(ptile->units) - 1);
474 }
475 }
476
478
479 return astr_str(&str);
480}
481
482#define FAR_CITY_SQUARE_DIST (2*(6*6))
483/************************************************************************/
488const char *get_nearest_city_text(struct city *pcity, int sq_dist)
489{
490 static struct astring str = ASTRING_INIT;
491
492 astr_clear(&str);
493
494 /* Just to be sure */
495 if (!pcity) {
496 sq_dist = -1;
497 }
498
500 /* TRANS: on own line immediately following \n, ... <city> */
501 ? _("far from %s")
502 : (sq_dist > 0)
503 /* TRANS: on own line immediately following \n, ... <city> */
504 ? _("near %s")
505 : (sq_dist == 0)
506 /* TRANS: on own line immediately following \n, ... <city> */
507 ? _("in %s")
508 : "%s",
509 pcity
511 : "");
512
513 return astr_str(&str);
514}
515
516/************************************************************************/
522const char *unit_description(struct unit *punit)
523{
524 int pcity_near_dist;
525 struct player *owner = unit_owner(punit);
526 struct player *nationality = unit_nationality(punit);
527 struct city *pcity
530 const struct unit_type *ptype = unit_type_get(punit);
531 static struct astring str = ASTRING_INIT;
532 const struct player *pplayer = client_player();
533
534 astr_clear(&str);
535
537
538 {
539 const char *veteran_name =
541 if (veteran_name) {
542 astr_add(&str, " (%s)", veteran_name);
543 }
544 }
545
546 if (pplayer == owner) {
548 } else {
549 astr_add(&str, "\n");
550 }
552
553 if (pcity) {
554 /* TRANS: on own line immediately following \n, ... <city> */
555 astr_add_line(&str, _("from %s"), city_name_get(pcity));
556 } else {
557 astr_add(&str, "\n");
558 }
560 if (nationality != NULL && owner != nationality) {
561 /* TRANS: Nationality of the people comprising a unit, if
562 * different from owner. */
563 astr_add_line(&str, _("%s people"),
564 nation_adjective_for_player(nationality));
565 } else {
566 astr_add(&str, "\n");
567 }
568 }
569
570 astr_add_line(&str, "%s",
572#ifdef FREECIV_DEBUG
573 astr_add_line(&str, "Unit ID: %d", punit->id);
574#endif
575
576 return astr_str(&str);
577}
578
579/************************************************************************/
592const char *get_airlift_text(const struct unit_list *punits,
593 const struct city *pdest)
594{
595 static struct astring str = ASTRING_INIT;
596 bool src = (pdest == NULL);
598 best = AL_IMPOSSIBLE;
599 int cur = 0, max = 0;
600
602 enum texttype this = AL_IMPOSSIBLE;
603 enum unit_airlift_result result;
604
605 /* NULL will tell us about the capability of airlifting from source */
607
608 switch (result) {
609 case AR_NO_MOVES:
611 case AR_OCCUPIED:
612 case AR_NOT_IN_CITY:
613 case AR_BAD_SRC_CITY:
614 case AR_BAD_DST_CITY:
615 /* No chance of an airlift. */
616 this = AL_IMPOSSIBLE;
617 break;
618 case AR_OK:
623 /* May or may not be able to airlift now, but there's a chance we could
624 * later */
625 {
626 const struct city *pcity = src ? tile_city(unit_tile(punit)) : pdest;
627
631 /* No restrictions on destination (and we can infer this even for
632 * other players' cities). */
633 this = AL_INFINITE;
636 this = AL_INFINITE;
637 } else if (client_player() == city_owner(pcity)) {
638 /* A city we know about. */
639 int this_cur = pcity->airlift, this_max = city_airlift_max(pcity);
640
641 if (this_max <= 0) {
642 /* City known not to be airlift-capable. */
643 this = AL_IMPOSSIBLE;
644 } else {
645 if (src
647 /* Unlimited capacity. */
648 this = AL_INFINITE;
649 } else if (!src
651 this = AL_INFINITE;
652 } else {
653 /* Limited capacity (possibly zero right now). */
654 this = AL_FINITE;
655 /* Store the numbers. This whole setup assumes that numeric
656 * capacity isn't unit-dependent. */
657 if (best == AL_FINITE) {
658 fc_assert(cur == this_cur && max == this_max);
659 }
660 cur = this_cur;
661 max = this_max;
662 }
663 }
664 } else {
665 /* Unknown capacity. */
666 this = AL_UNKNOWN;
667 }
668 }
669 break;
670 }
671
672 /* Now take the most optimistic view. */
673 best = MAX(best, this);
675
676 switch (best) {
677 case AL_IMPOSSIBLE:
678 return NULL;
679 case AL_UNKNOWN:
680 astr_set(&str, "?");
681 break;
682 case AL_FINITE:
683 astr_set(&str, "%d/%d", cur, max);
684 break;
685 case AL_INFINITE:
686 astr_set(&str, _("Yes"));
687 break;
688 }
689
690 return astr_str(&str);
691}
692
693/************************************************************************/
696static int get_bulbs_per_turn(int *pours, bool *pteam, int *ptheirs)
697{
698 const struct research *presearch;
699 int ours = 0, theirs = 0;
700 bool team = FALSE;
701
702 if (!client_has_player()) {
703 return 0;
704 }
706
707 /* Sum up science */
709 if (pplayer == client_player()) {
710 city_list_iterate(pplayer->cities, pcity) {
711 ours += pcity->surplus[O_SCIENCE];
713 } else {
714 team = TRUE;
715 theirs -= pplayer->client.tech_upkeep;
716 }
718
719 if (team) {
720 theirs += presearch->client.total_bulbs_prod - ours;
721 }
722 ours -= client_player()->client.tech_upkeep;
723
724 if (pours) {
725 *pours = ours;
726 }
727 if (pteam) {
728 *pteam = team;
729 }
730 if (ptheirs) {
731 *ptheirs = theirs;
732 }
733
734 return ours + theirs;
735}
736
737/************************************************************************/
741 int per_turn)
742{
743 if (per_turn > 0) {
744 return ceil((double)(presearch->client.researching_cost
745 - presearch->bulbs_researched) / per_turn);
746 } else {
747 return -1;
748 }
749}
750
751/************************************************************************/
755static int turns_per_advance(const struct research *presearch, int per_turn)
756{
757 if (per_turn > 0) {
758 return MAX(1, ceil((double)presearch->client.researching_cost) / per_turn);
759 } else {
760 return -1;
761 }
762}
763
764/************************************************************************/
768static int turns_to_tech_loss(const struct research *presearch, int per_turn)
769{
770 if (per_turn >= 0 || game.info.techloss_forgiveness == -1) {
771 /* With techloss_forgiveness == -1, we'll never lose a tech, just
772 * get further into debt. */
773 return -1;
774 } else {
775 int bulbs_to_loss = presearch->bulbs_researched
776 + (presearch->client.researching_cost
778
779 return ceil((double)bulbs_to_loss / -per_turn);
780 }
781}
782
783/************************************************************************/
788const char *science_dialog_text(void)
789{
790 bool team;
791 int ours, theirs, perturn, upkeep;
792 static struct astring str = ASTRING_INIT;
794 struct research *research;
795
796 astr_clear(&str);
797
799
801 upkeep = client_player()->client.tech_upkeep;
802
803 if (NULL == client.conn.playing || (ours == 0 && theirs == 0
804 && upkeep == 0)) {
805 return _("Progress: no research");
806 }
807
808 if (A_UNSET == research->researching) {
809 astr_add(&str, _("Progress: no research"));
810 } else {
811 int turns;
812
813 if ((turns = turns_per_advance(research, perturn)) >= 0) {
814 astr_add(&str, PL_("Progress: %d turn/advance",
815 "Progress: %d turns/advance",
816 turns), turns);
817 } else if ((turns = turns_to_tech_loss(research, perturn)) >= 0) {
818 /* FIXME: turns to next loss is not a good predictor of turns to
819 * following loss, due to techloss_restore etc. But it'll do. */
820 astr_add(&str, PL_("Progress: %d turn/advance loss",
821 "Progress: %d turns/advance loss",
822 turns), turns);
823 } else {
824 /* no forward progress -- no research, or tech loss disallowed */
825 if (perturn < 0) {
826 astr_add(&str, _("Progress: decreasing!"));
827 } else {
828 astr_add(&str, _("Progress: none"));
829 }
830 }
831 }
832 astr_set(&ourbuf, PL_("%d bulb/turn", "%d bulbs/turn", ours), ours);
833 if (team) {
834 /* Techpool version */
836 /* TRANS: This is appended to "%d bulb/turn" text */
837 PL_(", %d bulb/turn from team",
838 ", %d bulbs/turn from team", theirs), theirs);
839 } else {
841 }
842 astr_add(&str, " (%s%s)", astr_str(&ourbuf), astr_str(&theirbuf));
845
847 /* perturn is defined as: (bulbs produced) - upkeep */
848 astr_add_line(&str, _("Bulbs produced per turn: %d"), perturn + upkeep);
849 /* TRANS: keep leading space; appended to "Bulbs produced per turn: %d" */
850 astr_add(&str, _(" (needed for technology upkeep: %d)"), upkeep);
851 }
852
853 return astr_str(&str);
854}
855
856/************************************************************************/
868{
870 static struct astring str = ASTRING_INIT;
871
872 if (!research) {
873 return "-";
874 }
875
876 astr_clear(&str);
877 if (research->researching == A_UNSET) {
878 astr_add(&str, _("%d/- (never)"), research->bulbs_researched);
879 if (percent) {
880 *percent = 0.0;
881 }
882 } else {
883 int total = research->client.researching_cost;
884 int done = research->bulbs_researched;
886 int turns;
887
888 if ((turns = turns_to_research_done(research, perturn)) >= 0) {
889 astr_add(&str, PL_("%d/%d (%d turn)", "%d/%d (%d turns)", turns),
890 done, total, turns);
891 } else if ((turns = turns_to_tech_loss(research, perturn)) >= 0) {
892 astr_add(&str, PL_("%d/%d (%d turn to loss)",
893 "%d/%d (%d turns to loss)", turns),
894 done, total, turns);
895 } else {
896 /* no forward progress -- no research, or tech loss disallowed */
897 astr_add(&str, _("%d/%d (never)"), done, total);
898 }
899 if (percent) {
900 *percent = (double)done / (double)total;
901 *percent = CLIP(0.0, *percent, 1.0);
902 }
903 }
904
905 return astr_str(&str);
906}
907
908/************************************************************************/
914{
915 const struct research *research = research_get(client_player());
916 int steps = research_goal_unknown_techs(research, goal);
918 int turns;
920 static struct astring str = ASTRING_INIT;
921 struct astring buf1 = ASTRING_INIT,
924
925 if (!research) {
926 return "-";
927 }
928
929 astr_clear(&str);
930
932 || research->researching == goal) {
934 }
935
936 astr_set(&buf1,
937 PL_("%d step", "%d steps", steps), steps);
938 astr_set(&buf2,
939 PL_("%d bulb", "%d bulbs", bulbs_needed), bulbs_needed);
940 if (perturn > 0) {
941 turns = (bulbs_needed + perturn - 1) / perturn;
942 astr_set(&buf3,
943 PL_("%d turn", "%d turns", turns), turns);
944 } else {
945 astr_set(&buf3, _("never"));
946 }
947 astr_add_line(&str, "(%s - %s - %s)",
949 astr_free(&buf1);
950 astr_free(&buf2);
951 astr_free(&buf3);
952
953 return astr_str(&str);
954}
955
956/************************************************************************/
965{
966 static struct astring str = ASTRING_INIT;
967
968 astr_clear(&str);
969
970 if (NULL != client.conn.playing) {
971 astr_add_line(&str, _("Population: %s"),
973 }
974 astr_add_line(&str, _("Year: %s (T%d)"),
976
977 if (NULL != client.conn.playing) {
978 astr_add_line(&str, _("Gold: %d (%+d)"),
981 astr_add_line(&str, _("Tax: %d Lux: %d Sci: %d"),
985 }
987 if (game.info.phase < 0 || game.info.phase >= player_count()) {
988 astr_add_line(&str, _("Moving: Nobody"));
989 } else {
990 astr_add_line(&str, _("Moving: %s"),
992 }
993 } else if (game.info.phase_mode == PMT_TEAMS_ALTERNATE) {
994 if (game.info.phase < 0 || game.info.phase >= team_count()) {
995 astr_add_line(&str, _("Moving: Nobody"));
996 } else {
997 astr_add_line(&str, _("Moving: %s"),
999 }
1000 }
1001
1002 if (moreinfo) {
1003 astr_add_line(&str, _("(Click for more info)"));
1004 }
1005
1006 return astr_str(&str);
1007}
1008
1009/************************************************************************/
1017{
1018 static struct astring str = ASTRING_INIT;
1019
1020 astr_clear(&str);
1021
1022 if (NULL != client.conn.playing) {
1023 astr_add_line(&str, _("%s People"),
1025 }
1026 astr_add_line(&str, _("Year: %s"), calendar_text());
1027 astr_add_line(&str, _("Turn: %d"), game.info.turn);
1028
1029 if (NULL != client.conn.playing) {
1030 const struct research *presearch = research_get(client_player());
1032 int upkeep = client_player()->client.tech_upkeep;
1033
1034 astr_add_line(&str, _("Gold: %d"),
1036 astr_add_line(&str, _("Net Income: %d"),
1038 /* TRANS: Gold, luxury, and science rates are in percentage values. */
1039 astr_add_line(&str, _("Tax rates: Gold:%d%% Luxury:%d%% Science:%d%%"),
1043 astr_add_line(&str, _("Researching %s: %s"),
1045 presearch->researching),
1047 /* perturn is defined as: (bulbs produced) - upkeep */
1049 astr_add_line(&str, _("Bulbs per turn: %d - %d = %d"), perturn + upkeep,
1050 upkeep, perturn);
1051 } else {
1052 fc_assert(upkeep == 0);
1053 astr_add_line(&str, _("Bulbs per turn: %d"), perturn);
1054 }
1055 {
1057
1061 astr_add_line(&str, _("Culture: %d (%+d/turn)"),
1063 }
1064 }
1065
1066 /* See also get_global_warming_tooltip() and get_nuclear_winter_tooltip(). */
1067
1068 if (game.info.global_warming) {
1069 int chance, rate;
1071 astr_add_line(&str, _("Global warming chance: %d%% (%+d%%/turn)"),
1072 chance, rate);
1073 } else {
1074 astr_add_line(&str, _("Global warming deactivated."));
1075 }
1076
1077 if (game.info.nuclear_winter) {
1078 int chance, rate;
1080 astr_add_line(&str, _("Nuclear winter chance: %d%% (%+d%%/turn)"),
1081 chance, rate);
1082 } else {
1083 astr_add_line(&str, _("Nuclear winter deactivated."));
1084 }
1085
1086 if (NULL != client.conn.playing) {
1087 astr_add_line(&str, _("Government: %s"),
1089 }
1090
1091 return astr_str(&str);
1092}
1093
1094/************************************************************************/
1101const char *get_unit_info_label_text1(struct unit_list *punits)
1102{
1103 static struct astring str = ASTRING_INIT;
1104
1105 astr_clear(&str);
1106
1107 if (punits) {
1108 int count = unit_list_size(punits);
1109
1110 if (count == 1) {
1112 } else {
1113 astr_add(&str, PL_("%d unit", "%d units", count), count);
1114 }
1115 }
1116 return astr_str(&str);
1117}
1118
1119/************************************************************************/
1126const char *get_unit_info_label_text2(struct unit_list *punits, int linebreaks)
1127{
1128 static struct astring str = ASTRING_INIT;
1129 int count;
1130
1131 astr_clear(&str);
1132
1133 if (!punits) {
1134 return "";
1135 }
1136
1137 count = unit_list_size(punits);
1138
1139 /* This text should always have the same number of lines if
1140 * 'linebreaks' has no flags at all. Otherwise the GUI widgets may be
1141 * confused and try to resize themselves. If caller asks for
1142 * conditional 'linebreaks', it should take care of these problems
1143 * itself. */
1144
1145 /* Line 1. Goto or activity text. */
1146 if (count > 0 && hover_state != HOVER_NONE) {
1147 int min, max;
1148
1149 if (!goto_get_turns(&min, &max)) {
1150 /* TRANS: Impossible to reach goto target tile */
1151 astr_add_line(&str, "%s", Q_("?goto:Unreachable"));
1152 } else if (min == max) {
1153 astr_add_line(&str, _("Turns to target: %d"), max);
1154 } else {
1155 astr_add_line(&str, _("Turns to target: %d to %d"), min, max);
1156 }
1157 } else if (count == 1) {
1158 struct astring addition = ASTRING_INIT;
1159
1163 } else if (count > 1) {
1164 astr_add_line(&str, PL_("%d unit selected",
1165 "%d units selected",
1166 count),
1167 count);
1168 } else {
1169 astr_add_line(&str, _("No units selected."));
1170 }
1171
1172 /* Lines 2, 3, 4, and possible 5 vary. */
1173 if (count == 1) {
1174 struct unit *punit = unit_list_get(punits, 0);
1175 struct player *owner = unit_owner(punit);
1177 punit->homecity);
1178
1180 linebreaks));
1181 {
1183
1184 if (*infratext != '\0') {
1185 astr_add_line(&str, "%s", infratext);
1186 } else {
1187 astr_add_line(&str, " ");
1188 }
1189 }
1190 if (pcity) {
1192 } else {
1193 astr_add_line(&str, " ");
1194 }
1195
1197 struct player *nationality = unit_nationality(punit);
1198
1199 /* Line 5, nationality text */
1200 if (nationality != NULL && owner != nationality) {
1201 /* TRANS: Nationality of the people comprising a unit, if
1202 * different from owner. */
1203 astr_add_line(&str, _("%s people"),
1204 nation_adjective_for_player(nationality));
1205 } else {
1206 astr_add_line(&str, " ");
1207 }
1208 }
1209
1210 } else if (count > 1) {
1211 int mil = 0, nonmil = 0;
1212 int types_count[U_LAST], i;
1213 struct unit_type *top[3];
1214
1215 memset(types_count, 0, sizeof(types_count));
1218 nonmil++;
1219 } else {
1220 mil++;
1221 }
1224
1225 top[0] = top[1] = top[2] = NULL;
1226 unit_type_iterate(utype) {
1227 if (!top[2]
1228 || types_count[utype_index(top[2])] < types_count[utype_index(utype)]) {
1229 top[2] = utype;
1230
1231 if (!top[1]
1232 || types_count[utype_index(top[1])] < types_count[utype_index(top[2])]) {
1233 top[2] = top[1];
1234 top[1] = utype;
1235
1236 if (!top[0]
1237 || types_count[utype_index(top[0])] < types_count[utype_index(utype)]) {
1238 top[1] = top[0];
1239 top[0] = utype;
1240 }
1241 }
1242 }
1244
1245 for (i = 0; i < 2; i++) {
1246 if (top[i] && types_count[utype_index(top[i])] > 0) {
1247 if (utype_has_flag(top[i], UTYF_CIVILIAN)) {
1248 nonmil -= types_count[utype_index(top[i])];
1249 } else {
1250 mil -= types_count[utype_index(top[i])];
1251 }
1252 astr_add_line(&str, "%d: %s",
1253 types_count[utype_index(top[i])],
1255 } else {
1256 astr_add_line(&str, " ");
1257 }
1258 }
1259
1260 if (top[2] && types_count[utype_index(top[2])] > 0
1261 && types_count[utype_index(top[2])] == nonmil + mil) {
1262 astr_add_line(&str, "%d: %s", types_count[utype_index(top[2])],
1263 utype_name_translation(top[2]));
1264 } else if (nonmil > 0 && mil > 0) {
1265 astr_add_line(&str, _("Others: %d civil; %d military"), nonmil, mil);
1266 } else if (nonmil > 0) {
1267 astr_add_line(&str, _("Others: %d civilian"), nonmil);
1268 } else if (mil > 0) {
1269 astr_add_line(&str, _("Others: %d military"), mil);
1270 } else {
1271 astr_add_line(&str, " ");
1272 }
1273
1275 astr_add_line(&str, " ");
1276 }
1277 } else {
1278 astr_add_line(&str, " ");
1279 astr_add_line(&str, " ");
1280 astr_add_line(&str, " ");
1281
1283 astr_add_line(&str, " ");
1284 }
1285 }
1286
1287 /* Line 5/6. Debug text. */
1288#ifdef FREECIV_DEBUG
1289 if (count == 1) {
1290 astr_add_line(&str, "(Unit ID %d)", unit_list_get(punits, 0)->id);
1291 } else {
1292 astr_add_line(&str, " ");
1293 }
1294#endif /* FREECIV_DEBUG */
1295
1296 return astr_str(&str);
1297}
1298
1299/************************************************************************/
1305 struct unit_list *punits)
1306{
1307 if (unit_list_size(punits) == 0) {
1308 fc_snprintf(buf, bufsz, _("No units to upgrade!"));
1309 return FALSE;
1310 } else if (unit_list_size(punits) == 1) {
1312 } else {
1313 int upgrade_cost = 0;
1314 int num_upgraded = 0;
1316
1319 && UU_OK == unit_upgrade_test(&(wld.map), punit, FALSE)) {
1320 const struct unit_type *from_unittype = unit_type_get(punit);
1325
1326 num_upgraded++;
1327 upgrade_cost += cost;
1329 }
1331 if (num_upgraded == 0) {
1332 fc_snprintf(buf, bufsz, _("None of these units may be upgraded."));
1333 return FALSE;
1334 } else {
1335 /* This may trigger sometimes if you don't have enough money for
1336 * a full upgrade. If you have enough to upgrade at least one, it
1337 * will do it. */
1338 /* Construct prompt in several parts to allow separate pluralisation
1339 * by localizations */
1341
1342 fc_snprintf(tbuf, ARRAY_SIZE(tbuf), PL_("Treasury contains %d gold.",
1343 "Treasury contains %d gold.",
1344 client_player()->economic.gold),
1345 client_player()->economic.gold);
1346 /* TRANS: this whole string is a sentence fragment that is only ever
1347 * used by including it in another string (search comments for this
1348 * string to find it) */
1349 fc_snprintf(ubuf, ARRAY_SIZE(ubuf), PL_("Upgrade %d unit",
1350 "Upgrade %d units",
1351 num_upgraded),
1352 num_upgraded);
1353 /* TRANS: This is complicated. The first %s is a pre-pluralised
1354 * sentence fragment "Upgrade %d unit(s)"; the second is pre-pluralised
1355 * "Treasury contains %d gold." So the whole thing reads
1356 * "Upgrade 13 units for 1000 gold?\nTreasury contains 2000 gold." */
1357 fc_snprintf(buf, bufsz, PL_("%s for %d gold?\n%s",
1358 "%s for %d gold?\n%s", upgrade_cost),
1360 return TRUE;
1361 }
1362 }
1363}
1364
1365/************************************************************************/
1371 struct unit_list *punits)
1372{
1373 if (unit_list_size(punits) == 0) {
1374 fc_snprintf(buf, bufsz, _("No units to disband!"));
1375 return FALSE;
1376 } else if (unit_list_size(punits) == 1) {
1379 fc_snprintf(buf, bufsz, _("%s refuses to disband!"),
1381 return FALSE;
1382 } else {
1383 /* TRANS: %s is a unit type */
1384 fc_snprintf(buf, bufsz, _("Disband %s?"),
1386 return TRUE;
1387 }
1388 } else {
1389 int count = 0;
1390
1393 count++;
1394 }
1396 if (count == 0) {
1397 fc_snprintf(buf, bufsz, _("None of these units may be disbanded."));
1398 return FALSE;
1399 } else {
1400 /* TRANS: %d is never 0 or 1 */
1401 fc_snprintf(buf, bufsz, PL_("Disband %d unit?",
1402 "Disband %d units?", count), count);
1403 return TRUE;
1404 }
1405 }
1406}
1407
1408/************************************************************************/
1414const char *get_bulb_tooltip(void)
1415{
1416 static struct astring str = ASTRING_INIT;
1417
1418 astr_clear(&str);
1419
1420 astr_add_line(&str, _("Shows your progress in "
1421 "researching the current technology."));
1422
1423 if (NULL != client.conn.playing) {
1425
1426 if (research->researching == A_UNSET) {
1427 astr_add_line(&str, _("No research target."));
1428 } else {
1429 int turns;
1432
1433 if ((turns = turns_to_research_done(research, perturn)) >= 0) {
1434 astr_set(&buf1, PL_("%d turn", "%d turns", turns), turns);
1435 } else if ((turns = turns_to_tech_loss(research, perturn)) >= 0) {
1436 astr_set(&buf1, PL_("%d turn to loss", "%d turns to loss", turns),
1437 turns);
1438 } else {
1439 if (perturn < 0) {
1440 astr_set(&buf1, _("Decreasing"));
1441 } else {
1442 astr_set(&buf1, _("No progress"));
1443 }
1444 }
1445
1446 /* TRANS: <perturn> bulbs/turn */
1447 astr_set(&buf2, PL_("%d bulb/turn", "%d bulbs/turn", perturn), perturn);
1448
1449 /* TRANS: <tech>: <amount>/<total bulbs> */
1450 astr_add_line(&str, _("%s: %d/%d (%s, %s)."),
1455 astr_str(&buf1), astr_str(&buf2));
1456
1457 astr_free(&buf1);
1458 astr_free(&buf2);
1459 }
1460 }
1461
1462 return astr_str(&str);
1463}
1464
1465/************************************************************************/
1472{
1473 static struct astring str = ASTRING_INIT;
1474
1475 astr_clear(&str);
1476
1477 if (!game.info.global_warming) {
1478 astr_add_line(&str, _("Global warming deactivated."));
1479 } else {
1480 int chance, rate;
1481
1483 astr_add_line(&str, _("Shows the progress of global warming:"));
1484 astr_add_line(&str, _("Pollution rate: %d%%"), rate);
1485 astr_add_line(&str, _("Chance of catastrophic warming each turn: %d%%"),
1486 chance);
1487 }
1488
1489 return astr_str(&str);
1490}
1491
1492/************************************************************************/
1499{
1500 static struct astring str = ASTRING_INIT;
1501
1502 astr_clear(&str);
1503
1504 if (!game.info.nuclear_winter) {
1505 astr_add_line(&str, _("Nuclear winter deactivated."));
1506 } else {
1507 int chance, rate;
1508
1510 astr_add_line(&str, _("Shows the progress of nuclear winter:"));
1511 astr_add_line(&str, _("Fallout rate: %d%%"), rate);
1512 astr_add_line(&str, _("Chance of catastrophic winter each turn: %d%%"),
1513 chance);
1514 }
1515
1516 return astr_str(&str);
1517}
1518
1519/************************************************************************/
1525const char *get_government_tooltip(void)
1526{
1527 static struct astring str = ASTRING_INIT;
1528
1529 astr_clear(&str);
1530
1531 astr_add_line(&str, _("Shows your current government:"));
1532
1533 if (NULL != client.conn.playing) {
1534 astr_add_line(&str, "%s",
1536 }
1537
1538 return astr_str(&str);
1539}
1540
1541/************************************************************************/
1548{
1549 struct player_spaceship ship;
1550 static struct astring str = ASTRING_INIT;
1551
1552 astr_clear(&str);
1553
1554 if (!pship) {
1555 pship = &ship;
1556 memset(&ship, 0, sizeof(ship));
1557 }
1558
1559 /* TRANS: spaceship text; should have constant width. */
1560 astr_add_line(&str, _("Population: %5d"), pship->population);
1561
1562 /* TRANS: spaceship text; should have constant width. */
1563 astr_add_line(&str, _("Support: %5d %%"),
1564 (int) (pship->support_rate * 100.0));
1565
1566 /* TRANS: spaceship text; should have constant width. */
1567 astr_add_line(&str, _("Energy: %5d %%"),
1568 (int) (pship->energy_rate * 100.0));
1569
1570 /* TRANS: spaceship text; should have constant width. */
1571 astr_add_line(&str, PL_("Mass: %5d ton",
1572 "Mass: %5d tons",
1573 pship->mass), pship->mass);
1574
1575 if (pship->propulsion > 0) {
1576 /* TRANS: spaceship text; should have constant width. */
1577 astr_add_line(&str, _("Travel time: %5.1f years"),
1578 (float) (0.1 * ((int) (pship->travel_time * 10.0))));
1579 } else {
1580 /* TRANS: spaceship text; should have constant width. */
1581 astr_add_line(&str, "%s", _("Travel time: N/A "));
1582 }
1583
1584 /* TRANS: spaceship text; should have constant width. */
1585 astr_add_line(&str, _("Success prob.: %5d %%"),
1586 (int) (pship->success_rate * 100.0));
1587
1588 /* TRANS: spaceship text; should have constant width. */
1589 astr_add_line(&str, _("Year of arrival: %8s"),
1590 (pship->state == SSHIP_LAUNCHED)
1591 ? textyear((int) (pship->launch_year +
1592 (int) pship->travel_time))
1593 : "- ");
1594
1595 return astr_str(&str);
1596}
1597
1598/************************************************************************/
1604const char *get_timeout_label_text(void)
1605{
1606 static struct astring str = ASTRING_INIT;
1607
1608 astr_clear(&str);
1609
1612
1613 if (wt <= 0) {
1614 astr_add(&str, "%s", Q_("?timeout:wait"));
1615 } else {
1616 astr_add(&str, "%s: %s", Q_("?timeout:eta"), format_duration(wt));
1617 }
1618 } else {
1619 if (current_turn_timeout() <= 0) {
1620 astr_add(&str, "%s", Q_("?timeout:off"));
1621 } else {
1623 }
1624 }
1625
1626 return astr_str(&str);
1627}
1628
1629/************************************************************************/
1637static const char *format_duration(int duration)
1638{
1639 static struct astring str = ASTRING_INIT;
1640
1641 astr_clear(&str);
1642
1643 if (duration < 0) {
1644 duration = 0;
1645 }
1646 if (duration < 60) {
1647 astr_add(&str, Q_("?seconds:%02ds"), duration);
1648 } else if (duration < 3600) { /* < 60 minutes */
1649 astr_add(&str, Q_("?mins/secs:%02dm %02ds"), duration / 60, duration % 60);
1650 } else if (duration < 360000) { /* < 100 hours */
1651 astr_add(&str, Q_("?hrs/mns:%02dh %02dm"), duration / 3600, (duration / 60) % 60);
1652 } else if (duration < 8640000) { /* < 100 days */
1653 astr_add(&str, Q_("?dys/hrs:%02dd %02dh"), duration / 86400,
1654 (duration / 3600) % 24);
1655 } else {
1656 astr_add(&str, "%s", Q_("?duration:overflow"));
1657 }
1658
1659 return astr_str(&str);
1660}
1661
1662/************************************************************************/
1668const char *get_ping_time_text(const struct player *pplayer)
1669{
1670 static struct astring str = ASTRING_INIT;
1671
1672 astr_clear(&str);
1673
1675 if (!pconn->observer
1676 /* Certainly not needed, but safer. */
1677 && 0 == strcmp(pconn->username, pplayer->username)) {
1678 if (pconn->ping_time >= 0) {
1679 double ping_time_in_ms = 1000 * pconn->ping_time;
1680
1681 astr_add(&str, _("%6d.%02d ms"), (int) ping_time_in_ms,
1682 ((int) (ping_time_in_ms * 100.0)) % 100);
1683 }
1684 break;
1685 }
1687
1688 return astr_str(&str);
1689}
1690
1691/************************************************************************/
1697const char *get_score_text(const struct player *pplayer)
1698{
1699 static struct astring str = ASTRING_INIT;
1700
1701 astr_clear(&str);
1702
1703 if (pplayer->score.game >= 0) {
1704 astr_add(&str, "%d", pplayer->score.game);
1705 } else {
1706 astr_add(&str, "?");
1707 }
1708
1709 return astr_str(&str);
1710}
1711
1712/************************************************************************/
1719const char *get_report_title(const char *report_name)
1720{
1721 static struct astring str = ASTRING_INIT;
1722 const struct player *pplayer = client_player();
1723
1724 astr_clear(&str);
1725
1726 astr_add_line(&str, "%s", report_name);
1727
1728 if (pplayer != NULL) {
1729 char buf[4 * MAX_LEN_NAME];
1730
1731 /* TRANS: <nation adjective> <government name>.
1732 * E.g. "Polish Republic". */
1733 astr_add_line(&str, Q_("?nationgovernment:%s %s"),
1736
1737 /* TRANS: Just appending 2 strings, using the correct localized
1738 * syntax. */
1739 astr_add_line(&str, _("%s - %s"),
1740 ruler_title_for_player(pplayer, buf, sizeof(buf)),
1741 calendar_text());
1742 } else {
1743 /* TRANS: "Observer - 1985 AD" */
1744 astr_add_line(&str, _("Observer - %s"),
1745 calendar_text());
1746 }
1747
1748 return astr_str(&str);
1749}
1750
1751/**********************************************************************/
1758 const struct act_prob prob,
1759 const struct unit *actor_unit,
1760 const struct city *target_city)
1761{
1762 static struct astring custom = ASTRING_INIT;
1763
1765
1766 if (!action_prob_possible(prob)) {
1767 /* No info since impossible. */
1768 return NULL;
1769 }
1770
1772 || target_city != NULL),
1773 NULL);
1774
1780 TRUE);
1781
1782 if (revenue > 0) {
1784 /* TRANS: Estimated one time bonus and recurring revenue for
1785 * the Establish Trade _Route action. */
1786 _("%d one time bonus + %d trade"),
1787 revenue,
1789 } else {
1791 /* TRANS: Estimated recurring revenue for
1792 * the Establish Trade _Route action. */
1793 _("%d trade"),
1795 }
1801 FALSE);
1802
1803 if (revenue > 0) {
1805 /* TRANS: Estimated one time bonus for the Enter Marketplace
1806 * action. */
1807 _("%d one time bonus"), revenue);
1808 } else {
1809 /* No info to add. */
1810 return NULL;
1811 }
1815 /* Can only give remaining production for domestic and existing
1816 * cities. */
1818
1819 astr_set(&custom, _("%d remaining"), cost - target_city->shield_stock);
1820 } else {
1821 /* No info to add. */
1822 return NULL;
1823 }
1824
1825 return astr_str(&custom);
1826}
1827
1828/**********************************************************************/
1836const char *act_sel_action_tool_tip(const struct action *paction,
1837 const struct act_prob prob)
1838{
1839 return action_prob_explain(prob);
1840}
1841
1842/************************************************************************/
1847const char *text_happiness_buildings(const struct city *pcity)
1848{
1849 struct effect_list *plist = effect_list_new();
1850 static struct astring str = ASTRING_INIT;
1851
1853 if (0 < effect_list_size(plist)) {
1854 struct astring effects = ASTRING_INIT;
1855
1857 astr_set(&str, _("Buildings: %s."), astr_str(&effects));
1859 } else {
1860 astr_set(&str, _("Buildings: None."));
1861 }
1863
1864 /* Add line breaks after 80 characters. */
1865 astr_break_lines(&str, 80);
1866
1867 return astr_str(&str);
1868}
1869
1870/************************************************************************/
1875const char *text_happiness_nationality(const struct city *pcity)
1876{
1877 static struct astring str = ASTRING_INIT;
1878 int enemies = 0;
1879
1880 astr_clear(&str);
1881
1882 astr_add_line(&str, _("Nationality: "));
1883
1886 struct player *owner = city_owner(pcity);
1887
1888 citizens_foreign_iterate(pcity, pslot, nationality) {
1890 enemies += nationality;
1891 }
1893
1894 if (enemies > 0) {
1895 astr_add(&str, PL_("%d enemy nationalist", "%d enemy nationalists", enemies),
1896 enemies);
1897 }
1898 }
1899
1900 if (enemies == 0) {
1901 /* TRANS: No enemy nationalities, as there's no enemies present. */
1902 astr_add(&str, _("None."));
1903 }
1904 } else {
1905 /* TRANS: No nationalities present. */
1906 astr_add(&str, _("Disabled."));
1907 }
1908
1909 return astr_str(&str);
1910}
1911
1912/************************************************************************/
1917const char *text_happiness_wonders(const struct city *pcity)
1918{
1919 struct effect_list *plist = effect_list_new();
1920 static struct astring str = ASTRING_INIT;
1921
1925 if (0 < effect_list_size(plist)) {
1926 struct astring effects = ASTRING_INIT;
1927
1929 astr_set(&str, _("Wonders: %s."), astr_str(&effects));
1931 } else {
1932 astr_set(&str, _("Wonders: None."));
1933 }
1934
1935 /* Add line breaks after 80 characters. */
1936 astr_break_lines(&str, 80);
1938
1939 return astr_str(&str);
1940}
1941
1942/************************************************************************/
1947const char *text_happiness_cities(const struct city *pcity)
1948{
1949 struct player *pplayer = city_owner(pcity);
1950 int cities = city_list_size(pplayer->cities);
1951 int content = get_player_bonus(pplayer, EFT_CITY_UNHAPPY_SIZE);
1954 static struct astring str = ASTRING_INIT;
1955
1956 astr_clear(&str);
1957
1958 if (basis+step <= 0) {
1959 /* Special case where penalty is disabled; see
1960 * player_content_citizens(). */
1962 PL_("Cities: %d total, but no penalty for empire size.",
1963 "Cities: %d total, but no penalty for empire size.",
1964 cities),
1965 cities);
1967 /* TRANS: %d is number of citizens */
1968 PL_("%d content per city.",
1969 "%d content per city.", content),
1970 content);
1971 } else {
1972 /* Can have up to and including 'basis' cities without penalty */
1973 int excess = MAX(cities - basis, 0);
1974 int penalty;
1975 int unhappy, angry;
1976 int last, next;
1977
1978 if (excess > 0) {
1979 if (step > 0) {
1980 penalty = 1 + (excess - 1) / step;
1981 } else {
1982 penalty = 1;
1983 }
1984 } else {
1985 penalty = 0;
1986 }
1987
1988 unhappy = MIN(penalty, content);
1989 angry = game.info.angrycitizen ? MAX(penalty-content, 0) : 0;
1990 if (penalty >= 1) {
1991 /* 'last' is when last actual malcontent appeared, will saturate
1992 * if no angry citizens */
1993 last = basis + (unhappy+angry-1)*step;
1994 if (!game.info.angrycitizen && unhappy == content) {
1995 /* Maxed out unhappy citizens, so no more penalties */
1996 next = 0;
1997 } else {
1998 /* Angry citizens can continue appearing indefinitely */
1999 next = last + step;
2000 }
2001 } else {
2002 last = 0;
2003 next = basis;
2004 }
2005
2007 /* TRANS: sentence fragment, will have text appended */
2008 PL_("Cities: %d total:",
2009 "Cities: %d total:", cities),
2010 cities);
2011 if (excess > 0) {
2012 astr_add(&str,
2013 /* TRANS: appended to "Cities: %d total:"; preserve leading
2014 * space. Pluralized in "nearest threshold of %d cities". */
2015 PL_(" %d over nearest threshold of %d city.",
2016 " %d over nearest threshold of %d cities.", last),
2017 cities - last, last);
2019 /* TRANS: Number of content [citizen(s)] ... */
2020 PL_("%d content before penalty.",
2021 "%d content before penalty.", content),
2022 content);
2024 PL_("%d additional unhappy citizen.",
2025 "%d additional unhappy citizens.", unhappy),
2026 unhappy);
2027 if (angry > 0) {
2029 PL_("%d angry citizen.",
2030 "%d angry citizens.", angry),
2031 angry);
2032 }
2033 } else {
2034 astr_add(&str,
2035 /* TRANS: appended to "Cities: %d total:"; preserve leading
2036 * space. */
2037 PL_(" not more than %d, so no empire size penalty.",
2038 " not more than %d, so no empire size penalty.", next),
2039 next);
2041 /* TRANS: %d is number of citizens */
2042 PL_("%d content per city.",
2043 "%d content per city.", content),
2044 content);
2045 }
2046 if (next >= cities && penalty < content) {
2048 PL_("With %d more city, another citizen will become "
2049 "unhappy.",
2050 "With %d more cities, another citizen will become "
2051 "unhappy.",
2052 next + 1 - cities),
2053 next + 1 - cities);
2054 } else if (next >= cities) {
2055 /* We maxed out the number of unhappy citizens, but they can get
2056 * angry instead. */
2059 PL_("With %d more city, another citizen will become "
2060 "angry.",
2061 "With %d more cities, another citizen will become "
2062 "angry.",
2063 next + 1 - cities),
2064 next + 1 - cities);
2065 } else {
2066 /* Either no Empire_Size_Step, or we maxed out on unhappy citizens
2067 * and ruleset doesn't allow angry ones. */
2069 _("More cities will not cause more unhappy citizens."));
2070 }
2071 }
2072
2073 return astr_str(&str);
2074}
2075
2076/************************************************************************/
2081const char *text_happiness_units(const struct city *pcity)
2082{
2085 static struct astring str = ASTRING_INIT;
2086
2087 astr_clear(&str);
2088
2089 if (mlmax > 0) {
2091
2092 if (mlmax == 100) {
2093 astr_add_line(&str, "%s", _("Unlimited martial law in effect."));
2094 } else {
2095 astr_add_line(&str, PL_("%d military unit may impose martial law.",
2096 "Up to %d military units may impose martial "
2097 "law.", mlmax), mlmax);
2098 }
2099 astr_add_line(&str, PL_("Each military unit makes %d "
2100 "unhappy citizen content.",
2101 "Each military unit makes %d "
2102 "unhappy citizens content.",
2103 mleach), mleach);
2104 } else if (uhcfac > 0) {
2106 _("Military units in the field may cause unhappiness. "));
2107 } else {
2109 _("Military units have no happiness effect. "));
2110 }
2111
2112 return astr_str(&str);
2113}
2114
2115/************************************************************************/
2120const char *text_happiness_luxuries(const struct city *pcity)
2121{
2122 static struct astring str = ASTRING_INIT;
2123
2124 astr_clear(&str);
2125
2127 _("Luxury: %d total."),
2128 pcity->prod[O_LUXURY]);
2129
2130 return astr_str(&str);
2131}
2132
2133/************************************************************************/
2137const char *production_help(const struct universal *uni, char *buf,
2138 size_t bufsize)
2139{
2140 buf[0] = '\0';
2141 int segments = 0;
2142
2143 if (uni->kind == VUT_UTYPE) {
2144 if (uni->value.utype->helptext != NULL) {
2145 strvec_iterate(uni->value.utype->helptext, text) {
2146 if (segments++) {
2147 cat_snprintf(buf, bufsize, "\n\n");
2148 }
2149 cat_snprintf(buf, bufsize, "%s", _(text));
2151 }
2152 } else {
2154
2155 if (uni->value.building->helptext != NULL) {
2156 strvec_iterate(uni->value.building->helptext, text) {
2157 if (segments++) {
2158 cat_snprintf(buf, bufsize, "\n\n");
2159 }
2160 cat_snprintf(buf, bufsize, "%s", _(text));
2162 }
2163 }
2164
2165 return buf;
2166}
2167
2168/************************************************************************/
2174const char *score_tooltip(const struct player *pplayer, int score)
2175{
2176 static char buf[1024];
2177 char *relation;
2178
2179 if (client.conn.playing != NULL) {
2180 if (pplayer == client.conn.playing) {
2181 relation = _(" (us)");
2182 } else if (pplayers_allied(pplayer, client.conn.playing)) {
2183 relation = _(" (an ally)");
2184 } else if (player_diplstate_get(pplayer, client.conn.playing)->type == DS_WAR) {
2185 /* Actual enemy; don't want to use pplayers_at_war() that considers also
2186 * never met players enemies. */
2187 relation = _(" (an enemy)");
2188 } else {
2189 relation = "";
2190 }
2191 } else {
2192 relation = "";
2193 }
2194
2195 if (score >= 0) {
2196 /* TRANS: %s is a Nation */
2197 fc_snprintf(buf, sizeof(buf), _("%s%s: score %d"),
2199 score);
2200 } else {
2201 fc_snprintf(buf, sizeof(buf), "%s%s",
2203 }
2204
2205 return buf;
2206}
const char * action_prob_explain(const struct act_prob prob)
Definition actions.c:1423
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5091
enum action_target_kind action_get_target_kind(const struct action *paction)
Definition actions.c:1108
#define action_has_result(_act_, _res_)
Definition actions.h:180
void astr_free(struct astring *astr)
Definition astring.c:148
void astr_set(struct astring *astr, const char *format,...)
Definition astring.c:251
const char * astr_build_and_list(struct astring *astr, const char *const *items, size_t number)
Definition astring.c:351
void astr_add_line(struct astring *astr, const char *format,...)
Definition astring.c:283
void astr_clear(struct astring *astr)
Definition astring.c:201
void astr_add(struct astring *astr, const char *format,...)
Definition astring.c:271
#define str
Definition astring.c:76
void astr_break_lines(struct astring *astr, size_t desired_len)
Definition astring.c:302
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
Definition astring.h:93
#define ASTRING_INIT
Definition astring.h:44
const char * calendar_text(void)
Definition calendar.c:142
const char * textyear(int year)
Definition calendar.c:121
#define citizens_foreign_iterate_end
Definition citizens.h:63
#define citizens_foreign_iterate(_pcity, _pslot, _nationality)
Definition citizens.h:58
int city_production_build_shield_cost(const struct city *pcity)
Definition city.c:737
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
int city_airlift_max(const struct city *pcity)
Definition city.c:2942
struct output_type * get_output_type(Output_type_id output)
Definition city.c:638
bool city_is_occupied(const struct city *pcity)
Definition city.c:1665
int city_tile_output(const struct city *pcity, const struct tile *ptile, bool is_celebrating, Output_type_id otype)
Definition city.c:1283
#define city_list_iterate(citylist, pcity)
Definition city.h:505
#define city_owner(_pcity_)
Definition city.h:560
#define city_list_iterate_end
Definition city.h:507
bool client_is_global_observer(void)
int get_seconds_to_new_turn(void)
int get_seconds_to_turndone(void)
struct civclient client
bool is_waiting_turn_change(void)
bool client_has_player(void)
#define client_player()
void combat_odds_to_astr(struct astring *str, struct unit_list *punits, const struct tile *ptile, const struct unit *punit, const char *pct_str)
const char * concat_tile_activity_text(struct tile *ptile)
enum known_type client_tile_get_known(const struct tile *ptile)
Definition climap.c:36
void nuclear_winter_scaled(int *chance, int *rate, int max)
Definition climisc.c:344
void global_warming_scaled(int *chance, int *rate, int max)
Definition climisc.c:334
struct city * get_nearest_city(const struct unit *punit, int *sq_dist)
Definition climisc.c:1119
static struct fc_sockaddr_list * list
Definition clinet.c:102
char * incite_cost
Definition comments.c:76
#define MAX_LEN_MSG
Definition conn_types.h:37
#define conn_list_iterate(connlist, pconn)
Definition connection.h:108
#define conn_list_iterate_end
Definition connection.h:110
struct unit_list * get_units_in_focus(void)
Definition control.c:177
enum cursor_hover_state hover_state
Definition control.c:89
struct unit * find_visible_unit(struct tile *ptile)
Definition control.c:822
@ HOVER_NONE
Definition control.h:26
int city_history_gain(const struct city *pcity)
Definition culture.c:39
int nation_history_gain(const struct player *pplayer)
Definition culture.c:66
struct unit * actor_unit
Definition dialogs_g.h:55
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 const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
struct unit struct city * target_city
Definition dialogs_g.h:56
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
struct effect_list * effects[EFT_COUNT]
Definition effects.c:127
int get_player_output_bonus(const struct player *pplayer, const struct output_type *poutput, enum effect_type effect_type)
Definition effects.c:957
int get_city_bonus(const struct city *pcity, enum effect_type effect_type)
Definition effects.c:842
int get_city_bonus_effects(struct effect_list *plist, const struct city *pcity, const struct output_type *poutput, enum effect_type effect_type)
Definition effects.c:1151
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
Definition effects.c:824
void get_effect_list_req_text(const struct effect_list *plist, struct astring *astr)
Definition effects.c:1301
static struct extra_type extras[MAX_EXTRA_TYPES]
Definition extras.c:31
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:194
#define extra_type_iterate(_p)
Definition extras.h:315
#define extra_type_iterate_end
Definition extras.h:321
int Tech_type_id
Definition fc_types.h:236
#define MAX_LEN_NAME
Definition fc_types.h:66
@ O_SHIELD
Definition fc_types.h:101
@ O_FOOD
Definition fc_types.h:101
@ O_TRADE
Definition fc_types.h:101
@ O_SCIENCE
Definition fc_types.h:101
@ O_LUXURY
Definition fc_types.h:101
@ O_LAST
Definition fc_types.h:101
signed short Continent_id
Definition fc_types.h:231
#define LINE_BREAK
Definition fc_types.h:77
@ BORDERS_DISABLED
Definition fc_types.h:745
#define Q_(String)
Definition fcintl.h:70
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
const char * population_to_text(int thousand_citizen)
Definition game.c:739
struct civ_game game
Definition game.c:61
int current_turn_timeout(void)
Definition game.c:853
struct world wld
Definition game.c:62
int civ_population(const struct player *pplayer)
Definition game.c:73
struct city * game_city_by_number(int id)
Definition game.c:106
bool goto_get_turns(int *min, int *max)
Definition goto.c:1079
const char * ruler_title_for_player(const struct player *pplayer, char *buf, size_t buf_len)
Definition government.c:391
const char * government_name_for_player(const struct player *pplayer)
Definition government.c:154
struct city * owner
Definition citydlg.c:226
GType type
Definition repodlgs.c:1313
static const int bufsz
Definition helpdlg.c:70
bool is_improvement_visible(const struct impr_type *pimprove)
const char * improvement_name_translation(const struct impr_type *pimprove)
Impr_type_id improvement_count(void)
#define improvement_iterate_end
#define improvement_iterate(_p)
#define fc_assert(condition)
Definition log.h:177
#define fc_assert_ret_val(condition, val)
Definition log.h:195
int get_continent_size(Continent_id id)
Definition map.c:819
#define nat_x
#define nat_y
int map_signed_latitude(const struct tile *ptile)
Definition map.c:1692
int get_ocean_size(Continent_id id)
Definition map.c:830
int get_island_surrounder(Continent_id id)
Definition map.c:842
int get_lake_surrounder(Continent_id id)
Definition map.c:875
#define is_whole_continent_known(cont)
Definition map.h:78
#define is_whole_ocean_known(ocean)
Definition map.h:82
#define index_to_native_pos(pnat_x, pnat_y, mindex)
Definition map.h:161
#define index_to_map_pos(pmap_x, pmap_y, mindex)
Definition map.h:229
#define fc_strdup(str)
Definition mem.h:43
const char * nation_adjective_for_player(const struct player *pplayer)
Definition nation.c:169
struct city_list * cities
Definition packhand.c:119
struct player * player_by_number(const int player_id)
Definition player.c:849
int player_count(void)
Definition player.c:817
int player_get_expected_income(const struct player *pplayer)
Definition player.c:1286
const char * player_name(const struct player *pplayer)
Definition player.c:895
bool pplayers_at_war(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1388
struct city * player_city_by_number(const struct player *pplayer, int city_id)
Definition player.c:1203
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Definition player.c:324
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1409
bool can_player_see_units_in_city(const struct player *pplayer, const struct city *pcity)
Definition player.c:1133
struct player * player_slot_get_player(const struct player_slot *pslot)
Definition player.c:437
#define is_ai(plr)
Definition player.h:232
int research_goal_unknown_techs(const struct research *presearch, Tech_type_id goal)
Definition research.c:750
bool research_goal_tech_req(const struct research *presearch, Tech_type_id goal, Tech_type_id tech)
Definition research.c:807
int research_goal_bulbs_required(const struct research *presearch, Tech_type_id goal)
Definition research.c:772
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:273
struct research * research_get(const struct player *pplayer)
Definition research.c:128
#define research_players_iterate(_presearch, _pplayer)
Definition research.h:166
#define research_players_iterate_end
Definition research.h:170
#define CLIP(lower, current, upper)
Definition shared.h:57
#define ARRAY_SIZE(x)
Definition shared.h:85
#define MIN(x, y)
Definition shared.h:55
#define FC_INFINITY
Definition shared.h:36
#define MAX(x, y)
Definition shared.h:54
@ SSHIP_LAUNCHED
Definition spaceship.h:85
int step
Definition specpq.h:92
size_t size
Definition specvec.h:72
struct sprite int x
Definition sprite_g.h:31
#define strvec_iterate(psv, str)
#define strvec_iterate_end
Definition city.h:317
struct packet_game_info info
Definition game.h:89
struct packet_timeout_info tinfo
Definition game.h:91
struct connection conn
Definition client_main.h:96
struct player * playing
Definition connection.h:151
struct strvec * helptext
Definition improvement.h:65
enum borders_mode borders
enum tech_upkeep_style tech_upkeep_style
enum airlifting_style airlifting_style
enum phase_mode_type phase_mode
bool airlift_from_always_enabled
bool airlift_to_always_enabled
enum diplstate_type type
Definition player.h:199
struct city_list * cities
Definition player.h:281
char username[MAX_LEN_NAME]
Definition player.h:252
struct team * team
Definition player.h:261
struct conn_list * connections
Definition player.h:298
struct player_economic economic
Definition player.h:284
int culture
Definition player.h:367
char name[MAX_LEN_NAME]
Definition player.h:251
struct player_score score
Definition player.h:283
struct nation_type * nation
Definition player.h:260
struct player::@73::@76 client
Tech_type_id researching
Definition research.h:52
struct research::@79::@81 client
int researching_cost
Definition research.h:96
int bulbs_researched
Definition research.h:53
Definition team.c:40
Definition tile.h:50
bv_extras extras
Definition tile.h:55
struct unit_list * units
Definition tile.h:58
struct strvec * helptext
Definition unittype.h:578
Definition unit.h:140
int id
Definition unit.h:147
int homecity
Definition unit.h:148
struct goods_type * carrying
Definition unit.h:189
int veteran
Definition unit.h:154
enum universals_n kind
Definition fc_types.h:608
universals_u value
Definition fc_types.h:607
struct civ_map map
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
size_t fc_strlcpy(char *dest, const char *src, size_t n)
Definition support.c:777
int cat_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:986
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
int team_count(void)
Definition team.c:375
struct team * team_by_number(const int team_id)
Definition team.c:400
const char * team_name_translation(const struct team *pteam)
Definition team.c:420
#define A_UNSET
Definition tech.h:48
const char * get_infrastructure_text(bv_extras extras)
Definition terrain.c:508
const char * get_government_tooltip(void)
Definition text.c:1525
const char * text_happiness_cities(const struct city *pcity)
Definition text.c:1947
static const char * format_duration(int duration)
Definition text.c:1637
static void get_full_username(char *buf, int buflen, const struct player *pplayer)
Definition text.c:96
const char * text_happiness_nationality(const struct city *pcity)
Definition text.c:1875
#define FAR_CITY_SQUARE_DIST
Definition text.c:482
const char * score_tooltip(const struct player *pplayer, int score)
Definition text.c:2174
const char * text_happiness_wonders(const struct city *pcity)
Definition text.c:1917
bool get_units_upgrade_info(char *buf, size_t bufsz, struct unit_list *punits)
Definition text.c:1304
bool get_units_disband_info(char *buf, size_t bufsz, struct unit_list *punits)
Definition text.c:1370
static int turns_to_research_done(const struct research *presearch, int per_turn)
Definition text.c:740
const char * get_airlift_text(const struct unit_list *punits, const struct city *pdest)
Definition text.c:592
const char * get_info_label_text_popup(void)
Definition text.c:1016
const char * text_happiness_units(const struct city *pcity)
Definition text.c:2081
const char * text_happiness_luxuries(const struct city *pcity)
Definition text.c:2120
const char * science_dialog_text(void)
Definition text.c:788
static int get_bulbs_per_turn(int *pours, bool *pteam, int *ptheirs)
Definition text.c:696
const char * text_happiness_buildings(const struct city *pcity)
Definition text.c:1847
const char * get_ping_time_text(const struct player *pplayer)
Definition text.c:1668
const char * get_report_title(const char *report_name)
Definition text.c:1719
static int turns_to_tech_loss(const struct research *presearch, int per_turn)
Definition text.c:768
const char * get_nuclear_winter_tooltip(void)
Definition text.c:1498
const char * get_score_text(const struct player *pplayer)
Definition text.c:1697
const char * get_science_target_text(double *percent)
Definition text.c:867
const char * get_bulb_tooltip(void)
Definition text.c:1414
const char * get_timeout_label_text(void)
Definition text.c:1604
const char * get_nearest_city_text(struct city *pcity, int sq_dist)
Definition text.c:488
const char * get_act_sel_action_custom_text(struct action *paction, const struct act_prob prob, const struct unit *actor_unit, const struct city *target_city)
Definition text.c:1757
const char * popup_info_text(struct tile *ptile)
Definition text.c:147
const char * unit_description(struct unit *punit)
Definition text.c:522
static void get_full_nation(char *buf, int buflen, const struct player *pplayer)
Definition text.c:120
const char * get_global_warming_tooltip(void)
Definition text.c:1471
const char * get_tile_output_text(const struct tile *ptile)
Definition text.c:63
const char * get_info_label_text(bool moreinfo)
Definition text.c:964
const char * production_help(const struct universal *uni, char *buf, size_t bufsize)
Definition text.c:2137
static int turns_per_advance(const struct research *presearch, int per_turn)
Definition text.c:755
const char * get_science_goal_text(Tech_type_id goal)
Definition text.c:913
const char * get_unit_info_label_text2(struct unit_list *punits, int linebreaks)
Definition text.c:1126
const char * get_unit_info_label_text1(struct unit_list *punits)
Definition text.c:1101
const char * get_spaceship_descr(struct player_spaceship *pship)
Definition text.c:1547
const char * act_sel_action_tool_tip(const struct action *paction, const struct act_prob prob)
Definition text.c:1836
bool tile_has_visible_extra(const struct tile *ptile, const struct extra_type *pextra)
Definition tile.c:917
const char * tile_get_info_text(const struct tile *ptile, bool include_nuisances, int linebreaks)
Definition tile.c:771
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:89
@ TILE_UNKNOWN
Definition tile.h:36
#define tile_continent(_tile)
Definition tile.h:93
#define tile_owner(_tile)
Definition tile.h:97
bool can_cities_trade(const struct city *pc1, const struct city *pc2)
int trade_base_between_cities(const struct city *pc1, const struct city *pc2)
struct goods_type * unit_current_goods(const struct unit *punit, const struct city *homecity)
bool can_establish_trade_route(const struct city *pc1, const struct city *pc2, int priority)
int get_caravan_enter_city_trade_bonus(const struct city *pc1, const struct city *pc2, const struct unit_type *ut, struct goods_type *pgood, const bool establish_trade)
const struct unit_type * utype
Definition fc_types.h:553
const struct impr_type * building
Definition fc_types.h:546
enum unit_upgrade_result unit_upgrade_info(const struct civ_map *nmap, const struct unit *punit, char *buf, size_t bufsz)
Definition unit.c:2088
struct player * unit_nationality(const struct unit *punit)
Definition unit.c:1274
int unit_bribe_cost(const struct unit *punit, const struct player *briber, const struct unit *briber_unit)
Definition unit.c:2344
enum unit_airlift_result test_unit_can_airlift_to(const struct civ_map *nmap, const struct player *restriction, const struct unit *punit, const struct city *pdest_city)
Definition unit.c:81
void unit_upkeep_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1260
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:383
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1184
enum unit_upgrade_result unit_upgrade_test(const struct civ_map *nmap, const struct unit *punit, bool is_free)
Definition unit.c:2025
bool is_flagless_to_player(const struct unit *punit, const struct player *pplayer)
Definition unit.c:363
#define unit_tile(_pu)
Definition unit.h:404
#define unit_owner(_pu)
Definition unit.h:403
@ UU_OK
Definition unit.h:62
#define unit_home(_pu_)
Definition unit.h:401
unit_airlift_result
Definition unit.h:73
@ AR_SRC_NO_FLIGHTS
Definition unit.h:85
@ AR_OK_SRC_UNKNOWN
Definition unit.h:76
@ AR_OK_DST_UNKNOWN
Definition unit.h:77
@ AR_NO_MOVES
Definition unit.h:79
@ AR_BAD_DST_CITY
Definition unit.h:84
@ AR_NOT_IN_CITY
Definition unit.h:82
@ AR_OCCUPIED
Definition unit.h:81
@ AR_OK
Definition unit.h:75
@ AR_DST_NO_FLIGHTS
Definition unit.h:86
@ AR_WRONG_UNITTYPE
Definition unit.h:80
@ AR_BAD_SRC_CITY
Definition unit.h:83
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const char * utype_veteran_name_translation(const struct unit_type *punittype, int level)
Definition unittype.c:2616
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c:1575
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1709
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Definition unittype.c:196
Unit_type_id utype_index(const struct unit_type *punittype)
Definition unittype.c:91
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1566
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Definition unittype.c:377
int unit_upgrade_price(const struct player *pplayer, const struct unit_type *from, const struct unit_type *to)
Definition unittype.c:1737
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:624
#define unit_type_iterate(_p)
Definition unittype.h:862
#define U_LAST
Definition unittype.h:40
#define unit_type_iterate_end
Definition unittype.h:869