Freeciv-3.3
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
26struct counter
27{
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);
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 */
char * incite_cost
Definition comments.c:76
struct counter * counter_by_index(int index, enum counter_target target)
Definition counters.c:183
int counter_index(const struct counter *pcount)
Definition counters.c:174
void counters_init(void)
Definition counters.c:40
const char * counter_name_translation(const struct counter *counter)
Definition counters.c:157
struct counter * counter_by_rule_name(const char *name)
Definition counters.c:115
struct counter * counter_by_translated_name(const char *name)
Definition counters.c:136
const char * counter_rule_name(struct counter *pcount)
Definition counters.c:165
int counters_get_city_counters_count(void)
Definition counters.c:74
void counters_free(void)
Definition counters.c:51
struct counter * counter_by_id(int id)
Definition counters.c:82
int counter_id(struct counter *pcount)
Definition counters.c:105
void attach_city_counter(struct counter *counter)
Definition counters.c:94
counter_target
Definition fc_types.h:126
const char * name
Definition inputfile.c:127
enum counter_target target
Definition counters.h:32
int def
Definition counters.h:34
bool ruledit_disabled
Definition counters.h:30
int checkpoint
Definition counters.h:33
int index
Definition counters.h:37
struct name_translation name
Definition counters.h:28
struct strvec * helptext
Definition counters.h:29
enum counter_behaviour type
Definition counters.h:31