Freeciv-3.3
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 "autoworkers.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 autoworkers actions */
118}
void adv_units_ruleset_init(void)
Definition advruleset.c:33
void auto_workers_ruleset_init(void)
Definition autoworkers.c:95
#define BV_ISSET(bv, bit)
Definition bitvector.h:86
char * incite_cost
Definition comments.c:76
struct effect_list * get_effects(enum effect_type effect_type)
Definition effects.c:143
#define effect_list_iterate_end
Definition effects.h:81
#define effect_list_iterate(effect_list, peffect)
Definition effects.h:79
@ RPT_POSSIBLE
Definition fc_types.h:532
#define fc_assert(condition)
Definition log.h:177
bool is_native_to_class(const struct unit_class *punitclass, const struct terrain *pterrain, const bv_extras *extras)
Definition movement.c:341
bool is_req_active(const struct req_context *context, const struct req_context *other_context, 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::@90 adv
bool igwall
Definition unittype.h:581
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define terrain_type_iterate(_p)
Definition terrain.h:266
#define is_ocean(pterrain)
Definition terrain.h:194
#define terrain_type_iterate_end
Definition terrain.h:272
bool utype_has_role(const struct unit_type *punittype, int role)
Definition unittype.c:205
bool utype_can_do_action_result(const struct unit_type *putype, enum action_result result)
Definition unittype.c:393
#define unit_class_iterate(_p)
Definition unittype.h:915
@ 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:624
#define unit_type_iterate(_p)
Definition unittype.h:862
#define uclass_index(_c_)
Definition unittype.h:749
#define unit_class_iterate_end
Definition unittype.h:922
#define unit_type_iterate_end
Definition unittype.h:869