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)
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
18 #endif /* __cplusplus */
20 /* Used in the network protocol. */
21 #define SPECENUM_NAME disaster_effect_id
22 #define SPECENUM_VALUE0 DE_DESTROY_BUILDING
23 #define SPECENUM_VALUE0NAME "DestroyBuilding"
24 #define SPECENUM_VALUE1 DE_REDUCE_POP
25 #define SPECENUM_VALUE1NAME "ReducePopulation"
26 #define SPECENUM_VALUE2 DE_EMPTY_FOODSTOCK
27 #define SPECENUM_VALUE2NAME "EmptyFoodStock"
28 #define SPECENUM_VALUE3 DE_EMPTY_PRODSTOCK
29 #define SPECENUM_VALUE3NAME "EmptyProdStock"
30 #define SPECENUM_VALUE4 DE_POLLUTION
31 #define SPECENUM_VALUE4NAME "Pollution"
32 #define SPECENUM_VALUE5 DE_FALLOUT
33 #define SPECENUM_VALUE5NAME "Fallout"
34 #define SPECENUM_COUNT DE_COUNT
35 #include "specenum_gen.h"
37 BV_DEFINE(bv_disaster_effects
, DE_COUNT
); /* Used in the network protocol. */
39 #define DISASTER_BASE_RARITY 1000000
41 struct disaster_type
{
43 struct name_translation name
;
45 struct requirement_vector reqs
;
47 /* Final probability for each city each turn is
48 * this frequency * game.info.disasters frequency setting / DISASTER_BASE_RARITY */
51 bv_disaster_effects effects
;
54 /* Initialization and iteration */
55 void disaster_types_init(void);
56 void disaster_types_free(void);
58 /* General disaster type accessor functions. */
59 Disaster_type_id
disaster_count(void);
60 Disaster_type_id
disaster_index(const struct disaster_type
*pdis
);
61 Disaster_type_id
disaster_number(const struct disaster_type
*proad
);
63 struct disaster_type
*disaster_by_number(Disaster_type_id id
);
65 const char *disaster_name_translation(struct disaster_type
*pdis
);
66 const char *disaster_rule_name(struct disaster_type
*pdis
);
68 bool disaster_has_effect(const struct disaster_type
*pdis
,
69 enum disaster_effect_id effect
);
71 bool can_disaster_happen(struct disaster_type
*pdis
, struct city
*pcity
);
73 #define disaster_type_iterate(_p) \
76 for (_i_ = 0; _i_ < game.control.num_disaster_types ; _i_++) { \
77 struct disaster_type *_p = disaster_by_number(_i_);
79 #define disaster_type_iterate_end \
84 #endif /* __cplusplus */
86 #endif /* FC__DISASTER_H */