1 /****************************************************************************
2 Freeciv - Copyright (C) 2004 - The Freeciv Team
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)
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 ****************************************************************************/
15 #include <fc_config.h>
30 /*************************************************************************
31 Border radius sq from given border source tile.
32 *************************************************************************/
33 int tile_border_source_radius_sq(struct tile
*ptile
)
38 if (BORDERS_DISABLED
== game
.info
.borders
) {
42 pcity
= tile_city(ptile
);
45 radius_sq
= game
.info
.border_city_radius_sq
;
46 /* Limit the addition due to the city size. A city size of 60 or more is
47 * possible with a city radius of 5 (radius_sq = 26). */
48 radius_sq
+= MIN(city_size_get(pcity
), CITY_MAP_MAX_RADIUS_SQ
)
49 * game
.info
.border_size_effect
;
51 extra_type_by_cause_iterate(EC_BASE
, pextra
) {
52 struct base_type
*pbase
= extra_base_get(pextra
);
54 if (tile_has_extra(ptile
, pextra
) && territory_claiming_base(pbase
)) {
55 radius_sq
= pbase
->border_sq
;
58 } extra_type_by_cause_iterate_end
;
64 /*************************************************************************
65 Border source strength
66 *************************************************************************/
67 int tile_border_source_strength(struct tile
*ptile
)
72 if (BORDERS_DISABLED
== game
.info
.borders
) {
76 pcity
= tile_city(ptile
);
79 strength
= city_size_get(pcity
) + 2;
81 extra_type_by_cause_iterate(EC_BASE
, pextra
) {
82 struct base_type
*pbase
= extra_base_get(pextra
);
84 if (tile_has_extra(ptile
, pextra
) && territory_claiming_base(pbase
)) {
88 } extra_type_by_cause_iterate_end
;
94 /*************************************************************************
95 Border source strength at tile
96 *************************************************************************/
97 int tile_border_strength(struct tile
*ptile
, struct tile
*source
)
99 int full_strength
= tile_border_source_strength(source
);
100 int sq_dist
= sq_map_distance(ptile
, source
);
103 return full_strength
* full_strength
/ sq_dist
;
109 /*************************************************************************
110 Is given tile source to borders.
111 *************************************************************************/
112 bool is_border_source(struct tile
*ptile
)
114 if (tile_city(ptile
)) {
118 if (extra_owner(ptile
) != NULL
) {
119 extra_type_by_cause_iterate(EC_BASE
, pextra
) {
120 struct base_type
*pbase
= extra_base_get(pextra
);
122 if (tile_has_extra(ptile
, pextra
) && territory_claiming_base(pbase
)) {
125 } extra_type_by_cause_iterate_end
;