Freeciv-3.3
Loading...
Searching...
No Matches
server_settings.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2017 - Freeciv Development Team
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#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* utility */
19#include "astring.h"
20
21/* common */
22#include "fc_interface.h"
23
24#include "server_settings.h"
25
26/***********************************************************************/
36
37/***********************************************************************/
47
48/***********************************************************************/
58
59/***********************************************************************/
66
67/***********************************************************************/
78
79/***********************************************************************/
90
91/***********************************************************************/
102
103/***********************************************************************/
107{
108 /* Only Boolean and TRUE can be supported unless setting value encoding
109 * is implemented. */
110 if (!value) {
111 fc_assert(value);
112 return SSETV_NONE;
113 }
114
115 /* Only Boolean settings can be supported unless the setting value is
116 * encoded with the setting id. */
119 == SST_BOOL);
120 return SSETV_NONE;
121 }
122
123 return (ssetv)setting;
124}
125
126/***********************************************************************/
130{
131 /* Only Boolean settings can be supported unless the setting value is
132 * encoded with the setting id. */
134
135 return (server_setting_id)enc;
136}
137
138/***********************************************************************/
142{
143 /* Only Boolean settings can be supported unless the setting value is
144 * encoded with the setting id. */
146
147 return TRUE;
148}
149
150/***********************************************************************/
154{
156
157 /* Only Boolean settings can be supported unless the setting value is
158 * encoded with the setting id. */
160 return SSETV_NONE;
161 }
162
163 return val;
164}
165
166/***********************************************************************/
169const char *ssetv_rule_name(ssetv val)
170{
171 /* Only Boolean settings can be supported unless the setting value is
172 * encoded with the setting id. */
174
176}
177
178/***********************************************************************/
181const char *ssetv_human_readable(ssetv val, bool present)
182{
183 static struct astring out = ASTRING_INIT;
184
185 /* Only Boolean settings can be supported unless the setting value is
186 * encoded with the setting id. */
188
189 /* TRANS: the first %s is a server setting, the second %s is it's value.
190 * Example: killstack is enabled */
191 astr_set(&out, _("%s is %s"),
193 present ? _("enabled") : _("disabled"));
194
195 return astr_str(&out);
196}
197
198/***********************************************************************/
202{
203 /* Only boolean settings can be supported unless the setting value is
204 * encoded with the setting id. */
207
209}
void astr_set(struct astring *astr, const char *format,...)
Definition astring.c:251
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
Definition astring.h:93
#define ASTRING_INIT
Definition astring.h:44
char * incite_cost
Definition comments.c:76
const struct functions * fc_funcs
int server_setting_id
Definition fc_types.h:778
int ssetv
Definition fc_types.h:525
#define _(String)
Definition fcintl.h:67
const char * name
Definition inputfile.c:127
#define fc_assert(condition)
Definition log.h:177
#define fc_assert_ret_val(condition, val)
Definition log.h:195
const char * server_setting_name_get(server_setting_id id)
server_setting_id server_setting_by_name(const char *name)
bool server_setting_value_bool_get(server_setting_id id)
enum sset_type server_setting_type_get(server_setting_id id)
server_setting_id ssetv_setting_get(ssetv enc)
bool server_setting_exists(server_setting_id id)
bool ssetv_setting_has_value(ssetv val)
int ssetv_value_get(ssetv enc)
ssetv ssetv_by_rule_name(const char *name)
const char * ssetv_rule_name(ssetv val)
ssetv ssetv_from_values(server_setting_id setting, int value)
unsigned int server_setting_value_bitwise_get(server_setting_id id)
const char * ssetv_human_readable(ssetv val, bool present)
int server_setting_value_int_get(server_setting_id id)
#define SERVER_SETTING_NONE
#define SSETV_NONE
int(* server_setting_val_int_get)(server_setting_id id)
bool(* server_setting_val_bool_get)(server_setting_id id)
server_setting_id(* server_setting_by_name)(const char *name)
unsigned int(* server_setting_val_bitwise_get)(server_setting_id id)
enum sset_type(* server_setting_type_get)(server_setting_id id)
const char *(* server_setting_name_get)(server_setting_id id)
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47