Freeciv-3.3: /fast/freeciv/nightly/main/server/settings.h Source File

Freeciv-3.3

Loading...
Searching...
No Matches
settings.h
Go to the documentation of this file.
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.
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
14#ifndef FC__SETTINGS_H
15#define FC__SETTINGS_H
16
17#ifdef __cplusplus
18extern "C" {
19#endif /* __cplusplus */
20
21/* utility */
22#include "shared.h"
23
24/* common */
25#include "game.h"
26#include "server_settings.h"
27
28 struct sset_val_name {
29 const char *support; /* Untranslated long support name, used
30 * for saving. */
31 const char *pretty; /* Translated, used to display to the
32 * users. */
33};
34
35/* Categories allow options to be usefully organized when presented to the
36 * user */
37#define SPECENUM_NAME sset_category
38#define SPECENUM_VALUE0 SSET_GEOLOGY
39#define SPECENUM_VALUE0NAME N_("Geological")
40#define SPECENUM_VALUE1 SSET_SOCIOLOGY
41#define SPECENUM_VALUE1NAME N_("Sociological")
42#define SPECENUM_VALUE2 SSET_ECONOMICS
43#define SPECENUM_VALUE2NAME N_("Economic")
44#define SPECENUM_VALUE3 SSET_MILITARY
45#define SPECENUM_VALUE3NAME N_("Military")
46#define SPECENUM_VALUE4 SSET_SCIENCE
47#define SPECENUM_VALUE4NAME N_("Scientific")
48#define SPECENUM_VALUE5 SSET_INTERNAL
49#define SPECENUM_VALUE5NAME N_("Internal")
50#define SPECENUM_VALUE6 SSET_NETWORK
51#define SPECENUM_VALUE6NAME N_("Networking")
52/* keep this last */
53#define SPECENUM_COUNT SSET_NUM_CATEGORIES
54#include "specenum_gen.h"
55
56/* Levels allow options to be subdivided and thus easier to navigate */
57#define SPECENUM_NAME sset_level
58#define SPECENUM_VALUE0 SSET_NONE
59#define SPECENUM_VALUE0NAME N_("?ssetlevel:None")
60#define SPECENUM_VALUE1 SSET_ALL
61#define SPECENUM_VALUE1NAME N_("All")
62#define SPECENUM_VALUE2 SSET_VITAL
63#define SPECENUM_VALUE2NAME N_("Vital")
64#define SPECENUM_VALUE3 SSET_SITUATIONAL
65#define SPECENUM_VALUE3NAME N_("Situational")
66#define SPECENUM_VALUE4 SSET_RARE
67#define SPECENUM_VALUE4NAME N_("Rare")
68#define SPECENUM_VALUE5 SSET_CHANGED
69#define SPECENUM_VALUE5NAME N_("Changed")
70#define SPECENUM_VALUE6 SSET_LOCKED
71#define SPECENUM_VALUE6NAME N_("Locked")
72/* keep this last */
73#define SPECENUM_COUNT OLEVELS_NUM
74#include "specenum_gen.h"
75
76 enum setting_lock_level { SLOCK_NONE = 0, SLOCK_RULESET, SLOCK_ADMIN };
77
78/* Forward declaration */
79struct setting;
80
81 struct sf_cb_data {
82 struct setting *set;
83 bool compat;
84};
85
86struct setting *setting_by_number(int id);
87struct setting *setting_by_name(const char *name);
88int setting_number(const struct setting *pset);
89
90const char *setting_name(const struct setting *pset);
91const char *setting_short_help(const struct setting *pset);
92const char *setting_extra_help(const struct setting *pset, bool constant);
93enum sset_type setting_type(const struct setting *pset);
94enum sset_level setting_level(const struct setting *pset);
95enum sset_category setting_category(const struct setting *pset);
96
97bool setting_is_changeable(const struct setting *pset,
98 struct connection *caller, char *reject_msg,
99 size_t reject_msg_len);
100bool setting_is_visible_at_level(const struct setting *pset,
101 enum cmdlevel plevel);
102bool setting_is_visible(const struct setting *pset,
103 struct connection *caller);
104
105const char *setting_value_name(const struct setting *pset, bool pretty,
106 char *buf, size_t buf_len);
107const char *setting_default_name(const struct setting *pset, bool pretty,
108 char *buf, size_t buf_len);
109
110void setting_set_to_default(struct setting *pset);
111
112int read_enum_value(const struct setting *pset);
113const char *setting_enum_secfile_str(secfile_data_t data, int val);
114const char *setting_bitwise_secfile_str(secfile_data_t data, int bit);
115
116/* Type SST_BOOL setting functions. */
117bool setting_bool_set(struct setting *pset, const char *val,
118 struct connection *caller, char *reject_msg,
119 size_t reject_msg_len);
120bool setting_bool_validate(const struct setting *pset, const char *val,
121 struct connection *caller, char *reject_msg,
122 size_t reject_msg_len);
123bool setting_bool_get(struct setting *pset);
124
125/* Type SST_INT setting functions. */
126int setting_int_min(const struct setting *pset);
127int setting_int_max(const struct setting *pset);
128bool setting_int_set(struct setting *pset, int val,
129 struct connection *caller, char *reject_msg,
130 size_t reject_msg_len);
131bool setting_int_validate(const struct setting *pset, int val,
132 struct connection *caller, char *reject_msg,
133 size_t reject_msg_len);
134int setting_int_get(struct setting *pset);
135
136/* Type SST_STRING setting functions. */
137bool setting_str_set(struct setting *pset, const char *val,
138 struct connection *caller, char *reject_msg,
139 size_t reject_msg_len);
140bool setting_str_validate(const struct setting *pset, const char *val,
141 struct connection *caller, char *reject_msg,
142 size_t reject_msg_len);
143char *setting_str_get(struct setting *pset);
144
145/* Type SST_ENUM setting functions. */
146const char *setting_enum_val(const struct setting *pset, int val,
147 bool pretty);
148bool setting_enum_set(struct setting *pset, const char *val,
149 struct connection *caller, char *reject_msg,
150 size_t reject_msg_len);
151bool setting_enum_validate(const struct setting *pset, const char *val,
152 struct connection *caller, char *reject_msg,
153 size_t reject_msg_len);
154
155/* Type SST_BITWISE setting functions. */
156const char *setting_bitwise_bit(const struct setting *pset,
157 int bit, bool pretty);
158bool setting_bitwise_set(struct setting *pset, const char *val,
159 struct connection *caller, char *reject_msg,
160 size_t reject_msg_len);
161bool setting_bitwise_validate(const struct setting *pset, const char *val,
162 struct connection *caller, char *reject_msg,
163 size_t reject_msg_len);
164int setting_bitwise_get(struct setting *pset);
165
166void setting_action(const struct setting *pset);
167
168bool setting_non_default(const struct setting *pset);
169bool setting_locked(const struct setting *pset);
170bool setting_ruleset_locked(const struct setting *pset);
171void setting_ruleset_lock_set(struct setting *pset);
172void setting_admin_lock_set(struct setting *pset);
173void setting_ruleset_lock_clear(struct setting *pset);
174void setting_admin_lock_clear(struct setting *pset);
175
176/* get 'struct setting_list' and related functions: */
177#define SPECLIST_TAG setting
178#define SPECLIST_TYPE struct setting
179#include "speclist.h"
180
181#define setting_list_iterate(_setting_list, _setting) \
182 TYPED_LIST_ITERATE(struct setting, _setting_list, _setting)
183#define setting_list_iterate_end \
184 LIST_ITERATE_END
185
186/* Iterate over all settings; this additionally checks if the list is
187 * created and valid. */
188#define settings_iterate(_level, _pset) \
189{ \
190 struct setting_list *_setting_list = settings_list_get(_level); \
191 if (_setting_list != NULL) { \
192 setting_list_iterate(_setting_list, _pset) {
193
194#define settings_iterate_end \
195 } setting_list_iterate_end; \
196 } \
197}
198
199void settings_game_start(void);
200void settings_game_save(struct section_file *file, const char *section);
201void settings_game_load(struct section_file *file, const char *section);
202bool settings_game_reset(void);
203
204void settings_init(bool act);
205void settings_reset(void);
206void settings_turn(void);
207void settings_free(void);
208int settings_number(void);
209
210void settings_list_update(void);
211struct setting_list *settings_list_get(enum sset_level level);
212
213bool settings_ruleset(struct section_file *file, const char *section,
214 bool act, bool compat);
215
216void send_server_setting(struct conn_list *dest, const struct setting *pset);
217void send_server_settings(struct conn_list *dest);
218void send_server_access_level_settings(struct conn_list *dest,
219 enum cmdlevel old_level,
220 enum cmdlevel new_level);
221void send_server_setting_control(struct connection *pconn);
222
223void setting_changed(struct setting *pset);
224enum setting_default_level setting_get_setdef(const struct setting *pset);
225
226#ifdef __cplusplus
227}
228#endif /* __cplusplus */
229
230#endif /* FC__SETTINGS_H */
incite_cost
char * incite_cost
Definition comments.c:74
game.h
name
const char * name
Definition inputfile.c:127
secfile_data_t
const void * secfile_data_t
Definition registry_ini.h:30
compat
static struct compatibility compat[]
Definition savecompat.c:112
server_settings.h
level
struct setting_list * level[OLEVELS_NUM]
Definition settings.c:190
setting_ruleset_locked
bool setting_ruleset_locked(const struct setting *pset)
Definition settings.c:4641
setting_int_validate
bool setting_int_validate(const struct setting *pset, int val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:3756
settings_init
void settings_init(bool act)
Definition settings.c:5205
setting_action
void setting_action(const struct setting *pset)
Definition settings.c:4362
setting_ruleset_lock_clear
void setting_ruleset_lock_clear(struct setting *pset)
Definition settings.c:4669
setting_admin_lock_clear
void setting_admin_lock_clear(struct setting *pset)
Definition settings.c:4681
setting_int_get
int setting_int_get(struct setting *pset)
Definition settings.c:3781
setting_default_name
const char * setting_default_name(const struct setting *pset, bool pretty, char *buf, size_t buf_len)
Definition settings.c:4296
setting_enum_validate
bool setting_enum_validate(const struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:4044
setting_by_name
struct setting * setting_by_name(const char *name)
Definition settings.c:3302
setting_set_to_default
void setting_set_to_default(struct setting *pset)
Definition settings.c:4332
setting_value_name
const char * setting_value_name(const struct setting *pset, bool pretty, char *buf, size_t buf_len)
Definition settings.c:4260
settings_game_load
void settings_game_load(struct section_file *file, const char *section)
Definition settings.c:4906
setting_extra_help
const char * setting_extra_help(const struct setting *pset, bool constant)
Definition settings.c:3343
setting_number
int setting_number(const struct setting *pset)
Definition settings.c:3317
setting_by_number
struct setting * setting_by_number(int id)
Definition settings.c:3294
setting_int_set
bool setting_int_set(struct setting *pset, int val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:3736
setting_category
enum sset_category setting_category(const struct setting *pset)
Definition settings.c:3371
setting_is_visible
bool setting_is_visible(const struct setting *pset, struct connection *caller)
Definition settings.c:3499
setting_locked
bool setting_locked(const struct setting *pset)
Definition settings.c:4633
setting_non_default
bool setting_non_default(const struct setting *pset)
Definition settings.c:4607
setting_type
enum sset_type setting_type(const struct setting *pset)
Definition settings.c:3355
settings_free
void settings_free(void)
Definition settings.c:5247
setting_admin_lock_set
void setting_admin_lock_set(struct setting *pset)
Definition settings.c:4661
setting_str_set
bool setting_str_set(struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:3807
setting_int_max
int setting_int_max(const struct setting *pset)
Definition settings.c:3726
setting_level
enum sset_level setting_level(const struct setting *pset)
Definition settings.c:3363
setting_bitwise_set
bool setting_bitwise_set(struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:4216
setting_enum_secfile_str
const char * setting_enum_secfile_str(secfile_data_t data, int val)
Definition settings.c:3863
settings_game_save
void settings_game_save(struct section_file *file, const char *section)
Definition settings.c:4818
settings_number
int settings_number(void)
Definition settings.c:5259
setting_str_validate
bool setting_str_validate(const struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:3827
settings_turn
void settings_turn(void)
Definition settings.c:5239
setting_enum_val
const char * setting_enum_val(const struct setting *pset, int val, bool pretty)
Definition settings.c:3886
setting_changed
void setting_changed(struct setting *pset)
Definition settings.c:5597
setting_get_setdef
enum setting_default_level setting_get_setdef(const struct setting *pset)
Definition settings.c:5605
settings_game_start
void settings_game_start(void)
Definition settings.c:4805
setting_enum_set
bool setting_enum_set(struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:4015
setting_short_help
const char * setting_short_help(const struct setting *pset)
Definition settings.c:3334
send_server_setting_control
void send_server_setting_control(struct connection *pconn)
Definition settings.c:5431
setting_bitwise_bit
const char * setting_bitwise_bit(const struct setting *pset, int bit, bool pretty)
Definition settings.c:4081
setting_int_min
int setting_int_min(const struct setting *pset)
Definition settings.c:3717
setting_bitwise_validate
bool setting_bitwise_validate(const struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:4237
setting_ruleset_lock_set
void setting_ruleset_lock_set(struct setting *pset)
Definition settings.c:4649
setting_bool_validate
bool setting_bool_validate(const struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:3681
settings_list_get
struct setting_list * settings_list_get(enum sset_level level)
Definition settings.c:5568
setting_is_changeable
bool setting_is_changeable(const struct setting *pset, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:3453
settings_reset
void settings_reset(void)
Definition settings.c:5225
setting_name
const char * setting_name(const struct setting *pset)
Definition settings.c:3326
settings_game_reset
bool settings_game_reset(void)
Definition settings.c:5188
setting_bitwise_get
int setting_bitwise_get(struct setting *pset)
Definition settings.c:4250
settings_list_update
void settings_list_update(void)
Definition settings.c:5526
setting_str_get
char * setting_str_get(struct setting *pset)
Definition settings.c:3852
settings_ruleset
bool settings_ruleset(struct section_file *file, const char *section, bool act, bool compat)
Definition settings.c:4372
setting_bool_get
bool setting_bool_get(struct setting *pset)
Definition settings.c:3669
setting_bitwise_secfile_str
const char * setting_bitwise_secfile_str(secfile_data_t data, int bit)
Definition settings.c:4058
setting_is_visible_at_level
bool setting_is_visible_at_level(const struct setting *pset, enum cmdlevel plevel)
Definition settings.c:3489
setting_bool_set
bool setting_bool_set(struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:3650
send_server_setting
void send_server_setting(struct conn_list *dest, const struct setting *pset)
Definition settings.c:5268
send_server_settings
void send_server_settings(struct conn_list *dest)
Definition settings.c:5387
send_server_access_level_settings
void send_server_access_level_settings(struct conn_list *dest, enum cmdlevel old_level, enum cmdlevel new_level)
Definition settings.c:5399
read_enum_value
int read_enum_value(const struct setting *pset)
Definition settings.c:3988
setting_lock_level
setting_lock_level
Definition settings.h:76
SLOCK_RULESET
@ SLOCK_RULESET
Definition settings.h:76
SLOCK_ADMIN
@ SLOCK_ADMIN
Definition settings.h:76
SLOCK_NONE
@ SLOCK_NONE
Definition settings.h:76
shared.h
specenum_gen.h
speclist.h
connection
Definition connection.h:136
section_file
Definition section_file.h:36
section
Definition section_file.h:28
setting
Definition settings.c:92
sf_cb_data
Definition settings.h:81
sf_cb_data::set
struct setting * set
Definition settings.h:82
sf_cb_data::compat
bool compat
Definition settings.h:83
sset_val_name
Definition settings.h:28
sset_val_name::support
const char * support
Definition settings.h:29
sset_val_name::pretty
const char * pretty
Definition settings.h:31