Freeciv-3.1: /fast/freeciv/nightly/S3_1/common/disaster.h Source File

Freeciv-3.1

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
46 struct disaster_type {
47 int id;
48 struct name_translation name;
49
50 struct requirement_vector reqs;
51
52 /* Final probability for each city each turn is
53 * this frequency * game.info.disasters frequency setting / DISASTER_BASE_RARITY */
54 int frequency;
55
56 bv_disaster_effects effects;
57};
58
59/* Initialization and iteration */
60void disaster_types_init(void);
61void disaster_types_free(void);
62
63/* General disaster type accessor functions. */
64 Disaster_type_id disaster_count(void);
65 Disaster_type_id disaster_index(const struct disaster_type *pdis);
66 Disaster_type_id disaster_number(const struct disaster_type *pdis);
67
68struct disaster_type *disaster_by_number(Disaster_type_id id);
69
70const char *disaster_name_translation(struct disaster_type *pdis);
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,
75 enum disaster_effect_id effect);
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 */
disaster_rule_name
const char * disaster_rule_name(struct disaster_type *pdis)
Definition disaster.c:105
can_disaster_happen
bool can_disaster_happen(const struct disaster_type *pdis, const struct city *pcity)
Definition disaster.c:139
disaster_number
Disaster_type_id disaster_number(const struct disaster_type *pdis)
Definition disaster.c:56
disaster_index
Disaster_type_id disaster_index(const struct disaster_type *pdis)
Definition disaster.c:69
disaster_by_rule_name
struct disaster_type * disaster_by_rule_name(const char *name)
Definition disaster.c:114
disaster_name_translation
const char * disaster_name_translation(struct disaster_type *pdis)
Definition disaster.c:97
disaster_by_number
struct disaster_type * disaster_by_number(Disaster_type_id id)
Definition disaster.c:87
disaster_count
Disaster_type_id disaster_count(void)
Definition disaster.c:79
disaster_has_effect
bool disaster_has_effect(const struct disaster_type *pdis, enum disaster_effect_id effect)
Definition disaster.c:130
disaster_types_init
void disaster_types_init(void)
Definition disaster.c:33
disaster_types_free
void disaster_types_free(void)
Definition disaster.c:46
Disaster_type_id
int Disaster_type_id
Definition fc_types.h:355
name
const char * name
Definition inputfile.c:127
name_translation.h
requirements.h
specenum_gen.h
city
Definition city.h:309
disaster_type
Definition disaster.h:46
disaster_type::name
struct name_translation name
Definition disaster.h:48
disaster_type::reqs
struct requirement_vector reqs
Definition disaster.h:50
disaster_type::id
int id
Definition disaster.h:47
disaster_type::effects
bv_disaster_effects effects
Definition disaster.h:56
disaster_type::frequency
int frequency
Definition disaster.h:54
effect
Definition effects.h:340
name_translation
Definition name_translation.h:35