Freeciv-3.2
Loading...
Searching...
No Matches
extras.c
Go to the documentation of this file.
1/****************************************************************************
2 Freeciv - Copyright (C) 2004 - The Freeciv Team
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 "rand.h"
20#include "string_vector.h"
21
22/* common */
23#include "base.h"
24#include "game.h"
25#include "map.h"
26#include "research.h"
27#include "road.h"
28
29#include "extras.h"
30
32
34
39static struct extra_type_list *zoccers;
41
42/************************************************************************/
45void extras_init(void)
46{
47 int i;
48
49 for (i = 0; i < EC_LAST; i++) {
51 }
52 for (i = 0; i < ERM_COUNT; i++) {
54 }
59
60 for (i = 0; i < MAX_EXTRA_TYPES; i++) {
63 requirement_vector_init(&(extras[i].appearance_reqs));
64 requirement_vector_init(&(extras[i].disappearance_reqs));
65 extras[i].id = i;
72 extras[i].causes = 0;
73 extras[i].rmcauses = 0;
78 }
79}
80
81/************************************************************************/
84void extras_free(void)
85{
86 int i;
87
91
92 for (i = 0; i < game.control.num_extra_types; i++) {
93 if (extras[i].data.base != NULL) {
94 FC_FREE(extras[i].data.base);
96 }
97 if (extras[i].data.road != NULL) {
98 FC_FREE(extras[i].data.road);
100 }
101 if (extras[i].data.resource != NULL) {
102 FC_FREE(extras[i].data.resource);
104 }
105 }
106
107 for (i = 0; i < EC_LAST; i++) {
109 caused_by[i] = NULL;
110 }
111
112 for (i = 0; i < ERM_COUNT; i++) {
114 removed_by[i] = NULL;
115 }
116
118 cleanable = NULL;
122 zoccers = NULL;
125
126 for (i = 0; i < MAX_EXTRA_TYPES; i++) {
128 requirement_vector_free(&(extras[i].rmreqs));
129 requirement_vector_free(&(extras[i].appearance_reqs));
130 requirement_vector_free(&(extras[i].disappearance_reqs));
131
132 if (NULL != extras[i].helptext) {
133 strvec_destroy(extras[i].helptext);
135 }
136 }
137
138 extra_type_iterate(pextra) {
139 if (pextra->hiders != NULL) {
140 extra_type_list_destroy(pextra->hiders);
141 pextra->hiders = NULL;
142 }
143 if (pextra->bridged != NULL) {
144 extra_type_list_destroy(pextra->bridged);
145 pextra->bridged = NULL;
146 }
148}
149
150/************************************************************************/
153int extra_count(void)
154{
156}
157
158/************************************************************************/
161int extra_number(const struct extra_type *pextra)
162{
163 fc_assert_ret_val(NULL != pextra, -1);
164
165 return pextra->id;
166}
167
168#ifndef extra_index
169/************************************************************************/
172int extra_index(const struct extra_type *pextra)
173{
174 fc_assert_ret_val(NULL != pextra, -1);
175
176 return pextra - extras;
177}
178#endif /* extra_index */
179
180/************************************************************************/
184{
185 fc_assert_ret_val(id >= 0 && id < MAX_EXTRA_TYPES, NULL);
186
187 return &extras[id];
188}
189
190/************************************************************************/
194const char *extra_name_translation(const struct extra_type *pextra)
195{
196 return name_translation_get(&pextra->name);
197}
198
199/************************************************************************/
203const char *extra_rule_name(const struct extra_type *pextra)
204{
205 return rule_name_get(&pextra->name);
206}
207
208/************************************************************************/
213{
214 const char *qs;
215
216 if (name == NULL) {
217 return NULL;
218 }
219
220 qs = Qn_(name);
221
222 extra_type_iterate(pextra) {
223 if (!fc_strcasecmp(extra_rule_name(pextra), qs)) {
224 return pextra;
225 }
227
228 return NULL;
229}
230
231/************************************************************************/
236{
237 extra_type_iterate(pextra) {
238 if (0 == strcmp(extra_name_translation(pextra), name)) {
239 return pextra;
240 }
242
243 return NULL;
244}
245
246/************************************************************************/
250{
251 fc_assert(cause < EC_LAST);
252
253 return caused_by[cause];
254}
255
256/************************************************************************/
263
264/************************************************************************/
268{
269 return zoccers;
270}
271
272/************************************************************************/
279
280/************************************************************************/
283struct extra_type *rand_extra_for_tile(struct tile *ptile, enum extra_cause cause,
284 bool generated)
285{
288 int options;
289 struct extra_type *selected = NULL;
290
292 if ((!generated || pextra->generated)
293 && is_native_tile_to_extra(pextra, ptile)) {
295 }
297
299
300 if (options > 0) {
301 selected = extra_type_list_get(potential, fc_rand(options));
302 }
303
305
306 return selected;
307}
308
309/************************************************************************/
312void extra_to_caused_by_list(struct extra_type *pextra, enum extra_cause cause)
313{
314 fc_assert(cause < EC_LAST);
315
316 extra_type_list_append(caused_by[cause], pextra);
317}
318
319/************************************************************************/
328
329/************************************************************************/
333{
334 return cleanable;
335}
336
337/************************************************************************/
342{
344
345 if (rmcause == ERM_CLEAN) {
347 }
348}
349
350/************************************************************************/
353bool is_extra_removed_by(const struct extra_type *pextra,
355{
356 return (pextra->rmcauses & (1 << rmcause));
357}
358
359/************************************************************************/
363bool is_extra_card_near(const struct civ_map *nmap, const struct tile *ptile,
364 const struct extra_type *pextra)
365{
367 if (tile_has_extra(adjc_tile, pextra)) {
368 return TRUE;
369 }
371
372 return FALSE;
373}
374
375/************************************************************************/
379bool is_extra_near_tile(const struct civ_map *nmap, const struct tile *ptile,
380 const struct extra_type *pextra)
381{
382 adjc_iterate(nmap, ptile, adjc_tile) {
383 if (tile_has_extra(adjc_tile, pextra)) {
384 return TRUE;
385 }
387
388 return FALSE;
389}
390
391/************************************************************************/
394bool extra_can_be_built(const struct extra_type *pextra,
395 const struct tile *ptile)
396{
397 if (!pextra->buildable) {
398 /* Extra type not buildable */
399 return FALSE;
400 }
401
402 if (tile_has_extra(ptile, pextra)) {
403 /* Extra exist already */
404 return FALSE;
405 }
406
407 return TRUE;
408}
409
410/************************************************************************/
413bool can_build_extra_base(const struct extra_type *pextra,
414 const struct player *pplayer,
415 const struct tile *ptile)
416{
417 struct terrain *pterr;
418
419 if (!extra_can_be_built(pextra, ptile)) {
420 return FALSE;
421 }
422
423 pterr = tile_terrain(ptile);
424
425 if (is_extra_caused_by(pextra, EC_BASE)) {
426 if (pterr->base_time == 0) {
427 return FALSE;
428 }
429 if (tile_city(ptile) != NULL && extra_base_get(pextra)->border_sq >= 0) {
430 return FALSE;
431 }
432 }
433
434 /* Even if it's a multi-cause extra, just having Build Road as one of the
435 * causes makes it to require that road_time != 0.
436 * Correct functioning of EC_PLACE extras depend on this. */
437 if (is_extra_caused_by(pextra, EC_ROAD)
438 && pterr->road_time == 0) {
439 return FALSE;
440 }
441
443 && pterr->irrigation_time == 0) {
444 return FALSE;
445 }
446
447 if (is_extra_caused_by(pextra, EC_MINE)
448 && pterr->mining_time == 0) {
449 return FALSE;
450 }
451
452 if (pplayer != NULL && !player_knows_techs_with_flag(pplayer, TF_BRIDGE)) {
453 /* Player does not know technology to bridge over extras that require it. */
455 if (tile_has_extra(ptile, pbridged)) {
456 /* Tile has extra that would require bridging over. */
457 return FALSE;
458 }
460 }
461
462 return TRUE;
463}
464
465/************************************************************************/
468bool player_can_build_extra(const struct extra_type *pextra,
469 const struct player *pplayer,
470 const struct tile *ptile)
471{
472 if (!can_build_extra_base(pextra, pplayer, ptile)) {
473 return FALSE;
474 }
475
476 return are_reqs_active(&(const struct req_context) {
477 .player = pplayer,
478 .tile = ptile,
479 },
480 tile_owner(ptile),
481 &pextra->reqs,
483}
484
485/************************************************************************/
488bool player_can_place_extra(const struct extra_type *pextra,
489 const struct player *pplayer,
490 const struct tile *ptile)
491{
492 if (pextra->infracost == 0) {
493 return FALSE;
494 }
495
496 if (ptile->placing != NULL) {
497 /* Already placing something */
498 return FALSE;
499 }
500
501 if (tile_terrain(ptile)->placing_time <= 0) {
502 /* Can't place to this terrain */
503 return FALSE;
504 }
505
507 if (tile_owner(ptile) != pplayer) {
508 return FALSE;
509 }
510 } else {
511 struct city *pcity = tile_worked(ptile);
512
513 if (pcity == NULL || city_owner(pcity) != pplayer) {
514 return FALSE;
515 }
516 }
517
518 /* Placing extras is not allowed to tiles where also workers do changes. */
519 unit_list_iterate(ptile->units, punit) {
521 if (punit->activity == act) {
522 return FALSE;
523 }
526
527 return player_can_build_extra(pextra, pplayer, ptile);
528}
529
530/************************************************************************/
533bool can_build_extra(const struct extra_type *pextra,
534 const struct unit *punit,
535 const struct tile *ptile)
536{
537 struct player *pplayer = unit_owner(punit);
538
539 if (!can_build_extra_base(pextra, pplayer, ptile)) {
540 return FALSE;
541 }
542
543 return are_reqs_active(&(const struct req_context) {
544 .player = pplayer,
545 .tile = ptile,
546 .unit = punit,
547 .unittype = unit_type_get(punit),
548 },
549 tile_owner(ptile),
550 &pextra->reqs,
552}
553
554/************************************************************************/
557static bool can_extra_be_removed(const struct extra_type *pextra,
558 const struct tile *ptile)
559{
560 struct city *pcity = tile_city(ptile);
561
562 /* Cannot remove EF_ALWAYS_ON_CITY_CENTER extras from city center. */
563 if (pcity != NULL) {
565 return FALSE;
566 }
568 struct tile *vtile = tile_virtual_new(ptile);
569
570 /* Would extra get rebuilt if removed */
571 tile_remove_extra(vtile, pextra);
572 if (player_can_build_extra(pextra, city_owner(pcity), vtile)) {
573 /* No need to worry about conflicting extras - extra would had
574 * not been here if conflicting one is. */
576
577 return FALSE;
578 }
579
581 }
582 }
583
584 return TRUE;
585}
586
587/************************************************************************/
591bool player_can_remove_extra(const struct extra_type *pextra,
592 const struct player *pplayer,
593 const struct tile *ptile)
594{
595 if (!can_extra_be_removed(pextra, ptile)) {
596 return FALSE;
597 }
598
599 return are_reqs_active(&(const struct req_context) {
600 .player = pplayer,
601 .tile = ptile,
602 },
603 tile_owner(ptile),
604 &pextra->rmreqs,
606}
607
608/************************************************************************/
612bool can_remove_extra(const struct extra_type *pextra,
613 const struct unit *punit,
614 const struct tile *ptile)
615{
616 if (!can_extra_be_removed(pextra, ptile)) {
617 return FALSE;
618 }
619
620 return are_reqs_active(&(const struct req_context) {
621 .player = unit_owner(punit),
622 .tile = ptile,
623 .unit = punit,
624 .unittype = unit_type_get(punit),
625 },
626 tile_owner(ptile),
627 &pextra->rmreqs, RPT_CERTAIN);
628}
629
630/************************************************************************/
633bool is_native_tile_to_extra(const struct extra_type *pextra,
634 const struct tile *ptile)
635{
636 struct terrain *pterr = tile_terrain(ptile);
637
638 if (terrain_has_resource(pterr, pextra)) {
639 return TRUE;
640 }
641
643 && pterr->irrigation_time == 0) {
644 return FALSE;
645 }
646
647 if (is_extra_caused_by(pextra, EC_MINE)
648 && pterr->mining_time == 0) {
649 return FALSE;
650 }
651
652 if (is_extra_caused_by(pextra, EC_BASE)) {
653 if (pterr->base_time == 0) {
654 return FALSE;
655 }
656 if (tile_city(ptile) != NULL && extra_base_get(pextra)->border_sq >= 0) {
657 return FALSE;
658 }
659 }
660
661 if (is_extra_caused_by(pextra, EC_ROAD)) {
662 struct road_type *proad = extra_road_get(pextra);
663
666 return FALSE;
667 }
668 } else if (pterr->road_time == 0) {
669 return FALSE;
670 }
671 }
672
673 return are_reqs_active(&(const struct req_context) { .tile = ptile },
674 NULL, &pextra->reqs, RPT_POSSIBLE);
675}
676
677/************************************************************************/
680bool extra_conflicting_on_tile(const struct extra_type *pextra,
681 const struct tile *ptile)
682{
684 if (tile_has_extra(ptile, old_extra)
685 && !can_extras_coexist(old_extra, pextra)) {
686 return TRUE;
687 }
689
690 return FALSE;
691}
692
693/************************************************************************/
697bool hut_on_tile(const struct tile *ptile)
698{
700 if (tile_has_extra(ptile, extra)) {
701 return TRUE;
702 }
704
705 return FALSE;
706}
707
708/************************************************************************/
712bool unit_can_enter_hut(const struct unit *punit,
713 const struct tile *ptile)
714{
715 const struct req_context context = {
717 .tile = ptile,
718 };
719
722 return FALSE;
723 }
725 if (tile_has_extra(ptile, extra)
727 RPT_POSSIBLE)) {
728 return TRUE;
729 }
731 return FALSE;
732}
733
734/************************************************************************/
739 const struct tile *ptile)
740{
741 const struct req_context context = {
743 .tile = ptile,
744 };
745
750 return FALSE;
751 }
753 if (tile_has_extra(ptile, extra)
755 RPT_POSSIBLE)) {
756 return TRUE;
757 }
759 return FALSE;
760}
761
762/************************************************************************/
765struct extra_type *next_extra_for_tile(const struct tile *ptile, enum extra_cause cause,
766 const struct player *pplayer,
767 const struct unit *punit)
768{
769 extra_type_by_cause_iterate(cause, pextra) {
770 if (!tile_has_extra(ptile, pextra)) {
771 if (punit != NULL) {
772 if (can_build_extra(pextra, punit, ptile)) {
773 return pextra;
774 }
775 } else {
776 /* punit is certainly NULL, pplayer can be too */
777 if (player_can_build_extra(pextra, pplayer, ptile)) {
778 return pextra;
779 }
780 }
781 }
783
784 return NULL;
785}
786
787/************************************************************************/
790struct extra_type *prev_extra_in_tile(const struct tile *ptile,
792 const struct player *pplayer,
793 const struct unit *punit)
794{
795 fc_assert(punit != NULL || pplayer != NULL);
796
798 if (tile_has_extra(ptile, pextra)) {
799 if (punit != NULL) {
800 if (can_remove_extra(pextra, punit, ptile)) {
801 return pextra;
802 }
803 } else {
804 if (player_can_remove_extra(pextra, pplayer, ptile)) {
805 return pextra;
806 }
807 }
808 }
810
811 return NULL;
812}
813
814/************************************************************************/
817struct extra_type *prev_cleanable_in_tile(const struct tile *ptile,
818 const struct player *pplayer,
819 const struct unit *punit)
820{
821 fc_assert(punit != NULL || pplayer != NULL);
822
824 if (tile_has_extra(ptile, pextra)) {
825 if (punit != NULL) {
826 if (can_remove_extra(pextra, punit, ptile)) {
827 return pextra;
828 }
829 } else {
830 if (player_can_remove_extra(pextra, pplayer, ptile)) {
831 return pextra;
832 }
833 }
834 }
836
837 return NULL;
838}
839
840/************************************************************************/
843bool is_native_extra_to_uclass(const struct extra_type *pextra,
844 const struct unit_class *pclass)
845{
846 return BV_ISSET(pextra->native_to, uclass_index(pclass));
847}
848
849/************************************************************************/
852bool is_native_extra_to_utype(const struct extra_type *pextra,
853 const struct unit_type *punittype)
854{
856}
857
858/************************************************************************/
861bool extra_has_flag(const struct extra_type *pextra, enum extra_flag_id flag)
862{
863 return BV_ISSET(pextra->flags, flag);
864}
865
866/************************************************************************/
870bool is_extra_flag_card_near(const struct civ_map *nmap, const struct tile *ptile,
871 enum extra_flag_id flag)
872{
873 extra_type_iterate(pextra) {
874 if (extra_has_flag(pextra, flag)) {
876 if (tile_has_extra(adjc_tile, pextra)) {
877 return TRUE;
878 }
880 }
882
883 return FALSE;
884}
885
886/************************************************************************/
890bool is_extra_flag_near_tile(const struct civ_map *nmap, const struct tile *ptile,
891 enum extra_flag_id flag)
892{
893 extra_type_iterate(pextra) {
894 if (extra_has_flag(pextra, flag)) {
895 adjc_iterate(nmap, ptile, adjc_tile) {
896 if (tile_has_extra(adjc_tile, pextra)) {
897 return TRUE;
898 }
900 }
902
903 return FALSE;
904}
905
906/************************************************************************/
910{
911 int i;
912
913 for (i = 0; i < MAX_NUM_USER_EXTRA_FLAGS; i++) {
915 }
916}
917
918/************************************************************************/
922{
923 int i;
924
925 for (i = 0; i < MAX_NUM_USER_EXTRA_FLAGS; i++) {
927 }
928}
929
930/************************************************************************/
934 const char *helptxt)
935{
936 int efid = id - EF_USER_FLAG_1;
937
939
940 if (user_extra_flags[efid].name != NULL) {
943 }
944
945 if (name && name[0] != '\0') {
947 }
948
949 if (user_extra_flags[efid].helptxt != NULL) {
950 free(user_extra_flags[efid].helptxt);
952 }
953
954 if (helptxt && helptxt[0] != '\0') {
956 }
957}
958
959/************************************************************************/
963{
965 return NULL;
966 }
967
968 return user_extra_flags[flag - EF_USER_FLAG_1].name;
969}
970
971/************************************************************************/
975{
977
979}
980
981/**********************************************************************/
988{
990 if (extra_has_flag(pextra, id)) {
991 /* Found a user. */
992 return TRUE;
993 }
995
996 /* No users detected. */
997 return FALSE;
998}
999
1000/************************************************************************/
1004 const struct extra_type *pextra2)
1005{
1006 if (pextra1 == pextra2) {
1007 return TRUE;
1008 }
1009
1010 return !BV_ISSET(pextra1->conflicts, extra_index(pextra2));
1011}
1012
1013/************************************************************************/
1018{
1019 switch (upset) {
1020 case EUT_GLOBAL_WARMING:
1021 return extra_has_flag(pextra, EF_GLOBAL_WARMING);
1022 case EUT_NUCLEAR_WINTER:
1023 return extra_has_flag(pextra, EF_NUCLEAR_WINTER);
1024 }
1025
1026 return FALSE;
1027}
1028
1029/************************************************************************/
1033{
1034 /* Is any of the worker build action bits set? */
1035 return (pextra->causes
1036 & (1 << EC_IRRIGATION
1037 | 1 << EC_MINE
1038 | 1 << EC_BASE
1039 | 1 << EC_ROAD));
1040}
1041
1042/************************************************************************/
1046{
1047 /* Is any of the worker remove action bits set? */
1048 return (pextra->rmcauses
1049 & (1 << ERM_CLEAN
1050 | 1 << ERM_PILLAGE));
1051}
1052
1053/************************************************************************/
1056bool is_extra_caused_by_action(const struct extra_type *pextra,
1057 const struct action *paction)
1058{
1060 return is_extra_caused_by(pextra, activity_to_extra_cause(act));
1061}
1062
1063/************************************************************************/
1066bool is_extra_removed_by_action(const struct extra_type *pextra,
1067 const struct action *paction)
1068{
1071}
1072
1073/************************************************************************/
1077{
1078 switch (act) {
1079 case ACTIVITY_IRRIGATE:
1080 return EC_IRRIGATION;
1081 case ACTIVITY_MINE:
1082 return EC_MINE;
1083 case ACTIVITY_BASE:
1084 return EC_BASE;
1085 case ACTIVITY_GEN_ROAD:
1086 return EC_ROAD;
1087 default:
1088 break;
1089 }
1090
1091 return EC_NONE;
1092}
1093
1094/************************************************************************/
1098{
1099 switch (act) {
1100 case ACTIVITY_CLEAN:
1101 return ERM_CLEAN;
1102 case ACTIVITY_PILLAGE:
1103 return ERM_PILLAGE;
1104 default:
1105 break;
1106 }
1107
1108 return ERM_NONE;
1109}
1110
1111/************************************************************************/
1114struct player *extra_owner(const struct tile *ptile)
1115{
1116 return ptile->extras_owner;
1117}
1118
1119/************************************************************************/
1122bool can_extra_appear(const struct extra_type *pextra, const struct tile *ptile)
1123{
1124 return !tile_has_extra(ptile, pextra)
1126 && is_native_tile_to_extra(pextra, ptile)
1127 && !extra_conflicting_on_tile(pextra, ptile)
1128 && are_reqs_active(&(const struct req_context) { .tile = ptile },
1129 tile_owner(ptile),
1130 &pextra->appearance_reqs, RPT_CERTAIN);
1131}
1132
1133/************************************************************************/
1136bool can_extra_disappear(const struct extra_type *pextra, const struct tile *ptile)
1137{
1138 return tile_has_extra(ptile, pextra)
1140 && can_extra_be_removed(pextra, ptile)
1141 && are_reqs_active(&(const struct req_context) { .tile = ptile },
1142 tile_owner(ptile),
1144}
1145
1146/************************************************************************/
1149bool player_knows_extra_exist(const struct player *pplayer,
1150 const struct extra_type *pextra,
1151 const struct tile *ptile)
1152{
1153 if (!tile_has_extra(ptile, pextra)) {
1154 return FALSE;
1155 }
1156
1157 return research_invention_state(research_get(pplayer),
1158 pextra->visibility_req) == TECH_KNOWN;
1159}
#define action_get_activity(_pact_)
Definition actions.h:699
void base_types_free(void)
Definition base.c:132
#define BV_ISSET(bv, bit)
Definition bitvector.h:78
#define city_owner(_pcity_)
Definition city.h:563
char * incite_cost
Definition comments.c:75
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
int int id
Definition editgui_g.h:28
struct @21::@22 reqs
bool is_extra_removed_by_worker_action(const struct extra_type *pextra)
Definition extras.c:1045
struct extra_type * next_extra_for_tile(const struct tile *ptile, enum extra_cause cause, const struct player *pplayer, const struct unit *punit)
Definition extras.c:765
struct extra_type * extra_type_by_rule_name(const char *name)
Definition extras.c:212
struct extra_type * prev_cleanable_in_tile(const struct tile *ptile, const struct player *pplayer, const struct unit *punit)
Definition extras.c:817
bool extra_causes_env_upset(struct extra_type *pextra, enum environment_upset_type upset)
Definition extras.c:1016
bool can_build_extra_base(const struct extra_type *pextra, const struct player *pplayer, const struct tile *ptile)
Definition extras.c:413
bool unit_can_displace_hut(const struct unit *punit, const struct tile *ptile)
Definition extras.c:738
struct extra_type * rand_extra_for_tile(struct tile *ptile, enum extra_cause cause, bool generated)
Definition extras.c:283
bool player_can_place_extra(const struct extra_type *pextra, const struct player *pplayer, const struct tile *ptile)
Definition extras.c:488
void user_extra_flags_init(void)
Definition extras.c:909
struct player * extra_owner(const struct tile *ptile)
Definition extras.c:1114
bool extra_flag_is_in_use(enum extra_flag_id id)
Definition extras.c:987
const char * extra_flag_helptxt(enum extra_flag_id id)
Definition extras.c:974
struct extra_type * extra_type_by_translated_name(const char *name)
Definition extras.c:235
void set_user_extra_flag_name(enum extra_flag_id id, const char *name, const char *helptxt)
Definition extras.c:933
bool is_extra_flag_near_tile(const struct civ_map *nmap, const struct tile *ptile, enum extra_flag_id flag)
Definition extras.c:890
static struct extra_type_list * removed_by[ERM_COUNT]
Definition extras.c:36
static struct extra_type_list * terr_claimer
Definition extras.c:40
bool unit_can_enter_hut(const struct unit *punit, const struct tile *ptile)
Definition extras.c:712
bool is_extra_caused_by_worker_action(const struct extra_type *pextra)
Definition extras.c:1032
bool is_extra_flag_card_near(const struct civ_map *nmap, const struct tile *ptile, enum extra_flag_id flag)
Definition extras.c:870
void extras_free(void)
Definition extras.c:84
bool can_extra_appear(const struct extra_type *pextra, const struct tile *ptile)
Definition extras.c:1122
struct extra_type_list * extra_type_list_of_zoccers(void)
Definition extras.c:267
bool is_extra_near_tile(const struct civ_map *nmap, const struct tile *ptile, const struct extra_type *pextra)
Definition extras.c:379
int extra_number(const struct extra_type *pextra)
Definition extras.c:161
bool extra_has_flag(const struct extra_type *pextra, enum extra_flag_id flag)
Definition extras.c:861
static struct extra_type_list * caused_by[EC_LAST]
Definition extras.c:35
static struct extra_type_list * zoccers
Definition extras.c:39
bool is_native_tile_to_extra(const struct extra_type *pextra, const struct tile *ptile)
Definition extras.c:633
struct extra_type_list * extra_type_list_by_cause(enum extra_cause cause)
Definition extras.c:249
struct extra_type_list * extra_type_list_by_rmcause(enum extra_rmcause rmcause)
Definition extras.c:322
static struct extra_type_list * cleanable
Definition extras.c:37
struct extra_type * prev_extra_in_tile(const struct tile *ptile, enum extra_rmcause rmcause, const struct player *pplayer, const struct unit *punit)
Definition extras.c:790
bool hut_on_tile(const struct tile *ptile)
Definition extras.c:697
bool is_extra_card_near(const struct civ_map *nmap, const struct tile *ptile, const struct extra_type *pextra)
Definition extras.c:363
void extra_to_caused_by_list(struct extra_type *pextra, enum extra_cause cause)
Definition extras.c:312
bool player_can_build_extra(const struct extra_type *pextra, const struct player *pplayer, const struct tile *ptile)
Definition extras.c:468
struct extra_type * extra_by_number(int id)
Definition extras.c:183
enum extra_cause activity_to_extra_cause(enum unit_activity act)
Definition extras.c:1076
static struct extra_type extras[MAX_EXTRA_TYPES]
Definition extras.c:31
bool extra_can_be_built(const struct extra_type *pextra, const struct tile *ptile)
Definition extras.c:394
bool is_native_extra_to_utype(const struct extra_type *pextra, const struct unit_type *punittype)
Definition extras.c:852
const char * extra_flag_id_name_cb(enum extra_flag_id flag)
Definition extras.c:962
bool extra_conflicting_on_tile(const struct extra_type *pextra, const struct tile *ptile)
Definition extras.c:680
static struct user_flag user_extra_flags[MAX_NUM_USER_EXTRA_FLAGS]
Definition extras.c:33
bool can_extras_coexist(const struct extra_type *pextra1, const struct extra_type *pextra2)
Definition extras.c:1003
void extra_flags_free(void)
Definition extras.c:921
bool can_remove_extra(const struct extra_type *pextra, const struct unit *punit, const struct tile *ptile)
Definition extras.c:612
static struct extra_type_list * unit_hidden
Definition extras.c:38
struct extra_type_list * extra_type_list_of_terr_claimers(void)
Definition extras.c:275
bool is_extra_caused_by_action(const struct extra_type *pextra, const struct action *paction)
Definition extras.c:1056
const char * extra_rule_name(const struct extra_type *pextra)
Definition extras.c:203
struct extra_type_list * extra_type_list_cleanable(void)
Definition extras.c:332
bool is_extra_removed_by(const struct extra_type *pextra, enum extra_rmcause rmcause)
Definition extras.c:353
void _extra_to_removed_by_list(struct extra_type *pextra, enum extra_rmcause rmcause)
Definition extras.c:340
bool is_extra_removed_by_action(const struct extra_type *pextra, const struct action *paction)
Definition extras.c:1066
enum extra_rmcause activity_to_extra_rmcause(enum unit_activity act)
Definition extras.c:1097
bool player_can_remove_extra(const struct extra_type *pextra, const struct player *pplayer, const struct tile *ptile)
Definition extras.c:591
struct extra_type_list * extra_type_list_of_unit_hiders(void)
Definition extras.c:259
void extras_init(void)
Definition extras.c:45
static bool can_extra_be_removed(const struct extra_type *pextra, const struct tile *ptile)
Definition extras.c:557
int extra_count(void)
Definition extras.c:153
bool player_knows_extra_exist(const struct player *pplayer, const struct extra_type *pextra, const struct tile *ptile)
Definition extras.c:1149
bool can_build_extra(const struct extra_type *pextra, const struct unit *punit, const struct tile *ptile)
Definition extras.c:533
bool is_native_extra_to_uclass(const struct extra_type *pextra, const struct unit_class *pclass)
Definition extras.c:843
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:194
bool can_extra_disappear(const struct extra_type *pextra, const struct tile *ptile)
Definition extras.c:1136
#define extra_type_cleanable_iterate_end
Definition extras.h:367
#define extra_type_iterate(_p)
Definition extras.h:315
#define extra_type_list_iterate(extralist, pextra)
Definition extras.h:165
#define extra_type_iterate_end
Definition extras.h:321
#define extra_type_by_rmcause_iterate_end
Definition extras.h:358
#define is_extra_caused_by(e, c)
Definition extras.h:203
#define extra_index(_e_)
Definition extras.h:183
#define extra_type_by_rmcause_iterate(_rmcause, _extra)
Definition extras.h:353
#define extra_type_re_active_iterate_end
Definition extras.h:329
#define extra_type_list_iterate_end
Definition extras.h:167
#define extra_base_get(_e_)
Definition extras.h:190
#define extra_road_get(_e_)
Definition extras.h:191
#define extra_type_re_active_iterate(_p)
Definition extras.h:325
#define extra_type_cleanable_iterate(_extra)
Definition extras.h:362
#define extra_type_by_cause_iterate_end
Definition extras.h:339
#define EF_LAST_USER_FLAG
Definition extras.h:82
#define MAX_NUM_USER_EXTRA_FLAGS
Definition extras.h:83
#define extra_type_by_cause_iterate(_cause, _extra)
Definition extras.h:333
#define EC_LAST
Definition fc_types.h:1118
environment_upset_type
Definition fc_types.h:1277
@ EUT_NUCLEAR_WINTER
Definition fc_types.h:1279
@ EUT_GLOBAL_WARMING
Definition fc_types.h:1278
@ RPT_CERTAIN
Definition fc_types.h:701
@ RPT_POSSIBLE
Definition fc_types.h:700
#define EC_NONE
Definition fc_types.h:1113
#define MAX_EXTRA_TYPES
Definition fc_types.h:50
#define ERM_NONE
Definition fc_types.h:1136
@ BORDERS_DISABLED
Definition fc_types.h:1037
#define Qn_(String)
Definition fcintl.h:89
void user_flag_init(struct user_flag *flag)
Definition game.c:824
void user_flag_free(struct user_flag *flag)
Definition game.c:833
struct civ_game game
Definition game.c:62
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:433
#define cardinal_adjc_iterate_end
Definition map.h:459
#define adjc_iterate(nmap, center_tile, itr_tile)
Definition map.h:428
#define cardinal_adjc_iterate(nmap, center_tile, itr_tile)
Definition map.h:455
#define FC_FREE(ptr)
Definition mem.h:41
#define fc_strdup(str)
Definition mem.h:43
static const char * rule_name_get(const struct name_translation *ptrans)
static const char * name_translation_get(const struct name_translation *ptrans)
bool player_knows_techs_with_flag(const struct player *pplayer, enum tech_flag_id flag)
Definition player.c:1328
#define fc_rand(_size)
Definition rand.h:56
bool are_reqs_active(const struct req_context *context, const struct player *other_player, const struct requirement_vector *reqs, const enum req_problem_type prob_type)
struct research * research_get(const struct player *pplayer)
Definition research.c:128
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
bool road_has_flag(const struct road_type *proad, enum road_flag_id flag)
Definition road.c:410
void road_types_free(void)
Definition road.c:134
void strvec_destroy(struct strvec *psv)
Definition city.h:320
struct packet_ruleset_control control
Definition game.h:83
struct packet_game_info info
Definition game.h:89
bv_unit_classes native_to
Definition extras.h:130
uint8_t rmcauses
Definition extras.h:95
struct requirement_vector appearance_reqs
Definition extras.h:108
struct strvec * helptext
Definition extras.h:149
bv_extra_flags flags
Definition extras.h:132
struct extra_type_list * hiders
Definition extras.h:144
uint16_t causes
Definition extras.h:94
struct road_type * road
Definition extras.h:155
struct resource_type * resource
Definition extras.h:156
struct extra_type::@25 data
struct extra_type_list * bridged
Definition extras.h:147
bool ruledit_disabled
Definition extras.h:91
struct requirement_vector disappearance_reqs
Definition extras.h:109
bool generated
Definition extras.h:117
int special_idx
Definition extras.h:153
struct requirement_vector rmreqs
Definition extras.h:107
Tech_type_id visibility_req
Definition extras.h:139
int id
Definition extras.h:89
void * ruledit_dlg
Definition extras.h:92
struct requirement_vector reqs
Definition extras.h:106
bool buildable
Definition extras.h:116
int infracost
Definition extras.h:122
struct name_translation name
Definition extras.h:90
struct base_type * base
Definition extras.h:154
enum borders_mode borders
const struct player * player
const struct extra_type * extra
int placing_time
Definition terrain.h:227
Definition tile.h:50
struct unit_list * units
Definition tile.h:58
struct player * extras_owner
Definition tile.h:63
struct extra_type * placing
Definition tile.h:61
Definition unit.h:138
enum unit_activity activity
Definition unit.h:157
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
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define A_NONE
Definition tech.h:43
void resource_types_free(void)
Definition terrain.c:288
bool terrain_has_resource(const struct terrain *pterrain, const struct extra_type *presource)
Definition terrain.c:255
#define terrain_has_flag(terr, flag)
Definition terrain.h:283
void tile_virtual_destroy(struct tile *vtile)
Definition tile.c:1033
void tile_remove_extra(struct tile *ptile, const struct extra_type *pextra)
Definition tile.c:965
struct tile * tile_virtual_new(const struct tile *ptile)
Definition tile.c:981
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_worked(_tile)
Definition tile.h:114
#define tile_terrain(_tile)
Definition tile.h:110
#define tile_has_extra(ptile, pextra)
Definition tile.h:147
#define tile_owner(_tile)
Definition tile.h:96
bool unit_can_do_action_sub_result(const struct unit *punit, enum action_sub_result sub_result)
Definition unit.c:379
bool unit_can_do_action_result(const struct unit *punit, enum action_result result)
Definition unit.c:369
#define tile_changing_activities_iterate_end
Definition unit.h:299
#define unit_owner(_pu)
Definition unit.h:396
#define tile_changing_activities_iterate(_act_)
Definition unit.h:295
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
#define utype_class(_t_)
Definition unittype.h:749
#define uclass_index(_c_)
Definition unittype.h:742