Freeciv-3.2: /fast/freeciv/nightly/S3_2/common/terrain.c Source File

Freeciv-3.2

Loading...
Searching...
No Matches
terrain.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2003 - The Freeciv Project
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#include "log.h" /* fc_assert */
21#include "mem.h" /* free */
22#include "rand.h"
23#include "shared.h"
24#include "string_vector.h"
25#include "support.h"
26
27/* common */
28#include "extras.h"
29#include "game.h"
30#include "map.h"
31#include "rgbcolor.h"
32#include "road.h"
33
34#include "terrain.h"
35
36 static struct terrain civ_terrains[MAX_NUM_TERRAINS];
37 static struct user_flag user_terrain_flags[MAX_NUM_USER_TER_FLAGS];
38
39/**********************************************************************/
42 void terrains_init(void)
43{
44 int i;
45
46 for (i = 0; i < ARRAY_SIZE(civ_terrains); i++) {
47 int j;
48
49 /* Can't use terrain_by_number here because it does a bounds check. */
50 civ_terrains[i].item_number = i;
51 civ_terrains[i].ruledit_disabled = FALSE;
52 civ_terrains[i].ruledit_dlg = NULL;
53 civ_terrains[i].rgb = NULL;
54 civ_terrains[i].animal = NULL;
55
56 for (j = 0; j < MAX_EXTRA_TYPES; j++) {
57 civ_terrains[i].extra_removal_times[j] = 0;
58 }
59 }
60}
61
62/**********************************************************************/
65 void terrains_free(void)
66{
67 terrain_type_iterate(pterrain) {
68 if (NULL != pterrain->helptext) {
69 strvec_destroy(pterrain->helptext);
70 pterrain->helptext = NULL;
71 }
72 if (pterrain->resources != NULL) {
73 /* Server allocates this on ruleset loading, client when
74 * ruleset packet is received. */
75 free(pterrain->resources);
76 pterrain->resources = NULL;
77 }
78 if (pterrain->resource_freq != NULL) {
79 /* Server allocates this on ruleset loading, client when
80 * ruleset packet is received. */
81 free(pterrain->resource_freq);
82 pterrain->resource_freq = NULL;
83 }
84 if (pterrain->rgb != NULL) {
85 /* Server allocates this on ruleset loading, client when
86 * ruleset packet is received. */
87 rgbcolor_destroy(pterrain->rgb);
88 pterrain->rgb = NULL;
89 }
90 } terrain_type_iterate_end;
91}
92
93/**********************************************************************/
96 struct terrain *terrain_array_first(void)
97{
98 if (game.control.terrain_count > 0) {
99 return civ_terrains;
100 }
101 return NULL;
102}
103
104/**********************************************************************/
107 const struct terrain *terrain_array_last(void)
108{
109 if (game.control.terrain_count > 0) {
110 return &civ_terrains[game.control.terrain_count - 1];
111 }
112 return NULL;
113}
114
115/**********************************************************************/
118 Terrain_type_id terrain_count(void)
119{
120 return game.control.terrain_count;
121}
122
123/**********************************************************************/
126 char terrain_identifier(const struct terrain *pterrain)
127{
128 fc_assert_ret_val(pterrain, '\0');
129 return pterrain->identifier;
130}
131
132/**********************************************************************/
138 Terrain_type_id terrain_index(const struct terrain *pterrain)
139{
140 fc_assert_ret_val(pterrain, -1);
141 return pterrain - civ_terrains;
142}
143
144/**********************************************************************/
147 Terrain_type_id terrain_number(const struct terrain *pterrain)
148{
149 fc_assert_ret_val(pterrain, -1);
150 return pterrain->item_number;
151}
152
153/**********************************************************************/
156 struct terrain *terrain_by_number(const Terrain_type_id type)
157{
158 if (type < 0 || type >= game.control.terrain_count) {
159 /* This isn't an error; some T_UNKNOWN callers depend on it. */
160 return NULL;
161 }
162 return &civ_terrains[type];
163}
164
165/**********************************************************************/
169 struct terrain *terrain_by_identifier(const char identifier)
170{
171 if (TERRAIN_UNKNOWN_IDENTIFIER == identifier) {
172 return T_UNKNOWN;
173 }
174 terrain_type_iterate(pterrain) {
175 if (pterrain->identifier == identifier) {
176 return pterrain;
177 }
178 } terrain_type_iterate_end;
179
180 return T_UNKNOWN;
181}
182
183/**********************************************************************/
186 struct terrain *terrain_by_rule_name(const char *name)
187{
188 const char *qname = Qn_(name);
189
190 terrain_type_iterate(pterrain) {
191 if (0 == fc_strcasecmp(terrain_rule_name(pterrain), qname)) {
192 return pterrain;
193 }
194 } terrain_type_iterate_end;
195
196 return T_UNKNOWN;
197}
198
199/**********************************************************************/
202 struct terrain *terrain_by_translated_name(const char *name)
203{
204 terrain_type_iterate(pterrain) {
205 if (0 == strcmp(terrain_name_translation(pterrain), name)) {
206 return pterrain;
207 }
208 } terrain_type_iterate_end;
209
210 return T_UNKNOWN;
211}
212
213/**********************************************************************/
217 struct terrain *rand_terrain_by_flag(enum terrain_flag_id flag)
218{
219 int num = 0;
220 struct terrain *terr = NULL;
221
222 terrain_type_iterate(pterr) {
223 if (terrain_has_flag(pterr, flag)) {
224 num++;
225 if (fc_rand(num) == 1) {
226 terr = pterr;
227 }
228 }
229 } terrain_type_iterate_end;
230
231 return terr;
232}
233
234/**********************************************************************/
238 const char *terrain_name_translation(const struct terrain *pterrain)
239{
240 return name_translation_get(&pterrain->name);
241}
242
243/**********************************************************************/
247 const char *terrain_rule_name(const struct terrain *pterrain)
248{
249 return rule_name_get(&pterrain->name);
250}
251
252/**********************************************************************/
255 bool terrain_has_resource(const struct terrain *pterrain,
256 const struct extra_type *presource)
257{
258 struct extra_type **r = pterrain->resources;
259
260 while (NULL != *r) {
261 if (*r == presource) {
262 return TRUE;
263 }
264 r++;
265 }
266 return FALSE;
267}
268
269/**********************************************************************/
272 struct resource_type *resource_type_init(struct extra_type *pextra)
273{
274 struct resource_type *presource;
275
276 presource = fc_malloc(sizeof(*presource));
277
278 pextra->data.resource = presource;
279
280 presource->self = pextra;
281
282 return presource;
283}
284
285/**********************************************************************/
288 void resource_types_free(void)
289{
290 /* Resource structure itself is freed as part of extras destruction. */
291}
292
293/**********************************************************************/
296 struct extra_type *resource_extra_get(const struct resource_type *presource)
297{
298 return presource->self;
299}
300
301/**********************************************************************/
305#define variable_adjc_iterate(nmap, center_tile, _tile, card_only) \
306{ \
307 enum direction8 *_tile##_list; \
308 int _tile##_count; \
309 \
310 if (card_only) { \
311 _tile##_list = wld.map.cardinal_dirs; \
312 _tile##_count = wld.map.num_cardinal_dirs; \
313 } else { \
314 _tile##_list = wld.map.valid_dirs; \
315 _tile##_count = wld.map.num_valid_dirs; \
316 } \
317 adjc_dirlist_iterate(nmap, center_tile, _tile, _tile##_dir, \
318 _tile##_list, _tile##_count) {
319
320#define variable_adjc_iterate_end \
321 } adjc_dirlist_iterate_end; \
322}
323
324/**********************************************************************/
327 bool is_terrain_card_near(const struct civ_map *nmap,
328 const struct tile *ptile,
329 const struct terrain *pterrain,
330 bool check_self)
331{
332 if (pterrain == NULL) {
333 return FALSE;
334 }
335
336 cardinal_adjc_iterate(nmap, ptile, adjc_tile) {
337 if (tile_terrain(adjc_tile) == pterrain) {
338 return TRUE;
339 }
340 } cardinal_adjc_iterate_end;
341
342 return check_self && ptile->terrain == pterrain;
343}
344
345/**********************************************************************/
348 bool is_terrain_near_tile(const struct civ_map *nmap,
349 const struct tile *ptile,
350 const struct terrain *pterrain,
351 bool check_self)
352{
353 if (pterrain == NULL) {
354 return FALSE;
355 }
356
357 adjc_iterate(nmap, ptile, adjc_tile) {
358 if (tile_terrain(adjc_tile) == pterrain) {
359 return TRUE;
360 }
361 } adjc_iterate_end;
362
363 return check_self && ptile->terrain == pterrain;
364}
365
366/**********************************************************************/
369 int count_terrain_property_near_tile(const struct civ_map *nmap,
370 const struct tile *ptile,
371 bool cardinal_only, bool percentage,
372 enum mapgen_terrain_property prop)
373{
374 int count = 0, total = 0;
375
376 variable_adjc_iterate(nmap, ptile, adjc_tile, cardinal_only) {
377 struct terrain *pterrain = tile_terrain(adjc_tile);
378
379 if (pterrain->property[prop] > 0) {
380 count++;
381 }
382 total++;
383 } variable_adjc_iterate_end;
384
385 if (percentage && count > 0) { /* Latter condition avoids div by zero */
386 count = count * 100 / total;
387 }
388
389 return count;
390}
391
392/**********************************************************************/
395 bool is_resource_card_near(const struct civ_map *nmap,
396 const struct tile *ptile,
397 const struct extra_type *pres,
398 bool check_self)
399{
400 if (pres == NULL) {
401 return FALSE;
402 }
403
404 cardinal_adjc_iterate(nmap, ptile, adjc_tile) {
405 if (tile_resource(adjc_tile) == pres) {
406 return TRUE;
407 }
408 } cardinal_adjc_iterate_end;
409
410 return check_self && tile_resource(ptile) == pres;
411}
412
413/**********************************************************************/
416 bool is_resource_near_tile(const struct civ_map *nmap,
417 const struct tile *ptile,
418 const struct extra_type *pres,
419 bool check_self)
420{
421 if (pres == NULL) {
422 return FALSE;
423 }
424
425 adjc_iterate(nmap, ptile, adjc_tile) {
426 if (tile_resource(adjc_tile) == pres) {
427 return TRUE;
428 }
429 } adjc_iterate_end;
430
431 return check_self && tile_resource(ptile) == pres;
432}
433
434/**********************************************************************/
438 bool is_terrain_flag_card_near(const struct civ_map *nmap,
439 const struct tile *ptile,
440 enum terrain_flag_id flag)
441{
442 cardinal_adjc_iterate(nmap, ptile, adjc_tile) {
443 struct terrain* pterrain = tile_terrain(adjc_tile);
444
445 if (T_UNKNOWN != pterrain
446 && terrain_has_flag(pterrain, flag)) {
447 return TRUE;
448 }
449 } cardinal_adjc_iterate_end;
450
451 return FALSE;
452}
453
454/**********************************************************************/
458 bool is_terrain_flag_near_tile(const struct civ_map *nmap,
459 const struct tile *ptile,
460 enum terrain_flag_id flag)
461{
462 adjc_iterate(nmap, ptile, adjc_tile) {
463 struct terrain* pterrain = tile_terrain(adjc_tile);
464
465 if (T_UNKNOWN != pterrain
466 && terrain_has_flag(pterrain, flag)) {
467 return TRUE;
468 }
469 } adjc_iterate_end;
470
471 return FALSE;
472}
473
474/**********************************************************************/
478 int count_terrain_flag_near_tile(const struct civ_map *nmap,
479 const struct tile *ptile,
480 bool cardinal_only, bool percentage,
481 enum terrain_flag_id flag)
482{
483 int count = 0, total = 0;
484
485 variable_adjc_iterate(nmap, ptile, adjc_tile, cardinal_only) {
486 struct terrain *pterrain = tile_terrain(adjc_tile);
487
488 if (T_UNKNOWN != pterrain
489 && terrain_has_flag(pterrain, flag)) {
490 count++;
491 }
492 total++;
493 } variable_adjc_iterate_end;
494
495 if (percentage && count > 0) { /* Latter condition avoids div by zero */
496 count = count * 100 / total;
497 }
498
499 return count;
500}
501
502/**********************************************************************/
508 const char *get_infrastructure_text(bv_extras extras)
509{
510 static char s[256];
511 char *p;
512 int len;
513
514 s[0] = '\0';
515
516 extra_type_iterate(pextra) {
517 if (pextra->category == ECAT_INFRA
518 && BV_ISSET(extras, extra_index(pextra))) {
519 bool hidden = FALSE;
520
521 extra_type_iterate(top) {
522 int topi = extra_index(top);
523
524 if (BV_ISSET(pextra->hidden_by, topi)
525 && BV_ISSET(extras, topi)) {
526 hidden = TRUE;
527 break;
528 }
529 } extra_type_iterate_end;
530
531 if (!hidden) {
532 cat_snprintf(s, sizeof(s), "%s/", extra_name_translation(pextra));
533 }
534 }
535 } extra_type_iterate_end;
536
537 len = strlen(s);
538 p = s + len - 1;
539 if (len > 0 && *p == '/') {
540 *p = '\0';
541 }
542
543 return s;
544}
545
546/**********************************************************************/
550 struct extra_type *get_preferred_pillage(bv_extras extras)
551{
552 /* Semi-arbitrary preference order reflecting previous behavior */
553 static const enum extra_cause prefs[] = {
554 EC_IRRIGATION,
555 EC_MINE,
556 EC_BASE,
557 EC_ROAD,
558 EC_HUT,
559 EC_APPEARANCE,
560 EC_POLLUTION,
561 EC_FALLOUT,
562 EC_RESOURCE,
563 EC_NONE
564 };
565 int i;
566
567 for (i = 0; i < ARRAY_SIZE(prefs); i++) {
568 extra_type_by_cause_iterate_rev(prefs[i], pextra) {
569 if (is_extra_removed_by(pextra, ERM_PILLAGE)
570 && BV_ISSET(extras, extra_index(pextra))) {
571 return pextra;
572 }
573 } extra_type_by_cause_iterate_rev_end;
574 }
575
576 return NULL;
577}
578
579/**********************************************************************/
582 enum terrain_class terrain_type_terrain_class(const struct terrain *pterrain)
583{
584 return pterrain->tclass;
585}
586
587/**********************************************************************/
591 bool is_terrain_class_card_near(const struct civ_map *nmap,
592 const struct tile *ptile,
593 enum terrain_class tclass)
594{
595 cardinal_adjc_iterate(nmap, ptile, adjc_tile) {
596 struct terrain* pterrain = tile_terrain(adjc_tile);
597
598 if (pterrain != T_UNKNOWN) {
599 if (terrain_type_terrain_class(pterrain) == tclass) {
600 return TRUE;
601 }
602 }
603 } cardinal_adjc_iterate_end;
604
605 return FALSE;
606}
607
608/**********************************************************************/
612 bool is_terrain_class_near_tile(const struct civ_map *nmap,
613 const struct tile *ptile,
614 enum terrain_class tclass)
615{
616 adjc_iterate(nmap, ptile, adjc_tile) {
617 struct terrain* pterrain = tile_terrain(adjc_tile);
618
619 if (pterrain != T_UNKNOWN) {
620 if (terrain_type_terrain_class(pterrain) == tclass) {
621 return TRUE;
622 }
623 }
624 } adjc_iterate_end;
625
626 return FALSE;
627}
628
629/**********************************************************************/
633 int count_terrain_class_near_tile(const struct civ_map *nmap,
634 const struct tile *ptile,
635 bool cardinal_only, bool percentage,
636 enum terrain_class tclass)
637{
638 int count = 0, total = 0;
639
640 variable_adjc_iterate(nmap, ptile, adjc_tile, cardinal_only) {
641 struct terrain *pterrain = tile_terrain(adjc_tile);
642
643 if (T_UNKNOWN != pterrain
644 && terrain_type_terrain_class(pterrain) == tclass) {
645 count++;
646 }
647 total++;
648 } variable_adjc_iterate_end;
649
650 if (percentage && count > 0) { /* Latter condition avoids div by zero */
651 count = count * 100 / total;
652 }
653
654 return count;
655}
656
657/**********************************************************************/
661 const char *terrain_class_name_translation(enum terrain_class tclass)
662{
663 if (!terrain_class_is_valid(tclass)) {
664 return NULL;
665 }
666
667 return _(terrain_class_name(tclass));
668}
669
670/**********************************************************************/
673 bool terrain_can_support_alteration(const struct terrain *pterrain,
674 enum terrain_alteration alter)
675{
676 switch (alter) {
677 case TA_CAN_IRRIGATE:
678 return (pterrain->irrigation_time > 0);
679 case TA_CAN_MINE:
680 return (pterrain->mining_time > 0);
681 case TA_CAN_ROAD:
682 return (pterrain->road_time > 0);
683 case TA_CAN_BASE:
684 return (pterrain->base_time > 0);
685 case TA_CAN_PLACE:
686 return (pterrain->placing_time > 0);
687 default:
688 break;
689 }
690
691 fc_assert(FALSE);
692
693 return FALSE;
694}
695
696/**********************************************************************/
699 int terrain_extra_build_time(const struct terrain *pterrain,
700 enum unit_activity activity,
701 const struct extra_type *tgt)
702{
703 int factor;
704
705 if (tgt != NULL && tgt->build_time != 0) {
706 /* Extra specific build time */
707 return tgt->build_time;
708 }
709
710 if (tgt == NULL) {
711 factor = 1;
712 } else {
713 factor = tgt->build_time_factor;
714 }
715
716 /* Terrain and activity specific build time */
717 switch (activity) {
718 case ACTIVITY_BASE:
719 return pterrain->base_time * factor;
720 case ACTIVITY_GEN_ROAD:
721 return pterrain->road_time * factor;
722 case ACTIVITY_IRRIGATE:
723 return pterrain->irrigation_time * factor;
724 case ACTIVITY_MINE:
725 return pterrain->mining_time * factor;
726 default:
727 fc_assert(FALSE);
728 return 0;
729 }
730}
731
732/**********************************************************************/
735 int terrain_extra_removal_time(const struct terrain *pterrain,
736 enum unit_activity activity,
737 const struct extra_type *tgt)
738{
739 int factor;
740
741 if (tgt->removal_time != 0) {
742 /* Extra specific removal time */
743 return tgt->removal_time;
744 }
745
746 factor = tgt->removal_time_factor;
747
748 /* Terrain and activity specific removal time */
749 switch (activity) {
750 case ACTIVITY_CLEAN:
751 return pterrain->extra_removal_times[extra_index(tgt)] * factor;
752 case ACTIVITY_PILLAGE:
753 return pterrain->pillage_time * factor;
754 default:
755 fc_assert(FALSE);
756
757 return 0;
758 }
759}
760
761/**********************************************************************/
764 void user_terrain_flags_init(void)
765{
766 int i;
767
768 for (i = 0; i < MAX_NUM_USER_TER_FLAGS; i++) {
769 user_flag_init(&user_terrain_flags[i]);
770 }
771}
772
773/**********************************************************************/
776 void user_terrain_flags_free(void)
777{
778 int i;
779
780 for (i = 0; i < MAX_NUM_USER_TER_FLAGS; i++) {
781 user_flag_free(&user_terrain_flags[i]);
782 }
783}
784
785/**********************************************************************/
788 void set_user_terrain_flag_name(enum terrain_flag_id id, const char *name,
789 const char *helptxt)
790{
791 int tfid = id - TER_USER_1;
792
793 fc_assert_ret(id >= TER_USER_1 && id <= TER_USER_LAST);
794
795 if (user_terrain_flags[tfid].name != NULL) {
796 FC_FREE(user_terrain_flags[tfid].name);
797 user_terrain_flags[tfid].name = NULL;
798 }
799
800 if (name && name[0] != '\0') {
801 user_terrain_flags[tfid].name = fc_strdup(name);
802 }
803
804 if (user_terrain_flags[tfid].helptxt != NULL) {
805 FC_FREE(user_terrain_flags[tfid].helptxt);
806 user_terrain_flags[tfid].helptxt = NULL;
807 }
808
809 if (helptxt && helptxt[0] != '\0') {
810 user_terrain_flags[tfid].helptxt = fc_strdup(helptxt);
811 }
812}
813
814/**********************************************************************/
817 const char *terrain_flag_id_name_cb(enum terrain_flag_id flag)
818{
819 if (flag < TER_USER_1 || flag > TER_USER_LAST) {
820 return NULL;
821 }
822
823 return user_terrain_flags[flag-TER_USER_1].name;
824}
825
826/**********************************************************************/
829 const char *terrain_flag_helptxt(enum terrain_flag_id id)
830{
831 fc_assert(id >= TER_USER_1 && id <= TER_USER_LAST);
832
833 return user_terrain_flags[id - TER_USER_1].helptxt;
834}
BV_ISSET
#define BV_ISSET(bv, bit)
Definition bitvector.h:78
incite_cost
char * incite_cost
Definition comments.c:74
extras
static struct extra_type extras[MAX_EXTRA_TYPES]
Definition extras.c:31
is_extra_removed_by
bool is_extra_removed_by(const struct extra_type *pextra, enum extra_rmcause rmcause)
Definition extras.c:353
extra_name_translation
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:194
extras.h
extra_type_by_cause_iterate_rev
#define extra_type_by_cause_iterate_rev(_cause, _extra)
Definition extras.h:344
extra_type_by_cause_iterate_rev_end
#define extra_type_by_cause_iterate_rev_end
Definition extras.h:349
extra_type_iterate
#define extra_type_iterate(_p)
Definition extras.h:315
extra_type_iterate_end
#define extra_type_iterate_end
Definition extras.h:321
extra_index
#define extra_index(_e_)
Definition extras.h:183
Terrain_type_id
int Terrain_type_id
Definition fc_types.h:376
EC_NONE
#define EC_NONE
Definition fc_types.h:1114
MAX_EXTRA_TYPES
#define MAX_EXTRA_TYPES
Definition fc_types.h:50
fcintl.h
_
#define _(String)
Definition fcintl.h:67
Qn_
#define Qn_(String)
Definition fcintl.h:89
user_flag_init
void user_flag_init(struct user_flag *flag)
Definition game.c:822
user_flag_free
void user_flag_free(struct user_flag *flag)
Definition game.c:831
game
struct civ_game game
Definition game.c:62
game.h
type
GType type
Definition repodlgs.c:1313
name
const char * name
Definition inputfile.c:127
log.h
fc_assert_ret
#define fc_assert_ret(condition)
Definition log.h:191
fc_assert
#define fc_assert(condition)
Definition log.h:176
fc_assert_ret_val
#define fc_assert_ret_val(condition, val)
Definition log.h:194
map.h
adjc_iterate_end
#define adjc_iterate_end
Definition map.h:433
cardinal_adjc_iterate_end
#define cardinal_adjc_iterate_end
Definition map.h:459
adjc_iterate
#define adjc_iterate(nmap, center_tile, itr_tile)
Definition map.h:428
cardinal_adjc_iterate
#define cardinal_adjc_iterate(nmap, center_tile, itr_tile)
Definition map.h:455
mem.h
FC_FREE
#define FC_FREE(ptr)
Definition mem.h:41
fc_strdup
#define fc_strdup(str)
Definition mem.h:43
fc_malloc
#define fc_malloc(sz)
Definition mem.h:34
rule_name_get
static const char * rule_name_get(const struct name_translation *ptrans)
Definition name_translation.h:112
name_translation_get
static const char * name_translation_get(const struct name_translation *ptrans)
Definition name_translation.h:121
len
int len
Definition packhand.c:127
rand.h
fc_rand
#define fc_rand(_size)
Definition rand.h:56
rgbcolor_destroy
void rgbcolor_destroy(struct rgbcolor *prgbcolor)
Definition rgbcolor.c:74
rgbcolor.h
road.h
shared.h
ARRAY_SIZE
#define ARRAY_SIZE(x)
Definition shared.h:85
strvec_destroy
void strvec_destroy(struct strvec *psv)
Definition string_vector.c:71
string_vector.h
civ_game::control
struct packet_ruleset_control control
Definition game.h:83
civ_map
Definition map_types.h:71
extra_type
Definition extras.h:88
extra_type::resource
struct resource_type * resource
Definition extras.h:156
extra_type::data
struct extra_type::@25 data
extra_type::removal_time
int removal_time
Definition extras.h:120
extra_type::build_time_factor
int build_time_factor
Definition extras.h:119
extra_type::removal_time_factor
int removal_time_factor
Definition extras.h:121
extra_type::build_time
int build_time
Definition extras.h:118
packet_ruleset_control::terrain_count
int terrain_count
Definition packets_gen.h:1467
resource_type
Definition terrain.h:43
resource_type::self
struct extra_type * self
Definition terrain.h:51
terrain
Definition terrain.h:182
terrain::placing_time
int placing_time
Definition terrain.h:227
terrain::property
int property[MG_COUNT]
Definition terrain.h:253
terrain::resources
struct extra_type ** resources
Definition terrain.h:204
terrain::item_number
int item_number
Definition terrain.h:183
terrain::road_time
int road_time
Definition terrain.h:213
terrain::name
struct name_translation name
Definition terrain.h:184
terrain::animal
const struct unit_type * animal
Definition terrain.h:237
terrain::pillage_time
int pillage_time
Definition terrain.h:232
terrain::mining_time
int mining_time
Definition terrain.h:225
terrain::rgb
struct rgbcolor * rgb
Definition terrain.h:261
terrain::tclass
enum terrain_class tclass
Definition terrain.h:197
terrain::extra_removal_times
int extra_removal_times[MAX_EXTRA_TYPES]
Definition terrain.h:235
terrain::irrigation_time
int irrigation_time
Definition terrain.h:222
terrain::base_time
int base_time
Definition terrain.h:212
terrain::ruledit_dlg
void * ruledit_dlg
Definition terrain.h:186
terrain::identifier
char identifier
Definition terrain.h:191
terrain::ruledit_disabled
bool ruledit_disabled
Definition terrain.h:185
tile
Definition tile.h:50
tile::terrain
struct terrain * terrain
Definition tile.h:57
user_flag
Definition game.h:73
user_flag::name
char * name
Definition game.h:74
user_flag::helptxt
char * helptxt
Definition game.h:75
fc_strcasecmp
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:189
cat_snprintf
int cat_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:1000
support.h
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
terrain_extra_removal_time
int terrain_extra_removal_time(const struct terrain *pterrain, enum unit_activity activity, const struct extra_type *tgt)
Definition terrain.c:735
user_terrain_flags_init
void user_terrain_flags_init(void)
Definition terrain.c:764
terrains_free
void terrains_free(void)
Definition terrain.c:65
terrain_by_rule_name
struct terrain * terrain_by_rule_name(const char *name)
Definition terrain.c:186
is_terrain_class_near_tile
bool is_terrain_class_near_tile(const struct civ_map *nmap, const struct tile *ptile, enum terrain_class tclass)
Definition terrain.c:612
terrain_identifier
char terrain_identifier(const struct terrain *pterrain)
Definition terrain.c:126
terrain_count
Terrain_type_id terrain_count(void)
Definition terrain.c:118
terrains_init
void terrains_init(void)
Definition terrain.c:42
resource_extra_get
struct extra_type * resource_extra_get(const struct resource_type *presource)
Definition terrain.c:296
count_terrain_class_near_tile
int count_terrain_class_near_tile(const struct civ_map *nmap, const struct tile *ptile, bool cardinal_only, bool percentage, enum terrain_class tclass)
Definition terrain.c:633
is_terrain_class_card_near
bool is_terrain_class_card_near(const struct civ_map *nmap, const struct tile *ptile, enum terrain_class tclass)
Definition terrain.c:591
terrain_by_translated_name
struct terrain * terrain_by_translated_name(const char *name)
Definition terrain.c:202
terrain_class_name_translation
const char * terrain_class_name_translation(enum terrain_class tclass)
Definition terrain.c:661
count_terrain_flag_near_tile
int count_terrain_flag_near_tile(const struct civ_map *nmap, const struct tile *ptile, bool cardinal_only, bool percentage, enum terrain_flag_id flag)
Definition terrain.c:478
get_infrastructure_text
const char * get_infrastructure_text(bv_extras extras)
Definition terrain.c:508
terrain_flag_id_name_cb
const char * terrain_flag_id_name_cb(enum terrain_flag_id flag)
Definition terrain.c:817
terrain_index
Terrain_type_id terrain_index(const struct terrain *pterrain)
Definition terrain.c:138
is_resource_card_near
bool is_resource_card_near(const struct civ_map *nmap, const struct tile *ptile, const struct extra_type *pres, bool check_self)
Definition terrain.c:395
terrain_name_translation
const char * terrain_name_translation(const struct terrain *pterrain)
Definition terrain.c:238
variable_adjc_iterate
#define variable_adjc_iterate(nmap, center_tile, _tile, card_only)
Definition terrain.c:305
terrain_array_first
struct terrain * terrain_array_first(void)
Definition terrain.c:96
rand_terrain_by_flag
struct terrain * rand_terrain_by_flag(enum terrain_flag_id flag)
Definition terrain.c:217
terrain_by_number
struct terrain * terrain_by_number(const Terrain_type_id type)
Definition terrain.c:156
terrain_can_support_alteration
bool terrain_can_support_alteration(const struct terrain *pterrain, enum terrain_alteration alter)
Definition terrain.c:673
is_terrain_card_near
bool is_terrain_card_near(const struct civ_map *nmap, const struct tile *ptile, const struct terrain *pterrain, bool check_self)
Definition terrain.c:327
terrain_rule_name
const char * terrain_rule_name(const struct terrain *pterrain)
Definition terrain.c:247
is_resource_near_tile
bool is_resource_near_tile(const struct civ_map *nmap, const struct tile *ptile, const struct extra_type *pres, bool check_self)
Definition terrain.c:416
resource_types_free
void resource_types_free(void)
Definition terrain.c:288
user_terrain_flags_free
void user_terrain_flags_free(void)
Definition terrain.c:776
terrain_type_terrain_class
enum terrain_class terrain_type_terrain_class(const struct terrain *pterrain)
Definition terrain.c:582
terrain_flag_helptxt
const char * terrain_flag_helptxt(enum terrain_flag_id id)
Definition terrain.c:829
terrain_has_resource
bool terrain_has_resource(const struct terrain *pterrain, const struct extra_type *presource)
Definition terrain.c:255
resource_type_init
struct resource_type * resource_type_init(struct extra_type *pextra)
Definition terrain.c:272
is_terrain_flag_near_tile
bool is_terrain_flag_near_tile(const struct civ_map *nmap, const struct tile *ptile, enum terrain_flag_id flag)
Definition terrain.c:458
get_preferred_pillage
struct extra_type * get_preferred_pillage(bv_extras extras)
Definition terrain.c:550
set_user_terrain_flag_name
void set_user_terrain_flag_name(enum terrain_flag_id id, const char *name, const char *helptxt)
Definition terrain.c:788
terrain_array_last
const struct terrain * terrain_array_last(void)
Definition terrain.c:107
civ_terrains
static struct terrain civ_terrains[MAX_NUM_TERRAINS]
Definition terrain.c:36
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
user_terrain_flags
static struct user_flag user_terrain_flags[MAX_NUM_USER_TER_FLAGS]
Definition terrain.c:37
terrain_number
Terrain_type_id terrain_number(const struct terrain *pterrain)
Definition terrain.c:147
terrain_by_identifier
struct terrain * terrain_by_identifier(const char identifier)
Definition terrain.c:169
is_terrain_flag_card_near
bool is_terrain_flag_card_near(const struct civ_map *nmap, const struct tile *ptile, enum terrain_flag_id flag)
Definition terrain.c:438
count_terrain_property_near_tile
int count_terrain_property_near_tile(const struct civ_map *nmap, const struct tile *ptile, bool cardinal_only, bool percentage, enum mapgen_terrain_property prop)
Definition terrain.c:369
variable_adjc_iterate_end
#define variable_adjc_iterate_end
Definition terrain.c:320
is_terrain_near_tile
bool is_terrain_near_tile(const struct civ_map *nmap, const struct tile *ptile, const struct terrain *pterrain, bool check_self)
Definition terrain.c:348
terrain.h
terrain_type_iterate
#define terrain_type_iterate(_p)
Definition terrain.h:373
T_UNKNOWN
#define T_UNKNOWN
Definition terrain.h:57
TERRAIN_UNKNOWN_IDENTIFIER
#define TERRAIN_UNKNOWN_IDENTIFIER
Definition terrain.h:195
terrain_type_iterate_end
#define terrain_type_iterate_end
Definition terrain.h:379
MAX_NUM_TERRAINS
#define MAX_NUM_TERRAINS
Definition terrain.h:64
terrain_has_flag
#define terrain_has_flag(terr, flag)
Definition terrain.h:283
MAX_NUM_USER_TER_FLAGS
#define MAX_NUM_USER_TER_FLAGS
Definition terrain.h:152
tile_resource
#define tile_resource(_tile)
Definition tile.h:102
tile_terrain
#define tile_terrain(_tile)
Definition tile.h:110