Freeciv-3.2
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_COUNT DE_COUNT
41#define SPECENUM_BITVECTOR bv_disaster_effects
42#include "specenum_gen.h"
43
44#define DISASTER_BASE_RARITY 1000000
45
47 int id;
49
51
52 /* Final probability for each city each turn is
53 * this frequency * game.info.disasters frequency setting / DISASTER_BASE_RARITY */
55
57};
58
59/* Initialization and iteration */
60void disaster_types_init(void);
61void disaster_types_free(void);
62
63/* General disaster type accessor functions. */
67
69
71const char *disaster_rule_name(struct disaster_type *pdis);
72struct disaster_type *disaster_by_rule_name(const char *name);
73
74bool disaster_has_effect(const struct disaster_type *pdis,
76
77bool can_disaster_happen(const struct disaster_type *pdis,
78 const struct city *pcity);
79
80#define disaster_type_iterate(_p) \
81{ \
82 int _i_; \
83 for (_i_ = 0; _i_ < game.control.num_disaster_types ; _i_++) { \
84 struct disaster_type *_p = disaster_by_number(_i_);
85
86#define disaster_type_iterate_end \
87 } \
88}
89
90/* Deletion of disasters not supported */
91#define disaster_type_re_active_iterate(_p) \
92 disaster_type_iterate(_p)
93
94#define disaster_type_re_active_iterate_end \
95 disaster_type_iterate_end;
96
97#ifdef __cplusplus
98}
99#endif /* __cplusplus */
100
101#endif /* FC__DISASTER_H */
char * incite_cost
Definition comments.c:75
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:385
const char * name
Definition inputfile.c:127
Definition city.h:320
struct name_translation name
Definition disaster.h:48
struct requirement_vector reqs
Definition disaster.h:50
bv_disaster_effects effects
Definition disaster.h:56