Freeciv21
Develop your civilization from humble roots to a global empire
api_game_methods.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 1996-2020 Freeciv21 and Freeciv contributors. This file is
3  part of Freeciv21. Freeciv21 is free software: you can redistribute it
4  and/or modify it under the terms of the GNU General Public License as
5  published by the Free Software Foundation, either version 3 of the
6  License, or (at your option) any later version. You should have received
7  a copy of the GNU General Public License along with Freeciv21. If not,
8  see https://www.gnu.org/licenses/.
9  */
10 
11 // utility
12 #include "deprecations.h"
13 #include "fcintl.h"
14 
15 // common
16 #include "achievements.h"
17 #include "actions.h"
18 #include "calendar.h"
19 #include "citizens.h"
20 #include "culture.h"
21 #include "game.h"
22 #include "government.h"
23 #include "improvement.h"
24 #include "map.h"
25 #include "movement.h"
26 #include "nation.h"
27 #include "research.h"
28 #include "tech.h"
29 #include "terrain.h"
30 #include "tile.h"
31 #include "unitlist.h"
32 #include "unittype.h"
33 
34 /* common/scriptcore */
35 #include "luascript.h"
36 
37 #include "api_game_methods.h"
38 
42 int api_methods_game_turn(lua_State *L)
43 {
45 
46  return game.info.turn;
47 }
48 
52 int api_methods_game_year(lua_State *L)
53 {
55 
56  return game.info.year;
57 }
58 
63 {
65 
66  return game.info.fragment_count;
67 }
68 
72 const char *api_methods_game_year_text(lua_State *L)
73 {
74  LUASCRIPT_CHECK_STATE(L, nullptr);
75 
76  return calendar_text();
77 }
78 
83 {
85 
86  qCWarning(deprecations_category,
87  "Deprecated: lua construct \"game:turn\", deprecated "
88  "since \"3.0\", used. "
89  "Use \"game:current_turn\" instead.");
90 
91  if (game.info.turn > 0) {
92  return game.info.turn - 1;
93  }
94 
95  return game.info.turn;
96 }
97 
101 const char *api_methods_game_rulesetdir(lua_State *L)
102 {
103  Q_UNUSED(L)
104  return game.server.rulesetdir;
105 }
106 
110 const char *api_methods_game_ruleset_name(lua_State *L)
111 {
112  Q_UNUSED(L)
113  return game.control.name;
114 }
115 
120  Building_Type *pbuilding)
121 {
122  LUASCRIPT_CHECK_STATE(L, false);
123  LUASCRIPT_CHECK_SELF(L, pbuilding, false);
124 
125  return is_wonder(pbuilding);
126 }
127 
132  Building_Type *pbuilding)
133 {
134  LUASCRIPT_CHECK_STATE(L, false);
135  LUASCRIPT_CHECK_SELF(L, pbuilding, false);
136 
137  return is_great_wonder(pbuilding);
138 }
139 
144  Building_Type *pbuilding)
145 {
146  LUASCRIPT_CHECK_STATE(L, false);
147  LUASCRIPT_CHECK_SELF(L, pbuilding, false);
148 
149  return is_small_wonder(pbuilding);
150 }
151 
156  Building_Type *pbuilding)
157 {
158  LUASCRIPT_CHECK_STATE(L, false);
159  LUASCRIPT_CHECK_SELF(L, pbuilding, false);
160 
161  return is_improvement(pbuilding);
162 }
163 
167 const char *api_methods_building_type_rule_name(lua_State *L,
168  Building_Type *pbuilding)
169 {
170  LUASCRIPT_CHECK_STATE(L, nullptr);
171  LUASCRIPT_CHECK_SELF(L, pbuilding, nullptr);
172 
173  return improvement_rule_name(pbuilding);
174 }
175 
179 const char *
181  Building_Type *pbuilding)
182 {
183  LUASCRIPT_CHECK_STATE(L, nullptr);
184  LUASCRIPT_CHECK_SELF(L, pbuilding, nullptr);
185 
186  return improvement_name_translation(pbuilding);
187 }
188 
192 bool api_methods_city_has_building(lua_State *L, City *pcity,
193  Building_Type *building)
194 {
195  LUASCRIPT_CHECK_STATE(L, false);
196  LUASCRIPT_CHECK_SELF(L, pcity, false);
197  LUASCRIPT_CHECK_ARG_NIL(L, building, 3, Building_Type, false);
198 
199  return city_has_building(pcity, building);
200 }
201 
205 int api_methods_city_map_sq_radius(lua_State *L, City *pcity)
206 {
207  LUASCRIPT_CHECK_STATE(L, 0);
208  LUASCRIPT_CHECK_SELF(L, pcity, 0);
209 
210  return city_map_radius_sq_get(pcity);
211 }
212 
216 int api_methods_city_size_get(lua_State *L, City *pcity)
217 {
218  LUASCRIPT_CHECK_STATE(L, 1);
219  LUASCRIPT_CHECK_SELF(L, pcity, 1);
220 
221  return city_size_get(pcity);
222 }
223 
227 Tile *api_methods_city_tile_get(lua_State *L, City *pcity)
228 {
229  LUASCRIPT_CHECK_STATE(L, nullptr);
230  LUASCRIPT_CHECK_SELF(L, pcity, nullptr);
231 
232  return pcity->tile;
233 }
234 
238 int api_methods_city_inspire_partisans(lua_State *L, City *self,
239  Player *inspirer)
240 {
241  Q_UNUSED(L)
242  bool inspired = false;
243 
244  if (!game.info.citizen_nationality) {
245  if (self->original == inspirer) {
246  inspired = true;
247  }
248  } else {
249  if (game.info.citizen_partisans_pct > 0) {
250  if (is_server()) {
251  int own = citizens_nation_get(self, inspirer->slot);
252  int total = 0;
253 
254  /* Not citizens_foreign_iterate() as city has already changed hands.
255  * old owner would be considered foreign and new owner not. */
256  citizens_iterate(self, pslot, nat) { total += nat; }
258 
259  if (total != 0
260  && ((own * 100 / total) >= game.info.citizen_partisans_pct)) {
261  inspired = true;
262  }
263  }
264  // else is_client() -> don't consider inspired by default.
265  } else if (self->original == inspirer) {
266  inspired = true;
267  }
268  }
269 
270  if (inspired) {
271  /* Cannot use get_city_bonus() as it would use city's current owner
272  * instead of inspirer. */
274  nullptr, inspirer, nullptr, self, nullptr, city_tile(self), nullptr,
275  nullptr, nullptr, nullptr, nullptr, EFT_INSPIRE_PARTISANS);
276  }
277 
278  return 0;
279 }
280 
284 int api_methods_city_culture_get(lua_State *L, City *pcity)
285 {
286  LUASCRIPT_CHECK_STATE(L, 0);
287  LUASCRIPT_CHECK_SELF(L, pcity, 0);
288 
289  return city_culture(pcity);
290 }
291 
295 bool api_methods_is_city_happy(lua_State *L, City *pcity)
296 {
297  LUASCRIPT_CHECK_STATE(L, false);
298  LUASCRIPT_CHECK_SELF(L, pcity, false);
299 
300  // Note: if clients ever have virtual cities or sth, needs amending
301  return is_server() ? city_happy(pcity) : pcity->client.happy;
302 }
303 
307 bool api_methods_is_city_unhappy(lua_State *L, City *pcity)
308 {
309  LUASCRIPT_CHECK_STATE(L, false);
310  LUASCRIPT_CHECK_SELF(L, pcity, false);
311 
312  // Note: if clients ever have virtual cities or sth, needs amending
313  return is_server() ? city_unhappy(pcity) : pcity->client.unhappy;
314 }
315 
319 bool api_methods_is_city_celebrating(lua_State *L, City *pcity)
320 {
321  LUASCRIPT_CHECK_STATE(L, false);
322  LUASCRIPT_CHECK_SELF(L, pcity, false);
323 
324  return city_celebrating(pcity);
325 }
326 
330 bool api_methods_is_gov_center(lua_State *L, City *pcity)
331 {
332  LUASCRIPT_CHECK_STATE(L, false);
333  LUASCRIPT_CHECK_SELF(L, pcity, false);
334 
335  return is_gov_center(pcity);
336 }
337 
341 bool api_methods_is_capital(lua_State *L, City *pcity)
342 {
343  LUASCRIPT_CHECK_STATE(L, false);
344  LUASCRIPT_CHECK_SELF(L, pcity, false);
345 
346  return is_capital(pcity);
347 }
348 
352 const char *api_methods_government_rule_name(lua_State *L,
353  Government *pgovernment)
354 {
355  LUASCRIPT_CHECK_STATE(L, nullptr);
356  LUASCRIPT_CHECK_SELF(L, pgovernment, nullptr);
357 
358  return government_rule_name(pgovernment);
359 }
360 
365  Government *pgovernment)
366 {
367  LUASCRIPT_CHECK_STATE(L, nullptr);
368  LUASCRIPT_CHECK_SELF(L, pgovernment, nullptr);
369 
370  return government_name_translation(pgovernment);
371 }
372 
376 const char *api_methods_nation_type_rule_name(lua_State *L,
377  Nation_Type *pnation)
378 {
379  LUASCRIPT_CHECK_STATE(L, nullptr);
380  LUASCRIPT_CHECK_SELF(L, pnation, nullptr);
381 
382  return nation_rule_name(pnation);
383 }
384 
389  Nation_Type *pnation)
390 {
391  LUASCRIPT_CHECK_STATE(L, nullptr);
392  LUASCRIPT_CHECK_SELF(L, pnation, nullptr);
393 
394  return nation_adjective_translation(pnation);
395 }
396 
401  Nation_Type *pnation)
402 {
403  LUASCRIPT_CHECK_STATE(L, nullptr);
404  LUASCRIPT_CHECK_SELF(L, pnation, nullptr);
405 
406  return nation_plural_translation(pnation);
407 }
408 
412 const char *api_methods_player_controlling_gui(lua_State *L, Player *pplayer)
413 {
414  static bool warned = false;
415  if (!warned) {
416  qWarning() << "player:controlling_gui is deprecated";
417  warned = true;
418  }
419  return "Qt";
420 }
421 
425 bool api_methods_player_has_wonder(lua_State *L, Player *pplayer,
426  Building_Type *building)
427 {
428  LUASCRIPT_CHECK_STATE(L, false);
429  LUASCRIPT_CHECK_SELF(L, pplayer, false);
430  LUASCRIPT_CHECK_ARG_NIL(L, building, 3, Building_Type, false);
431 
432  return wonder_is_built(pplayer, building);
433 }
434 
438 int api_methods_player_number(lua_State *L, Player *pplayer)
439 {
440  LUASCRIPT_CHECK_STATE(L, -1);
441  LUASCRIPT_CHECK_SELF(L, pplayer, -1);
442 
443  return player_number(pplayer);
444 }
445 
449 int api_methods_player_num_cities(lua_State *L, Player *pplayer)
450 {
451  LUASCRIPT_CHECK_STATE(L, 0);
452  LUASCRIPT_CHECK_SELF(L, pplayer, 0);
453 
454  return city_list_size(pplayer->cities);
455 }
456 
460 int api_methods_player_num_units(lua_State *L, Player *pplayer)
461 {
462  LUASCRIPT_CHECK_STATE(L, 0);
463  LUASCRIPT_CHECK_SELF(L, pplayer, 0);
464 
465  return unit_list_size(pplayer->units);
466 }
467 
471 int api_methods_player_gold(lua_State *L, Player *pplayer)
472 {
473  LUASCRIPT_CHECK_STATE(L, 0);
474  LUASCRIPT_CHECK_SELF(L, pplayer, 0);
475 
476  return pplayer->economic.gold;
477 }
478 
482 bool api_methods_player_knows_tech(lua_State *L, Player *pplayer,
483  Tech_Type *ptech)
484 {
485  LUASCRIPT_CHECK_STATE(L, false);
486  LUASCRIPT_CHECK_SELF(L, pplayer, false);
487  LUASCRIPT_CHECK_ARG_NIL(L, ptech, 3, Tech_Type, false);
488 
489  return research_invention_state(research_get(pplayer),
490  advance_number(ptech))
491  == TECH_KNOWN;
492 }
493 
497 int api_methods_player_culture_get(lua_State *L, Player *pplayer)
498 {
499  LUASCRIPT_CHECK_STATE(L, 0);
500  LUASCRIPT_CHECK_SELF(L, pplayer, 0);
501 
502  return player_culture(pplayer);
503 }
504 
508 bool api_methods_player_has_flag(lua_State *L, Player *pplayer,
509  const char *flag)
510 {
511  enum plr_flag_id flag_val;
512 
513  LUASCRIPT_CHECK_STATE(L, 0);
514  LUASCRIPT_CHECK_SELF(L, pplayer, 0);
515 
516  flag_val = plr_flag_id_by_name(flag, fc_strcasecmp);
517 
518  if (plr_flag_id_is_valid(flag_val)) {
519  return player_has_flag(pplayer, flag_val);
520  }
521 
522  return false;
523 }
524 
528 bool api_methods_player_shares_research(lua_State *L, Player *pplayer,
529  Player *aplayer)
530 {
531  LUASCRIPT_CHECK_STATE(L, false);
532  LUASCRIPT_CHECK_SELF(L, pplayer, false);
533  LUASCRIPT_CHECK_ARG_NIL(L, aplayer, 3, Player, false);
534 
535  return research_get(pplayer) == research_get(aplayer);
536 }
537 
541 const char *api_methods_research_rule_name(lua_State *L, Player *pplayer)
542 {
543  LUASCRIPT_CHECK_STATE(L, nullptr);
544  LUASCRIPT_CHECK_SELF(L, pplayer, nullptr);
545 
546  return research_rule_name(research_get(pplayer));
547 }
548 
552 const char *api_methods_research_name_translation(lua_State *L,
553  Player *pplayer)
554 {
555  static char buf[MAX_LEN_MSG];
556 
557  LUASCRIPT_CHECK_STATE(L, nullptr);
558  LUASCRIPT_CHECK_SELF(L, pplayer, nullptr);
559 
560  (void) research_pretty_name(research_get(pplayer), buf, ARRAY_SIZE(buf));
561 
562  return buf;
563 }
564 
569  Player *pplayer)
570 {
571  LUASCRIPT_CHECK_STATE(L, nullptr);
572  LUASCRIPT_CHECK_SELF(L, pplayer, nullptr);
573  return unit_list_head(pplayer->units);
574 }
575 
580  Player *pplayer)
581 {
582  LUASCRIPT_CHECK_STATE(L, nullptr);
583  LUASCRIPT_CHECK_SELF(L, pplayer, nullptr);
584 
585  return city_list_head(pplayer->cities);
586 }
587 
591 const char *api_methods_tech_type_rule_name(lua_State *L, Tech_Type *ptech)
592 {
593  LUASCRIPT_CHECK_STATE(L, nullptr);
594  LUASCRIPT_CHECK_SELF(L, ptech, nullptr);
595 
596  return advance_rule_name(ptech);
597 }
598 
602 const char *api_methods_tech_type_name_translation(lua_State *L,
603  Tech_Type *ptech)
604 {
605  LUASCRIPT_CHECK_STATE(L, nullptr);
606  LUASCRIPT_CHECK_SELF(L, ptech, nullptr);
607 
608  return advance_name_translation(ptech);
609 }
610 
614 const char *api_methods_terrain_rule_name(lua_State *L, Terrain *pterrain)
615 {
616  LUASCRIPT_CHECK_STATE(L, nullptr);
617  LUASCRIPT_CHECK_SELF(L, pterrain, nullptr);
618 
619  return terrain_rule_name(pterrain);
620 }
621 
625 const char *api_methods_terrain_name_translation(lua_State *L,
626  Terrain *pterrain)
627 {
628  LUASCRIPT_CHECK_STATE(L, nullptr);
629  LUASCRIPT_CHECK_SELF(L, pterrain, nullptr);
630 
631  return terrain_name_translation(pterrain);
632 }
633 
637 const char *api_methods_terrain_class_name(lua_State *L, Terrain *pterrain)
638 {
639  LUASCRIPT_CHECK_STATE(L, nullptr);
640  LUASCRIPT_CHECK_SELF(L, pterrain, nullptr);
641 
642  return terrain_class_name(terrain_type_terrain_class(pterrain));
643 }
644 
648 const char *api_methods_disaster_rule_name(lua_State *L, Disaster *pdis)
649 {
650  LUASCRIPT_CHECK_STATE(L, nullptr);
651  LUASCRIPT_CHECK_SELF(L, pdis, nullptr);
652 
653  return disaster_rule_name(pdis);
654 }
655 
659 const char *api_methods_disaster_name_translation(lua_State *L,
660  Disaster *pdis)
661 {
662  LUASCRIPT_CHECK_STATE(L, nullptr);
663  LUASCRIPT_CHECK_SELF(L, pdis, nullptr);
664 
665  return disaster_name_translation(pdis);
666 }
667 
671 const char *api_methods_achievement_rule_name(lua_State *L,
672  Achievement *pach)
673 {
674  LUASCRIPT_CHECK_STATE(L, nullptr);
675  LUASCRIPT_CHECK_SELF(L, pach, nullptr);
676 
677  return achievement_rule_name(pach);
678 }
679 
684  Achievement *pach)
685 {
686  LUASCRIPT_CHECK_STATE(L, nullptr);
687  LUASCRIPT_CHECK_SELF(L, pach, nullptr);
688 
689  return achievement_name_translation(pach);
690 }
691 
695 const char *api_methods_action_rule_name(lua_State *L, Action *pact)
696 {
697  LUASCRIPT_CHECK_STATE(L, nullptr);
698  LUASCRIPT_CHECK_SELF(L, pact, nullptr);
699 
700  return action_id_rule_name(pact->id);
701 }
702 
706 const char *api_methods_action_name_translation(lua_State *L, Action *pact)
707 {
708  LUASCRIPT_CHECK_STATE(L, nullptr);
709  LUASCRIPT_CHECK_SELF(L, pact, nullptr);
710 
711  return qUtf8Printable(action_id_name_translation(pact->id));
712 }
713 
717 int api_methods_tile_nat_x(lua_State *L, Tile *ptile)
718 {
719  LUASCRIPT_CHECK_STATE(L, -1);
720  LUASCRIPT_CHECK_SELF(L, ptile, -1);
721 
722  return index_to_native_pos_x(tile_index(ptile));
723 }
724 
728 int api_methods_tile_nat_y(lua_State *L, Tile *ptile)
729 {
730  LUASCRIPT_CHECK_STATE(L, -1);
731  LUASCRIPT_CHECK_SELF(L, ptile, -1);
732 
733  return index_to_native_pos_y(tile_index(ptile));
734 }
735 
739 int api_methods_tile_map_x(lua_State *L, Tile *ptile)
740 {
741  LUASCRIPT_CHECK_STATE(L, -1);
742  LUASCRIPT_CHECK_SELF(L, ptile, -1);
743 
744  return index_to_map_pos_x(tile_index(ptile));
745 }
746 
750 int api_methods_tile_map_y(lua_State *L, Tile *ptile)
751 {
752  LUASCRIPT_CHECK_STATE(L, -1);
753  LUASCRIPT_CHECK_SELF(L, ptile, -1);
754 
755  return index_to_map_pos_y(tile_index(ptile));
756 }
757 
761 City *api_methods_tile_city(lua_State *L, Tile *ptile)
762 {
763  LUASCRIPT_CHECK_STATE(L, nullptr);
764  LUASCRIPT_CHECK_SELF(L, ptile, nullptr);
765 
766  return tile_city(ptile);
767 }
768 
773  Tile *ptile,
774  bool may_be_on_center)
775 {
776  LUASCRIPT_CHECK_STATE(L, false);
777  LUASCRIPT_CHECK_SELF(L, ptile, false);
778 
779  return city_exists_within_max_city_map(ptile, may_be_on_center);
780 }
781 
786 bool api_methods_tile_has_extra(lua_State *L, Tile *ptile, const char *name)
787 {
788  LUASCRIPT_CHECK_STATE(L, false);
789  LUASCRIPT_CHECK_SELF(L, ptile, false);
790 
791  if (!name) {
792  extra_type_iterate(pextra)
793  {
794  if (tile_has_extra(ptile, pextra)) {
795  return true;
796  }
797  }
799 
800  return false;
801  } else {
802  struct extra_type *pextra;
803 
804  pextra = extra_type_by_rule_name(name);
805 
806  return (nullptr != pextra && tile_has_extra(ptile, pextra));
807  }
808 }
809 
814 bool api_methods_tile_has_base(lua_State *L, Tile *ptile, const char *name)
815 {
816  LUASCRIPT_CHECK_STATE(L, false);
817  LUASCRIPT_CHECK_SELF(L, ptile, false);
818 
819  if (!name) {
820  extra_type_by_cause_iterate(EC_BASE, pextra)
821  {
822  if (tile_has_extra(ptile, pextra)) {
823  return true;
824  }
825  }
827 
828  return false;
829  } else {
830  struct extra_type *pextra;
831 
832  pextra = extra_type_by_rule_name(name);
833 
834  return (nullptr != pextra && is_extra_caused_by(pextra, EC_BASE)
835  && tile_has_extra(ptile, pextra));
836  }
837 }
838 
843 bool api_methods_tile_has_road(lua_State *L, Tile *ptile, const char *name)
844 {
845  LUASCRIPT_CHECK_STATE(L, false);
846  LUASCRIPT_CHECK_SELF(L, ptile, false);
847 
848  if (!name) {
849  extra_type_by_cause_iterate(EC_ROAD, pextra)
850  {
851  if (tile_has_extra(ptile, pextra)) {
852  return true;
853  }
854  }
856 
857  return false;
858  } else {
859  struct extra_type *pextra;
860 
861  pextra = extra_type_by_rule_name(name);
862 
863  return (nullptr != pextra && is_extra_caused_by(pextra, EC_ROAD)
864  && tile_has_extra(ptile, pextra));
865  }
866 }
867 
871 bool api_methods_enemy_tile(lua_State *L, Tile *ptile, Player *against)
872 {
873  struct city *pcity;
874 
875  LUASCRIPT_CHECK_STATE(L, false);
876  LUASCRIPT_CHECK_SELF(L, ptile, false);
877 
878  if (is_non_allied_unit_tile(ptile, against)) {
879  return true;
880  }
881 
882  pcity = tile_city(ptile);
883  return pcity != nullptr && !pplayers_allied(against, city_owner(pcity));
884 }
885 
889 int api_methods_tile_num_units(lua_State *L, Tile *ptile)
890 {
891  LUASCRIPT_CHECK_STATE(L, 0);
892  LUASCRIPT_CHECK_SELF(L, ptile, 0);
893 
894  return unit_list_size(ptile->units);
895 }
896 
901  Tile *ptile)
902 {
903  LUASCRIPT_CHECK_STATE(L, nullptr);
904  LUASCRIPT_CHECK_SELF(L, ptile, nullptr);
905 
906  return unit_list_head(ptile->units);
907 }
908 
914  int tindex, int max_dist)
915 {
916  int dx, dy;
917  int newx, newy;
918  int startx, starty;
919 
920  LUASCRIPT_CHECK_STATE(L, 0);
921  LUASCRIPT_CHECK_SELF(L, pstart, 0);
922 
923  if (tindex < 0) {
924  return 0;
925  }
926 
927  index_to_map_pos(&startx, &starty, tile_index(pstart));
928 
929  tindex++;
930  while (tindex < wld.map.num_iterate_outwards_indices) {
931  if (wld.map.iterate_outwards_indices[tindex].dist > max_dist) {
932  return -1;
933  }
934  dx = wld.map.iterate_outwards_indices[tindex].dx;
935  dy = wld.map.iterate_outwards_indices[tindex].dy;
936  newx = dx + startx;
937  newy = dy + starty;
938  if (!normalize_map_pos(&(wld.map), &newx, &newy)) {
939  tindex++;
940  continue;
941  }
942 
943  return tindex;
944  }
945 
946  return -1;
947 }
948 
953  int tindex)
954 {
955  int newx, newy;
956 
957  LUASCRIPT_CHECK_STATE(L, nullptr);
958  LUASCRIPT_CHECK_SELF(L, pstart, nullptr);
960  L, tindex >= 0 && tindex < wld.map.num_iterate_outwards_indices, 3,
961  "index out of bounds", nullptr);
962 
963  index_to_map_pos(&newx, &newy, tile_index(pstart));
964  newx += wld.map.iterate_outwards_indices[tindex].dx;
965  newy += wld.map.iterate_outwards_indices[tindex].dy;
966 
967  if (!normalize_map_pos(&(wld.map), &newx, &newy)) {
968  return nullptr;
969  }
970 
971  return map_pos_to_tile(&(wld.map), newx, newy);
972 }
973 
977 int api_methods_tile_sq_distance(lua_State *L, Tile *ptile1, Tile *ptile2)
978 {
979  LUASCRIPT_CHECK_STATE(L, 0);
980  LUASCRIPT_CHECK_SELF(L, ptile1, 0);
981  LUASCRIPT_CHECK_ARG_NIL(L, ptile2, 3, Tile, 0);
982 
983  return sq_map_distance(ptile1, ptile2);
984 }
985 
990 {
991  LUASCRIPT_CHECK_STATE(L, false);
992  LUASCRIPT_CHECK_SELF(L, punit, false);
993 
994  return city_can_be_built_here(unit_tile(punit), punit);
995 }
996 
1000 Tile *api_methods_unit_tile_get(lua_State *L, Unit *punit)
1001 {
1002  LUASCRIPT_CHECK_STATE(L, nullptr);
1003  LUASCRIPT_CHECK_SELF(L, punit, nullptr);
1004 
1005  return unit_tile(punit);
1006 }
1007 
1012 {
1013  LUASCRIPT_CHECK_STATE(L, nullptr);
1014  LUASCRIPT_CHECK_ARG_NIL(L, punit, 2, Unit, nullptr);
1015 
1016  return luascript_dir(punit->facing);
1017 }
1018 
1023 {
1024  LUASCRIPT_CHECK_STATE(L, nullptr);
1025  LUASCRIPT_CHECK_SELF(L, punit, nullptr);
1026 
1027  return punit->transporter;
1028 }
1029 
1034  Unit *punit)
1035 {
1036  LUASCRIPT_CHECK_STATE(L, nullptr);
1037  LUASCRIPT_CHECK_SELF(L, punit, nullptr);
1038  return unit_list_head(punit->transporting);
1039 }
1040 
1044 bool api_methods_unit_type_has_flag(lua_State *L, Unit_Type *punit_type,
1045  const char *flag)
1046 {
1047  enum unit_type_flag_id id;
1048 
1049  LUASCRIPT_CHECK_STATE(L, false);
1050  LUASCRIPT_CHECK_SELF(L, punit_type, false);
1051  LUASCRIPT_CHECK_ARG_NIL(L, flag, 3, string, false);
1052 
1053  id = unit_type_flag_id_by_name(flag, fc_strcasecmp);
1054  if (unit_type_flag_id_is_valid(id)) {
1055  return utype_has_flag(punit_type, id);
1056  } else {
1057  luascript_error(L, "Unit type flag \"%s\" does not exist", flag);
1058  return false;
1059  }
1060 }
1061 
1065 bool api_methods_unit_type_has_role(lua_State *L, Unit_Type *punit_type,
1066  const char *role)
1067 {
1068  enum unit_role_id id;
1069 
1070  LUASCRIPT_CHECK_STATE(L, false);
1071  LUASCRIPT_CHECK_SELF(L, punit_type, false);
1072  LUASCRIPT_CHECK_ARG_NIL(L, role, 3, string, false);
1073 
1074  id = unit_role_id_by_name(role, fc_strcasecmp);
1075  if (unit_role_id_is_valid(id)) {
1076  return utype_has_role(punit_type, id);
1077  } else {
1078  luascript_error(L, "Unit role \"%s\" does not exist", role);
1079  return false;
1080  }
1081 }
1082 
1087  Unit_Type *punit_type,
1088  Tile *ptile)
1089 {
1090  LUASCRIPT_CHECK_STATE(L, false);
1091  LUASCRIPT_CHECK_SELF(L, punit_type, false);
1092  LUASCRIPT_CHECK_ARG_NIL(L, ptile, 3, Tile, false);
1093 
1094  return can_exist_at_tile(&(wld.map), punit_type, ptile);
1095 }
1096 
1100 const char *api_methods_unit_type_rule_name(lua_State *L,
1101  Unit_Type *punit_type)
1102 {
1103  LUASCRIPT_CHECK_STATE(L, nullptr);
1104  LUASCRIPT_CHECK_SELF(L, punit_type, nullptr);
1105 
1106  return utype_rule_name(punit_type);
1107 }
1108 
1113  Unit_Type *punit_type)
1114 {
1115  LUASCRIPT_CHECK_STATE(L, nullptr);
1116  LUASCRIPT_CHECK_SELF(L, punit_type, nullptr);
1117 
1118  return utype_name_translation(punit_type);
1119 }
1120 
1125 {
1126  LUASCRIPT_CHECK_STATE(L, nullptr);
1127 
1128  return unit_list_link_data(ul_link);
1129 }
1130 
1135  Unit_List_Link *ul_link)
1136 {
1137  LUASCRIPT_CHECK_STATE(L, nullptr);
1138 
1139  return unit_list_link_next(ul_link);
1140 }
1141 
1146 {
1147  LUASCRIPT_CHECK_STATE(L, nullptr);
1148 
1149  return city_list_link_data(cl_link);
1150 }
1151 
1156  City_List_Link *cl_link)
1157 {
1158  LUASCRIPT_CHECK_STATE(L, nullptr);
1159 
1160  return city_list_link_next(cl_link);
1161 }
const char * achievement_rule_name(struct achievement *pach)
Return untranslated name of this achievement type.
const char * achievement_name_translation(struct achievement *pach)
Return translated name of this achievement type.
const QString action_id_name_translation(action_id act_id)
Get the action name used when displaying the action in the UI.
Definition: actions.cpp:1373
const char * action_id_rule_name(action_id act_id)
Get the rule name of the action.
Definition: actions.cpp:1362
const char * api_methods_unit_type_rule_name(lua_State *L, Unit_Type *punit_type)
Return rule name for Unit_Type.
int api_methods_tile_nat_x(lua_State *L, Tile *ptile)
Return the native x coordinate of the tile.
int api_methods_tile_num_units(lua_State *L, Tile *ptile)
Return number of units on tile.
bool api_methods_is_city_unhappy(lua_State *L, City *pcity)
Return TRUE iff city is unhappy.
bool api_methods_is_gov_center(lua_State *L, City *pcity)
Return TRUE iff city is government center.
bool api_methods_unit_type_can_exist_at_tile(lua_State *L, Unit_Type *punit_type, Tile *ptile)
Return TRUE iff the unit type can exist on the tile.
int api_methods_player_num_cities(lua_State *L, Player *pplayer)
Return the number of cities pplayer has.
City * api_methods_city_list_link_data(lua_State *L, City_List_Link *cl_link)
Return City for list link.
const char * api_methods_nation_type_name_translation(lua_State *L, Nation_Type *pnation)
Return translated adjective for Nation_Type.
const char * api_methods_achievement_rule_name(lua_State *L, Achievement *pach)
Return rule name for Achievement.
bool api_methods_player_has_wonder(lua_State *L, Player *pplayer, Building_Type *building)
Return TRUE iff player has wonder.
const char * api_methods_terrain_rule_name(lua_State *L, Terrain *pterrain)
Return rule name for Terrain.
Tile * api_methods_unit_tile_get(lua_State *L, Unit *punit)
Return the tile of the unit.
City_List_Link * api_methods_private_player_city_list_head(lua_State *L, Player *pplayer)
Return list head for city list for Player.
const char * api_methods_disaster_rule_name(lua_State *L, Disaster *pdis)
Return rule name for Disaster.
City_List_Link * api_methods_city_list_next_link(lua_State *L, City_List_Link *cl_link)
Return next list link or nullptr when link is the last link.
Unit * api_methods_unit_list_link_data(lua_State *L, Unit_List_Link *ul_link)
Return Unit for list link.
int api_methods_tile_nat_y(lua_State *L, Tile *ptile)
Return the native y coordinate of the tile.
int api_methods_game_year_fragment(lua_State *L)
Return the current year fragment.
int api_methods_city_culture_get(lua_State *L, City *pcity)
How much culture city has?
const char * api_methods_action_rule_name(lua_State *L, Action *pact)
Return rule name for Action.
const char * api_methods_unit_type_name_translation(lua_State *L, Unit_Type *punit_type)
Return translated name for Unit_Type.
Unit_List_Link * api_methods_private_player_unit_list_head(lua_State *L, Player *pplayer)
Return list head for unit list for Player.
int api_methods_player_num_units(lua_State *L, Player *pplayer)
Return the number of units pplayer has.
int api_methods_tile_map_x(lua_State *L, Tile *ptile)
Return the map x coordinate of the tile.
bool api_methods_is_city_happy(lua_State *L, City *pcity)
Return TRUE iff city happy.
City * api_methods_tile_city(lua_State *L, Tile *ptile)
Return City on ptile, else nullptr.
Tile * api_methods_city_tile_get(lua_State *L, City *pcity)
Return the tile of the city.
int api_methods_player_number(lua_State *L, Player *pplayer)
Return player number.
const char * api_methods_government_name_translation(lua_State *L, Government *pgovernment)
Return translated name for Government.
const char * api_methods_government_rule_name(lua_State *L, Government *pgovernment)
Return rule name for Government.
bool api_methods_player_shares_research(lua_State *L, Player *pplayer, Player *aplayer)
Return TRUE if players share research.
int api_methods_city_size_get(lua_State *L, City *pcity)
Return the size of the city.
const char * api_methods_nation_type_plural_translation(lua_State *L, Nation_Type *pnation)
Return translated plural noun for Nation_Type.
Tile * api_methods_private_tile_for_outward_index(lua_State *L, Tile *pstart, int tindex)
Return tile for nth iteration index (for internal use)
bool api_methods_tile_has_extra(lua_State *L, Tile *ptile, const char *name)
Return TRUE if there is a extra with rule name name on ptile.
int api_methods_tile_sq_distance(lua_State *L, Tile *ptile1, Tile *ptile2)
Return squared distance between tiles 1 and 2.
bool api_methods_unit_type_has_role(lua_State *L, Unit_Type *punit_type, const char *role)
Return TRUE if punit_type has role.
const char * api_methods_research_rule_name(lua_State *L, Player *pplayer)
Return name of the research group player belongs to.
const char * api_methods_disaster_name_translation(lua_State *L, Disaster *pdis)
Return translated name for Disaster.
const char * api_methods_research_name_translation(lua_State *L, Player *pplayer)
Return name of the research group player belongs to.
int api_methods_player_culture_get(lua_State *L, Player *pplayer)
How much culture player has?
const char * api_methods_tech_type_rule_name(lua_State *L, Tech_Type *ptech)
Return rule name for Tech_Type.
int api_methods_game_turn_deprecated(lua_State *L)
Return the current turn, as if real turns started from 0.
const char * api_methods_action_name_translation(lua_State *L, Action *pact)
Return translated name for Action.
const char * api_methods_terrain_name_translation(lua_State *L, Terrain *pterrain)
Return translated name for Terrain.
bool api_methods_building_type_is_great_wonder(lua_State *L, Building_Type *pbuilding)
Return TRUE if pbuilding is a great wonder.
int api_methods_private_tile_next_outward_index(lua_State *L, Tile *pstart, int tindex, int max_dist)
Return nth tile iteration index (for internal use) Will return the next index, or an index < 0 when d...
bool api_methods_tile_has_road(lua_State *L, Tile *ptile, const char *name)
Return TRUE if there is a road with rule name name on ptile.
int api_methods_game_turn(lua_State *L)
Return the current turn.
bool api_methods_player_knows_tech(lua_State *L, Player *pplayer, Tech_Type *ptech)
Return TRUE if Player knows advance ptech.
bool api_methods_enemy_tile(lua_State *L, Tile *ptile, Player *against)
Is tile occupied by enemies.
bool api_methods_building_type_is_small_wonder(lua_State *L, Building_Type *pbuilding)
Return TRUE if pbuilding is a small wonder.
int api_methods_game_year(lua_State *L)
Return the current year.
const char * api_methods_building_type_name_translation(lua_State *L, Building_Type *pbuilding)
Return translated name for Building_Type.
bool api_methods_building_type_is_wonder(lua_State *L, Building_Type *pbuilding)
Return TRUE if pbuilding is a wonder.
int api_methods_city_inspire_partisans(lua_State *L, City *self, Player *inspirer)
How much city inspires partisans for a player.
int api_methods_city_map_sq_radius(lua_State *L, City *pcity)
Return the square raduis of the city map.
bool api_methods_city_has_building(lua_State *L, City *pcity, Building_Type *building)
Return TRUE iff city has building.
const char * api_methods_achievement_name_translation(lua_State *L, Achievement *pach)
Return translated name for Achievement.
Unit_List_Link * api_methods_private_unit_cargo_list_head(lua_State *L, Unit *punit)
Return list head for cargo list for Unit.
const char * api_methods_game_ruleset_name(lua_State *L)
Return name of the current ruleset.
bool api_methods_unit_type_has_flag(lua_State *L, Unit_Type *punit_type, const char *flag)
Return TRUE if punit_type has flag.
bool api_methods_building_type_is_improvement(lua_State *L, Building_Type *pbuilding)
Return TRUE if pbuilding is a building.
bool api_methods_tile_city_exists_within_max_city_map(lua_State *L, Tile *ptile, bool may_be_on_center)
Return TRUE if there is a city inside the maximum city radius from ptile.
Unit_List_Link * api_methods_unit_list_next_link(lua_State *L, Unit_List_Link *ul_link)
Return next list link or nullptr when link is the last link.
bool api_methods_player_has_flag(lua_State *L, Player *pplayer, const char *flag)
Does player have flag set?
const Direction * api_methods_unit_orientation_get(lua_State *L, Unit *punit)
Get unit orientation.
bool api_methods_unit_city_can_be_built_here(lua_State *L, Unit *punit)
Can punit found a city on its tile?
Unit_List_Link * api_methods_private_tile_unit_list_head(lua_State *L, Tile *ptile)
Return list head for unit list for Tile.
const char * api_methods_game_year_text(lua_State *L)
Return the current year fragment.
bool api_methods_tile_has_base(lua_State *L, Tile *ptile, const char *name)
Return TRUE if there is a base with rule name name on ptile.
const char * api_methods_game_rulesetdir(lua_State *L)
Return name of the current ruleset.
int api_methods_player_gold(lua_State *L, Player *pplayer)
Return gold for Player.
const char * api_methods_building_type_rule_name(lua_State *L, Building_Type *pbuilding)
Return rule name for Building_Type.
const char * api_methods_player_controlling_gui(lua_State *L, Player *pplayer)
Return gui type string of the controlling connection.
const char * api_methods_tech_type_name_translation(lua_State *L, Tech_Type *ptech)
Return translated name for Tech_Type.
int api_methods_tile_map_y(lua_State *L, Tile *ptile)
Return the map y coordinate of the tile.
Unit * api_methods_unit_transporter(lua_State *L, Unit *punit)
Return Unit that transports punit, if any.
const char * api_methods_nation_type_rule_name(lua_State *L, Nation_Type *pnation)
Return rule name for Nation_Type.
const char * api_methods_terrain_class_name(lua_State *L, Terrain *pterrain)
Return name of the terrain's class.
bool api_methods_is_city_celebrating(lua_State *L, City *pcity)
Return TRUE iff city is celebrating.
bool api_methods_is_capital(lua_State *L, City *pcity)
Return TRUE if city is capital.
const char * calendar_text()
Produce a statically allocated textual representation of the current calendar time.
Definition: calendar.cpp:137
citizens citizens_nation_get(const struct city *pcity, const struct player_slot *pslot)
Get the number of citizens with the given nationality.
Definition: citizens.cpp:65
#define citizens_iterate_end
Definition: citizens.h:44
#define citizens_iterate(_pcity, _pslot, _nationality)
Definition: citizens.h:37
bool city_exists_within_max_city_map(const struct tile *ptile, bool may_be_on_center)
Return TRUE iff a city exists within a city radius of the given location.
Definition: city.cpp:2013
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Return TRUE iff the city has this building in it.
Definition: city.cpp:1189
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
Definition: city.cpp:1083
bool is_capital(const struct city *pcity)
Return TRUE iff this city is its nation's capital.
Definition: city.cpp:1495
struct tile * city_tile(const struct city *pcity)
Return the tile location of the city.
Definition: city.cpp:1095
bool city_can_be_built_here(const struct tile *ptile, const struct unit *punit)
Returns TRUE if the given unit can build a city at the given map coordinates.
Definition: city.cpp:1423
bool city_unhappy(const struct city *pcity)
Return TRUE iff the city is unhappy.
Definition: city.cpp:1544
bool city_celebrating(const struct city *pcity)
cities celebrate only after consecutive happy turns
Definition: city.cpp:1564
bool city_happy(const struct city *pcity)
Return TRUE iff the city is happy.
Definition: city.cpp:1531
int city_map_radius_sq_get(const struct city *pcity)
Returns the current squared radius of the city.
Definition: city.cpp:130
bool is_gov_center(const struct city *pcity)
Return TRUE iff this city is governmental center.
Definition: city.cpp:1503
citizens city_size_get(const struct city *pcity)
Get the city size.
Definition: city.cpp:1101
static struct ai_type * self
Definition: classicai.cpp:40
int city_culture(const struct city *pcity)
Return current culture score of the city.
Definition: culture.cpp:23
int player_culture(const struct player *plr)
Return current culture score of the player.
Definition: culture.cpp:40
const char * disaster_rule_name(struct disaster_type *pdis)
Return untranslated name of this disaster type.
Definition: disaster.cpp:91
const char * disaster_name_translation(struct disaster_type *pdis)
Return translated name of this disaster type.
Definition: disaster.cpp:83
int get_target_bonus_effects(struct effect_list *plist, const struct player *target_player, const struct player *other_player, const struct city *target_city, const struct impr_type *target_building, const struct tile *target_tile, const struct unit *target_unit, const struct unit_type *target_unittype, const struct output_type *target_output, const struct specialist *target_specialist, const struct action *target_action, enum effect_type effect_type, enum vision_layer vision_layer, enum national_intelligence nintel)
Returns the effect bonus of a given type for any target.
Definition: effects.cpp:611
struct extra_type * extra_type_by_rule_name(const char *name)
Returns extra type matching rule name or nullptr if there is no extra type with such name.
Definition: extras.cpp:183
#define extra_type_iterate(_p)
Definition: extras.h:279
#define extra_type_iterate_end
Definition: extras.h:285
#define is_extra_caused_by(e, c)
Definition: extras.h:182
#define extra_type_by_cause_iterate_end
Definition: extras.h:307
#define extra_type_by_cause_iterate(_cause, _extra)
Definition: extras.h:299
struct civ_game game
Definition: game.cpp:47
bool is_server()
Is program type server?
Definition: game.cpp:57
struct world wld
Definition: game.cpp:48
const char * government_rule_name(const struct government *pgovern)
Return the (untranslated) rule name of the government.
Definition: government.cpp:126
const char * government_name_translation(const struct government *pgovern)
Return the (translated) name of the given government.
Definition: government.cpp:136
const char * improvement_rule_name(const struct impr_type *pimprove)
Return the (untranslated) rule name of the improvement.
bool is_improvement(const struct impr_type *pimprove)
Is this building a regular improvement?
bool wonder_is_built(const struct player *pplayer, const struct impr_type *pimprove)
Returns whether the player is currently in possession of this wonder (small or great) and it hasn't b...
bool is_wonder(const struct impr_type *pimprove)
Returns whether improvement is some kind of wonder.
bool is_great_wonder(const struct impr_type *pimprove)
Is this building a great wonder?
const char * improvement_name_translation(const struct impr_type *pimprove)
Return the (translated) name of the given improvement.
bool is_small_wonder(const struct impr_type *pimprove)
Is this building a small wonder?
const char * name
Definition: inputfile.cpp:118
const Direction * luascript_dir(enum direction8 dir)
Returns a pointer to a given value of enum direction8 (always the same address for the same value),...
Definition: luascript.cpp:789
int luascript_error(lua_State *L, const char *format,...)
Internal api error function - varg version.
Definition: luascript.cpp:231
#define LUASCRIPT_CHECK_STATE(L,...)
Definition: luascript.h:110
#define LUASCRIPT_CHECK_SELF(L, value,...)
Definition: luascript.h:139
#define LUASCRIPT_CHECK_ARG_NIL(L, value, narg, type,...)
Definition: luascript.h:131
#define LUASCRIPT_CHECK_ARG(L, check, narg, msg,...)
Definition: luascript.h:124
const struct city_list_link City_List_Link
enum direction8 Direction
const struct unit_list_link Unit_List_Link
int sq_map_distance(const struct tile *tile0, const struct tile *tile1)
Return squared distance between two tiles.
Definition: map.cpp:610
struct tile * map_pos_to_tile(const struct civ_map *nmap, int map_x, int map_y)
Return the tile for the given cartesian (map) position.
Definition: map.cpp:391
bool normalize_map_pos(const struct civ_map *nmap, int *x, int *y)
If the position is real, it will be normalized and TRUE will be returned.
Definition: map.cpp:919
#define index_to_native_pos_y(mindex)
Definition: map.h:115
static int index_to_map_pos_y(int mindex)
Definition: map.h:616
static int index_to_map_pos_x(int mindex)
Definition: map.h:607
#define index_to_native_pos_x(mindex)
Definition: map.h:114
#define index_to_map_pos(pmap_x, pmap_y, mindex)
Definition: map.h:164
bool can_exist_at_tile(const struct civ_map *nmap, const struct unit_type *utype, const struct tile *ptile)
Return TRUE iff a unit of the given unit type can "exist" at this location.
Definition: movement.cpp:236
const char * nation_rule_name(const struct nation_type *pnation)
Return the (untranslated) rule name of the nation (adjective form).
Definition: nation.cpp:115
const char * nation_adjective_translation(const struct nation_type *pnation)
Return the (translated) adjective for the given nation.
Definition: nation.cpp:126
const char * nation_plural_translation(const struct nation_type *pnation)
Return the (translated) plural noun of the given nation.
Definition: nation.cpp:136
#define MAX_LEN_MSG
Definition: packets.h:37
int player_number(const struct player *pplayer)
Return the player index/number/id.
Definition: player.cpp:756
bool player_has_flag(const struct player *pplayer, enum plr_flag_id flag)
Check if player has given flag.
Definition: player.cpp:1888
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players are allied.
Definition: player.cpp:1334
struct research * research_get(const struct player *pplayer)
Returns the research structure associated with the player.
Definition: research.cpp:110
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Returns state of the tech for current research.
Definition: research.cpp:609
const char * research_rule_name(const struct research *presearch)
Returns the name of the research owner: a player name or a team name.
Definition: research.cpp:137
int research_pretty_name(const struct research *presearch, char *buf, size_t buf_len)
Set in 'buf' the name of the research owner.
Definition: research.cpp:163
#define ARRAY_SIZE(x)
Definition: shared.h:79
action_id id
Definition: actions.h:306
Definition: tech.h:113
Definition: city.h:291
struct city::@15::@18 client
int id
Definition: city.h:296
struct tile * tile
Definition: city.h:293
struct civ_game::@28::@32 server
struct packet_ruleset_control control
Definition: game.h:74
struct packet_game_info info
Definition: game.h:80
int num_iterate_outwards_indices
Definition: map_types.h:72
struct iter_index * iterate_outwards_indices
Definition: map_types.h:71
int dist
Definition: city.h:83
int dx
Definition: city.h:83
int dy
Definition: city.h:83
Definition: player.h:231
struct city_list * cities
Definition: player.h:263
struct unit_list * units
Definition: player.h:264
struct player_economic economic
Definition: player.h:266
struct player_slot * slot
Definition: player.h:232
Definition: tile.h:42
struct unit_list * units
Definition: tile.h:50
Definition: unit.h:134
struct unit_list * transporting
Definition: unit.h:181
enum direction8 facing
Definition: unit.h:138
struct unit * transporter
Definition: unit.h:180
struct civ_map map
Definition: world_object.h:21
int fc_strcasecmp(const char *str0, const char *str1)
Compare strings like strcmp(), but ignoring case.
Definition: support.cpp:89
const char * advance_rule_name(const struct advance *padvance)
Return the (untranslated) rule name of the advance/technology.
Definition: tech.cpp:283
Tech_type_id advance_number(const struct advance *padvance)
Return the advance index.
Definition: tech.cpp:85
const char * advance_name_translation(const struct advance *padvance)
Return the (translated) name of the given advance/technology.
Definition: tech.cpp:274
const char * terrain_rule_name(const struct terrain *pterrain)
Return the (untranslated) rule name of the terrain.
Definition: terrain.cpp:184
enum terrain_class terrain_type_terrain_class(const struct terrain *pterrain)
What terrain class terrain type belongs to.
Definition: terrain.cpp:464
const char * terrain_name_translation(const struct terrain *pterrain)
Return the (translated) name of the terrain.
Definition: terrain.cpp:175
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
Definition: tile.cpp:72
#define tile_index(_pt_)
Definition: tile.h:70
#define tile_has_extra(ptile, pextra)
Definition: tile.h:130
struct unit * is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Is there an non-allied unit on this tile?
Definition: unit.cpp:1252
#define unit_tile(_pu)
Definition: unit.h:371
const char * utype_rule_name(const struct unit_type *punittype)
Return the (untranslated) rule name of the unit type.
Definition: unittype.cpp:1274
bool utype_has_role(const struct unit_type *punittype, int role)
Return whether the given unit type has the role.
Definition: unittype.cpp:186
const char * utype_name_translation(const struct unit_type *punittype)
Return the (translated) name of the unit type.
Definition: unittype.cpp:1256
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition: unittype.h:584