Freeciv-3.2: /fast/freeciv/nightly/S3_2/tools/manual/manual_buildings.c Source File

Freeciv-3.2

Loading...
Searching...
No Matches
manual_buildings.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/* common */
22#include "game.h"
23
24/* client */
25#include "helpdata.h"
26
27/* tools/manual */
28#include "fc_manual.h"
29
30/**********************************************************************/
37 static bool manual_improvements(struct tag_types *tag_info,
38 enum manuals manual)
39{
40 FILE *doc;
41
42 doc = manual_start(tag_info, manual);
43
44 if (doc == NULL) {
45 return FALSE;
46 }
47
48 if (manual == MANUAL_BUILDINGS) {
49 /* TRANS: markup ... Freeciv version ... ruleset name ... markup */
50 fprintf(doc, _("%sFreeciv %s buildings help (%s)%s\n\n"), tag_info->title_begin,
51 VERSION_STRING, game.control.name, tag_info->title_end);
52 } else {
53 /* TRANS: markup ... Freeciv version ... ruleset name ... markup */
54 fprintf(doc, _("%sFreeciv %s wonders help (%s)%s\n\n"), tag_info->title_begin,
55 VERSION_STRING, game.control.name, tag_info->title_end);
56 }
57
58 fprintf(doc, "<table>\n<tr bgcolor=#9bc3d1><th colspan=2>%s</th>"
59 "<th>%s<br/>%s</th><th>%s<br/>%s</th><th>%s</th></tr>\n\n",
60 _("Name"), _("Cost"), _("Upkeep"),
61 _("Requirement"), _("Obsolete by"), _("More info"));
62
63 improvement_iterate(pimprove) {
64 char buf[64000];
65
66 if (!valid_improvement(pimprove)
67 || is_great_wonder(pimprove) == (manual == MANUAL_BUILDINGS)) {
68 continue;
69 }
70
71 helptext_building(buf, sizeof(buf), NULL, NULL, pimprove);
72
73 fprintf(doc, "<tr><td>%s%s%s</td><td>%s</td>\n"
74 "<td align=\"center\"><b>%d</b><br/>%d</td>\n<td>",
75 tag_info->image_begin, pimprove->graphic_str, tag_info->image_end,
76 improvement_name_translation(pimprove),
77 pimprove->build_cost,
78 pimprove->upkeep);
79
80 if (requirement_vector_size(&pimprove->reqs) == 0) {
81 char text[512];
82
83 strncpy(text, Q_("?req:None"), sizeof(text) - 1);
84 fprintf(doc, "%s<br/>", text);
85 } else {
86 requirement_vector_iterate(&pimprove->reqs, req) {
87 char text[512], text2[512];
88
89 fc_snprintf(text2, sizeof(text2),
90 /* TRANS: Feature required to be absent. */
91 req->present ? "%s" : _("no %s"),
92 universal_name_translation(&req->source,
93 text, sizeof(text)));
94 fprintf(doc, "%s<br/>", text2);
95 } requirement_vector_iterate_end;
96 }
97
98 fprintf(doc, "\n%s\n", tag_info->hline);
99
100 if (requirement_vector_size(&pimprove->obsolete_by) == 0) {
101 char text[512];
102
103 strncpy(text, Q_("?req:None"), sizeof(text) - 1);
104 fprintf(doc, "<em>%s</em><br/>", text);
105 } else {
106 requirement_vector_iterate(&pimprove->obsolete_by, pobs) {
107 char text[512], text2[512];
108
109 fc_snprintf(text2, sizeof(text2),
110 /* TRANS: Feature required to be absent. */
111 pobs->present ? "%s" : _("no %s"),
112 universal_name_translation(&pobs->source,
113 text, sizeof(text)));
114 fprintf(doc, "<em>%s</em><br/>", text2);
115 } requirement_vector_iterate_end;
116 }
117
118 fprintf(doc,
119 "</td>\n<td>%s</td>\n</tr><tr><td colspan=\"5\">\n%s\n</td></tr>\n\n",
120 buf, tag_info->hline);
121 } improvement_iterate_end;
122
123 fprintf(doc, "</table>");
124
125 manual_finalize(tag_info, doc, manual);
126
127 return TRUE;
128}
129
130/**********************************************************************/
136 bool manual_buildings(struct tag_types *tag_info)
137{
138 return manual_improvements(tag_info, MANUAL_BUILDINGS)
139 && manual_improvements(tag_info, MANUAL_WONDERS);
140}
incite_cost
char * incite_cost
Definition comments.c:74
manual_finalize
void manual_finalize(struct tag_types *tag_info, FILE *doc, enum manuals manual)
Definition fc_manual.c:316
manual_start
FILE * manual_start(struct tag_types *tag_info, int manual_number)
Definition fc_manual.c:287
fc_manual.h
fcintl.h
Q_
#define Q_(String)
Definition fcintl.h:70
_
#define _(String)
Definition fcintl.h:67
game
struct civ_game game
Definition game.c:62
game.h
helptext_building
char * helptext_building(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct impr_type *pimprove)
Definition helpdata.c:1381
helpdata.h
valid_improvement
const struct impr_type * valid_improvement(const struct impr_type *pimprove)
Definition improvement.c:211
is_great_wonder
bool is_great_wonder(const struct impr_type *pimprove)
Definition improvement.c:772
improvement_name_translation
const char * improvement_name_translation(const struct impr_type *pimprove)
Definition improvement.c:243
improvement_iterate_end
#define improvement_iterate_end
Definition improvement.h:205
improvement_iterate
#define improvement_iterate(_p)
Definition improvement.h:199
manual_buildings
bool manual_buildings(struct tag_types *tag_info)
Definition manual_buildings.c:136
manual_improvements
static bool manual_improvements(struct tag_types *tag_info, enum manuals manual)
Definition manual_buildings.c:37
universal_name_translation
const char * universal_name_translation(const struct universal *psource, char *buf, size_t bufsz)
Definition requirements.c:6755
requirement_vector_iterate_end
#define requirement_vector_iterate_end
Definition requirements.h:94
requirement_vector_iterate
#define requirement_vector_iterate(req_vec, preq)
Definition requirements.h:92
civ_game::control
struct packet_ruleset_control control
Definition game.h:83
packet_ruleset_control::name
char name[MAX_LEN_NAME]
Definition packets_gen.h:1475
tag_types
Definition fc_manual.h:47
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47