Freeciv-3.2
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
168 astr_clear(&str);
170 astr_add_line(&str, _("Location: (%d, %d) [%d]"),
171 tile_x, tile_y, tile_continent(ptile));
173 astr_add_line(&str, _("Native coordinates: (%d, %d)"),
174 nat_x, nat_y);
175 astr_add_line(&str, _("Latitude: %d"),
176 map_signed_latitude(ptile));
177
178 if (client_tile_get_known(ptile) == TILE_UNKNOWN) {
179 astr_add(&str, _("Unknown"));
180 return astr_str(&str);
181 }
182 astr_add_line(&str, _("Terrain: %s"), tile_get_info_text(ptile, TRUE, 0));
183 astr_add_line(&str, _("Food/Prod/Trade: %s"),
184 get_tile_output_text(ptile));
185 first = TRUE;
186 extra_type_iterate(pextra) {
187 if (pextra->category == ECAT_BONUS && tile_has_visible_extra(ptile, pextra)) {
188 if (!first) {
189 astr_add(&str, ",%s", extra_name_translation(pextra));
190 } else {
192 first = FALSE;
193 }
194 }
196 if (BORDERS_DISABLED != game.info.borders && !pcity) {
197 struct player *owner = tile_owner(ptile);
198
201
203 astr_add_line(&str, _("Our territory"));
204 } else if (NULL != owner && NULL == client.conn.playing) {
205 /* TRANS: "Territory of <username> (<nation + team>)" */
206 astr_add_line(&str, _("Territory of %s (%s)"), username, nation);
207 } else if (NULL != owner) {
209 owner);
210
211 if (ds->type == DS_CEASEFIRE) {
212 int turns = ds->turns_left;
213
215 /* TRANS: "Territory of <username> (<nation + team>)
216 * (<number> turn cease-fire)" */
217 PL_("Territory of %s (%s) (%d turn cease-fire)",
218 "Territory of %s (%s) (%d turn cease-fire)",
219 turns),
220 username, nation, turns);
221 } else if (ds->type == DS_ARMISTICE) {
222 int turns = ds->turns_left;
223
225 /* TRANS: "Territory of <username> (<nation + team>)
226 * (<number> turn armistice)" */
227 PL_("Territory of %s (%s) (%d turn armistice)",
228 "Territory of %s (%s) (%d turn armistice)",
229 turns),
230 username, nation, turns);
231 } else {
232 int type = ds->type;
233
234 /* TRANS: "Territory of <username>
235 * (<nation + team> | <diplomatic state>)" */
236 astr_add_line(&str, _("Territory of %s (%s | %s)"),
237 username, nation,
239 }
240 } else {
241 astr_add_line(&str, _("Unclaimed territory"));
242 }
243 }
244 if (pcity) {
245 /* Look at city owner, not tile owner (the two should be the same, if
246 * borders are in use). */
247 struct player *owner = city_owner(pcity);
248 const char *improvements[improvement_count()];
249 int has_improvements = 0;
250
253
255 /* TRANS: "City: <city name> | <username> (<nation + team>)" */
256 astr_add_line(&str, _("City: %s | %s (%s)"),
257 city_name_get(pcity), username, nation);
258 } else {
259 struct player_diplstate *ds
261 if (ds->type == DS_CEASEFIRE) {
262 int turns = ds->turns_left;
263
264 /* TRANS: "City: <city name> | <username>
265 * (<nation + team>, <number> turn cease-fire)" */
266 astr_add_line(&str, PL_("City: %s | %s (%s, %d turn cease-fire)",
267 "City: %s | %s (%s, %d turn cease-fire)",
268 turns),
269 city_name_get(pcity), username, nation, turns);
270 } else if (ds->type == DS_ARMISTICE) {
271 int turns = ds->turns_left;
272
273 /* TRANS: "City: <city name> | <username>
274 * (<nation + team>, <number> turn armistice)" */
275 astr_add_line(&str, PL_("City: %s | %s (%s, %d turn armistice)",
276 "City: %s | %s (%s, %d turn armistice)",
277 turns),
278 city_name_get(pcity), username, nation, turns);
279 } else {
280 /* TRANS: "City: <city name> | <username>
281 * (<nation + team>, <diplomatic state>)" */
282 astr_add_line(&str, _("City: %s | %s (%s, %s)"),
283 city_name_get(pcity), username, nation,
285 }
286 }
288 int count = unit_list_size(ptile->units);
289
290 if (count > 0) {
291 /* TRANS: preserve leading space */
292 astr_add(&str, PL_(" | Occupied with %d unit.",
293 " | Occupied with %d units.", count), count);
294 } else {
295 /* TRANS: preserve leading space */
296 astr_add(&str, _(" | Not occupied."));
297 }
298 } else {
299 if (city_is_occupied(pcity)) {
300 /* TRANS: preserve leading space */
301 astr_add(&str, _(" | Occupied."));
302 } else {
303 /* TRANS: preserve leading space */
304 astr_add(&str, _(" | Not occupied."));
305 }
306 }
307 improvement_iterate(pimprove) {
308 if (is_improvement_visible(pimprove)
309 && city_has_building(pcity, pimprove)) {
310 improvements[has_improvements++] =
312 }
314
315 if (0 < has_improvements) {
316 struct astring list = ASTRING_INIT;
317
319 /* TRANS: %s is a list of "and"-separated improvements. */
320 astr_add_line(&str, _(" with %s."), astr_str(&list));
321 astr_free(&list);
322 }
323
325 struct city *hcity = game_city_by_number(pfocus_unit->homecity);
326
328 && can_cities_trade(hcity, pcity)
329 && can_establish_trade_route(hcity, pcity)) {
330 /* TRANS: "Trade from Warsaw: 5" */
331 astr_add_line(&str, _("Trade from %s: %d"),
334 }
336 }
337 {
338 const char *infratext = get_infrastructure_text(ptile->extras);
339
340 if (*infratext != '\0') {
341 astr_add_line(&str, _("Infrastructure: %s"), infratext);
342 }
343 }
345 if (strlen(activity_text) > 0) {
346 astr_add_line(&str, _("Activity: %s"), activity_text);
347 }
348 if (punit && !pcity) {
349 struct player *owner = unit_owner(punit);
350 const struct unit_type *ptype = unit_type_get(punit);
351
352 get_full_username(username, sizeof(username), owner);
353 get_full_nation(nation, sizeof(nation), owner);
354
355 if (!client_player() || owner == client_player()) {
357
358 /* TRANS: "Unit: <unit type> | <username> (<nation + team>)" */
359 astr_add_line(&str, _("Unit: %s | %s (%s)"),
360 utype_name_translation(ptype), username, nation);
361
364 if (hcity != NULL) {
365 /* TRANS: on own line immediately following \n, "from <city> |
366 * <nationality> people" */
367 astr_add_line(&str, _("from %s | %s people"), city_name_get(hcity),
369 } else {
370 /* TRANS: Nationality of the people comprising a unit, if
371 * different from owner. */
372 astr_add_line(&str, _("%s people"),
374 }
375 } else if (hcity != NULL) {
376 /* TRANS: on own line immediately following \n, ... <city> */
377 astr_add_line(&str, _("from %s"), city_name_get(hcity));
378 }
379 } else if (NULL != owner) {
381 owner);
382 if (ds->type == DS_CEASEFIRE) {
383 int turns = ds->turns_left;
384
385 /* TRANS: "Unit: <unit type> | <username> (<nation + team>,
386 * <number> turn cease-fire)" */
387 astr_add_line(&str, PL_("Unit: %s | %s (%s, %d turn cease-fire)",
388 "Unit: %s | %s (%s, %d turn cease-fire)",
389 turns),
391 username, nation, turns);
392 } else if (ds->type == DS_ARMISTICE) {
393 int turns = ds->turns_left;
394
395 /* TRANS: "Unit: <unit type> | <username> (<nation + team>,
396 * <number> turn armistice)" */
397 astr_add_line(&str, PL_("Unit: %s | %s (%s, %d turn armistice)",
398 "Unit: %s | %s (%s, %d turn armistice)",
399 turns),
401 username, nation, turns);
402 } else {
403 /* TRANS: "Unit: <unit type> | <username> (<nation + team>,
404 * <diplomatic state>)" */
405 astr_add_line(&str, _("Unit: %s | %s (%s, %s)"),
406 utype_name_translation(ptype), username, nation,
408 }
409 }
410
412
415 /* Show bribe cost for own units. */
416 astr_add_line(&str, _("Probable bribe cost: %d"),
418 } else {
419 /* We can only give an (lower) boundary for units of other players. */
420 astr_add_line(&str, _("Estimated bribe cost: > %d"),
422 }
423
425 && unit_list_size(ptile->units) >= 2) {
426 /* TRANS: "5 more" units on this tile */
427 astr_add(&str, _(" (%d more)"), unit_list_size(ptile->units) - 1);
428 }
429 }
430
432 return astr_str(&str);
433}
434
435#define FAR_CITY_SQUARE_DIST (2*(6*6))
436/************************************************************************/
441const char *get_nearest_city_text(struct city *pcity, int sq_dist)
442{
443 static struct astring str = ASTRING_INIT;
444
445 astr_clear(&str);
446
447 /* Just to be sure */
448 if (!pcity) {
449 sq_dist = -1;
450 }
451
453 /* TRANS: on own line immediately following \n, ... <city> */
454 ? _("far from %s")
455 : (sq_dist > 0)
456 /* TRANS: on own line immediately following \n, ... <city> */
457 ? _("near %s")
458 : (sq_dist == 0)
459 /* TRANS: on own line immediately following \n, ... <city> */
460 ? _("in %s")
461 : "%s",
462 pcity
463 ? city_name_get(pcity)
464 : "");
465
466 return astr_str(&str);
467}
468
469/************************************************************************/
475const char *unit_description(struct unit *punit)
476{
477 int pcity_near_dist;
478 struct player *owner = unit_owner(punit);
479 struct player *nationality = unit_nationality(punit);
480 struct city *pcity =
483 const struct unit_type *ptype = unit_type_get(punit);
484 static struct astring str = ASTRING_INIT;
485 const struct player *pplayer = client_player();
486
487 astr_clear(&str);
488
490
491 {
492 const char *veteran_name =
494 if (veteran_name) {
495 astr_add(&str, " (%s)", veteran_name);
496 }
497 }
498
499 if (pplayer == owner) {
501 } else {
502 astr_add(&str, "\n");
503 }
505
506 if (pcity) {
507 /* TRANS: on own line immediately following \n, ... <city> */
508 astr_add_line(&str, _("from %s"), city_name_get(pcity));
509 } else {
510 astr_add(&str, "\n");
511 }
513 if (nationality != NULL && owner != nationality) {
514 /* TRANS: Nationality of the people comprising a unit, if
515 * different from owner. */
516 astr_add_line(&str, _("%s people"),
517 nation_adjective_for_player(nationality));
518 } else {
519 astr_add(&str, "\n");
520 }
521 }
522
523 astr_add_line(&str, "%s",
525#ifdef FREECIV_DEBUG
526 astr_add_line(&str, "Unit ID: %d", punit->id);
527#endif
528
529 return astr_str(&str);
530}
531
532/************************************************************************/
545const char *get_airlift_text(const struct unit_list *punits,
546 const struct city *pdest)
547{
548 static struct astring str = ASTRING_INIT;
549 bool src = (pdest == NULL);
551 best = AL_IMPOSSIBLE;
552 int cur = 0, max = 0;
553
555 enum texttype this = AL_IMPOSSIBLE;
556 enum unit_airlift_result result;
557
558 /* NULL will tell us about the capability of airlifting from source */
560
561 switch (result) {
562 case AR_NO_MOVES:
564 case AR_OCCUPIED:
565 case AR_NOT_IN_CITY:
566 case AR_BAD_SRC_CITY:
567 case AR_BAD_DST_CITY:
568 /* No chance of an airlift. */
569 this = AL_IMPOSSIBLE;
570 break;
571 case AR_OK:
576 /* May or may not be able to airlift now, but there's a chance we could
577 * later */
578 {
579 const struct city *pcity = src ? tile_city(unit_tile(punit)) : pdest;
580
581 fc_assert_ret_val(pcity != NULL, fc_strdup("-"));
584 /* No restrictions on destination (and we can infer this even for
585 * other players' cities). */
586 this = AL_INFINITE;
589 this = AL_INFINITE;
590 } else if (client_player() == city_owner(pcity)) {
591 /* A city we know about. */
592 int this_cur = pcity->airlift, this_max = city_airlift_max(pcity);
593
594 if (this_max <= 0) {
595 /* City known not to be airlift-capable. */
596 this = AL_IMPOSSIBLE;
597 } else {
598 if (src
600 /* Unlimited capacity. */
601 this = AL_INFINITE;
602 } else if (!src
604 this = AL_INFINITE;
605 } else {
606 /* Limited capacity (possibly zero right now). */
607 this = AL_FINITE;
608 /* Store the numbers. This whole setup assumes that numeric
609 * capacity isn't unit-dependent. */
610 if (best == AL_FINITE) {
611 fc_assert(cur == this_cur && max == this_max);
612 }
613 cur = this_cur;
614 max = this_max;
615 }
616 }
617 } else {
618 /* Unknown capacity. */
619 this = AL_UNKNOWN;
620 }
621 }
622 break;
623 }
624
625 /* Now take the most optimistic view. */
626 best = MAX(best, this);
628
629 switch (best) {
630 case AL_IMPOSSIBLE:
631 return NULL;
632 case AL_UNKNOWN:
633 astr_set(&str, "?");
634 break;
635 case AL_FINITE:
636 astr_set(&str, "%d/%d", cur, max);
637 break;
638 case AL_INFINITE:
639 astr_set(&str, _("Yes"));
640 break;
641 }
642
643 return astr_str(&str);
644}
645
646/************************************************************************/
649static int get_bulbs_per_turn(int *pours, bool *pteam, int *ptheirs)
650{
651 const struct research *presearch;
652 int ours = 0, theirs = 0;
653 bool team = FALSE;
654
655 if (!client_has_player()) {
656 return 0;
657 }
659
660 /* Sum up science */
662 if (pplayer == client_player()) {
663 city_list_iterate(pplayer->cities, pcity) {
664 ours += pcity->surplus[O_SCIENCE];
666 } else {
667 team = TRUE;
668 theirs -= pplayer->client.tech_upkeep;
669 }
671
672 if (team) {
673 theirs += presearch->client.total_bulbs_prod - ours;
674 }
675 ours -= client_player()->client.tech_upkeep;
676
677 if (pours) {
678 *pours = ours;
679 }
680 if (pteam) {
681 *pteam = team;
682 }
683 if (ptheirs) {
684 *ptheirs = theirs;
685 }
686
687 return ours + theirs;
688}
689
690/************************************************************************/
694 int per_turn)
695{
696 if (per_turn > 0) {
697 return ceil((double)(presearch->client.researching_cost
698 - presearch->bulbs_researched) / per_turn);
699 } else {
700 return -1;
701 }
702}
703
704/************************************************************************/
708static int turns_per_advance(const struct research *presearch, int per_turn)
709{
710 if (per_turn > 0) {
711 return MAX(1, ceil((double)presearch->client.researching_cost) / per_turn);
712 } else {
713 return -1;
714 }
715}
716
717/************************************************************************/
721static int turns_to_tech_loss(const struct research *presearch, int per_turn)
722{
723 if (per_turn >= 0 || game.info.techloss_forgiveness == -1) {
724 /* With techloss_forgiveness == -1, we'll never lose a tech, just
725 * get further into debt. */
726 return -1;
727 } else {
728 int bulbs_to_loss = presearch->bulbs_researched
729 + (presearch->client.researching_cost
731
732 return ceil((double)bulbs_to_loss / -per_turn);
733 }
734}
735
736/************************************************************************/
741const char *science_dialog_text(void)
742{
743 bool team;
744 int ours, theirs, perturn, upkeep;
745 static struct astring str = ASTRING_INIT;
747 struct research *research;
748
749 astr_clear(&str);
750
752
754 upkeep = client_player()->client.tech_upkeep;
755
756 if (NULL == client.conn.playing || (ours == 0 && theirs == 0
757 && upkeep == 0)) {
758 return _("Progress: no research");
759 }
760
761 if (A_UNSET == research->researching) {
762 astr_add(&str, _("Progress: no research"));
763 } else {
764 int turns;
765
766 if ((turns = turns_per_advance(research, perturn)) >= 0) {
767 astr_add(&str, PL_("Progress: %d turn/advance",
768 "Progress: %d turns/advance",
769 turns), turns);
770 } else if ((turns = turns_to_tech_loss(research, perturn)) >= 0) {
771 /* FIXME: turns to next loss is not a good predictor of turns to
772 * following loss, due to techloss_restore etc. But it'll do. */
773 astr_add(&str, PL_("Progress: %d turn/advance loss",
774 "Progress: %d turns/advance loss",
775 turns), turns);
776 } else {
777 /* no forward progress -- no research, or tech loss disallowed */
778 if (perturn < 0) {
779 astr_add(&str, _("Progress: decreasing!"));
780 } else {
781 astr_add(&str, _("Progress: none"));
782 }
783 }
784 }
785 astr_set(&ourbuf, PL_("%d bulb/turn", "%d bulbs/turn", ours), ours);
786 if (team) {
787 /* Techpool version */
789 /* TRANS: This is appended to "%d bulb/turn" text */
790 PL_(", %d bulb/turn from team",
791 ", %d bulbs/turn from team", theirs), theirs);
792 } else {
794 }
795 astr_add(&str, " (%s%s)", astr_str(&ourbuf), astr_str(&theirbuf));
798
800 /* perturn is defined as: (bulbs produced) - upkeep */
801 astr_add_line(&str, _("Bulbs produced per turn: %d"), perturn + upkeep);
802 /* TRANS: keep leading space; appended to "Bulbs produced per turn: %d" */
803 astr_add(&str, _(" (needed for technology upkeep: %d)"), upkeep);
804 }
805
806 return astr_str(&str);
807}
808
809/************************************************************************/
821{
823 static struct astring str = ASTRING_INIT;
824
825 if (!research) {
826 return "-";
827 }
828
829 astr_clear(&str);
830 if (research->researching == A_UNSET) {
831 astr_add(&str, _("%d/- (never)"), research->bulbs_researched);
832 if (percent) {
833 *percent = 0.0;
834 }
835 } else {
836 int total = research->client.researching_cost;
837 int done = research->bulbs_researched;
839 int turns;
840
841 if ((turns = turns_to_research_done(research, perturn)) >= 0) {
842 astr_add(&str, PL_("%d/%d (%d turn)", "%d/%d (%d turns)", turns),
843 done, total, turns);
844 } else if ((turns = turns_to_tech_loss(research, perturn)) >= 0) {
845 astr_add(&str, PL_("%d/%d (%d turn to loss)",
846 "%d/%d (%d turns to loss)", turns),
847 done, total, turns);
848 } else {
849 /* no forward progress -- no research, or tech loss disallowed */
850 astr_add(&str, _("%d/%d (never)"), done, total);
851 }
852 if (percent) {
853 *percent = (double)done / (double)total;
854 *percent = CLIP(0.0, *percent, 1.0);
855 }
856 }
857
858 return astr_str(&str);
859}
860
861/************************************************************************/
867{
868 const struct research *research = research_get(client_player());
869 int steps = research_goal_unknown_techs(research, goal);
871 int turns;
873 static struct astring str = ASTRING_INIT;
874 struct astring buf1 = ASTRING_INIT,
877
878 if (!research) {
879 return "-";
880 }
881
882 astr_clear(&str);
883
885 || research->researching == goal) {
887 }
888
889 astr_set(&buf1,
890 PL_("%d step", "%d steps", steps), steps);
891 astr_set(&buf2,
892 PL_("%d bulb", "%d bulbs", bulbs_needed), bulbs_needed);
893 if (perturn > 0) {
894 turns = (bulbs_needed + perturn - 1) / perturn;
895 astr_set(&buf3,
896 PL_("%d turn", "%d turns", turns), turns);
897 } else {
898 astr_set(&buf3, _("never"));
899 }
900 astr_add_line(&str, "(%s - %s - %s)",
902 astr_free(&buf1);
903 astr_free(&buf2);
904 astr_free(&buf3);
905
906 return astr_str(&str);
907}
908
909/************************************************************************/
918{
919 static struct astring str = ASTRING_INIT;
920
921 astr_clear(&str);
922
923 if (NULL != client.conn.playing) {
924 astr_add_line(&str, _("Population: %s"),
926 }
927 astr_add_line(&str, _("Year: %s (T%d)"),
929
930 if (NULL != client.conn.playing) {
931 astr_add_line(&str, _("Gold: %d (%+d)"),
934 astr_add_line(&str, _("Tax: %d Lux: %d Sci: %d"),
938 }
940 if (game.info.phase < 0 || game.info.phase >= player_count()) {
941 astr_add_line(&str, _("Moving: Nobody"));
942 } else {
943 astr_add_line(&str, _("Moving: %s"),
945 }
946 } else if (game.info.phase_mode == PMT_TEAMS_ALTERNATE) {
947 if (game.info.phase < 0 || game.info.phase >= team_count()) {
948 astr_add_line(&str, _("Moving: Nobody"));
949 } else {
950 astr_add_line(&str, _("Moving: %s"),
952 }
953 }
954
955 if (moreinfo) {
956 astr_add_line(&str, _("(Click for more info)"));
957 }
958
959 return astr_str(&str);
960}
961
962/************************************************************************/
970{
971 static struct astring str = ASTRING_INIT;
972
973 astr_clear(&str);
974
975 if (NULL != client.conn.playing) {
976 astr_add_line(&str, _("%s People"),
978 }
979 astr_add_line(&str, _("Year: %s"), calendar_text());
980 astr_add_line(&str, _("Turn: %d"), game.info.turn);
981
982 if (NULL != client.conn.playing) {
983 const struct research *presearch = research_get(client_player());
985 int upkeep = client_player()->client.tech_upkeep;
986
987 astr_add_line(&str, _("Gold: %d"),
989 astr_add_line(&str, _("Net Income: %d"),
991 /* TRANS: Gold, luxury, and science rates are in percentage values. */
992 astr_add_line(&str, _("Tax rates: Gold:%d%% Luxury:%d%% Science:%d%%"),
996 astr_add_line(&str, _("Researching %s: %s"),
998 presearch->researching),
1000 /* perturn is defined as: (bulbs produced) - upkeep */
1002 astr_add_line(&str, _("Bulbs per turn: %d - %d = %d"), perturn + upkeep,
1003 upkeep, perturn);
1004 } else {
1005 fc_assert(upkeep == 0);
1006 astr_add_line(&str, _("Bulbs per turn: %d"), perturn);
1007 }
1008 {
1010
1014 astr_add_line(&str, _("Culture: %d (%+d/turn)"),
1016 }
1017 }
1018
1019 /* See also get_global_warming_tooltip() and get_nuclear_winter_tooltip(). */
1020
1021 if (game.info.global_warming) {
1022 int chance, rate;
1024 astr_add_line(&str, _("Global warming chance: %d%% (%+d%%/turn)"),
1025 chance, rate);
1026 } else {
1027 astr_add_line(&str, _("Global warming deactivated."));
1028 }
1029
1030 if (game.info.nuclear_winter) {
1031 int chance, rate;
1033 astr_add_line(&str, _("Nuclear winter chance: %d%% (%+d%%/turn)"),
1034 chance, rate);
1035 } else {
1036 astr_add_line(&str, _("Nuclear winter deactivated."));
1037 }
1038
1039 if (NULL != client.conn.playing) {
1040 astr_add_line(&str, _("Government: %s"),
1042 }
1043
1044 return astr_str(&str);
1045}
1046
1047/************************************************************************/
1054const char *get_unit_info_label_text1(struct unit_list *punits)
1055{
1056 static struct astring str = ASTRING_INIT;
1057
1058 astr_clear(&str);
1059
1060 if (punits) {
1061 int count = unit_list_size(punits);
1062
1063 if (count == 1) {
1065 } else {
1066 astr_add(&str, PL_("%d unit", "%d units", count), count);
1067 }
1068 }
1069 return astr_str(&str);
1070}
1071
1072/************************************************************************/
1079const char *get_unit_info_label_text2(struct unit_list *punits, int linebreaks)
1080{
1081 static struct astring str = ASTRING_INIT;
1082 int count;
1083
1084 astr_clear(&str);
1085
1086 if (!punits) {
1087 return "";
1088 }
1089
1090 count = unit_list_size(punits);
1091
1092 /* This text should always have the same number of lines if
1093 * 'linebreaks' has no flags at all. Otherwise the GUI widgets may be
1094 * confused and try to resize themselves. If caller asks for
1095 * conditional 'linebreaks', it should take care of these problems
1096 * itself. */
1097
1098 /* Line 1. Goto or activity text. */
1099 if (count > 0 && hover_state != HOVER_NONE) {
1100 int min, max;
1101
1102 if (!goto_get_turns(&min, &max)) {
1103 /* TRANS: Impossible to reach goto target tile */
1104 astr_add_line(&str, "%s", Q_("?goto:Unreachable"));
1105 } else if (min == max) {
1106 astr_add_line(&str, _("Turns to target: %d"), max);
1107 } else {
1108 astr_add_line(&str, _("Turns to target: %d to %d"), min, max);
1109 }
1110 } else if (count == 1) {
1111 struct astring addition = ASTRING_INIT;
1112
1116 } else if (count > 1) {
1117 astr_add_line(&str, PL_("%d unit selected",
1118 "%d units selected",
1119 count),
1120 count);
1121 } else {
1122 astr_add_line(&str, _("No units selected."));
1123 }
1124
1125 /* Lines 2, 3, 4, and possible 5 vary. */
1126 if (count == 1) {
1127 struct unit *punit = unit_list_get(punits, 0);
1128 struct player *owner = unit_owner(punit);
1129 struct city *pcity = player_city_by_number(owner,
1130 punit->homecity);
1131
1133 linebreaks));
1134 {
1136
1137 if (*infratext != '\0') {
1138 astr_add_line(&str, "%s", infratext);
1139 } else {
1140 astr_add_line(&str, " ");
1141 }
1142 }
1143 if (pcity) {
1144 astr_add_line(&str, "%s", city_name_get(pcity));
1145 } else {
1146 astr_add_line(&str, " ");
1147 }
1148
1150 struct player *nationality = unit_nationality(punit);
1151
1152 /* Line 5, nationality text */
1153 if (nationality != NULL && owner != nationality) {
1154 /* TRANS: Nationality of the people comprising a unit, if
1155 * different from owner. */
1156 astr_add_line(&str, _("%s people"),
1157 nation_adjective_for_player(nationality));
1158 } else {
1159 astr_add_line(&str, " ");
1160 }
1161 }
1162
1163 } else if (count > 1) {
1164 int mil = 0, nonmil = 0;
1165 int types_count[U_LAST], i;
1166 struct unit_type *top[3];
1167
1168 memset(types_count, 0, sizeof(types_count));
1171 nonmil++;
1172 } else {
1173 mil++;
1174 }
1177
1178 top[0] = top[1] = top[2] = NULL;
1179 unit_type_iterate(utype) {
1180 if (!top[2]
1181 || types_count[utype_index(top[2])] < types_count[utype_index(utype)]) {
1182 top[2] = utype;
1183
1184 if (!top[1]
1185 || types_count[utype_index(top[1])] < types_count[utype_index(top[2])]) {
1186 top[2] = top[1];
1187 top[1] = utype;
1188
1189 if (!top[0]
1190 || types_count[utype_index(top[0])] < types_count[utype_index(utype)]) {
1191 top[1] = top[0];
1192 top[0] = utype;
1193 }
1194 }
1195 }
1197
1198 for (i = 0; i < 2; i++) {
1199 if (top[i] && types_count[utype_index(top[i])] > 0) {
1200 if (utype_has_flag(top[i], UTYF_CIVILIAN)) {
1201 nonmil -= types_count[utype_index(top[i])];
1202 } else {
1203 mil -= types_count[utype_index(top[i])];
1204 }
1205 astr_add_line(&str, "%d: %s",
1206 types_count[utype_index(top[i])],
1208 } else {
1209 astr_add_line(&str, " ");
1210 }
1211 }
1212
1213 if (top[2] && types_count[utype_index(top[2])] > 0
1214 && types_count[utype_index(top[2])] == nonmil + mil) {
1215 astr_add_line(&str, "%d: %s", types_count[utype_index(top[2])],
1216 utype_name_translation(top[2]));
1217 } else if (nonmil > 0 && mil > 0) {
1218 astr_add_line(&str, _("Others: %d civil; %d military"), nonmil, mil);
1219 } else if (nonmil > 0) {
1220 astr_add_line(&str, _("Others: %d civilian"), nonmil);
1221 } else if (mil > 0) {
1222 astr_add_line(&str, _("Others: %d military"), mil);
1223 } else {
1224 astr_add_line(&str, " ");
1225 }
1226
1228 astr_add_line(&str, " ");
1229 }
1230 } else {
1231 astr_add_line(&str, " ");
1232 astr_add_line(&str, " ");
1233 astr_add_line(&str, " ");
1234
1236 astr_add_line(&str, " ");
1237 }
1238 }
1239
1240 /* Line 5/6. Debug text. */
1241#ifdef FREECIV_DEBUG
1242 if (count == 1) {
1243 astr_add_line(&str, "(Unit ID %d)", unit_list_get(punits, 0)->id);
1244 } else {
1245 astr_add_line(&str, " ");
1246 }
1247#endif /* FREECIV_DEBUG */
1248
1249 return astr_str(&str);
1250}
1251
1252/************************************************************************/
1258 struct unit_list *punits)
1259{
1260 if (unit_list_size(punits) == 0) {
1261 fc_snprintf(buf, bufsz, _("No units to upgrade!"));
1262 return FALSE;
1263 } else if (unit_list_size(punits) == 1) {
1265 } else {
1266 int upgrade_cost = 0;
1267 int num_upgraded = 0;
1269
1272 && UU_OK == unit_upgrade_test(&(wld.map), punit, FALSE)) {
1273 const struct unit_type *from_unittype = unit_type_get(punit);
1278
1279 num_upgraded++;
1280 upgrade_cost += cost;
1282 }
1284 if (num_upgraded == 0) {
1285 fc_snprintf(buf, bufsz, _("None of these units may be upgraded."));
1286 return FALSE;
1287 } else {
1288 /* This may trigger sometimes if you don't have enough money for
1289 * a full upgrade. If you have enough to upgrade at least one, it
1290 * will do it. */
1291 /* Construct prompt in several parts to allow separate pluralisation
1292 * by localizations */
1294
1295 fc_snprintf(tbuf, ARRAY_SIZE(tbuf), PL_("Treasury contains %d gold.",
1296 "Treasury contains %d gold.",
1297 client_player()->economic.gold),
1298 client_player()->economic.gold);
1299 /* TRANS: this whole string is a sentence fragment that is only ever
1300 * used by including it in another string (search comments for this
1301 * string to find it) */
1302 fc_snprintf(ubuf, ARRAY_SIZE(ubuf), PL_("Upgrade %d unit",
1303 "Upgrade %d units",
1304 num_upgraded),
1305 num_upgraded);
1306 /* TRANS: This is complicated. The first %s is a pre-pluralised
1307 * sentence fragment "Upgrade %d unit(s)"; the second is pre-pluralised
1308 * "Treasury contains %d gold." So the whole thing reads
1309 * "Upgrade 13 units for 1000 gold?\nTreasury contains 2000 gold." */
1310 fc_snprintf(buf, bufsz, PL_("%s for %d gold?\n%s",
1311 "%s for %d gold?\n%s", upgrade_cost),
1313 return TRUE;
1314 }
1315 }
1316}
1317
1318/************************************************************************/
1324 struct unit_list *punits)
1325{
1326 if (unit_list_size(punits) == 0) {
1327 fc_snprintf(buf, bufsz, _("No units to disband!"));
1328 return FALSE;
1329 } else if (unit_list_size(punits) == 1) {
1332 fc_snprintf(buf, bufsz, _("%s refuses to disband!"),
1334 return FALSE;
1335 } else {
1336 /* TRANS: %s is a unit type */
1337 fc_snprintf(buf, bufsz, _("Disband %s?"),
1339 return TRUE;
1340 }
1341 } else {
1342 int count = 0;
1343
1346 count++;
1347 }
1349 if (count == 0) {
1350 fc_snprintf(buf, bufsz, _("None of these units may be disbanded."));
1351 return FALSE;
1352 } else {
1353 /* TRANS: %d is never 0 or 1 */
1354 fc_snprintf(buf, bufsz, PL_("Disband %d unit?",
1355 "Disband %d units?", count), count);
1356 return TRUE;
1357 }
1358 }
1359}
1360
1361/************************************************************************/
1367const char *get_bulb_tooltip(void)
1368{
1369 static struct astring str = ASTRING_INIT;
1370
1371 astr_clear(&str);
1372
1373 astr_add_line(&str, _("Shows your progress in "
1374 "researching the current technology."));
1375
1376 if (NULL != client.conn.playing) {
1378
1379 if (research->researching == A_UNSET) {
1380 astr_add_line(&str, _("No research target."));
1381 } else {
1382 int turns;
1385
1386 if ((turns = turns_to_research_done(research, perturn)) >= 0) {
1387 astr_set(&buf1, PL_("%d turn", "%d turns", turns), turns);
1388 } else if ((turns = turns_to_tech_loss(research, perturn)) >= 0) {
1389 astr_set(&buf1, PL_("%d turn to loss", "%d turns to loss", turns),
1390 turns);
1391 } else {
1392 if (perturn < 0) {
1393 astr_set(&buf1, _("Decreasing"));
1394 } else {
1395 astr_set(&buf1, _("No progress"));
1396 }
1397 }
1398
1399 /* TRANS: <perturn> bulbs/turn */
1400 astr_set(&buf2, PL_("%d bulb/turn", "%d bulbs/turn", perturn), perturn);
1401
1402 /* TRANS: <tech>: <amount>/<total bulbs> */
1403 astr_add_line(&str, _("%s: %d/%d (%s, %s)."),
1408 astr_str(&buf1), astr_str(&buf2));
1409
1410 astr_free(&buf1);
1411 astr_free(&buf2);
1412 }
1413 }
1414
1415 return astr_str(&str);
1416}
1417
1418/************************************************************************/
1425{
1426 static struct astring str = ASTRING_INIT;
1427
1428 astr_clear(&str);
1429
1430 if (!game.info.global_warming) {
1431 astr_add_line(&str, _("Global warming deactivated."));
1432 } else {
1433 int chance, rate;
1434
1436 astr_add_line(&str, _("Shows the progress of global warming:"));
1437 astr_add_line(&str, _("Pollution rate: %d%%"), rate);
1438 astr_add_line(&str, _("Chance of catastrophic warming each turn: %d%%"),
1439 chance);
1440 }
1441
1442 return astr_str(&str);
1443}
1444
1445/************************************************************************/
1452{
1453 static struct astring str = ASTRING_INIT;
1454
1455 astr_clear(&str);
1456
1457 if (!game.info.nuclear_winter) {
1458 astr_add_line(&str, _("Nuclear winter deactivated."));
1459 } else {
1460 int chance, rate;
1461
1463 astr_add_line(&str, _("Shows the progress of nuclear winter:"));
1464 astr_add_line(&str, _("Fallout rate: %d%%"), rate);
1465 astr_add_line(&str, _("Chance of catastrophic winter each turn: %d%%"),
1466 chance);
1467 }
1468
1469 return astr_str(&str);
1470}
1471
1472/************************************************************************/
1478const char *get_government_tooltip(void)
1479{
1480 static struct astring str = ASTRING_INIT;
1481
1482 astr_clear(&str);
1483
1484 astr_add_line(&str, _("Shows your current government:"));
1485
1486 if (NULL != client.conn.playing) {
1487 astr_add_line(&str, "%s",
1489 }
1490
1491 return astr_str(&str);
1492}
1493
1494/************************************************************************/
1501{
1502 struct player_spaceship ship;
1503 static struct astring str = ASTRING_INIT;
1504
1505 astr_clear(&str);
1506
1507 if (!pship) {
1508 pship = &ship;
1509 memset(&ship, 0, sizeof(ship));
1510 }
1511
1512 /* TRANS: spaceship text; should have constant width. */
1513 astr_add_line(&str, _("Population: %5d"), pship->population);
1514
1515 /* TRANS: spaceship text; should have constant width. */
1516 astr_add_line(&str, _("Support: %5d %%"),
1517 (int) (pship->support_rate * 100.0));
1518
1519 /* TRANS: spaceship text; should have constant width. */
1520 astr_add_line(&str, _("Energy: %5d %%"),
1521 (int) (pship->energy_rate * 100.0));
1522
1523 /* TRANS: spaceship text; should have constant width. */
1524 astr_add_line(&str, PL_("Mass: %5d ton",
1525 "Mass: %5d tons",
1526 pship->mass), pship->mass);
1527
1528 if (pship->propulsion > 0) {
1529 /* TRANS: spaceship text; should have constant width. */
1530 astr_add_line(&str, _("Travel time: %5.1f years"),
1531 (float) (0.1 * ((int) (pship->travel_time * 10.0))));
1532 } else {
1533 /* TRANS: spaceship text; should have constant width. */
1534 astr_add_line(&str, "%s", _("Travel time: N/A "));
1535 }
1536
1537 /* TRANS: spaceship text; should have constant width. */
1538 astr_add_line(&str, _("Success prob.: %5d %%"),
1539 (int) (pship->success_rate * 100.0));
1540
1541 /* TRANS: spaceship text; should have constant width. */
1542 astr_add_line(&str, _("Year of arrival: %8s"),
1543 (pship->state == SSHIP_LAUNCHED)
1544 ? textyear((int) (pship->launch_year +
1545 (int) pship->travel_time))
1546 : "- ");
1547
1548 return astr_str(&str);
1549}
1550
1551/************************************************************************/
1557const char *get_timeout_label_text(void)
1558{
1559 static struct astring str = ASTRING_INIT;
1560
1561 astr_clear(&str);
1562
1565
1566 if (wt <= 0) {
1567 astr_add(&str, "%s", Q_("?timeout:wait"));
1568 } else {
1569 astr_add(&str, "%s: %s", Q_("?timeout:eta"), format_duration(wt));
1570 }
1571 } else {
1572 if (current_turn_timeout() <= 0) {
1573 astr_add(&str, "%s", Q_("?timeout:off"));
1574 } else {
1576 }
1577 }
1578
1579 return astr_str(&str);
1580}
1581
1582/************************************************************************/
1590static const char *format_duration(int duration)
1591{
1592 static struct astring str = ASTRING_INIT;
1593
1594 astr_clear(&str);
1595
1596 if (duration < 0) {
1597 duration = 0;
1598 }
1599 if (duration < 60) {
1600 astr_add(&str, Q_("?seconds:%02ds"), duration);
1601 } else if (duration < 3600) { /* < 60 minutes */
1602 astr_add(&str, Q_("?mins/secs:%02dm %02ds"), duration / 60, duration % 60);
1603 } else if (duration < 360000) { /* < 100 hours */
1604 astr_add(&str, Q_("?hrs/mns:%02dh %02dm"), duration / 3600, (duration / 60) % 60);
1605 } else if (duration < 8640000) { /* < 100 days */
1606 astr_add(&str, Q_("?dys/hrs:%02dd %02dh"), duration / 86400,
1607 (duration / 3600) % 24);
1608 } else {
1609 astr_add(&str, "%s", Q_("?duration:overflow"));
1610 }
1611
1612 return astr_str(&str);
1613}
1614
1615/************************************************************************/
1621const char *get_ping_time_text(const struct player *pplayer)
1622{
1623 static struct astring str = ASTRING_INIT;
1624
1625 astr_clear(&str);
1626
1628 if (!pconn->observer
1629 /* Certainly not needed, but safer. */
1630 && 0 == strcmp(pconn->username, pplayer->username)) {
1631 if (pconn->ping_time >= 0) {
1632 double ping_time_in_ms = 1000 * pconn->ping_time;
1633
1634 astr_add(&str, _("%6d.%02d ms"), (int) ping_time_in_ms,
1635 ((int) (ping_time_in_ms * 100.0)) % 100);
1636 }
1637 break;
1638 }
1640
1641 return astr_str(&str);
1642}
1643
1644/************************************************************************/
1650const char *get_score_text(const struct player *pplayer)
1651{
1652 static struct astring str = ASTRING_INIT;
1653
1654 astr_clear(&str);
1655
1656 if (pplayer->score.game >= 0) {
1657 astr_add(&str, "%d", pplayer->score.game);
1658 } else {
1659 astr_add(&str, "?");
1660 }
1661
1662 return astr_str(&str);
1663}
1664
1665/************************************************************************/
1672const char *get_report_title(const char *report_name)
1673{
1674 static struct astring str = ASTRING_INIT;
1675 const struct player *pplayer = client_player();
1676
1677 astr_clear(&str);
1678
1679 astr_add_line(&str, "%s", report_name);
1680
1681 if (pplayer != NULL) {
1682 char buf[4 * MAX_LEN_NAME];
1683
1684 /* TRANS: <nation adjective> <government name>.
1685 * E.g. "Polish Republic". */
1686 astr_add_line(&str, Q_("?nationgovernment:%s %s"),
1689
1690 /* TRANS: Just appending 2 strings, using the correct localized
1691 * syntax. */
1692 astr_add_line(&str, _("%s - %s"),
1693 ruler_title_for_player(pplayer, buf, sizeof(buf)),
1694 calendar_text());
1695 } else {
1696 /* TRANS: "Observer - 1985 AD" */
1697 astr_add_line(&str, _("Observer - %s"),
1698 calendar_text());
1699 }
1700
1701 return astr_str(&str);
1702}
1703
1704/**********************************************************************/
1711 const struct act_prob prob,
1712 const struct unit *actor_unit,
1713 const struct city *target_city)
1714{
1715 static struct astring custom = ASTRING_INIT;
1716
1718
1719 if (!action_prob_possible(prob)) {
1720 /* No info since impossible. */
1721 return NULL;
1722 }
1723
1725 || target_city != NULL),
1726 NULL);
1727
1733 TRUE);
1734
1735 if (revenue > 0) {
1737 /* TRANS: Estimated one time bonus and recurring revenue for
1738 * the Establish Trade _Route action. */
1739 _("%d one time bonus + %d trade"),
1740 revenue,
1742 } else {
1744 /* TRANS: Estimated recurring revenue for
1745 * the Establish Trade _Route action. */
1746 _("%d trade"),
1748 }
1754 FALSE);
1755
1756 if (revenue > 0) {
1758 /* TRANS: Estimated one time bonus for the Enter Marketplace
1759 * action. */
1760 _("%d one time bonus"), revenue);
1761 } else {
1762 /* No info to add. */
1763 return NULL;
1764 }
1768 /* Can only give remaining production for domestic and existing
1769 * cities. */
1771
1772 astr_set(&custom, _("%d remaining"), cost - target_city->shield_stock);
1773 } else {
1774 /* No info to add. */
1775 return NULL;
1776 }
1777
1778 return astr_str(&custom);
1779}
1780
1781/**********************************************************************/
1789const char *act_sel_action_tool_tip(const struct action *paction,
1790 const struct act_prob prob)
1791{
1792 return action_prob_explain(prob);
1793}
1794
1795/************************************************************************/
1800const char *text_happiness_buildings(const struct city *pcity)
1801{
1802 struct effect_list *plist = effect_list_new();
1803 static struct astring str = ASTRING_INIT;
1804
1806 if (0 < effect_list_size(plist)) {
1807 struct astring effects = ASTRING_INIT;
1808
1810 astr_set(&str, _("Buildings: %s."), astr_str(&effects));
1812 } else {
1813 astr_set(&str, _("Buildings: None."));
1814 }
1816
1817 /* Add line breaks after 80 characters. */
1818 astr_break_lines(&str, 80);
1819
1820 return astr_str(&str);
1821}
1822
1823/************************************************************************/
1828const char *text_happiness_nationality(const struct city *pcity)
1829{
1830 static struct astring str = ASTRING_INIT;
1831 int enemies = 0;
1832
1833 astr_clear(&str);
1834
1835 astr_add_line(&str, _("Nationality: "));
1836
1839 struct player *owner = city_owner(pcity);
1840
1841 citizens_foreign_iterate(pcity, pslot, nationality) {
1843 enemies += nationality;
1844 }
1846
1847 if (enemies > 0) {
1848 astr_add(&str, PL_("%d enemy nationalist", "%d enemy nationalists", enemies),
1849 enemies);
1850 }
1851 }
1852
1853 if (enemies == 0) {
1854 /* TRANS: No enemy nationalities, as there's no enemies present. */
1855 astr_add(&str, _("None."));
1856 }
1857 } else {
1858 /* TRANS: No nationalities present. */
1859 astr_add(&str, _("Disabled."));
1860 }
1861
1862 return astr_str(&str);
1863}
1864
1865/************************************************************************/
1870const char *text_happiness_wonders(const struct city *pcity)
1871{
1872 struct effect_list *plist = effect_list_new();
1873 static struct astring str = ASTRING_INIT;
1874
1878 if (0 < effect_list_size(plist)) {
1879 struct astring effects = ASTRING_INIT;
1880
1882 astr_set(&str, _("Wonders: %s."), astr_str(&effects));
1884 } else {
1885 astr_set(&str, _("Wonders: None."));
1886 }
1887
1888 /* Add line breaks after 80 characters. */
1889 astr_break_lines(&str, 80);
1891
1892 return astr_str(&str);
1893}
1894
1895/************************************************************************/
1900const char *text_happiness_cities(const struct city *pcity)
1901{
1902 struct player *pplayer = city_owner(pcity);
1903 int cities = city_list_size(pplayer->cities);
1904 int content = get_player_bonus(pplayer, EFT_CITY_UNHAPPY_SIZE);
1907 static struct astring str = ASTRING_INIT;
1908
1909 astr_clear(&str);
1910
1911 if (basis+step <= 0) {
1912 /* Special case where penalty is disabled; see
1913 * player_content_citizens(). */
1915 PL_("Cities: %d total, but no penalty for empire size.",
1916 "Cities: %d total, but no penalty for empire size.",
1917 cities),
1918 cities);
1920 /* TRANS: %d is number of citizens */
1921 PL_("%d content per city.",
1922 "%d content per city.", content),
1923 content);
1924 } else {
1925 /* Can have up to and including 'basis' cities without penalty */
1926 int excess = MAX(cities - basis, 0);
1927 int penalty;
1928 int unhappy, angry;
1929 int last, next;
1930
1931 if (excess > 0) {
1932 if (step > 0) {
1933 penalty = 1 + (excess - 1) / step;
1934 } else {
1935 penalty = 1;
1936 }
1937 } else {
1938 penalty = 0;
1939 }
1940
1941 unhappy = MIN(penalty, content);
1942 angry = game.info.angrycitizen ? MAX(penalty-content, 0) : 0;
1943 if (penalty >= 1) {
1944 /* 'last' is when last actual malcontent appeared, will saturate
1945 * if no angry citizens */
1946 last = basis + (unhappy+angry-1)*step;
1947 if (!game.info.angrycitizen && unhappy == content) {
1948 /* Maxed out unhappy citizens, so no more penalties */
1949 next = 0;
1950 } else {
1951 /* Angry citizens can continue appearing indefinitely */
1952 next = last + step;
1953 }
1954 } else {
1955 last = 0;
1956 next = basis;
1957 }
1958
1960 /* TRANS: sentence fragment, will have text appended */
1961 PL_("Cities: %d total:",
1962 "Cities: %d total:", cities),
1963 cities);
1964 if (excess > 0) {
1965 astr_add(&str,
1966 /* TRANS: appended to "Cities: %d total:"; preserve leading
1967 * space. Pluralized in "nearest threshold of %d cities". */
1968 PL_(" %d over nearest threshold of %d city.",
1969 " %d over nearest threshold of %d cities.", last),
1970 cities - last, last);
1972 /* TRANS: Number of content [citizen(s)] ... */
1973 PL_("%d content before penalty.",
1974 "%d content before penalty.", content),
1975 content);
1977 PL_("%d additional unhappy citizen.",
1978 "%d additional unhappy citizens.", unhappy),
1979 unhappy);
1980 if (angry > 0) {
1982 PL_("%d angry citizen.",
1983 "%d angry citizens.", angry),
1984 angry);
1985 }
1986 } else {
1987 astr_add(&str,
1988 /* TRANS: appended to "Cities: %d total:"; preserve leading
1989 * space. */
1990 PL_(" not more than %d, so no empire size penalty.",
1991 " not more than %d, so no empire size penalty.", next),
1992 next);
1994 /* TRANS: %d is number of citizens */
1995 PL_("%d content per city.",
1996 "%d content per city.", content),
1997 content);
1998 }
1999 if (next >= cities && penalty < content) {
2001 PL_("With %d more city, another citizen will become "
2002 "unhappy.",
2003 "With %d more cities, another citizen will become "
2004 "unhappy.",
2005 next + 1 - cities),
2006 next + 1 - cities);
2007 } else if (next >= cities) {
2008 /* We maxed out the number of unhappy citizens, but they can get
2009 * angry instead. */
2012 PL_("With %d more city, another citizen will become "
2013 "angry.",
2014 "With %d more cities, another citizen will become "
2015 "angry.",
2016 next + 1 - cities),
2017 next + 1 - cities);
2018 } else {
2019 /* Either no Empire_Size_Step, or we maxed out on unhappy citizens
2020 * and ruleset doesn't allow angry ones. */
2022 _("More cities will not cause more unhappy citizens."));
2023 }
2024 }
2025
2026 return astr_str(&str);
2027}
2028
2029/************************************************************************/
2034const char *text_happiness_units(const struct city *pcity)
2035{
2038 static struct astring str = ASTRING_INIT;
2039
2040 astr_clear(&str);
2041
2042 if (mlmax > 0) {
2044 if (mlmax == 100) {
2045 astr_add_line(&str, "%s", _("Unlimited martial law in effect."));
2046 } else {
2047 astr_add_line(&str, PL_("%d military unit may impose martial law.",
2048 "Up to %d military units may impose martial "
2049 "law.", mlmax), mlmax);
2050 }
2051 astr_add_line(&str, PL_("Each military unit makes %d "
2052 "unhappy citizen content.",
2053 "Each military unit makes %d "
2054 "unhappy citizens content.",
2055 mleach), mleach);
2056 } else if (uhcfac > 0) {
2058 _("Military units in the field may cause unhappiness. "));
2059 } else {
2061 _("Military units have no happiness effect. "));
2062 }
2063
2064 return astr_str(&str);
2065}
2066
2067/************************************************************************/
2072const char *text_happiness_luxuries(const struct city *pcity)
2073{
2074 static struct astring str = ASTRING_INIT;
2075
2076 astr_clear(&str);
2077
2079 _("Luxury: %d total."),
2080 pcity->prod[O_LUXURY]);
2081
2082 return astr_str(&str);
2083}
2084
2085/************************************************************************/
2089const char *production_help(const struct universal *uni, char *buf,
2090 size_t bufsize)
2091{
2092 buf[0] = '\0';
2093 int segments = 0;
2094
2095 if (uni->kind == VUT_UTYPE) {
2096 if (uni->value.utype->helptext != NULL) {
2097 strvec_iterate(uni->value.utype->helptext, text) {
2098 if (segments++) {
2099 cat_snprintf(buf, bufsize, "\n\n");
2100 }
2101 cat_snprintf(buf, bufsize, "%s", _(text));
2103 }
2104 } else {
2106
2107 if (uni->value.building->helptext != NULL) {
2108 strvec_iterate(uni->value.building->helptext, text) {
2109 if (segments++) {
2110 cat_snprintf(buf, bufsize, "\n\n");
2111 }
2112 cat_snprintf(buf, bufsize, "%s", _(text));
2114 }
2115 }
2116
2117 return buf;
2118}
2119
2120/************************************************************************/
2126const char *score_tooltip(const struct player *pplayer, int score)
2127{
2128 static char buf[1024];
2129 char *relation;
2130
2131 if (client.conn.playing != NULL) {
2132 if (pplayer == client.conn.playing) {
2133 relation = _(" (us)");
2134 } else if (pplayers_allied(pplayer, client.conn.playing)) {
2135 relation = _(" (an ally)");
2136 } else if (player_diplstate_get(pplayer, client.conn.playing)->type == DS_WAR) {
2137 /* Actual enemy; don't want to use pplayers_at_war() that considers also
2138 * never met players enemies. */
2139 relation = _(" (an enemy)");
2140 } else {
2141 relation = "";
2142 }
2143 } else {
2144 relation = "";
2145 }
2146
2147 if (score >= 0) {
2148 /* TRANS: %s is a Nation */
2149 fc_snprintf(buf, sizeof(buf), _("%s%s: score %d"),
2151 score);
2152 } else {
2153 fc_snprintf(buf, sizeof(buf), "%s%s",
2155 }
2156
2157 return buf;
2158}
const char * action_prob_explain(const struct act_prob prob)
Definition actions.c:2184
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5821
enum action_target_kind action_get_target_kind(const struct action *paction)
Definition actions.c:1869
#define action_has_result(_act_, _res_)
Definition actions.h:431
void astr_free(struct astring *astr)
Definition astring.c:153
void astr_set(struct astring *astr, const char *format,...)
Definition astring.c:267
const char * astr_build_and_list(struct astring *astr, const char *const *items, size_t number)
Definition astring.c:367
void astr_add_line(struct astring *astr, const char *format,...)
Definition astring.c:299
void astr_clear(struct astring *astr)
Definition astring.c:205
void astr_add(struct astring *astr, const char *format,...)
Definition astring.c:287
#define str
Definition astring.c:76
void astr_break_lines(struct astring *astr, size_t desired_len)
Definition astring.c:318
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:141
const char * textyear(int year)
Definition calendar.c:120
#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:508
#define city_owner(_pcity_)
Definition city.h:563
#define city_list_iterate_end
Definition city.h:510
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:1118
static struct fc_sockaddr_list * list
Definition clinet.c:102
char * incite_cost
Definition comments.c:75
#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:37
int nation_history_gain(const struct player *pplayer)
Definition culture.c:61
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 * 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:961
int get_city_bonus(const struct city *pcity, enum effect_type effect_type)
Definition effects.c:846
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:1153
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
Definition effects.c:828
void get_effect_list_req_text(const struct effect_list *plist, struct astring *astr)
Definition effects.c:1303
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:377
#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
#define LINE_BREAK
Definition fc_types.h:77
@ BORDERS_DISABLED
Definition fc_types.h:1037
#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:734
struct civ_game game
Definition game.c:62
int current_turn_timeout(void)
Definition game.c:848
struct world wld
Definition game.c:63
int civ_population(const struct player *pplayer)
Definition game.c:74
struct city * game_city_by_number(int id)
Definition game.c:107
bool goto_get_turns(int *min, int *max)
Definition goto.c:1068
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:176
#define fc_assert_ret_val(condition, val)
Definition log.h:194
#define nat_x
#define nat_y
int map_signed_latitude(const struct tile *ptile)
Definition map.c:1550
#define index_to_native_pos(pnat_x, pnat_y, mindex)
Definition map.h:157
#define index_to_map_pos(pmap_x, pmap_y, mindex)
Definition map.h:233
#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:1405
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:230
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
struct sprite int x
Definition sprite_g.h:31
#define strvec_iterate(psv, str)
#define strvec_iterate_end
Definition city.h:320
int airlift
Definition city.h:378
int prod[O_LAST]
Definition city.h:358
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:197
struct city_list * cities
Definition player.h:279
char username[MAX_LEN_NAME]
Definition player.h:250
struct team * team
Definition player.h:259
struct conn_list * connections
Definition player.h:296
struct player::@70::@73 client
struct player_economic economic
Definition player.h:282
int culture
Definition player.h:365
char name[MAX_LEN_NAME]
Definition player.h:249
struct player_score score
Definition player.h:281
struct nation_type * nation
Definition player.h:258
Tech_type_id researching
Definition research.h:52
struct research::@76::@78 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:571
Definition unit.h:138
int id
Definition unit.h:145
int homecity
Definition unit.h:146
struct goods_type * carrying
Definition unit.h:186
int veteran
Definition unit.h:152
enum universals_n kind
Definition fc_types.h:902
universals_u value
Definition fc_types.h:901
struct civ_map map
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
size_t fc_strlcpy(char *dest, const char *src, size_t n)
Definition support.c:791
int cat_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:1000
#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:1478
const char * text_happiness_cities(const struct city *pcity)
Definition text.c:1900
static const char * format_duration(int duration)
Definition text.c:1590
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:1828
#define FAR_CITY_SQUARE_DIST
Definition text.c:435
const char * score_tooltip(const struct player *pplayer, int score)
Definition text.c:2126
const char * text_happiness_wonders(const struct city *pcity)
Definition text.c:1870
bool get_units_upgrade_info(char *buf, size_t bufsz, struct unit_list *punits)
Definition text.c:1257
bool get_units_disband_info(char *buf, size_t bufsz, struct unit_list *punits)
Definition text.c:1323
static int turns_to_research_done(const struct research *presearch, int per_turn)
Definition text.c:693
const char * get_airlift_text(const struct unit_list *punits, const struct city *pdest)
Definition text.c:545
const char * get_info_label_text_popup(void)
Definition text.c:969
const char * text_happiness_units(const struct city *pcity)
Definition text.c:2034
const char * text_happiness_luxuries(const struct city *pcity)
Definition text.c:2072
const char * science_dialog_text(void)
Definition text.c:741
static int get_bulbs_per_turn(int *pours, bool *pteam, int *ptheirs)
Definition text.c:649
const char * text_happiness_buildings(const struct city *pcity)
Definition text.c:1800
const char * get_ping_time_text(const struct player *pplayer)
Definition text.c:1621
const char * get_report_title(const char *report_name)
Definition text.c:1672
static int turns_to_tech_loss(const struct research *presearch, int per_turn)
Definition text.c:721
const char * get_nuclear_winter_tooltip(void)
Definition text.c:1451
const char * get_score_text(const struct player *pplayer)
Definition text.c:1650
const char * get_science_target_text(double *percent)
Definition text.c:820
const char * get_bulb_tooltip(void)
Definition text.c:1367
const char * get_timeout_label_text(void)
Definition text.c:1557
const char * get_nearest_city_text(struct city *pcity, int sq_dist)
Definition text.c:441
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:1710
const char * popup_info_text(struct tile *ptile)
Definition text.c:147
const char * unit_description(struct unit *punit)
Definition text.c:475
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:1424
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:917
const char * production_help(const struct universal *uni, char *buf, size_t bufsize)
Definition text.c:2089
static int turns_per_advance(const struct research *presearch, int per_turn)
Definition text.c:708
const char * get_science_goal_text(Tech_type_id goal)
Definition text.c:866
const char * get_unit_info_label_text2(struct unit_list *punits, int linebreaks)
Definition text.c:1079
const char * get_unit_info_label_text1(struct unit_list *punits)
Definition text.c:1054
const char * get_spaceship_descr(struct player_spaceship *pship)
Definition text.c:1500
const char * act_sel_action_tool_tip(const struct action *paction, const struct act_prob prob)
Definition text.c:1789
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:88
@ TILE_UNKNOWN
Definition tile.h:36
#define tile_continent(_tile)
Definition tile.h:92
#define tile_owner(_tile)
Definition tile.h:96
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)
bool can_establish_trade_route(const struct city *pc1, const struct city *pc2)
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:721
const struct impr_type * building
Definition fc_types.h:714
enum unit_upgrade_result unit_upgrade_info(const struct civ_map *nmap, const struct unit *punit, char *buf, size_t bufsz)
Definition unit.c:2051
struct player * unit_nationality(const struct unit *punit)
Definition unit.c:1245
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
int unit_bribe_cost(struct unit *punit, struct player *briber)
Definition unit.c:2304
void unit_upkeep_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1231
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:359
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1155
enum unit_upgrade_result unit_upgrade_test(const struct civ_map *nmap, const struct unit *punit, bool is_free)
Definition unit.c:1988
#define unit_tile(_pu)
Definition unit.h:397
#define unit_owner(_pu)
Definition unit.h:396
@ UU_OK
Definition unit.h:61
#define unit_home(_pu_)
Definition unit.h:394
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:2610
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:1569
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1703
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Definition unittype.c:190
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:1560
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Definition unittype.c:371
int unit_upgrade_price(const struct player *pplayer, const struct unit_type *from, const struct unit_type *to)
Definition unittype.c:1731
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:617
#define unit_type_iterate(_p)
Definition unittype.h:855
#define U_LAST
Definition unittype.h:40
#define unit_type_iterate_end
Definition unittype.h:862