Freeciv-3.3
Loading...
Searching...
No Matches
barbarian.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2003 - A Kjeldberg, L Gregersen, P Unold
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/***********************************************************************
15 Functions for creating barbarians in huts, land and sea
16 Started by Jerzy Klek <jekl@altavista.net>
17 with more ideas from Falk Hueffner
18***********************************************************************/
19
20#ifdef HAVE_CONFIG_H
21#include <fc_config.h>
22#endif
23
24#include <stdio.h>
25#include <stdlib.h>
26#include <string.h>
27
28/* utility */
29#include "fcintl.h"
30#include "log.h"
31#include "rand.h"
32#include "support.h"
33
34/* common */
35#include "effects.h"
36#include "events.h"
37#include "game.h"
38#include "government.h"
39#include "map.h"
40#include "movement.h"
41#include "nation.h"
42#include "research.h"
43#include "tech.h"
44#include "terrain.h"
45#include "unitlist.h"
46
47/* server */
48#include "aiiface.h"
49#include "citytools.h"
50#include "diplhand.h"
51#include "gamehand.h"
52#include "maphand.h"
53#include "notify.h"
54#include "plrhand.h"
55#include "srv_main.h"
56#include "stdinhand.h"
57#include "techtools.h"
58#include "unithand.h"
59#include "unittools.h"
60
61/* server/advisors */
62#include "advdata.h"
63
64/* ai */
65#include "difficulty.h"
66
67#include "barbarian.h"
68
69#define BARBARIAN_INITIAL_VISION_RADIUS 3
70#define BARBARIAN_INITIAL_VISION_RADIUS_SQ 9
71
72/**********************************************************************/
75bool is_land_barbarian(struct player *pplayer)
76{
77 return (pplayer->ai_common.barbarian_type == LAND_BARBARIAN
79}
80
81/**********************************************************************/
84bool is_sea_barbarian(struct player *pplayer)
85{
86 return (pplayer->ai_common.barbarian_type == SEA_BARBARIAN
88}
89
90/**********************************************************************/
97struct player *create_barbarian_player(enum barbarian_type type)
98{
99 struct player *barbarians;
100 struct nation_type *nation = NULL;
101 struct research *presearch;
102
106 if (!old_barbs->is_alive) {
107 old_barbs->economic.gold = 0;
108 old_barbs->is_alive = TRUE;
110
111 /* Free old name so pick_random_player_name() can select it again.
112 * This is needed in case ruleset defines just one leader for
113 * barbarian nation. */
114 old_barbs->name[0] = '\0';
118 old_barbs->unassigned_user = TRUE;
119 /* I need to make them to forget the map, I think */
120 whole_map_iterate(&(wld.map), ptile) {
123 }
124 old_barbs->economic.gold += 100; /* New leader, new money */
125
126 return old_barbs;
127 }
129
130 /* Make a new player, or not */
132 if (barbarians == NULL) {
133 return NULL;
134 }
135 /* Freeciv-web depends on AI-status being set already before server_player_init() */
138
139 if (type == LAND_BARBARIAN || type == SEA_BARBARIAN) {
140 /* Try LAND_AND_SEA *FIRST*, so that we don't end up
141 * with one of the Land/Sea barbarians created first and
142 * then LAND_AND_SEA created instead of the second. */
144 if (nation != NULL) {
146 }
147 }
148
149 if (nation == NULL) {
150 nation = pick_a_nation(NULL, FALSE, FALSE, type);
151 }
152
153 /* Ruleset loading time checks should guarantee that there always is
154 suitable nation available */
155 fc_assert(nation != NULL);
156
158 if (game_was_started()) {
159 /* Find a color for the new player. */
161 }
162
163 server.nbarbarians++;
164
166 barbarians->unassigned_user = TRUE;
167 barbarians->is_connected = FALSE;
168 barbarians->government = init_government_of_nation(nation);
169 fc_assert(barbarians->revolution_finishes < 0);
171 barbarians->economic.gold = 100;
172
173 barbarians->phase_done = TRUE;
174
175 /* Do the AI */
176 barbarians->ai_common.barbarian_type = type;
178
182
183 /* Ensure that we are at war with everyone else */
185
186 CALL_PLR_AI_FUNC(gained_control, barbarians, barbarians);
187
188 log_verbose("Created barbarian %s, player %d", player_name(barbarians),
191 _("%s gain a leader by the name %s. Dangerous "
192 "times may lie ahead."),
195
197 /* Send research info after player info, else the client will complain
198 * about invalid team. */
200
201 return barbarians;
202}
203
204/**********************************************************************/
209 enum terrain_class tclass)
210{
211 int dir;
212
213 for (dir = 0; dir < 8; dir++) {
214 if (terrainc[dir] == tclass) {
215 checked[dir] = FALSE;
216 } else {
217 checked[dir] = TRUE;
218 }
219 }
220}
221
222/**********************************************************************/
226{
227 int j = -1;
228 int i;
229
230 int num = fc_rand(possibilities);
231 for (i = 0; i <= num; i++) {
232 j++;
233 while (checked[j]) {
234 j++;
235 fc_assert(j < 8);
236 }
237 }
238
239 return j;
240}
241
242/**********************************************************************/
245static void unit_move_pay(struct unit *punit, struct tile *pdesttile)
246{
247 int move_cost = map_move_cost_unit(&(wld.map), punit, pdesttile);
248
249 unit_move(punit, pdesttile, move_cost,
250 /* Don't override "Transport Embark" */
251 NULL, FALSE,
252 /* Don't override "Conquer City" */
253 FALSE,
254 /* Don't override "Conquer Extras" */
255 FALSE,
256 /* Don't override "Enter Hut" */
257 FALSE,
258 /* Don't override "Frighten Hut" */
259 FALSE);
260}
261
262/**********************************************************************/
272bool unleash_barbarians(struct tile *ptile)
273{
274 struct player *barbarians;
275 int unit_cnt;
276 int i;
277 bool alive = TRUE; /* explorer survived */
278 enum terrain_class terrainc[8];
279 struct tile *dir_tiles[8];
280 int land_tiles = 0;
281 int ocean_tiles = 0;
282 bool checked[8];
283 int checked_count;
284 int dir;
285 bool barbarian_stays = FALSE;
286 const struct civ_map *nmap = &(wld.map);
287
288 /* FIXME: When there is no L_BARBARIAN unit,
289 * but L_BARBARIAN_TECH is already available,
290 * we should unleash those.
291 * Doesn't affect any ruleset I'm aware of. */
294 || num_role_units(L_BARBARIAN) == 0) {
295 unit_list_iterate_safe((ptile)->units, punit) {
298 return FALSE;
299 }
300
302 if (!barbarians) {
303 return FALSE;
304 }
305
308
309 unit_cnt = 3 + fc_rand(4);
310 for (i = 0; i < unit_cnt; i++) {
311 struct unit_type *punittype
313
314 /* If unit cannot live on this tile, we just don't create one.
315 * Maybe find_a_unit_type() should take tile parameter, so
316 * we could get suitable unit if one exist. */
317 if (is_native_tile(punittype, ptile)
319 struct unit *barb_unit;
320
321 barb_unit = create_unit(barbarians, ptile, punittype, 0, 0, -1);
322 log_debug("Created barbarian unit %s", utype_rule_name(punittype));
324 }
325 }
326
327 /* Get information about surrounding terrains in terrain class level.
328 * Only needed if we consider moving units away to random directions. */
329 for (dir = 0; dir < 8; dir++) {
330 dir_tiles[dir] = mapstep(nmap, ptile, dir);
331 if (dir_tiles[dir] == NULL) {
333 } else if (!is_non_allied_unit_tile(dir_tiles[dir], barbarians, TRUE)) {
334 if (is_ocean_tile(dir_tiles[dir])) {
335 terrainc[dir] = TC_OCEAN;
336 ocean_tiles++;
337 } else {
338 terrainc[dir] = TC_LAND;
339 land_tiles++;
340 }
341 } else {
343 }
344 }
345
346 if (land_tiles >= 3) {
347 /* Enough land, scatter guys around */
348 unit_list_iterate_safe((ptile)->units, punit2) {
349 if (unit_owner(punit2) == barbarians) {
350 bool dest_found = FALSE;
351
352 /* Initialize checked status for checking free land tiles */
354
355 /* Search tile to move to */
357 checked_count++) {
359
361 TRUE, FALSE, FALSE)) {
362 /* Move */
364 log_debug("Moved barbarian unit from (%d, %d) to (%d, %d)",
365 TILE_XY(ptile), TILE_XY(dir_tiles[rdir]));
367 }
368
369 checked[rdir] = TRUE;
370 }
371 if (!dest_found) {
372 /* This barbarian failed to move out of hut tile. */
374 }
375 }
377
378 } else {
379 if (ocean_tiles > 0) {
380 /* maybe it's an island, try to get on boats */
381 struct unit *boat = NULL; /* Boat */
382
383 /* Initialize checked status for checking Ocean tiles */
385
386 /* Search tile for boat. We always create just one boat. */
388 checked_count++) {
389 struct unit_type *candidate;
391
396 0, 0, -1);
397 }
398
399 checked[rdir] = TRUE;
400 }
401
402 if (boat) {
403 /* We do have a boat. Try to get everybody in */
404 unit_list_iterate_safe((ptile)->units, punit2) {
405 if (unit_owner(punit2) == barbarians) {
407 punit2, boat)) {
408 /* Load */
412 punit2, boat)) {
413 /* Load */
417 punit2, boat)) {
418 /* Load */
422 punit2, boat)) {
423 /* Load */
426 }
427 }
429 }
430
431 /* Move rest of the barbarians to random land tiles */
432 unit_list_iterate_safe((ptile)->units, punit2) {
433 if (unit_owner(punit2) == barbarians) {
434 bool dest_found = FALSE;
435
436 /* Initialize checked status for checking Land tiles */
438
439 /* Search tile to move to */
441 checked_count++) {
442 int rdir;
443
445
447 TRUE, FALSE, FALSE)) {
448 /* Move */
451 }
452
453 checked[rdir] = TRUE;
454 }
455 if (!dest_found) {
456 /* This barbarian failed to move out of hut tile. */
458 }
459 }
461 } else {
462 /* The village is surrounded! Barbarians cannot leave. */
464 }
465 }
466
467 if (barbarian_stays) {
468 /* There's barbarian in this village! Kill the explorer. */
469 unit_list_iterate_safe((ptile)->units, punit2) {
470 if (unit_owner(punit2) != barbarians) {
472 alive = FALSE;
473 } else {
475 }
477 }
478
479 /* FIXME: I don't know if this is needed */
480 if (ptile) {
482 }
483
484 return alive;
485}
486
487/**********************************************************************/
490static bool is_near_land(struct tile *tile0)
491{
492 square_iterate(&(wld.map), tile0, 4, ptile) {
493 if (!is_ocean_tile(ptile)) {
494 return TRUE;
495 }
497
498 return FALSE;
499}
500
501/**********************************************************************/
504static struct tile *find_empty_tile_nearby(struct tile *ptile)
505{
506 square_iterate(&(wld.map), ptile, 1, tile1) {
507 if (unit_list_size(tile1->units) == 0) {
508 return tile1;
509 }
511
512 return NULL;
513}
514
515/**********************************************************************/
533static void try_summon_barbarians(void)
534{
535 struct tile *ptile, *utile;
536 int i, dist;
537 int uprise;
538 struct city *pc;
539 struct player *barbarians, *victim;
540 struct unit_type *leader_type;
541 int barb_count, really_created = 0;
542 bool hut_present = FALSE;
543 int city_count;
544 int city_max;
545 const struct civ_map *nmap = &(wld.map);
546
547 /* We attempt the summons on a particular, random position. If this is
548 * an invalid position then the summons simply fails this time. This means
549 * that a particular tile's chance of being summoned on is independent of
550 * all the other tiles on the map - which is essential for balanced
551 * gameplay. */
552 ptile = rand_map_pos(nmap);
553
555 return;
556 }
557
558 if (!(pc = find_closest_city(ptile, NULL, NULL, FALSE, FALSE, FALSE, FALSE,
559 FALSE, NULL))) {
560 /* any city */
561 return;
562 }
563
565
566 dist = real_map_distance(ptile, pc->tile);
567 log_debug("Closest city (to %d,%d) is %s (at %d,%d) distance %d.",
568 TILE_XY(ptile), city_name_get(pc), TILE_XY(pc->tile), dist);
569 if (dist > MAX_UNREST_DIST || dist < MIN_UNREST_DIST) {
570 return;
571 }
572
573 /* I think Sea Raiders can come out of unknown sea territory */
574 if (!(utile = find_empty_tile_nearby(ptile))
575 || (!map_is_known(utile, victim)
576 && !is_ocean_tile(utile))
577 || !is_near_land(utile)) {
578 return;
579 }
580
582
583 /* do not harass small civs - in practice: do not uprise at the beginning */
584 if ((int)fc_rand(30) + 1 >
585 (int)city_list_size(victim->cities) * (game.server.barbarianrate - 1)
587 return;
588 }
589 log_debug("Barbarians are willing to fight");
590
591 /* Remove huts in place of uprising */
592 /* FIXME: Should we really always do it? */
594 if (tile_has_extra(utile, pextra)) {
595 tile_extra_rm_apply(utile, pextra);
597 }
599
600 if (hut_present) {
602 }
603
606 uprise = 1;
607
608 while (city_max <= city_count) {
609 uprise++;
610 city_max += (city_max * 1.2) + UPRISE_CIV_SIZE;
611 }
612
615
616 if (!is_ocean_tile(utile)) {
617 /* land (disembark) barbarians */
619 if (!barbarians) {
620 return;
621 }
622 for (i = 0; i < barb_count; i++) {
623 struct unit_type *punittype
625
626 /* If unit cannot live on this tile, we just don't create one.
627 * Maybe find_a_unit_type() should take tile parameter, so
628 * we could get suitable unit if one exist. */
629 if (is_native_tile(punittype, utile)
631 (void) create_unit(barbarians, utile, punittype, 0, 0, -1);
633 log_debug("Created barbarian unit %s", utype_rule_name(punittype));
634 }
635 }
636
637 if (is_native_tile(leader_type, utile)
639 (void) create_unit(barbarians, utile,
640 leader_type, 0, 0, -1);
642 }
643 } else { /* Sea raiders - their units will be veteran */
644 struct unit *ptrans;
645 struct unit_type *boat;
646 bool miniphase;
647
649 if (!barbarians) {
650 return;
651 }
652 /* Setup data phase if it's not already set up. Created ferries may
653 need that data.
654 We don't know if create_barbarian_player() above created completely
655 new player or did it just return existing one. If it was existing
656 one, phase has already been set up at turn begin and will be closed
657 at turn end. If this is completely new player, we have to take care
658 of both opening and closing the data phase. Return value of
659 adv_data_phase_init() tells us if data phase was already initialized
660 at turn beginning. */
662 if (miniphase) {
664 }
665
667
668 if (is_native_tile(boat, utile)
670 && (is_safe_ocean(nmap, utile)
673 int cap;
674
675 ptrans = create_unit(barbarians, utile, boat, 0, 0, -1);
678
679 /* Fill boat with barb_count barbarians at max, leave space for leader */
680 for (i = 0; i < cap - 1 && i < barb_count; i++) {
681 struct unit_type *barb
683
686 (void) create_unit_full(barbarians, utile, barb, 0, 0, -1, -1,
687 ptrans);
689 log_debug("Created barbarian unit %s", utype_rule_name(barb));
690 }
691 }
692
696 -1, -1, ptrans);
698 }
699 }
700
701 if (miniphase) {
702 CALL_PLR_AI_FUNC(phase_finished, barbarians, barbarians);
704 }
705 }
706
707 if (really_created == 0) {
708 /* No barbarians found suitable spot */
709 return;
710 }
711
712 /* Is this necessary? create_unit_full() already sends unit info. */
716
717 /* to let them know where to get you */
720
721 /* There should probably be a different message about Sea Raiders */
724 _("Native unrest near %s led by %s."),
725 city_link(pc),
727 } else if (map_is_known_and_seen(utile, victim, V_MAIN)) {
729 _("Sea raiders seen near %s!"),
730 city_link(pc));
731 }
732}
733
734/**********************************************************************/
739{
740 int i, n;
741
744 return;
745 }
746
748 return;
749 }
750
752 if (n == 0) {
753 /* Allow barbarians on maps smaller than MAP_FACTOR */
754 n = 1;
755 }
756
757 for (i = 0; i < n * (game.server.barbarianrate - 1); i++) {
759 }
760}
761
762/**********************************************************************/
766{
767 /* It would be nice to get rid of this special case,
768 * and make barbarians to switch from "No Contact" to "War"
769 * upon first contact like everyone else. Then other parts
770 * of the code would not need to be prepared to the possibility
771 * of a war between no-contact nations.
772 * The problem is that if barbarians were not in War, they would
773 * likely not to head to attack towards yet-unknown players
774 * as aggressively */
775
776 players_iterate(pplayer) {
777 if (pplayer != barbarians) {
780 DS_WAR);
781 }
783}
bool is_action_enabled_unit_on_unit(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct unit *target_unit)
Definition actions.c:3168
bool adv_data_phase_init(struct player *pplayer, bool is_new_phase)
Definition advdata.c:263
void adv_data_phase_done(struct player *pplayer)
Definition advdata.c:566
#define CALL_PLR_AI_FUNC(_func, _player,...)
Definition ai.h:377
const char * default_ai_type_name(void)
Definition aiiface.c:264
#define n
Definition astring.c:77
static struct tile * find_empty_tile_nearby(struct tile *ptile)
Definition barbarian.c:504
static void try_summon_barbarians(void)
Definition barbarian.c:533
void barbarian_initial_wars(struct player *barbarians)
Definition barbarian.c:765
bool unleash_barbarians(struct tile *ptile)
Definition barbarian.c:272
void summon_barbarians(void)
Definition barbarian.c:738
#define BARBARIAN_INITIAL_VISION_RADIUS_SQ
Definition barbarian.c:70
static void init_dir_checked_status(bool *checked, enum terrain_class *terrainc, enum terrain_class tclass)
Definition barbarian.c:207
bool is_sea_barbarian(struct player *pplayer)
Definition barbarian.c:84
static bool is_near_land(struct tile *tile0)
Definition barbarian.c:490
static void unit_move_pay(struct unit *punit, struct tile *pdesttile)
Definition barbarian.c:245
bool is_land_barbarian(struct player *pplayer)
Definition barbarian.c:75
static int random_unchecked_direction(int possibilities, const bool *checked)
Definition barbarian.c:225
struct player * create_barbarian_player(enum barbarian_type type)
Definition barbarian.c:97
#define MAP_FACTOR
Definition barbarian.h:28
#define UPRISE_CIV_SIZE
Definition barbarian.h:26
#define MIN_UNREST_DIST
Definition barbarian.h:23
#define MAX_UNREST_DIST
Definition barbarian.h:24
#define BV_CLR(bv, bit)
Definition bitvector.h:94
const char * city_name_get(const struct city *pcity)
Definition city.c:1137
#define city_owner(_pcity_)
Definition city.h:560
struct city * find_closest_city(const struct tile *ptile, const struct city *pexclcity, const struct player *pplayer, bool only_ocean, bool only_continent, bool only_known, bool only_player, bool only_enemy, const struct unit_class *pclass)
Definition citytools.c:856
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 * punit
Definition dialogs_g.h:74
void set_ai_level_directer(struct player *pplayer, enum ai_level level)
Definition difficulty.c:39
void set_diplstate_type(struct player_diplstate *state1, struct player_diplstate *state2, enum diplstate_type type)
Definition diplhand.c:122
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
Definition effects.c:824
#define extra_type_by_rmcause_iterate_end
Definition extras.h:358
#define extra_type_by_rmcause_iterate(_rmcause, _extra)
Definition extras.h:353
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_server
const char * city_link(const struct city *pcity)
struct civ_game game
Definition game.c:61
struct world wld
Definition game.c:62
@ BARBS_HUTS_ONLY
Definition game.h:53
@ BARBS_DISABLED
Definition game.h:52
GType type
Definition repodlgs.c:1313
#define log_verbose(message,...)
Definition log.h:110
#define fc_assert(condition)
Definition log.h:177
#define log_debug(message,...)
Definition log.h:116
int map_num_tiles(void)
Definition map.c:1152
struct tile * rand_map_pos(const struct civ_map *nmap)
Definition map.c:1228
bool is_safe_ocean(const struct civ_map *nmap, const struct tile *ptile)
Definition map.c:712
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:675
struct tile * mapstep(const struct civ_map *nmap, const struct tile *ptile, enum direction8 dir)
Definition map.c:384
#define square_iterate(nmap, center_tile, radius, tile_itr)
Definition map.h:388
#define square_iterate_end
Definition map.h:391
static int map_move_cost_unit(const struct civ_map *nmap, struct unit *punit, const struct tile *ptile)
Definition map.h:290
#define whole_map_iterate(_map, _tile)
Definition map.h:573
#define whole_map_iterate_end
Definition map.h:582
bool map_is_known(const struct tile *ptile, const struct player *pplayer)
Definition maphand.c:899
bool map_is_known_and_seen(const struct tile *ptile, const struct player *pplayer, enum vision_layer vlayer)
Definition maphand.c:925
void map_show_circle(struct player *pplayer, struct tile *ptile, int radius_sq)
Definition maphand.c:869
void update_tile_knowledge(struct tile *ptile)
Definition maphand.c:1444
void map_clear_known(struct tile *ptile, struct player *pplayer)
Definition maphand.c:1191
bool is_native_tile(const struct unit_type *punittype, const struct tile *ptile)
Definition movement.c:330
bool unit_can_move_to_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *dst_tile, bool igzoc, bool enter_transport, bool enter_enemy_city)
Definition movement.c:571
bool can_unit_type_transport(const struct unit_type *transporter, const struct unit_class *transported)
Definition movement.c:869
struct nation_type * nation_of_player(const struct player *pplayer)
Definition nation.c:444
const char * nation_plural_for_player(const struct player *pplayer)
Definition nation.c:178
struct government * init_government_of_nation(const struct nation_type *pnation)
Definition nation.c:659
void notify_player(const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Definition notify.c:291
int player_number(const struct player *pplayer)
Definition player.c:837
const char * player_name(const struct player *pplayer)
Definition player.c:895
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Definition player.c:324
#define players_iterate_end
Definition player.h:542
#define players_iterate(_pplayer)
Definition player.h:537
#define ANON_USER_NAME
Definition player.h:48
#define set_as_ai(plr)
Definition player.h:234
void server_player_set_name(struct player *pplayer, const char *name)
Definition plrhand.c:2270
void send_player_all_c(struct player *src, struct conn_list *dest)
Definition plrhand.c:1131
struct player * server_create_player(int player_id, const char *ai_tname, struct rgbcolor *prgbcolor, bool allow_ai_type_fallbacking)
Definition plrhand.c:1896
struct nation_type * pick_a_nation(const struct nation_list *choices, bool ignore_conflicts, bool needs_startpos, enum barbarian_type barb_type)
Definition plrhand.c:2458
void player_status_reset(struct player *plr)
Definition plrhand.c:3233
void server_player_init(struct player *pplayer, bool initmap, bool needs_team)
Definition plrhand.c:1620
void assign_player_colors(void)
Definition plrhand.c:1736
#define fc_rand(_size)
Definition rand.h:56
struct research * research_get(const struct player *pplayer)
Definition research.c:128
const char * pick_random_player_name(const struct nation_type *pnation)
Definition srv_main.c:2844
void player_nation_defaults(struct player *pplayer, struct nation_type *pnation, bool set_name)
Definition srv_main.c:2621
bool game_was_started(void)
Definition srv_main.c:354
Definition city.h:317
enum barbarians_rate barbarianrate
Definition game.h:140
int onsetbarbarian
Definition game.h:178
struct packet_game_info info
Definition game.h:89
struct civ_game::@32::@36 server
enum ai_level skill_level
enum barbarian_type barbarian_type
Definition player.h:122
struct player_ai ai_common
Definition player.h:288
Definition tile.h:50
struct unit_list * units
Definition tile.h:58
Definition unit.h:140
struct civ_map map
#define sz_strlcpy(dest, src)
Definition support.h:195
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
void init_tech(struct research *research, bool update)
Definition techtools.c:1094
void send_research_info(const struct research *presearch, const struct conn_list *dest)
Definition techtools.c:293
void give_initial_techs(struct research *presearch, int num_random_techs)
Definition techtools.c:1188
#define is_ocean_tile(ptile)
Definition terrain.h:196
#define terrain_has_flag(terr, flag)
Definition terrain.h:176
bool tile_extra_rm_apply(struct tile *ptile, struct extra_type *tgt)
Definition tile.c:601
#define tile_terrain(_tile)
Definition tile.h:111
#define TILE_XY(ptile)
Definition tile.h:43
#define tile_has_extra(ptile, pextra)
Definition tile.h:148
int get_transporter_capacity(const struct unit *punit)
Definition unit.c:297
#define unit_owner(_pu)
Definition unit.h:403
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer, bool everyone_non_allied)
Definition unit.h:440
void unit_do_action(struct player *pplayer, const int actor_id, const int target_id, const int sub_tgt_id, const char *name, const action_id action_type)
Definition unithand.c:3338
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_safe(unitlist, _unit)
Definition unitlist.h:39
#define unit_list_iterate_end
Definition unitlist.h:33
#define unit_list_iterate_safe_end
Definition unitlist.h:61
void send_unit_info(struct conn_list *dest, struct unit *punit)
Definition unittools.c:2877
struct unit * create_unit_full(struct player *pplayer, struct tile *ptile, const struct unit_type *type, int veteran_level, int homecity_id, int moves_left, int hp_left, struct unit *ptrans)
Definition unittools.c:1632
struct unit * create_unit(struct player *pplayer, struct tile *ptile, const struct unit_type *type, int veteran_level, int homecity_id, int moves_left)
Definition unittools.c:1605
void wipe_unit(struct unit *punit, enum unit_loss_reason reason, struct player *killer)
Definition unittools.c:2139
struct unit_type * find_a_unit_type(enum unit_role_id role, enum unit_role_id role_tech)
Definition unittools.c:175
bool unit_move(struct unit *punit, struct tile *pdesttile, int move_cost, struct unit *embark_to, bool find_embark_target, bool conquer_city_allowed, bool conquer_extras_allowed, bool enter_hut, bool frighten_hut)
Definition unittools.c:4078
struct unit_type * get_role_unit(int role, int role_index)
Definition unittype.c:2259
int num_role_units(int role)
Definition unittype.c:2209
bool utype_player_already_has_this_unique(const struct player *pplayer, const struct unit_type *putype)
Definition unittype.c:1933
const char * utype_rule_name(const struct unit_type *punittype)
Definition unittype.c:1584
#define utype_class(_t_)
Definition unittype.h:756
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:624