Freeciv-3.3: /fast/freeciv/nightly/main/common/metaknowledge.c Source File

Freeciv-3.3

Loading...
Searching...
No Matches
metaknowledge.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996-2013 - Freeciv Development 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/* common */
19#include "diptreaty.h"
20#include "game.h"
21#include "map.h"
22#include "metaknowledge.h"
23#include "tile.h"
24#include "traderoutes.h"
25
26/**********************************************************************/
30 static bool is_tile_seen_cadj(const struct player *pow_player,
31 const struct tile *target_tile)
32{
33 /* The tile it self is unseen. */
34 if (!tile_is_seen(target_tile, pow_player)) {
35 return FALSE;
36 }
37
38 /* A cardinally adjacent tile is unseen. */
39 cardinal_adjc_iterate(&(wld.map), target_tile, ptile) {
40 if (!tile_is_seen(ptile, pow_player)) {
41 return FALSE;
42 }
43 } cardinal_adjc_iterate_end;
44
45 /* They are all seen. */
46 return TRUE;
47}
48
49/**********************************************************************/
53 static bool is_tile_seen_adj(const struct player *pow_player,
54 const struct tile *target_tile)
55{
56 /* The tile it self is unseen. */
57 if (!tile_is_seen(target_tile, pow_player)) {
58 return FALSE;
59 }
60
61 /* An adjacent tile is unseen. */
62 adjc_iterate(&(wld.map), target_tile, ptile) {
63 if (!tile_is_seen(ptile, pow_player)) {
64 return FALSE;
65 }
66 } adjc_iterate_end;
67
68 /* They are all seen. */
69 return TRUE;
70}
71
72/**********************************************************************/
75 static bool is_tile_seen_city(const struct player *pow_player,
76 const struct city *target_city)
77{
78 const struct civ_map *nmap = &(wld.map);
79
80 /* Don't know the city radius. */
81 if (!can_player_see_city_internals(pow_player, target_city)) {
82 return FALSE;
83 }
84
85 /* A tile of the city is unseen */
86 city_tile_iterate(nmap, city_map_radius_sq_get(target_city),
87 city_tile(target_city), ptile) {
88 if (!tile_is_seen(ptile, pow_player)) {
89 return FALSE;
90 }
91 } city_tile_iterate_end;
92
93 /* They are all seen. */
94 return TRUE;
95}
96
97/**********************************************************************/
101 static bool is_tile_seen_trade_route(const struct player *pow_player,
102 const struct city *target_city)
103{
104 /* Don't know who the trade routes will go to. */
105 if (!can_player_see_city_internals(pow_player, target_city)) {
106 return FALSE;
107 }
108
109 /* A tile of the city is unseen */
110 if (!is_tile_seen_city(pow_player, target_city)) {
111 return FALSE;
112 }
113
114 /* A tile of a trade parter is unseen */
115 trade_partners_iterate(target_city, trade_partner) {
116 if (!is_tile_seen_city(pow_player, trade_partner)) {
117 return FALSE;
118 }
119 } trade_partners_iterate_end;
120
121 /* They are all seen. */
122 return TRUE;
123}
124
125/**********************************************************************/
129 static bool can_plr_see_all_sym_diplrels_of(const struct player *pplayer,
130 const struct player *tplayer)
131{
132 if (pplayer == tplayer) {
133 /* Can see own relationships. */
134 return TRUE;
135 }
136
137 if (team_has_embassy(pplayer->team, tplayer)) {
138 /* Gets reports from the embassy. */
139 return TRUE;
140 }
141
142 if (player_diplstate_get(pplayer, tplayer)->contact_turns_left > 0) {
143 /* Can see relationships during contact turns. */
144 return TRUE;
145 }
146
147 return FALSE;
148}
149
150/**********************************************************************/
160 static bool is_req_knowable(const struct player *pov_player,
161 const struct req_context *context,
162 const struct player *other_player,
163 const struct requirement *req,
164 const enum req_problem_type prob_type)
165{
166 fc_assert_ret_val_msg(NULL != pov_player, FALSE, "No point of view");
167
168 if (context == NULL) {
169 context = req_context_empty();
170 }
171
172 if (req->source.kind == VUT_UTFLAG
173 || req->source.kind == VUT_UTYPE
174 || req->source.kind == VUT_UCLASS
175 || req->source.kind == VUT_UCFLAG
176 || req->source.kind == VUT_MINVETERAN
177 || req->source.kind == VUT_MINHP) {
178 switch (req->range) {
179 case REQ_RANGE_LOCAL:
180 if (context->unit == NULL) {
181 /* The unit may exist but not be passed when the problem type is
182 * RPT_POSSIBLE. */
183 return prob_type == RPT_CERTAIN;
184 }
185
186 return can_player_see_unit(pov_player, context->unit);
187 case REQ_RANGE_TILE:
188 case REQ_RANGE_CADJACENT:
189 case REQ_RANGE_ADJACENT:
190 case REQ_RANGE_CONTINENT:
191 case REQ_RANGE_CITY:
192 case REQ_RANGE_TRADE_ROUTE:
193 case REQ_RANGE_PLAYER:
194 case REQ_RANGE_TEAM:
195 case REQ_RANGE_ALLIANCE:
196 case REQ_RANGE_WORLD:
197 case REQ_RANGE_COUNT:
198 return FALSE;
199 }
200 }
201
202 if (req->source.kind == VUT_UNITSTATE) {
203 fc_assert_ret_val_msg(req->range == REQ_RANGE_LOCAL, FALSE, "Wrong range");
204
205 if (context->unit == NULL) {
206 /* The unit may exist but not be passed when the problem type is
207 * RPT_POSSIBLE. */
208 return prob_type == RPT_CERTAIN;
209 }
210
211 switch (req->source.value.unit_state) {
212 case USP_TRANSPORTED:
213 case USP_LIVABLE_TILE:
214 case USP_TRANSPORTING:
215 case USP_NATIVE_TILE:
216 case USP_NATIVE_EXTRA:
217 /* Known if the unit is seen by the player. */
218 return can_player_see_unit(pov_player, context->unit);
219 case USP_HAS_HOME_CITY:
220 case USP_MOVED_THIS_TURN:
221 /* Known to the unit's owner. */
222 return unit_owner(context->unit) == pov_player;
223 case USP_COUNT:
224 fc_assert_msg(req->source.value.unit_state != USP_COUNT,
225 "Invalid unit state property.");
226 /* Invalid property is unknowable. */
227 return FALSE;
228 }
229 }
230
231 if (req->source.kind == VUT_MINMOVES) {
232 fc_assert_ret_val_msg(req->range == REQ_RANGE_LOCAL, FALSE, "Wrong range");
233
234 if (context->unit == NULL) {
235 /* The unit may exist but not be passed when the problem type is
236 * RPT_POSSIBLE. */
237 return prob_type == RPT_CERTAIN;
238 }
239
240 switch (req->range) {
241 case REQ_RANGE_LOCAL:
242 /* The owner can see if their unit has move fragments left. */
243 return unit_owner(context->unit) == pov_player;
244 case REQ_RANGE_TILE:
245 case REQ_RANGE_CADJACENT:
246 case REQ_RANGE_ADJACENT:
247 case REQ_RANGE_CITY:
248 case REQ_RANGE_TRADE_ROUTE:
249 case REQ_RANGE_CONTINENT:
250 case REQ_RANGE_PLAYER:
251 case REQ_RANGE_TEAM:
252 case REQ_RANGE_ALLIANCE:
253 case REQ_RANGE_WORLD:
254 case REQ_RANGE_COUNT:
255 /* Invalid range */
256 return FALSE;
257 }
258 }
259
260 if (req->source.kind == VUT_ACTIVITY) {
261 fc_assert_ret_val_msg(req->range == REQ_RANGE_LOCAL,
262 FALSE, "Wrong range");
263
264 if (context->unit == NULL) {
265 /* The unit may exist but not be passed when the problem type is
266 * RPT_POSSIBLE. */
267 return prob_type == RPT_CERTAIN;
268 }
269
270 if (unit_owner(context->unit) == pov_player) {
271 return TRUE;
272 }
273
274 /* Sent in package_short_unit() */
275 return can_player_see_unit(pov_player, context->unit);
276 }
277
278 if (req->source.kind == VUT_DIPLREL
279 || req->source.kind == VUT_DIPLREL_TILE
280 || req->source.kind == VUT_DIPLREL_TILE_O
281 || req->source.kind == VUT_DIPLREL_UNITANY
282 || req->source.kind == VUT_DIPLREL_UNITANY_O) {
283 switch (req->range) {
284 case REQ_RANGE_LOCAL:
285 if (other_player == NULL
286 || context->player == NULL) {
287 /* The two players may exist but not be passed when the problem
288 * type is RPT_POSSIBLE. */
289 return prob_type == RPT_CERTAIN;
290 }
291
292 if (pov_player == context->player
293 || pov_player == other_player) {
294 return TRUE;
295 }
296
297 if (can_plr_see_all_sym_diplrels_of(pov_player, context->player)
298 || can_plr_see_all_sym_diplrels_of(pov_player, other_player)) {
299 return TRUE;
300 }
301
302 /* TODO: Non symmetric diplomatic relationships. */
303 break;
304 case REQ_RANGE_PLAYER:
305 if (context->player == NULL) {
306 /* The target player may exist but not be passed when the problem
307 * type is RPT_POSSIBLE. */
308 return prob_type == RPT_CERTAIN;
309 }
310
311 if (pov_player == context->player) {
312 return TRUE;
313 }
314
315 if (can_plr_see_all_sym_diplrels_of(pov_player, context->player)) {
316 return TRUE;
317 }
318
319 /* TODO: Non symmetric diplomatic relationships. */
320 break;
321 case REQ_RANGE_TEAM:
322 /* TODO */
323 break;
324 case REQ_RANGE_ALLIANCE:
325 /* TODO */
326 break;
327 case REQ_RANGE_WORLD:
328 /* TODO */
329 break;
330 case REQ_RANGE_TILE:
331 case REQ_RANGE_CADJACENT:
332 case REQ_RANGE_ADJACENT:
333 case REQ_RANGE_CITY:
334 case REQ_RANGE_TRADE_ROUTE:
335 case REQ_RANGE_CONTINENT:
336 case REQ_RANGE_COUNT:
337 /* Invalid range */
338 return FALSE;
339 break;
340 }
341 }
342
343 if (req->source.kind == VUT_MINSIZE) {
344 if (context->city == NULL) {
345 /* The city may exist but not be passed when the problem type is
346 * RPT_POSSIBLE. */
347 return prob_type == RPT_CERTAIN;
348 }
349
350 if (player_can_see_city_externals(pov_player, context->city)) {
351 return TRUE;
352 }
353 }
354
355 if (req->source.kind == VUT_CITYTILE) {
356 struct city *pcity;
357
358 if (context->city == NULL) {
359 switch (req->source.value.citytile) {
360 case CITYT_CENTER:
361 case CITYT_SAME_CONTINENT:
362 case CITYT_BORDERING_TCLASS_REGION:
363 /* Require the city, not passed */
364 return prob_type == RPT_CERTAIN;
365 case CITYT_CLAIMED:
366 case CITYT_WORKED:
367 case CITYT_EXTRAS_OWNED:
368 /* Do not require a city passed */
369 break;
370 case CITYT_LAST:
371 /* Invalid */
372 fc_assert_msg(req->source.value.citytile != CITYT_LAST,
373 "Invalid city tile property.");
374 return FALSE;
375 }
376 }
377
378 if (context->tile == NULL) {
379 /* The tile may exist but not be passed when the problem type is
380 * RPT_POSSIBLE. */
381 return prob_type == RPT_CERTAIN;
382 }
383
384 switch (req->range) {
385 case REQ_RANGE_TILE:
386 /* Known because the tile is seen */
387 if (tile_is_seen(context->tile, pov_player)) {
388 return TRUE;
389 }
390
391 /* The player knows their city even if they can't see it */
392 pcity = tile_city(context->tile);
393 return pcity && city_owner(pcity) == pov_player;
394 case REQ_RANGE_CADJACENT:
395 /* Known because the tile is seen */
396 if (is_tile_seen_cadj(pov_player, context->tile)) {
397 return TRUE;
398 }
399
400 /* The player knows their city even if they can't see it */
401 cardinal_adjc_iterate(&(wld.map), context->tile, ptile) {
402 pcity = tile_city(ptile);
403 if (pcity && city_owner(pcity) == pov_player) {
404 return TRUE;
405 }
406 } cardinal_adjc_iterate_end;
407
408 /* Unknown */
409 return FALSE;
410 case REQ_RANGE_ADJACENT:
411 /* Known because the tile is seen */
412 if (is_tile_seen_adj(pov_player, context->tile)) {
413 return TRUE;
414 }
415
416 /* The player knows their city even if they can't see it */
417 adjc_iterate(&(wld.map), context->tile, ptile) {
418 pcity = tile_city(ptile);
419 if (pcity && city_owner(pcity) == pov_player) {
420 return TRUE;
421 }
422 } adjc_iterate_end;
423
424 /* Unknown */
425 return FALSE;
426 case REQ_RANGE_CITY:
427 case REQ_RANGE_TRADE_ROUTE:
428 case REQ_RANGE_CONTINENT:
429 case REQ_RANGE_PLAYER:
430 case REQ_RANGE_TEAM:
431 case REQ_RANGE_ALLIANCE:
432 case REQ_RANGE_WORLD:
433 case REQ_RANGE_LOCAL:
434 case REQ_RANGE_COUNT:
435 /* Invalid range */
436 return FALSE;
437 }
438 }
439
440 if (req->source.kind == VUT_IMPR_GENUS) {
441 /* The only legal range when this was written was local. */
442 fc_assert(req->range == REQ_RANGE_LOCAL);
443
444 if (context->city == NULL) {
445 /* RPT_CERTAIN: Can't be. No city to contain it.
446 * RPT_POSSIBLE: A city like that may exist but not be passed. */
447 return prob_type == RPT_CERTAIN;
448 }
449
450 /* Local BuildingGenus could be about city production. */
451 return can_player_see_city_internals(pov_player, context->city);
452 }
453
454 if (req->source.kind == VUT_IMPROVEMENT) {
455 switch (req->range) {
456 case REQ_RANGE_WORLD:
457 case REQ_RANGE_ALLIANCE:
458 case REQ_RANGE_TEAM:
459 case REQ_RANGE_PLAYER:
460 case REQ_RANGE_CONTINENT:
461 /* Only wonders (great or small) can be required in those ranges.
462 * Wonders are always visible. */
463 return TRUE;
464 case REQ_RANGE_TRADE_ROUTE:
465 /* Could be known for trade routes to cities owned by pov_player as
466 * long as the requirement is present. Not present requirements would
467 * require knowledge that no trade routes to another foreign city
468 * exists (since all possible trade routes are to a city owned by
469 * pov_player). Not worth the complexity, IMHO. */
470 return FALSE;
471 case REQ_RANGE_CITY:
472 case REQ_RANGE_LOCAL:
473 if (context->city == NULL) {
474 /* RPT_CERTAIN: Can't be. No city to contain it.
475 * RPT_POSSIBLE: A city like that may exist but not be passed. */
476 return prob_type == RPT_CERTAIN;
477 }
478
479 if (can_player_see_city_internals(pov_player, context->city)) {
480 /* Anyone that can see city internals (like the owner) known all
481 * its improvements. */
482 return TRUE;
483 }
484
485 if (is_improvement_visible(req->source.value.building)
486 && player_can_see_city_externals(pov_player, context->city)) {
487 /* Can see visible improvements when the outside of the city is
488 * seen. */
489 return TRUE;
490 }
491
492 /* No way to know if a city has an improvement */
493 return FALSE;
494 case REQ_RANGE_TILE:
495 if (context->tile == NULL) {
496 /* RPT_CERTAIN: Can't be. No tile to contain it.
497 * RPT_POSSIBLE: A tile city like that may exist but not be passed. */
498 return prob_type == RPT_CERTAIN;
499 }
500
501 {
502 const struct city *tcity = tile_city(context->tile);
503
504 if (!tcity) {
505 /* No building can be in no city if it's known
506 * there is no city */
507 if (is_great_wonder(req->source.value.building)) {
508 const struct city *wcity
509 = city_from_great_wonder(req->source.value.building);
510
511 if (!wcity
512 || player_can_see_city_externals(pov_player, wcity)) {
513 /* Player can be sure the wonder is not here */
514 return TRUE;
515 /* FIXME: deducing from known borders aside, the player
516 * may have seen wcity before and cities don't move */
517 }
518 }
519
520 return tile_is_seen(context->tile, pov_player);
521 }
522
523 if (can_player_see_city_internals(pov_player, tcity)) {
524 /* Anyone that can see city internals (like the owner) known all
525 * its improvements. */
526 return TRUE;
527 }
528
529 if (is_improvement_visible(req->source.value.building)
530 && player_can_see_city_externals(pov_player, tcity)) {
531 /* Can see visible improvements when the outside of the city is
532 * seen. */
533 return TRUE;
534 }
535 }
536
537 /* No way to know if a city has an improvement */
538 return FALSE;
539 case REQ_RANGE_CADJACENT:
540 case REQ_RANGE_ADJACENT:
541 case REQ_RANGE_COUNT:
542 /* Not supported by the requirement type. */
543 return FALSE;
544 }
545 }
546
547 if (req->source.kind == VUT_NATION
548 || req->source.kind == VUT_NATIONGROUP) {
549 if (context->player == NULL
550 && (req->range == REQ_RANGE_PLAYER
551 || req->range == REQ_RANGE_TEAM
552 || req->range == REQ_RANGE_ALLIANCE)) {
553 /* The player (that can have a nationality or be allied to someone
554 * with the nationality) may exist but not be passed when the problem
555 * type is RPT_POSSIBLE. */
556 return prob_type == RPT_CERTAIN;
557 }
558
559 return TRUE;
560 }
561
562 if (req->source.kind == VUT_ADVANCE || req->source.kind == VUT_TECHFLAG) {
563 if (req->range == REQ_RANGE_PLAYER) {
564 if (context->player == NULL) {
565 /* The player (that may or may not possess the tech) may exist but
566 * not be passed when the problem type is RPT_POSSIBLE. */
567 return prob_type == RPT_CERTAIN;
568 }
569
570 return can_see_techs_of_target(pov_player, context->player);
571 } else if (req->range == REQ_RANGE_WORLD && req->survives) {
572 /* game.info.global_advances is sent to each player */
573 return TRUE;
574 }
575 }
576
577 if (req->source.kind == VUT_GOVERNMENT) {
578 if (req->range == REQ_RANGE_PLAYER) {
579 if (context->player == NULL) {
580 /* The player (that may or may not possess the tech) may exist but
581 * not be passed when the problem type is RPT_POSSIBLE. */
582 return prob_type == RPT_CERTAIN;
583 }
584
585 return (pov_player == context->player
586 || could_intel_with_player(pov_player, context->player));
587 }
588 }
589
590 if (req->source.kind == VUT_MAXTILEUNITS) {
591 if (context->tile == NULL) {
592 /* The tile may exist but not be passed when the problem type is
593 * RPT_POSSIBLE. */
594 return prob_type == RPT_CERTAIN;
595 }
596
597 switch (req->range) {
598 case REQ_RANGE_TILE:
599 return can_player_see_hypotetic_units_at(pov_player, context->tile);
600 case REQ_RANGE_CADJACENT:
601 if (!can_player_see_hypotetic_units_at(pov_player, context->tile)) {
602 return FALSE;
603 }
604 cardinal_adjc_iterate(&(wld.map), context->tile, adjc_tile) {
605 if (!can_player_see_hypotetic_units_at(pov_player, adjc_tile)) {
606 return FALSE;
607 }
608 } cardinal_adjc_iterate_end;
609
610 return TRUE;
611 case REQ_RANGE_ADJACENT:
612 if (!can_player_see_hypotetic_units_at(pov_player, context->tile)) {
613 return FALSE;
614 }
615 adjc_iterate(&(wld.map), context->tile, adjc_tile) {
616 if (!can_player_see_hypotetic_units_at(pov_player, adjc_tile)) {
617 return FALSE;
618 }
619 } adjc_iterate_end;
620
621 return TRUE;
622 case REQ_RANGE_CONTINENT:
623 case REQ_RANGE_CITY:
624 case REQ_RANGE_TRADE_ROUTE:
625 case REQ_RANGE_PLAYER:
626 case REQ_RANGE_TEAM:
627 case REQ_RANGE_ALLIANCE:
628 case REQ_RANGE_WORLD:
629 case REQ_RANGE_LOCAL:
630 case REQ_RANGE_COUNT:
631 /* Non existing. */
632 return FALSE;
633 }
634 }
635
636 if (req->source.kind == VUT_EXTRA
637 || req->source.kind == VUT_EXTRAFLAG
638 || req->source.kind == VUT_ROADFLAG) {
639 if (req->range == REQ_RANGE_LOCAL) {
640 if (context->extra == NULL) {
641 /* The extra may exist but not be passed when the problem type is
642 * RPT_POSSIBLE. */
643 return prob_type == RPT_CERTAIN;
644 }
645 /* The extra is given; we can figure out whether it matches. */
646 return TRUE;
647 }
648 /* Other ranges handled below */
649 }
650
651 if (req->source.kind == VUT_TERRAIN
652 || req->source.kind == VUT_TERRFLAG
653 || req->source.kind == VUT_TERRAINCLASS
654 || req->source.kind == VUT_TERRAINALTER
655 || req->source.kind == VUT_EXTRA
656 || req->source.kind == VUT_EXTRAFLAG
657 || req->source.kind == VUT_ROADFLAG) {
658 if (context->tile == NULL) {
659 /* The tile may exist but not be passed when the problem type is
660 * RPT_POSSIBLE. */
661 return prob_type == RPT_CERTAIN;
662 }
663
664 switch (req->range) {
665 case REQ_RANGE_TILE:
666 return tile_is_seen(context->tile, pov_player);
667 case REQ_RANGE_CADJACENT:
668 /* TODO: The answer is known when the universal is located on a seen
669 * tile. Is returning TRUE in those cases worth the added complexity
670 * and the extra work for the computer? */
671 return is_tile_seen_cadj(pov_player, context->tile);
672 case REQ_RANGE_ADJACENT:
673 /* TODO: The answer is known when the universal is located on a seen
674 * tile. Is returning TRUE in those cases worth the added complexity
675 * and the extra work for the computer? */
676 return is_tile_seen_adj(pov_player, context->tile);
677 case REQ_RANGE_CITY:
678 /* TODO: The answer is known when the universal is located on a seen
679 * tile. Is returning TRUE in those cases worth the added complexity
680 * and the extra work for the computer? */
681 return is_tile_seen_city(pov_player, context->city);
682 case REQ_RANGE_TRADE_ROUTE:
683 /* TODO: The answer is known when the universal is located on a seen
684 * tile. Is returning TRUE in those cases worth the added complexity
685 * and the extra work for the computer? */
686 return is_tile_seen_trade_route(pov_player, context->city);
687 case REQ_RANGE_CONTINENT:
688 case REQ_RANGE_PLAYER:
689 case REQ_RANGE_ALLIANCE:
690 case REQ_RANGE_TEAM:
691 case REQ_RANGE_WORLD:
692 case REQ_RANGE_LOCAL:
693 case REQ_RANGE_COUNT:
694 /* Non existing range for requirement types. */
695 return FALSE;
696 }
697 }
698
699 if (req->source.kind == VUT_ACTION
700 || req->source.kind == VUT_OTYPE) {
701 /* This requirement type is intended to specify the situation. */
702 return TRUE;
703 }
704
705 if (req->source.kind == VUT_SERVERSETTING) {
706 /* Only visible server settings can be requirements. */
707 return TRUE;
708 }
709
710 /* Uncertain or no support added yet. */
711 return FALSE;
712}
713
714/**********************************************************************/
721enum fc_tristate
722mke_eval_req(const struct player *pov_player,
723 const struct req_context *context,
724 const struct player *other_player,
725 const struct requirement *req,
726 const enum req_problem_type prob_type)
727{
728 if (!is_req_knowable(pov_player, context, other_player,
729 req, prob_type)) {
730 return TRI_MAYBE;
731 }
732
733 if (is_req_active(context, other_player, req, prob_type)) {
734 return TRI_YES;
735 } else {
736 return TRI_NO;
737 }
738}
739
740/**********************************************************************/
747enum fc_tristate
748mke_eval_reqs(const struct player *pov_player,
749 const struct req_context *context,
750 const struct player *other_player,
751 const struct requirement_vector *reqs,
752 const enum req_problem_type prob_type)
753{
754 enum fc_tristate current;
755 enum fc_tristate result;
756
757 result = TRI_YES;
758 requirement_vector_iterate(reqs, preq) {
759 current = mke_eval_req(pov_player, context, other_player,
760 preq, prob_type);
761 if (current == TRI_NO) {
762 return TRI_NO;
763 } else if (current == TRI_MAYBE) {
764 result = TRI_MAYBE;
765 }
766 } requirement_vector_iterate_end;
767
768 return result;
769}
770
771/**********************************************************************/
774 bool can_see_techs_of_target(const struct player *pow_player,
775 const struct player *target_player)
776{
777 return pow_player == target_player
778 || team_has_embassy(pow_player->team, target_player);
779}
city_map_radius_sq_get
int city_map_radius_sq_get(const struct city *pcity)
Definition city.c:136
city_tile
#define city_tile(_pcity_)
Definition city.h:564
city_owner
#define city_owner(_pcity_)
Definition city.h:563
city_tile_iterate
#define city_tile_iterate(_nmap, _radius_sq, _city_tile, _tile)
Definition city.h:230
city_tile_iterate_end
#define city_tile_iterate_end
Definition city.h:238
incite_cost
char * incite_cost
Definition comments.c:74
target_tile
struct unit struct city struct unit struct tile * target_tile
Definition dialogs_g.h:57
target_city
struct unit struct city * target_city
Definition dialogs_g.h:56
could_intel_with_player
bool could_intel_with_player(const struct player *pplayer, const struct player *aplayer)
Definition diptreaty.c:84
diptreaty.h
reqs
struct @21::@22 reqs
req_problem_type
req_problem_type
Definition fc_types.h:706
RPT_CERTAIN
@ RPT_CERTAIN
Definition fc_types.h:708
wld
struct world wld
Definition game.c:63
game.h
is_improvement_visible
bool is_improvement_visible(const struct impr_type *pimprove)
Definition improvement.c:393
is_great_wonder
bool is_great_wonder(const struct impr_type *pimprove)
Definition improvement.c:772
city_from_great_wonder
struct city * city_from_great_wonder(const struct impr_type *pimprove)
Definition improvement.c:1016
fc_assert_msg
#define fc_assert_msg(condition, message,...)
Definition log.h:181
fc_assert
#define fc_assert(condition)
Definition log.h:176
fc_assert_ret_val_msg
#define fc_assert_ret_val_msg(condition, val, message,...)
Definition log.h:208
map.h
adjc_iterate_end
#define adjc_iterate_end
Definition map.h:419
cardinal_adjc_iterate_end
#define cardinal_adjc_iterate_end
Definition map.h:445
adjc_iterate
#define adjc_iterate(nmap, center_tile, itr_tile)
Definition map.h:414
cardinal_adjc_iterate
#define cardinal_adjc_iterate(nmap, center_tile, itr_tile)
Definition map.h:441
is_tile_seen_cadj
static bool is_tile_seen_cadj(const struct player *pow_player, const struct tile *target_tile)
Definition metaknowledge.c:30
can_see_techs_of_target
bool can_see_techs_of_target(const struct player *pow_player, const struct player *target_player)
Definition metaknowledge.c:774
is_tile_seen_city
static bool is_tile_seen_city(const struct player *pow_player, const struct city *target_city)
Definition metaknowledge.c:75
can_plr_see_all_sym_diplrels_of
static bool can_plr_see_all_sym_diplrels_of(const struct player *pplayer, const struct player *tplayer)
Definition metaknowledge.c:129
mke_eval_reqs
enum fc_tristate mke_eval_reqs(const struct player *pov_player, const struct req_context *context, const struct player *other_player, const struct requirement_vector *reqs, const enum req_problem_type prob_type)
Definition metaknowledge.c:748
is_tile_seen_trade_route
static bool is_tile_seen_trade_route(const struct player *pow_player, const struct city *target_city)
Definition metaknowledge.c:101
is_req_knowable
static bool is_req_knowable(const struct player *pov_player, const struct req_context *context, const struct player *other_player, const struct requirement *req, const enum req_problem_type prob_type)
Definition metaknowledge.c:160
mke_eval_req
enum fc_tristate mke_eval_req(const struct player *pov_player, const struct req_context *context, const struct player *other_player, const struct requirement *req, const enum req_problem_type prob_type)
Definition metaknowledge.c:722
is_tile_seen_adj
static bool is_tile_seen_adj(const struct player *pow_player, const struct tile *target_tile)
Definition metaknowledge.c:53
metaknowledge.h
can_player_see_unit
bool can_player_see_unit(const struct player *pplayer, const struct unit *punit)
Definition player.c:1104
team_has_embassy
bool team_has_embassy(const struct team *pteam, const struct player *tgt_player)
Definition player.c:220
player_can_see_city_externals
bool player_can_see_city_externals(const struct player *pow_player, const struct city *target_city)
Definition player.c:1164
player_diplstate_get
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Definition player.c:324
can_player_see_hypotetic_units_at
bool can_player_see_hypotetic_units_at(const struct player *pplayer, const struct tile *ptile)
Definition player.c:993
can_player_see_city_internals
bool can_player_see_city_internals(const struct player *pplayer, const struct city *pcity)
Definition player.c:1149
req_context_empty
const struct req_context * req_context_empty(void)
Definition requirements.c:1011
is_req_active
bool is_req_active(const struct req_context *context, const struct player *other_player, const struct requirement *req, const enum req_problem_type prob_type)
Definition requirements.c:5616
requirement_vector_iterate_end
#define requirement_vector_iterate_end
Definition requirements.h:94
requirement_vector_iterate
#define requirement_vector_iterate(req_vec, preq)
Definition requirements.h:92
fc_tristate
fc_tristate
Definition shared.h:46
TRI_YES
@ TRI_YES
Definition shared.h:46
TRI_NO
@ TRI_NO
Definition shared.h:46
TRI_MAYBE
@ TRI_MAYBE
Definition shared.h:46
city
Definition city.h:320
civ_map
Definition map_types.h:71
player
Definition player.h:249
player::team
struct team * team
Definition player.h:261
req_context
Definition requirements.h:100
requirement
Definition requirements.h:81
requirement::survives
bool survives
Definition requirements.h:84
requirement::range
enum req_range range
Definition requirements.h:83
requirement::source
struct universal source
Definition requirements.h:82
tile
Definition tile.h:50
universal::kind
enum universals_n kind
Definition fc_types.h:910
universal::value
universals_u value
Definition fc_types.h:909
world::map
struct civ_map map
Definition world_object.h:38
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
tile_is_seen
bool tile_is_seen(const struct tile *target_tile, const struct player *pow_player)
Definition tile.c:407
tile_city
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
tile.h
traderoutes.h
trade_partners_iterate_end
#define trade_partners_iterate_end
Definition traderoutes.h:167
trade_partners_iterate
#define trade_partners_iterate(c, p)
Definition traderoutes.h:162
universals_u::citytile
enum citytile_type citytile
Definition fc_types.h:737
universals_u::building
const struct impr_type * building
Definition fc_types.h:721
universals_u::unit_state
enum ustate_prop unit_state
Definition fc_types.h:756
unit_owner
#define unit_owner(_pu)
Definition unit.h:396