Freeciv-3.3
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 &(const struct req_context) {
481 .player = tile_owner(ptile),
482 },
483 &pextra->reqs,
485}
486
487/************************************************************************/
490bool player_can_place_extra(const struct extra_type *pextra,
491 const struct player *pplayer,
492 const struct tile *ptile)
493{
494 if (pextra->infracost == 0) {
495 return FALSE;
496 }
497
498 if (ptile->placing != NULL) {
499 /* Already placing something */
500 return FALSE;
501 }
502
503 if (tile_terrain(ptile)->placing_time <= 0) {
504 /* Can't place to this terrain */
505 return FALSE;
506 }
507
509 if (tile_owner(ptile) != pplayer) {
510 return FALSE;
511 }
512 } else {
513 struct city *pcity = tile_worked(ptile);
514
515 if (pcity == NULL || city_owner(pcity) != pplayer) {
516 return FALSE;
517 }
518 }
519
520 /* Placing extras is not allowed to tiles where also workers do changes. */
521 unit_list_iterate(ptile->units, punit) {
523 if (punit->activity == act) {
524 return FALSE;
525 }
528
529 return player_can_build_extra(pextra, pplayer, ptile);
530}
531
532/************************************************************************/
535bool can_build_extra(const struct extra_type *pextra,
536 const struct unit *punit,
537 const struct tile *ptile)
538{
539 struct player *pplayer = unit_owner(punit);
540
541 if (!can_build_extra_base(pextra, pplayer, ptile)) {
542 return FALSE;
543 }
544
545 return are_reqs_active(&(const struct req_context) {
546 .player = pplayer,
547 .tile = ptile,
548 .unit = punit,
549 .unittype = unit_type_get(punit),
550 },
551 &(const struct req_context) {
552 .player = tile_owner(ptile),
553 },
554 &pextra->reqs,
556}
557
558/************************************************************************/
561static bool can_extra_be_removed(const struct extra_type *pextra,
562 const struct tile *ptile)
563{
564 struct city *pcity = tile_city(ptile);
565
566 /* Cannot remove EF_ALWAYS_ON_CITY_CENTER extras from city center. */
567 if (pcity != NULL) {
569 return FALSE;
570 }
572 struct tile *vtile = tile_virtual_new(ptile);
573
574 /* Would extra get rebuilt if removed */
575 tile_remove_extra(vtile, pextra);
577 /* No need to worry about conflicting extras - extra would had
578 * not been here if conflicting one is. */
580
581 return FALSE;
582 }
583
585 }
586 }
587
588 return TRUE;
589}
590
591/************************************************************************/
595bool player_can_remove_extra(const struct extra_type *pextra,
596 const struct player *pplayer,
597 const struct tile *ptile)
598{
599 if (!can_extra_be_removed(pextra, ptile)) {
600 return FALSE;
601 }
602
603 return are_reqs_active(&(const struct req_context) {
604 .player = pplayer,
605 .tile = ptile,
606 },
607 &(const struct req_context) {
608 .player = tile_owner(ptile),
609 },
610 &pextra->rmreqs,
612}
613
614/************************************************************************/
618bool can_remove_extra(const struct extra_type *pextra,
619 const struct unit *punit,
620 const struct tile *ptile)
621{
622 if (!can_extra_be_removed(pextra, ptile)) {
623 return FALSE;
624 }
625
626 return are_reqs_active(&(const struct req_context) {
627 .player = unit_owner(punit),
628 .tile = ptile,
629 .unit = punit,
630 .unittype = unit_type_get(punit),
631 },
632 &(const struct req_context) {
633 .player = tile_owner(ptile),
634 },
635 &pextra->rmreqs, RPT_CERTAIN);
636}
637
638/************************************************************************/
641bool is_native_tile_to_extra(const struct extra_type *pextra,
642 const struct tile *ptile)
643{
644 struct terrain *pterr = tile_terrain(ptile);
645
646 if (terrain_has_resource(pterr, pextra)) {
647 return TRUE;
648 }
649
651 && pterr->irrigation_time == 0) {
652 return FALSE;
653 }
654
655 if (is_extra_caused_by(pextra, EC_MINE)
656 && pterr->mining_time == 0) {
657 return FALSE;
658 }
659
660 if (is_extra_caused_by(pextra, EC_BASE)) {
661 if (pterr->base_time == 0) {
662 return FALSE;
663 }
664 if (tile_city(ptile) != NULL && extra_base_get(pextra)->border_sq >= 0) {
665 return FALSE;
666 }
667 }
668
669 if (is_extra_caused_by(pextra, EC_ROAD)) {
670 struct road_type *proad = extra_road_get(pextra);
671
674 return FALSE;
675 }
676 } else if (pterr->road_time == 0) {
677 return FALSE;
678 }
679 }
680
681 return are_reqs_active(&(const struct req_context) { .tile = ptile },
682 NULL, &pextra->reqs, RPT_POSSIBLE);
683}
684
685/************************************************************************/
688bool extra_conflicting_on_tile(const struct extra_type *pextra,
689 const struct tile *ptile)
690{
692 if (tile_has_extra(ptile, old_extra)
693 && !can_extras_coexist(old_extra, pextra)) {
694 return TRUE;
695 }
697
698 return FALSE;
699}
700
701/************************************************************************/
705bool hut_on_tile(const struct tile *ptile)
706{
708 if (tile_has_extra(ptile, extra)) {
709 return TRUE;
710 }
712
713 return FALSE;
714}
715
716/************************************************************************/
720bool unit_can_enter_hut(const struct unit *punit,
721 const struct tile *ptile)
722{
723 const struct req_context context = {
725 .tile = ptile,
726 };
727
730 return FALSE;
731 }
733 if (tile_has_extra(ptile, extra)
735 &(const struct req_context) {
736 .player = tile_owner(ptile),
737 },
739 return TRUE;
740 }
742 return FALSE;
743}
744
745/************************************************************************/
750 const struct tile *ptile)
751{
752 const struct req_context context = {
754 .tile = ptile,
755 };
756
761 return FALSE;
762 }
764 if (tile_has_extra(ptile, extra)
766 &(const struct req_context) {
767 .player = tile_owner(ptile),
768 },
770 return TRUE;
771 }
773 return FALSE;
774}
775
776/************************************************************************/
779struct extra_type *next_extra_for_tile(const struct tile *ptile, enum extra_cause cause,
780 const struct player *pplayer,
781 const struct unit *punit)
782{
783 extra_type_by_cause_iterate(cause, pextra) {
784 if (!tile_has_extra(ptile, pextra)) {
785 if (punit != NULL) {
786 if (can_build_extra(pextra, punit, ptile)) {
787 return pextra;
788 }
789 } else {
790 /* punit is certainly NULL, pplayer can be too */
791 if (player_can_build_extra(pextra, pplayer, ptile)) {
792 return pextra;
793 }
794 }
795 }
797
798 return NULL;
799}
800
801/************************************************************************/
804struct extra_type *prev_extra_in_tile(const struct tile *ptile,
806 const struct player *pplayer,
807 const struct unit *punit)
808{
809 fc_assert(punit != NULL || pplayer != NULL);
810
812 if (tile_has_extra(ptile, pextra)) {
813 if (punit != NULL) {
814 if (can_remove_extra(pextra, punit, ptile)) {
815 return pextra;
816 }
817 } else {
818 if (player_can_remove_extra(pextra, pplayer, ptile)) {
819 return pextra;
820 }
821 }
822 }
824
825 return NULL;
826}
827
828/************************************************************************/
831struct extra_type *prev_cleanable_in_tile(const struct tile *ptile,
832 const struct player *pplayer,
833 const struct unit *punit)
834{
835 fc_assert(punit != NULL || pplayer != NULL);
836
838 if (tile_has_extra(ptile, pextra)) {
839 if (punit != NULL) {
840 if (can_remove_extra(pextra, punit, ptile)) {
841 return pextra;
842 }
843 } else {
844 if (player_can_remove_extra(pextra, pplayer, ptile)) {
845 return pextra;
846 }
847 }
848 }
850
851 return NULL;
852}
853
854/************************************************************************/
857bool is_native_extra_to_uclass(const struct extra_type *pextra,
858 const struct unit_class *pclass)
859{
860 return BV_ISSET(pextra->native_to, uclass_index(pclass));
861}
862
863/************************************************************************/
866bool is_native_extra_to_utype(const struct extra_type *pextra,
867 const struct unit_type *punittype)
868{
870}
871
872/************************************************************************/
875bool extra_has_flag(const struct extra_type *pextra, enum extra_flag_id flag)
876{
877 return BV_ISSET(pextra->flags, flag);
878}
879
880/************************************************************************/
884bool is_extra_flag_card_near(const struct civ_map *nmap, const struct tile *ptile,
885 enum extra_flag_id flag)
886{
887 extra_type_iterate(pextra) {
888 if (extra_has_flag(pextra, flag)) {
890 if (tile_has_extra(adjc_tile, pextra)) {
891 return TRUE;
892 }
894 }
896
897 return FALSE;
898}
899
900/************************************************************************/
904bool is_extra_flag_near_tile(const struct civ_map *nmap, const struct tile *ptile,
905 enum extra_flag_id flag)
906{
907 extra_type_iterate(pextra) {
908 if (extra_has_flag(pextra, flag)) {
909 adjc_iterate(nmap, ptile, adjc_tile) {
910 if (tile_has_extra(adjc_tile, pextra)) {
911 return TRUE;
912 }
914 }
916
917 return FALSE;
918}
919
920/************************************************************************/
924{
925 int i;
926
927 for (i = 0; i < MAX_NUM_USER_EXTRA_FLAGS; i++) {
929 }
930}
931
932/************************************************************************/
936{
937 int i;
938
939 for (i = 0; i < MAX_NUM_USER_EXTRA_FLAGS; i++) {
941 }
942}
943
944/************************************************************************/
948 const char *helptxt)
949{
950 int efid = id - EF_USER_FLAG_1;
951
953
954 if (user_extra_flags[efid].name != NULL) {
957 }
958
959 if (name && name[0] != '\0') {
961 }
962
963 if (user_extra_flags[efid].helptxt != NULL) {
964 free(user_extra_flags[efid].helptxt);
966 }
967
968 if (helptxt && helptxt[0] != '\0') {
970 }
971}
972
973/************************************************************************/
977{
979 return NULL;
980 }
981
982 return user_extra_flags[flag - EF_USER_FLAG_1].name;
983}
984
985/************************************************************************/
989{
991
993}
994
995/**********************************************************************/
1002{
1004 if (extra_has_flag(pextra, id)) {
1005 /* Found a user. */
1006 return TRUE;
1007 }
1009
1010 /* No users detected. */
1011 return FALSE;
1012}
1013
1014/************************************************************************/
1018 const struct extra_type *pextra2)
1019{
1020 if (pextra1 == pextra2) {
1021 return TRUE;
1022 }
1023
1024 return !BV_ISSET(pextra1->conflicts, extra_index(pextra2));
1025}
1026
1027/************************************************************************/
1032{
1033 switch (upset) {
1034 case EUT_GLOBAL_WARMING:
1035 return extra_has_flag(pextra, EF_GLOBAL_WARMING);
1036 case EUT_NUCLEAR_WINTER:
1037 return extra_has_flag(pextra, EF_NUCLEAR_WINTER);
1038 }
1039
1040 return FALSE;
1041}
1042
1043/************************************************************************/
1047{
1048 /* Is any of the worker build action bits set? */
1049 return (pextra->causes
1050 & (1 << EC_IRRIGATION
1051 | 1 << EC_MINE
1052 | 1 << EC_BASE
1053 | 1 << EC_ROAD));
1054}
1055
1056/************************************************************************/
1060{
1061 /* Is any of the worker remove action bits set? */
1062 return (pextra->rmcauses
1063 & (1 << ERM_CLEAN
1064 | 1 << ERM_PILLAGE));
1065}
1066
1067/************************************************************************/
1070bool is_extra_caused_by_action(const struct extra_type *pextra,
1071 const struct action *paction)
1072{
1074 return is_extra_caused_by(pextra, activity_to_extra_cause(act));
1075}
1076
1077/************************************************************************/
1080bool is_extra_removed_by_action(const struct extra_type *pextra,
1081 const struct action *paction)
1082{
1085}
1086
1087/************************************************************************/
1091{
1092 switch (act) {
1093 case ACTIVITY_IRRIGATE:
1094 return EC_IRRIGATION;
1095 case ACTIVITY_MINE:
1096 return EC_MINE;
1097 case ACTIVITY_BASE:
1098 return EC_BASE;
1099 case ACTIVITY_GEN_ROAD:
1100 return EC_ROAD;
1101 default:
1102 break;
1103 }
1104
1105 return EC_NONE;
1106}
1107
1108/************************************************************************/
1112{
1113 switch (act) {
1114 case ACTIVITY_CLEAN:
1115 return ERM_CLEAN;
1116 case ACTIVITY_PILLAGE:
1117 return ERM_PILLAGE;
1118 default:
1119 break;
1120 }
1121
1122 return ERM_NONE;
1123}
1124
1125/************************************************************************/
1128struct player *extra_owner(const struct tile *ptile)
1129{
1130 return ptile->extras_owner;
1131}
1132
1133/************************************************************************/
1136bool can_extra_appear(const struct extra_type *pextra, const struct tile *ptile)
1137{
1138 return !tile_has_extra(ptile, pextra)
1140 && is_native_tile_to_extra(pextra, ptile)
1141 && !extra_conflicting_on_tile(pextra, ptile)
1142 && are_reqs_active(&(const struct req_context) { .tile = ptile },
1143 &(const struct req_context) {
1144 .player = tile_owner(ptile),
1145 },
1146 &pextra->appearance_reqs, RPT_CERTAIN);
1147}
1148
1149/************************************************************************/
1152bool can_extra_disappear(const struct extra_type *pextra, const struct tile *ptile)
1153{
1154 return tile_has_extra(ptile, pextra)
1156 && can_extra_be_removed(pextra, ptile)
1157 && are_reqs_active(&(const struct req_context) { .tile = ptile },
1158 &(const struct req_context) {
1159 .player = tile_owner(ptile),
1160 },
1162}
1163
1164/************************************************************************/
1167bool player_knows_extra_exist(const struct player *pplayer,
1168 const struct extra_type *pextra,
1169 const struct tile *ptile)
1170{
1171 if (!tile_has_extra(ptile, pextra)) {
1172 return FALSE;
1173 }
1174
1175 return research_invention_state(research_get(pplayer),
1176 pextra->visibility_req) == TECH_KNOWN;
1177}
#define action_get_activity(_pact_)
Definition actions.h:460
void base_types_free(void)
Definition base.c:136
#define BV_ISSET(bv, bit)
Definition bitvector.h:86
#define city_owner(_pcity_)
Definition city.h:560
char * incite_cost
Definition comments.c:76
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
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 int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
int int id
Definition editgui_g.h:28
struct @22::@23 reqs
bool is_extra_removed_by_worker_action(const struct extra_type *pextra)
Definition extras.c:1059
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:779
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:831
bool extra_causes_env_upset(struct extra_type *pextra, enum environment_upset_type upset)
Definition extras.c:1030
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:749
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:490
void user_extra_flags_init(void)
Definition extras.c:923
struct player * extra_owner(const struct tile *ptile)
Definition extras.c:1128
bool extra_flag_is_in_use(enum extra_flag_id id)
Definition extras.c:1001
const char * extra_flag_helptxt(enum extra_flag_id id)
Definition extras.c:988
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:947
bool is_extra_flag_near_tile(const struct civ_map *nmap, const struct tile *ptile, enum extra_flag_id flag)
Definition extras.c:904
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:720
bool is_extra_caused_by_worker_action(const struct extra_type *pextra)
Definition extras.c:1046
bool is_extra_flag_card_near(const struct civ_map *nmap, const struct tile *ptile, enum extra_flag_id flag)
Definition extras.c:884
void extras_free(void)
Definition extras.c:84
bool can_extra_appear(const struct extra_type *pextra, const struct tile *ptile)
Definition extras.c:1136
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:875
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:641
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:804
bool hut_on_tile(const struct tile *ptile)
Definition extras.c:705
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:1090
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:866
const char * extra_flag_id_name_cb(enum extra_flag_id flag)
Definition extras.c:976
bool extra_conflicting_on_tile(const struct extra_type *pextra, const struct tile *ptile)
Definition extras.c:688
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:1017
void extra_flags_free(void)
Definition extras.c:935
bool can_remove_extra(const struct extra_type *pextra, const struct unit *punit, const struct tile *ptile)
Definition extras.c:618
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:1070
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:1080
enum extra_rmcause activity_to_extra_rmcause(enum unit_activity act)
Definition extras.c:1111
bool player_can_remove_extra(const struct extra_type *pextra, const struct player *pplayer, const struct tile *ptile)
Definition extras.c:595
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:561
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:1167
bool can_build_extra(const struct extra_type *pextra, const struct unit *punit, const struct tile *ptile)
Definition extras.c:535
bool is_native_extra_to_uclass(const struct extra_type *pextra, const struct unit_class *pclass)
Definition extras.c:857
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:1152
#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:826
environment_upset_type
Definition fc_types.h:986
@ EUT_NUCLEAR_WINTER
Definition fc_types.h:988
@ EUT_GLOBAL_WARMING
Definition fc_types.h:987
@ RPT_CERTAIN
Definition fc_types.h:533
@ RPT_POSSIBLE
Definition fc_types.h:532
#define EC_NONE
Definition fc_types.h:821
#define MAX_EXTRA_TYPES
Definition fc_types.h:50
#define ERM_NONE
Definition fc_types.h:844
@ BORDERS_DISABLED
Definition fc_types.h:745
#define Qn_(String)
Definition fcintl.h:89
void user_flag_init(struct user_flag *flag)
Definition game.c:829
void user_flag_free(struct user_flag *flag)
Definition game.c:838
struct civ_game game
Definition game.c:61
const char * name
Definition inputfile.c:127
#define fc_assert_ret(condition)
Definition log.h:192
#define fc_assert(condition)
Definition log.h:177
#define fc_assert_ret_val(condition, val)
Definition log.h:195
#define adjc_iterate_end
Definition map.h:430
#define cardinal_adjc_iterate_end
Definition map.h:456
#define adjc_iterate(nmap, center_tile, itr_tile)
Definition map.h:425
#define cardinal_adjc_iterate(nmap, center_tile, itr_tile)
Definition map.h:452
#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 req_context *other_context, 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:416
void road_types_free(void)
Definition road.c:134
void strvec_destroy(struct strvec *psv)
Definition city.h:317
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_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 extra_type::@26 data
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
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:140
enum unit_activity activity
Definition unit.h:159
char * name
Definition game.h:74
char * helptxt
Definition game.h:75
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:186
#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:176
void tile_virtual_destroy(struct tile *vtile)
Definition tile.c:1035
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:115
#define tile_terrain(_tile)
Definition tile.h:111
#define tile_has_extra(ptile, pextra)
Definition tile.h:148
#define tile_owner(_tile)
Definition tile.h:97
bool unit_can_do_action_sub_result(const struct unit *punit, enum action_sub_result sub_result)
Definition unit.c:403
bool unit_can_do_action_result(const struct unit *punit, enum action_result result)
Definition unit.c:393
#define tile_changing_activities_iterate_end
Definition unit.h:302
#define unit_owner(_pu)
Definition unit.h:403
#define tile_changing_activities_iterate(_act_)
Definition unit.h:298
#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:756
#define uclass_index(_c_)
Definition unittype.h:749