~ubuntu-branches/ubuntu/natty/freeciv/natty-proposed

« back to all changes in this revision

Viewing changes to common/requirements.h

  • Committer: Bazaar Package Importer
  • Author(s): Clint Adams, Karl Goetz, Clint Adams
  • Date: 2010-02-23 22:09:02 UTC
  • mfrom: (7.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100223220902-s3spqi1x4e190y0t
Tags: 2.2.0-1
[ Karl Goetz ]
* Remove civserver files in /etc/ggzd/ (Closes: 523772, 517787)
* Adding ${misc:Depends} to all binary packages (lintian warnings)

[ Clint Adams ]
* New upstream version.
  - Drop data_dsc_use_bindir.diff (binary pathnames have changed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
#define FC__REQUIREMENTS_H
16
16
 
17
17
#include "fc_types.h"
 
18
 
18
19
#include "tech.h"
19
20
#include "terrain.h"
20
21
#include "unittype.h"
21
22
 
22
 
/* The type of a requirement source.  This must correspond to req_type_names[]
23
 
 * in requirements.c. */
24
 
enum req_source_type {
25
 
  REQ_NONE,
26
 
  REQ_TECH,
27
 
  REQ_GOV,
28
 
  REQ_BUILDING,
29
 
  REQ_SPECIAL,
30
 
  REQ_TERRAIN,
31
 
  REQ_NATION,
32
 
  REQ_UNITTYPE,
33
 
  REQ_UNITFLAG,
34
 
  REQ_UNITCLASS,
35
 
  REQ_OUTPUTTYPE,
36
 
  REQ_SPECIALIST,
37
 
  REQ_MINSIZE, /* Minimum size: at city range means city size */
38
 
  REQ_LAST
39
 
};
40
 
 
41
23
/* Range of requirements.  This must correspond to req_range_names[]
42
24
 * in requirements.c. */
43
25
enum req_range {
50
32
  REQ_RANGE_LAST   /* keep this last */
51
33
};
52
34
 
53
 
/* A requirement source. */
54
 
struct req_source {
55
 
  enum req_source_type type;            /* source type */
56
 
 
57
 
  union {
58
 
    Tech_type_id tech;                  /* source tech */
59
 
    struct government *gov;             /* source government */
60
 
    Impr_type_id building;              /* source building */
61
 
    enum tile_special_type special;     /* source special */
62
 
    struct terrain *terrain;            /* source terrain type */
63
 
    struct nation_type *nation;         /* source nation type */
64
 
    struct unit_type *unittype;         /* source unittype */
65
 
    enum unit_flag_id unitflag;         /* source unit flag */
66
 
    struct unit_class *unitclass;       /* source unit class */
67
 
    Output_type_id outputtype;          /* source output type */
68
 
    Specialist_type_id specialist;      /* specialist type */
69
 
    int minsize;                        /* source minsize type */
70
 
  } value;                              /* source value */
71
 
};
72
 
 
73
35
/* A requirement. This requirement is basically a conditional; it may or
74
36
 * may not be active on a target.  If it is active then something happens.
75
37
 * For instance units and buildings have requirements to be built, techs
76
38
 * have requirements to be researched, and effects have requirements to be
77
39
 * active. */
78
40
struct requirement {
79
 
  struct req_source source;             /* requirement source */
 
41
  struct universal source;              /* requirement source */
80
42
  enum req_range range;                 /* requirement range */
81
43
  bool survives; /* set if destroyed sources satisfy the req*/
82
44
  bool negated;  /* set if the requirement is to be negated */
96
58
  TYPED_VECTOR_ITERATE(struct requirement, req_vec, preq)
97
59
#define requirement_vector_iterate_end VECTOR_ITERATE_END
98
60
 
99
 
struct req_source req_source_from_str(const char *type, const char *value);
100
 
struct req_source req_source_from_values(int type, int value);
101
 
void req_source_get_values(const struct req_source *source,
102
 
                           int *type, int *value);
103
 
 
 
61
/* General requirement functions. */
104
62
enum req_range req_range_from_str(const char *str);
105
63
struct requirement req_from_str(const char *type, const char *range,
106
64
                                bool survives, bool negated,
136
94
 
137
95
bool is_req_unchanging(const struct requirement *req);
138
96
 
139
 
/* Req-source helper functions. */
140
 
bool are_req_sources_equal(const struct req_source *psource1,
141
 
                           const struct req_source *psource2);
142
 
char *get_req_source_text(const struct req_source *psource,
143
 
                          char *buf, size_t bufsz);
144
 
 
145
 
const char *get_req_source_type_name_orig(const struct req_source *psource);
 
97
/* General universal functions. */
 
98
int universal_number(const struct universal *source);
 
99
 
 
100
struct universal universal_by_number(const enum universals_n kind,
 
101
                                     const int value);
 
102
struct universal universal_by_rule_name(const char *kind,
 
103
                                        const char *value);
 
104
void universal_extraction(const struct universal *source,
 
105
                          int *kind, int *value);
 
106
 
 
107
bool are_universals_equal(const struct universal *psource1,
 
108
                          const struct universal *psource2);
 
109
 
 
110
const char *universal_kind_name(const enum universals_n kind);
 
111
const char *universal_rule_name(const struct universal *psource);
 
112
const char *universal_name_translation(const struct universal *psource,
 
113
                                       char *buf, size_t bufsz);
 
114
const char *universal_type_rule_name(const struct universal *psource);
 
115
 
 
116
int universal_build_shield_cost(const struct universal *target);
146
117
 
147
118
#endif  /* FC__REQUIREMENTS_H */