Freeciv-3.2
Loading...
Searching...
No Matches
manual_settings.c
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
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* utility */
19#include "fcintl.h"
20
21/* server */
22#include "settings.h"
23
24/* tools/manual */
25#include "fc_manual.h"
26
27/**********************************************************************/
34{
35 FILE *doc;
37 int i;
38
40
41 if (doc == NULL) {
42 return FALSE;
43 }
44
45 /* Default client access. */
47 dummy_conn.access_level = ALLOW_CTRL;
48
49 /* TRANS: markup ... Freeciv version ... markup */
50 fprintf(doc, _("%sFreeciv %s server settings%s\n\n"), tag_info->title_begin,
51 VERSION_STRING, tag_info->title_end);
53 char buf[256];
54 const char *sethelp;
55
56 fprintf(doc, tag_info->item_begin, "setting", setting_number(pset));
57 fprintf(doc, "%s%s - %s%s\n\n", tag_info->sect_title_begin,
59 tag_info->sect_title_end);
61 if (strlen(sethelp) > 0) {
62 char *help = fc_strdup(sethelp);
63 size_t help_len = strlen(help) + 1;
64
66 help = html_special_chars(help, &help_len);
67 fprintf(doc, "<pre>%s</pre>\n\n", help);
68 FC_FREE(help);
69 }
70 fprintf(doc, "<p class=\"misc\">");
71 fprintf(doc, _("Level: %s.<br>"),
73 fprintf(doc, _("Category: %s.<br>"),
75
76 /* First check if the setting is locked because this is included in
77 * the function setting_is_changeable() */
79 fprintf(doc, _("Is locked by the ruleset."));
80 } else if (!setting_is_changeable(pset, &dummy_conn, NULL, 0)) {
81 fprintf(doc, _("Can only be used in server console."));
82 }
83
84 fprintf(doc, "</p>\n");
86 switch (setting_type(pset)) {
87 case SST_INT:
88 fprintf(doc, "\n<p class=\"bounds\">%s %d, %s %s, %s %d</p>\n",
89 _("Minimum:"), setting_int_min(pset),
90 _("Default:"), buf,
91 _("Maximum:"), setting_int_max(pset));
92 break;
93 case SST_ENUM:
94 {
95 const char *value;
96
97 fprintf(doc, "\n<p class=\"bounds\">%s</p><ul>",
98 _("Possible values:"));
99 for (i = 0; (value = setting_enum_val(pset, i, FALSE)); i++) {
100 fprintf(doc, "\n<li><p class=\"bounds\"> %s: \"%s\"</p>",
101 value, setting_enum_val(pset, i, TRUE));
102 }
103 fprintf(doc, "</ul>\n");
104 }
105 break;
106 case SST_BITWISE:
107 {
108 const char *value;
109
110 fprintf(doc, "\n<p class=\"bounds\">%s</p><ul>",
111 _("Possible values (option can take any number of these):"));
112 for (i = 0; (value = setting_bitwise_bit(pset, i, FALSE)); i++) {
113 fprintf(doc, "\n<li><p class=\"bounds\"> %s: \"%s\"</p>",
114 value, setting_bitwise_bit(pset, i, TRUE));
115 }
116 fprintf(doc, "</ul>\n");
117 }
118 break;
119 case SST_BOOL:
120 case SST_STRING:
121 break;
122 case SST_COUNT:
124 break;
125 }
126 if (SST_INT != setting_type(pset)) {
127 fprintf(doc, "\n<p class=\"bounds\">%s %s</p>\n",
128 _("Default:"), buf);
129 }
131 fprintf(doc, _("\n<p class=\"changed\">Value set to %s</p>\n"),
132 setting_value_name(pset, TRUE, buf, sizeof(buf)));
133 }
134
135 fprintf(doc, "%s", tag_info->item_end);
137
139
140 return TRUE;
141}
char * incite_cost
Definition comments.c:75
void connection_common_init(struct connection *pconn)
Definition connection.c:603
void manual_finalize(struct tag_types *tag_info, FILE *doc, enum manuals manual)
Definition fc_manual.c:320
char * html_special_chars(char *str, size_t *len)
Definition fc_manual.c:168
FILE * manual_start(struct tag_types *tag_info, int manual_number)
Definition fc_manual.c:291
#define LINE_BREAK
Definition fc_types.h:77
#define _(String)
Definition fcintl.h:67
#define fc_assert(condition)
Definition log.h:176
bool manual_settings(struct tag_types *tag_info)
#define FC_FREE(ptr)
Definition mem.h:41
#define fc_strdup(str)
Definition mem.h:43
bool setting_ruleset_locked(const struct setting *pset)
Definition settings.c:4681
const char * setting_default_name(const struct setting *pset, bool pretty, char *buf, size_t buf_len)
Definition settings.c:4300
const char * setting_value_name(const struct setting *pset, bool pretty, char *buf, size_t buf_len)
Definition settings.c:4264
const char * setting_extra_help(const struct setting *pset, bool constant)
Definition settings.c:3347
int setting_number(const struct setting *pset)
Definition settings.c:3321
enum sset_category setting_category(const struct setting *pset)
Definition settings.c:3375
bool setting_non_default(const struct setting *pset)
Definition settings.c:4647
enum sset_type setting_type(const struct setting *pset)
Definition settings.c:3359
int setting_int_max(const struct setting *pset)
Definition settings.c:3730
enum sset_level setting_level(const struct setting *pset)
Definition settings.c:3367
const char * setting_enum_val(const struct setting *pset, int val, bool pretty)
Definition settings.c:3890
const char * setting_short_help(const struct setting *pset)
Definition settings.c:3338
const char * setting_bitwise_bit(const struct setting *pset, int bit, bool pretty)
Definition settings.c:4085
int setting_int_min(const struct setting *pset)
Definition settings.c:3721
bool setting_is_changeable(const struct setting *pset, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:3457
const char * setting_name(const struct setting *pset)
Definition settings.c:3330
#define settings_iterate(_level, _pset)
Definition settings.h:188
#define settings_iterate_end
Definition settings.h:194
int fc_break_lines(char *str, size_t desired_len)
Definition support.c:1149
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47