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
370
372 /* TRANS: "Trade from Warsaw: 5" */
373 astr_add_line(&str, _("Trade from %s: %d"),
376 }
377 }
379 }
380 {
381 const char *infratext = get_infrastructure_text(ptile->extras);
382
383 if (*infratext != '\0') {
384 astr_add_line(&str, _("Infrastructure: %s"), infratext);
385 }
386 }
388 if (strlen(activity_text) > 0) {
389 astr_add_line(&str, _("Activity: %s"), activity_text);
390 }
391
392 if (punit != nullptr && pcity == nullptr) {
393 struct player *owner = unit_owner(punit);
394 const struct unit_type *ptype = unit_type_get(punit);
395
396 if (flaggy_unit) {
397 get_full_username(username, sizeof(username), owner);
398 get_full_nation(nation, sizeof(nation), owner);
399
400 if (plr == nullptr || owner == plr) {
402
403 /* TRANS: "Unit: <unit type> | <username> (<nation + team>)" */
404 astr_add_line(&str, _("Unit: %s | %s (%s)"),
405 utype_name_translation(ptype), username, nation);
406
409 if (hcity != nullptr) {
410 /* TRANS: on own line immediately following \n, "from <city> |
411 * <nationality> people" */
412 astr_add_line(&str, _("from %s | %s people"), city_name_get(hcity),
414 } else {
415 /* TRANS: Nationality of the people comprising a unit, if
416 * different from owner. */
417 astr_add_line(&str, _("%s people"),
419 }
420 } else if (hcity != nullptr) {
421 /* TRANS: on own line immediately following \n, ... <city> */
422 astr_add_line(&str, _("from %s"), city_name_get(hcity));
423 }
424 if (punit->carrying
426 /* TRANS: on own line immediately following \n, from ... */
427 astr_add_line(&str, _("carrying %s"),
429 }
430 } else if (owner != nullptr) {
432
433 if (ds->type == DS_CEASEFIRE) {
434 int turns = ds->turns_left;
435
436 /* TRANS: "Unit: <unit type> | <username> (<nation + team>,
437 * <number> turn cease-fire)" */
438 astr_add_line(&str, PL_("Unit: %s | %s (%s, %d turn cease-fire)",
439 "Unit: %s | %s (%s, %d turn cease-fire)",
440 turns),
442 username, nation, turns);
443 } else if (ds->type == DS_ARMISTICE) {
444 int turns = ds->turns_left;
445
446 /* TRANS: "Unit: <unit type> | <username> (<nation + team>,
447 * <number> turn armistice)" */
448 astr_add_line(&str, PL_("Unit: %s | %s (%s, %d turn armistice)",
449 "Unit: %s | %s (%s, %d turn armistice)",
450 turns),
452 username, nation, turns);
453 } else {
454 /* TRANS: "Unit: <unit type> | <username> (<nation + team>,
455 * <diplomatic state>)" */
456 astr_add_line(&str, _("Unit: %s | %s (%s, %s)"),
457 utype_name_translation(ptype), username, nation,
459 }
460 }
461 } else {
463 }
464
466
467 if (owner == plr || client_is_global_observer()) {
468 /* Show bribe cost for own units. */
469 astr_add_line(&str, _("Probable bribe cost: %d"),
470 unit_bribe_cost(punit, nullptr, nullptr));
471 } else {
472 /* We can only give an (lower) boundary for units of other players. */
473 astr_add_line(&str, _("Estimated bribe cost: > %d"),
474 unit_bribe_cost(punit, plr, nullptr));
475 }
476
477 if ((plr == nullptr || owner == plr)
478 && unit_list_size(ptile->units) >= 2) {
479 /* TRANS: "5 more" units on this tile */
480 astr_add(&str, _(" (%d more)"), unit_list_size(ptile->units) - 1);
481 }
482 }
483
485
486 return astr_str(&str);
487}
488
489#define FAR_CITY_SQUARE_DIST (2*(6*6))
490/************************************************************************/
495const char *get_nearest_city_text(struct city *pcity, int sq_dist)
496{
497 static struct astring str = ASTRING_INIT;
498
499 astr_clear(&str);
500
501 /* Just to be sure */
502 if (!pcity) {
503 sq_dist = -1;
504 }
505
507 /* TRANS: on own line immediately following \n, ... <city> */
508 ? _("far from %s")
509 : (sq_dist > 0)
510 /* TRANS: on own line immediately following \n, ... <city> */
511 ? _("near %s")
512 : (sq_dist == 0)
513 /* TRANS: on own line immediately following \n, ... <city> */
514 ? _("in %s")
515 : "%s",
516 pcity
518 : "");
519
520 return astr_str(&str);
521}
522
523/************************************************************************/
529const char *unit_description(struct unit *punit)
530{
531 int pcity_near_dist;
532 struct player *owner = unit_owner(punit);
533 struct player *nationality = unit_nationality(punit);
534 struct city *pcity
537 const struct unit_type *ptype = unit_type_get(punit);
538 static struct astring str = ASTRING_INIT;
539 const struct player *pplayer = client_player();
540
541 astr_clear(&str);
542
544
545 {
546 const char *veteran_name =
548 if (veteran_name) {
549 astr_add(&str, " (%s)", veteran_name);
550 }
551 }
552
553 if (pplayer == owner) {
555 } else {
556 astr_add(&str, "\n");
557 }
559
560 if (pcity) {
561 /* TRANS: on own line immediately following \n, ... <city> */
562 astr_add_line(&str, _("from %s"), city_name_get(pcity));
563 } else {
564 astr_add(&str, "\n");
565 }
567 if (nationality != NULL && owner != nationality) {
568 /* TRANS: Nationality of the people comprising a unit, if
569 * different from owner. */
570 astr_add_line(&str, _("%s people"),
571 nation_adjective_for_player(nationality));
572 } else {
573 astr_add(&str, "\n");
574 }
575 }
576
577 astr_add_line(&str, "%s",
579#ifdef FREECIV_DEBUG
580 astr_add_line(&str, "Unit ID: %d", punit->id);
581#endif
582
583 return astr_str(&str);
584}
585
586/************************************************************************/
599const char *get_airlift_text(const struct unit_list *punits,
600 const struct city *pdest)
601{
602 static struct astring str = ASTRING_INIT;
603 bool src = (pdest == NULL);
605 best = AL_IMPOSSIBLE;
606 int cur = 0, max = 0;
607
609 enum texttype this = AL_IMPOSSIBLE;
610 enum unit_airlift_result result;
611
612 /* NULL will tell us about the capability of airlifting from source */
614
615 switch (result) {
616 case AR_NO_MOVES:
618 case AR_OCCUPIED:
619 case AR_NOT_IN_CITY:
620 case AR_BAD_SRC_CITY:
621 case AR_BAD_DST_CITY:
622 /* No chance of an airlift. */
623 this = AL_IMPOSSIBLE;
624 break;
625 case AR_OK:
630 /* May or may not be able to airlift now, but there's a chance we could
631 * later */
632 {
633 const struct city *pcity = src ? tile_city(unit_tile(punit)) : pdest;
634
638 /* No restrictions on destination (and we can infer this even for
639 * other players' cities). */
640 this = AL_INFINITE;
643 this = AL_INFINITE;
644 } else if (client_player() == city_owner(pcity)) {
645 /* A city we know about. */
646 int this_cur = pcity->airlift, this_max = city_airlift_max(pcity);
647
648 if (this_max <= 0) {
649 /* City known not to be airlift-capable. */
650 this = AL_IMPOSSIBLE;
651 } else {
652 if (src
654 /* Unlimited capacity. */
655 this = AL_INFINITE;
656 } else if (!src
658 this = AL_INFINITE;
659 } else {
660 /* Limited capacity (possibly zero right now). */
661 this = AL_FINITE;
662 /* Store the numbers. This whole setup assumes that numeric
663 * capacity isn't unit-dependent. */
664 if (best == AL_FINITE) {
665 fc_assert(cur == this_cur && max == this_max);
666 }
667 cur = this_cur;
668 max = this_max;
669 }
670 }
671 } else {
672 /* Unknown capacity. */
673 this = AL_UNKNOWN;
674 }
675 }
676 break;
677 }
678
679 /* Now take the most optimistic view. */
680 best = MAX(best, this);
682
683 switch (best) {
684 case AL_IMPOSSIBLE:
685 return NULL;
686 case AL_UNKNOWN:
687 astr_set(&str, "?");
688 break;
689 case AL_FINITE:
690 astr_set(&str, "%d/%d", cur, max);
691 break;
692 case AL_INFINITE:
693 astr_set(&str, _("Yes"));
694 break;
695 }
696
697 return astr_str(&str);
698}
699
700/************************************************************************/
703static int get_bulbs_per_turn(int *pours, bool *pteam, int *ptheirs)
704{
705 const struct research *presearch;
706 int ours = 0, theirs = 0;
707 bool team = FALSE;
708
709 if (!client_has_player()) {
710 return 0;
711 }
713
714 /* Sum up science */
716 if (pplayer == client_player()) {
717 city_list_iterate(pplayer->cities, pcity) {
718 ours += pcity->surplus[O_SCIENCE];
720 } else {
721 team = TRUE;
722 theirs -= pplayer->client.tech_upkeep;
723 }
725
726 if (team) {
727 theirs += presearch->client.total_bulbs_prod - ours;
728 }
729 ours -= client_player()->client.tech_upkeep;
730
731 if (pours) {
732 *pours = ours;
733 }
734 if (pteam) {
735 *pteam = team;
736 }
737 if (ptheirs) {
738 *ptheirs = theirs;
739 }
740
741 return ours + theirs;
742}
743
744/************************************************************************/
748 int per_turn)
749{
750 if (per_turn > 0) {
751 return ceil((double)(presearch->client.researching_cost
752 - presearch->bulbs_researched) / per_turn);
753 } else {
754 return -1;
755 }
756}
757
758/************************************************************************/
762static int turns_per_advance(const struct research *presearch, int per_turn)
763{
764 if (per_turn > 0) {
765 return MAX(1, ceil((double)presearch->client.researching_cost) / per_turn);
766 } else {
767 return -1;
768 }
769}
770
771/************************************************************************/
775static int turns_to_tech_loss(const struct research *presearch, int per_turn)
776{
777 if (per_turn >= 0 || game.info.techloss_forgiveness == -1) {
778 /* With techloss_forgiveness == -1, we'll never lose a tech, just
779 * get further into debt. */
780 return -1;
781 } else {
782 int bulbs_to_loss = presearch->bulbs_researched
783 + (presearch->client.researching_cost
785
786 return ceil((double)bulbs_to_loss / -per_turn);
787 }
788}
789
790/************************************************************************/
795const char *science_dialog_text(void)
796{
797 bool team;
798 int ours, theirs, perturn, upkeep;
799 static struct astring str = ASTRING_INIT;
801 struct research *research;
802
803 astr_clear(&str);
804
806
808 upkeep = client_player()->client.tech_upkeep;
809
810 if (NULL == client.conn.playing || (ours == 0 && theirs == 0
811 && upkeep == 0)) {
812 return _("Progress: no research");
813 }
814
815 if (A_UNSET == research->researching) {
816 astr_add(&str, _("Progress: no research"));
817 } else {
818 int turns;
819
820 if ((turns = turns_per_advance(research, perturn)) >= 0) {
821 astr_add(&str, PL_("Progress: %d turn/advance",
822 "Progress: %d turns/advance",
823 turns), turns);
824 } else if ((turns = turns_to_tech_loss(research, perturn)) >= 0) {
825 /* FIXME: turns to next loss is not a good predictor of turns to
826 * following loss, due to techloss_restore etc. But it'll do. */
827 astr_add(&str, PL_("Progress: %d turn/advance loss",
828 "Progress: %d turns/advance loss",
829 turns), turns);
830 } else {
831 /* no forward progress -- no research, or tech loss disallowed */
832 if (perturn < 0) {
833 astr_add(&str, _("Progress: decreasing!"));
834 } else {
835 astr_add(&str, _("Progress: none"));
836 }
837 }
838 }
839 astr_set(&ourbuf, PL_("%d bulb/turn", "%d bulbs/turn", ours), ours);
840 if (team) {
841 /* Techpool version */
843 /* TRANS: This is appended to "%d bulb/turn" text */
844 PL_(", %d bulb/turn from team",
845 ", %d bulbs/turn from team", theirs), theirs);
846 } else {
848 }
849 astr_add(&str, " (%s%s)", astr_str(&ourbuf), astr_str(&theirbuf));
852
854 /* perturn is defined as: (bulbs produced) - upkeep */
855 astr_add_line(&str, _("Bulbs produced per turn: %d"), perturn + upkeep);
856 /* TRANS: keep leading space; appended to "Bulbs produced per turn: %d" */
857 astr_add(&str, _(" (needed for technology upkeep: %d)"), upkeep);
858 }
859
860 return astr_str(&str);
861}
862
863/************************************************************************/
875{
877 static struct astring str = ASTRING_INIT;
878
879 if (!research) {
880 return "-";
881 }
882
883 astr_clear(&str);
884 if (research->researching == A_UNSET) {
885 astr_add(&str, _("%d/- (never)"), research->bulbs_researched);
886 if (percent) {
887 *percent = 0.0;
888 }
889 } else {
890 int total = research->client.researching_cost;
891 int done = research->bulbs_researched;
893 int turns;
894
895 if ((turns = turns_to_research_done(research, perturn)) >= 0) {
896 astr_add(&str, PL_("%d/%d (%d turn)", "%d/%d (%d turns)", turns),
897 done, total, turns);
898 } else if ((turns = turns_to_tech_loss(research, perturn)) >= 0) {
899 astr_add(&str, PL_("%d/%d (%d turn to loss)",
900 "%d/%d (%d turns to loss)", turns),
901 done, total, turns);
902 } else {
903 /* no forward progress -- no research, or tech loss disallowed */
904 astr_add(&str, _("%d/%d (never)"), done, total);
905 }
906 if (percent) {
907 *percent = (double)done / (double)total;
908 *percent = CLIP(0.0, *percent, 1.0);
909 }
910 }
911
912 return astr_str(&str);
913}
914
915/************************************************************************/
921{
922 const struct research *research = research_get(client_player());
923 int steps = research_goal_unknown_techs(research, goal);
925 int turns;
927 static struct astring str = ASTRING_INIT;
928 struct astring buf1 = ASTRING_INIT,
931
932 if (!research) {
933 return "-";
934 }
935
936 astr_clear(&str);
937
939 || research->researching == goal) {
941 }
942
943 astr_set(&buf1,
944 PL_("%d step", "%d steps", steps), steps);
945 astr_set(&buf2,
946 PL_("%d bulb", "%d bulbs", bulbs_needed), bulbs_needed);
947 if (perturn > 0) {
948 turns = (bulbs_needed + perturn - 1) / perturn;
949 astr_set(&buf3,
950 PL_("%d turn", "%d turns", turns), turns);
951 } else {
952 astr_set(&buf3, _("never"));
953 }
954 astr_add_line(&str, "(%s - %s - %s)",
956 astr_free(&buf1);
957 astr_free(&buf2);
958 astr_free(&buf3);
959
960 return astr_str(&str);
961}
962
963/************************************************************************/
972{
973 static struct astring str = ASTRING_INIT;
974
975 astr_clear(&str);
976
977 if (NULL != client.conn.playing) {
978 astr_add_line(&str, _("Population: %s"),
980 }
981 astr_add_line(&str, _("Year: %s (T%d)"),
983
984 if (NULL != client.conn.playing) {
985 astr_add_line(&str, _("Gold: %d (%+d)"),
988 astr_add_line(&str, _("Tax: %d Lux: %d Sci: %d"),
992 }
994 if (game.info.phase < 0 || game.info.phase >= player_count()) {
995 astr_add_line(&str, _("Moving: Nobody"));
996 } else {
997 astr_add_line(&str, _("Moving: %s"),
999 }
1000 } else if (game.info.phase_mode == PMT_TEAMS_ALTERNATE) {
1001 if (game.info.phase < 0 || game.info.phase >= team_count()) {
1002 astr_add_line(&str, _("Moving: Nobody"));
1003 } else {
1004 astr_add_line(&str, _("Moving: %s"),
1006 }
1007 }
1008
1009 if (moreinfo) {
1010 astr_add_line(&str, _("(Click for more info)"));
1011 }
1012
1013 return astr_str(&str);
1014}
1015
1016/************************************************************************/
1024{
1025 static struct astring str = ASTRING_INIT;
1026
1027 astr_clear(&str);
1028
1029 if (NULL != client.conn.playing) {
1030 astr_add_line(&str, _("%s People"),
1032 }
1033 astr_add_line(&str, _("Year: %s"), calendar_text());
1034 astr_add_line(&str, _("Turn: %d"), game.info.turn);
1035
1036 if (NULL != client.conn.playing) {
1037 const struct research *presearch = research_get(client_player());
1039 int upkeep = client_player()->client.tech_upkeep;
1040
1041 astr_add_line(&str, _("Gold: %d"),
1043 astr_add_line(&str, _("Net Income: %d"),
1045 /* TRANS: Gold, luxury, and science rates are in percentage values. */
1046 astr_add_line(&str, _("Tax rates: Gold:%d%% Luxury:%d%% Science:%d%%"),
1050 astr_add_line(&str, _("Researching %s: %s"),
1052 presearch->researching),
1054 /* perturn is defined as: (bulbs produced) - upkeep */
1056 astr_add_line(&str, _("Bulbs per turn: %d - %d = %d"), perturn + upkeep,
1057 upkeep, perturn);
1058 } else {
1059 fc_assert(upkeep == 0);
1060 astr_add_line(&str, _("Bulbs per turn: %d"), perturn);
1061 }
1062 {
1064
1068 astr_add_line(&str, _("Culture: %d (%+d/turn)"),
1070 }
1071 }
1072
1073 /* See also get_global_warming_tooltip() and get_nuclear_winter_tooltip(). */
1074
1075 if (game.info.global_warming) {
1076 int chance, rate;
1078 astr_add_line(&str, _("Global warming chance: %d%% (%+d%%/turn)"),
1079 chance, rate);
1080 } else {
1081 astr_add_line(&str, _("Global warming deactivated."));
1082 }
1083
1084 if (game.info.nuclear_winter) {
1085 int chance, rate;
1087 astr_add_line(&str, _("Nuclear winter chance: %d%% (%+d%%/turn)"),
1088 chance, rate);
1089 } else {
1090 astr_add_line(&str, _("Nuclear winter deactivated."));
1091 }
1092
1093 if (NULL != client.conn.playing) {
1094 astr_add_line(&str, _("Government: %s"),
1096 }
1097
1098 return astr_str(&str);
1099}
1100
1101/************************************************************************/
1108const char *get_unit_info_label_text1(struct unit_list *punits)
1109{
1110 static struct astring str = ASTRING_INIT;
1111
1112 astr_clear(&str);
1113
1114 if (punits) {
1115 int count = unit_list_size(punits);
1116
1117 if (count == 1) {
1119 } else {
1120 astr_add(&str, PL_("%d unit", "%d units", count), count);
1121 }
1122 }
1123 return astr_str(&str);
1124}
1125
1126/************************************************************************/
1133const char *get_unit_info_label_text2(struct unit_list *punits, int linebreaks)
1134{
1135 static struct astring str = ASTRING_INIT;
1136 int count;
1137
1138 astr_clear(&str);
1139
1140 if (!punits) {
1141 return "";
1142 }
1143
1144 count = unit_list_size(punits);
1145
1146 /* This text should always have the same number of lines if
1147 * 'linebreaks' has no flags at all. Otherwise the GUI widgets may be
1148 * confused and try to resize themselves. If caller asks for
1149 * conditional 'linebreaks', it should take care of these problems
1150 * itself. */
1151
1152 /* Line 1. Goto or activity text. */
1153 if (count > 0 && hover_state != HOVER_NONE) {
1154 int min, max;
1155
1156 if (!goto_get_turns(&min, &max)) {
1157 /* TRANS: Impossible to reach goto target tile */
1158 astr_add_line(&str, "%s", Q_("?goto:Unreachable"));
1159 } else if (min == max) {
1160 astr_add_line(&str, _("Turns to target: %d"), max);
1161 } else {
1162 astr_add_line(&str, _("Turns to target: %d to %d"), min, max);
1163 }
1164 } else if (count == 1) {
1165 struct astring addition = ASTRING_INIT;
1166
1170 } else if (count > 1) {
1171 astr_add_line(&str, PL_("%d unit selected",
1172 "%d units selected",
1173 count),
1174 count);
1175 } else {
1176 astr_add_line(&str, _("No units selected."));
1177 }
1178
1179 /* Lines 2, 3, 4, and possible 5 vary. */
1180 if (count == 1) {
1181 struct unit *punit = unit_list_get(punits, 0);
1182 struct player *owner = unit_owner(punit);
1184 punit->homecity);
1185
1187 linebreaks));
1188 {
1190
1191 if (*infratext != '\0') {
1192 astr_add_line(&str, "%s", infratext);
1193 } else {
1194 astr_add_line(&str, " ");
1195 }
1196 }
1197 if (pcity) {
1199 } else {
1200 astr_add_line(&str, " ");
1201 }
1202
1204 struct player *nationality = unit_nationality(punit);
1205
1206 /* Line 5, nationality text */
1207 if (nationality != NULL && owner != nationality) {
1208 /* TRANS: Nationality of the people comprising a unit, if
1209 * different from owner. */
1210 astr_add_line(&str, _("%s people"),
1211 nation_adjective_for_player(nationality));
1212 } else {
1213 astr_add_line(&str, " ");
1214 }
1215 }
1216
1217 } else if (count > 1) {
1218 int mil = 0, nonmil = 0;
1219 int types_count[U_LAST], i;
1220 struct unit_type *top[3];
1221
1222 memset(types_count, 0, sizeof(types_count));
1225 nonmil++;
1226 } else {
1227 mil++;
1228 }
1231
1232 top[0] = top[1] = top[2] = NULL;
1233 unit_type_iterate(utype) {
1234 if (!top[2]
1235 || types_count[utype_index(top[2])] < types_count[utype_index(utype)]) {
1236 top[2] = utype;
1237
1238 if (!top[1]
1239 || types_count[utype_index(top[1])] < types_count[utype_index(top[2])]) {
1240 top[2] = top[1];
1241 top[1] = utype;
1242
1243 if (!top[0]
1244 || types_count[utype_index(top[0])] < types_count[utype_index(utype)]) {
1245 top[1] = top[0];
1246 top[0] = utype;
1247 }
1248 }
1249 }
1251
1252 for (i = 0; i < 2; i++) {
1253 if (top[i] && types_count[utype_index(top[i])] > 0) {
1254 if (utype_has_flag(top[i], UTYF_CIVILIAN)) {
1255 nonmil -= types_count[utype_index(top[i])];
1256 } else {
1257 mil -= types_count[utype_index(top[i])];
1258 }
1259 astr_add_line(&str, "%d: %s",
1260 types_count[utype_index(top[i])],
1262 } else {
1263 astr_add_line(&str, " ");
1264 }
1265 }
1266
1267 if (top[2] && types_count[utype_index(top[2])] > 0
1268 && types_count[utype_index(top[2])] == nonmil + mil) {
1269 astr_add_line(&str, "%d: %s", types_count[utype_index(top[2])],
1270 utype_name_translation(top[2]));
1271 } else if (nonmil > 0 && mil > 0) {
1272 astr_add_line(&str, _("Others: %d civil; %d military"), nonmil, mil);
1273 } else if (nonmil > 0) {
1274 astr_add_line(&str, _("Others: %d civilian"), nonmil);
1275 } else if (mil > 0) {
1276 astr_add_line(&str, _("Others: %d military"), mil);
1277 } else {
1278 astr_add_line(&str, " ");
1279 }
1280
1282 astr_add_line(&str, " ");
1283 }
1284 } else {
1285 astr_add_line(&str, " ");
1286 astr_add_line(&str, " ");
1287 astr_add_line(&str, " ");
1288
1290 astr_add_line(&str, " ");
1291 }
1292 }
1293
1294 /* Line 5/6. Debug text. */
1295#ifdef FREECIV_DEBUG
1296 if (count == 1) {
1297 astr_add_line(&str, "(Unit ID %d)", unit_list_get(punits, 0)->id);
1298 } else {
1299 astr_add_line(&str, " ");
1300 }
1301#endif /* FREECIV_DEBUG */
1302
1303 return astr_str(&str);
1304}
1305
1306/************************************************************************/
1312 struct unit_list *punits)
1313{
1314 if (unit_list_size(punits) == 0) {
1315 fc_snprintf(buf, bufsz, _("No units to upgrade!"));
1316 return FALSE;
1317 } else if (unit_list_size(punits) == 1) {
1319 } else {
1320 int upgrade_cost = 0;
1321 int num_upgraded = 0;
1323
1326 && UU_OK == unit_upgrade_test(&(wld.map), punit, FALSE)) {
1327 const struct unit_type *from_unittype = unit_type_get(punit);
1332
1333 num_upgraded++;
1334 upgrade_cost += cost;
1336 }
1338 if (num_upgraded == 0) {
1339 fc_snprintf(buf, bufsz, _("None of these units may be upgraded."));
1340 return FALSE;
1341 } else {
1342 /* This may trigger sometimes if you don't have enough money for
1343 * a full upgrade. If you have enough to upgrade at least one, it
1344 * will do it. */
1345 /* Construct prompt in several parts to allow separate pluralisation
1346 * by localizations */
1348
1349 fc_snprintf(tbuf, ARRAY_SIZE(tbuf), PL_("Treasury contains %d gold.",
1350 "Treasury contains %d gold.",
1351 client_player()->economic.gold),
1352 client_player()->economic.gold);
1353 /* TRANS: this whole string is a sentence fragment that is only ever
1354 * used by including it in another string (search comments for this
1355 * string to find it) */
1356 fc_snprintf(ubuf, ARRAY_SIZE(ubuf), PL_("Upgrade %d unit",
1357 "Upgrade %d units",
1358 num_upgraded),
1359 num_upgraded);
1360 /* TRANS: This is complicated. The first %s is a pre-pluralised
1361 * sentence fragment "Upgrade %d unit(s)"; the second is pre-pluralised
1362 * "Treasury contains %d gold." So the whole thing reads
1363 * "Upgrade 13 units for 1000 gold?\nTreasury contains 2000 gold." */
1364 fc_snprintf(buf, bufsz, PL_("%s for %d gold?\n%s",
1365 "%s for %d gold?\n%s", upgrade_cost),
1367 return TRUE;
1368 }
1369 }
1370}
1371
1372/************************************************************************/
1378 struct unit_list *punits)
1379{
1380 if (unit_list_size(punits) == 0) {
1381 fc_snprintf(buf, bufsz, _("No units to disband!"));
1382 return FALSE;
1383 } else if (unit_list_size(punits) == 1) {
1386 fc_snprintf(buf, bufsz, _("%s refuses to disband!"),
1388 return FALSE;
1389 } else {
1390 /* TRANS: %s is a unit type */
1391 fc_snprintf(buf, bufsz, _("Disband %s?"),
1393 return TRUE;
1394 }
1395 } else {
1396 int count = 0;
1397
1400 count++;
1401 }
1403 if (count == 0) {
1404 fc_snprintf(buf, bufsz, _("None of these units may be disbanded."));
1405 return FALSE;
1406 } else {
1407 /* TRANS: %d is never 0 or 1 */
1408 fc_snprintf(buf, bufsz, PL_("Disband %d unit?",
1409 "Disband %d units?", count), count);
1410 return TRUE;
1411 }
1412 }
1413}
1414
1415/************************************************************************/
1421const char *get_bulb_tooltip(void)
1422{
1423 static struct astring str = ASTRING_INIT;
1424
1425 astr_clear(&str);
1426
1427 astr_add_line(&str, _("Shows your progress in "
1428 "researching the current technology."));
1429
1430 if (NULL != client.conn.playing) {
1432
1433 if (research->researching == A_UNSET) {
1434 astr_add_line(&str, _("No research target."));
1435 } else {
1436 int turns;
1439
1440 if ((turns = turns_to_research_done(research, perturn)) >= 0) {
1441 astr_set(&buf1, PL_("%d turn", "%d turns", turns), turns);
1442 } else if ((turns = turns_to_tech_loss(research, perturn)) >= 0) {
1443 astr_set(&buf1, PL_("%d turn to loss", "%d turns to loss", turns),
1444 turns);
1445 } else {
1446 if (perturn < 0) {
1447 astr_set(&buf1, _("Decreasing"));
1448 } else {
1449 astr_set(&buf1, _("No progress"));
1450 }
1451 }
1452
1453 /* TRANS: <perturn> bulbs/turn */
1454 astr_set(&buf2, PL_("%d bulb/turn", "%d bulbs/turn", perturn), perturn);
1455
1456 /* TRANS: <tech>: <amount>/<total bulbs> */
1457 astr_add_line(&str, _("%s: %d/%d (%s, %s)."),
1462 astr_str(&buf1), astr_str(&buf2));
1463
1464 astr_free(&buf1);
1465 astr_free(&buf2);
1466 }
1467 }
1468
1469 return astr_str(&str);
1470}
1471
1472/************************************************************************/
1479{
1480 static struct astring str = ASTRING_INIT;
1481
1482 astr_clear(&str);
1483
1484 if (!game.info.global_warming) {
1485 astr_add_line(&str, _("Global warming deactivated."));
1486 } else {
1487 int chance, rate;
1488
1490 astr_add_line(&str, _("Shows the progress of global warming:"));
1491 astr_add_line(&str, _("Pollution rate: %d%%"), rate);
1492 astr_add_line(&str, _("Chance of catastrophic warming each turn: %d%%"),
1493 chance);
1494 }
1495
1496 return astr_str(&str);
1497}
1498
1499/************************************************************************/
1506{
1507 static struct astring str = ASTRING_INIT;
1508
1509 astr_clear(&str);
1510
1511 if (!game.info.nuclear_winter) {
1512 astr_add_line(&str, _("Nuclear winter deactivated."));
1513 } else {
1514 int chance, rate;
1515
1517 astr_add_line(&str, _("Shows the progress of nuclear winter:"));
1518 astr_add_line(&str, _("Fallout rate: %d%%"), rate);
1519 astr_add_line(&str, _("Chance of catastrophic winter each turn: %d%%"),
1520 chance);
1521 }
1522
1523 return astr_str(&str);
1524}
1525
1526/************************************************************************/
1532const char *get_government_tooltip(void)
1533{
1534 static struct astring str = ASTRING_INIT;
1535
1536 astr_clear(&str);
1537
1538 astr_add_line(&str, _("Shows your current government:"));
1539
1540 if (NULL != client.conn.playing) {
1541 astr_add_line(&str, "%s",
1543 }
1544
1545 return astr_str(&str);
1546}
1547
1548/************************************************************************/
1555{
1556 struct player_spaceship ship;
1557 static struct astring str = ASTRING_INIT;
1558
1559 astr_clear(&str);
1560
1561 if (!pship) {
1562 pship = &ship;
1563 memset(&ship, 0, sizeof(ship));
1564 }
1565
1566 /* TRANS: spaceship text; should have constant width. */
1567 astr_add_line(&str, _("Population: %5d"), pship->population);
1568
1569 /* TRANS: spaceship text; should have constant width. */
1570 astr_add_line(&str, _("Support: %5d %%"),
1571 (int) (pship->support_rate * 100.0));
1572
1573 /* TRANS: spaceship text; should have constant width. */
1574 astr_add_line(&str, _("Energy: %5d %%"),
1575 (int) (pship->energy_rate * 100.0));
1576
1577 /* TRANS: spaceship text; should have constant width. */
1578 astr_add_line(&str, PL_("Mass: %5d ton",
1579 "Mass: %5d tons",
1580 pship->mass), pship->mass);
1581
1582 if (pship->propulsion > 0) {
1583 /* TRANS: spaceship text; should have constant width. */
1584 astr_add_line(&str, _("Travel time: %5.1f years"),
1585 (float) (0.1 * ((int) (pship->travel_time * 10.0))));
1586 } else {
1587 /* TRANS: spaceship text; should have constant width. */
1588 astr_add_line(&str, "%s", _("Travel time: N/A "));
1589 }
1590
1591 /* TRANS: spaceship text; should have constant width. */
1592 astr_add_line(&str, _("Success prob.: %5d %%"),
1593 (int) (pship->success_rate * 100.0));
1594
1595 /* TRANS: spaceship text; should have constant width. */
1596 astr_add_line(&str, _("Year of arrival: %8s"),
1597 (pship->state == SSHIP_LAUNCHED)
1598 ? textyear((int) (pship->launch_year +
1599 (int) pship->travel_time))
1600 : "- ");
1601
1602 return astr_str(&str);
1603}
1604
1605/************************************************************************/
1611const char *get_timeout_label_text(void)
1612{
1613 static struct astring str = ASTRING_INIT;
1614
1615 astr_clear(&str);
1616
1619
1620 if (wt <= 0) {
1621 astr_add(&str, "%s", Q_("?timeout:wait"));
1622 } else {
1623 astr_add(&str, "%s: %s", Q_("?timeout:eta"), format_duration(wt));
1624 }
1625 } else {
1626 if (current_turn_timeout() <= 0) {
1627 astr_add(&str, "%s", Q_("?timeout:off"));
1628 } else {
1630 }
1631 }
1632
1633 return astr_str(&str);
1634}
1635
1636/************************************************************************/
1644static const char *format_duration(int duration)
1645{
1646 static struct astring str = ASTRING_INIT;
1647
1648 astr_clear(&str);
1649
1650 if (duration < 0) {
1651 duration = 0;
1652 }
1653 if (duration < 60) {
1654 astr_add(&str, Q_("?seconds:%02ds"), duration);
1655 } else if (duration < 3600) { /* < 60 minutes */
1656 astr_add(&str, Q_("?mins/secs:%02dm %02ds"), duration / 60, duration % 60);
1657 } else if (duration < 360000) { /* < 100 hours */
1658 astr_add(&str, Q_("?hrs/mns:%02dh %02dm"), duration / 3600, (duration / 60) % 60);
1659 } else if (duration < 8640000) { /* < 100 days */
1660 astr_add(&str, Q_("?dys/hrs:%02dd %02dh"), duration / 86400,
1661 (duration / 3600) % 24);
1662 } else {
1663 astr_add(&str, "%s", Q_("?duration:overflow"));
1664 }
1665
1666 return astr_str(&str);
1667}
1668
1669/************************************************************************/
1675const char *get_ping_time_text(const struct player *pplayer)
1676{
1677 static struct astring str = ASTRING_INIT;
1678
1679 astr_clear(&str);
1680
1682 if (!pconn->observer
1683 /* Certainly not needed, but safer. */
1684 && 0 == strcmp(pconn->username, pplayer->username)) {
1685 if (pconn->ping_time >= 0) {
1686 double ping_time_in_ms = 1000 * pconn->ping_time;
1687
1688 astr_add(&str, _("%6d.%02d ms"), (int) ping_time_in_ms,
1689 ((int) (ping_time_in_ms * 100.0)) % 100);
1690 }
1691 break;
1692 }
1694
1695 return astr_str(&str);
1696}
1697
1698/************************************************************************/
1704const char *get_score_text(const struct player *pplayer)
1705{
1706 static struct astring str = ASTRING_INIT;
1707
1708 astr_clear(&str);
1709
1710 if (pplayer->score.game >= 0) {
1711 astr_add(&str, "%d", pplayer->score.game);
1712 } else {
1713 astr_add(&str, "?");
1714 }
1715
1716 return astr_str(&str);
1717}
1718
1719/************************************************************************/
1726const char *get_report_title(const char *report_name)
1727{
1728 static struct astring str = ASTRING_INIT;
1729 const struct player *pplayer = client_player();
1730
1731 astr_clear(&str);
1732
1733 astr_add_line(&str, "%s", report_name);
1734
1735 if (pplayer != NULL) {
1736 char buf[4 * MAX_LEN_NAME];
1737
1738 /* TRANS: <nation adjective> <government name>.
1739 * E.g. "Polish Republic". */
1740 astr_add_line(&str, Q_("?nationgovernment:%s %s"),
1743
1744 /* TRANS: Just appending 2 strings, using the correct localized
1745 * syntax. */
1746 astr_add_line(&str, _("%s - %s"),
1747 ruler_title_for_player(pplayer, buf, sizeof(buf)),
1748 calendar_text());
1749 } else {
1750 /* TRANS: "Observer - 1985 AD" */
1751 astr_add_line(&str, _("Observer - %s"),
1752 calendar_text());
1753 }
1754
1755 return astr_str(&str);
1756}
1757
1758/**********************************************************************/
1765 const struct act_prob prob,
1766 const struct unit *actor_unit,
1767 const struct city *target_city)
1768{
1769 static struct astring custom = ASTRING_INIT;
1770
1772
1773 if (!action_prob_possible(prob)) {
1774 /* No info since impossible. */
1775 return NULL;
1776 }
1777
1779 || target_city != NULL),
1780 NULL);
1781
1783 bool estimated = FALSE;
1788 TRUE);
1789
1791 && target_city->owner != actor_homecity->owner) {
1792 estimated = TRUE;
1793 }
1794 if (revenue > 0) {
1795 if (estimated) {
1797 /* TRANS: estimated one time bonus and recurring revenue for
1798 * the Establish Trade _Route action. */
1799 _("%d estimated one time bonus + %d trade"),
1800 revenue,
1802 } else {
1804 /* TRANS: one time bonus and recurring revenue for
1805 * the Establish Trade _Route action. */
1806 _("%d one time bonus + %d trade"),
1807 revenue,
1809 }
1810 } else {
1812 /* TRANS: recurring revenue for
1813 * the Establish Trade _Route action. */
1814 _("%d trade"),
1816 }
1818 bool estimated = FALSE;
1823 FALSE);
1824
1826 && target_city->owner != actor_homecity->owner) {
1827 estimated = TRUE;
1828 }
1829 if (revenue > 0) {
1830 if (estimated) {
1832 /* TRANS: estimated one time bonus for the Enter Marketplace
1833 * action. */
1834 _("%d estimated one time bonus"), revenue);
1835 } else {
1837 /* TRANS: one time bonus for the Enter Marketplace
1838 * action. */
1839 _("%d one time bonus"), revenue);
1840 }
1841 } else {
1842 /* No info to add. */
1843 return NULL;
1844 }
1848 /* Can only give remaining production for domestic and existing
1849 * cities. */
1851
1852 astr_set(&custom, _("%d remaining"), cost - target_city->shield_stock);
1853 } else {
1854 /* No info to add. */
1855 return NULL;
1856 }
1857
1858 return astr_str(&custom);
1859}
1860
1861/**********************************************************************/
1869const char *act_sel_action_tool_tip(const struct action *paction,
1870 const struct act_prob prob)
1871{
1872 return action_prob_explain(prob);
1873}
1874
1875/************************************************************************/
1880const char *text_happiness_buildings(const struct city *pcity)
1881{
1882 struct effect_list *plist = effect_list_new();
1883 static struct astring str = ASTRING_INIT;
1884
1886 if (0 < effect_list_size(plist)) {
1887 struct astring effects = ASTRING_INIT;
1888
1890 astr_set(&str, _("Buildings: %s."), astr_str(&effects));
1892 } else {
1893 astr_set(&str, _("Buildings: None."));
1894 }
1896
1897 /* Add line breaks after 80 characters. */
1898 astr_break_lines(&str, 80);
1899
1900 return astr_str(&str);
1901}
1902
1903/************************************************************************/
1908const char *text_happiness_nationality(const struct city *pcity)
1909{
1910 static struct astring str = ASTRING_INIT;
1911 int enemies = 0;
1912
1913 astr_clear(&str);
1914
1915 astr_add_line(&str, _("Nationality: "));
1916
1919 struct player *owner = city_owner(pcity);
1920
1921 citizens_foreign_iterate(pcity, pslot, nationality) {
1923 enemies += nationality;
1924 }
1926
1927 if (enemies > 0) {
1928 astr_add(&str, PL_("%d enemy nationalist", "%d enemy nationalists", enemies),
1929 enemies);
1930 }
1931 }
1932
1933 if (enemies == 0) {
1934 /* TRANS: No enemy nationalities, as there's no enemies present. */
1935 astr_add(&str, _("None."));
1936 }
1937 } else {
1938 /* TRANS: No nationalities present. */
1939 astr_add(&str, _("Disabled."));
1940 }
1941
1942 return astr_str(&str);
1943}
1944
1945/************************************************************************/
1950const char *text_happiness_wonders(const struct city *pcity)
1951{
1952 struct effect_list *plist = effect_list_new();
1953 static struct astring str = ASTRING_INIT;
1954
1958 if (0 < effect_list_size(plist)) {
1959 struct astring effects = ASTRING_INIT;
1960
1962 astr_set(&str, _("Wonders: %s."), astr_str(&effects));
1964 } else {
1965 astr_set(&str, _("Wonders: None."));
1966 }
1967
1968 /* Add line breaks after 80 characters. */
1969 astr_break_lines(&str, 80);
1971
1972 return astr_str(&str);
1973}
1974
1975/************************************************************************/
1980const char *text_happiness_cities(const struct city *pcity)
1981{
1982 struct player *pplayer = city_owner(pcity);
1983 int cities = city_list_size(pplayer->cities);
1984 int content = get_player_bonus(pplayer, EFT_CITY_UNHAPPY_SIZE);
1987 static struct astring str = ASTRING_INIT;
1988
1989 astr_clear(&str);
1990
1991 if (basis+step <= 0) {
1992 /* Special case where penalty is disabled; see
1993 * player_content_citizens(). */
1995 PL_("Cities: %d total, but no penalty for empire size.",
1996 "Cities: %d total, but no penalty for empire size.",
1997 cities),
1998 cities);
2000 /* TRANS: %d is number of citizens */
2001 PL_("%d content per city.",
2002 "%d content per city.", content),
2003 content);
2004 } else {
2005 /* Can have up to and including 'basis' cities without penalty */
2006 int excess = MAX(cities - basis, 0);
2007 int penalty;
2008 int unhappy, angry;
2009 int last, next;
2010
2011 if (excess > 0) {
2012 if (step > 0) {
2013 penalty = 1 + (excess - 1) / step;
2014 } else {
2015 penalty = 1;
2016 }
2017 } else {
2018 penalty = 0;
2019 }
2020
2021 unhappy = MIN(penalty, content);
2022 angry = game.info.angrycitizen ? MAX(penalty-content, 0) : 0;
2023 if (penalty >= 1) {
2024 /* 'last' is when last actual malcontent appeared, will saturate
2025 * if no angry citizens */
2026 last = basis + (unhappy+angry-1)*step;
2027 if (!game.info.angrycitizen && unhappy == content) {
2028 /* Maxed out unhappy citizens, so no more penalties */
2029 next = 0;
2030 } else {
2031 /* Angry citizens can continue appearing indefinitely */
2032 next = last + step;
2033 }
2034 } else {
2035 last = 0;
2036 next = basis;
2037 }
2038
2040 /* TRANS: sentence fragment, will have text appended */
2041 PL_("Cities: %d total:",
2042 "Cities: %d total:", cities),
2043 cities);
2044 if (excess > 0) {
2045 astr_add(&str,
2046 /* TRANS: appended to "Cities: %d total:"; preserve leading
2047 * space. Pluralized in "nearest threshold of %d cities". */
2048 PL_(" %d over nearest threshold of %d city.",
2049 " %d over nearest threshold of %d cities.", last),
2050 cities - last, last);
2052 /* TRANS: Number of content [citizen(s)] ... */
2053 PL_("%d content before penalty.",
2054 "%d content before penalty.", content),
2055 content);
2057 PL_("%d additional unhappy citizen.",
2058 "%d additional unhappy citizens.", unhappy),
2059 unhappy);
2060 if (angry > 0) {
2062 PL_("%d angry citizen.",
2063 "%d angry citizens.", angry),
2064 angry);
2065 }
2066 } else {
2067 astr_add(&str,
2068 /* TRANS: appended to "Cities: %d total:"; preserve leading
2069 * space. */
2070 PL_(" not more than %d, so no empire size penalty.",
2071 " not more than %d, so no empire size penalty.", next),
2072 next);
2074 /* TRANS: %d is number of citizens */
2075 PL_("%d content per city.",
2076 "%d content per city.", content),
2077 content);
2078 }
2079 if (next >= cities && penalty < content) {
2081 PL_("With %d more city, another citizen will become "
2082 "unhappy.",
2083 "With %d more cities, another citizen will become "
2084 "unhappy.",
2085 next + 1 - cities),
2086 next + 1 - cities);
2087 } else if (next >= cities) {
2088 /* We maxed out the number of unhappy citizens, but they can get
2089 * angry instead. */
2092 PL_("With %d more city, another citizen will become "
2093 "angry.",
2094 "With %d more cities, another citizen will become "
2095 "angry.",
2096 next + 1 - cities),
2097 next + 1 - cities);
2098 } else {
2099 /* Either no Empire_Size_Step, or we maxed out on unhappy citizens
2100 * and ruleset doesn't allow angry ones. */
2102 _("More cities will not cause more unhappy citizens."));
2103 }
2104 }
2105
2106 return astr_str(&str);
2107}
2108
2109/************************************************************************/
2114const char *text_happiness_units(const struct city *pcity)
2115{
2118 static struct astring str = ASTRING_INIT;
2119
2120 astr_clear(&str);
2121
2122 if (mlmax > 0) {
2124
2125 if (mlmax == 100) {
2126 astr_add_line(&str, "%s", _("Unlimited martial law in effect."));
2127 } else {
2128 astr_add_line(&str, PL_("%d military unit may impose martial law.",
2129 "Up to %d military units may impose martial "
2130 "law.", mlmax), mlmax);
2131 }
2132 astr_add_line(&str, PL_("Each military unit makes %d "
2133 "unhappy citizen content.",
2134 "Each military unit makes %d "
2135 "unhappy citizens content.",
2136 mleach), mleach);
2137 } else if (uhcfac > 0) {
2139 _("Military units in the field may cause unhappiness. "));
2140 } else {
2142 _("Military units have no happiness effect. "));
2143 }
2144
2145 return astr_str(&str);
2146}
2147
2148/************************************************************************/
2153const char *text_happiness_luxuries(const struct city *pcity)
2154{
2155 static struct astring str = ASTRING_INIT;
2156
2157 astr_clear(&str);
2158
2160 _("Luxury: %d total."),
2161 pcity->prod[O_LUXURY]);
2162
2163 return astr_str(&str);
2164}
2165
2166/************************************************************************/
2170const char *production_help(const struct universal *uni, char *buf,
2171 size_t bufsize)
2172{
2173 buf[0] = '\0';
2174 int segments = 0;
2175
2176 if (uni->kind == VUT_UTYPE) {
2177 if (uni->value.utype->helptext != NULL) {
2178 strvec_iterate(uni->value.utype->helptext, text) {
2179 if (segments++) {
2180 cat_snprintf(buf, bufsize, "\n\n");
2181 }
2182 cat_snprintf(buf, bufsize, "%s", _(text));
2184 }
2185 } else {
2187
2188 if (uni->value.building->helptext != NULL) {
2189 strvec_iterate(uni->value.building->helptext, text) {
2190 if (segments++) {
2191 cat_snprintf(buf, bufsize, "\n\n");
2192 }
2193 cat_snprintf(buf, bufsize, "%s", _(text));
2195 }
2196 }
2197
2198 return buf;
2199}
2200
2201/************************************************************************/
2207const char *score_tooltip(const struct player *pplayer, int score)
2208{
2209 static char buf[1024];
2210 char *relation;
2211
2212 if (client.conn.playing != NULL) {
2213 if (pplayer == client.conn.playing) {
2214 relation = _(" (us)");
2215 } else if (pplayers_allied(pplayer, client.conn.playing)) {
2216 relation = _(" (an ally)");
2217 } else if (player_diplstate_get(pplayer, client.conn.playing)->type == DS_WAR) {
2218 /* Actual enemy; don't want to use pplayers_at_war() that considers also
2219 * never met players enemies. */
2220 relation = _(" (an enemy)");
2221 } else {
2222 relation = "";
2223 }
2224 } else {
2225 relation = "";
2226 }
2227
2228 if (score >= 0) {
2229 /* TRANS: %s is a Nation */
2230 fc_snprintf(buf, sizeof(buf), _("%s%s: score %d"),
2232 score);
2233 } else {
2234 fc_snprintf(buf, sizeof(buf), "%s%s",
2236 }
2237
2238 return buf;
2239}
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:5079
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:184
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:2956
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:834
@ 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:54
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:77
struct unit struct city * target_city
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 int cost
Definition dialogs_g.h:73
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:237
#define MAX_LEN_NAME
Definition fc_types.h:67
@ O_SHIELD
Definition fc_types.h:102
@ O_FOOD
Definition fc_types.h:102
@ O_TRADE
Definition fc_types.h:102
@ O_SCIENCE
Definition fc_types.h:102
@ O_LUXURY
Definition fc_types.h:102
@ O_LAST
Definition fc_types.h:102
signed short Continent_id
Definition fc_types.h:232
#define LINE_BREAK
Definition fc_types.h:78
@ BORDERS_DISABLED
Definition fc_types.h:744
#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:405
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:828
#define nat_x
#define nat_y
int map_signed_latitude(const struct tile *ptile)
Definition map.c:1701
int get_ocean_size(Continent_id id)
Definition map.c:839
int get_island_surrounder(Continent_id id)
Definition map.c:851
int get_lake_surrounder(Continent_id id)
Definition map.c:884
#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
SPECPQ_PRIORITY_TYPE priority
Definition specpq.h:86
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
enum caravan_bonus_style caravan_bonus_style
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:576
Definition unit.h:139
int id
Definition unit.h:146
int homecity
Definition unit.h:147
struct goods_type * carrying
Definition unit.h:188
int veteran
Definition unit.h:153
struct player * owner
Definition unit.h:144
enum universals_n kind
Definition fc_types.h:609
universals_u value
Definition fc_types.h:608
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:376
struct team * team_by_number(const int team_id)
Definition team.c:401
const char * team_name_translation(const struct team *pteam)
Definition team.c:421
#define A_UNSET
Definition tech.h:48
const char * get_infrastructure_text(bv_extras extras)
Definition terrain.c:507
const char * get_government_tooltip(void)
Definition text.c:1532
const char * text_happiness_cities(const struct city *pcity)
Definition text.c:1980
static const char * format_duration(int duration)
Definition text.c:1644
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:1908
#define FAR_CITY_SQUARE_DIST
Definition text.c:489
const char * score_tooltip(const struct player *pplayer, int score)
Definition text.c:2207
const char * text_happiness_wonders(const struct city *pcity)
Definition text.c:1950
bool get_units_upgrade_info(char *buf, size_t bufsz, struct unit_list *punits)
Definition text.c:1311
bool get_units_disband_info(char *buf, size_t bufsz, struct unit_list *punits)
Definition text.c:1377
static int turns_to_research_done(const struct research *presearch, int per_turn)
Definition text.c:747
const char * get_airlift_text(const struct unit_list *punits, const struct city *pdest)
Definition text.c:599
const char * get_info_label_text_popup(void)
Definition text.c:1023
const char * text_happiness_units(const struct city *pcity)
Definition text.c:2114
const char * text_happiness_luxuries(const struct city *pcity)
Definition text.c:2153
const char * science_dialog_text(void)
Definition text.c:795
static int get_bulbs_per_turn(int *pours, bool *pteam, int *ptheirs)
Definition text.c:703
const char * text_happiness_buildings(const struct city *pcity)
Definition text.c:1880
const char * get_ping_time_text(const struct player *pplayer)
Definition text.c:1675
const char * get_report_title(const char *report_name)
Definition text.c:1726
static int turns_to_tech_loss(const struct research *presearch, int per_turn)
Definition text.c:775
const char * get_nuclear_winter_tooltip(void)
Definition text.c:1505
const char * get_score_text(const struct player *pplayer)
Definition text.c:1704
const char * get_science_target_text(double *percent)
Definition text.c:874
const char * get_bulb_tooltip(void)
Definition text.c:1421
const char * get_timeout_label_text(void)
Definition text.c:1611
const char * get_nearest_city_text(struct city *pcity, int sq_dist)
Definition text.c:495
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:1764
const char * popup_info_text(struct tile *ptile)
Definition text.c:147
const char * unit_description(struct unit *punit)
Definition text.c:529
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:1478
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:971
const char * production_help(const struct universal *uni, char *buf, size_t bufsize)
Definition text.c:2170
static int turns_per_advance(const struct research *presearch, int per_turn)
Definition text.c:762
const char * get_science_goal_text(Tech_type_id goal)
Definition text.c:920
const char * get_unit_info_label_text2(struct unit_list *punits, int linebreaks)
Definition text.c:1133
const char * get_unit_info_label_text1(struct unit_list *punits)
Definition text.c:1108
const char * get_spaceship_descr(struct player_spaceship *pship)
Definition text.c:1554
const char * act_sel_action_tool_tip(const struct action *paction, const struct act_prob prob)
Definition text.c:1869
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)
const char * goods_name_translation(struct goods_type *pgood)
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:554
const struct impr_type * building
Definition fc_types.h:547
enum unit_upgrade_result unit_upgrade_info(const struct civ_map *nmap, const struct unit *punit, char *buf, size_t bufsz)
Definition unit.c:2114
struct player * unit_nationality(const struct unit *punit)
Definition unit.c:1300
int unit_bribe_cost(const struct unit *punit, const struct player *briber, const struct unit *briber_unit)
Definition unit.c:2370
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:85
void unit_upkeep_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1286
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:401
int unit_current_good_replace_priority(const struct unit *punit, const struct city *homecity)
Definition unit.c:2983
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1210
enum unit_upgrade_result unit_upgrade_test(const struct civ_map *nmap, const struct unit *punit, bool is_free)
Definition unit.c:2051
bool is_flagless_to_player(const struct unit *punit, const struct player *pplayer)
Definition unit.c:381
#define unit_tile(_pu)
Definition unit.h:406
#define unit_owner(_pu)
Definition unit.h:405
@ UU_OK
Definition unit.h:61
#define unit_home(_pu_)
Definition unit.h:403
unit_airlift_result
Definition unit.h:72
@ AR_SRC_NO_FLIGHTS
Definition unit.h:84
@ AR_OK_SRC_UNKNOWN
Definition unit.h:75
@ AR_OK_DST_UNKNOWN
Definition unit.h:76
@ AR_NO_MOVES
Definition unit.h:78
@ AR_BAD_DST_CITY
Definition unit.h:83
@ AR_NOT_IN_CITY
Definition unit.h:81
@ AR_OCCUPIED
Definition unit.h:80
@ AR_OK
Definition unit.h:74
@ AR_DST_NO_FLIGHTS
Definition unit.h:85
@ AR_WRONG_UNITTYPE
Definition unit.h:79
@ AR_BAD_SRC_CITY
Definition unit.h:82
#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:2614
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:1573
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1707
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Definition unittype.c:194
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:1564
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Definition unittype.c:375
int unit_upgrade_price(const struct player *pplayer, const struct unit_type *from, const struct unit_type *to)
Definition unittype.c:1735
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:622
#define unit_type_iterate(_p)
Definition unittype.h:860
#define U_LAST
Definition unittype.h:40
#define unit_type_iterate_end
Definition unittype.h:867