Freeciv-3.2: /fast/freeciv/nightly/S3_2/common/counters.h Source File

Freeciv-3.2

Loading...
Searching...
No Matches
counters.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__COUNTERS_H
14#define FC__COUNTERS_H
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
20/* utility */
21#include "support.h"
22
23/* common */
24#include "name_translation.h"
25
26 struct counter
27{
28 struct name_translation name;
29 struct strvec *helptext;
30 bool ruledit_disabled;
31 enum counter_behaviour type;
32 enum counter_target target;
33 int checkpoint;
34 int def; /* default value for each entity of given type
35 * for this counter */
36
37 int index; /* index in specific (city/player/world) array */
38};
39
40void counters_init(void);
41void counters_free(void);
42
43struct counter *counter_by_id(int id);
44int counter_id(struct counter *pcount);
45
46struct counter *counter_by_rule_name(const char *name);
47const char *counter_rule_name(struct counter *pcount);
48
49const char *counter_name_translation(const struct counter *counter);
50struct counter *counter_by_translated_name(const char *name);
51
52int counter_index(const struct counter *pcount);
53struct counter *counter_by_index(int index, enum counter_target target);
54int counters_get_city_counters_count(void);
55void attach_city_counter(struct counter *counter);
56
57#define city_counters_iterate(pcount) { \
58 int _i_##pcount; \
59 struct counter *pcount; \
60 int _ccounter_count_##pcount = counters_get_city_counters_count(); \
61 for (_i_##pcount = 0; _i_##pcount < _ccounter_count_##pcount; _i_##pcount++) { \
62 pcount = counter_by_index(_i_##pcount, CTGT_CITY);
63
64#define city_counters_iterate_end } \
65 }
66
67#define counters_re_iterate(pcount) { \
68 int _i_##pcount; \
69 struct counter *pcount; \
70 int _ccounter_count_##pcount = game.control.num_counters; { \
71 for (_i_##pcount = 0; _i_##pcount < _ccounter_count_##pcount; _i_##pcount++) { \
72 pcount = counter_by_id(_i_##pcount); \
73 if ( ! pcount -> ruledit_disabled ) {
74
75#define counters_re_iterate_end } \
76 } \
77 } \
78 }
79#ifdef __cplusplus
80}
81#endif /* __cplusplus */
82
83#endif /* FC__COUNTERS_H */
incite_cost
char * incite_cost
Definition comments.c:74
counter_by_index
struct counter * counter_by_index(int index, enum counter_target target)
Definition counters.c:183
counter_index
int counter_index(const struct counter *pcount)
Definition counters.c:174
counters_init
void counters_init(void)
Definition counters.c:40
counter_name_translation
const char * counter_name_translation(const struct counter *counter)
Definition counters.c:157
counter_by_rule_name
struct counter * counter_by_rule_name(const char *name)
Definition counters.c:115
counter_by_translated_name
struct counter * counter_by_translated_name(const char *name)
Definition counters.c:136
counter_rule_name
const char * counter_rule_name(struct counter *pcount)
Definition counters.c:165
counters_get_city_counters_count
int counters_get_city_counters_count(void)
Definition counters.c:74
counters_free
void counters_free(void)
Definition counters.c:51
counter_by_id
struct counter * counter_by_id(int id)
Definition counters.c:82
counter_id
int counter_id(struct counter *pcount)
Definition counters.c:105
attach_city_counter
void attach_city_counter(struct counter *counter)
Definition counters.c:94
counter_target
counter_target
Definition fc_types.h:126
name
const char * name
Definition inputfile.c:127
name_translation.h
counter
Definition counters.h:27
counter::target
enum counter_target target
Definition counters.h:32
counter::def
int def
Definition counters.h:34
counter::ruledit_disabled
bool ruledit_disabled
Definition counters.h:30
counter::checkpoint
int checkpoint
Definition counters.h:33
counter::index
int index
Definition counters.h:37
counter::name
struct name_translation name
Definition counters.h:28
counter::helptext
struct strvec * helptext
Definition counters.h:29
counter::type
enum counter_behaviour type
Definition counters.h:31
name_translation
Definition name_translation.h:35
strvec
Definition string_vector.c:29
support.h