12 #include <fc_config.h>
19 #include <QCommandLineParser>
20 #include <QCoreApplication>
87 "<html><head><link rel=\"stylesheet\" type=\"text/css\" "
88 "href=\"manual.css\"/><meta http-equiv=\"Content-Type\" "
89 "content=\"text/html; charset=UTF-8\"/></head><body>\n\n",
98 "<h3 class='section'>",
104 "<div class='item' id='%s%d'>\n",
138 "----\n<!-- %s %d -->\n",
170 if (!
load_rulesets(
nullptr,
nullptr,
false,
nullptr,
false,
false,
176 for (
int imanuals = 0; imanuals <
MANUAL_COUNT; imanuals++) {
184 if (QFile::exists(filename) || !(doc =
fc_fopen(filename,
"w"))) {
185 qCritical(
_(
"Could not write manual file %s."), filename);
189 fprintf(doc,
"%s", tag_info->
header);
190 fprintf(doc,
"<!-- Generated by freeciv21-manual version %s -->\n\n",
196 fprintf(doc,
_(
"%sFreeciv21 %s server options (%s)%s\n\n"),
209 if (strlen(sethelp) > 0) {
210 QString help = sethelp;
212 help = help.toHtmlEscaped();
213 fprintf(doc,
"<pre>%s</pre>\n\n", qUtf8Printable(help));
215 fprintf(doc,
"<p class=\"misc\">");
216 fprintf(doc,
_(
"Level: %s.<br>"),
218 fprintf(doc,
_(
"Category: %s.<br>"),
224 fprintf(doc,
_(
"Is locked by the ruleset."));
226 fprintf(doc,
_(
"Can only be used in server console."));
229 fprintf(doc,
"</p>\n");
233 fprintf(doc,
"\n<p class=\"bounds\">%s %d, %s %s, %s %d</p>\n",
240 fprintf(doc,
"\n<p class=\"bounds\">%s</p>",
241 _(
"Possible values:"));
243 fprintf(doc,
"\n<p class=\"bounds\"><li/> %s: \"%s\"</p>", value,
251 doc,
"\n<p class=\"bounds\">%s</p>",
252 _(
"Possible values (option can take any number of these):"));
254 fprintf(doc,
"\n<p class=\"bounds\"><li/> %s: \"%s\"</p>", value,
266 fprintf(doc,
"\n<p class=\"bounds\">%s %s</p>\n",
_(
"Default:"),
270 fprintf(doc,
_(
"\n<p class=\"changed\">Value set to %s</p>\n"),
274 fprintf(doc,
"%s", tag_info->
item_end);
281 fprintf(doc,
_(
"%sFreeciv21 %s server commands%s\n\n"),
284 for (i = 0; i <
CMD_NUM; i++) {
293 cmdstr = cmdstr.toHtmlEscaped();
294 fprintf(doc,
_(
"<table>\n<tr>\n<td valign=\"top\">"
295 "<pre>Synopsis:</pre></td>\n<td>"));
296 fprintf(doc,
"<pre>%s</pre></td></tr></table>",
297 qUtf8Printable(cmdstr));
299 fprintf(doc,
_(
"<p class=\"level\">Level: %s</p>\n"),
303 if (!help.isEmpty()) {
305 help = help.toHtmlEscaped();
307 fprintf(doc,
_(
"<p>Description:</p>\n\n"));
308 fprintf(doc,
"<pre>%s</pre>\n", qUtf8Printable(help));
312 fprintf(doc,
"%s", tag_info->
item_end);
318 fprintf(doc,
_(
"%sFreeciv21 %s terrain help (%s)%s\n\n"),
321 fprintf(doc,
"<table><tr bgcolor=#9bc3d1><th>%s</th>",
_(
"Terrain"));
322 fprintf(doc,
"<th>F/P/T</th><th>%s</th>",
_(
"Resources"));
323 fprintf(doc,
"<th>%s<br/>%s</th>",
_(
"Move cost"),
_(
"Defense bonus"));
324 fprintf(doc,
"<th>%s<br/>%s<br/>%s<br/>%s<br/>%s<br/>%s<br/>(%s)</th>",
325 _(
"Irrigation"),
_(
"Cultivate"),
_(
"Mining"),
_(
"Plant"),
328 _(
"% of Road bonus"),
_(
"turns"));
329 fprintf(doc,
"<th>%s<br/>%s</th>",
_(
"Clean pollution"),
333 fprintf(doc,
"<th>");
345 fprintf(doc,
"</tr>\n\n");
356 fprintf(doc,
"<td>%d/%d/%d</td>\n", pterrain->output[
O_FOOD],
359 fprintf(doc,
"<td><table width=\"100%%\">\n");
360 for (r = pterrain->resources; *r; r++) {
362 "<tr><td>%s</td><td align=\"right\">%d/%d/%d</td></tr>\n",
364 (*r)->data.resource->output[
O_FOOD],
365 (*r)->data.resource->output[
O_SHIELD],
366 (*r)->data.resource->output[
O_TRADE]);
368 fprintf(doc,
"</table></td>\n");
370 fprintf(doc,
"<td align=\"center\">%d<br/>+%d%%</td>\n",
371 pterrain->movement_cost, pterrain->defense_bonus);
373 fprintf(doc,
"<td><table width=\"100%%\">\n");
374 if (pterrain->irrigation_time != 0) {
376 "<tr><td>+%d F</td><td align=\"right\">(%d)</td></tr>\n",
377 pterrain->irrigation_food_incr, pterrain->irrigation_time);
379 fprintf(doc,
"<tr><td>%s</td></tr>\n",
_(
"impossible"));
381 if (pterrain->irrigation_result !=
nullptr
382 && pterrain->irrigation_result != pterrain) {
383 fprintf(doc,
"<tr><td>%s</td><td align=\"right\">(%d)</td></tr>\n",
385 pterrain->cultivate_time);
387 fprintf(doc,
"<tr><td>%s</td></tr>\n",
_(
"impossible"));
389 if (pterrain->mining_time != 0) {
391 "<tr><td>+%d P</td><td align=\"right\">(%d)</td></tr>\n",
392 pterrain->mining_shield_incr, pterrain->mining_time);
394 fprintf(doc,
"<tr><td>%s</td></tr>\n",
_(
"impossible"));
396 if (pterrain->mining_result !=
nullptr
397 && pterrain->mining_result != pterrain) {
398 fprintf(doc,
"<tr><td>%s</td><td align=\"right\">(%d)</td></tr>\n",
400 pterrain->plant_time);
402 fprintf(doc,
"<tr><td>%s</td></tr>\n",
_(
"impossible"));
405 if (pterrain->transform_result) {
406 fprintf(doc,
"<tr><td>%s</td><td align=\"right\">(%d)</td></tr>\n",
408 pterrain->transform_time);
410 fprintf(doc,
"<tr><td>-</td><td align=\"right\">(-)</td></tr>\n");
412 fprintf(doc,
"<tr><td>%d / %d / %d</td></tr>\n</table></td>\n",
413 pterrain->road_output_incr_pct[
O_FOOD],
414 pterrain->road_output_incr_pct[
O_SHIELD],
415 pterrain->road_output_incr_pct[
O_TRADE]);
417 fprintf(doc,
"<td align=\"center\">%d / %d</td>",
418 pterrain->clean_pollution_time,
419 pterrain->clean_fallout_time);
423 fprintf(doc,
"<td>");
428 fprintf(doc,
"%d / ",
432 fprintf(doc,
"%d</td>",
438 fprintf(doc,
"</tr>\n\n");
442 fprintf(doc,
"</table>\n");
450 fprintf(doc,
_(
"%sFreeciv21 %s buildings help (%s)%s\n\n"),
455 fprintf(doc,
_(
"%sFreeciv21 %s wonders help (%s)%s\n\n"),
461 "<table>\n<tr bgcolor=#9bc3d1><th>%s</th>"
462 "<th>%s<br/>%s</th><th>%s<br/>%s</th><th>%s</th></tr>\n\n",
463 _(
"Name"),
_(
"Cost"),
_(
"Upkeep"),
_(
"Requirement"),
464 _(
"Obsolete by"),
_(
"More info"));
469 struct advance *obs_tech =
nullptr;
481 "<td align=\"center\"><b>%d</b><br/>%d</td>\n<td>",
487 char text[512], text2[512];
490 req->present ?
"%s" :
_(
"no %s"),
491 VUT_NONE != req->source.kind
495 fprintf(doc,
"%s<br/>", text2);
501 if (pobs->source.kind == VUT_ADVANCE) {
502 obs_tech = pobs->source.value.advance;
508 fprintf(doc,
"<em>%s</em></td>\n",
511 fprintf(doc,
"<td>%s</td>\n</tr>\n\n", buf);
514 fprintf(doc,
"</table>");
522 fprintf(doc,
_(
"%sFreeciv21 %s governments help (%s)%s\n\n"),
527 fprintf(doc, tag_info->
item_begin,
"gov", pgov.item_number);
533 fprintf(doc,
"%s\n\n", buf);
535 fprintf(doc,
"%s", tag_info->
item_end);
544 fprintf(doc,
_(
"%sFreeciv21 %s unit types help (%s)%s\n\n"),
551 fprintf(doc, tag_info->
item_begin,
"utype", putype->item_number);
556 PL_(
"Cost: %d shield",
"Cost: %d shields",
564 fprintf(doc,
_(
"Moves: %s"),
568 fprintf(doc,
_(
"Vision: %d"),
569 (
int) sqrt((
double) putype->vision_radius_sq));
572 fprintf(doc,
_(
"Attack: %d"), putype->attack_strength);
575 fprintf(doc,
_(
"Defense: %d"), putype->defense_strength);
578 fprintf(doc,
_(
"Firepower: %d"), putype->firepower);
581 fprintf(doc,
_(
"Hitpoints: %d"), putype->hp);
584 fprintf(doc,
_(
"Obsolete by: %s"),
590 helptext_unit(buf,
sizeof(buf),
nullptr,
"", putype,
nullptr);
591 fprintf(doc,
"%s", buf);
593 fprintf(doc,
"%s", tag_info->
item_end);
601 fprintf(doc,
_(
"%sFreeciv21 %s tech help (%s)%s\n\n"),
609 fprintf(doc, tag_info->
item_begin,
"tech", ptech->item_number);
616 fprintf(doc,
"%s", buf);
619 fprintf(doc,
"%s", tag_info->
item_end);
630 fprintf(doc,
"%s", tag_info->
tail);
632 qInfo(
_(
"Manual file %s successfully written."), filename);
641 int main(
int argc,
char **argv)
643 int retval = EXIT_SUCCESS;
646 QCoreApplication app(argc, argv);
652 QCommandLineParser parser;
653 parser.addHelpOption();
654 parser.addVersionOption();
656 bool ok = parser.addOptions({
660 _(
"Set debug log level (fatal/critical/warning/info/debug)."),
662 QStringLiteral(
"info")},
663 {{
"F",
"Fatal"},
_(
"Raise a signal on failed assertion.")},
665 _(
"Use FILE as logfile."),
669 _(
"Make manual for RULESET."),
672 {{
"w",
"wiki"},
_(
"Write manual in wiki format.")},
675 qFatal(
"Adding command line arguments failed.");
682 if (!
log_init(parser.value(QStringLiteral(
"debug")))) {
686 if (parser.isSet(QStringLiteral(
"ruleset"))) {
687 if (parser.values(QStringLiteral(
"ruleset")).
size() > 1) {
688 fc_fprintf(stderr,
_(
"Multiple rulesets requested. Only one ruleset "
689 "at time supported.\n"));
692 ruleset = parser.value(QStringLiteral(
"ruleset"));
695 if (parser.isSet(QStringLiteral(
"log"))) {
698 if (parser.isSet(QStringLiteral(
"wiki"))) {
727 retval = EXIT_FAILURE;
QString break_lines(const QString &src, int after)
void init_our_capability()
Setup our internal network capability string.
int main(int argc, char **argv)
Entry point of whole freeciv-manual program.
static bool manual_command(struct tag_types *tag_info)
Write a server manual, then quit.
struct tag_types html_tags
struct tag_types wiki_tags
const char * command_name(const struct command *pcommand)
Return name of the command.
const struct command * command_by_number(int i)
Return command by its number.
const char * command_short_help(const struct command *pcommand)
Returns the short help text of the command (translated).
char * command_extra_help(const struct command *pcommand)
Returns the extra help text of the command (translated).
enum cmdlevel command_level(const struct command *pcommand)
What is the permissions level required for running the command?
const char * command_synopsis(const struct command *pcommand)
Returns the synopsis text of the command (translated).
void connection_common_init(struct connection *pconn)
Initialize common part of connection structure.
void con_log_init(const QString &log_filename)
Initialize logging via console.
void con_log_close()
Deinitialize logging.
void free_libfreeciv()
Free misc resources allocated for libfreeciv.
void fc_fprintf(FILE *stream, const char *format,...)
Do a fprintf from the internal charset into the local charset.
void init_character_encodings(const char *my_internal_encoding, bool my_use_transliteration)
Must be called during the initialization phase of server and client to initialize the character encod...
#define FC_DEFAULT_DATA_ENCODING
#define PL_(String1, String2, n)
void game_init(bool keep_ruleset_value)
Initialise all game settings.
std::vector< government > governments
const char * government_name_translation(const struct government *pgovern)
Return the (translated) name of the given government.
void helptext_advance(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, int i, const nation_set *nations_to_show)
Append misc dynamic text for advance/technology.
void helptext_government(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct government *gov)
Append text for government.
char * helptext_unit(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct unit_type *utype, const nation_set *nations_to_show)
Append misc dynamic text for units.
char * helptext_unit_upkeep_str(const struct unit_type *utype)
Returns pointer to static string with eg: "1 shield, 1 unhappy".
char * helptext_building(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct impr_type *pimprove, const nation_set *nations_to_show)
FIXME: Also, in principle these could be auto-generated once, inserted into pitem->text,...
const struct impr_type * valid_improvement(const struct impr_type *pimprove)
Returns pointer when the improvement_type "exists" in this game, returns nullptr otherwise.
bool is_great_wonder(const struct impr_type *pimprove)
Is this building a great wonder?
const char * improvement_name_translation(const struct impr_type *pimprove)
Return the (translated) name of the given improvement.
#define improvement_iterate_end
#define improvement_iterate(_p)
bool log_init(const QString &level_str, const QStringList &extra_rules)
Parses a log level string as provided by the user on the command line, and installs the corresponding...
void fc_assert_set_fatal(bool fatal)
Set what signal the assert* macros should raise on failed assertion (-1 to disable).
#define fc_assert(condition)
const char * move_points_text(int mp, bool reduce)
Simple version of move_points_text_full() – render positive movement points as text without any prefi...
const char * universal_name_translation(const struct universal *psource, char *buf, size_t bufsz)
Make user-friendly text for the source.
#define requirement_vector_iterate_end
#define requirement_vector_iterate(req_vec, preq)
bool load_rulesets(const char *restore, const char *alt, bool compat_mode, rs_conversion_logger logger, bool act, bool buffer_script, bool load_luadata)
Loads the rulesets.
void init_connections()
Initialize connection related stuff.
void settings_init(bool act)
Initialize stuff related to this code module.
int setting_number(const struct setting *pset)
Returns the id to the given setting.
enum sset_category setting_category(const struct setting *pset)
Access function for the setting category.
bool setting_locked(const struct setting *pset)
Returns if the setting is locked by the ruleset.
bool setting_non_default(const struct setting *pset)
Returns whether the setting has non-default value.
enum sset_type setting_type(const struct setting *pset)
Access function for the setting type.
int setting_int_max(const struct setting *pset)
Returns the maximal integer value for this setting.
enum sset_level setting_level(const struct setting *pset)
Access function for the setting level (used by the /show command).
const char * setting_enum_val(const struct setting *pset, int val, bool pretty)
Convert the integer to the string representation of an enumerator.
const char * setting_name(const struct setting *pset)
Access function for the setting name.
const char * setting_value_name(const struct setting *pset, bool pretty, char *buf, size_t buf_len)
Compute the name of the current value of the setting.
int setting_int_min(const struct setting *pset)
Returns the minimal integer value for this setting.
const char * setting_short_help(const struct setting *pset)
Access function for the short help (not translated yet) of the setting.
const char * setting_extra_help(const struct setting *pset, bool constant)
Access function for the long (extra) help of the setting.
bool setting_is_changeable(const struct setting *pset, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Returns whether the specified server setting (option) can currently be changed by the caller.
const char * setting_bitwise_bit(const struct setting *pset, int bit, bool pretty)
Convert the bit number to its string representation.
const char * setting_default_name(const struct setting *pset, bool pretty, char *buf, size_t buf_len)
Compute the name of the default value of the setting.
#define settings_iterate(_level, _pset)
#define settings_iterate_end
void free_nls()
Free memory allocated by Native Language Support.
void init_nls()
Setup for Native Language Support, if configured to use it.
struct server_arguments srvarg
struct civ_game::@28::@32 server
struct packet_ruleset_control control
struct packet_game_info info
enum cmdlevel access_level
const char * subitem_begin
const char * sect_title_end
const char * sect_title_begin
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
FILE * fc_fopen(const char *filename, const char *opentype)
Wrapper function for fopen() with filename conversion to local encoding on Windows.
#define sz_strlcpy(dest, src)
struct advance * valid_advance(struct advance *padvance)
Returns pointer when the advance "exists" in this game, returns nullptr otherwise.
const char * advance_name_translation(const struct advance *padvance)
Return the (translated) name of the given advance/technology.
#define advance_iterate(_start, _p)
#define advance_iterate_end
const char * terrain_rule_name(const struct terrain *pterrain)
Return the (untranslated) rule name of the terrain.
const char * terrain_name_translation(const struct terrain *pterrain)
Return the (translated) name of the terrain.
int terrain_extra_build_time(const struct terrain *pterrain, enum unit_activity activity, const struct extra_type *tgt)
Time to complete the extra building activity on the given terrain.
#define terrain_type_iterate(_p)
#define terrain_type_iterate_end
int utype_build_shield_cost_base(const struct unit_type *punittype)
Returns the number of shields this unit type represents.
const char * utype_name_translation(const struct unit_type *punittype)
Return the (translated) name of the unit type.
#define unit_type_iterate(_p)
#define unit_type_iterate_end
const char * freeciv21_version()
Returns the raw version string.