Freeciv-3.1
Loading...
Searching...
No Matches
api_game_methods.c
Go to the documentation of this file.
1/*****************************************************************************
2 Freeciv - Copyright (C) 2005 - The Freeciv Project
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12*****************************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* utility */
19#include "deprecations.h"
20
21/* common */
22#include "achievements.h"
23#include "actions.h"
24#include "calendar.h"
25#include "citizens.h"
26#include "culture.h"
27#include "featured_text.h"
28#include "game.h"
29#include "government.h"
30#include "improvement.h"
31#include "map.h"
32#include "movement.h"
33#include "nation.h"
34#include "research.h"
35#include "tech.h"
36#include "terrain.h"
37#include "tile.h"
38#include "unitlist.h"
39#include "unittype.h"
40
41/* common/scriptcore */
42#include "luascript.h"
43
44#include "api_game_methods.h"
45
46
47/**********************************************************************/
50int api_methods_game_turn(lua_State *L)
51{
53
54 return game.info.turn;
55}
56
57/**********************************************************************/
60int api_methods_game_year(lua_State *L)
61{
63
64 return game.info.year;
65}
66
67/**********************************************************************/
71{
73
75}
76
77/**********************************************************************/
80const char *api_methods_game_year_text(lua_State *L)
81{
82 LUASCRIPT_CHECK_STATE(L, NULL);
83
84 return calendar_text();
85}
86
87/**********************************************************************/
91{
93
94 log_deprecation("Deprecated: lua construct \"game:turn\", deprecated since \"3.0\", used. "
95 "Use \"game:current_turn\" instead.");
96
97 if (game.info.turn > 0) {
98 return game.info.turn - 1;
99 }
100
101 return game.info.turn;
102}
103
104/**********************************************************************/
107const char *api_methods_game_rulesetdir(lua_State *L)
108{
109 return game.server.rulesetdir;
110}
111
112/**********************************************************************/
115const char *api_methods_game_ruleset_name(lua_State *L)
116{
117 return game.control.name;
118}
119
120/**********************************************************************/
124 Building_Type *pbuilding)
125{
127 LUASCRIPT_CHECK_SELF(L, pbuilding, FALSE);
128
129 return is_wonder(pbuilding);
130}
131
132/**********************************************************************/
136 Building_Type *pbuilding)
137{
139 LUASCRIPT_CHECK_SELF(L, pbuilding, FALSE);
140
141 return is_great_wonder(pbuilding);
142}
143
144/**********************************************************************/
148 Building_Type *pbuilding)
149{
151 LUASCRIPT_CHECK_SELF(L, pbuilding, FALSE);
152
153 return is_small_wonder(pbuilding);
154}
155
156/**********************************************************************/
160 Building_Type *pbuilding)
161{
163 LUASCRIPT_CHECK_SELF(L, pbuilding, FALSE);
164
165 return is_improvement(pbuilding);
166}
167
168/**********************************************************************/
171const char *api_methods_building_type_rule_name(lua_State *L,
172 Building_Type *pbuilding)
173{
174 LUASCRIPT_CHECK_STATE(L, NULL);
175 LUASCRIPT_CHECK_SELF(L, pbuilding, NULL);
176
177 return improvement_rule_name(pbuilding);
178}
179
180/**********************************************************************/
183const char
185 Building_Type *pbuilding)
186{
187 LUASCRIPT_CHECK_STATE(L, NULL);
188 LUASCRIPT_CHECK_SELF(L, pbuilding, NULL);
189
190 return improvement_name_translation(pbuilding);
191}
192
193/**********************************************************************/
196bool api_methods_city_has_building(lua_State *L, City *pcity,
197 Building_Type *building)
198{
200 LUASCRIPT_CHECK_SELF(L, pcity, FALSE);
202
203 return city_has_building(pcity, building);
204}
205
206/**********************************************************************/
209int api_methods_city_map_sq_radius(lua_State *L, City *pcity)
210{
212 LUASCRIPT_CHECK_SELF(L, pcity, 0);
213
214 return city_map_radius_sq_get(pcity);
215}
216
217/**********************************************************************/
220int api_methods_city_size_get(lua_State *L, City *pcity)
221{
223 LUASCRIPT_CHECK_SELF(L, pcity, 1);
224
225 return city_size_get(pcity);
226}
227
228/**********************************************************************/
231Tile *api_methods_city_tile_get(lua_State *L, City *pcity)
232{
233 LUASCRIPT_CHECK_STATE(L, NULL);
234 LUASCRIPT_CHECK_SELF(L, pcity, NULL);
235
236 return pcity->tile;
237}
238
239/**********************************************************************/
243 Player *inspirer)
244{
245 bool inspired = FALSE;
246
248 if (self->original == inspirer) {
249 inspired = TRUE;
250 }
251 } else {
253 if (is_server()) {
254 citizens own = citizens_nation_get(self, inspirer->slot);
255 citizens total = city_size_get(self);
256
257 if (total > 0 && (own * 100 / total) >= game.info.citizen_partisans_pct) {
258 inspired = TRUE;
259 }
260 }
261 /* else is_client() -> don't consider inspired by default. */
262 } else if (self->original == inspirer) {
263 inspired = TRUE;
264 }
265 }
266
267 if (inspired) {
268 /* Cannot use get_city_bonus() as it would use city's current owner
269 * instead of inspirer. */
270 return get_target_bonus_effects(NULL,
271 &(const struct req_context) {
272 .player = inspirer,
273 .city = self,
274 .tile = city_tile(self),
275 },
276 NULL, EFT_INSPIRE_PARTISANS);
277 }
278
279 return 0;
280}
281
282/**********************************************************************/
285int api_methods_city_culture_get(lua_State *L, City *pcity)
286{
288 LUASCRIPT_CHECK_SELF(L, pcity, 0);
289
290 return city_culture(pcity);
291}
292
293/**********************************************************************/
296bool api_methods_is_city_happy(lua_State *L, City *pcity)
297{
299 LUASCRIPT_CHECK_SELF(L, pcity, FALSE);
300
301 /* Note: if clients ever have virtual cities or sth, needs amending */
302 return is_server() ? city_happy(pcity) : pcity->client.happy;
303}
304
305/**********************************************************************/
308bool api_methods_is_city_unhappy(lua_State *L, City *pcity)
309{
311 LUASCRIPT_CHECK_SELF(L, pcity, FALSE);
312
313 /* Note: if clients ever have virtual cities or sth, needs amending */
314 return is_server() ? city_unhappy(pcity) : pcity->client.unhappy;
315}
316
317/**********************************************************************/
320bool api_methods_is_city_celebrating(lua_State *L, City *pcity)
321{
323 LUASCRIPT_CHECK_SELF(L, pcity, FALSE);
324
325 return city_celebrating(pcity);
326}
327
328/**********************************************************************/
331bool api_methods_is_gov_center(lua_State *L, City *pcity)
332{
334 LUASCRIPT_CHECK_SELF(L, pcity, FALSE);
335
336 return is_gov_center(pcity);
337}
338
339/**********************************************************************/
342bool api_methods_is_capital(lua_State *L, City *pcity)
343{
345 LUASCRIPT_CHECK_SELF(L, pcity, FALSE);
346
347 return is_capital(pcity);
348}
349
350/**********************************************************************/
353bool api_methods_is_primary_capital(lua_State *L, City *pcity)
354{
356 LUASCRIPT_CHECK_SELF(L, pcity, FALSE);
357
358 return pcity->capital == CAPITAL_PRIMARY;
359}
360
361/**********************************************************************/
364const char *api_methods_government_rule_name(lua_State *L,
365 Government *pgovernment)
366{
367 LUASCRIPT_CHECK_STATE(L, NULL);
368 LUASCRIPT_CHECK_SELF(L, pgovernment, NULL);
369
370 return government_rule_name(pgovernment);
371}
372
373/**********************************************************************/
377 Government *pgovernment)
378{
379 LUASCRIPT_CHECK_STATE(L, NULL);
380 LUASCRIPT_CHECK_SELF(L, pgovernment, NULL);
381
382 return government_name_translation(pgovernment);
383}
384
385/**********************************************************************/
388const char *api_methods_nation_type_rule_name(lua_State *L,
389 Nation_Type *pnation)
390{
391 LUASCRIPT_CHECK_STATE(L, NULL);
392 LUASCRIPT_CHECK_SELF(L, pnation, NULL);
393
394 return nation_rule_name(pnation);
395}
396
397/**********************************************************************/
401 Nation_Type *pnation)
402{
403 LUASCRIPT_CHECK_STATE(L, NULL);
404 LUASCRIPT_CHECK_SELF(L, pnation, NULL);
405
406 return nation_adjective_translation(pnation);
407}
408
409/**********************************************************************/
413 Nation_Type *pnation)
414{
415 LUASCRIPT_CHECK_STATE(L, NULL);
416 LUASCRIPT_CHECK_SELF(L, pnation, NULL);
417
418 return nation_plural_translation(pnation);
419}
420
421/**********************************************************************/
424const char *api_methods_player_controlling_gui(lua_State *L,
425 Player *pplayer)
426{
427 struct connection *conn = NULL;
428
429 LUASCRIPT_CHECK_STATE(L, NULL);
430 LUASCRIPT_CHECK_SELF(L, pplayer, NULL);
431
432 conn_list_iterate(pplayer->connections, pconn) {
433 if (!pconn->observer) {
434 conn = pconn;
435 break;
436 }
438
439 if (conn == NULL) {
440 return "None";
441 }
442
443 return gui_type_name(conn->client_gui);
444}
445
446/**********************************************************************/
449bool api_methods_player_has_wonder(lua_State *L, Player *pplayer,
450 Building_Type *building)
451{
453 LUASCRIPT_CHECK_SELF(L, pplayer, FALSE);
455
456 return wonder_is_built(pplayer, building);
457}
458
459/**********************************************************************/
462int api_methods_player_number(lua_State *L, Player *pplayer)
463{
465 LUASCRIPT_CHECK_SELF(L, pplayer, -1);
466
467 return player_number(pplayer);
468}
469
470/**********************************************************************/
473int api_methods_player_num_cities(lua_State *L, Player *pplayer)
474{
476 LUASCRIPT_CHECK_SELF(L, pplayer, 0);
477
478 return city_list_size(pplayer->cities);
479}
480
481/**********************************************************************/
484int api_methods_player_num_units(lua_State *L, Player *pplayer)
485{
487 LUASCRIPT_CHECK_SELF(L, pplayer, 0);
488
489 return unit_list_size(pplayer->units);
490}
491
492/**********************************************************************/
495int api_methods_player_gold(lua_State *L, Player *pplayer)
496{
498 LUASCRIPT_CHECK_SELF(L, pplayer, 0);
499
500 return pplayer->economic.gold;
501}
502
503/**********************************************************************/
506bool api_methods_player_knows_tech(lua_State *L, Player *pplayer,
507 Tech_Type *ptech)
508{
510 LUASCRIPT_CHECK_SELF(L, pplayer, FALSE);
512
514 advance_number(ptech)) == TECH_KNOWN;
515}
516
517/**********************************************************************/
520int api_methods_player_culture_get(lua_State *L, Player *pplayer)
521{
523 LUASCRIPT_CHECK_SELF(L, pplayer, 0);
524
525 return player_culture(pplayer);
526}
527
528/**********************************************************************/
531bool api_methods_player_has_flag(lua_State *L, Player *pplayer,
532 const char *flag)
533{
534 enum plr_flag_id flag_val;
535
537 LUASCRIPT_CHECK_SELF(L, pplayer, 0);
538
539 flag_val = plr_flag_id_by_name(flag, fc_strcasecmp);
540
541 if (plr_flag_id_is_valid(flag_val)) {
542 return player_has_flag(pplayer, flag_val);
543 }
544
545 return FALSE;
546}
547
548/**********************************************************************/
553 Unit_Type *utype)
554{
555 LUASCRIPT_CHECK_STATE(L, NULL);
556 LUASCRIPT_CHECK_SELF(L, pplayer, NULL);
557 LUASCRIPT_CHECK_ARG_NIL(L, utype, 3, Unit_Type, NULL);
558
559 return (Unit_Type *)can_upgrade_unittype(pplayer, utype);
560}
561
562/**********************************************************************/
567 Unit_Type *utype)
568{
570 LUASCRIPT_CHECK_SELF(L, pplayer, FALSE);
572
573 return can_player_build_unit_direct(pplayer, utype);
574}
575
576/**********************************************************************/
580 Building_Type *itype)
581{
583 LUASCRIPT_CHECK_SELF(L, pplayer, FALSE);
585
586 return can_player_build_improvement_direct(pplayer, itype);
587}
588
589
590/**********************************************************************/
594bool api_methods_unit_can_upgrade(lua_State *L, Unit *punit, bool is_free)
595{
596
597 return UU_OK == unit_upgrade_test(&(wld.map), punit, is_free);
598}
599
600/**********************************************************************/
605 Unit_Type *ptype)
606{
607 enum unit_upgrade_result uu;
608
609 LUASCRIPT_CHECK_STATE(L, NULL);
610 LUASCRIPT_CHECK_SELF(L, punit, NULL);
611 LUASCRIPT_CHECK_ARG_NIL(L, ptype, 3, Unit_Type, NULL);
612
613 uu = unit_transform_result(&(wld.map), punit, ptype);
614 switch (uu) {
615 case UU_OK:
616 return NULL;
618 return "cargo";
620 return "transport";
621 case UU_NOT_TERRAIN:
622 return "terrain";
623 case UU_NOT_ACTIVITY:
624 return "activity";
625 case UU_NO_UNITTYPE:
626 case UU_NO_MONEY:
627 case UU_NOT_IN_CITY:
629 /* should not get here */
630 break;
631 }
632
633 fc_assert_msg(FALSE, "Unexpected unit transform result %i", uu);
634
635 return "\?";
636}
637
638/**********************************************************************/
641bool api_methods_player_shares_research(lua_State *L, Player *pplayer,
642 Player *aplayer)
643{
645 LUASCRIPT_CHECK_SELF(L, pplayer, FALSE);
646 LUASCRIPT_CHECK_ARG_NIL(L, aplayer, 3, Player, FALSE);
647
648 return research_get(pplayer) == research_get(aplayer);
649}
650
651/**********************************************************************/
654const char *api_methods_research_rule_name(lua_State *L, Player *pplayer)
655{
656 LUASCRIPT_CHECK_STATE(L, NULL);
657 LUASCRIPT_CHECK_SELF(L, pplayer, NULL);
658
659 return research_rule_name(research_get(pplayer));
660}
661
662/**********************************************************************/
666 Player *pplayer)
667{
668 static char buf[MAX_LEN_MSG];
669
670 LUASCRIPT_CHECK_STATE(L, NULL);
671 LUASCRIPT_CHECK_SELF(L, pplayer, NULL);
672
673 (void) research_pretty_name(research_get(pplayer), buf, ARRAY_SIZE(buf));
674
675 return buf;
676}
677
678/**********************************************************************/
682lua_Object api_methods_private_list_players(lua_State *L)
683{
684 lua_Object result = 0;
685 int i = 0;
686
688 lua_createtable(L, player_count(), 0);
689 result = lua_gettop(L);
690 players_iterate(pplayer) {
691 tolua_pushfieldusertype(L, result, ++i, pplayer, "Player");
693 return result;
694}
695
696/**********************************************************************/
700 Player *pplayer)
701{
702 LUASCRIPT_CHECK_STATE(L, NULL);
703 LUASCRIPT_CHECK_SELF(L, pplayer, NULL);
704 return unit_list_head(pplayer->units);
705}
706
707/**********************************************************************/
711 Player *pplayer)
712{
713 LUASCRIPT_CHECK_STATE(L, NULL);
714 LUASCRIPT_CHECK_SELF(L, pplayer, NULL);
715
716 return city_list_head(pplayer->cities);
717}
718
719/**********************************************************************/
722const char *api_methods_tech_type_rule_name(lua_State *L, Tech_Type *ptech)
723{
724 LUASCRIPT_CHECK_STATE(L, NULL);
725 LUASCRIPT_CHECK_SELF(L, ptech, NULL);
726
727 return advance_rule_name(ptech);
728}
729
730/**********************************************************************/
734 Tech_Type *ptech)
735{
736 LUASCRIPT_CHECK_STATE(L, NULL);
737 LUASCRIPT_CHECK_SELF(L, ptech, NULL);
738
739 return advance_name_translation(ptech);
740}
741
742/**********************************************************************/
745const char *api_methods_terrain_rule_name(lua_State *L, Terrain *pterrain)
746{
747 LUASCRIPT_CHECK_STATE(L, NULL);
748 LUASCRIPT_CHECK_SELF(L, pterrain, NULL);
749
750 return terrain_rule_name(pterrain);
751}
752
753/**********************************************************************/
757 Terrain *pterrain)
758{
759 LUASCRIPT_CHECK_STATE(L, NULL);
760 LUASCRIPT_CHECK_SELF(L, pterrain, NULL);
761
762 return terrain_name_translation(pterrain);
763}
764
765/**********************************************************************/
768const char *api_methods_terrain_class_name(lua_State *L, Terrain *pterrain)
769{
770 LUASCRIPT_CHECK_STATE(L, NULL);
771 LUASCRIPT_CHECK_SELF(L, pterrain, NULL);
772
773 return terrain_class_name(terrain_type_terrain_class(pterrain));
774}
775
776/**********************************************************************/
779const char *api_methods_disaster_rule_name(lua_State *L, Disaster *pdis)
780{
781 LUASCRIPT_CHECK_STATE(L, NULL);
782 LUASCRIPT_CHECK_SELF(L, pdis, NULL);
783
784 return disaster_rule_name(pdis);
785}
786
787/**********************************************************************/
791 Disaster *pdis)
792{
793 LUASCRIPT_CHECK_STATE(L, NULL);
794 LUASCRIPT_CHECK_SELF(L, pdis, NULL);
795
796 return disaster_name_translation(pdis);
797}
798
799/**********************************************************************/
802const char *api_methods_achievement_rule_name(lua_State *L,
803 Achievement *pach)
804{
805 LUASCRIPT_CHECK_STATE(L, NULL);
806 LUASCRIPT_CHECK_SELF(L, pach, NULL);
807
808 return achievement_rule_name(pach);
809}
810
811/**********************************************************************/
815 Achievement *pach)
816{
817 LUASCRIPT_CHECK_STATE(L, NULL);
818 LUASCRIPT_CHECK_SELF(L, pach, NULL);
819
820 return achievement_name_translation(pach);
821}
822
823/**********************************************************************/
826const char *api_methods_action_rule_name(lua_State *L, Action *pact)
827{
828 LUASCRIPT_CHECK_STATE(L, NULL);
829 LUASCRIPT_CHECK_SELF(L, pact, NULL);
830
831 return action_id_rule_name(pact->id);
832}
833
834/**********************************************************************/
837const char *api_methods_action_name_translation(lua_State *L, Action *pact)
838{
839 LUASCRIPT_CHECK_STATE(L, NULL);
840 LUASCRIPT_CHECK_SELF(L, pact, NULL);
841
842 return action_id_name_translation(pact->id);
843}
844
845/**********************************************************************/
848const char *api_methods_action_target_kind(lua_State *L, Action *pact)
849{
850 struct action *paction;
851
852 LUASCRIPT_CHECK_STATE(L, NULL);
853 LUASCRIPT_CHECK_SELF(L, pact, NULL);
854
855 paction = action_by_number(pact->id);
856 fc_assert_ret_val(paction, "error: no action");
857
858 return action_target_kind_name(action_get_target_kind(paction));
859}
860
861/**********************************************************************/
864int api_methods_tile_nat_x(lua_State *L, Tile *ptile)
865{
867 LUASCRIPT_CHECK_SELF(L, ptile, -1);
868
869 return index_to_native_pos_x(tile_index(ptile));
870}
871
872/**********************************************************************/
875int api_methods_tile_nat_y(lua_State *L, Tile *ptile)
876{
878 LUASCRIPT_CHECK_SELF(L, ptile, -1);
879
880 return index_to_native_pos_y(tile_index(ptile));
881}
882
883/**********************************************************************/
886int api_methods_tile_map_x(lua_State *L, Tile *ptile)
887{
889 LUASCRIPT_CHECK_SELF(L, ptile, -1);
890
891 return index_to_map_pos_x(tile_index(ptile));
892}
893
894/**********************************************************************/
897int api_methods_tile_map_y(lua_State *L, Tile *ptile)
898{
900 LUASCRIPT_CHECK_SELF(L, ptile, -1);
901
902 return index_to_map_pos_y(tile_index(ptile));
903}
904
905/**********************************************************************/
908City *api_methods_tile_city(lua_State *L, Tile *ptile)
909{
910 LUASCRIPT_CHECK_STATE(L, NULL);
911 LUASCRIPT_CHECK_SELF(L, ptile, NULL);
912
913 return tile_city(ptile);
914}
915
916/**********************************************************************/
920 Tile *ptile,
921 bool may_be_on_center)
922{
924 LUASCRIPT_CHECK_SELF(L, ptile, FALSE);
925
926 return city_exists_within_max_city_map(&(wld.map), ptile, may_be_on_center);
927}
928
929/**********************************************************************/
933bool api_methods_tile_has_extra(lua_State *L, Tile *ptile,
934 const char *name)
935{
937 LUASCRIPT_CHECK_SELF(L, ptile, FALSE);
938
939 if (!name) {
940 extra_type_iterate(pextra) {
941 if (tile_has_extra(ptile, pextra)) {
942 return TRUE;
943 }
945
946 return FALSE;
947 } else {
948 struct extra_type *pextra;
949
951
952 return (NULL != pextra && tile_has_extra(ptile, pextra));
953 }
954}
955
956/**********************************************************************/
960bool api_methods_tile_has_base(lua_State *L, Tile *ptile, const char *name)
961{
963 LUASCRIPT_CHECK_SELF(L, ptile, FALSE);
964
965 if (!name) {
966 extra_type_by_cause_iterate(EC_BASE, pextra) {
967 if (tile_has_extra(ptile, pextra)) {
968 return TRUE;
969 }
971
972 return FALSE;
973 } else {
974 struct extra_type *pextra;
975
977
978 return (NULL != pextra && is_extra_caused_by(pextra, EC_BASE)
979 && tile_has_extra(ptile, pextra));
980 }
981}
982
983/**********************************************************************/
987bool api_methods_tile_has_road(lua_State *L, Tile *ptile, const char *name)
988{
990 LUASCRIPT_CHECK_SELF(L, ptile, FALSE);
991
992 if (!name) {
993 extra_type_by_cause_iterate(EC_ROAD, pextra) {
994 if (tile_has_extra(ptile, pextra)) {
995 return TRUE;
996 }
998
999 return FALSE;
1000 } else {
1001 struct extra_type *pextra;
1002
1003 pextra = extra_type_by_rule_name(name);
1004
1005 return (NULL != pextra && is_extra_caused_by(pextra, EC_ROAD)
1006 && tile_has_extra(ptile, pextra));
1007 }
1008}
1009
1010/**********************************************************************/
1017 Tile *ptile, const char *extra_name)
1018{
1019 LUASCRIPT_CHECK_STATE(L, NULL);
1020 LUASCRIPT_CHECK_SELF(L, ptile, NULL);
1021
1022 if (extra_name) {
1023 struct extra_type *pextra;
1024
1025 pextra = extra_type_by_rule_name(extra_name);
1026 LUASCRIPT_CHECK_ARG(L, pextra != NULL, 3, "unknown extra type", NULL);
1027
1028 if (tile_has_extra(ptile, pextra)) {
1029 /* All extras have the same owner. */
1030 return extra_owner(ptile);
1031 } else {
1032 /* The extra isn't there. */
1033 return NULL;
1034 }
1035 } else {
1036 extra_type_iterate(pextra) {
1037 if (tile_has_extra(ptile, pextra)) {
1038 /* All extras have the same owner. */
1039 return extra_owner(ptile);
1040 }
1042 return NULL;
1043 }
1044}
1045
1046/**********************************************************************/
1049bool api_methods_enemy_tile(lua_State *L, Tile *ptile, Player *against)
1050{
1051 struct city *pcity;
1052
1054 LUASCRIPT_CHECK_SELF(L, ptile, FALSE);
1055
1056 if (is_non_allied_unit_tile(ptile, against)) {
1057 return TRUE;
1058 }
1059
1060 pcity = tile_city(ptile);
1061 if (pcity != NULL && !pplayers_allied(against, city_owner(pcity))) {
1062 return TRUE;
1063 }
1064
1065 return FALSE;
1066}
1067
1068/**********************************************************************/
1071int api_methods_tile_num_units(lua_State *L, Tile *ptile)
1072{
1074 LUASCRIPT_CHECK_SELF(L, ptile, 0);
1075
1076 return unit_list_size(ptile->units);
1077}
1078
1079/**********************************************************************/
1083 Tile *ptile)
1084{
1085 LUASCRIPT_CHECK_STATE(L, NULL);
1086 LUASCRIPT_CHECK_SELF(L, ptile, NULL);
1087
1088 return unit_list_head(ptile->units);
1089}
1090
1091/**********************************************************************/
1096 int tindex, int max_dist)
1097{
1098 int dx, dy;
1099 int newx, newy;
1100 int startx, starty;
1101
1103 LUASCRIPT_CHECK_SELF(L, pstart, 0);
1104
1105 if (tindex < 0) {
1106 return 0;
1107 }
1108
1109 index_to_map_pos(&startx, &starty, tile_index(pstart));
1110
1111 tindex++;
1112 while (tindex < wld.map.num_iterate_outwards_indices) {
1113 if (wld.map.iterate_outwards_indices[tindex].dist > max_dist) {
1114 return -1;
1115 }
1116 dx = wld.map.iterate_outwards_indices[tindex].dx;
1117 dy = wld.map.iterate_outwards_indices[tindex].dy;
1118 newx = dx + startx;
1119 newy = dy + starty;
1120 if (!normalize_map_pos(&(wld.map), &newx, &newy)) {
1121 tindex++;
1122 continue;
1123 }
1124
1125 return tindex;
1126 }
1127
1128 return -1;
1129}
1130
1131/**********************************************************************/
1135 Tile *pstart, int tindex)
1136{
1137 int newx, newy;
1138
1139 LUASCRIPT_CHECK_STATE(L, NULL);
1140 LUASCRIPT_CHECK_SELF(L, pstart, NULL);
1142 tindex >= 0 && tindex < wld.map.num_iterate_outwards_indices,
1143 3, "index out of bounds", NULL);
1144
1145 index_to_map_pos(&newx, &newy, tile_index(pstart));
1146 newx += wld.map.iterate_outwards_indices[tindex].dx;
1147 newy += wld.map.iterate_outwards_indices[tindex].dy;
1148
1149 if (!normalize_map_pos(&(wld.map), &newx, &newy)) {
1150 return NULL;
1151 }
1152
1153 return map_pos_to_tile(&(wld.map), newx, newy);
1154}
1155
1156/**********************************************************************/
1159int api_methods_tile_sq_distance(lua_State *L, Tile *ptile1, Tile *ptile2)
1160{
1162 LUASCRIPT_CHECK_SELF(L, ptile1, 0);
1163 LUASCRIPT_CHECK_ARG_NIL(L, ptile2, 3, Tile, 0);
1164
1165 return sq_map_distance(ptile1, ptile2);
1166}
1167
1168/**********************************************************************/
1176{
1177 const struct civ_map *nmap = &(wld.map);
1178
1181
1183}
1184
1185/**********************************************************************/
1189{
1190 LUASCRIPT_CHECK_STATE(L, NULL);
1191 LUASCRIPT_CHECK_SELF(L, punit, NULL);
1192
1193 return unit_tile(punit);
1194}
1195
1196/**********************************************************************/
1200 Unit *punit)
1201{
1202 LUASCRIPT_CHECK_STATE(L, NULL);
1203 LUASCRIPT_CHECK_ARG_NIL(L, punit, 2, Unit, NULL);
1204
1205 return luascript_dir(punit->facing);
1206}
1207
1208/**********************************************************************/
1212{
1213 LUASCRIPT_CHECK_STATE(L, NULL);
1214 LUASCRIPT_CHECK_SELF(L, punit, NULL);
1215
1216 return punit->transporter;
1217}
1218
1219/**********************************************************************/
1223 Unit *punit)
1224{
1225 LUASCRIPT_CHECK_STATE(L, NULL);
1226 LUASCRIPT_CHECK_SELF(L, punit, NULL);
1227 return unit_list_head(punit->transporting);
1228}
1229
1230/**********************************************************************/
1233bool api_methods_unit_type_has_flag(lua_State *L, Unit_Type *punit_type,
1234 const char *flag)
1235{
1236 enum unit_type_flag_id id;
1237
1239 LUASCRIPT_CHECK_SELF(L, punit_type, FALSE);
1240 LUASCRIPT_CHECK_ARG_NIL(L, flag, 3, string, FALSE);
1241
1242 id = unit_type_flag_id_by_name(flag, fc_strcasecmp);
1243 if (unit_type_flag_id_is_valid(id)) {
1244 return utype_has_flag(punit_type, id);
1245 } else {
1246 luascript_error(L, "Unit type flag \"%s\" does not exist", flag);
1247 return FALSE;
1248 }
1249}
1250
1251/**********************************************************************/
1254bool api_methods_unit_type_has_role(lua_State *L, Unit_Type *punit_type,
1255 const char *role)
1256{
1257 enum unit_role_id id;
1258
1260 LUASCRIPT_CHECK_SELF(L, punit_type, FALSE);
1261 LUASCRIPT_CHECK_ARG_NIL(L, role, 3, string, FALSE);
1262
1263 id = unit_role_id_by_name(role, fc_strcasecmp);
1264 if (unit_role_id_is_valid(id)) {
1265 return utype_has_role(punit_type, id);
1266 } else {
1267 luascript_error(L, "Unit role \"%s\" does not exist", role);
1268 return FALSE;
1269 }
1270}
1271
1272/**********************************************************************/
1276 Unit_Type *punit_type,
1277 Tile *ptile)
1278{
1280 LUASCRIPT_CHECK_SELF(L, punit_type, FALSE);
1281 LUASCRIPT_CHECK_ARG_NIL(L, ptile, 3, Tile, FALSE);
1282
1283 return can_exist_at_tile(&(wld.map), punit_type, ptile);
1284}
1285
1286/**********************************************************************/
1289const char *api_methods_unit_type_rule_name(lua_State *L,
1290 Unit_Type *punit_type)
1291{
1292 LUASCRIPT_CHECK_STATE(L, NULL);
1293 LUASCRIPT_CHECK_SELF(L, punit_type, NULL);
1294
1295 return utype_rule_name(punit_type);
1296}
1297
1298/**********************************************************************/
1302 Unit_Type *punit_type)
1303{
1304 LUASCRIPT_CHECK_STATE(L, NULL);
1305 LUASCRIPT_CHECK_SELF(L, punit_type, NULL);
1306
1307 return utype_name_translation(punit_type);
1308}
1309
1310
1311/**********************************************************************/
1315 Unit_List_Link *ul_link)
1316{
1317 LUASCRIPT_CHECK_STATE(L, NULL);
1318
1319 return unit_list_link_data(ul_link);
1320}
1321
1322/**********************************************************************/
1326 Unit_List_Link *ul_link)
1327{
1328 LUASCRIPT_CHECK_STATE(L, NULL);
1329
1330 return unit_list_link_next(ul_link);
1331}
1332
1333/**********************************************************************/
1337 City_List_Link *cl_link)
1338{
1339 LUASCRIPT_CHECK_STATE(L, NULL);
1340
1341 return city_list_link_data(cl_link);
1342}
1343
1344/**********************************************************************/
1348 City_List_Link *cl_link)
1349{
1350 LUASCRIPT_CHECK_STATE(L, NULL);
1351
1352 return city_list_link_next(cl_link);
1353}
1354
1355/**********************************************************************/
1358const char *api_methods_tile_link(lua_State *L, Tile *ptile)
1359{
1360 LUASCRIPT_CHECK_STATE(L, NULL);
1361 LUASCRIPT_CHECK_SELF(L, ptile, NULL);
1362
1363 return tile_link(ptile);
1364}
1365
1366/**********************************************************************/
1369const char *api_methods_unit_tile_link(lua_State *L, Unit *punit)
1370{
1371 LUASCRIPT_CHECK_STATE(L, NULL);
1372 LUASCRIPT_CHECK_SELF(L, punit, NULL);
1373
1374 return unit_tile_link(punit);
1375}
1376
1377/**********************************************************************/
1380const char *api_methods_city_tile_link(lua_State *L, City *pcity)
1381{
1382 LUASCRIPT_CHECK_STATE(L, NULL);
1383 LUASCRIPT_CHECK_SELF(L, pcity, NULL);
1384
1385 return city_tile_link(pcity);
1386}
1387
1388/**********************************************************************/
1391const char *api_methods_unit_link(lua_State *L, Unit *punit)
1392{
1393 LUASCRIPT_CHECK_STATE(L, NULL);
1394 LUASCRIPT_CHECK_SELF(L, punit, NULL);
1395
1396 return unit_link(punit);
1397}
1398
1399/**********************************************************************/
1402const char *api_methods_city_link(lua_State *L, City *pcity)
1403{
1404 LUASCRIPT_CHECK_STATE(L, NULL);
1405 LUASCRIPT_CHECK_SELF(L, pcity, NULL);
1406
1407 return city_link(pcity);
1408}
const char * achievement_rule_name(struct achievement *pach)
const char * achievement_name_translation(struct achievement *pach)
const char * action_id_name_translation(action_id act_id)
Definition actions.c:1910
const char * action_id_rule_name(action_id act_id)
Definition actions.c:1899
enum action_target_kind action_get_target_kind(const struct action *paction)
Definition actions.c:1740
static struct action * action_by_number(action_id act_id)
Definition actions.h:638
int api_methods_tile_nat_x(lua_State *L, Tile *ptile)
int api_methods_tile_num_units(lua_State *L, Tile *ptile)
bool api_methods_is_city_unhappy(lua_State *L, City *pcity)
bool api_methods_is_gov_center(lua_State *L, City *pcity)
const char * api_methods_game_rulesetdir(lua_State *L)
bool api_methods_unit_type_can_exist_at_tile(lua_State *L, Unit_Type *punit_type, Tile *ptile)
int api_methods_player_num_cities(lua_State *L, Player *pplayer)
bool api_methods_unit_can_upgrade(lua_State *L, Unit *punit, bool is_free)
bool api_methods_player_has_wonder(lua_State *L, Player *pplayer, Building_Type *building)
Unit_List_Link * api_methods_unit_list_next_link(lua_State *L, Unit_List_Link *ul_link)
const char * api_methods_nation_type_plural_translation(lua_State *L, Nation_Type *pnation)
const char * api_methods_disaster_name_translation(lua_State *L, Disaster *pdis)
Unit * api_methods_unit_list_link_data(lua_State *L, Unit_List_Link *ul_link)
int api_methods_tile_nat_y(lua_State *L, Tile *ptile)
Unit_List_Link * api_methods_private_tile_unit_list_head(lua_State *L, Tile *ptile)
int api_methods_game_year_fragment(lua_State *L)
int api_methods_city_culture_get(lua_State *L, City *pcity)
const char * api_methods_unit_type_name_translation(lua_State *L, Unit_Type *punit_type)
const char * api_methods_game_ruleset_name(lua_State *L)
const char * api_methods_building_type_rule_name(lua_State *L, Building_Type *pbuilding)
City * api_methods_city_list_link_data(lua_State *L, City_List_Link *cl_link)
const char * api_methods_unit_tile_link(lua_State *L, Unit *punit)
bool api_methods_player_can_build_impr_direct(lua_State *L, Player *pplayer, Building_Type *itype)
int api_methods_player_num_units(lua_State *L, Player *pplayer)
const char * api_methods_tech_type_rule_name(lua_State *L, Tech_Type *ptech)
int api_methods_tile_map_x(lua_State *L, Tile *ptile)
bool api_methods_is_city_happy(lua_State *L, City *pcity)
const char * api_methods_achievement_rule_name(lua_State *L, Achievement *pach)
Unit_Type * api_methods_player_can_upgrade(lua_State *L, Player *pplayer, Unit_Type *utype)
const char * api_methods_city_link(lua_State *L, City *pcity)
const char * api_methods_nation_type_name_translation(lua_State *L, Nation_Type *pnation)
const char * api_methods_government_rule_name(lua_State *L, Government *pgovernment)
const char * api_methods_terrain_rule_name(lua_State *L, Terrain *pterrain)
int api_methods_player_number(lua_State *L, Player *pplayer)
Unit_List_Link * api_methods_private_unit_cargo_list_head(lua_State *L, Unit *punit)
const char * api_methods_player_controlling_gui(lua_State *L, Player *pplayer)
const char * api_methods_action_name_translation(lua_State *L, Action *pact)
const char * api_methods_terrain_class_name(lua_State *L, Terrain *pterrain)
bool api_methods_player_shares_research(lua_State *L, Player *pplayer, Player *aplayer)
const char * api_methods_tech_type_name_translation(lua_State *L, Tech_Type *ptech)
Player * api_methods_tile_extra_owner(lua_State *L, Tile *ptile, const char *extra_name)
int api_methods_city_size_get(lua_State *L, City *pcity)
City * api_methods_tile_city(lua_State *L, Tile *ptile)
const char * api_methods_government_name_translation(lua_State *L, Government *pgovernment)
bool api_methods_tile_has_extra(lua_State *L, Tile *ptile, const char *name)
int api_methods_tile_sq_distance(lua_State *L, Tile *ptile1, Tile *ptile2)
bool api_methods_unit_type_has_role(lua_State *L, Unit_Type *punit_type, const char *role)
const char * api_methods_tile_link(lua_State *L, Tile *ptile)
int api_methods_player_culture_get(lua_State *L, Player *pplayer)
int api_methods_game_turn_deprecated(lua_State *L)
const char * api_methods_achievement_name_translation(lua_State *L, Achievement *pach)
bool api_methods_building_type_is_great_wonder(lua_State *L, Building_Type *pbuilding)
const char * api_methods_city_tile_link(lua_State *L, City *pcity)
int api_methods_private_tile_next_outward_index(lua_State *L, Tile *pstart, int tindex, int max_dist)
Tile * api_methods_unit_tile_get(lua_State *L, Unit *punit)
bool api_methods_tile_has_road(lua_State *L, Tile *ptile, const char *name)
const char * api_methods_nation_type_rule_name(lua_State *L, Nation_Type *pnation)
const Direction * api_methods_unit_orientation_get(lua_State *L, Unit *punit)
int api_methods_game_turn(lua_State *L)
bool api_methods_player_knows_tech(lua_State *L, Player *pplayer, Tech_Type *ptech)
bool api_methods_enemy_tile(lua_State *L, Tile *ptile, Player *against)
bool api_methods_building_type_is_small_wonder(lua_State *L, Building_Type *pbuilding)
int api_methods_game_year(lua_State *L)
Tile * api_methods_private_tile_for_outward_index(lua_State *L, Tile *pstart, int tindex)
const char * api_methods_game_year_text(lua_State *L)
const char * api_methods_action_rule_name(lua_State *L, Action *pact)
const char * api_methods_disaster_rule_name(lua_State *L, Disaster *pdis)
const char * api_methods_building_type_name_translation(lua_State *L, Building_Type *pbuilding)
bool api_methods_building_type_is_wonder(lua_State *L, Building_Type *pbuilding)
const char * api_methods_research_name_translation(lua_State *L, Player *pplayer)
int api_methods_city_inspire_partisans(lua_State *L, City *self, Player *inspirer)
int api_methods_city_map_sq_radius(lua_State *L, City *pcity)
bool api_methods_city_has_building(lua_State *L, City *pcity, Building_Type *building)
const char * api_methods_unit_transform_problem(lua_State *L, Unit *punit, Unit_Type *ptype)
City_List_Link * api_methods_city_list_next_link(lua_State *L, City_List_Link *cl_link)
bool api_methods_unit_type_has_flag(lua_State *L, Unit_Type *punit_type, const char *flag)
const char * api_methods_unit_type_rule_name(lua_State *L, Unit_Type *punit_type)
bool api_methods_building_type_is_improvement(lua_State *L, Building_Type *pbuilding)
bool api_methods_tile_city_exists_within_max_city_map(lua_State *L, Tile *ptile, bool may_be_on_center)
bool api_methods_player_has_flag(lua_State *L, Player *pplayer, const char *flag)
lua_Object api_methods_private_list_players(lua_State *L)
bool api_methods_unit_city_can_be_built_here(lua_State *L, Unit *punit)
bool api_methods_tile_has_base(lua_State *L, Tile *ptile, const char *name)
int api_methods_player_gold(lua_State *L, Player *pplayer)
const char * api_methods_research_rule_name(lua_State *L, Player *pplayer)
bool api_methods_is_primary_capital(lua_State *L, City *pcity)
int api_methods_tile_map_y(lua_State *L, Tile *ptile)
Unit_List_Link * api_methods_private_player_unit_list_head(lua_State *L, Player *pplayer)
const char * api_methods_action_target_kind(lua_State *L, Action *pact)
City_List_Link * api_methods_private_player_city_list_head(lua_State *L, Player *pplayer)
const char * api_methods_terrain_name_translation(lua_State *L, Terrain *pterrain)
Tile * api_methods_city_tile_get(lua_State *L, City *pcity)
const char * api_methods_unit_link(lua_State *L, Unit *punit)
bool api_methods_is_city_celebrating(lua_State *L, City *pcity)
bool api_methods_is_capital(lua_State *L, City *pcity)
bool api_methods_player_can_build_unit_direct(lua_State *L, Player *pplayer, Unit_Type *utype)
Unit * api_methods_unit_transporter(lua_State *L, Unit *punit)
const char * calendar_text(void)
Definition calendar.c:141
citizens citizens_nation_get(const struct city *pcity, const struct player_slot *pslot)
Definition citizens.c:74
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:1216
bool is_capital(const struct city *pcity)
Definition city.c:1552
bool city_unhappy(const struct city *pcity)
Definition city.c:1599
bool city_celebrating(const struct city *pcity)
Definition city.c:1618
bool city_can_be_built_here(const struct civ_map *nmap, const struct tile *ptile, const struct unit *punit, bool hut_test)
Definition city.c:1460
bool city_happy(const struct city *pcity)
Definition city.c:1587
int city_map_radius_sq_get(const struct city *pcity)
Definition city.c:132
bool is_gov_center(const struct city *pcity)
Definition city.c:1560
bool city_exists_within_max_city_map(const struct civ_map *nmap, const struct tile *ptile, bool may_be_on_center)
Definition city.c:2084
#define city_tile(_pcity_)
Definition city.h:544
static citizens city_size_get(const struct city *pcity)
Definition city.h:549
#define city_owner(_pcity_)
Definition city.h:543
static struct ai_type * self
Definition classicai.c:46
#define conn_list_iterate(connlist, pconn)
Definition connection.h:113
#define conn_list_iterate_end
Definition connection.h:115
int city_culture(const struct city *pcity)
Definition culture.c:29
int player_culture(const struct player *plr)
Definition culture.c:46
#define log_deprecation(message,...)
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:73
const char * disaster_rule_name(struct disaster_type *pdis)
Definition disaster.c:105
const char * disaster_name_translation(struct disaster_type *pdis)
Definition disaster.c:97
int int id
Definition editgui_g.h:28
int get_target_bonus_effects(struct effect_list *plist, const struct req_context *context, const struct player *other_player, enum effect_type effect_type)
Definition effects.c:691
struct extra_type * extra_type_by_rule_name(const char *name)
Definition extras.c:204
struct player * extra_owner(const struct tile *ptile)
Definition extras.c:1068
#define extra_type_iterate(_p)
Definition extras.h:291
#define extra_type_iterate_end
Definition extras.h:297
#define is_extra_caused_by(e, c)
Definition extras.h:196
#define extra_type_by_cause_iterate_end
Definition extras.h:315
#define extra_type_by_cause_iterate(_cause, _extra)
Definition extras.h:309
static bool is_server(void)
unsigned char citizens
Definition fc_types.h:358
const char * city_tile_link(const struct city *pcity)
const char * tile_link(const struct tile *ptile)
const char * city_link(const struct city *pcity)
const char * unit_link(const struct unit *punit)
const char * unit_tile_link(const struct unit *punit)
struct civ_game game
Definition game.c:57
struct world wld
Definition game.c:58
const char * government_name_translation(const struct government *pgovern)
Definition government.c:142
const char * government_rule_name(const struct government *pgovern)
Definition government.c:132
bool can_player_build_improvement_direct(const struct player *p, const struct impr_type *pimprove)
bool is_improvement(const struct impr_type *pimprove)
bool wonder_is_built(const struct player *pplayer, const struct impr_type *pimprove)
const char * improvement_rule_name(const struct impr_type *pimprove)
bool is_wonder(const struct impr_type *pimprove)
bool is_great_wonder(const struct impr_type *pimprove)
const char * improvement_name_translation(const struct impr_type *pimprove)
bool is_small_wonder(const struct impr_type *pimprove)
const char * name
Definition inputfile.c:127
#define fc_assert_msg(condition, message,...)
Definition log.h:181
#define fc_assert_ret_val(condition, val)
Definition log.h:194
int luascript_error(lua_State *L, const char *format,...)
Definition luascript.c:291
const Direction * luascript_dir(enum direction8 dir)
Definition luascript.c:789
#define LUASCRIPT_CHECK_STATE(L,...)
Definition luascript.h:117
#define LUASCRIPT_CHECK_SELF(L, value,...)
Definition luascript.h:146
#define LUASCRIPT_CHECK_ARG_NIL(L, value, narg, type,...)
Definition luascript.h:138
#define LUASCRIPT_CHECK_ARG(L, check, narg, msg,...)
Definition luascript.h:131
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)
Definition map.c:639
struct tile * map_pos_to_tile(const struct civ_map *nmap, int map_x, int map_y)
Definition map.c:417
bool normalize_map_pos(const struct civ_map *nmap, int *x, int *y)
Definition map.c:977
#define index_to_native_pos_y(mindex)
Definition map.h:156
static int index_to_map_pos_y(int mindex)
Definition map.h:696
static int index_to_map_pos_x(int mindex)
Definition map.h:687
#define index_to_native_pos_x(mindex)
Definition map.h:154
#define index_to_map_pos(pmap_x, pmap_y, mindex)
Definition map.h:227
bool can_exist_at_tile(const struct civ_map *nmap, const struct unit_type *utype, const struct tile *ptile)
Definition movement.c:275
const char * nation_rule_name(const struct nation_type *pnation)
Definition nation.c:137
const char * nation_adjective_translation(const struct nation_type *pnation)
Definition nation.c:148
const char * nation_plural_translation(const struct nation_type *pnation)
Definition nation.c:158
#define MAX_LEN_MSG
Definition packets.h:43
int player_count(void)
Definition player.c:808
int player_number(const struct player *pplayer)
Definition player.c:828
bool player_has_flag(const struct player *pplayer, enum plr_flag_id flag)
Definition player.c:1954
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1381
#define players_iterate_end
Definition player.h:535
#define players_iterate(_pplayer)
Definition player.h:530
const char * research_rule_name(const struct research *presearch)
Definition research.c:141
struct research * research_get(const struct player *pplayer)
Definition research.c:126
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:616
int research_pretty_name(const struct research *presearch, char *buf, size_t buf_len)
Definition research.c:167
#define ARRAY_SIZE(x)
Definition shared.h:85
action_id id
Definition actions.h:380
Definition city.h:309
enum capital_type capital
Definition city.h:317
bool happy
Definition city.h:445
struct tile * tile
Definition city.h:311
bool unhappy
Definition city.h:446
struct city::@17::@20 client
struct civ_game::@30::@34 server
struct packet_ruleset_control control
Definition game.h:83
struct packet_game_info info
Definition game.h:89
char rulesetdir[MAX_LEN_NAME]
Definition game.h:236
int num_iterate_outwards_indices
Definition map_types.h:76
struct iter_index * iterate_outwards_indices
Definition map_types.h:75
enum gui_type client_gui
Definition connection.h:184
int dist
Definition city.h:102
int dx
Definition city.h:102
int dy
Definition city.h:102
char name[MAX_LEN_NAME]
struct city_list * cities
Definition player.h:281
struct unit_list * units
Definition player.h:282
struct conn_list * connections
Definition player.h:298
struct player_economic economic
Definition player.h:284
struct player_slot * slot
Definition player.h:250
Definition tile.h:49
struct unit_list * units
Definition tile.h:57
Definition unit.h:138
struct unit_list * transporting
Definition unit.h:184
enum direction8 facing
Definition unit.h:142
struct unit * transporter
Definition unit.h:183
struct civ_map map
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:189
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:290
const char * advance_rule_name(const struct advance *padvance)
Definition tech.c:299
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
const char * terrain_name_translation(const struct terrain *pterrain)
Definition terrain.c:226
const char * terrain_rule_name(const struct terrain *pterrain)
Definition terrain.c:235
enum terrain_class terrain_type_terrain_class(const struct terrain *pterrain)
Definition terrain.c:570
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:87
#define tile_has_extra(ptile, pextra)
Definition tile.h:146
enum unit_upgrade_result unit_transform_result(const struct civ_map *nmap, const struct unit *punit, const struct unit_type *to_unittype)
Definition unit.c:1940
enum unit_upgrade_result unit_upgrade_test(const struct civ_map *nmap, const struct unit *punit, bool is_free)
Definition unit.c:1972
#define unit_tile(_pu)
Definition unit.h:395
unit_upgrade_result
Definition unit.h:60
@ UU_NO_MONEY
Definition unit.h:63
@ UU_NOT_IN_CITY
Definition unit.h:64
@ UU_NO_UNITTYPE
Definition unit.h:62
@ UU_NOT_TERRAIN
Definition unit.h:67
@ UU_UNSUITABLE_TRANSPORT
Definition unit.h:68
@ UU_NOT_CITY_OWNER
Definition unit.h:65
@ UU_NOT_ENOUGH_ROOM
Definition unit.h:66
@ UU_OK
Definition unit.h:61
@ UU_NOT_ACTIVITY
Definition unit.h:69
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:430
bool utype_has_role(const struct unit_type *punittype, int role)
Definition unittype.c:193
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1755
bool can_player_build_unit_direct(const struct player *p, const struct unit_type *punittype)
Definition unittype.c:2015
const char * utype_rule_name(const struct unit_type *punittype)
Definition unittype.c:1630
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1612
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:604