Freeciv-3.3
Loading...
Searching...
No Matches
disaster.h
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#ifndef FC__DISASTER_H
14#define FC__DISASTER_H
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
20/* common */
21#include "name_translation.h"
22#include "requirements.h"
23
24/* Used in the network protocol. */
25#define SPECENUM_NAME disaster_effect_id
26#define SPECENUM_VALUE0 DE_DESTROY_BUILDING
27#define SPECENUM_VALUE0NAME "DestroyBuilding"
28#define SPECENUM_VALUE1 DE_REDUCE_POP
29#define SPECENUM_VALUE1NAME "ReducePopulation"
30#define SPECENUM_VALUE2 DE_EMPTY_FOODSTOCK
31#define SPECENUM_VALUE2NAME "EmptyFoodStock"
32#define SPECENUM_VALUE3 DE_EMPTY_PRODSTOCK
33#define SPECENUM_VALUE3NAME "EmptyProdStock"
34#define SPECENUM_VALUE4 DE_POLLUTION
35#define SPECENUM_VALUE4NAME "Pollution"
36#define SPECENUM_VALUE5 DE_FALLOUT
37#define SPECENUM_VALUE5NAME "Fallout"
38#define SPECENUM_VALUE6 DE_REDUCE_DESTROY
39#define SPECENUM_VALUE6NAME "ReducePopDestroy"
40#define SPECENUM_VALUE7 DE_ROBBERY
41#define SPECENUM_VALUE7NAME "Robbery"
42#define SPECENUM_COUNT DE_COUNT
43#define SPECENUM_BITVECTOR bv_disaster_effects
44#include "specenum_gen.h"
45
46#define DISASTER_BASE_RARITY 1000000
47
49 int id;
51
53
54 /* Final probability for each city each turn is
55 * this frequency * game.info.disasters frequency setting / DISASTER_BASE_RARITY */
57
59};
60
61/* Initialization and iteration */
62void disaster_types_init(void);
63void disaster_types_free(void);
64
65/* General disaster type accessor functions. */
69
71
73const char *disaster_rule_name(struct disaster_type *pdis);
74struct disaster_type *disaster_by_rule_name(const char *name);
75
76bool disaster_has_effect(const struct disaster_type *pdis,
78
79bool can_disaster_happen(const struct disaster_type *pdis,
80 const struct city *pcity);
81
82#define disaster_type_iterate(_p) \
83{ \
84 int _i_; \
85 for (_i_ = 0; _i_ < game.control.num_disaster_types ; _i_++) { \
86 struct disaster_type *_p = disaster_by_number(_i_);
87
88#define disaster_type_iterate_end \
89 } \
90}
91
92/* Deletion of disasters not supported */
93#define disaster_type_re_active_iterate(_p) \
94 disaster_type_iterate(_p)
95
96#define disaster_type_re_active_iterate_end \
97 disaster_type_iterate_end;
98
99#ifdef __cplusplus
100}
101#endif /* __cplusplus */
102
103#endif /* FC__DISASTER_H */
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 int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
const char * disaster_rule_name(struct disaster_type *pdis)
Definition disaster.c:105
bool can_disaster_happen(const struct disaster_type *pdis, const struct city *pcity)
Definition disaster.c:139
Disaster_type_id disaster_number(const struct disaster_type *pdis)
Definition disaster.c:56
Disaster_type_id disaster_index(const struct disaster_type *pdis)
Definition disaster.c:69
struct disaster_type * disaster_by_rule_name(const char *name)
Definition disaster.c:114
const char * disaster_name_translation(struct disaster_type *pdis)
Definition disaster.c:97
struct disaster_type * disaster_by_number(Disaster_type_id id)
Definition disaster.c:87
Disaster_type_id disaster_count(void)
Definition disaster.c:79
bool disaster_has_effect(const struct disaster_type *pdis, enum disaster_effect_id effect)
Definition disaster.c:130
void disaster_types_init(void)
Definition disaster.c:33
void disaster_types_free(void)
Definition disaster.c:46
int Disaster_type_id
Definition fc_types.h:244
const char * name
Definition inputfile.c:127
Definition city.h:317
struct name_translation name
Definition disaster.h:50
struct requirement_vector reqs
Definition disaster.h:52
bv_disaster_effects effects
Definition disaster.h:58