[Freeciv-Dev] Re: (PR#9685) manual generator
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] Re: (PR#9685) manual generator |
From: |
"Per I. Mathisen" <per@xxxxxxxxxxx> |
Date: |
Sat, 4 Sep 2004 13:44:05 -0700 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=9685 >
On Sat, 4 Sep 2004, Per I. Mathisen wrote:
> New manual generator diff.
CHANGES:
- actually compiles (civmanual.h reference removed)
- links with client/helpdata.o
- fixed cooperation with --enable-server|client
- Per
## Process this file with automake to produce Makefile.in
bin_PROGRAMS = civmanual
AM_CPPFLAGS = -I$(top_srcdir)/server -I$(top_srcdir)/utility
-I$(top_srcdir)/common -I$(top_srcdir)/ai -I../intl
-I$(top_srcdir)/common/aicore -I$(top_srcdir)/server/userdb
-I$(top_srcdir)/client -I$(top_srcdir)/client/include
## Above, note -I../intl instead of -I$(top_srcdir/intl) is deliberate.
civmanual_SOURCES = \
civmanual.c \
civmanual.h
civmanual_DEPENDENCIES = ../utility/libcivutility.a ../common/libcivcommon.a \
../ai/libcivai.a ../utility/libcivutility.a ../server/libcivserver.a \
../utility/libcivutility.a ../common/aicore/libaicore.a \
../server/userdb/libuserdb.a ../client/helpdata.o
civmanual_LDADD = ../utility/libcivutility.a ../common/libcivcommon.a \
../ai/libcivai.a ../utility/libcivutility.a ../server/libcivserver.a \
@INTLLIBS@ ../client/helpdata.o \
../utility/libcivutility.a ../common/libcivcommon.a ../ai/libcivai.a \
../utility/libcivutility.a ../server/libcivserver.a \
../server/userdb/libuserdb.a \
../utility/libcivutility.a \
../common/aicore/libaicore.a $(SERVER_LIBS)
Index: Makefile.am
===================================================================
RCS file: /home/freeciv/CVS/freeciv/Makefile.am,v
retrieving revision 1.43
diff -u -r1.43 Makefile.am
--- Makefile.am 21 Aug 2004 16:20:25 -0000 1.43
+++ Makefile.am 4 Sep 2004 20:30:10 -0000
@@ -12,6 +12,16 @@
SSUBDIRS =
endif
+if SERVER
+if CLIENT
+MSUBDIRS = manual
+else
+MSUBDIRS =
+endif
+else
+MSUBDIRS =
+endif
+
if MAKE_DATA
DSUBDIRS = data
else
@@ -19,7 +29,7 @@
endif
-SUBDIRS= $(DSUBDIRS) intl utility common tests $(SSUBDIRS) $(CSUBDIRS)
po doc
+SUBDIRS= $(DSUBDIRS) intl utility common tests $(SSUBDIRS) $(CSUBDIRS)
po doc $(MSUBDIRS)
EXTRA_DIST= acconfig.old \
autogen.sh \
Index: configure.ac
===================================================================
RCS file: /home/freeciv/CVS/freeciv/configure.ac,v
retrieving revision 1.70
diff -u -r1.70 configure.ac
--- configure.ac 21 Aug 2004 16:20:25 -0000 1.70
+++ configure.ac 4 Sep 2004 20:30:10 -0000
@@ -641,6 +641,7 @@
client/gui-stub/Makefile
server/Makefile
server/userdb/Makefile
+ manual/Makefile
intl/Makefile
po/Makefile.in
doc/Makefile
Index: configure.in
===================================================================
RCS file: /home/freeciv/CVS/freeciv/configure.in,v
retrieving revision 1.247
diff -u -r1.247 configure.in
--- configure.in 4 Sep 2004 00:52:59 -0000 1.247
+++ configure.in 4 Sep 2004 20:30:11 -0000
@@ -638,6 +638,7 @@
client/gui-stub/Makefile
server/Makefile
server/userdb/Makefile
+ manual/Makefile
intl/Makefile
po/Makefile.in
doc/Makefile
/**********************************************************************
Freeciv - Copyright (C) 2004 - The Freeciv Project
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
***********************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "astring.h"
#include "capability.h"
#include "events.h"
#include "fcintl.h"
#include "game.h"
#include "improvement.h"
#include "log.h"
#include "map.h"
#include "mem.h"
#include "player.h"
#include "registry.h"
#include "shared.h"
#include "support.h"
#include "version.h"
#include "helpdata.h"
#include "helpdlg_g.h"
#include "citytools.h"
#include "connecthand.h"
#include "console.h"
#include "diplhand.h"
#include "gamehand.h"
#include "gamelog.h"
#include "plrhand.h"
#include "report.h"
#include "ruleset.h"
#include "savegame.h"
#include "srv_main.h"
#include "stdinhand.h"
#include "commands.h"
#include "settings.h"
#include "stdinhand_info.h"
#define NUM_MANUALS 5
#define HTML_HEADER "<html><head><link rel=\"stylesheet\" type=\"text/css\" "\
"href=\"manual.css\" /></head><body>\n\n"
#ifdef USE_HTML
#define SECTION_BEGIN "<h3>"
#define SECTION_END "</h3>"
#define IMAGE_BEGIN "<img src="
#define IMAGE_END ".png\">"
#else
#define SECTION_BEGIN "==="
#define SECTION_END "==="
#define IMAGE_BEGIN "[[Image:"
#define IMAGE_END ".png]]"
#endif
/* useless stubs for compiling client code */
void popup_help_dialog_string(const char *item) {}
void popdown_help_dialog(void) {}
/**************************************************************************
Write a server manual in html format, then quit.
**************************************************************************/
static bool manual_command(void)
{
FILE *doc;
char filename[40];
int manuals;
load_rulesets();
for (manuals = 1; manuals < NUM_MANUALS + 1; manuals++) {
int i;
snprintf(filename, sizeof(filename), "manual%d.html", manuals);
if (!is_reg_file_for_access(filename, TRUE)
|| !(doc = fopen(filename, "w"))) {
die(_("Could not write manual file %s."), filename);
return FALSE;
}
#ifdef USE_HTML
fprintf(doc, HTML_HEADER);
#endif
switch (manuals) {
case 1:
fprintf(doc, "<h1>Freeciv %s server options</h1>\n\n", VERSION_STRING);
for (i = 0; settings[i].name; i++) {
struct settings_s *op = &settings[i];
static struct astring abuf = ASTRING_INIT;
const char *help = _(op->extra_help);
astr_minsize(&abuf, strlen(help) + 10);
strcpy(abuf.str, help);
wordwrap_string(abuf.str, 76);
#ifndef USE_HTML
fprintf(doc, "----\n\n");
#endif
fprintf(doc, "%s%s - %s%s\n\n", SECTION_BEGIN, op->name,
_(op->short_help), SECTION_END);
if (strlen(op->extra_help) > 0) {
fprintf(doc, "<pre>%s</pre>\n\n", abuf.str);
}
fprintf(doc, "<p class=\"misc\">");
fprintf(doc, _("Level: %s.<br>"), sset_level_names[op->level]);
fprintf(doc, _("Category: %s.<br>"), sset_category_names[op->category]);
if (op->to_client == SSET_SERVER_ONLY) {
fprintf(doc, _("Can only be used in server console. "));
}
if (sset_is_changeable(i)) {
fprintf(doc, _("Can be changed during a game. "));
} else {
fprintf(doc, _("Can <b>not</b> be changed during a game. "));
}
fprintf(doc, "</p>\n\n");
switch (op->type) {
case SSET_BOOL:
fprintf(doc, _("<p class=\"bounds\">Minimum: 0, Default: %d, "
"Maximum: 1</p>\n\n"), op->bool_default_value ? 1 : 0);
if (*(op->bool_value) != op->bool_default_value) {
fprintf(doc, _("<p class=\"changed\">Value set to %d</p>\n\n"),
*(op->bool_value));
}
break;
case SSET_INT:
fprintf(doc, _("<p class=\"bounds\">Minimum: %d, Default: %d, "
"Maximum: %d</p>\n\n"),
op->int_min_value, op->int_default_value, op->int_max_value);
if (*(op->int_value) != op->int_default_value) {
fprintf(doc, _("<p class=\"changed\">Value set to %d</p>\n\n"),
*(op->int_value));
}
break;
case SSET_STRING:
fprintf(doc, _("<p class=\"bounds\">Default: \"%s\"</p>\n\n"),
op->string_default_value);
if (strcmp(op->string_value, op->string_default_value) != 0) {
fprintf(doc, _("<p class=\"changed\">Value set to %s</p>\n\n"),
op->string_value);
}
break;
}
}
break;
case 2:
fprintf(doc, "<h1>Freeciv %s server commands</h1>\n\n", VERSION_STRING);
for (i = 0; i < CMD_NUM; i++) {
const struct command *cmd = &commands[i];
#ifndef USE_HTML
fprintf(doc, "----\n\n");
#endif
fprintf(doc, _("%s%s - %s%s\n\n"), SECTION_BEGIN, cmd->name,
_(cmd->short_help), SECTION_END);
if (cmd->synopsis) {
fprintf(doc, _("<table>\n<tr>\n<td valign=\"top\"><pre>Synopsis:</pre>"
"</td>\n<td>"));
fprintf(doc, "<pre>%s</pre></td></tr></table>", _(cmd->synopsis));
}
fprintf(doc, _("<p class=\"level\">Level: %s</p>\n\n"),
cmdlevel_name(cmd->level));
if (cmd->extra_help) {
static struct astring abuf = ASTRING_INIT;
const char *help = _(cmd->extra_help);
astr_minsize(&abuf, strlen(help)+1);
strcpy(abuf.str, help);
wordwrap_string(abuf.str, 76);
fprintf(doc, _("<p>Description:</p>\n\n"));
fprintf(doc, "<pre>%s</pre>\n\n", abuf.str);
}
}
break;
case 3:
fprintf(doc, _("<h1>Freeciv %s terrain help</h1>\n\n"), VERSION_STRING);
fprintf(doc, _("<table border=1><tr><th>Terrain</th>"));
fprintf(doc, _("<th>Food/ Shield/ Trade</th>"));
fprintf(doc, _("<th>Special 1</th><th>Food/ Shield/ Trade</th>"));
fprintf(doc, _("<th>Special 2</th><th>Food/ Shield/ Trade</th>"));
fprintf(doc, _("<th>Move cost</th><th>Defense</th><th>Road
+trade</th>\n")); fprintf(doc, _("<th>Irrigation +food</th><th>Mining
+shields</th>\n"));
fprintf(doc, _("<th>Transform to</th>"));
fprintf(doc, "</tr>\n");
terrain_type_iterate(id) {
struct tile_type *ptype = get_tile_type(id);
if (ptype->defense_bonus == 0) {
/* Must be a disabled piece of terrain */
continue;
}
fprintf(doc, "<tr><td>%s%s%s %s</td>", IMAGE_BEGIN, ptype->graphic_str,
IMAGE_END, get_terrain_name(id));
fprintf(doc, "<td>%d / %d / %d</td>",
ptype->food, ptype->shield, ptype->trade);
fprintf(doc, "<td>%s%s%s %s</td>", IMAGE_BEGIN,
ptype->special[0].graphic_str, IMAGE_END,
ptype->special_1_name);
fprintf(doc, "<td>%d / %d / %d</td>",
ptype->food_special_1, ptype->shield_special_1,
ptype->trade_special_1);
fprintf(doc, "<td>%s%s%s", IMAGE_BEGIN,
ptype->special[1].graphic_str, IMAGE_END);
fprintf(doc, " %s</td>", ptype->special_2_name);
fprintf(doc, "<td>%d / %d / %d</td>",
ptype->food_special_2, ptype->shield_special_2,
ptype->trade_special_2);
fprintf(doc, "<td>%d</td>\n", ptype->movement_cost);
fprintf(doc, "<td>%d0%%</td><td>%d</td><td>%d</td><td>%d</td>\n",
ptype->defense_bonus, ptype->road_trade_incr,
ptype->irrigation_food_incr, ptype->mining_shield_incr);
fprintf(doc, "<td>%s</td></tr>\n\n",
get_terrain_name(ptype->transform_result));
} terrain_type_iterate_end;
fprintf(doc, "</table><br><br><br><table border=1>");
fprintf(doc, "<caption>Time to perform action</caption>");
fprintf(doc, "<tr><th>Terrain</th>\n");
fprintf(doc, "<th>Road</th><th>Irrigation</th>\n");
fprintf(doc, "<th>Mining</th><th>Rail</th>\n");
fprintf(doc, "<th>Airbase</th><th>Fortress</th>\n");
fprintf(doc, "<th>Clean pollution</th><th>Clean fallout</th>\n");
fprintf(doc, "<th>Transform</th></tr>\n");
terrain_type_iterate(id) {
const char *name = get_terrain_name(id);
struct tile_type *ptype = get_tile_type(id);
if (ptype->defense_bonus == 0) {
/* Must be a disabled piece of terrain */
continue;
}
fprintf(doc, "<tr><td>%s%s%s %s</td><td>%d</td>\n",
IMAGE_BEGIN, ptype->graphic_str, IMAGE_END, name,
ptype->road_time);
fprintf(doc, "<td>%d</td><td>%d</td><td>%d</td><td>%d</td>\n",
ptype->irrigation_time, ptype->mining_time,
ptype->rail_time, ptype->airbase_time);
fprintf(doc, "<td>%d</td><td>%d</td><td>%d</td><td>%d</td>\n",
ptype->fortress_time, ptype->clean_pollution_time,
ptype->clean_fallout_time, ptype->transform_time);
fprintf(doc, "</tr>\n\n");
} terrain_type_iterate_end;
fprintf(doc, "</table>\n");
break;
case 4:
fprintf(doc, _("<h1>Buildings help for %s</h1>\n\n"), VERSION_STRING);
impr_type_iterate(id) {
struct astring astr = ASTRING_INIT;
struct impr_type *pimpr = get_improvement_type(id);
if (pimpr->is_wonder) {
continue;
}
astr_init(&astr);
// improvement_helptext(&astr, id);
fprintf(doc, "%s%s%s\n\n", SECTION_BEGIN, get_improvement_name(id),
SECTION_END);
fprintf(doc, "<table>\n");
fprintf(doc, _("<tr><td>Cost: <td>%d</tr>\n"), pimpr->build_cost);
fprintf(doc, _("<tr><td>Upkeep: <td>%d</tr>\n"), pimpr->upkeep);
if (tech_exists(pimpr->tech_req)) {
fprintf(doc, _("<tr><td>Tech required: <td>%s</tr>\n"),
advances[pimpr->tech_req].name);
}
if (tech_exists(pimpr->obsolete_by)) {
fprintf(doc, _("<tr><td>Obsoleted by: <td>%s</tr>\n"),
advances[pimpr->obsolete_by].name);
}
fprintf(doc, "</table>\n\n");
fprintf(doc, "<pre>%s</pre>\n\n", astr.str);
astr_free(&astr);
} impr_type_iterate_end;
break;
case 5:
fprintf(doc, _("<h1>Wonder help for %s</h1>\n\n"), VERSION_STRING);
impr_type_iterate(id) {
struct astring astr = ASTRING_INIT;
struct impr_type *pimpr = get_improvement_type(id);
if (!pimpr->is_wonder) {
continue;
}
astr_init(&astr);
// improvement_helptext(&astr, id);
fprintf(doc, "%s%s%s\n\n", SECTION_BEGIN, get_improvement_name(id),
SECTION_END);
fprintf(doc, "<table>\n");
fprintf(doc, _("<tr><td>Cost: <td>%d</tr>\n"), pimpr->build_cost);
fprintf(doc, _("<tr><td>Upkeep: <td>%d</tr>\n"), pimpr->upkeep);
if (tech_exists(pimpr->tech_req)) {
fprintf(doc, _("<tr><td>Tech required: <td>%s</tr>\n"),
advances[pimpr->tech_req].name);
}
if (tech_exists(pimpr->obsolete_by)) {
fprintf(doc, _("<tr><td>Obsoleted by: <td>%s</tr>\n"),
advances[pimpr->obsolete_by].name);
}
fprintf(doc, "</table>\n\n");
if (astr.str != NULL) {
fprintf(doc, "<pre>%s</pre>\n\n", astr.str);
}
astr_free(&astr);
} impr_type_iterate_end;
break;
} /* switch */
#ifdef USE_HTML
fprintf(doc, "</body></html>");
#endif
fclose(doc);
} /* manuals */
exit(EXIT_SUCCESS);
return TRUE;
}
int main(int argc, char **argv)
{
manual_command();
return 0;
}
|
|