Freeciv-3.3
Loading...
Searching...
No Matches
caravan.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 <math.h>
19
20/* utility */
21#include "log.h"
22
23/* common */
24#include "game.h"
25#include "traderoutes.h"
26
27/* aicore */
28#include "path_finding.h"
29#include "pf_tools.h"
30
31#include "caravan.h"
32
33/************************************************************************/
37{
38 parameter->horizon = FC_INFINITY;
39 parameter->discount = 0.95;
40 parameter->consider_windfall = TRUE;
41 parameter->consider_trade = TRUE;
42 parameter->consider_wonders = TRUE; /* see also init_from_unit */
45 parameter->ignore_transit_time = FALSE;
46 parameter->convert_trade = FALSE;
47 parameter->callback = NULL;
48}
49
50/************************************************************************/
54 const struct unit *caravan)
55{
58 parameter->consider_trade = FALSE;
59 }
62 parameter->consider_windfall = FALSE;
63 }
65 parameter->consider_wonders = FALSE;
66 }
67}
68
69/************************************************************************/
72bool caravan_parameter_is_legal(const struct caravan_parameter *parameter)
73{
74 /* a discount > 1.0 means money later is worth more than money now,
75 which is ridiculous. */
76 if (parameter->discount > 1.0) {
77 return FALSE;
78 }
79
80 /* a negative discount doesn't converge */
81 if (parameter->discount < 0.0) {
82 return FALSE;
83 }
84
85 /* infinite horizon with no discount gives infinite reward. */
86 if (parameter->horizon == FC_INFINITY && parameter->discount == 1.0) {
87 return FALSE;
88 }
89
90 return TRUE;
91}
92
93/************************************************************************/
96static const char *ftl_name(enum foreign_trade_limit ftl)
97{
98 switch (ftl) {
100 return "no";
101 case FTL_ALLIED:
102 return "allied";
103 case FTL_PEACEFUL:
104 return "peaceful";
105 case FTL_NONWAR:
106 return "anything but enemies";
107 }
108
109 return "<illegal>";
110}
111
112/************************************************************************/
116 enum log_level level, const char *file,
117 const char *function, int line)
118{
119 do_log(file, function, line, FALSE, level,
120 "parameter {\n"
121 " horizon = %d\n"
122 " discount = %g\n"
123 " objective = <%s,%s,%s>\n"
124 " account-broken = %s\n"
125 " allow-foreign = %s\n"
126 " ignore-transit = %s\n"
127 " convert-trade = %s\n"
128 "}\n",
129 parameter->horizon,
130 parameter->discount,
131 parameter->consider_windfall ? "windfall" : "-",
132 parameter->consider_trade ? "trade" : "-",
133 parameter->consider_wonders ? "wonders" : "-",
134 parameter->account_for_broken_routes ? "yes" : "no",
135 ftl_name(parameter->allow_foreign_trade),
136 parameter->ignore_transit_time ? "yes" : "no",
137 parameter->convert_trade ? "yes" : "no");
138}
139
140
141/************************************************************************/
145{
146 result->src = result->dest = NULL;
147 result->arrival_time = 0;
148 result->value = 0;
149 result->help_wonder = FALSE;
150 result->required_boat = FALSE;
151}
152
153/************************************************************************/
157static void caravan_result_init(struct caravan_result *result,
158 const struct city *src,
159 const struct city *dest,
160 int arrival_time)
161{
162 result->src = src;
163 result->dest = dest;
164 result->arrival_time = arrival_time;
165
166 result->value = 0;
167 result->help_wonder = FALSE;
168 /* FIXME: required_boat field is never used. */
169 if ((src != NULL) && (dest != NULL)) {
170 if (tile_continent(src->tile) != tile_continent(dest->tile)) {
171 result->required_boat = TRUE;
172 } else {
173 result->required_boat = FALSE;
174 }
175 } else {
176 result->required_boat = FALSE;
177 }
178}
179
180/************************************************************************/
184 const struct caravan_result *b)
185{
186 if (a->value > b->value) {
187 return 1;
188 } else if (a->value < b->value) {
189 return -1;
190 } else {
191 /* Faster time is better, so reverse-sort on time. */
192 return b->arrival_time - a->arrival_time ;
193 }
194}
195
196/************************************************************************/
204typedef bool (*search_callback) (const struct civ_map *nmap,
205 void *data, const struct city *pcity,
207
208static void caravan_search_from(const struct civ_map *nmap,
209 const struct unit *caravan,
210 const struct caravan_parameter *param,
211 struct tile *start_tile,
213 bool omniscient,
215 void *callback_data)
216{
217 struct pf_map *pfm;
218 struct pf_parameter pfparam;
219 int end_time;
220
221 end_time = param->horizon - turns_before;
222
223 /* Initialize the pf run. */
224 pft_fill_unit_parameter(&pfparam, nmap, (struct unit *) caravan);
225 pfparam.start_tile = start_tile;
226 pfparam.moves_left_initially = moves_left_before;
227 pfparam.omniscience = omniscient;
229
230 /* For every tile in distance order:
231 quit if we've exceeded the maximum number of turns
232 otherwise, run the callback if we're on a city.
233 Do-while loop rather than while loop to make sure to process the
234 start tile.
235 */
237 struct city *pcity;
238
239 if (pos.turn > end_time) {
240 break;
241 }
242
243 pcity = tile_city(pos.tile);
244 if (pcity != NULL
245 && callback(nmap, callback_data, pcity, turns_before + pos.turn,
246 pos.moves_left)) {
247 break;
248 }
250
252}
253
254/************************************************************************/
258static double windfall_benefit(const struct unit *caravan,
259 const struct city *src,
260 const struct city *dest,
261 const struct goods_type *pgood,
262 const struct caravan_parameter *param)
263{
264 if (!param->consider_windfall || !can_cities_trade(src, dest)) {
265 return 0;
266 } else {
268 && can_establish_trade_route(src, dest,
269 pgood->replace_priority));
271 unit_type_get(caravan),
273
274 /* when bonus goes to both sci and gold, double it */
276 (cities_trade_route_type(src, dest))->bonus_type) {
277 bonus *= 2;
278 }
279
280 return bonus;
281 }
282}
283
284/****************************************************************************
285 Compute the change in the per-turn trade.
286****************************************************************************/
287
288/************************************************************************/
292static int one_city_trade_benefit(const struct city *pcity,
293 const struct player *pplayer,
294 const struct goods_type *pgood,
295 bool countloser, int newtrade)
296{
297 int losttrade = 0;
298
299 /* If the city is owned by someone else, we don't benefit from the
300 new trade (but we might still lose from a broken trade route) */
301 if (city_owner(pcity) != pplayer) {
302 newtrade = 0;
303 }
304
306 /* If the city can handle this route, we don't break any old routes */
307 losttrade = 0;
308 } else {
311 int oldtrade = city_trade_removable(pcity, pgood->replace_priority,
313
314 /* If we own the city, the trade benefit is only by how much
315 better we are than the old trade route */
316 if (city_owner(pcity) == pplayer) {
318 }
319
320 /* If the cities that lost a trade route is one of ours, and if we
321 care about accounting for the lost trade, count it. */
322 if (countloser) {
324 struct city *losercity = game_city_by_number(plost->partner);
325
326 if (city_owner(losercity) == pplayer) {
328 if (pback->partner == pcity->id) {
329 losttrade += pback->value;
330 }
332 }
335 }
336 }
337
338 /* Find the increase or decrease in trade we benefit from */
339 return newtrade - losttrade;
340}
341
342/************************************************************************/
347static double trade_benefit(const struct player *caravan_owner,
348 const struct city *src,
349 const struct city *dest,
350 const struct goods_type *pgood,
351 const struct caravan_parameter *param)
352{
353 /* Do we care about trade at all? */
354 if (!param->consider_trade) {
355 return 0;
356 }
357
358 /* First, see if a new route is made. */
359 if (!can_cities_trade(src, dest)
360 || !can_establish_trade_route(src, dest, pgood->replace_priority)) {
361 return 0;
362 }
363 if (max_trade_routes(src) <= 0 || max_trade_routes(dest) <= 0) {
364 /* Can't create new trade routes even by replacing old ones if
365 * there's no slots at all. */
366 return 0;
367 }
368
369 if (!param->convert_trade) {
371 int newtrade = trade_base_between_cities(src, dest);
372
377 } else {
378 /* Always fails. */
380 "Unimplemented functionality: "
381 "using CM to calculate trade.");
382 return 0;
383 }
384}
385
386/************************************************************************/
393static double wonder_benefit(const struct unit *caravan, int arrival_time,
394 const struct city *dest,
395 const struct caravan_parameter *param)
396{
399
400 if (!param->consider_wonders
401 /* TODO: Should helping an ally to build be considered when legal? */
402 || unit_owner(caravan) != city_owner(dest)
404 /* TODO: Should helping to build a unit be considered when legal? */
405 || VUT_UTYPE == dest->production.kind
406 /* TODO: Should helping to build an improvement be considered when
407 * legal? */
408 || !is_wonder(dest->production.value.building)) {
409 return 0;
410 }
411
413 + arrival_time * dest->surplus[O_SHIELD];
414
419
421 return costwithout - costwith;
422}
423
424/************************************************************************/
428static double presentvalue(double payment, int term, double rate)
429{
430 return payment * pow(rate, term);
431}
432
433/************************************************************************/
437static double perpetuity(double payment, double rate)
438{
439 return payment / (1.0 - rate);
440}
441
442/************************************************************************/
446static double annuity(double payment, int term, double rate)
447{
448 return perpetuity(payment, rate) * (1.0 - 1.0 / pow(rate, term));
449}
450
451/************************************************************************/
454static bool does_foreign_trade_param_allow(const struct caravan_parameter *param,
455 struct player *src, struct player *dest)
456{
457 switch (param->allow_foreign_trade) {
459 return (src == dest);
460 break;
461 case FTL_ALLIED:
462 return pplayers_allied(src, dest);
463 break;
464 case FTL_PEACEFUL:
465 return pplayers_in_peace(src, dest);
466 break;
467 case FTL_NONWAR:
468 return !pplayers_at_war(src, dest);
469 }
470
472 return FALSE;
473}
474
475/************************************************************************/
481static bool get_discounted_reward(const struct unit *caravan,
482 const struct caravan_parameter *parameter,
483 struct caravan_result *result)
484{
485 double trade;
486 double windfall;
487 double wonder;
488 const struct city *src = result->src;
489 const struct city *dest = result->dest;
490 int arrival_time = result->arrival_time;
491 double discount = parameter->discount;
492 struct player *pplayer_src = city_owner(src);
493 struct player *pplayer_dest = city_owner(dest);
494 int cost = unit_build_shield_cost(src, caravan);
495 bool consider_wonder;
496 bool consider_trade;
497 bool consider_windfall;
498 struct goods_type *pgood;
499 const struct civ_map *nmap = &(wld.map);
500
501 /* If no foreign trade is allowed, just quit. */
504 return FALSE;
505 }
506
510 caravan, src, city_tile(dest),
511 TRUE, dest));
512 consider_trade = parameter->consider_trade
515 caravan, src, city_tile(dest),
516 TRUE, dest));
517 consider_windfall = parameter->consider_windfall
520 caravan, src, city_tile(dest),
521 TRUE, dest));
522
523 if (!consider_wonder && !consider_trade && !consider_windfall) {
524 /* No caravan action is possible against this target. */
526
527 return FALSE;
528 }
529
530 if (consider_wonder) {
531 wonder = wonder_benefit(caravan, arrival_time, dest, parameter);
532 /* We want to aid for wonder building */
533 wonder *= 2;
534
535 wonder = presentvalue(wonder, arrival_time, discount);
536 } else {
537 wonder = -1.0;
538 }
539
541
542 if (consider_trade) {
543 trade = trade_benefit(pplayer_src, src, dest, pgood, parameter);
544 if (parameter->horizon == FC_INFINITY) {
545 trade = perpetuity(trade, discount);
546 } else {
547 trade = annuity(trade, parameter->horizon - arrival_time, discount);
548 }
549 trade = presentvalue(trade, arrival_time, discount);
550 } else {
551 trade = 0.0;
552 }
553
554 if (consider_windfall) {
555 windfall = windfall_benefit(caravan, src, dest, pgood, parameter);
556 windfall = presentvalue(windfall, arrival_time, discount);
557 } else {
558 windfall = 0.0;
559 }
560
561 if ((consider_trade
562 || (consider_windfall
563 && (!parameter->consider_trade /* Can only enter marketplaces */
564 /* (FIXME: test any extra restrictions for trade routes) */
565 /* or the result is so big that we are still in plus */
566 /* (consider having produced IF_GOLD instead) */
567 || windfall
569 / MAX(src->surplus[O_SHIELD], 2), discount)))
570 ) && trade + windfall >= wonder) {
571 result->value = trade + windfall;
572 result->help_wonder = FALSE;
573 } else if (consider_wonder) {
574 result->value = wonder;
575 result->help_wonder = TRUE;
576 } else {
578 return FALSE;
579 }
580
581 if (parameter->callback) {
582 parameter->callback(result, parameter->callback_data);
583 }
584
585 return TRUE;
586}
587
588/****************************************************************************
589 Functions to compute the benefit of moving the caravan to dest.
590****************************************************************************/
591
592/************************************************************************/
595static void caravan_find_best_destination_notransit(const struct unit *caravan,
596 const struct caravan_parameter *param,
597 struct caravan_result *best)
598{
599 struct caravan_result current;
600 struct city *pcity = game_city_by_number(caravan->homecity);
601 struct player *src_owner = city_owner(pcity);
602
603 caravan_result_init(best, pcity, NULL, 0);
604 current = *best;
605
608 city_list_iterate(dest_owner->cities, dest) {
609 caravan_result_init(&current, pcity, dest, 0);
610 if (get_discounted_reward(caravan, param, &current)
611 && caravan_result_compare(&current, best) > 0) {
612 *best = current;
613 }
615 }
617}
618
619/************************************************************************/
625 const struct unit *caravan;
627};
628
629static bool cfbdw_callback(const struct civ_map *nmap,
630 void *vdata, const struct city *dest,
631 int arrival_time, int moves_left)
632{
633 struct cfbdw_data *data = vdata;
634 struct caravan_result current;
635
636 caravan_result_init(&current, data->best->src, dest, arrival_time);
637
638 if (get_discounted_reward(data->caravan, data->param, &current)
639 && caravan_result_compare(&current, data->best) > 0) {
640 *data->best = current;
641 }
642
643 return FALSE; /* Don't stop. */
644}
645
646/************************************************************************/
650 const struct civ_map *nmap,
651 const struct unit *caravan,
652 const struct caravan_parameter *param,
653 const struct city *src,
654 int turns_before,
655 int moves_left,
656 bool omniscient,
657 struct caravan_result *result)
658{
659 struct tile *start_tile;
660 struct cfbdw_data data;
661
662 data.param = param;
663 data.caravan = caravan;
664 data.best = result;
665 caravan_result_init(data.best, src, NULL, 0);
666
667 if (src->id != caravan->homecity) {
668 start_tile = src->tile;
669 } else {
670 start_tile = unit_tile(caravan);
671 }
672
675}
676
677/************************************************************************/
683 const struct unit *caravan,
684 const struct caravan_parameter *parameter,
685 struct caravan_result *result, bool omniscient)
686{
687 if (parameter->ignore_transit_time) {
689 } else {
690 const struct city *src = game_city_by_number(caravan->homecity);
691
692 fc_assert(src != NULL);
693
694 caravan_find_best_destination_withtransit(nmap, caravan, parameter, src, 0,
695 caravan->moves_left, omniscient, result);
696 }
697}
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5091
struct act_prob action_speculate_unit_on_city(const struct civ_map *nmap, const action_id act_id, const struct unit *actor, const struct city *actor_home, const struct tile *actor_tile, const bool omniscient_cheat, const struct city *target)
Definition actions.c:4844
static double wonder_benefit(const struct unit *caravan, int arrival_time, const struct city *dest, const struct caravan_parameter *param)
Definition caravan.c:393
static double perpetuity(double payment, double rate)
Definition caravan.c:437
void caravan_find_best_destination(const struct civ_map *nmap, const struct unit *caravan, const struct caravan_parameter *parameter, struct caravan_result *result, bool omniscient)
Definition caravan.c:682
static bool does_foreign_trade_param_allow(const struct caravan_parameter *param, struct player *src, struct player *dest)
Definition caravan.c:454
static void caravan_search_from(const struct civ_map *nmap, const struct unit *caravan, const struct caravan_parameter *param, struct tile *start_tile, int turns_before, int moves_left_before, bool omniscient, search_callback callback, void *callback_data)
Definition caravan.c:208
bool caravan_parameter_is_legal(const struct caravan_parameter *parameter)
Definition caravan.c:72
static void caravan_find_best_destination_notransit(const struct unit *caravan, const struct caravan_parameter *param, struct caravan_result *best)
Definition caravan.c:595
void caravan_result_init_zero(struct caravan_result *result)
Definition caravan.c:144
static double annuity(double payment, int term, double rate)
Definition caravan.c:446
static bool cfbdw_callback(const struct civ_map *nmap, void *vdata, const struct city *dest, int arrival_time, int moves_left)
Definition caravan.c:629
static const char * ftl_name(enum foreign_trade_limit ftl)
Definition caravan.c:96
bool(* search_callback)(const struct civ_map *nmap, void *data, const struct city *pcity, int arrival_turn, int arrival_moves_left)
Definition caravan.c:204
int caravan_result_compare(const struct caravan_result *a, const struct caravan_result *b)
Definition caravan.c:183
static int one_city_trade_benefit(const struct city *pcity, const struct player *pplayer, const struct goods_type *pgood, bool countloser, int newtrade)
Definition caravan.c:292
static void caravan_find_best_destination_withtransit(const struct civ_map *nmap, const struct unit *caravan, const struct caravan_parameter *param, const struct city *src, int turns_before, int moves_left, bool omniscient, struct caravan_result *result)
Definition caravan.c:649
void caravan_parameter_log_real(const struct caravan_parameter *parameter, enum log_level level, const char *file, const char *function, int line)
Definition caravan.c:115
static double trade_benefit(const struct player *caravan_owner, const struct city *src, const struct city *dest, const struct goods_type *pgood, const struct caravan_parameter *param)
Definition caravan.c:347
static bool get_discounted_reward(const struct unit *caravan, const struct caravan_parameter *parameter, struct caravan_result *result)
Definition caravan.c:481
static double windfall_benefit(const struct unit *caravan, const struct city *src, const struct city *dest, const struct goods_type *pgood, const struct caravan_parameter *param)
Definition caravan.c:258
void caravan_parameter_init_default(struct caravan_parameter *parameter)
Definition caravan.c:36
static double presentvalue(double payment, int term, double rate)
Definition caravan.c:428
void caravan_parameter_init_from_unit(struct caravan_parameter *parameter, const struct unit *caravan)
Definition caravan.c:53
static void caravan_result_init(struct caravan_result *result, const struct city *src, const struct city *dest, int arrival_time)
Definition caravan.c:157
foreign_trade_limit
Definition caravan.h:29
@ FTL_ALLIED
Definition caravan.h:31
@ FTL_NATIONAL_ONLY
Definition caravan.h:30
@ FTL_NONWAR
Definition caravan.h:33
@ FTL_PEACEFUL
Definition caravan.h:32
bool city_production_gets_caravan_shields(const struct universal *tgt)
Definition city.c:1860
#define city_list_iterate(citylist, pcity)
Definition city.h:505
#define city_tile(_pcity_)
Definition city.h:561
#define city_owner(_pcity_)
Definition city.h:560
#define city_list_iterate_end
Definition city.h:507
char * incite_cost
Definition comments.c:76
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
struct unit struct city 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
@ O_SHIELD
Definition fc_types.h:101
struct world wld
Definition game.c:62
struct city * game_city_by_number(int id)
Definition game.c:106
static struct tile * pos
Definition finddlg.c:53
int impr_buy_gold_cost(const struct city *pcity, const struct impr_type *pimprove, int shields_in_stock)
bool is_wonder(const struct impr_type *pimprove)
void do_log(const char *file, const char *function, int line, bool print_from_where, enum log_level level, const char *message,...)
Definition log.c:514
#define fc_assert_msg(condition, message,...)
Definition log.h:182
#define fc_assert(condition)
Definition log.h:177
#define fc_assert_ret_val(condition, val)
Definition log.h:195
log_level
Definition log.h:29
struct pf_map * pf_map_new(const struct pf_parameter *parameter)
void pf_map_destroy(struct pf_map *pfm)
#define pf_map_positions_iterate_end
#define pf_map_positions_iterate(ARG_pfm, NAME_pos, COND_from_start)
void pft_fill_unit_parameter(struct pf_parameter *parameter, const struct civ_map *nmap, const struct unit *punit)
Definition pf_tools.c:843
bool pplayers_at_war(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1388
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1409
bool pplayers_in_peace(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1430
#define players_iterate_end
Definition player.h:542
#define players_iterate(_pplayer)
Definition player.h:537
struct setting_list * level[OLEVELS_NUM]
Definition settings.c:190
#define FC_INFINITY
Definition shared.h:36
#define MAX(x, y)
Definition shared.h:54
bool consider_trade
Definition caravan.h:86
bool consider_windfall
Definition caravan.h:85
void(* callback)(const struct caravan_result *result, void *data)
Definition caravan.h:124
enum foreign_trade_limit allow_foreign_trade
Definition caravan.h:99
bool consider_wonders
Definition caravan.h:87
bool ignore_transit_time
Definition caravan.h:108
double discount
Definition caravan.h:77
bool account_for_broken_routes
Definition caravan.h:93
void * callback_data
Definition caravan.h:125
const struct city * src
Definition caravan.h:52
const struct city * dest
Definition caravan.h:53
int arrival_time
Definition caravan.h:54
bool help_wonder
Definition caravan.h:57
bool required_boat
Definition caravan.h:58
double value
Definition caravan.h:56
struct caravan_result * best
Definition caravan.c:626
const struct unit * caravan
Definition caravan.c:625
const struct caravan_parameter * param
Definition caravan.c:624
Definition city.h:317
int surplus[O_LAST]
Definition city.h:352
int id
Definition city.h:323
struct universal production
Definition city.h:393
int bonus[O_LAST]
Definition city.h:360
struct tile * tile
Definition city.h:319
int shield_stock
Definition city.h:365
struct tile * start_tile
Definition tile.h:50
Definition unit.h:140
int moves_left
Definition unit.h:152
int id
Definition unit.h:147
int homecity
Definition unit.h:148
enum universals_n kind
Definition fc_types.h:608
universals_u value
Definition fc_types.h:607
struct civ_map map
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define bool
Definition support.h:71
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_continent(_tile)
Definition tile.h:93
bool can_cities_trade(const struct city *pc1, const struct city *pc2)
enum trade_route_type cities_trade_route_type(const struct city *pcity1, const struct city *pcity2)
Definition traderoutes.c:58
int trade_base_between_cities(const struct city *pc1, const struct city *pc2)
int city_num_trade_routes(const struct city *pcity)
struct trade_route_settings * trade_route_settings_by_type(enum trade_route_type type)
struct goods_type * goods_from_city_to_unit(const struct city *src, const struct unit *punit)
unsigned max_trade_routes(const struct city *pcity)
Definition traderoutes.c:48
int city_trade_removable(const struct city *pcity, int priority, struct trade_route_list *would_remove)
bool can_establish_trade_route(const struct city *pc1, const struct city *pc2, int priority)
int get_caravan_enter_city_trade_bonus(const struct city *pc1, const struct city *pc2, const struct unit_type *ut, struct goods_type *pgood, const bool establish_trade)
#define trade_route_list_iterate(trade_route_list, proute)
Definition traderoutes.h:95
#define trade_routes_iterate_end
#define trade_route_list_iterate_end
Definition traderoutes.h:97
#define trade_routes_iterate(c, proute)
const struct impr_type * building
Definition fc_types.h:546
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:383
#define unit_tile(_pu)
Definition unit.h:404
#define unit_owner(_pu)
Definition unit.h:403
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
int unit_build_shield_cost(const struct city *pcity, const struct unit *punit)
Definition unittype.c:1482
int unit_build_shield_cost_base(const struct unit *punit)
Definition unittype.c:1490