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 struct packet_access_area packet;
42
45
47
49 pcity->aarea = nullptr;
51
52 access_unit = unit_virtual_create(plr, nullptr,
53 access_utype, 0);
54
55 packet.player = player_number(plr);
56
58 if (pcity->aarea == nullptr) {
59 struct access_area *aarea = fc_malloc(sizeof(struct access_area));
60 struct pf_parameter parameter;
61 struct pf_map *pfm;
62
63 aarea->index = index++;
64 aarea->cities = city_list_new();
65 aarea->capital = is_capital(pcity);
66
67 pcity->aarea = aarea;
70
71 unit_tile_set(access_unit, city_tile(pcity));
72 pft_fill_unit_parameter(&parameter, nmap, access_unit);
73 pfm = pf_map_new(&parameter);
74
76 if (pcity2->aarea == nullptr) {
77 struct pf_path *path;
78
80 if (path != nullptr) {
81 pcity2->aarea = aarea;
83
84 if (!aarea->capital && is_capital(pcity2)) {
85 aarea->capital = TRUE;
86 }
87 }
88
89 pf_path_destroy(path);
90 }
92
93 BV_CLR_ALL(aarea->tiledefs);
94 BV_CLR_ALL(packet.tiledefs);
96 if (ptile != nullptr) {
98 if (tile_matches_tiledef(td, ptile)) {
99 int tn = tiledef_number(td);
100
101 BV_SET(aarea->tiledefs, tn);
102 BV_SET(packet.tiledefs, tn);
103 }
105 }
107
109
110 packet.index = aarea->index;
111 packet.capital = aarea->capital;
112
114 }
116
117 unit_virtual_destroy(access_unit);
118 }
119}
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:112
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
void lsend_packet_access_area(struct conn_list *dest, const struct packet_access_area *packet)
#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
int player_number(const struct player *pplayer)
Definition player.c:826
bv_tiledefs tiledefs
Definition fc_types.h:1108
struct city_list * cities
Definition fc_types.h:1106
bv_tiledefs tiledefs
struct city_list * cities
Definition player.h:281
struct conn_list * connections
Definition player.h:298
Definition unit.h:140
#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