Do not build gtk3.22-client by default
[freeciv.git] / server / settings.h
blobb31871c46f76ae8f8b129dacd5720eb3264721eb
1 /**********************************************************************
2 Freeciv - Copyright (C) 1996-2004 - The Freeciv Project
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.
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 ***********************************************************************/
14 #ifndef FC__SETTINGS_H
15 #define FC__SETTINGS_H
17 #ifdef __cplusplus
18 extern "C" {
19 #endif /* __cplusplus */
21 /* utility */
22 #include "shared.h"
24 /* common */
25 #include "game.h"
27 struct sset_val_name {
28 const char *support; /* Untranslated long support name, used
29 * for saving. */
30 const char *pretty; /* Translated, used to display to the
31 * users. */
34 /* Whether settings are sent to the client when the client lists
35 * server options; also determines whether clients can set them in principle.
36 * Eg, not sent: seeds, saveturns, etc.
38 #define SSET_TO_CLIENT TRUE
39 #define SSET_SERVER_ONLY FALSE
41 /* Categories allow options to be usefully organized when presented to the
42 * user */
43 #define SPECENUM_NAME sset_category
44 #define SPECENUM_VALUE0 SSET_GEOLOGY
45 #define SPECENUM_VALUE0NAME N_("Geological")
46 #define SPECENUM_VALUE1 SSET_SOCIOLOGY
47 #define SPECENUM_VALUE1NAME N_("Sociological")
48 #define SPECENUM_VALUE2 SSET_ECONOMICS
49 #define SPECENUM_VALUE2NAME N_("Economic")
50 #define SPECENUM_VALUE3 SSET_MILITARY
51 #define SPECENUM_VALUE3NAME N_("Military")
52 #define SPECENUM_VALUE4 SSET_SCIENCE
53 #define SPECENUM_VALUE4NAME N_("Scientific")
54 #define SPECENUM_VALUE5 SSET_INTERNAL
55 #define SPECENUM_VALUE5NAME N_("Internal")
56 #define SPECENUM_VALUE6 SSET_NETWORK
57 #define SPECENUM_VALUE6NAME N_("Networking")
58 /* keep this last */
59 #define SPECENUM_COUNT SSET_NUM_CATEGORIES
60 #include "specenum_gen.h"
62 /* Levels allow options to be subdivided and thus easier to navigate */
63 #define SPECENUM_NAME sset_level
64 #define SPECENUM_VALUE0 SSET_NONE
65 #define SPECENUM_VALUE0NAME N_("?ssetlevel:None")
66 #define SPECENUM_VALUE1 SSET_ALL
67 #define SPECENUM_VALUE1NAME N_("All")
68 #define SPECENUM_VALUE2 SSET_VITAL
69 #define SPECENUM_VALUE2NAME N_("Vital")
70 #define SPECENUM_VALUE3 SSET_SITUATIONAL
71 #define SPECENUM_VALUE3NAME N_("Situational")
72 #define SPECENUM_VALUE4 SSET_RARE
73 #define SPECENUM_VALUE4NAME N_("Rare")
74 #define SPECENUM_VALUE5 SSET_CHANGED
75 #define SPECENUM_VALUE5NAME N_("Changed")
76 #define SPECENUM_VALUE6 SSET_LOCKED
77 #define SPECENUM_VALUE6NAME N_("Locked")
78 /* keep this last */
79 #define SPECENUM_COUNT OLEVELS_NUM
80 #include "specenum_gen.h"
82 /* Server setting types. */
83 #define SPECENUM_NAME sset_type
84 #define SPECENUM_VALUE0 SSET_BOOL
85 #define SPECENUM_VALUE1 SSET_INT
86 #define SPECENUM_VALUE2 SSET_STRING
87 #define SPECENUM_VALUE3 SSET_ENUM
88 #define SPECENUM_VALUE4 SSET_BITWISE
89 #include "specenum_gen.h"
91 enum setting_default_level { SETDEF_INTERNAL, SETDEF_RULESET, SETDEF_CHANGED };
93 /* forward declaration */
94 struct setting;
96 struct setting *setting_by_number(int id);
97 struct setting *setting_by_name(const char *name);
98 int setting_number(const struct setting *pset);
100 const char *setting_name(const struct setting *pset);
101 const char *setting_short_help(const struct setting *pset);
102 const char *setting_extra_help(const struct setting *pset, bool constant);
103 enum sset_type setting_type(const struct setting *pset);
104 enum sset_level setting_level(const struct setting *pset);
105 enum sset_category setting_category(const struct setting *pset);
107 bool setting_is_changeable(const struct setting *pset,
108 struct connection *caller, char *reject_msg,
109 size_t reject_msg_len);
110 bool setting_is_visible(const struct setting *pset,
111 struct connection *caller);
113 const char *setting_value_name(const struct setting *pset, bool pretty,
114 char *buf, size_t buf_len);
115 const char *setting_default_name(const struct setting *pset, bool pretty,
116 char *buf, size_t buf_len);
118 void setting_set_to_default(struct setting *pset);
120 int read_enum_value(const struct setting *pset);
121 const char *setting_enum_secfile_str(secfile_data_t data, int val);
122 const char *setting_bitwise_secfile_str(secfile_data_t data, int bit);
124 /* Type SSET_BOOL setting functions. */
125 bool setting_bool_set(struct setting *pset, const char *val,
126 struct connection *caller, char *reject_msg,
127 size_t reject_msg_len);
128 bool setting_bool_validate(const struct setting *pset, const char *val,
129 struct connection *caller, char *reject_msg,
130 size_t reject_msg_len);
131 bool setting_bool_get(struct setting *pset);
133 /* Type SSET_INT setting functions. */
134 int setting_int_min(const struct setting *pset);
135 int setting_int_max(const struct setting *pset);
136 bool setting_int_set(struct setting *pset, int val,
137 struct connection *caller, char *reject_msg,
138 size_t reject_msg_len);
139 bool setting_int_validate(const struct setting *pset, int val,
140 struct connection *caller, char *reject_msg,
141 size_t reject_msg_len);
142 int setting_int_get(struct setting *pset);
144 /* Type SSET_STRING setting functions. */
145 bool setting_str_set(struct setting *pset, const char *val,
146 struct connection *caller, char *reject_msg,
147 size_t reject_msg_len);
148 bool setting_str_validate(const struct setting *pset, const char *val,
149 struct connection *caller, char *reject_msg,
150 size_t reject_msg_len);
151 char *setting_str_get(struct setting *pset);
153 /* Type SSET_ENUM setting functions. */
154 const char *setting_enum_val(const struct setting *pset, int val,
155 bool pretty);
156 bool setting_enum_set(struct setting *pset, const char *val,
157 struct connection *caller, char *reject_msg,
158 size_t reject_msg_len);
159 bool setting_enum_validate(const struct setting *pset, const char *val,
160 struct connection *caller, char *reject_msg,
161 size_t reject_msg_len);
163 /* Type SSET_BITWISE setting functions. */
164 const char *setting_bitwise_bit(const struct setting *pset,
165 int bit, bool pretty);
166 bool setting_bitwise_set(struct setting *pset, const char *val,
167 struct connection *caller, char *reject_msg,
168 size_t reject_msg_len);
169 bool setting_bitwise_validate(const struct setting *pset, const char *val,
170 struct connection *caller, char *reject_msg,
171 size_t reject_msg_len);
172 int setting_bitwise_get(struct setting *pset);
174 void setting_action(const struct setting *pset);
176 bool setting_non_default(const struct setting *pset);
177 bool setting_locked(const struct setting *pset);
178 void setting_lock_set(struct setting *pset, bool lock);
180 /* get 'struct setting_list' and related functions: */
181 #define SPECLIST_TAG setting
182 #define SPECLIST_TYPE struct setting
183 #include "speclist.h"
185 #define setting_list_iterate(_setting_list, _setting) \
186 TYPED_LIST_ITERATE(struct setting, _setting_list, _setting)
187 #define setting_list_iterate_end \
188 LIST_ITERATE_END
190 /* Iterate over all settings; this additionally checks if the list is
191 * created and valid. */
192 #define settings_iterate(_level, _pset) \
194 struct setting_list *_setting_list = settings_list_get(_level); \
195 if (_setting_list != NULL) { \
196 setting_list_iterate(_setting_list, _pset) {
198 #define settings_iterate_end \
199 } setting_list_iterate_end; \
203 void settings_game_start(void);
204 void settings_game_save(struct section_file *file, const char *section);
205 void settings_game_load(struct section_file *file, const char *section);
206 bool settings_game_reset(void);
208 void settings_init(bool act);
209 void settings_reset(void);
210 void settings_turn(void);
211 void settings_free(void);
212 int settings_number(void);
214 void settings_list_update(void);
215 struct setting_list *settings_list_get(enum sset_level level);
217 bool settings_ruleset(struct section_file *file, const char *section, bool act);
219 void send_server_setting(struct conn_list *dest, const struct setting *pset);
220 void send_server_settings(struct conn_list *dest);
221 void send_server_hack_level_settings(struct conn_list *dest);
222 void send_server_setting_control(struct connection *pconn);
224 void setting_changed(struct setting *pset);
225 enum setting_default_level setting_get_setdef(struct setting *pset);
226 void settings_consider_all_changed(void);
228 #ifdef __cplusplus
230 #endif /* __cplusplus */
232 #endif /* FC__SETTINGS_H */