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

Freeciv-3.1

Loading...
Searching...
No Matches
citydlg_common.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#include <stdarg.h>
19
20/* utility */
21#include "astring.h"
22#include "fcintl.h"
23#include "log.h"
24#include "support.h"
25
26/* common */
27#include "city.h"
28#include "culture.h"
29#include "game.h"
30#include "specialist.h"
31#include "unitlist.h"
32
33/* client/include */
34#include "citydlg_g.h"
35#include "mapview_g.h"
36
37/* client */
38#include "citydlg_common.h"
39#include "client_main.h" /* for can_client_issue_orders() */
40#include "climap.h"
41#include "control.h"
42#include "mapview_common.h"
43#include "options.h" /* for concise_city_production */
44#include "tilespec.h" /* for tileset_is_isometric(tileset) */
45
46 static int citydlg_map_width, citydlg_map_height;
47
48/**********************************************************************/
51 int get_citydlg_canvas_width(void)
52{
53 return citydlg_map_width;
54}
55
56/**********************************************************************/
59 int get_citydlg_canvas_height(void)
60{
61 return citydlg_map_height;
62}
63
64/**********************************************************************/
67 void generate_citydlg_dimensions(void)
68{
69 int min_x = 0, max_x = 0, min_y = 0, max_y = 0;
70 int max_rad = rs_max_city_radius_sq();
71
72 /* use maximum possible squared city radius. */
73 city_map_iterate_without_index(max_rad, city_x, city_y) {
74 float canvas_x, canvas_y;
75
76 map_to_gui_vector(get_tileset(), 1.0, &canvas_x, &canvas_y,
77 CITY_ABS2REL(city_x), CITY_ABS2REL(city_y));
78
79 min_x = MIN(canvas_x, min_x);
80 max_x = MAX(canvas_x, max_x);
81 min_y = MIN(canvas_y, min_y);
82 max_y = MAX(canvas_y, max_y);
83 } city_map_iterate_without_index_end;
84
85 citydlg_map_width = max_x - min_x + tileset_tile_width(get_tileset());
86 citydlg_map_height = max_y - min_y + tileset_tile_height(get_tileset());
87}
88
89/**********************************************************************/
93 bool city_to_canvas_pos(float *canvas_x, float *canvas_y, int city_x,
94 int city_y, int city_radius_sq)
95{
96 const int width = get_citydlg_canvas_width();
97 const int height = get_citydlg_canvas_height();
98
99 /* The citymap is centered over the center of the citydlg canvas. */
100 map_to_gui_vector(tileset, 1.0, canvas_x, canvas_y, CITY_ABS2REL(city_x),
101 CITY_ABS2REL(city_y));
102 *canvas_x += (width - tileset_tile_width(tileset)) / 2;
103 *canvas_y += (height - tileset_tile_height(tileset)) / 2;
104
105 fc_assert_ret_val(is_valid_city_coords(city_radius_sq, city_x, city_y),
106 FALSE);
107
108 return TRUE;
109}
110
111/**********************************************************************/
115 bool canvas_to_city_pos(int *city_x, int *city_y, int city_radius_sq,
116 int canvas_x, int canvas_y)
117{
118#ifdef FREECIV_DEBUG
119 int orig_canvas_x = canvas_x, orig_canvas_y = canvas_y;
120#endif
121 const int width = get_citydlg_canvas_width();
122 const int height = get_citydlg_canvas_height();
123
124 /* The citymap is centered over the center of the citydlg canvas. */
125 canvas_x -= (width - tileset_tile_width(get_tileset())) / 2;
126 canvas_y -= (height - tileset_tile_height(get_tileset())) / 2;
127
128 if (tileset_is_isometric(get_tileset())) {
129 const int W = tileset_tile_width(get_tileset()),
130 H = tileset_tile_height(get_tileset());
131
132 /* Shift the tile left so the top corner of the origin tile is at
133 canvas position (0,0). */
134 canvas_x -= W / 2;
135
136 /* Perform a pi / 4 rotation, with scaling. See gui_to_map_pos()
137 for a full explanation. */
138 *city_x = DIVIDE(canvas_x * H + canvas_y * W, W * H);
139 *city_y = DIVIDE(canvas_y * W - canvas_x * H, W * H);
140 } else {
141 *city_x = DIVIDE(canvas_x, tileset_tile_width(get_tileset()));
142 *city_y = DIVIDE(canvas_y, tileset_tile_height(get_tileset()));
143 }
144
145 /* Add on the offset of the top-left corner to get the final
146 * coordinates (like in gui_to_map_pos() ). */
147 *city_x = CITY_REL2ABS(*city_x);
148 *city_y = CITY_REL2ABS(*city_y);
149
150 log_debug("canvas_to_city_pos(pos=(%d,%d))=(%d,%d)@radius=%d",
151 orig_canvas_x, orig_canvas_y, *city_x, *city_y, city_radius_sq);
152
153 return is_valid_city_coords(city_radius_sq, *city_x, *city_y);
154}
155
156/* Iterate over all known tiles in the city. This iteration follows the
157 * painter's algorithm and can be used for drawing. */
158#define citydlg_iterate(pcity, ptile, pedge, pcorner, _x, _y) \
159{ \
160 float _x##_0, _y##_0; \
161 int _tile_x, _tile_y; \
162 const int _x##_w = get_citydlg_canvas_width(); \
163 const int _y##_h = get_citydlg_canvas_height(); \
164 index_to_map_pos(&_tile_x, &_tile_y, tile_index((pcity)->tile)); \
165 \
166 map_to_gui_vector(tileset, 1.0, &_x##_0, &_y##_0, _tile_x, _tile_y); \
167 _x##_0 -= (_x##_w - tileset_tile_width(tileset)) / 2; \
168 _y##_0 -= (_y##_h - tileset_tile_height(tileset)) / 2; \
169 log_debug("citydlg: %f,%f + %dx%d", \
170 _x##_0, _y##_0, _x##_w, _y##_h); \
171 \
172 gui_rect_iterate_coord(_x##_0, _y##_0, _x##_w, _y##_h, \
173 ptile, pedge, pcorner, _x##_g, _y##_g, 1.0) { \
174 const int _x = _x##_g - _x##_0; \
175 const int _y = _y##_g - _y##_0; \
176 {
177
178#define citydlg_iterate_end \
179 } \
180 } gui_rect_iterate_coord_end; \
181}
182
183/**********************************************************************/
187 void city_dialog_redraw_map(struct city *pcity,
188 struct canvas *pcanvas)
189{
190 struct tileset *tmp;
191
192 tmp = NULL;
193 if (unscaled_tileset) {
194 tmp = tileset;
195 tileset = unscaled_tileset;
196 }
197
198 /* First make it all black. */
199 canvas_put_rectangle(pcanvas, get_color(tileset, COLOR_MAPVIEW_UNKNOWN),
200 0, 0,
201 get_citydlg_canvas_width(),
202 get_citydlg_canvas_height());
203
204 mapview_layer_iterate(layer) {
205 citydlg_iterate(pcity, ptile, pedge, pcorner, canvas_x, canvas_y) {
206 struct unit *punit
207 = ptile ? get_drawable_unit(tileset, ptile, pcity) : NULL;
208 struct city *pcity_draw = ptile ? tile_city(ptile) : NULL;
209
210 put_one_element(pcanvas, 1.0, layer, ptile, pedge, pcorner,
211 punit, pcity_draw, canvas_x, canvas_y, pcity, NULL);
212 } citydlg_iterate_end;
213 } mapview_layer_iterate_end;
214
215 if (tmp != NULL) {
216 tileset = tmp;
217 }
218}
219
220/**********************************************************************/
224 char *city_production_cost_str(const struct city *pcity)
225{
226 static char cost_str[50];
227 int cost = city_production_build_shield_cost(pcity);
228 int build_slots = city_build_slots(pcity);
229 int num_units;
230
231 if (build_slots > 1
232 && city_production_build_units(pcity, TRUE, &num_units)) {
233 /* the city could build more than one unit of the selected type */
234 if (num_units == 0) {
235 /* no unit will be finished this turn but one is build */
236 num_units++;
237 }
238
239 if (build_slots > num_units) {
240 /* some build slots for units will be unused */
241 fc_snprintf(cost_str, sizeof(cost_str), "{%d*%d}", num_units, cost);
242 } else {
243 /* maximal number of units will be build */
244 fc_snprintf(cost_str, sizeof(cost_str), "[%d*%d]", num_units, cost);
245 }
246 } else {
247 /* nothing special */
248 fc_snprintf(cost_str, sizeof(cost_str), "%3d", cost);
249 }
250
251 return cost_str;
252}
253
254/**********************************************************************/
260 void get_city_dialog_production(struct city *pcity,
261 char *buffer, size_t buffer_len)
262{
263 char time_str[50], *cost_str;
264 int turns, stock;
265
266 if (pcity == NULL) {
267 /*
268 * Some GUIs use this to build a "filler string" so that they can
269 * properly size the widget to hold the string. This has some
270 * obvious problems; the big one is that we have two forms of time
271 * information: "XXX turns" and "never". Later this may need to
272 * be extended to return the longer of the two; in the meantime
273 * translators can fudge it by changing this "filler" string.
274 */
275 /* TRANS: Use longer of "XXX turns" and "never" */
276 fc_strlcpy(buffer, Q_("?filler:XXX/XXX XXX turns"), buffer_len);
277
278 return;
279 }
280
281 if (city_production_has_flag(pcity, IF_GOLD)) {
282 int gold = MAX(0, pcity->surplus[O_SHIELD]);
283 fc_snprintf(buffer, buffer_len, PL_("%3d gold per turn",
284 "%3d gold per turn", gold), gold);
285 return;
286 }
287
288 turns = city_production_turns_to_build(pcity, TRUE);
289 stock = pcity->shield_stock;
290 cost_str = city_production_cost_str(pcity);
291
292 if (turns < FC_INFINITY) {
293 if (gui_options.concise_city_production) {
294 fc_snprintf(time_str, sizeof(time_str), "%3d", turns);
295 } else {
296 fc_snprintf(time_str, sizeof(time_str),
297 PL_("%3d turn", "%3d turns", turns), turns);
298 }
299 } else {
300 fc_snprintf(time_str, sizeof(time_str), "%s",
301 gui_options.concise_city_production ? "-" : _("never"));
302 }
303
304 if (gui_options.concise_city_production) {
305 fc_snprintf(buffer, buffer_len, _("%3d/%s:%s"), stock, cost_str,
306 time_str);
307 } else {
308 fc_snprintf(buffer, buffer_len, _("%3d/%s %s"), stock, cost_str,
309 time_str);
310 }
311}
312
313
314/**********************************************************************/
324 void get_city_dialog_production_full(char *buffer, size_t buffer_len,
325 struct universal *target,
326 struct city *pcity)
327{
328 int turns = city_turns_to_build(pcity, target, TRUE);
329 int cost = universal_build_shield_cost(pcity, target);
330
331 switch (target->kind) {
332 case VUT_IMPROVEMENT:
333 fc_strlcpy(buffer,
334 city_improvement_name_translation(pcity, target->value.building),
335 buffer_len);
336
337 if (improvement_has_flag(target->value.building, IF_GOLD)) {
338 cat_snprintf(buffer, buffer_len, " (--) ");
339 cat_snprintf(buffer, buffer_len, _("%d/turn"),
340 MAX(0, pcity->surplus[O_SHIELD]));
341 return;
342 }
343 break;
344 default:
345 universal_name_translation(target, buffer, buffer_len);
346 break;
347 };
348 cat_snprintf(buffer, buffer_len, " (%d) ", cost);
349
350 if (turns < FC_INFINITY) {
351 cat_snprintf(buffer, buffer_len,
352 PL_("%d turn", "%d turns", turns),
353 turns);
354 } else {
355 cat_snprintf(buffer, buffer_len, _("never"));
356 }
357}
358
359/**********************************************************************/
364 void get_city_dialog_production_row(char *buf[], size_t column_size,
365 struct universal *target,
366 struct city *pcity)
367{
368 struct player *pplayer = pcity ? city_owner(pcity) : client_player();
369
370 universal_name_translation(target, buf[0], column_size);
371
372 switch (target->kind) {
373 case VUT_UTYPE:
374 {
375 const struct unit_type *ptype = target->value.utype;
376
377 fc_strlcpy(buf[1], utype_values_string(ptype), column_size);
378 fc_snprintf(buf[2], column_size, "(%d)",
379 utype_build_shield_cost(pcity, pplayer, ptype));
380 break;
381 }
382 case VUT_IMPROVEMENT:
383 {
384 const struct impr_type *pimprove = target->value.building;
385
386 /* Total & turns left meaningless on capitalization */
387 if (improvement_has_flag(pimprove, IF_GOLD)) {
388 buf[1][0] = '\0';
389 fc_snprintf(buf[2], column_size, "---");
390 } else {
391 int upkeep = pcity ? city_improvement_upkeep(pcity, pimprove)
392 : pimprove->upkeep;
393 /* from city.c city_improvement_name_translation() */
394 if (pcity && is_improvement_redundant(pcity, pimprove)) {
395 fc_snprintf(buf[1], column_size, "%d*", upkeep);
396 } else {
397 const char *state = NULL;
398
399 if (is_great_wonder(pimprove)) {
400 if (improvement_obsolete(pplayer, pimprove, pcity)) {
401 state = _("Obsolete");
402 } else if (great_wonder_is_built(pimprove)) {
403 state = _("Built");
404 } else if (great_wonder_is_destroyed(pimprove)) {
405 state = _("Destroyed");
406 } else {
407 state = _("Great Wonder");
408 }
409 } else if (is_small_wonder(pimprove)) {
410 if (improvement_obsolete(pplayer, pimprove, pcity)) {
411 state = _("Obsolete");
412 } else if (wonder_is_built(pplayer, target->value.building)) {
413 state = _("Built");
414 } else {
415 state = _("Small Wonder");
416 }
417 }
418 if (state) {
419 fc_strlcpy(buf[1], state, column_size);
420 } else {
421 fc_snprintf(buf[1], column_size, "%d", upkeep);
422 }
423 }
424
425 if (pcity != NULL) {
426 fc_snprintf(buf[2], column_size, "%d",
427 impr_build_shield_cost(pcity, pimprove));
428 } else {
429 fc_snprintf(buf[2], column_size, "%d",
430 impr_estimate_build_shield_cost(pplayer, NULL, pimprove));
431 }
432 }
433 break;
434 }
435 default:
436 buf[1][0] = '\0';
437 buf[2][0] = '\0';
438 break;
439 };
440
441 /* Add the turns-to-build entry in the 4th position */
442 if (pcity) {
443 if (VUT_IMPROVEMENT == target->kind
444 && improvement_has_flag(target->value.building, IF_GOLD)) {
445 fc_snprintf(buf[3], column_size, _("%d/turn"),
446 MAX(0, pcity->surplus[O_SHIELD]));
447 } else {
448 int turns = city_turns_to_build(pcity, target, FALSE);
449
450 if (turns < FC_INFINITY) {
451 fc_snprintf(buf[3], column_size, "%d", turns);
452 } else {
453 fc_snprintf(buf[3], column_size, _("never"));
454 }
455 }
456 } else {
457 fc_snprintf(buf[3], column_size, "---");
458 }
459}
460
461/**********************************************************************/
466 struct city_sum {
467 const char *format;
468 size_t n;
469 struct {
470 /* The net value that is accumulated. */
471 double value;
472 /* Description; compared for duplicate-merging.
473 * Both of these are maintained/compared until the net 'value' is known;
474 * then posdesc is used if value>=0, negdesc if value<0 */
475 char *posdesc, *negdesc;
476 /* Whether posdesc is printed for total==0 */
477 bool suppress_if_zero;
478 /* An auxiliary value that is also accumulated, but not tested */
479 double aux;
480 /* ...and the format string for the net aux value (appended to *desc) */
481 const char *auxfmt;
482 } *sums;
483};
484
485/**********************************************************************/
491 static struct city_sum *city_sum_new(const char *format)
492{
493 struct city_sum *sum = fc_malloc(sizeof(struct city_sum));
494
495 sum->format = format;
496 sum->n = 0;
497 sum->sums = NULL;
498
499 return sum;
500}
501
502/**********************************************************************/
507 static void city_sum_add_real(struct city_sum *sum, double value,
508 bool suppress_if_zero,
509 const char *auxfmt,
510 double aux,
511 char *posdesc,
512 char *negdesc)
513{
514 size_t i;
515
516 /* Likely to lead to quadratic behaviour, but who cares: */
517 for (i = 0; i < sum->n; i++) {
518 fc_assert(sum->sums != NULL);
519 if ((strcmp(sum->sums[i].posdesc, posdesc) == 0)
520 && (strcmp(sum->sums[i].negdesc, negdesc) == 0)
521 && ((sum->sums[i].auxfmt == auxfmt)
522 || (auxfmt != NULL && !strcmp(sum->sums[i].auxfmt, auxfmt)))
523 && sum->sums[i].suppress_if_zero == suppress_if_zero) {
524 /* Looks like we already have an entry like this. Accumulate values. */
525 sum->sums[i].value += value;
526 sum->sums[i].aux += aux;
527 FC_FREE(posdesc);
528 FC_FREE(negdesc);
529 return;
530 }
531 }
532
533 /* Didn't find description already, so add it to the end. */
534 sum->sums = fc_realloc(sum->sums, (sum->n + 1) * sizeof(sum->sums[0]));
535 sum->sums[sum->n].value = value;
536 sum->sums[sum->n].posdesc = posdesc;
537 sum->sums[sum->n].negdesc = negdesc;
538 sum->sums[sum->n].suppress_if_zero = suppress_if_zero;
539 sum->sums[sum->n].aux = aux;
540 sum->sums[sum->n].auxfmt = auxfmt;
541 sum->n++;
542}
543
544/**********************************************************************/
555static void
556 fc__attribute((__format__(__printf__, 6, 8)))
557 fc__attribute((__format__(__printf__, 7, 8)))
558 fc__attribute((nonnull (1, 6, 7)))
559 city_sum_add_full(struct city_sum *sum, double value,
560 bool suppress_if_zero,
561 const char *auxfmt,
562 double aux,
563 const char *posfmt,
564 const char *negfmt,
565 ...)
566{
567 va_list args;
568 struct astring astr = ASTRING_INIT;
569 char *posdesc, *negdesc;
570
571 /* Format both descriptions */
572 va_start(args, negfmt); /* sic -- arguments follow negfmt */
573 astr_vadd(&astr, posfmt, args);
574 posdesc = astr_to_str(&astr);
575 va_end(args);
576 va_start(args, negfmt);
577 astr_vadd(&astr, negfmt, args);
578 negdesc = astr_to_str(&astr);
579 va_end(args);
580
581 city_sum_add_real(sum, value, suppress_if_zero, auxfmt, aux,
582 posdesc, negdesc);
583}
584
585/**********************************************************************/
592static void
593 fc__attribute((__format__(__printf__, 3, 4)))
594 fc__attribute((nonnull (1, 3)))
595 city_sum_add(struct city_sum *sum, double value,
596 const char *descfmt, ...)
597{
598 va_list args;
599 struct astring astr = ASTRING_INIT;
600 char *desc;
601
602 /* Format description (same used for positive or negative net value) */
603 va_start(args, descfmt);
604 astr_vadd(&astr, descfmt, args);
605 desc = astr_to_str(&astr);
606 va_end(args);
607
608 /* Descriptions will be freed individually, so need to strdup */
609 city_sum_add_real(sum, value, FALSE, NULL, 0, desc, fc_strdup(desc));
610}
611
612/**********************************************************************/
619static void
620 fc__attribute((__format__(__printf__, 3, 4)))
621 fc__attribute((nonnull (1, 3)))
622 city_sum_add_if_nonzero(struct city_sum *sum, double value,
623 const char *descfmt, ...)
624{
625 va_list args;
626 struct astring astr = ASTRING_INIT;
627 char *desc;
628
629 /* Format description (same used for positive or negative net value) */
630 va_start(args, descfmt);
631 astr_vadd(&astr, descfmt, args);
632 desc = astr_to_str(&astr);
633 va_end(args);
634
635 /* Descriptions will be freed individually, so need to strdup */
636 city_sum_add_real(sum, value, TRUE, NULL, 0, desc, fc_strdup(desc));
637}
638
639/**********************************************************************/
642 static double city_sum_total(struct city_sum *sum)
643{
644 size_t i;
645 double total = 0;
646
647 for (i = 0; i < sum->n; i++) {
648 total += sum->sums[i].value;
649 }
650 return total;
651}
652
653/**********************************************************************/
659 static inline int city_sum_compare(double val1, double val2)
660{
661 /* Fudgey epsilon -- probably the numbers we're dealing with have at
662 * most 1% or 0.1% real difference */
663 if (fabs(val1-val2) < 0.0000001) {
664 return 0;
665 }
666 return (val1 > val2 ? +1 : -1);
667}
668
669/**********************************************************************/
676static void
677 fc__attribute((__format__(__printf__, 5, 6)))
678 fc__attribute((nonnull (1, 2, 5)))
679 city_sum_print(struct city_sum *sum, char *buf, size_t bufsz,
680 bool account_for_unknown,
681 const char *totalfmt, ...)
682{
683 va_list args;
684 size_t i;
685
686 /* This probably ought not to happen in well-designed rulesets, but it's
687 * possible for incomplete client knowledge to give an inaccurate
688 * breakdown. If it does happen, at least acknowledge to the user that
689 * we are confused, rather than displaying an incorrect sum. */
690 if (account_for_unknown) {
691 double total = city_sum_total(sum);
692 double actual_total;
693
694 va_start(args, totalfmt);
695 actual_total = va_arg(args, double);
696 va_end(args);
697
698 if (city_sum_compare(total, actual_total) != 0) {
699 city_sum_add(sum, actual_total - total,
700 /* TRANS: Client cannot explain some aspect of city
701 * output. Should never happen. */
702 Q_("?city_sum:(unknown)"));
703 }
704 }
705
706 for (i = 0; i < sum->n; i++) {
707 if (!sum->sums[i].suppress_if_zero
708 || city_sum_compare(sum->sums[i].value, 0) != 0) {
709 cat_snprintf(buf, bufsz,
710 sum->format, sum->sums[i].value,
711 (sum->sums[i].value < 0) ? sum->sums[i].negdesc
712 : sum->sums[i].posdesc);
713 if (sum->sums[i].auxfmt) {
714 cat_snprintf(buf, bufsz, sum->sums[i].auxfmt, sum->sums[i].aux);
715 }
716 cat_snprintf(buf, bufsz, "\n");
717 }
718 FC_FREE(sum->sums[i].posdesc);
719 FC_FREE(sum->sums[i].negdesc);
720 }
721
722 va_start(args, totalfmt);
723 fc_vsnprintf(buf + strlen(buf), bufsz - strlen(buf), totalfmt, args);
724 va_end(args);
725
726 FC_FREE(sum->sums);
727 FC_FREE(sum);
728}
729
730/**********************************************************************/
733 void get_city_dialog_output_text(const struct city *pcity,
734 Output_type_id otype,
735 char *buf, size_t bufsz)
736{
737 int priority;
738 int tax[O_LAST];
739 struct output_type *output = &output_types[otype];
740 /* TRANS: format string for a row of the city output sum that adds up
741 * to "Total surplus" */
742 struct city_sum *sum = city_sum_new(Q_("?city_surplus:%+4.0f : %s"));
743
744 buf[0] = '\0';
745
746 city_sum_add(sum, pcity->citizen_base[otype],
747 Q_("?city_surplus:Citizens"));
748
749 /* Hack to get around the ugliness of add_tax_income. */
750 memset(tax, 0, O_LAST * sizeof(*tax));
751 add_tax_income(city_owner(pcity), pcity->prod[O_TRADE], tax);
752 city_sum_add_if_nonzero(sum, tax[otype],
753 Q_("?city_surplus:Taxed from trade"));
754
755 /* Special cases for "bonus" production. See set_city_production in
756 * city.c. */
757 if (otype == O_TRADE) {
758 trade_routes_iterate(pcity, proute) {
759 /* NB: (proute->value == 0) is valid case. The trade route
760 * is established but doesn't give trade surplus. */
761 struct city *trade_city = game_city_by_number(proute->partner);
762 /* TRANS: Trade partner unknown to client */
763 const char *name = trade_city ? city_name_get(trade_city) : _("(unknown)");
764 int value = proute->value
765 * (100 + get_city_bonus(pcity, EFT_TRADE_ROUTE_PCT)) / 100;
766
767 switch (proute->dir) {
768 case RDIR_BIDIRECTIONAL:
769 city_sum_add(sum, value, Q_("?city_surplus:Trading %s with %s"),
770 goods_name_translation(proute->goods),
771 name);
772 break;
773 case RDIR_FROM:
774 city_sum_add(sum, value, Q_("?city_surplus:Trading %s to %s"),
775 goods_name_translation(proute->goods),
776 name);
777 break;
778 case RDIR_TO:
779 city_sum_add(sum, value, Q_("?city_surplus:Trading %s from %s"),
780 goods_name_translation(proute->goods),
781 name);
782 break;
783 case RDIR_NONE:
784 fc_assert(proute->dir != RDIR_NONE);
785 break;
786 }
787 } trade_routes_iterate_end;
788 } else if (otype == O_GOLD) {
789 int tithes = get_city_tithes_bonus(pcity);
790
791 city_sum_add_if_nonzero(sum, tithes,
792 Q_("?city_surplus:Building tithes"));
793 }
794
795 for (priority = 0; priority < 2; priority++) {
796 enum effect_type eft[] = {EFT_OUTPUT_BONUS, EFT_OUTPUT_BONUS_2};
797
798 {
799 int base = city_sum_total(sum), bonus = 100;
800 struct effect_list *plist = effect_list_new();
801
802 (void) get_city_bonus_effects(plist, pcity, output, eft[priority]);
803
804 effect_list_iterate(plist, peffect) {
805 char buf2[512];
806 int delta;
807 int new_total;
808
809 get_effect_req_text(peffect, buf2, sizeof(buf2));
810
811 if (peffect->multiplier) {
812 int mul = player_multiplier_effect_value(city_owner(pcity),
813 peffect->multiplier);
814
815 if (mul == 0) {
816 /* Suppress text when multiplier setting suppresses effect
817 * (this will also suppress it when the city owner's policy
818 * settings are not known to us) */
819 continue;
820 }
821 delta = (peffect->value * mul) / 100;
822 } else {
823 delta = peffect->value;
824 }
825 bonus += delta;
826 new_total = bonus * base / 100;
827 city_sum_add_full(sum, new_total - city_sum_total(sum), TRUE,
828 /* TRANS: percentage city output bonus/loss from
829 * some source; preserve leading space */
830 Q_("?city_surplus: (%+.0f%%)"), delta,
831 Q_("?city_surplus:Bonus from %s"),
832 Q_("?city_surplus:Loss from %s"), buf2);
833 } effect_list_iterate_end;
834 effect_list_destroy(plist);
835 }
836 }
837
838 if (pcity->waste[otype] != 0) {
839 int wastetypes[OLOSS_LAST];
840 bool breakdown_ok;
841 int regular_waste;
842 /* FIXME: this will give the wrong answer in rulesets with waste on
843 * taxed outputs, such as 'science waste', as our total so far includes
844 * contributions taxed from trade, whereas the equivalent bit in
845 * set_city_production() does not */
846 if (city_waste(pcity, otype, city_sum_total(sum), wastetypes)
847 == pcity->waste[otype]) {
848 /* Our calculation matches the server's, so we trust our breakdown. */
849 city_sum_add_if_nonzero(sum, -wastetypes[OLOSS_SIZE],
850 Q_("?city_surplus:Size penalty"));
851 regular_waste = wastetypes[OLOSS_WASTE];
852 breakdown_ok = TRUE;
853 } else {
854 /* Our calculation doesn't match what the server sent. Account it all
855 * to corruption/waste. */
856 regular_waste = pcity->waste[otype];
857 breakdown_ok = FALSE;
858 }
859 if (regular_waste > 0) {
860 const char *fmt;
861 switch (otype) {
862 case O_SHIELD:
863 default: /* FIXME other output types? */
864 /* TRANS: %s is normally empty, but becomes '?' if client is
865 * uncertain about its accounting (should never happen) */
866 fmt = Q_("?city_surplus:Waste%s");
867 break;
868 case O_TRADE:
869 /* TRANS: %s is normally empty, but becomes '?' if client is
870 * uncertain about its accounting (should never happen) */
871 fmt = Q_("?city_surplus:Corruption%s");
872 break;
873 }
874 city_sum_add(sum, -regular_waste, fmt, breakdown_ok ? "" : "?");
875 }
876 }
877
878 city_sum_add_if_nonzero(sum, -pcity->unhappy_penalty[otype],
879 Q_("?city_surplus:Disorder"));
880
881 if (pcity->usage[otype] > 0) {
882 city_sum_add(sum, -pcity->usage[otype],
883 Q_("?city_surplus:Used"));
884 }
885
886 city_sum_print(sum, buf, bufsz, TRUE,
887 Q_("?city_surplus:"
888 "==== : Adds up to\n"
889 "%4.0f : Total surplus"), (double) pcity->surplus[otype]);
890}
891
892/**********************************************************************/
895 void get_city_dialog_illness_text(const struct city *pcity,
896 char *buf, size_t bufsz)
897{
898 int illness, ill_base, ill_size, ill_trade, ill_pollution;
899 struct effect_list *plist;
900 struct city_sum *sum;
901
902 buf[0] = '\0';
903
904 if (!game.info.illness_on) {
905 cat_snprintf(buf, bufsz, _("Illness deactivated in ruleset."));
906 return;
907 }
908
909 sum = city_sum_new(Q_("?city_plague:%+5.1f%% : %s"));
910
911 illness = city_illness_calc(pcity, &ill_base, &ill_size, &ill_trade,
912 &ill_pollution);
913
914 city_sum_add(sum, (float)(ill_size) / 10.0,
915 Q_("?city_plague:Risk from overcrowding"));
916 city_sum_add(sum, (float)(ill_trade) / 10.0,
917 Q_("?city_plague:Risk from trade"));
918 city_sum_add(sum, (float)(ill_pollution) / 10.0,
919 Q_("?city_plague:Risk from pollution"));
920
921 plist = effect_list_new();
922
923 (void) get_city_bonus_effects(plist, pcity, NULL, EFT_HEALTH_PCT);
924
925 effect_list_iterate(plist, peffect) {
926 char buf2[512];
927 int delta;
928
929 get_effect_req_text(peffect, buf2, sizeof(buf2));
930
931 if (peffect->multiplier) {
932 int mul = player_multiplier_effect_value(city_owner(pcity),
933 peffect->multiplier);
934
935 if (mul == 0) {
936 /* Suppress text when multiplier setting suppresses effect
937 * (this will also suppress it when the city owner's policy
938 * settings are not known to us) */
939 continue;
940 }
941 delta = (peffect->value * mul) / 100;
942 } else {
943 delta = peffect->value;
944 }
945
946 city_sum_add_full(sum, -(0.1 * ill_base * delta / 100), TRUE,
947 Q_("?city_plague: (%+.0f%%)"), -delta,
948 Q_("?city_plague:Risk from %s"),
949 Q_("?city_plague:Bonus from %s"), buf2);
950 } effect_list_iterate_end;
951 effect_list_destroy(plist);
952
953 /* XXX: account_for_unknown==FALSE: the displayed sum can fail to
954 * add up due to rounding. Making it always add up probably requires
955 * arbitrary assignment of 0.1% rounding figures to particular
956 * effects with something like distribute(). */
957 city_sum_print(sum, buf, bufsz, FALSE,
958 Q_("?city_plague:"
959 "====== : Adds up to\n"
960 "%5.1f%% : Plague chance per turn"),
961 ((double)(illness) / 10.0));
962}
963
964/**********************************************************************/
967 void get_city_dialog_pollution_text(const struct city *pcity,
968 char *buf, size_t bufsz)
969{
970 int pollu, prod, pop, mod;
971 struct city_sum *sum = city_sum_new(Q_("?city_pollution:%+4.0f : %s"));
972
973 /* On the server, pollution is calculated before production is deducted
974 * for disorder; we need to compensate for that */
975 pollu = city_pollution_types(pcity,
976 pcity->prod[O_SHIELD]
977 + pcity->unhappy_penalty[O_SHIELD],
978 &prod, &pop, &mod);
979 buf[0] = '\0';
980
981 city_sum_add(sum, prod, Q_("?city_pollution:Pollution from shields"));
982 city_sum_add(sum, pop, Q_("?city_pollution:Pollution from citizens"));
983 city_sum_add(sum, mod, Q_("?city_pollution:Pollution modifier"));
984 city_sum_print(sum, buf, bufsz, FALSE,
985 Q_("?city_pollution:"
986 "==== : Adds up to\n"
987 "%4.0f : Total surplus"), (double)pollu);
988}
989
990/**********************************************************************/
993 void get_city_dialog_culture_text(const struct city *pcity,
994 char *buf, size_t bufsz)
995{
996 struct effect_list *plist;
997 struct city_sum *sum = city_sum_new(Q_("?city_culture:%4.0f : %s"));
998
999 buf[0] = '\0';
1000
1001 /* XXX: no way to check whether client's idea of gain/turn is accurate */
1002 city_sum_add(sum, pcity->history, Q_("?city_culture:History (%+d/turn)"),
1003 city_history_gain(pcity));
1004
1005 plist = effect_list_new();
1006
1007 (void) get_city_bonus_effects(plist, pcity, NULL, EFT_PERFORMANCE);
1008
1009 effect_list_iterate(plist, peffect) {
1010 char buf2[512];
1011 int mul = 100;
1012 int value;
1013
1014 get_effect_req_text(peffect, buf2, sizeof(buf2));
1015
1016 if (peffect->multiplier) {
1017 mul = player_multiplier_effect_value(city_owner(pcity),
1018 peffect->multiplier);
1019
1020 if (mul == 0) {
1021 /* Suppress text when multiplier setting suppresses effect
1022 * (this will also suppress it when the city owner's policy
1023 * settings are not known to us) */
1024 continue;
1025 }
1026 }
1027
1028 value = (peffect->value * mul) / 100;
1029 /* TRANS: text describing source of culture bonus ("Library+Republic") */
1030 city_sum_add_if_nonzero(sum, value, Q_("?city_culture:%s"), buf2);
1031 } effect_list_iterate_end;
1032 effect_list_destroy(plist);
1033
1034 city_sum_print(sum, buf, bufsz, TRUE,
1035 Q_("?city_culture:"
1036 "==== : Adds up to\n"
1037 "%4.0f : Total culture"), (double)pcity->client.culture);
1038}
1039
1040/**********************************************************************/
1043 void get_city_dialog_airlift_text(const struct city *pcity,
1044 char *buf, size_t bufsz)
1045{
1046 char src[512];
1047 char dest[512];
1048 int unlimited = 0;
1049
1050 if ((game.info.airlifting_style & AIRLIFTING_UNLIMITED_SRC)
1051 && (pcity->airlift >= 1 || game.info.airlift_from_always_enabled)) {
1052
1053 unlimited++;
1054
1055 /* TRANS: airlift. Possible take offs text. String is a
1056 * proviso that take offs can't occur if landings spend all the
1057 * remaining airlift when landings are limited and empty when they
1058 * aren't limited. */
1059 fc_snprintf(src, sizeof(src), _("unlimited take offs%s"),
1060 game.info.airlifting_style & AIRLIFTING_UNLIMITED_DEST
1061 /* TRANS: airlift unlimited take offs proviso used above.
1062 * Plural based on remaining airlift capacity. */
1063 ? "" : PL_(" (until the landing has been spent)",
1064 " (until all landings have been spent)",
1065 pcity->airlift));
1066 } else {
1067 fc_snprintf(src, sizeof(src),
1068 /* TRANS: airlift. Possible take offs text. Number is
1069 * airlift capacity. */
1070 PL_("%d take off", "%d take offs", pcity->airlift),
1071 pcity->airlift);
1072 }
1073
1074 if ((game.info.airlifting_style & AIRLIFTING_UNLIMITED_DEST)
1075 && (pcity->airlift >= 1 || game.info.airlift_to_always_enabled)){
1076
1077 unlimited++;
1078
1079 /* TRANS: airlift. Possible landings text. */
1080 fc_snprintf(dest, sizeof(dest), _("unlimited landings"));
1081 } else {
1082 fc_snprintf(dest, sizeof(dest),
1083 /* TRANS: airlift. Possible landings text.
1084 * Number is airlift capacity. */
1085 PL_("%d landing", "%d landings", pcity->airlift),
1086 pcity->airlift);
1087 }
1088
1089 switch (unlimited) {
1090 case 2:
1091 /* TRANS: airlift take offs and landings */
1092 fc_snprintf(buf, bufsz, _("unlimited take offs and landings"));
1093 break;
1094 case 1:
1095 /* TRANS: airlift take offs and landings. One is unlimited. The first
1096 * string is the take offs text. The 2nd string is the landings text. */
1097 fc_snprintf(buf, bufsz, _("%s and %s"), src, dest);
1098 break;
1099 default:
1100 fc_snprintf(buf, bufsz,
1101 /* TRANS: airlift take offs or landings, no unlimited.
1102 * Number is airlift capacity. */
1103 PL_("%d take off or landing", "%d take offs or landings",
1104 pcity->airlift),
1105 pcity->airlift);
1106 break;
1107 }
1108}
1109
1110/**********************************************************************/
1113 void get_city_dialog_airlift_value(const struct city *pcity,
1114 char *buf, size_t bufsz)
1115{
1116 char src[512];
1117 char dest[512];
1118 int unlimited = 0;
1119
1120 if ((game.info.airlifting_style & AIRLIFTING_UNLIMITED_SRC)
1121 && (pcity->airlift >= 1 || game.info.airlift_from_always_enabled)) {
1122
1123 unlimited++;
1124
1125 /* TRANS: airlift. Possible take offs text. String is a symbol that
1126 * indicates that terms and conditions apply when landings are limited
1127 * and empty when they aren't limited. */
1128 fc_snprintf(src, sizeof(src), _(" ∞%s"),
1129 game.info.airlifting_style & AIRLIFTING_UNLIMITED_DEST
1130 /* TRANS: airlift unlimited take offs may be spent symbol
1131 * used above. */
1132 ? "" : _("*"));
1133 } else {
1134 /* TRANS: airlift. Possible take offs text. Number is
1135 * airlift capacity. */
1136 fc_snprintf(src, sizeof(src), _("%4d"), pcity->airlift);
1137 }
1138
1139 if ((game.info.airlifting_style & AIRLIFTING_UNLIMITED_DEST)
1140 && (pcity->airlift >= 1 || game.info.airlift_to_always_enabled)){
1141
1142 unlimited++;
1143
1144 /* TRANS: airlift. Possible landings text. */
1145 fc_snprintf(dest, sizeof(dest), _(" ∞"));
1146 } else {
1147 /* TRANS: airlift. Possible landings text. */
1148 fc_snprintf(dest, sizeof(dest), _("%4d"), pcity->airlift);
1149 }
1150
1151 switch (unlimited) {
1152 case 2:
1153 /* TRANS: unlimited airlift take offs and landings */
1154 fc_snprintf(buf, bufsz, _(" ∞"));
1155 break;
1156 case 1:
1157 /* TRANS: airlift take offs and landings. One is unlimited. The first
1158 * string is the take offs text. The 2nd string is the landings text.
1159 * For English, initials of d)epartures and a)rrivals were chosen. */
1160 fc_snprintf(buf, bufsz, _("d: %s a: %s"), src, dest);
1161 break;
1162 default:
1163 /* TRANS: airlift take offs or landings, no unlimited */
1164 fc_snprintf(buf, bufsz, _("%s"), src);
1165 break;
1166 }
1167}
1168
1169/**********************************************************************/
1175 int get_city_citizen_types(struct city *pcity, enum citizen_feeling idx,
1176 enum citizen_category *categories)
1177{
1178 int i = 0, n;
1179
1180 fc_assert(idx >= 0 && idx < FEELING_LAST);
1181
1182 for (n = 0; n < pcity->feel[CITIZEN_HAPPY][idx]; n++, i++) {
1183 categories[i] = CITIZEN_HAPPY;
1184 }
1185 for (n = 0; n < pcity->feel[CITIZEN_CONTENT][idx]; n++, i++) {
1186 categories[i] = CITIZEN_CONTENT;
1187 }
1188 for (n = 0; n < pcity->feel[CITIZEN_UNHAPPY][idx]; n++, i++) {
1189 categories[i] = CITIZEN_UNHAPPY;
1190 }
1191 for (n = 0; n < pcity->feel[CITIZEN_ANGRY][idx]; n++, i++) {
1192 categories[i] = CITIZEN_ANGRY;
1193 }
1194
1195 specialist_type_iterate(sp) {
1196 for (n = 0; n < pcity->specialists[sp]; n++, i++) {
1197 categories[i] = CITIZEN_SPECIALIST + sp;
1198 }
1199 } specialist_type_iterate_end;
1200
1201 if (city_size_get(pcity) != i) {
1202 log_error("get_city_citizen_types() %d citizens "
1203 "not equal %d city size in \"%s\".",
1204 i, city_size_get(pcity), city_name_get(pcity));
1205 }
1206 return i;
1207}
1208
1209/**********************************************************************/
1212 void city_rotate_specialist(struct city *pcity, int citizen_index)
1213{
1214 enum citizen_category categories[MAX_CITY_SIZE];
1215 Specialist_type_id from, to;
1216 int num_citizens = get_city_citizen_types(pcity, FEELING_FINAL, categories);
1217
1218 if (citizen_index < 0 || citizen_index >= num_citizens
1219 || categories[citizen_index] < CITIZEN_SPECIALIST) {
1220 return;
1221 }
1222 from = categories[citizen_index] - CITIZEN_SPECIALIST;
1223
1224 /* Loop through all specialists in order until we find a usable one
1225 * (or run out of choices). */
1226 to = from;
1227 fc_assert(to >= 0 && to < specialist_count());
1228 do {
1229 to = (to + 1) % specialist_count();
1230 } while (to != from && !city_can_use_specialist(pcity, to));
1231
1232 if (from != to) {
1233 city_change_specialist(pcity, from, to);
1234 }
1235}
1236
1237/**********************************************************************/
1240 void activate_all_units(struct tile *ptile)
1241{
1242 struct unit_list *punit_list = ptile->units;
1243 struct unit *pmyunit = NULL;
1244
1245 unit_list_iterate(punit_list, punit) {
1246 if (unit_owner(punit) == client.conn.playing) {
1247 /* Activate this unit. */
1248 pmyunit = punit;
1249 request_new_unit_activity(punit, ACTIVITY_IDLE);
1250 }
1251 } unit_list_iterate_end;
1252 if (pmyunit) {
1253 /* Put the focus on one of the activated units. */
1254 unit_focus_set(pmyunit);
1255 }
1256}
1257
1258/**********************************************************************/
1261 int city_change_production(struct city *pcity, struct universal *target)
1262{
1263 return dsend_packet_city_change(&client.conn, pcity->id, pcity->id,
1264 target->kind,
1265 universal_number(target));
1266}
1267
1268/**********************************************************************/
1273 int city_set_worklist(struct city *pcity, const struct worklist *pworklist)
1274{
1275 return dsend_packet_city_worklist(&client.conn, pcity->id, pcity->id,
1276 pworklist);
1277}
1278
1279/**********************************************************************/
1282 void city_worklist_commit(struct city *pcity, struct worklist *pwl)
1283{
1284 int k;
1285
1286 /* Update the worklist. Remember, though -- the current build
1287 target really isn't in the worklist; don't send it to the server
1288 as part of the worklist. Of course, we have to search through
1289 the current worklist to find the first _now_available_ build
1290 target (to cope with players who try mean things like adding a
1291 Battleship to a city worklist when the player doesn't even yet
1292 have the Map Making tech). */
1293
1294 for (k = 0; k < MAX_LEN_WORKLIST; k++) {
1295 int same_as_current_build;
1296 struct universal target;
1297
1298 if (!worklist_peek_ith(pwl, &target, k)) {
1299 break;
1300 }
1301
1302 same_as_current_build = are_universals_equal(&pcity->production, &target);
1303
1304 /* Very special case: If we are currently building a wonder we
1305 allow the construction to continue, even if we the wonder is
1306 finished elsewhere, ie unbuildable. */
1307 if (k == 0
1308 && VUT_IMPROVEMENT == target.kind
1309 && is_wonder(target.value.building)
1310 && same_as_current_build) {
1311 worklist_remove(pwl, k);
1312 break;
1313 }
1314
1315 /* If it can be built... */
1316 if (can_city_build_now(pcity, &target)) {
1317 /* ...but we're not yet building it, then switch. */
1318 if (!same_as_current_build) {
1319 /* Change the current target */
1320 city_change_production(pcity, &target);
1321 }
1322
1323 /* This item is now (and may have always been) the current
1324 build target. Drop it out of the worklist. */
1325 worklist_remove(pwl, k);
1326 break;
1327 }
1328 }
1329
1330 /* Send the rest of the worklist on its way. */
1331 city_set_worklist(pcity, pwl);
1332}
1333
1334/**********************************************************************/
1342 static bool base_city_queue_insert(struct city *pcity, int position,
1343 struct universal *item)
1344{
1345 if (position == 0) {
1346 struct universal old = pcity->production;
1347
1348 /* Insert as current production. */
1349 if (!can_city_build_direct(pcity, item)) {
1350 return FALSE;
1351 }
1352
1353 if (!worklist_insert(&pcity->worklist, &old, 0)) {
1354 return FALSE;
1355 }
1356
1357 city_change_production(pcity, item);
1358 } else if (position >= 1
1359 && position <= worklist_length(&pcity->worklist)) {
1360 /* Insert into middle. */
1361 if (!can_city_build_later(pcity, item)) {
1362 return FALSE;
1363 }
1364 if (!worklist_insert(&pcity->worklist, item, position - 1)) {
1365 return FALSE;
1366 }
1367 } else {
1368 /* Insert at end. */
1369 if (!can_city_build_later(pcity, item)) {
1370 return FALSE;
1371 }
1372 if (!worklist_append(&pcity->worklist, item)) {
1373 return FALSE;
1374 }
1375 }
1376 return TRUE;
1377}
1378
1379/**********************************************************************/
1384 bool city_queue_insert(struct city *pcity, int position,
1385 struct universal *item)
1386{
1387 if (base_city_queue_insert(pcity, position, item)) {
1388 city_set_worklist(pcity, &pcity->worklist);
1389 return TRUE;
1390 }
1391 return FALSE;
1392}
1393
1394/**********************************************************************/
1400 bool city_queue_clear(struct city *pcity)
1401{
1402 worklist_init(&pcity->worklist);
1403
1404 return TRUE;
1405}
1406
1407/**********************************************************************/
1412 bool city_queue_insert_worklist(struct city *pcity, int position,
1413 const struct worklist *worklist)
1414{
1415 bool success = FALSE;
1416
1417 if (worklist_length(worklist) == 0) {
1418 return TRUE;
1419 }
1420
1421 worklist_iterate(worklist, target) {
1422 if (base_city_queue_insert(pcity, position, &target)) {
1423 if (position > 0) {
1424 /* Move to the next position (unless position == -1 in which case
1425 * we're appending. */
1426 position++;
1427 }
1428 success = TRUE;
1429 }
1430 } worklist_iterate_end;
1431
1432 if (success) {
1433 city_set_worklist(pcity, &pcity->worklist);
1434 }
1435
1436 return success;
1437}
1438
1439/**********************************************************************/
1442 void city_get_queue(struct city *pcity, struct worklist *pqueue)
1443{
1444 worklist_copy(pqueue, &pcity->worklist);
1445
1446 /* The GUI wants current production to be in the task list, but the
1447 worklist API wants it out for reasons unknown. Perhaps someone enjoyed
1448 making things more complicated than necessary? So I dance around it. */
1449
1450 /* We want the current production to be in the queue. Always. */
1451 worklist_remove(pqueue, MAX_LEN_WORKLIST - 1);
1452
1453 worklist_insert(pqueue, &pcity->production, 0);
1454}
1455
1456/**********************************************************************/
1459 bool city_set_queue(struct city *pcity, const struct worklist *pqueue)
1460{
1461 struct worklist copy;
1462 struct universal target;
1463
1464 worklist_copy(&copy, pqueue);
1465
1466 /* The GUI wants current production to be in the task list, but the
1467 worklist API wants it out for reasons unknown. Perhaps someone enjoyed
1468 making things more complicated than necessary? So I dance around it. */
1469 if (worklist_peek(&copy, &target)) {
1470
1471 if (!city_can_change_build(pcity)
1472 && !are_universals_equal(&pcity->production, &target)) {
1473 /* We cannot change production to one from worklist.
1474 * Do not replace old worklist with new one. */
1475 return FALSE;
1476 }
1477
1478 worklist_advance(&copy);
1479
1480 city_set_worklist(pcity, &copy);
1481 city_change_production(pcity, &target);
1482 } else {
1483 /* You naughty boy, you can't erase the current production. Nyah! */
1484 if (worklist_is_empty(&pcity->worklist)) {
1485 refresh_city_dialog(pcity);
1486 } else {
1487 city_set_worklist(pcity, &copy);
1488 }
1489 }
1490
1491 return TRUE;
1492}
1493
1494/**********************************************************************/
1497 bool city_can_buy(const struct city *pcity)
1498{
1499 /* See really_handle_city_buy() in the server. However this function
1500 * doesn't allow for error messages. It doesn't check the cost of
1501 * buying; that's handled separately (and with an error message). */
1502 return (can_client_issue_orders()
1503 && NULL != pcity
1504 && city_owner(pcity) == client.conn.playing
1505 && pcity->turn_founded != game.info.turn
1506 && !pcity->did_buy
1507 && (VUT_UTYPE == pcity->production.kind
1508 || !improvement_has_flag(pcity->production.value.building, IF_GOLD))
1509 && !(VUT_UTYPE == pcity->production.kind
1510 && pcity->anarchy != 0)
1511 && pcity->client.buy_cost > 0);
1512}
1513
1514/**********************************************************************/
1517 int city_sell_improvement(struct city *pcity, Impr_type_id sell_id)
1518{
1519 return dsend_packet_city_sell(&client.conn, pcity->id, pcity->id, sell_id);
1520}
1521
1522/**********************************************************************/
1525 int city_buy_production(struct city *pcity)
1526{
1527 return dsend_packet_city_buy(&client.conn, pcity->id, pcity->id);
1528}
1529
1530/**********************************************************************/
1533 int city_change_specialist(struct city *pcity, Specialist_type_id from,
1534 Specialist_type_id to)
1535{
1536 return dsend_packet_city_change_specialist(&client.conn,
1537 pcity->id, pcity->id, from,
1538 to);
1539}
1540
1541/**********************************************************************/
1545 int city_toggle_worker(struct city *pcity, int city_x, int city_y)
1546{
1547 int city_radius_sq;
1548 struct tile *ptile;
1549
1550 if (city_owner(pcity) != client_player()) {
1551 return 0;
1552 }
1553
1554 city_radius_sq = city_map_radius_sq_get(pcity);
1555 fc_assert(is_valid_city_coords(city_radius_sq, city_x, city_y));
1556 ptile = city_map_to_tile(&(wld.map), city_tile(pcity), city_radius_sq,
1557 city_x, city_y);
1558 if (NULL == ptile) {
1559 return 0;
1560 }
1561
1562 if (NULL != tile_worked(ptile) && tile_worked(ptile) == pcity) {
1563 return dsend_packet_city_make_specialist(&client.conn,
1564 pcity->id, pcity->id,
1565 ptile->index);
1566 } else if (city_can_work_tile(pcity, ptile)) {
1567 return dsend_packet_city_make_worker(&client.conn,
1568 pcity->id, pcity->id, ptile->index);
1569 } else {
1570 return 0;
1571 }
1572}
1573
1574/**********************************************************************/
1577 int city_rename(struct city *pcity, const char *name)
1578{
1579 return dsend_packet_city_rename(&client.conn, pcity->id, pcity->id, name);
1580}
astr_vadd
void astr_vadd(struct astring *astr, const char *format, va_list ap)
Definition astring.c:279
astr_to_str
char * astr_to_str(struct astring *astr)
Definition astring.c:167
n
#define n
Definition astring.c:77
astring.h
ASTRING_INIT
#define ASTRING_INIT
Definition astring.h:44
height
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
canvas_y
struct canvas int int canvas_y
Definition canvas_g.h:43
canvas_x
struct canvas int canvas_x
Definition canvas_g.h:43
width
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
pcanvas
struct canvas * pcanvas
Definition canvas_g.h:42
city_turns_to_build
int city_turns_to_build(const struct city *pcity, const struct universal *target, bool include_shield_stock)
Definition city.c:1930
city_improvement_name_translation
const char * city_improvement_name_translation(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:657
city_production_build_shield_cost
int city_production_build_shield_cost(const struct city *pcity)
Definition city.c:721
city_pollution_types
int city_pollution_types(const struct city *pcity, int shield_total, int *pollu_prod, int *pollu_pop, int *pollu_mod)
Definition city.c:2680
can_city_build_now
bool can_city_build_now(const struct city *pcity, const struct universal *target)
Definition city.c:984
city_waste
int city_waste(const struct city *pcity, Output_type_id otype, int total, int *breakdown)
Definition city.c:3110
city_build_slots
int city_build_slots(const struct city *pcity)
Definition city.c:2825
city_map_to_tile
struct tile * city_map_to_tile(const struct civ_map *nmap, const struct tile *city_center, int city_radius_sq, int city_map_x, int city_map_y)
Definition city.c:299
city_name_get
const char * city_name_get(const struct city *pcity)
Definition city.c:1106
city_improvement_upkeep
int city_improvement_upkeep(const struct city *pcity, const struct impr_type *b)
Definition city.c:1222
city_can_use_specialist
bool city_can_use_specialist(const struct city *pcity, Specialist_type_id type)
Definition city.c:1034
city_production_has_flag
bool city_production_has_flag(const struct city *pcity, enum impr_flag_id flag)
Definition city.c:711
add_tax_income
void add_tax_income(const struct player *pplayer, int trade, int *output)
Definition city.c:2208
get_city_tithes_bonus
int get_city_tithes_bonus(const struct city *pcity)
Definition city.c:2190
city_production_turns_to_build
int city_production_turns_to_build(const struct city *pcity, bool include_shield_stock)
Definition city.c:804
city_illness_calc
int city_illness_calc(const struct city *pcity, int *ill_base, int *ill_size, int *ill_trade, int *ill_pollution)
Definition city.c:2763
is_valid_city_coords
bool is_valid_city_coords(const int city_radius_sq, const int city_map_x, const int city_map_y)
Definition city.c:182
city_map_radius_sq_get
int city_map_radius_sq_get(const struct city *pcity)
Definition city.c:131
can_city_build_direct
bool can_city_build_direct(const struct city *pcity, const struct universal *target)
Definition city.c:966
rs_max_city_radius_sq
int rs_max_city_radius_sq(void)
Definition city.c:153
can_city_build_later
bool can_city_build_later(const struct city *pcity, const struct universal *target)
Definition city.c:1001
city_can_work_tile
bool city_can_work_tile(const struct city *pcity, const struct tile *ptile)
Definition city.c:1420
city_production_build_units
bool city_production_build_units(const struct city *pcity, bool add_production, int *num_units)
Definition city.c:731
output_types
struct output_type output_types[O_LAST]
Definition city.c:82
city_can_change_build
bool city_can_change_build(const struct city *pcity)
Definition city.c:1048
city.h
city_tile
#define city_tile(_pcity_)
Definition city.h:544
city_size_get
static citizens city_size_get(const struct city *pcity)
Definition city.h:549
citizen_category
citizen_category
Definition city.h:259
CITIZEN_SPECIALIST
@ CITIZEN_SPECIALIST
Definition city.h:265
CITIZEN_ANGRY
@ CITIZEN_ANGRY
Definition city.h:263
CITIZEN_HAPPY
@ CITIZEN_HAPPY
Definition city.h:260
CITIZEN_CONTENT
@ CITIZEN_CONTENT
Definition city.h:261
CITIZEN_UNHAPPY
@ CITIZEN_UNHAPPY
Definition city.h:262
CITY_REL2ABS
#define CITY_REL2ABS(_coor)
Definition city.h:107
city_owner
#define city_owner(_pcity_)
Definition city.h:543
MAX_CITY_SIZE
#define MAX_CITY_SIZE
Definition city.h:98
citizen_feeling
citizen_feeling
Definition city.h:270
FEELING_FINAL
@ FEELING_FINAL
Definition city.h:276
FEELING_LAST
@ FEELING_LAST
Definition city.h:277
OLOSS_SIZE
@ OLOSS_SIZE
Definition city.h:283
OLOSS_WASTE
@ OLOSS_WASTE
Definition city.h:282
OLOSS_LAST
@ OLOSS_LAST
Definition city.h:284
city_map_iterate_without_index_end
#define city_map_iterate_without_index_end
Definition city.h:176
CITY_ABS2REL
#define CITY_ABS2REL(_coor)
Definition city.h:108
city_map_iterate_without_index
#define city_map_iterate_without_index(_radius_sq, _x, _y)
Definition city.h:172
city_sum_total
static double city_sum_total(struct city_sum *sum)
Definition citydlg_common.c:642
get_city_dialog_production_row
void get_city_dialog_production_row(char *buf[], size_t column_size, struct universal *target, struct city *pcity)
Definition citydlg_common.c:364
get_city_dialog_output_text
void get_city_dialog_output_text(const struct city *pcity, Output_type_id otype, char *buf, size_t bufsz)
Definition citydlg_common.c:733
citydlg_iterate_end
#define citydlg_iterate_end
Definition citydlg_common.c:178
get_city_dialog_production
void get_city_dialog_production(struct city *pcity, char *buffer, size_t buffer_len)
Definition citydlg_common.c:260
city_set_worklist
int city_set_worklist(struct city *pcity, const struct worklist *pworklist)
Definition citydlg_common.c:1273
city_rename
int city_rename(struct city *pcity, const char *name)
Definition citydlg_common.c:1577
city_worklist_commit
void city_worklist_commit(struct city *pcity, struct worklist *pwl)
Definition citydlg_common.c:1282
citydlg_iterate
#define citydlg_iterate(pcity, ptile, pedge, pcorner, _x, _y)
Definition citydlg_common.c:158
get_city_citizen_types
int get_city_citizen_types(struct city *pcity, enum citizen_feeling idx, enum citizen_category *categories)
Definition citydlg_common.c:1175
city_buy_production
int city_buy_production(struct city *pcity)
Definition citydlg_common.c:1525
city_production_cost_str
char * city_production_cost_str(const struct city *pcity)
Definition citydlg_common.c:224
city_queue_insert
bool city_queue_insert(struct city *pcity, int position, struct universal *item)
Definition citydlg_common.c:1384
city_queue_insert_worklist
bool city_queue_insert_worklist(struct city *pcity, int position, const struct worklist *worklist)
Definition citydlg_common.c:1412
city_toggle_worker
int city_toggle_worker(struct city *pcity, int city_x, int city_y)
Definition citydlg_common.c:1545
get_city_dialog_airlift_text
void get_city_dialog_airlift_text(const struct city *pcity, char *buf, size_t bufsz)
Definition citydlg_common.c:1043
city_sum_compare
static int city_sum_compare(double val1, double val2)
Definition citydlg_common.c:659
city_set_queue
bool city_set_queue(struct city *pcity, const struct worklist *pqueue)
Definition citydlg_common.c:1459
city_change_production
int city_change_production(struct city *pcity, struct universal *target)
Definition citydlg_common.c:1261
get_city_dialog_production_full
void get_city_dialog_production_full(char *buffer, size_t buffer_len, struct universal *target, struct city *pcity)
Definition citydlg_common.c:324
city_rotate_specialist
void city_rotate_specialist(struct city *pcity, int citizen_index)
Definition citydlg_common.c:1212
get_citydlg_canvas_width
int get_citydlg_canvas_width(void)
Definition citydlg_common.c:51
canvas_to_city_pos
bool canvas_to_city_pos(int *city_x, int *city_y, int city_radius_sq, int canvas_x, int canvas_y)
Definition citydlg_common.c:115
base_city_queue_insert
static bool base_city_queue_insert(struct city *pcity, int position, struct universal *item)
Definition citydlg_common.c:1342
activate_all_units
void activate_all_units(struct tile *ptile)
Definition citydlg_common.c:1240
city_queue_clear
bool city_queue_clear(struct city *pcity)
Definition citydlg_common.c:1400
city_sum_add_real
static void city_sum_add_real(struct city_sum *sum, double value, bool suppress_if_zero, const char *auxfmt, double aux, char *posdesc, char *negdesc)
Definition citydlg_common.c:507
get_city_dialog_airlift_value
void get_city_dialog_airlift_value(const struct city *pcity, char *buf, size_t bufsz)
Definition citydlg_common.c:1113
citydlg_map_height
static int citydlg_map_height
Definition citydlg_common.c:46
city_to_canvas_pos
bool city_to_canvas_pos(float *canvas_x, float *canvas_y, int city_x, int city_y, int city_radius_sq)
Definition citydlg_common.c:93
generate_citydlg_dimensions
void generate_citydlg_dimensions(void)
Definition citydlg_common.c:67
city_sum_new
static struct city_sum * city_sum_new(const char *format)
Definition citydlg_common.c:491
city_get_queue
void city_get_queue(struct city *pcity, struct worklist *pqueue)
Definition citydlg_common.c:1442
city_dialog_redraw_map
void city_dialog_redraw_map(struct city *pcity, struct canvas *pcanvas)
Definition citydlg_common.c:187
city_sell_improvement
int city_sell_improvement(struct city *pcity, Impr_type_id sell_id)
Definition citydlg_common.c:1517
get_city_dialog_pollution_text
void get_city_dialog_pollution_text(const struct city *pcity, char *buf, size_t bufsz)
Definition citydlg_common.c:967
city_change_specialist
int city_change_specialist(struct city *pcity, Specialist_type_id from, Specialist_type_id to)
Definition citydlg_common.c:1533
get_city_dialog_culture_text
void get_city_dialog_culture_text(const struct city *pcity, char *buf, size_t bufsz)
Definition citydlg_common.c:993
city_can_buy
bool city_can_buy(const struct city *pcity)
Definition citydlg_common.c:1497
get_citydlg_canvas_height
int get_citydlg_canvas_height(void)
Definition citydlg_common.c:59
citydlg_map_width
static int citydlg_map_width
Definition citydlg_common.c:46
get_city_dialog_illness_text
void get_city_dialog_illness_text(const struct city *pcity, char *buf, size_t bufsz)
Definition citydlg_common.c:895
citydlg_common.h
citydlg_g.h
refresh_city_dialog
void refresh_city_dialog(struct city *pcity)
Definition update_queue.c:632
trade_city
Definition menu.h:138
client
struct civclient client
Definition client_main.c:149
can_client_issue_orders
bool can_client_issue_orders(void)
Definition client_main.c:1265
client_main.h
client_player
#define client_player()
Definition client_main.h:106
climap.h
get_color
struct color * get_color(const struct tileset *t, enum color_std stdcolor)
Definition colors_common.c:100
unit_focus_set
void unit_focus_set(struct unit *punit)
Definition control.c:502
request_new_unit_activity
void request_new_unit_activity(struct unit *punit, enum unit_activity act)
Definition control.c:1828
control.h
city_history_gain
int city_history_gain(const struct city *pcity)
Definition culture.c:37
culture.h
base
static void base(QVariant data1, QVariant data2)
Definition dialogs.cpp:2839
punit
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:73
cost
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
Definition dialogs_g.h:73
get_city_bonus
int get_city_bonus(const struct city *pcity, enum effect_type effect_type)
Definition effects.c:789
get_city_bonus_effects
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:1075
get_effect_req_text
void get_effect_req_text(const struct effect *peffect, char *buf, size_t buf_len)
Definition effects.c:1197
effect_list_iterate_end
#define effect_list_iterate_end
Definition effects.h:375
effect_list_iterate
#define effect_list_iterate(effect_list, peffect)
Definition effects.h:373
Impr_type_id
int Impr_type_id
Definition fc_types.h:346
Specialist_type_id
int Specialist_type_id
Definition fc_types.h:345
O_SHIELD
@ O_SHIELD
Definition fc_types.h:91
O_TRADE
@ O_TRADE
Definition fc_types.h:91
O_GOLD
@ O_GOLD
Definition fc_types.h:91
O_LAST
@ O_LAST
Definition fc_types.h:91
Output_type_id
enum output_type_id Output_type_id
Definition fc_types.h:348
fcintl.h
Q_
#define Q_(String)
Definition fcintl.h:70
PL_
#define PL_(String1, String2, n)
Definition fcintl.h:71
_
#define _(String)
Definition fcintl.h:67
game
struct civ_game game
Definition game.c:57
wld
struct world wld
Definition game.c:58
game_city_by_number
struct city * game_city_by_number(int id)
Definition game.c:102
game.h
canvas_put_rectangle
void canvas_put_rectangle(struct canvas *pcanvas, struct color *pcolor, int canvas_x, int canvas_y, int width, int height)
Definition canvas.c:176
bufsz
static const int bufsz
Definition helpdlg.c:70
great_wonder_is_built
bool great_wonder_is_built(const struct impr_type *pimprove)
Definition improvement.c:955
is_improvement_redundant
bool is_improvement_redundant(const struct city *pcity, const struct impr_type *pimprove)
Definition improvement.c:636
great_wonder_is_destroyed
bool great_wonder_is_destroyed(const struct impr_type *pimprove)
Definition improvement.c:966
wonder_is_built
bool wonder_is_built(const struct player *pplayer, const struct impr_type *pimprove)
Definition improvement.c:857
impr_build_shield_cost
int impr_build_shield_cost(const struct city *pcity, const struct impr_type *pimprove)
Definition improvement.c:292
is_wonder
bool is_wonder(const struct impr_type *pimprove)
Definition improvement.c:341
is_great_wonder
bool is_great_wonder(const struct impr_type *pimprove)
Definition improvement.c:767
improvement_obsolete
bool improvement_obsolete(const struct player *pplayer, const struct impr_type *pimprove, const struct city *pcity)
Definition improvement.c:409
improvement_has_flag
bool improvement_has_flag(const struct impr_type *pimprove, enum impr_flag_id flag)
Definition improvement.c:381
is_small_wonder
bool is_small_wonder(const struct impr_type *pimprove)
Definition improvement.c:775
impr_estimate_build_shield_cost
int impr_estimate_build_shield_cost(const struct player *pplayer, const struct tile *ptile, const struct impr_type *pimprove)
Definition improvement.c:271
name
const char * name
Definition inputfile.c:127
log.h
fc_assert
#define fc_assert(condition)
Definition log.h:176
fc_assert_ret_val
#define fc_assert_ret_val(condition, val)
Definition log.h:194
log_debug
#define log_debug(message,...)
Definition log.h:115
log_error
#define log_error(message,...)
Definition log.h:103
map_to_gui_vector
void map_to_gui_vector(const struct tileset *t, float zoom, float *gui_dx, float *gui_dy, int map_dx, int map_dy)
Definition mapview_common.c:553
put_one_element
void put_one_element(struct canvas *pcanvas, float zoom, enum mapview_layer layer, const struct tile *ptile, const struct tile_edge *pedge, const struct tile_corner *pcorner, const struct unit *punit, const struct city *pcity, int canvas_x, int canvas_y, const struct city *citymode, const struct unit_type *putype)
Definition mapview_common.c:1349
mapview_common.h
mapview_g.h
H
#define H(x, y, z)
Definition md5.c:92
FC_FREE
#define FC_FREE(ptr)
Definition mem.h:41
fc_strdup
#define fc_strdup(str)
Definition mem.h:43
fc_realloc
#define fc_realloc(ptr, sz)
Definition mem.h:36
fc_malloc
#define fc_malloc(sz)
Definition mem.h:34
gui_options
struct client_options gui_options
Definition options.c:71
options.h
dsend_packet_city_make_worker
int dsend_packet_city_make_worker(struct connection *pc, int city_id16, int city_id32, int tile_id)
Definition packets_gen.c:28461
dsend_packet_city_sell
int dsend_packet_city_sell(struct connection *pc, int city_id16, int city_id32, int build_id)
Definition packets_gen.c:26616
dsend_packet_city_make_specialist
int dsend_packet_city_make_specialist(struct connection *pc, int city_id16, int city_id32, int tile_id)
Definition packets_gen.c:28092
dsend_packet_city_change
int dsend_packet_city_change(struct connection *pc, int city_id16, int city_id32, int production_kind, int production_value)
Definition packets_gen.c:27353
dsend_packet_city_change_specialist
int dsend_packet_city_change_specialist(struct connection *pc, int city_id16, int city_id32, Specialist_type_id from, Specialist_type_id to)
Definition packets_gen.c:28932
dsend_packet_city_rename
int dsend_packet_city_rename(struct connection *pc, int city_id16, int city_id32, const char *name)
Definition packets_gen.c:29302
dsend_packet_city_buy
int dsend_packet_city_buy(struct connection *pc, int city_id16, int city_id32)
Definition packets_gen.c:26923
dsend_packet_city_worklist
int dsend_packet_city_worklist(struct connection *pc, int city_id16, int city_id32, const struct worklist *worklist)
Definition packets_gen.c:27723
player_multiplier_effect_value
int player_multiplier_effect_value(const struct player *pplayer, const struct multiplier *pmul)
Definition player.c:1933
universal_build_shield_cost
int universal_build_shield_cost(const struct city *pcity, const struct universal *target)
Definition requirements.c:5819
are_universals_equal
bool are_universals_equal(const struct universal *psource1, const struct universal *psource2)
Definition requirements.c:5278
universal_number
int universal_number(const struct universal *source)
Definition requirements.c:790
universal_name_translation
const char * universal_name_translation(const struct universal *psource, char *buf, size_t bufsz)
Definition requirements.c:5529
DIVIDE
#define DIVIDE(n, d)
Definition shared.h:78
MIN
#define MIN(x, y)
Definition shared.h:55
FC_INFINITY
#define FC_INFINITY
Definition shared.h:36
MAX
#define MAX(x, y)
Definition shared.h:54
specialist_count
Specialist_type_id specialist_count(void)
Definition specialist.c:71
specialist.h
specialist_type_iterate_end
#define specialist_type_iterate_end
Definition specialist.h:79
specialist_type_iterate
#define specialist_type_iterate(sp)
Definition specialist.h:73
priority
SPECPQ_PRIORITY_TYPE priority
Definition specpq.h:86
astring
Definition astring.h:36
canvas
Definition canvas.h:21
city_sum
Definition citydlg_common.c:466
city_sum::sums
struct city_sum::@127 * sums
city_sum::value
double value
Definition citydlg_common.c:471
city_sum::aux
double aux
Definition citydlg_common.c:479
city_sum::auxfmt
const char * auxfmt
Definition citydlg_common.c:481
city_sum::posdesc
char * posdesc
Definition citydlg_common.c:475
city_sum::negdesc
char * negdesc
Definition citydlg_common.c:475
city_sum::format
const char * format
Definition citydlg_common.c:467
city_sum::suppress_if_zero
bool suppress_if_zero
Definition citydlg_common.c:477
city_sum::n
size_t n
Definition citydlg_common.c:468
city
Definition city.h:309
city::surplus
int surplus[O_LAST]
Definition city.h:343
city::history
int history
Definition city.h:393
city::id
int id
Definition city.h:315
city::waste
int waste[O_LAST]
Definition city.h:344
city::turn_founded
int turn_founded
Definition city.h:372
city::airlift
int airlift
Definition city.h:365
city::citizen_base
int citizen_base[O_LAST]
Definition city.h:347
city::did_buy
bool did_buy
Definition city.h:366
city::anarchy
int anarchy
Definition city.h:370
city::usage
int usage[O_LAST]
Definition city.h:348
city::worklist
struct worklist worklist
Definition city.h:387
city::production
struct universal production
Definition city.h:382
city::bonus
int bonus[O_LAST]
Definition city.h:351
city::unhappy_penalty
int unhappy_penalty[O_LAST]
Definition city.h:345
city::culture
int culture
Definition city.h:448
city::buy_cost
int buy_cost
Definition city.h:449
city::feel
citizens feel[CITIZEN_LAST][FEELING_LAST]
Definition city.h:321
city::specialists
citizens specialists[SP_MAX]
Definition city.h:324
city::shield_stock
int shield_stock
Definition city.h:355
city::prod
int prod[O_LAST]
Definition city.h:346
city::client
struct city::@17::@20 client
civ_game::info
struct packet_game_info info
Definition game.h:89
civclient::conn
struct connection conn
Definition client_main.h:96
client_options::concise_city_production
bool concise_city_production
Definition options.h:156
connection::playing
struct player * playing
Definition connection.h:156
impr_type
Definition improvement.h:68
impr_type::upkeep
int upkeep
Definition improvement.h:78
item
Definition climisc.h:80
output_type
Definition city.h:251
packet_game_info::airlifting_style
enum airlifting_style airlifting_style
Definition packets_gen.h:123
packet_game_info::airlift_from_always_enabled
bool airlift_from_always_enabled
Definition packets_gen.h:124
packet_game_info::illness_on
bool illness_on
Definition packets_gen.h:181
packet_game_info::turn
int turn
Definition packets_gen.h:241
packet_game_info::airlift_to_always_enabled
bool airlift_to_always_enabled
Definition packets_gen.h:125
player
Definition player.h:249
tile
Definition tile.h:49
tile::index
int index
Definition tile.h:50
tile::units
struct unit_list * units
Definition tile.h:57
tileset
Definition tilespec.c:459
unit_type
Definition unittype.h:481
unit
Definition unit.h:138
universal
Definition fc_types.h:756
universal::kind
enum universals_n kind
Definition fc_types.h:758
universal::value
universals_u value
Definition fc_types.h:757
worklist
Definition worklist.h:28
world::map
struct civ_map map
Definition world_object.h:38
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
fc_strlcpy
size_t fc_strlcpy(char *dest, const char *src, size_t n)
Definition support.c:787
cat_snprintf
int cat_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:995
fc_vsnprintf
int fc_vsnprintf(char *str, size_t n, const char *format, va_list ap)
Definition support.c:896
support.h
fc__attribute
#define fc__attribute(x)
Definition support.h:89
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
tile_city
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
tile_worked
#define tile_worked(_tile)
Definition tile.h:113
get_drawable_unit
struct unit * get_drawable_unit(const struct tileset *t, struct tile *ptile, const struct city *citymode)
Definition tilespec.c:6306
get_tileset
struct tileset * get_tileset(void)
Definition tilespec.c:655
unscaled_tileset
struct tileset * unscaled_tileset
Definition tilespec.c:545
tileset_is_isometric
bool tileset_is_isometric(const struct tileset *t)
Definition tilespec.c:675
tileset_tile_height
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:728
tileset_tile_width
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:716
tilespec.h
mapview_layer_iterate
#define mapview_layer_iterate(layer)
Definition tilespec.h:174
mapview_layer_iterate_end
#define mapview_layer_iterate_end
Definition tilespec.h:182
goods_name_translation
const char * goods_name_translation(struct goods_type *pgood)
Definition traderoutes.c:612
trade_routes_iterate_end
#define trade_routes_iterate_end
Definition traderoutes.h:133
trade_routes_iterate
#define trade_routes_iterate(c, proute)
Definition traderoutes.h:129
universals_u::utype
const struct unit_type * utype
Definition fc_types.h:604
universals_u::building
const struct impr_type * building
Definition fc_types.h:598
unit_owner
#define unit_owner(_pu)
Definition unit.h:387
unitlist.h
unit_list_iterate
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
unit_list_iterate_end
#define unit_list_iterate_end
Definition unitlist.h:33
utype_values_string
const char * utype_values_string(const struct unit_type *punittype)
Definition unittype.c:1648
utype_build_shield_cost
int utype_build_shield_cost(const struct city *pcity, const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1490
worklist_advance
void worklist_advance(struct worklist *pwl)
Definition worklist.c:104
worklist_peek
bool worklist_peek(const struct worklist *pwl, struct universal *prod)
Definition worklist.c:76
worklist_copy
void worklist_copy(struct worklist *dst, const struct worklist *src)
Definition worklist.c:112
worklist_init
void worklist_init(struct worklist *pwl)
Definition worklist.c:38
worklist_peek_ith
bool worklist_peek_ith(const struct worklist *pwl, struct universal *prod, int idx)
Definition worklist.c:86
worklist_is_empty
bool worklist_is_empty(const struct worklist *pwl)
Definition worklist.c:66
worklist_append
bool worklist_append(struct worklist *pwl, const struct universal *prod)
Definition worklist.c:147
worklist_insert
bool worklist_insert(struct worklist *pwl, const struct universal *prod, int idx)
Definition worklist.c:167
worklist_remove
void worklist_remove(struct worklist *pwl, int idx)
Definition worklist.c:122
worklist_length
int worklist_length(const struct worklist *pwl)
Definition worklist.c:57
worklist_iterate_end
#define worklist_iterate_end
Definition worklist.h:59
worklist_iterate
#define worklist_iterate(_list, _p)
Definition worklist.h:51
MAX_LEN_WORKLIST
#define MAX_LEN_WORKLIST
Definition worklist.h:24