~ubuntu-branches/debian/squeeze/freeciv/squeeze

« back to all changes in this revision

Viewing changes to manual/civmanual.c

  • Committer: Bazaar Package Importer
  • Author(s): Clint Adams, Karl Goetz, Clint Adams
  • Date: 2010-02-23 22:09:02 UTC
  • mfrom: (1.2.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20100223220902-kiyrmr9i4152cka5
Tags: 2.2.0-1
[ Karl Goetz ]
* Remove civserver files in /etc/ggzd/ (Closes: 523772, 517787)
* Adding ${misc:Depends} to all binary packages (lintian warnings)

[ Clint Adams ]
* New upstream version.
  - Drop data_dsc_use_bindir.diff (binary pathnames have changed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include <stdlib.h>
22
22
#include <string.h>
23
23
 
24
 
#include "astring.h"
 
24
/* utility */
 
25
#include "capability.h"
25
26
#include "fciconv.h"
26
27
#include "fcintl.h"
27
28
#include "log.h"
30
31
#include "shared.h"
31
32
#include "support.h"
32
33
 
33
 
#include "capability.h"
 
34
/* common */
 
35
#include "connection.h"
34
36
#include "events.h"
35
37
#include "game.h"
36
38
#include "improvement.h"
38
40
#include "player.h"
39
41
#include "version.h"
40
42
 
 
43
/* client */
41
44
#include "helpdata.h"
42
45
#include "helpdlg_g.h"
43
46
 
 
47
/* server */
44
48
#include "citytools.h"
 
49
#include "commands.h"
45
50
#include "connecthand.h"
46
51
#include "console.h"
47
52
#include "diplhand.h"
50
55
#include "report.h"
51
56
#include "ruleset.h"
52
57
#include "savegame.h"
 
58
#include "settings.h"
53
59
#include "srv_main.h"
54
 
 
55
60
#include "stdinhand.h"
56
 
#include "commands.h"
57
 
#include "settings.h"
58
61
 
59
62
enum manuals {
60
63
  MANUAL_SETTINGS,
107
110
  FILE *doc;
108
111
  char filename[40];
109
112
  enum manuals manuals;
110
 
 
111
 
  game_init();
 
113
  struct connection my_conn;
 
114
 
 
115
  /* Default client access. */
 
116
  connection_common_init(&my_conn);
 
117
  my_conn.access_level = ALLOW_CTRL;
 
118
 
 
119
  /* Reset aifill to zero */
 
120
  game.info.aifill = 0;
112
121
  load_rulesets();
113
122
  for (manuals = 0; manuals < MANUAL_COUNT; manuals++) {
114
123
    int i;
126
135
    switch (manuals) {
127
136
    case MANUAL_SETTINGS:
128
137
      fprintf(doc, _("<h1>Freeciv %s server options</h1>\n\n"), VERSION_STRING);
129
 
      for (i = 0; settings[i].name; i++) {
130
 
        struct settings_s *op = &settings[i];
131
 
        static struct astring abuf = ASTRING_INIT;
132
 
        const char *help = _(op->extra_help);
 
138
      settings_iterate(pset) {
 
139
        const char *help = _(setting_extra_help(pset));
133
140
 
134
 
        astr_minsize(&abuf, strlen(help) + 10);
135
 
        strcpy(abuf.str, help);
136
 
        wordwrap_string(abuf.str, 76);
137
141
        fprintf(doc, SEPARATOR);
138
 
        fprintf(doc, "%s%s - %s%s\n\n", SECTION_BEGIN, op->name,
139
 
                _(op->short_help), SECTION_END);
140
 
        if (strlen(op->extra_help) > 0) {
141
 
          fprintf(doc, "<pre>%s</pre>\n\n", abuf.str);
 
142
        fprintf(doc, "%s%s - %s%s\n\n", SECTION_BEGIN, setting_name(pset),
 
143
                _(setting_short_help(pset)), SECTION_END);
 
144
        if (strlen(setting_extra_help(pset)) > 0) {
 
145
          fprintf(doc, "<pre>%s</pre>\n\n", help);
142
146
        }
143
147
        fprintf(doc, "<p class=\"misc\">");
144
 
        fprintf(doc, _("Level: %s.<br>"), _(sset_level_names[op->slevel]));
145
 
        fprintf(doc, _("Category: %s.<br>"),
146
 
                _(sset_category_names[op->scategory]));
147
 
        if (op->to_client == SSET_SERVER_ONLY) {
 
148
        fprintf(doc, _("Level: %s.<br>"), _(setting_level_name(pset)));
 
149
        fprintf(doc, _("Category: %s.<br>"), _(setting_category_name(pset)));
 
150
        
 
151
        if (!setting_is_changeable(pset, &my_conn, NULL)) {
148
152
          fprintf(doc, _("Can only be used in server console. "));
149
153
        }
150
 
        if (setting_is_changeable(i)) {
151
 
          fprintf(doc, _("Can be changed during a game. "));
152
 
        } else {
153
 
          fprintf(doc, _("Can <b>not</b> be changed during a game. "));
154
 
        }
155
154
        fprintf(doc, "</p>\n\n");
156
 
        switch (op->stype) {
 
155
        switch (setting_type(pset)) {
157
156
        case SSET_BOOL:
158
 
          fprintf(doc, _("<p class=\"bounds\">Minimum: 0, Default: %d, "
159
 
                         "Maximum: 1</p>\n\n"),
160
 
                  op->bool_default_value ? 1 : 0);
161
 
          if (*(op->bool_value) != op->bool_default_value) {
 
157
          fprintf(doc, "<p class=\"bounds\">%s 0, %s %d, %s 1</p>\n\n",
 
158
                  _("Minimum:"), _("Default:"),
 
159
                  setting_bool_def(pset) ? 1 : 0, _("Maximum:"));
 
160
          if (setting_bool_get(pset) != setting_bool_def(pset)) {
162
161
            fprintf(doc, _("<p class=\"changed\">Value set to %d</p>\n\n"),
163
 
                    *(op->bool_value));
 
162
                    setting_bool_get(pset) ? 1 : 0);
164
163
          }
165
164
          break;
166
165
        case SSET_INT:
167
 
          fprintf(doc, _("<p class=\"bounds\">Minimum: %d, Default: %d, "
168
 
                         "Maximum: %d</p>\n\n"),
169
 
                  op->int_min_value, op->int_default_value,
170
 
                  op->int_max_value);
171
 
          if (*(op->int_value) != op->int_default_value) {
 
166
          fprintf(doc, "<p class=\"bounds\">%s %d, %s %d, %s %d</p>\n\n",
 
167
                  _("Minimum:"), setting_int_min(pset),
 
168
                  _("Default:"), setting_int_def(pset),
 
169
                  _("Maximum:"), setting_int_max(pset));
 
170
          if (setting_int_get(pset) != setting_int_def(pset)) {
172
171
            fprintf(doc, _("<p class=\"changed\">Value set to %d</p>\n\n"),
173
 
                    *(op->int_value));
 
172
                    setting_int_get(pset));
174
173
          }
175
174
          break;
176
175
        case SSET_STRING:
177
 
          fprintf(doc, _("<p class=\"bounds\">Default: \"%s\"</p>\n\n"),
178
 
                  op->string_default_value);
179
 
          if (strcmp(op->string_value, op->string_default_value) != 0) {
 
176
          fprintf(doc, "<p class=\"bounds\">%s \"%s\"</p>\n\n",
 
177
                  _("Default:"), setting_str_def(pset));
 
178
          if (strcmp(setting_str_get(pset), setting_str_def(pset)) != 0) {
180
179
            fprintf(doc, _("<p class=\"changed\">Value set to %s</p>\n\n"),
181
 
                    op->string_value);
 
180
                    setting_str_get(pset));
182
181
          }
183
182
          break;
184
183
        }
185
 
      }
 
184
      } settings_iterate_end;
186
185
      break;
187
186
 
188
187
    case MANUAL_COMMANDS:
189
188
      fprintf(doc, _("<h1>Freeciv %s server commands</h1>\n\n"),
190
189
              VERSION_STRING);
191
190
      for (i = 0; i < CMD_NUM; i++) {
192
 
        const struct command *cmd = &commands[i];
 
191
        const struct command *cmd = command_by_number(i);
193
192
 
194
193
        fprintf(doc, SEPARATOR);
195
 
        fprintf(doc, "%s%s  -  %s%s\n\n", SECTION_BEGIN, cmd->name,
196
 
                _(cmd->short_help), SECTION_END);
197
 
        if (cmd->synopsis) {
 
194
        fprintf(doc, "%s%s  -  %s%s\n\n", SECTION_BEGIN, command_name(cmd),
 
195
                command_short_help(cmd), SECTION_END);
 
196
        if (command_synopsis(cmd)) {
198
197
          fprintf(doc, _("<table>\n<tr>\n<td valign=\"top\">"
199
198
                         "<pre>Synopsis:</pre></td>\n<td>"));
200
 
          fprintf(doc, "<pre>%s</pre></td></tr></table>", _(cmd->synopsis));
 
199
          fprintf(doc, "<pre>%s</pre></td></tr></table>", command_synopsis(cmd));
201
200
        }
202
201
        fprintf(doc, _("<p class=\"level\">Level: %s</p>\n\n"),
203
 
                cmdlevel_name(cmd->level));
204
 
        if (cmd->extra_help) {
205
 
          static struct astring abuf = ASTRING_INIT;
206
 
          const char *help = _(cmd->extra_help);
207
 
 
208
 
          astr_minsize(&abuf, strlen(help)+1);
209
 
          strcpy(abuf.str, help);
210
 
          wordwrap_string(abuf.str, 76);
 
202
                cmdlevel_name(command_level(cmd)));
 
203
        if (command_extra_help(cmd)) {
211
204
          fprintf(doc, _("<p>Description:</p>\n\n"));
212
 
          fprintf(doc, "<pre>%s</pre>\n\n", abuf.str);
 
205
          fprintf(doc, "<pre>%s</pre>\n\n", command_extra_help(cmd));
213
206
        }
214
207
      }
215
208
      break;
222
215
      fprintf(doc, "<th>%s<br/>%s</th>", _("Move cost"), _("Defense bonus"));
223
216
      fprintf(doc, "<th>%s<br/>%s<br/>%s<br/>%s<br/>(%s)</th>",
224
217
              _("Irrigation"), _("Mining"), _("Road"), _("Transform"), _("turns"));
225
 
      fprintf(doc, "<th>%s<br/>%s<br/>%s<br/>%s<br/>%s</th></tr>\n\n",
226
 
              _("Airbase"), _("Fortress"), _("Rail"),
 
218
      fprintf(doc, "<th>%s<br/>%s<br/>%s</th></tr>\n\n",
 
219
              _("Rail"),
227
220
              _("Clean pollution"), _("Clean fallout"));
228
221
      terrain_type_iterate(pterrain) {
229
222
        struct resource **r;
277
270
        }
278
271
        fprintf(doc, "<tr><td>+%d T</td><td align=\"right\">(%d)</td></tr>\n",
279
272
                pterrain->road_trade_incr, pterrain->road_time);
280
 
        fprintf(doc, "<tr><td>%s</td><td align=\"right\">(%d)</td></tr>\n</table></td>\n",
281
 
                terrain_name_translation(pterrain->transform_result),
282
 
                pterrain->transform_time);
283
 
 
284
 
        fprintf(doc, "<td align=\"center\">%d / %d / %d / %d / %d</td></tr>\n\n",
285
 
                pterrain->airbase_time, pterrain->fortress_time, pterrain->rail_time,
 
273
 
 
274
        if (pterrain->transform_result) {
 
275
          fprintf(doc, "<tr><td>%s</td><td align=\"right\">(%d)</td></tr>\n</table></td>\n",
 
276
                  terrain_name_translation(pterrain->transform_result),
 
277
                  pterrain->transform_time);
 
278
        } else {
 
279
          fprintf(doc, "<tr><td>-</td><td align=\"right\">(-)</td></tr>\n</table></td>\n");
 
280
        }
 
281
 
 
282
        fprintf(doc, "<td align=\"center\">%d / %d / %d</td></tr>\n\n",
 
283
                pterrain->rail_time,
286
284
                pterrain->clean_pollution_time, pterrain->clean_fallout_time);
287
285
      } terrain_type_iterate_end;
288
286
      fprintf(doc, "</table>\n");
302
300
              _("Name"), _("Cost"), _("Upkeep"),
303
301
              _("Requirement"), _("Obsolete by"), _("More info"));
304
302
 
305
 
      impr_type_iterate(id) {
306
 
        struct impr_type *pimpr = improvement_by_number(id);
 
303
      improvement_iterate(pimprove) {
307
304
        char buf[64000];
308
305
 
309
 
        if (is_great_wonder(id) == (manuals == MANUAL_BUILDINGS)) {
 
306
        if (!valid_improvement(pimprove)
 
307
         || is_great_wonder(pimprove) == (manuals == MANUAL_BUILDINGS)) {
310
308
          continue;
311
309
        }
312
310
 
313
 
        helptext_building(buf, sizeof(buf), id, NULL);
 
311
        helptext_building(buf, sizeof(buf), NULL, NULL, pimprove);
314
312
 
315
313
        fprintf(doc, "<tr><td>" IMAGE_BEGIN "%s" IMAGE_END "</td><td>%s</td>\n"
316
314
                     "<td align=\"center\"><b>%d</b><br/>%d</td>\n<td>",
317
 
                pimpr->graphic_str,
318
 
                improvement_name_translation(id),
319
 
                pimpr->build_cost,
320
 
                pimpr->upkeep);
 
315
                pimprove->graphic_str,
 
316
                improvement_name_translation(pimprove),
 
317
                pimprove->build_cost,
 
318
                pimprove->upkeep);
321
319
 
322
 
        requirement_vector_iterate(&pimpr->reqs, req) {
 
320
        requirement_vector_iterate(&pimprove->reqs, req) {
323
321
          char text[512];
324
322
          fprintf(doc, "%s<br/>",
325
 
                  req->source.type != REQ_NONE
326
 
                  ? get_req_source_text(&req->source, text, sizeof(text))
 
323
                  VUT_NONE != req->source.kind
 
324
                  ? universal_name_translation(&req->source, text, sizeof(text))
327
325
                  : _("None"));
328
326
        } requirement_vector_iterate_end;
329
327
 
330
328
        fprintf(doc, "<em>%s</em></td>\n",
331
 
                tech_exists(pimpr->obsolete_by)
332
 
                ? advance_name_translation(pimpr->obsolete_by)
 
329
                valid_advance(pimprove->obsolete_by)
 
330
                ? advance_name_translation(pimprove->obsolete_by)
333
331
                : _("None"));
334
332
        fprintf(doc, "<td>%s</td>\n</tr>\n\n", buf);
335
 
      } impr_type_iterate_end;
 
333
      } improvement_iterate_end;
336
334
      break;
337
335
 
338
336
    case MANUAL_COUNT:
357
355
  init_nls();
358
356
  init_character_encodings(FC_DEFAULT_DATA_ENCODING, FALSE);
359
357
 
 
358
  /* Initialize game with default values */
 
359
  game_init();
 
360
 
360
361
  /* parse command-line arguments... */
361
362
  inx = 1;
362
363
  while (inx < argc) {
363
 
    if ((option = get_option_malloc("--file", argv, &inx, argc))) {
364
 
      sz_strlcpy(srvarg.load_filename, option);
 
364
    if ((option = get_option_malloc("--ruleset", argv, &inx, argc))) {
 
365
      sz_strlcpy(game.server.rulesetdir, option);
365
366
      free(option);
366
367
    } else if (is_option("--help", argv[inx])) {
367
368
      showhelp = TRUE;
379
380
    fc_fprintf(stderr,
380
381
         _("Usage: %s [option ...]\nValid options are:\n"), argv[0]);
381
382
    fc_fprintf(stderr,
382
 
         _("  -h, --help\t\tPrint a summary of the options\n"));
383
 
    fc_fprintf(stderr, _("  -v, --version\t\tPrint the version number\n"));
384
 
    fc_fprintf(stderr, _("Report bugs at %s.\n"), BUG_URL);
 
383
         _("  -r, --ruleset RULESET  Make manual for RULESET\n"));
 
384
    fc_fprintf(stderr,
 
385
         _("  -h, --help             Print a summary of the options\n"));
 
386
    fc_fprintf(stderr,
 
387
         _("  -v, --version          Print the version number\n"));
 
388
    /* TRANS: No full stop after the URL, could cause confusion. */
 
389
    fc_fprintf(stderr, _("Report bugs at %s\n"), BUG_URL);
385
390
    exit(EXIT_SUCCESS);
386
391
  }
387
392