Freeciv-3.3
Loading...
Searching...
No Matches
manual_terrain.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/* tools/manual */
25#include "fc_manual.h"
26
27/**********************************************************************/
34{
35 FILE *doc;
36 int ri;
37
39
40 if (doc == NULL) {
41 return FALSE;
42 }
43
44 /* TRANS: Markup ... Freeciv version ... ruleset name ... markup */
45 fprintf(doc, _("%sFreeciv %s terrain help (%s)%s\n\n"), tag_info->title_begin,
47 fprintf(doc, "<table><tr bgcolor=#9bc3d1><th>%s</th>", _("Terrain"));
48 fprintf(doc, "<th>F/P/T</th><th>%s</th>", _("Resources"));
49 fprintf(doc, "<th>%s<br/>%s</th>", _("Move cost"), _("Defense bonus"));
50 fprintf(doc, "<th>%s<br/>%s<br/>%s<br/>%s<br/>%s<br/>%s<br/>(%s)</th>",
51 _("Irrigation"), _("Cultivate"), _("Mining"), _("Plant"), _("Transform"),
52 /* xgettext:no-c-format */
53 _("% of Road bonus"), _("turns"));
54 ri = 0;
55 if (game.control.num_road_types > 0) {
56 fprintf(doc, "<th>");
57 }
59 if (++ri < game.control.num_road_types) {
60 fprintf(doc, "%s<br/>", extra_name_translation(pextra));
61 } else {
62 /* Last one */
63 fprintf(doc, "%s</th>", extra_name_translation(pextra));
64 }
66 fprintf(doc, "</tr>\n\n");
67 terrain_type_iterate(pterrain) {
68 struct extra_type **r;
69 struct universal for_terr
70 = { .kind = VUT_TERRAIN, .value = { .terrain = pterrain }};
71
72 if (0 == strlen(terrain_rule_name(pterrain))) {
73 /* Must be a disabled piece of terrain */
74 continue;
75 }
76
77 fprintf(doc, "<tr><td>%s%s%s<br/>%s</td>",
78 tag_info->image_begin, pterrain->graphic_str,
79 tag_info->image_end,
80 terrain_name_translation(pterrain));
81 fprintf(doc, "<td>%d/%d/%d</td>\n",
82 pterrain->output[O_FOOD], pterrain->output[O_SHIELD],
83 pterrain->output[O_TRADE]);
84
85 /* TODO: Include resource frequency information */
86 fprintf(doc, "<td><table width=\"100%%\">\n");
87 for (r = pterrain->resources; *r; r++) {
88 fprintf(doc, "<tr><td>%s%s%s</td><td>%s</td>"
89 "<td align=\"right\">%d/%d/%d</td></tr>\n",
90 tag_info->image_begin, (*r)->graphic_str, tag_info->image_end,
92 (*r)->data.resource->output[O_FOOD],
93 (*r)->data.resource->output[O_SHIELD],
94 (*r)->data.resource->output[O_TRADE]);
95 }
96 fprintf(doc, "</table></td>\n");
97
98 fprintf(doc, "<td align=\"center\">%d<br/>+%d%%</td>\n",
99 pterrain->movement_cost, pterrain->defense_bonus);
100
101 fprintf(doc, "<td><table width=\"100%%\">\n");
103 NULL, &for_terr)) {
104 fprintf(doc, "<tr><td>+%d F</td>", pterrain->irrigation_food_incr);
105 if (pterrain->irrigation_time == 0) {
106 fprintf(doc, "<td align=\"right\">(-)</td></tr>\n");
107 } else {
108 fprintf(doc, "<td align=\"right\">(%d)</td></tr>\n",
109 pterrain->irrigation_time);
110 }
111 } else {
112 fprintf(doc, "<tr><td>%s</td></tr>\n", _("impossible"));
113 }
114 if (pterrain->cultivate_result != NULL
116 NULL, &for_terr)) {
117 fprintf(doc, "<tr><td>%s</td>",
118 terrain_name_translation(pterrain->cultivate_result));
119 if (pterrain->cultivate_time == 0) {
120 fprintf(doc, "<td align=\"right\">(-)</td></tr>\n");
121 } else {
122 fprintf(doc, "<td align=\"right\">(%d)</td></tr>\n",
123 pterrain->cultivate_time);
124 }
125 } else {
126 fprintf(doc, "<tr><td>%s</td></tr>\n", _("impossible"));
127 }
129 fprintf(doc, "<tr><td>+%d P</td>", pterrain->mining_shield_incr);
130 if (pterrain->mining_time == 0) {
131 fprintf(doc, "<td align=\"right\">(-)</td></tr>\n");
132 } else {
133 fprintf(doc, "<td align=\"right\">(%d)</td></tr>\n",
134 pterrain->mining_time);
135 }
136 } else {
137 fprintf(doc, "<tr><td>%s</td></tr>\n", _("impossible"));
138 }
139 if (pterrain->plant_result != NULL
141 NULL, &for_terr)) {
142 fprintf(doc, "<tr><td>%s</td>",
143 terrain_name_translation(pterrain->plant_result));
144 if (pterrain->plant_time == 0) {
145 fprintf(doc, "<td align=\"right\">(-)</td></tr>\n");
146 } else {
147 fprintf(doc, "<td align=\"right\">(%d)</td></tr>\n",
148 pterrain->plant_time);
149 }
150 } else {
151 fprintf(doc, "<tr><td>%s</td></tr>\n", _("impossible"));
152 }
153
154 if (pterrain->transform_result
156 NULL, &for_terr)) {
157 fprintf(doc, "<tr><td>%s</td>",
158 terrain_name_translation(pterrain->transform_result));
159 if (pterrain->transform_time == 0) {
160 fprintf(doc, "<td align=\"right\">(-)</td></tr>\n");
161 } else {
162 fprintf(doc, "<td align=\"right\">(%d)</td></tr>\n",
163 pterrain->transform_time);
164 }
165 } else {
166 fprintf(doc, "<tr><td>-</td><td align=\"right\">(-)</td></tr>\n");
167 }
168 fprintf(doc, "<tr><td>%d / %d / %d</td></tr>\n</table></td>\n",
169 pterrain->road_output_incr_pct[O_FOOD],
170 pterrain->road_output_incr_pct[O_SHIELD],
171 pterrain->road_output_incr_pct[O_TRADE]);
172
173 ri = 0;
174 if (game.control.num_road_types > 0) {
175 fprintf(doc, "<td>");
176 }
178 int btime = terrain_extra_build_time(pterrain, ACTIVITY_GEN_ROAD, pextra);
179
180 if (++ri < game.control.num_road_types) {
181 if (btime == 0) {
182 fprintf(doc, "- / ");
183 } else {
184 fprintf(doc, "%d / ", btime);
185 }
186 } else {
187 if (btime == 0) {
188 fprintf(doc, "-</td>");
189 } else {
190 fprintf(doc, "%d</td>", btime);
191 }
192 }
194 fprintf(doc, "</tr><tr><td colspan=\"7\">\n%s\n</td></tr>\n\n", tag_info->hline);
196
197 fprintf(doc, "</table>\n");
198
200
201 return TRUE;
202}
#define action_id_univs_not_blocking(act_id, act_uni, tgt_uni)
Definition actions.h:710
char * incite_cost
Definition comments.c:76
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:194
#define extra_type_by_cause_iterate_end
Definition extras.h:339
#define extra_type_by_cause_iterate(_cause, _extra)
Definition extras.h:333
void manual_finalize(struct tag_types *tag_info, FILE *doc, enum manuals manual)
Definition fc_manual.c:320
FILE * manual_start(struct tag_types *tag_info, int manual_number)
Definition fc_manual.c:291
@ O_SHIELD
Definition fc_types.h:101
@ O_FOOD
Definition fc_types.h:101
@ O_TRADE
Definition fc_types.h:101
#define _(String)
Definition fcintl.h:67
struct civ_game game
Definition game.c:61
bool manual_terrain(struct tag_types *tag_info)
struct packet_ruleset_control control
Definition game.h:83
char name[MAX_LEN_NAME]
enum universals_n kind
Definition fc_types.h:608
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
const char * terrain_name_translation(const struct terrain *pterrain)
Definition terrain.c:238
const char * terrain_rule_name(const struct terrain *pterrain)
Definition terrain.c:247
int terrain_extra_build_time(const struct terrain *pterrain, enum unit_activity activity, const struct extra_type *tgt)
Definition terrain.c:699
#define terrain_type_iterate(_p)
Definition terrain.h:266
#define terrain_type_iterate_end
Definition terrain.h:272