Freeciv-3.4
Loading...
Searching...
No Matches
aahand.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/* common/aicore */
19#include "pf_tools.h"
20
21/* common */
22#include "accessarea.h"
23#include "player.h"
24#include "tiledef.h"
25
26#include "aahand.h"
27
28/*********************************************************************/
33void access_areas_refresh(struct civ_map *nmap, struct player *plr)
34{
36
37 if (access_utype != nullptr) {
38 struct unit *access_unit;
39 struct aarea_list *alist;
40 int index = 0;
41
44
46
48 pcity->server.aarea = nullptr;
50
51 access_unit = unit_virtual_create(plr, nullptr,
52 access_utype, 0);
53
55 if (pcity->server.aarea == nullptr) {
56 struct access_area *aarea = fc_malloc(sizeof(struct access_area));
57 struct pf_parameter parameter;
58 struct pf_map *pfm;
59
60 aarea->index = index++;
61 aarea->cities = city_list_new();
62 aarea->capital = is_capital(pcity);
63
64 pcity->server.aarea = aarea;
67
68 unit_tile_set(access_unit, city_tile(pcity));
69 pft_fill_unit_parameter(&parameter, nmap, access_unit);
70 pfm = pf_map_new(&parameter);
71
73 if (pcity2->server.aarea == nullptr) {
74 struct pf_path *path;
75
77 if (path != nullptr) {
78 pcity2->server.aarea = aarea;
80
81 if (!aarea->capital && is_capital(pcity2)) {
82 aarea->capital = TRUE;
83 }
84 }
85
86 pf_path_destroy(path);
87 }
89
90 BV_CLR_ALL(aarea->tiledefs);
92 if (ptile != nullptr) {
94 if (tile_matches_tiledef(td, ptile)) {
96 }
98 }
100
102 }
104
105 unit_virtual_destroy(access_unit);
106 }
107}
void access_areas_refresh(struct civ_map *nmap, struct player *plr)
Definition aahand.c:33
void area_list_for_player_set(struct player *pplayer, struct aarea_list *alist)
Definition accessarea.c:103
const struct unit_type * access_info_access_unit(void)
Definition accessarea.c:71
void area_list_clear_plr(struct player *pplayer)
Definition accessarea.c:94
#define BV_CLR_ALL(bv)
Definition bitvector.h:103
#define BV_SET(bv, bit)
Definition bitvector.h:89
bool is_capital(const struct city *pcity)
Definition city.c:1636
#define city_list_iterate(citylist, pcity)
Definition city.h:508
#define city_tile(_pcity_)
Definition city.h:565
#define city_list_iterate_end
Definition city.h:510
char * incite_cost
Definition comments.c:77
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
#define fc_malloc(sz)
Definition mem.h:34
void pf_path_destroy(struct pf_path *path)
struct pf_map * pf_map_new(const struct pf_parameter *parameter)
struct pf_path * pf_map_path(struct pf_map *pfm, struct tile *ptile)
void pf_map_destroy(struct pf_map *pfm)
#define pf_map_tiles_iterate(ARG_pfm, NAME_tile, COND_from_start)
#define pf_map_tiles_iterate_end
void pft_fill_unit_parameter(struct pf_parameter *parameter, const struct civ_map *nmap, const struct unit *punit)
Definition pf_tools.c:843
bv_tiledefs tiledefs
Definition fc_types.h:1108
struct city_list * cities
Definition fc_types.h:1106
struct city_list * cities
Definition player.h:281
Definition unit.h:140
struct unit::@84::@87 server
#define TRUE
Definition support.h:46
int tiledef_number(const struct tiledef *td)
Definition tiledef.c:62
bool tile_matches_tiledef(const struct tiledef *td, const struct tile *ptile)
Definition tiledef.c:150
#define tiledef_iterate_end
Definition tiledef.h:56
#define tiledef_iterate(_p)
Definition tiledef.h:50
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Definition unit.c:1682
void unit_virtual_destroy(struct unit *punit)
Definition unit.c:1786
void unit_tile_set(struct unit *punit, struct tile *ptile)
Definition unit.c:1308