Freeciv-3.1
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
38
39/**********************************************************************/
42void terrains_init(void)
43{
44 int i;
45
46 for (i = 0; i < ARRAY_SIZE(civ_terrains); i++) {
47 /* Can't use terrain_by_number here because it does a bounds check. */
50 civ_terrains[i].ruledit_dlg = NULL;
51 civ_terrains[i].rgb = NULL;
52 civ_terrains[i].animal = NULL;
53 }
54}
55
56/**********************************************************************/
59void terrains_free(void)
60{
61 terrain_type_iterate(pterrain) {
62 if (NULL != pterrain->helptext) {
63 strvec_destroy(pterrain->helptext);
64 pterrain->helptext = NULL;
65 }
66 if (pterrain->resources != NULL) {
67 /* Server allocates this on ruleset loading, client when
68 * ruleset packet is received. */
69 free(pterrain->resources);
70 pterrain->resources = NULL;
71 }
72 if (pterrain->rgb != NULL) {
73 /* Server allocates this on ruleset loading, client when
74 * ruleset packet is received. */
75 rgbcolor_destroy(pterrain->rgb);
76 pterrain->rgb = NULL;
77 }
79}
80
81/**********************************************************************/
85{
86 if (game.control.terrain_count > 0) {
87 return civ_terrains;
88 }
89 return NULL;
90}
91
92/**********************************************************************/
95const struct terrain *terrain_array_last(void)
96{
97 if (game.control.terrain_count > 0) {
99 }
100 return NULL;
101}
102
103/**********************************************************************/
110
111/**********************************************************************/
114char terrain_identifier(const struct terrain *pterrain)
115{
116 fc_assert_ret_val(pterrain, '\0');
117 return pterrain->identifier;
118}
119
120/**********************************************************************/
126Terrain_type_id terrain_index(const struct terrain *pterrain)
127{
128 fc_assert_ret_val(pterrain, -1);
129 return pterrain - civ_terrains;
130}
131
132/**********************************************************************/
136{
137 fc_assert_ret_val(pterrain, -1);
138 return pterrain->item_number;
139}
140
141/**********************************************************************/
145{
146 if (type < 0 || type >= game.control.terrain_count) {
147 /* This isn't an error; some T_UNKNOWN callers depend on it. */
148 return NULL;
149 }
150 return &civ_terrains[type];
151}
152
153/**********************************************************************/
158{
160 return T_UNKNOWN;
161 }
162 terrain_type_iterate(pterrain) {
163 if (pterrain->identifier == identifier) {
164 return pterrain;
165 }
167
168 return T_UNKNOWN;
169}
170
171/**********************************************************************/
175{
176 const char *qname = Qn_(name);
177
178 terrain_type_iterate(pterrain) {
179 if (0 == fc_strcasecmp(terrain_rule_name(pterrain), qname)) {
180 return pterrain;
181 }
183
184 return T_UNKNOWN;
185}
186
187/**********************************************************************/
191{
192 terrain_type_iterate(pterrain) {
193 if (0 == strcmp(terrain_name_translation(pterrain), name)) {
194 return pterrain;
195 }
197
198 return T_UNKNOWN;
199}
200
201/**********************************************************************/
205struct terrain *rand_terrain_by_flag(enum terrain_flag_id flag)
206{
207 int num = 0;
208 struct terrain *terr = NULL;
209
210 terrain_type_iterate(pterr) {
211 if (terrain_has_flag(pterr, flag)) {
212 num++;
213 if (fc_rand(num) == 1) {
214 terr = pterr;
215 }
216 }
218
219 return terr;
220}
221
222/**********************************************************************/
226const char *terrain_name_translation(const struct terrain *pterrain)
227{
228 return name_translation_get(&pterrain->name);
229}
230
231/**********************************************************************/
235const char *terrain_rule_name(const struct terrain *pterrain)
236{
237 return rule_name_get(&pterrain->name);
238}
239
240/**********************************************************************/
243bool terrain_has_resource(const struct terrain *pterrain,
244 const struct extra_type *presource)
245{
246 struct extra_type **r = pterrain->resources;
247
248 while (NULL != *r) {
249 if (*r == presource) {
250 return TRUE;
251 }
252 r++;
253 }
254 return FALSE;
255}
256
257/**********************************************************************/
261{
262 struct resource_type *presource;
263
264 presource = fc_malloc(sizeof(*presource));
265
266 pextra->data.resource = presource;
267
268 presource->self = pextra;
269
270 return presource;
271}
272
273/**********************************************************************/
277{
278 /* Resource structure itself is freed as part of extras destruction. */
279}
280
281/**********************************************************************/
284struct extra_type *resource_extra_get(const struct resource_type *presource)
285{
286 return presource->self;
287}
288
289/**********************************************************************/
293#define variable_adjc_iterate(nmap, center_tile, _tile, card_only) \
294{ \
295 enum direction8 *_tile##_list; \
296 int _tile##_count; \
297 \
298 if (card_only) { \
299 _tile##_list = wld.map.cardinal_dirs; \
300 _tile##_count = wld.map.num_cardinal_dirs; \
301 } else { \
302 _tile##_list = wld.map.valid_dirs; \
303 _tile##_count = wld.map.num_valid_dirs; \
304 } \
305 adjc_dirlist_iterate(nmap, center_tile, _tile, _tile##_dir, \
306 _tile##_list, _tile##_count) {
307
308#define variable_adjc_iterate_end \
309 } adjc_dirlist_iterate_end; \
310}
311
312/**********************************************************************/
315bool is_terrain_card_near(const struct civ_map *nmap,
316 const struct tile *ptile,
317 const struct terrain *pterrain,
318 bool check_self)
319{
320 if (pterrain == NULL) {
321 return FALSE;
322 }
323
324 cardinal_adjc_iterate(nmap, ptile, adjc_tile) {
325 if (tile_terrain(adjc_tile) == pterrain) {
326 return TRUE;
327 }
329
330 return check_self && ptile->terrain == pterrain;
331}
332
333/**********************************************************************/
336bool is_terrain_near_tile(const struct civ_map *nmap,
337 const struct tile *ptile,
338 const struct terrain *pterrain,
339 bool check_self)
340{
341 if (pterrain == NULL) {
342 return FALSE;
343 }
344
345 adjc_iterate(nmap, ptile, adjc_tile) {
346 if (tile_terrain(adjc_tile) == pterrain) {
347 return TRUE;
348 }
350
351 return check_self && ptile->terrain == pterrain;
352}
353
354/**********************************************************************/
358 const struct tile *ptile,
359 bool cardinal_only, bool percentage,
360 enum mapgen_terrain_property prop)
361{
362 int count = 0, total = 0;
363
364 variable_adjc_iterate(nmap, ptile, adjc_tile, cardinal_only) {
365 struct terrain *pterrain = tile_terrain(adjc_tile);
366
367 if (pterrain->property[prop] > 0) {
368 count++;
369 }
370 total++;
372
373 if (percentage && count > 0) { /* Latter condition avoids div by zero */
374 count = count * 100 / total;
375 }
376
377 return count;
378}
379
380/**********************************************************************/
383bool is_resource_card_near(const struct civ_map *nmap,
384 const struct tile *ptile,
385 const struct extra_type *pres,
386 bool check_self)
387{
388 if (pres == NULL) {
389 return FALSE;
390 }
391
392 cardinal_adjc_iterate(nmap, ptile, adjc_tile) {
393 if (tile_resource(adjc_tile) == pres) {
394 return TRUE;
395 }
397
398 return check_self && tile_resource(ptile) == pres;
399}
400
401/**********************************************************************/
404bool is_resource_near_tile(const struct civ_map *nmap,
405 const struct tile *ptile,
406 const struct extra_type *pres,
407 bool check_self)
408{
409 if (pres == NULL) {
410 return FALSE;
411 }
412
413 adjc_iterate(nmap, ptile, adjc_tile) {
414 if (tile_resource(adjc_tile) == pres) {
415 return TRUE;
416 }
418
419 return check_self && tile_resource(ptile) == pres;
420}
421
422/**********************************************************************/
426bool is_terrain_flag_card_near(const struct civ_map *nmap,
427 const struct tile *ptile,
428 enum terrain_flag_id flag)
429{
430 cardinal_adjc_iterate(nmap, ptile, adjc_tile) {
431 struct terrain* pterrain = tile_terrain(adjc_tile);
432
433 if (T_UNKNOWN != pterrain
434 && terrain_has_flag(pterrain, flag)) {
435 return TRUE;
436 }
438
439 return FALSE;
440}
441
442/**********************************************************************/
446bool is_terrain_flag_near_tile(const struct civ_map *nmap,
447 const struct tile *ptile,
448 enum terrain_flag_id flag)
449{
450 adjc_iterate(nmap, ptile, adjc_tile) {
451 struct terrain* pterrain = tile_terrain(adjc_tile);
452
453 if (T_UNKNOWN != pterrain
454 && terrain_has_flag(pterrain, flag)) {
455 return TRUE;
456 }
458
459 return FALSE;
460}
461
462/**********************************************************************/
467 const struct tile *ptile,
468 bool cardinal_only, bool percentage,
469 enum terrain_flag_id flag)
470{
471 int count = 0, total = 0;
472
473 variable_adjc_iterate(nmap, ptile, adjc_tile, cardinal_only) {
474 struct terrain *pterrain = tile_terrain(adjc_tile);
475
476 if (T_UNKNOWN != pterrain
477 && terrain_has_flag(pterrain, flag)) {
478 count++;
479 }
480 total++;
482
483 if (percentage && count > 0) { /* Latter condition avoids div by zero */
484 count = count * 100 / total;
485 }
486
487 return count;
488}
489
490/**********************************************************************/
496const char *get_infrastructure_text(bv_extras extras)
497{
498 static char s[256];
499 char *p;
500 int len;
501
502 s[0] = '\0';
503
504 extra_type_iterate(pextra) {
505 if (pextra->category == ECAT_INFRA
506 && BV_ISSET(extras, extra_index(pextra))) {
507 bool hidden = FALSE;
508
509 extra_type_iterate(top) {
510 int topi = extra_index(top);
511
512 if (BV_ISSET(pextra->hidden_by, topi)
513 && BV_ISSET(extras, topi)) {
514 hidden = TRUE;
515 break;
516 }
518
519 if (!hidden) {
520 cat_snprintf(s, sizeof(s), "%s/", extra_name_translation(pextra));
521 }
522 }
524
525 len = strlen(s);
526 p = s + len - 1;
527 if (len > 0 && *p == '/') {
528 *p = '\0';
529 }
530
531 return s;
532}
533
534/**********************************************************************/
539{
540 /* Semi-arbitrary preference order reflecting previous behavior */
541 static const enum extra_cause prefs[] = {
542 EC_IRRIGATION,
543 EC_MINE,
544 EC_BASE,
545 EC_ROAD,
546 EC_HUT,
547 EC_APPEARANCE,
548 EC_POLLUTION,
549 EC_FALLOUT,
550 EC_RESOURCE,
551 EC_NONE
552 };
553 int i;
554
555 for (i = 0; i < ARRAY_SIZE(prefs); i++) {
556 extra_type_by_cause_iterate_rev(prefs[i], pextra) {
557 if (is_extra_removed_by(pextra, ERM_PILLAGE)
558 && BV_ISSET(extras, extra_index(pextra))) {
559 return pextra;
560 }
562 }
563
564 return NULL;
565}
566
567/**********************************************************************/
570enum terrain_class terrain_type_terrain_class(const struct terrain *pterrain)
571{
572 return pterrain->tclass;
573}
574
575/**********************************************************************/
579bool is_terrain_class_card_near(const struct civ_map *nmap,
580 const struct tile *ptile,
581 enum terrain_class tclass)
582{
583 cardinal_adjc_iterate(nmap, ptile, adjc_tile) {
584 struct terrain* pterrain = tile_terrain(adjc_tile);
585
586 if (pterrain != T_UNKNOWN) {
587 if (terrain_type_terrain_class(pterrain) == tclass) {
588 return TRUE;
589 }
590 }
592
593 return FALSE;
594}
595
596/**********************************************************************/
600bool is_terrain_class_near_tile(const struct civ_map *nmap,
601 const struct tile *ptile,
602 enum terrain_class tclass)
603{
604 adjc_iterate(nmap, ptile, adjc_tile) {
605 struct terrain* pterrain = tile_terrain(adjc_tile);
606
607 if (pterrain != T_UNKNOWN) {
608 if (terrain_type_terrain_class(pterrain) == tclass) {
609 return TRUE;
610 }
611 }
613
614 return FALSE;
615}
616
617/**********************************************************************/
622 const struct tile *ptile,
623 bool cardinal_only, bool percentage,
624 enum terrain_class tclass)
625{
626 int count = 0, total = 0;
627
628 variable_adjc_iterate(nmap, ptile, adjc_tile, cardinal_only) {
629 struct terrain *pterrain = tile_terrain(adjc_tile);
630
631 if (T_UNKNOWN != pterrain
632 && terrain_type_terrain_class(pterrain) == tclass) {
633 count++;
634 }
635 total++;
637
638 if (percentage && count > 0) { /* Latter condition avoids div by zero */
639 count = count * 100 / total;
640 }
641
642 return count;
643}
644
645/**********************************************************************/
649const char *terrain_class_name_translation(enum terrain_class tclass)
650{
651 if (!terrain_class_is_valid(tclass)) {
652 return NULL;
653 }
654
655 return _(terrain_class_name(tclass));
656}
657
658/**********************************************************************/
661bool terrain_can_support_alteration(const struct terrain *pterrain,
662 enum terrain_alteration alter)
663{
664 switch (alter) {
665 case TA_CAN_IRRIGATE:
666 return (pterrain->irrigation_time > 0);
667 case TA_CAN_MINE:
668 return (pterrain->mining_time > 0);
669 case TA_CAN_ROAD:
670 return (pterrain->road_time > 0);
671 default:
672 break;
673 }
674
676 return FALSE;
677}
678
679/**********************************************************************/
682int terrain_extra_build_time(const struct terrain *pterrain,
683 enum unit_activity activity,
684 const struct extra_type *tgt)
685{
686 int factor;
687
688 if (tgt != NULL && tgt->build_time != 0) {
689 /* Extra specific build time */
690 return tgt->build_time;
691 }
692
693 if (tgt == NULL) {
694 factor = 1;
695 } else {
696 factor = tgt->build_time_factor;
697 }
698
699 /* Terrain and activity specific build time */
700 switch (activity) {
701 case ACTIVITY_BASE:
702 return pterrain->base_time * factor;
703 case ACTIVITY_GEN_ROAD:
704 return pterrain->road_time * factor;
705 case ACTIVITY_IRRIGATE:
706 return pterrain->irrigation_time * factor;
707 case ACTIVITY_MINE:
708 return pterrain->mining_time * factor;
709 default:
711 return 0;
712 }
713}
714
715/**********************************************************************/
718int terrain_extra_removal_time(const struct terrain *pterrain,
719 enum unit_activity activity,
720 const struct extra_type *tgt)
721{
722 int factor;
723
724 if (tgt != NULL && tgt->removal_time != 0) {
725 /* Extra specific removal time */
726 return tgt->removal_time;
727 }
728
729 if (tgt == NULL) {
730 factor = 1;
731 } else {
732 factor = tgt->removal_time_factor;
733 }
734
735 /* Terrain and activity specific removal time */
736 switch (activity) {
737 case ACTIVITY_POLLUTION:
738 return pterrain->clean_pollution_time * factor;
739 case ACTIVITY_FALLOUT:
740 return pterrain->clean_fallout_time * factor;
741 case ACTIVITY_PILLAGE:
742 return pterrain->pillage_time * factor;
743 default:
745 return 0;
746 }
747}
748
749/**********************************************************************/
753{
754 int i;
755
756 for (i = 0; i < MAX_NUM_USER_TER_FLAGS; i++) {
758 }
759}
760
761/**********************************************************************/
765{
766 int i;
767
768 for (i = 0; i < MAX_NUM_USER_TER_FLAGS; i++) {
770 }
771}
772
773/**********************************************************************/
776void set_user_terrain_flag_name(enum terrain_flag_id id, const char *name,
777 const char *helptxt)
778{
779 int tfid = id - TER_USER_1;
780
781 fc_assert_ret(id >= TER_USER_1 && id <= TER_USER_LAST);
782
783 if (user_terrain_flags[tfid].name != NULL) {
785 user_terrain_flags[tfid].name = NULL;
786 }
787
788 if (name && name[0] != '\0') {
790 }
791
792 if (user_terrain_flags[tfid].helptxt != NULL) {
793 FC_FREE(user_terrain_flags[tfid].helptxt);
794 user_terrain_flags[tfid].helptxt = NULL;
795 }
796
797 if (helptxt && helptxt[0] != '\0') {
798 user_terrain_flags[tfid].helptxt = fc_strdup(helptxt);
799 }
800}
801
802/**********************************************************************/
805const char *terrain_flag_id_name_cb(enum terrain_flag_id flag)
806{
807 if (flag < TER_USER_1 || flag > TER_USER_LAST) {
808 return NULL;
809 }
810
811 return user_terrain_flags[flag-TER_USER_1].name;
812}
813
814/**********************************************************************/
817const char *terrain_flag_helptxt(enum terrain_flag_id id)
818{
819 fc_assert(id >= TER_USER_1 && id <= TER_USER_LAST);
820
821 return user_terrain_flags[id - TER_USER_1].helptxt;
822}
#define BV_ISSET(bv, bit)
Definition bitvector.h:78
static struct extra_type extras[MAX_EXTRA_TYPES]
Definition extras.c:31
bool is_extra_removed_by(const struct extra_type *pextra, enum extra_rmcause rmcause)
Definition extras.c:327
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:186
#define extra_type_by_cause_iterate_rev(_cause, _extra)
Definition extras.h:320
#define extra_type_by_cause_iterate_rev_end
Definition extras.h:325
#define extra_type_iterate(_p)
Definition extras.h:291
#define extra_type_iterate_end
Definition extras.h:297
#define extra_index(_e_)
Definition extras.h:177
int Terrain_type_id
Definition fc_types.h:343
#define EC_NONE
Definition fc_types.h:967
#define _(String)
Definition fcintl.h:67
#define Qn_(String)
Definition fcintl.h:89
void user_flag_init(struct user_flag *flag)
Definition game.c:804
void user_flag_free(struct user_flag *flag)
Definition game.c:813
struct civ_game game
Definition game.c:57
GType type
Definition repodlgs.c:1312
const char * name
Definition inputfile.c:127
#define fc_assert_ret(condition)
Definition log.h:191
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_ret_val(condition, val)
Definition log.h:194
#define adjc_iterate_end
Definition map.h:427
#define cardinal_adjc_iterate_end
Definition map.h:453
#define adjc_iterate(nmap, center_tile, itr_tile)
Definition map.h:422
#define cardinal_adjc_iterate(nmap, center_tile, itr_tile)
Definition map.h:449
#define FC_FREE(ptr)
Definition mem.h:41
#define fc_strdup(str)
Definition mem.h:43
#define fc_malloc(sz)
Definition mem.h:34
static const char * rule_name_get(const struct name_translation *ptrans)
static const char * name_translation_get(const struct name_translation *ptrans)
int len
Definition packhand.c:125
#define fc_rand(_size)
Definition rand.h:34
void rgbcolor_destroy(struct rgbcolor *prgbcolor)
Definition rgbcolor.c:74
#define ARRAY_SIZE(x)
Definition shared.h:85
void strvec_destroy(struct strvec *psv)
struct packet_ruleset_control control
Definition game.h:83
struct resource_type * resource
Definition extras.h:150
int removal_time
Definition extras.h:116
int build_time_factor
Definition extras.h:115
struct extra_type::@24 data
int removal_time_factor
Definition extras.h:117
int build_time
Definition extras.h:114
struct extra_type * self
Definition terrain.h:51
int property[MG_COUNT]
Definition terrain.h:239
struct extra_type ** resources
Definition terrain.h:197
int item_number
Definition terrain.h:177
int road_time
Definition terrain.h:201
struct name_translation name
Definition terrain.h:178
int clean_fallout_time
Definition terrain.h:220
const struct unit_type * animal
Definition terrain.h:223
int pillage_time
Definition terrain.h:221
int mining_time
Definition terrain.h:213
struct rgbcolor * rgb
Definition terrain.h:247
int clean_pollution_time
Definition terrain.h:219
enum terrain_class tclass
Definition terrain.h:190
int irrigation_time
Definition terrain.h:210
int base_time
Definition terrain.h:200
void * ruledit_dlg
Definition terrain.h:180
char identifier
Definition terrain.h:184
bool ruledit_disabled
Definition terrain.h:179
Definition tile.h:49
struct terrain * terrain
Definition tile.h:56
char * name
Definition game.h:74
char * helptxt
Definition game.h:75
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:189
int cat_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:995
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
int terrain_extra_removal_time(const struct terrain *pterrain, enum unit_activity activity, const struct extra_type *tgt)
Definition terrain.c:718
void user_terrain_flags_init(void)
Definition terrain.c:752
void terrains_free(void)
Definition terrain.c:59
struct terrain * terrain_by_rule_name(const char *name)
Definition terrain.c:174
bool is_terrain_class_near_tile(const struct civ_map *nmap, const struct tile *ptile, enum terrain_class tclass)
Definition terrain.c:600
char terrain_identifier(const struct terrain *pterrain)
Definition terrain.c:114
Terrain_type_id terrain_count(void)
Definition terrain.c:106
void terrains_init(void)
Definition terrain.c:42
struct extra_type * resource_extra_get(const struct resource_type *presource)
Definition terrain.c:284
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:621
bool is_terrain_class_card_near(const struct civ_map *nmap, const struct tile *ptile, enum terrain_class tclass)
Definition terrain.c:579
struct terrain * terrain_by_translated_name(const char *name)
Definition terrain.c:190
const char * terrain_class_name_translation(enum terrain_class tclass)
Definition terrain.c:649
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:466
const char * get_infrastructure_text(bv_extras extras)
Definition terrain.c:496
const char * terrain_flag_id_name_cb(enum terrain_flag_id flag)
Definition terrain.c:805
Terrain_type_id terrain_index(const struct terrain *pterrain)
Definition terrain.c:126
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:383
const char * terrain_name_translation(const struct terrain *pterrain)
Definition terrain.c:226
#define variable_adjc_iterate(nmap, center_tile, _tile, card_only)
Definition terrain.c:293
struct terrain * terrain_array_first(void)
Definition terrain.c:84
struct terrain * rand_terrain_by_flag(enum terrain_flag_id flag)
Definition terrain.c:205
struct terrain * terrain_by_number(const Terrain_type_id type)
Definition terrain.c:144
bool terrain_can_support_alteration(const struct terrain *pterrain, enum terrain_alteration alter)
Definition terrain.c:661
bool is_terrain_card_near(const struct civ_map *nmap, const struct tile *ptile, const struct terrain *pterrain, bool check_self)
Definition terrain.c:315
const char * terrain_rule_name(const struct terrain *pterrain)
Definition terrain.c:235
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:404
void resource_types_free(void)
Definition terrain.c:276
void user_terrain_flags_free(void)
Definition terrain.c:764
enum terrain_class terrain_type_terrain_class(const struct terrain *pterrain)
Definition terrain.c:570
const char * terrain_flag_helptxt(enum terrain_flag_id id)
Definition terrain.c:817
bool terrain_has_resource(const struct terrain *pterrain, const struct extra_type *presource)
Definition terrain.c:243
struct resource_type * resource_type_init(struct extra_type *pextra)
Definition terrain.c:260
bool is_terrain_flag_near_tile(const struct civ_map *nmap, const struct tile *ptile, enum terrain_flag_id flag)
Definition terrain.c:446
struct extra_type * get_preferred_pillage(bv_extras extras)
Definition terrain.c:538
void set_user_terrain_flag_name(enum terrain_flag_id id, const char *name, const char *helptxt)
Definition terrain.c:776
const struct terrain * terrain_array_last(void)
Definition terrain.c:95
static struct terrain civ_terrains[MAX_NUM_TERRAINS]
Definition terrain.c:36
int terrain_extra_build_time(const struct terrain *pterrain, enum unit_activity activity, const struct extra_type *tgt)
Definition terrain.c:682
static struct user_flag user_terrain_flags[MAX_NUM_USER_TER_FLAGS]
Definition terrain.c:37
Terrain_type_id terrain_number(const struct terrain *pterrain)
Definition terrain.c:135
struct terrain * terrain_by_identifier(const char identifier)
Definition terrain.c:157
bool is_terrain_flag_card_near(const struct civ_map *nmap, const struct tile *ptile, enum terrain_flag_id flag)
Definition terrain.c:426
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:357
#define variable_adjc_iterate_end
Definition terrain.c:308
bool is_terrain_near_tile(const struct civ_map *nmap, const struct tile *ptile, const struct terrain *pterrain, bool check_self)
Definition terrain.c:336
#define terrain_type_iterate(_p)
Definition terrain.h:358
#define T_UNKNOWN
Definition terrain.h:57
#define TERRAIN_UNKNOWN_IDENTIFIER
Definition terrain.h:188
#define terrain_type_iterate_end
Definition terrain.h:364
#define MAX_NUM_TERRAINS
Definition terrain.h:64
#define terrain_has_flag(terr, flag)
Definition terrain.h:269
#define MAX_NUM_USER_TER_FLAGS
Definition terrain.h:146
#define tile_resource(_tile)
Definition tile.h:101
#define tile_terrain(_tile)
Definition tile.h:109