Freeciv-3.2
Loading...
Searching...
No Matches
advruleset.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - 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#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* common */
19#include "base.h"
20#include "effects.h"
21#include "map.h"
22#include "movement.h"
23#include "unittype.h"
24
25/* server/advisors */
26#include "autosettlers.h"
27
28#include "advruleset.h"
29
30/**********************************************************************/
34{
36 bool move_land_enabled = FALSE; /* Can move at some land terrains */
37 bool move_land_disabled = FALSE; /* Cannot move at some land terrains */
38 bool move_sea_enabled = FALSE; /* Can move at some ocean terrains */
39 bool move_sea_disabled = FALSE; /* Cannot move at some ocean terrains */
40
41 terrain_type_iterate(pterrain) {
42 if (is_native_to_class(pclass, pterrain, NULL)) {
43 /* Can move at terrain */
44 if (is_ocean(pterrain)) {
46 } else {
48 }
49 } else {
50 /* Cannot move at terrain */
51 if (is_ocean(pterrain)) {
53 } else {
55 }
56 }
58
60 pclass->adv.land_move = MOVE_FULL;
62 pclass->adv.land_move = MOVE_PARTIAL;
63 } else {
65 pclass->adv.land_move = MOVE_NONE;
66 }
67
69 pclass->adv.sea_move = MOVE_FULL;
70 } else if (move_sea_enabled && move_sea_disabled) {
71 pclass->adv.sea_move = MOVE_PARTIAL;
72 } else {
74 pclass->adv.sea_move = MOVE_NONE;
75 }
76
77 pclass->adv.ferry_types = 0;
79
81 const struct req_context context = { .unittype = ptype };
82
84
86 if (peffect->value > 0) {
89 ptype->adv.igwall = FALSE;
90 break;
91 }
93 }
94 if (!ptype->adv.igwall) {
95 break;
96 }
98
101 if (BV_ISSET(ptype->cargo, uclass_index(aclass))) {
102 aclass->adv.ferry_types++;
103 }
105 }
106
107 ptype->adv.worker
115
116 /* Initialize autosettlers actions */
118}
void adv_units_ruleset_init(void)
Definition advruleset.c:33
void auto_settlers_ruleset_init(void)
#define BV_ISSET(bv, bit)
Definition bitvector.h:78
char * incite_cost
Definition comments.c:75
struct effect_list * get_effects(enum effect_type effect_type)
Definition effects.c:143
#define effect_list_iterate_end
Definition effects.h:406
#define effect_list_iterate(effect_list, peffect)
Definition effects.h:404
@ RPT_POSSIBLE
Definition fc_types.h:700
#define fc_assert(condition)
Definition log.h:176
bool is_native_to_class(const struct unit_class *punitclass, const struct terrain *pterrain, const bv_extras *extras)
Definition movement.c:342
bool is_req_active(const struct req_context *context, const struct player *other_player, const struct requirement *req, const enum req_problem_type prob_type)
#define requirement_vector_iterate_end
#define requirement_vector_iterate(req_vec, preq)
const struct unit_type * unittype
struct unit_type::@87 adv
bool igwall
Definition unittype.h:574
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define terrain_type_iterate(_p)
Definition terrain.h:373
#define is_ocean(pterrain)
Definition terrain.h:301
#define terrain_type_iterate_end
Definition terrain.h:379
bool utype_has_role(const struct unit_type *punittype, int role)
Definition unittype.c:199
bool utype_can_do_action_result(const struct unit_type *putype, enum action_result result)
Definition unittype.c:387
#define unit_class_iterate(_p)
Definition unittype.h:908
@ MOVE_PARTIAL
Definition unittype.h:144
@ MOVE_FULL
Definition unittype.h:144
@ MOVE_NONE
Definition unittype.h:144
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:617
#define unit_type_iterate(_p)
Definition unittype.h:855
#define uclass_index(_c_)
Definition unittype.h:742
#define unit_class_iterate_end
Definition unittype.h:915
#define unit_type_iterate_end
Definition unittype.h:862