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>
29 /*************************************************************************
30 Border radius sq from given border source tile.
31 *************************************************************************/
32 int tile_border_source_radius_sq(struct tile
*ptile
)
37 if (BORDERS_DISABLED
== game
.info
.borders
) {
41 pcity
= tile_city(ptile
);
44 radius_sq
= game
.info
.border_city_radius_sq
;
45 /* Limit the addition due to the city size. A city size of 60 or more is
46 * possible with a city radius of 5 (radius_sq = 26). */
47 radius_sq
+= MIN(city_size_get(pcity
), CITY_MAP_MAX_RADIUS_SQ
)
48 * game
.info
.border_size_effect
;
50 base_type_iterate(pbase
) {
51 if (tile_has_base(ptile
, pbase
) && territory_claiming_base(pbase
)) {
52 radius_sq
= pbase
->border_sq
;
55 } base_type_iterate_end
;
61 /*************************************************************************
62 Border source strength
63 *************************************************************************/
64 int tile_border_source_strength(struct tile
*ptile
)
69 if (BORDERS_DISABLED
== game
.info
.borders
) {
73 pcity
= tile_city(ptile
);
76 strength
= city_size_get(pcity
) + 2;
78 base_type_iterate(pbase
) {
79 if (tile_has_base(ptile
, pbase
) && territory_claiming_base(pbase
)) {
83 } base_type_iterate_end
;
89 /*************************************************************************
90 Border source strength at tile
91 *************************************************************************/
92 int tile_border_strength(struct tile
*ptile
, struct tile
*source
)
94 int full_strength
= tile_border_source_strength(source
);
95 int sq_dist
= sq_map_distance(ptile
, source
);
98 return full_strength
* full_strength
/ sq_dist
;
104 /*************************************************************************
105 Is given tile source to borders.
106 *************************************************************************/
107 bool is_border_source(struct tile
*ptile
)
109 if (tile_city(ptile
)) {
113 if (tile_owner(ptile
) != NULL
) {
114 base_type_iterate(pbase
) {
115 if (tile_has_base(ptile
, pbase
) && territory_claiming_base(pbase
)) {
118 } base_type_iterate_end
;