Freeciv-3.3: /fast/freeciv/nightly/main/tools/manual/manual_terrain.c Source File

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/**********************************************************************/
33 bool manual_terrain(struct tag_types *tag_info)
34{
35 FILE *doc;
36 int ri;
37
38 doc = manual_start(tag_info, MANUAL_TERRAIN);
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,
46 VERSION_STRING, game.control.name, tag_info->title_end);
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 }
58 extra_type_by_cause_iterate(EC_ROAD, pextra) {
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 }
65 } extra_type_by_cause_iterate_end;
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%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,
91 extra_name_translation(*r),
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");
102 if (action_id_univs_not_blocking(ACTION_IRRIGATE,
103 NULL, &for_terr)) {
104 fprintf(doc, "<tr><td>+%d F</td><td align=\"right\">(%d)</td></tr>\n",
105 pterrain->irrigation_food_incr, pterrain->irrigation_time);
106 } else {
107 fprintf(doc, "<tr><td>%s</td></tr>\n", _("impossible"));
108 }
109 if (pterrain->cultivate_result != NULL
110 && action_id_univs_not_blocking(ACTION_CULTIVATE,
111 NULL, &for_terr)) {
112 fprintf(doc, "<tr><td>%s</td><td align=\"right\">(%d)</td></tr>\n",
113 terrain_name_translation(pterrain->cultivate_result),
114 pterrain->cultivate_time);
115 } else {
116 fprintf(doc, "<tr><td>%s</td></tr>\n", _("impossible"));
117 }
118 if (action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr)) {
119 fprintf(doc, "<tr><td>+%d P</td><td align=\"right\">(%d)</td></tr>\n",
120 pterrain->mining_shield_incr, pterrain->mining_time);
121 } else {
122 fprintf(doc, "<tr><td>%s</td></tr>\n", _("impossible"));
123 }
124 if (pterrain->plant_result != NULL
125 && action_id_univs_not_blocking(ACTION_PLANT,
126 NULL, &for_terr)) {
127 fprintf(doc, "<tr><td>%s</td><td align=\"right\">(%d)</td></tr>\n",
128 terrain_name_translation(pterrain->plant_result),
129 pterrain->plant_time);
130 } else {
131 fprintf(doc, "<tr><td>%s</td></tr>\n", _("impossible"));
132 }
133
134 if (pterrain->transform_result
135 && action_id_univs_not_blocking(ACTION_TRANSFORM_TERRAIN,
136 NULL, &for_terr)) {
137 fprintf(doc, "<tr><td>%s</td><td align=\"right\">(%d)</td></tr>\n",
138 terrain_name_translation(pterrain->transform_result),
139 pterrain->transform_time);
140 } else {
141 fprintf(doc, "<tr><td>-</td><td align=\"right\">(-)</td></tr>\n");
142 }
143 fprintf(doc, "<tr><td>%d / %d / %d</td></tr>\n</table></td>\n",
144 pterrain->road_output_incr_pct[O_FOOD],
145 pterrain->road_output_incr_pct[O_SHIELD],
146 pterrain->road_output_incr_pct[O_TRADE]);
147
148 ri = 0;
149 if (game.control.num_road_types > 0) {
150 fprintf(doc, "<td>");
151 }
152 extra_type_by_cause_iterate(EC_ROAD, pextra) {
153 if (++ri < game.control.num_road_types) {
154 fprintf(doc, "%d / ", terrain_extra_build_time(pterrain, ACTIVITY_GEN_ROAD,
155 pextra));
156 } else {
157 fprintf(doc, "%d</td>", terrain_extra_build_time(pterrain, ACTIVITY_GEN_ROAD,
158 pextra));
159 }
160 } extra_type_by_cause_iterate_end;
161 fprintf(doc, "</tr><tr><td colspan=\"7\">\n%s\n</td></tr>\n\n", tag_info->hline);
162 } terrain_type_iterate_end;
163
164 fprintf(doc, "</table>\n");
165
166 manual_finalize(tag_info, doc, MANUAL_TERRAIN);
167
168 return TRUE;
169}
action_id_univs_not_blocking
#define action_id_univs_not_blocking(act_id, act_uni, tgt_uni)
Definition actions.h:685
incite_cost
char * incite_cost
Definition comments.c:74
extra_name_translation
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:194
extra_type_by_cause_iterate_end
#define extra_type_by_cause_iterate_end
Definition extras.h:339
extra_type_by_cause_iterate
#define extra_type_by_cause_iterate(_cause, _extra)
Definition extras.h:333
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
O_SHIELD
@ O_SHIELD
Definition fc_types.h:101
O_FOOD
@ O_FOOD
Definition fc_types.h:101
O_TRADE
@ O_TRADE
Definition fc_types.h:101
fcintl.h
_
#define _(String)
Definition fcintl.h:67
game
struct civ_game game
Definition game.c:62
game.h
manual_terrain
bool manual_terrain(struct tag_types *tag_info)
Definition manual_terrain.c:33
civ_game::control
struct packet_ruleset_control control
Definition game.h:83
extra_type
Definition extras.h:88
packet_ruleset_control::num_road_types
int num_road_types
Definition packets_gen.h:1465
packet_ruleset_control::name
char name[MAX_LEN_NAME]
Definition packets_gen.h:1484
tag_types
Definition fc_manual.h:28
universal
Definition fc_types.h:908
universal::kind
enum universals_n kind
Definition fc_types.h:910
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
terrain_name_translation
const char * terrain_name_translation(const struct terrain *pterrain)
Definition terrain.c:238
terrain_rule_name
const char * terrain_rule_name(const struct terrain *pterrain)
Definition terrain.c:247
terrain_extra_build_time
int terrain_extra_build_time(const struct terrain *pterrain, enum unit_activity activity, const struct extra_type *tgt)
Definition terrain.c:699
terrain_type_iterate
#define terrain_type_iterate(_p)
Definition terrain.h:266
terrain_type_iterate_end
#define terrain_type_iterate_end
Definition terrain.h:272