Freeciv-3.3
Loading...
Searching...
No Matches
borders.c
Go to the documentation of this file.
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)
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/* utility */
19#include "fcintl.h"
20#include "log.h"
21
22/* common */
23#include "game.h"
24#include "map.h"
25#include "tile.h"
26#include "unit.h"
27
28#include "borders.h"
29
30/*********************************************************************/
34{
35 struct city *pcity;
36 int radius_sq = 0;
37
39 return 0;
40 }
41
42 pcity = tile_city(ptile);
43
44 if (pcity) {
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). */
50 } else {
52
54 if (tile_has_extra(ptile, pextra)) {
55 struct base_type *pbase = extra_base_get(pextra);
56
57 radius_sq = pbase->border_sq;
58 break;
59 }
61 }
62
63 return radius_sq;
64}
65
66/*********************************************************************/
70{
71 struct city *pcity;
72 int strength = 0;
73
75 return 0;
76 }
77
78 pcity = tile_city(ptile);
79
80 if (pcity) {
83 } else {
85
87 if (tile_has_extra(ptile, pextra)) {
88 /* Base strength 100 / 100 = 1 */
89 strength = (100 + get_tile_bonus(ptile, EFT_BORDER_STRENGTH_PCT)) / 100;
90 break;
91 }
93 }
94
95 return strength;
96}
97
98/*********************************************************************/
101int tile_border_strength(struct tile *ptile, struct tile *source)
102{
104 int sq_dist = sq_map_distance(ptile, source);
105
106 if (sq_dist > 0) {
108 } else {
109 return FC_INFINITY;
110 }
111}
112
113/*********************************************************************/
116bool is_border_source(struct tile *ptile)
117{
118 if (tile_city(ptile)) {
119 return TRUE;
120 }
121
122 if (extra_owner(ptile) != NULL) {
124
126 if (tile_has_extra(ptile, pextra)) {
127 return TRUE;
128 }
130 }
131
132 return FALSE;
133}
int tile_border_source_radius_sq(struct tile *ptile)
Definition borders.c:33
bool is_border_source(struct tile *ptile)
Definition borders.c:116
int tile_border_strength(struct tile *ptile, struct tile *source)
Definition borders.c:101
int tile_border_source_strength(struct tile *ptile)
Definition borders.c:69
#define CITY_MAP_MAX_RADIUS_SQ
Definition city.h:83
static citizens city_size_get(const struct city *pcity)
Definition city.h:566
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
int get_city_bonus(const struct city *pcity, enum effect_type effect_type)
Definition effects.c:842
int get_tile_bonus(const struct tile *ptile, enum effect_type effect_type)
Definition effects.c:862
struct player * extra_owner(const struct tile *ptile)
Definition extras.c:1128
struct extra_type_list * extra_type_list_of_terr_claimers(void)
Definition extras.c:275
#define extra_type_list_iterate(extralist, pextra)
Definition extras.h:165
#define extra_type_list_iterate_end
Definition extras.h:167
#define extra_base_get(_e_)
Definition extras.h:190
@ BORDERS_DISABLED
Definition fc_types.h:745
struct civ_game game
Definition game.c:61
static GtkWidget * source
Definition gotodlg.c:58
int sq_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:686
#define MIN(x, y)
Definition shared.h:55
#define FC_INFINITY
Definition shared.h:36
Definition city.h:317
struct packet_game_info info
Definition game.h:89
enum borders_mode borders
Definition tile.h:50
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_has_extra(ptile, pextra)
Definition tile.h:148