Freeciv-3.2
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/**********************************************************************/
56
57/**********************************************************************/
66
67/**********************************************************************/
76
77/**********************************************************************/
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/**********************************************************************/
108{
109 return game.server.rulesetdir;
110}
111
112/**********************************************************************/
116{
117 return game.control.name;
118}
119
120/**********************************************************************/
127
128/**********************************************************************/
135
136/**********************************************************************/
147
148/**********************************************************************/
159
160/**********************************************************************/
171
172/**********************************************************************/
183
184/**********************************************************************/
195
196/**********************************************************************/
199const char
208
209/**********************************************************************/
213 Building_Type *building)
214{
218
219 return city_has_building(pcity, building);
220}
221
222/**********************************************************************/
226{
228 LUASCRIPT_CHECK_SELF(L, pcity, 0);
229
230 return city_map_radius_sq_get(pcity);
231}
232
233/**********************************************************************/
237{
239 LUASCRIPT_CHECK_SELF(L, pcity, 1);
240
241 return city_size_get(pcity);
242}
243
244/**********************************************************************/
248{
250 LUASCRIPT_CHECK_SELF(L, pcity, NULL);
251
252 return pcity->tile;
253}
254
255/**********************************************************************/
260{
261 bool inspired = FALSE;
262
264 if (self->original == inspirer) {
265 inspired = TRUE;
266 }
267 } else {
269 if (is_server()) {
271 citizens total = city_size_get(self);
272
273 if (total > 0 && (own * 100 / total) >= game.info.citizen_partisans_pct) {
274 inspired = TRUE;
275 }
276 }
277 /* else is_client() -> don't consider inspired by default. */
278 } else if (self->original == inspirer) {
279 inspired = TRUE;
280 }
281 }
282
283 if (inspired) {
284 /* Cannot use get_city_bonus() as it would use city's current owner
285 * instead of inspirer. */
287 &(const struct req_context) {
288 .player = inspirer,
289 .city = self,
290 .tile = city_tile(self),
291 },
293 }
294
295 return 0;
296}
297
298/**********************************************************************/
302{
304 LUASCRIPT_CHECK_SELF(L, pcity, 0);
305
306 return city_culture(pcity);
307}
308
309/**********************************************************************/
313{
315
316 return counter_rule_name(c);
317}
318
319/**********************************************************************/
328
329/**********************************************************************/
338
339/**********************************************************************/
343{
346
347 /* Note: if clients ever have virtual cities or sth, needs amending */
348 return is_server() ? city_happy(pcity) : pcity->client.happy;
349}
350
351/**********************************************************************/
355{
358
359 /* Note: if clients ever have virtual cities or sth, needs amending */
360 return is_server() ? city_unhappy(pcity) : pcity->client.unhappy;
361}
362
363/**********************************************************************/
367{
370
371 return city_celebrating(pcity);
372}
373
374/**********************************************************************/
378{
381
382 return is_gov_center(pcity);
383}
384
385/**********************************************************************/
389{
392
393 return is_capital(pcity);
394}
395
396/**********************************************************************/
400{
403
404 return pcity->capital == CAPITAL_PRIMARY;
405}
406
407/**********************************************************************/
418
419/**********************************************************************/
430
431/**********************************************************************/
435 Nation_Type *pnation)
436{
438 LUASCRIPT_CHECK_SELF(L, pnation, NULL);
439
440 return nation_rule_name(pnation);
441}
442
443/**********************************************************************/
447 Nation_Type *pnation)
448{
450 LUASCRIPT_CHECK_SELF(L, pnation, NULL);
451
452 return nation_adjective_translation(pnation);
453}
454
455/**********************************************************************/
459 Nation_Type *pnation)
460{
462 LUASCRIPT_CHECK_SELF(L, pnation, NULL);
463
464 return nation_plural_translation(pnation);
465}
466
467/**********************************************************************/
471 Player *pplayer)
472{
473 struct connection *conn = NULL;
474
476 LUASCRIPT_CHECK_SELF(L, pplayer, NULL);
477
479 if (!pconn->observer) {
480 conn = pconn;
481 break;
482 }
484
485 if (conn == NULL) {
486 return "None";
487 }
488
489 return gui_type_name(conn->client_gui);
490}
491
492/**********************************************************************/
496 Building_Type *building)
497{
499 LUASCRIPT_CHECK_SELF(L, pplayer, FALSE);
501
502 return wonder_is_built(pplayer, building);
503}
504
505/**********************************************************************/
509{
511 LUASCRIPT_CHECK_SELF(L, pplayer, -1);
512
513 return player_number(pplayer);
514}
515
516/**********************************************************************/
520{
522 LUASCRIPT_CHECK_SELF(L, pplayer, 0);
523
524 return city_list_size(pplayer->cities);
525}
526
527/**********************************************************************/
531{
533 LUASCRIPT_CHECK_SELF(L, pplayer, 0);
534
535 return unit_list_size(pplayer->units);
536}
537
538/**********************************************************************/
542{
544 LUASCRIPT_CHECK_SELF(L, pplayer, 0);
545
546 return pplayer->economic.gold;
547}
548
549/**********************************************************************/
553{
555 LUASCRIPT_CHECK_SELF(L, pplayer, 0);
556
557 return pplayer->economic.infra_points;
558}
559
560/**********************************************************************/
573
574/**********************************************************************/
589
590/**********************************************************************/
604{
607
608 if (!pplayer && TECH_COST_CIV1CIV2 == game.info.tech_cost_style) {
609 /* Avoid getting error messages and return at least something */
610 return ptech->cost * (double) game.info.sciencebox / 100.0;
611 }
612 return
615}
616
617/**********************************************************************/
627{
628 const struct research *presearch;
629 int rr;
630
632 LUASCRIPT_CHECK_SELF(L, pplayer, 0);
633 presearch = research_get(pplayer);
634 LUASCRIPT_CHECK(L, presearch, "player's research not set", 0);
635
636 rr = presearch->researching;
637
638 switch (rr) {
639 case A_FUTURE:
641 break;
642 case A_UNSET:
643 case A_UNKNOWN:
644 lua_pushnil(L);
645 break;
646 default:
647 /* A regular tech */
648 fc_assert(rr >= A_FIRST && rr <= A_LAST);
650 }
651
652 return lua_gettop(L);
653}
654
655/**********************************************************************/
661{
662 const struct research *presearch;
663
665 LUASCRIPT_CHECK_SELF(L, pplayer, 0);
666 presearch = research_get(pplayer);
667 LUASCRIPT_CHECK(L, presearch, "player's research not set", 0);
668
669 return presearch->bulbs_researched;
670}
671
672/**********************************************************************/
678{
679 const struct research *presearch;
680
682 LUASCRIPT_CHECK_SELF(L, pplayer, 0);
683 presearch = research_get(pplayer);
684 LUASCRIPT_CHECK(L, presearch, "player's research not set", 0);
685
686 return is_server()
688 : presearch->client.researching_cost;
689}
690
691/**********************************************************************/
697{
698 const struct research *presearch;
699
701 LUASCRIPT_CHECK_SELF(L, pplayer, 0);
702 presearch = research_get(pplayer);
703 LUASCRIPT_CHECK(L, presearch, "player's research not set", 0);
704
705 return presearch->future_tech;
706}
707
708/**********************************************************************/
712{
714 LUASCRIPT_CHECK_SELF(L, pplayer, 0);
715
716 return player_culture(pplayer);
717}
718
719/**********************************************************************/
723 const char *flag)
724{
726
728 LUASCRIPT_CHECK_SELF(L, pplayer, 0);
729
731
733 return player_has_flag(pplayer, flag_val);
734 }
735
736 return FALSE;
737}
738
739/**********************************************************************/
744 Unit_Type *utype)
745{
747 LUASCRIPT_CHECK_SELF(L, pplayer, NULL);
749
750 return (Unit_Type *)can_upgrade_unittype(pplayer, utype);
751}
752
753/**********************************************************************/
758 Unit_Type *utype)
759{
761 LUASCRIPT_CHECK_SELF(L, pplayer, FALSE);
763
764 return can_player_build_unit_direct(pplayer, utype, TRUE);
765}
766
767/**********************************************************************/
779
780/**********************************************************************/
790
791/**********************************************************************/
800
801/**********************************************************************/
807{
809
813
815 switch (uu) {
816 case UU_OK:
817 return NULL;
819 return "cargo";
821 return "transport";
822 case UU_NOT_TERRAIN:
823 return "terrain";
824 case UU_NOT_ACTIVITY:
825 return "activity";
826 case UU_NO_UNITTYPE:
827 case UU_NO_MONEY:
828 case UU_NOT_IN_CITY:
830 /* should not get here */
831 break;
832 }
833
834 fc_assert_msg(FALSE, "Unexpected unit transform result %i", uu);
835
836 return "\?";
837}
838
839/**********************************************************************/
850
851/**********************************************************************/
863
864/**********************************************************************/
868{
870 LUASCRIPT_CHECK_SELF(L, pplayer, NULL);
871
872 return research_rule_name(research_get(pplayer));
873}
874
875/**********************************************************************/
879 Player *pplayer)
880{
881 static char buf[MAX_LEN_MSG];
882
884 LUASCRIPT_CHECK_SELF(L, pplayer, NULL);
885
887
888 return buf;
889}
890
891/**********************************************************************/
896{
897 lua_Object result = 0;
898 int i = 0;
899
902 result = lua_gettop(L);
903 players_iterate(pplayer) {
904 tolua_pushfieldusertype(L, result, ++i, pplayer, "Player");
906 return result;
907}
908
909/**********************************************************************/
919
920/**********************************************************************/
931
932/**********************************************************************/
942
943/**********************************************************************/
954
955/**********************************************************************/
959{
961 LUASCRIPT_CHECK_SELF(L, pterrain, NULL);
962
963 return terrain_rule_name(pterrain);
964}
965
966/**********************************************************************/
970 Terrain *pterrain)
971{
973 LUASCRIPT_CHECK_SELF(L, pterrain, NULL);
974
975 return terrain_name_translation(pterrain);
976}
977
978/**********************************************************************/
982{
984 LUASCRIPT_CHECK_SELF(L, pterrain, NULL);
985
987}
988
989/**********************************************************************/
999
1000/**********************************************************************/
1011
1012/**********************************************************************/
1023
1024/**********************************************************************/
1035
1036/**********************************************************************/
1046
1047/**********************************************************************/
1057
1058/**********************************************************************/
1062{
1063 struct action *paction;
1064
1067
1069 fc_assert_ret_val(paction, "error: no action");
1070
1072}
1073
1074/**********************************************************************/
1078{
1080 LUASCRIPT_CHECK_SELF(L, ptile, -1);
1081
1082 return index_to_native_pos_x(tile_index(ptile));
1083}
1084
1085/**********************************************************************/
1089{
1091 LUASCRIPT_CHECK_SELF(L, ptile, -1);
1092
1093 return index_to_native_pos_y(tile_index(ptile));
1094}
1095
1096/**********************************************************************/
1100{
1102 LUASCRIPT_CHECK_SELF(L, ptile, -1);
1103
1104 return index_to_map_pos_x(tile_index(ptile));
1105}
1106
1107/**********************************************************************/
1111{
1113 LUASCRIPT_CHECK_SELF(L, ptile, -1);
1114
1115 return index_to_map_pos_y(tile_index(ptile));
1116}
1117
1118/**********************************************************************/
1122{
1124 LUASCRIPT_CHECK_SELF(L, ptile, NULL);
1125
1126 return tile_city(ptile);
1127}
1128
1129/**********************************************************************/
1141
1142/**********************************************************************/
1147 const char *name)
1148{
1150 LUASCRIPT_CHECK_SELF(L, ptile, FALSE);
1151
1152 if (!name) {
1153 extra_type_iterate(pextra) {
1154 if (tile_has_extra(ptile, pextra)) {
1155 return TRUE;
1156 }
1158
1159 return FALSE;
1160 } else {
1161 struct extra_type *pextra;
1162
1163 pextra = extra_type_by_rule_name(name);
1164
1165 return (NULL != pextra && tile_has_extra(ptile, pextra));
1166 }
1167}
1168
1169/**********************************************************************/
1173bool api_methods_tile_has_base(lua_State *L, Tile *ptile, const char *name)
1174{
1176 LUASCRIPT_CHECK_SELF(L, ptile, FALSE);
1177
1178 if (!name) {
1180 if (tile_has_extra(ptile, pextra)) {
1181 return TRUE;
1182 }
1184
1185 return FALSE;
1186 } else {
1187 struct extra_type *pextra;
1188
1189 pextra = extra_type_by_rule_name(name);
1190
1191 return (NULL != pextra && is_extra_caused_by(pextra, EC_BASE)
1192 && tile_has_extra(ptile, pextra));
1193 }
1194}
1195
1196/**********************************************************************/
1200bool api_methods_tile_has_road(lua_State *L, Tile *ptile, const char *name)
1201{
1203 LUASCRIPT_CHECK_SELF(L, ptile, FALSE);
1204
1205 if (!name) {
1207 if (tile_has_extra(ptile, pextra)) {
1208 return TRUE;
1209 }
1211
1212 return FALSE;
1213 } else {
1214 struct extra_type *pextra;
1215
1216 pextra = extra_type_by_rule_name(name);
1217
1218 return (NULL != pextra && is_extra_caused_by(pextra, EC_ROAD)
1219 && tile_has_extra(ptile, pextra));
1220 }
1221}
1222
1223/**********************************************************************/
1230 Tile *ptile, const char *extra_name)
1231{
1233 LUASCRIPT_CHECK_SELF(L, ptile, NULL);
1234
1235 if (extra_name) {
1236 struct extra_type *pextra;
1237
1239 LUASCRIPT_CHECK_ARG(L, pextra != NULL, 3, "unknown extra type", NULL);
1240
1241 if (tile_has_extra(ptile, pextra)) {
1242 /* All extras have the same owner. */
1243 return extra_owner(ptile);
1244 } else {
1245 /* The extra isn't there. */
1246 return NULL;
1247 }
1248 } else {
1249 extra_type_iterate(pextra) {
1250 if (tile_has_extra(ptile, pextra)) {
1251 /* All extras have the same owner. */
1252 return extra_owner(ptile);
1253 }
1255 return NULL;
1256 }
1257}
1258
1259/**********************************************************************/
1263{
1264 struct city *pcity;
1265
1267 LUASCRIPT_CHECK_SELF(L, ptile, FALSE);
1268
1269 if (is_non_allied_unit_tile(ptile, against)) {
1270 return TRUE;
1271 }
1272
1273 pcity = tile_city(ptile);
1274 if (pcity != NULL && !pplayers_allied(against, city_owner(pcity))) {
1275 return TRUE;
1276 }
1277
1278 return FALSE;
1279}
1280
1281/**********************************************************************/
1285{
1287 LUASCRIPT_CHECK_SELF(L, ptile, 0);
1288
1289 return unit_list_size(ptile->units);
1290}
1291
1292/**********************************************************************/
1303
1304/**********************************************************************/
1309 int tindex, int max_dist)
1310{
1311 int dx, dy;
1312 int newx, newy;
1313 int startx, starty;
1314
1317
1318 if (tindex < 0) {
1319 return 0;
1320 }
1321
1323
1324 tindex++;
1325 while (tindex < wld.map.num_iterate_outwards_indices) {
1327 return -1;
1328 }
1329 dx = wld.map.iterate_outwards_indices[tindex].dx;
1330 dy = wld.map.iterate_outwards_indices[tindex].dy;
1331 newx = dx + startx;
1332 newy = dy + starty;
1333 if (!normalize_map_pos(&(wld.map), &newx, &newy)) {
1334 tindex++;
1335 continue;
1336 }
1337
1338 return tindex;
1339 }
1340
1341 return -1;
1342}
1343
1344/**********************************************************************/
1348 Tile *pstart, int tindex)
1349{
1350 int newx, newy;
1351
1355 tindex >= 0 && tindex < wld.map.num_iterate_outwards_indices,
1356 3, "index out of bounds", NULL);
1357
1361
1362 if (!normalize_map_pos(&(wld.map), &newx, &newy)) {
1363 return NULL;
1364 }
1365
1366 return map_pos_to_tile(&(wld.map), newx, newy);
1367}
1368
1369/**********************************************************************/
1380
1381/**********************************************************************/
1397
1398/**********************************************************************/
1408
1409/**********************************************************************/
1420
1421/**********************************************************************/
1432
1433/**********************************************************************/
1444
1445/**********************************************************************/
1455
1456/**********************************************************************/
1467
1468/**********************************************************************/
1472 const char *flag)
1473{
1474 enum unit_type_flag_id id;
1475
1478 LUASCRIPT_CHECK_ARG_NIL(L, flag, 3, string, FALSE);
1479
1482 return utype_has_flag(punit_type, id);
1483 } else {
1484 luascript_error(L, "Unit type flag \"%s\" does not exist", flag);
1485 return FALSE;
1486 }
1487}
1488
1489/**********************************************************************/
1493 const char *role)
1494{
1495 enum unit_role_id id;
1496
1499 LUASCRIPT_CHECK_ARG_NIL(L, role, 3, string, FALSE);
1500
1502 if (unit_role_id_is_valid(id)) {
1503 return utype_has_role(punit_type, id);
1504 } else {
1505 luascript_error(L, "Unit role \"%s\" does not exist", role);
1506 return FALSE;
1507 }
1508}
1509
1510/**********************************************************************/
1523
1524/**********************************************************************/
1535
1536/**********************************************************************/
1547
1548
1549/**********************************************************************/
1559
1560/**********************************************************************/
1570
1571/**********************************************************************/
1581
1582/**********************************************************************/
1592
1593/**********************************************************************/
1597{
1599 LUASCRIPT_CHECK_SELF(L, ptile, NULL);
1600
1601 return tile_link(ptile);
1602}
1603
1604/**********************************************************************/
1614
1615/**********************************************************************/
1619{
1621 LUASCRIPT_CHECK_SELF(L, pcity, NULL);
1622
1623 return city_tile_link(pcity);
1624}
1625
1626/**********************************************************************/
1630{
1633
1634 return unit_link(punit);
1635}
1636
1637/**********************************************************************/
1641{
1643 LUASCRIPT_CHECK_SELF(L, pcity, NULL);
1644
1645 return city_link(pcity);
1646}
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:2011
const char * action_id_rule_name(action_id act_id)
Definition actions.c:2000
enum action_target_kind action_get_target_kind(const struct action *paction)
Definition actions.c:1869
static struct action * action_by_number(action_id act_id)
Definition actions.h:635
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)
int api_methods_player_future(lua_State *L, Player *pplayer)
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_player_tech_cost(lua_State *L, Player *pplayer, Tech_Type *ptech)
lua_Object api_methods_player_researching(lua_State *L, Player *pplayer)
int api_methods_game_year_fragment(lua_State *L)
const char * api_methods_counter_name_translation(lua_State *L, Counter *c)
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)
bool api_methods_unit_seen(lua_State *L, Unit *self, Player *watcher)
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)
const char * api_methods_counter_rule_name(lua_State *L, Counter *c)
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)
int api_methods_player_infrapoints(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)
const char * api_methods_tech_cost_style(lua_State *L)
City * api_methods_tile_city(lua_State *L, Tile *ptile)
const char * api_methods_tech_leakage_style(lua_State *L)
const char * api_methods_government_name_translation(lua_State *L, Government *pgovernment)
bool api_method_player_can_research(lua_State *L, Player *pplayer, Tech_Type *ptech)
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)
int api_methods_player_bulbs(lua_State *L, Player *pplayer)
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)
bool api_methods_tile_seen(lua_State *L, Tile *self, Player *watcher)
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)
bool api_methods_tile_known(lua_State *L, Tile *self, Player *watcher)
const char * api_methods_research_rule_name(lua_State *L, Player *pplayer)
bool api_methods_is_primary_capital(lua_State *L, City *pcity)
City * api_methods_player_primary_capital(lua_State *L, Player *pplayer)
int api_methods_player_research_cost(lua_State *L, Player *pplayer)
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)
int api_methods_counter_city_get(lua_State *L, Counter *c, City *city)
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:1240
bool is_capital(const struct city *pcity)
Definition city.c:1579
bool city_unhappy(const struct city *pcity)
Definition city.c:1626
bool city_celebrating(const struct city *pcity)
Definition city.c:1645
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:1487
bool city_happy(const struct city *pcity)
Definition city.c:1614
int city_map_radius_sq_get(const struct city *pcity)
Definition city.c:137
bool is_gov_center(const struct city *pcity)
Definition city.c:1587
bool city_exists_within_max_city_map(const struct civ_map *nmap, const struct tile *ptile, bool may_be_on_center)
Definition city.c:2112
#define city_tile(_pcity_)
Definition city.h:564
static citizens city_size_get(const struct city *pcity)
Definition city.h:569
#define city_owner(_pcity_)
Definition city.h:563
static struct ai_type * self
Definition classicai.c:45
char * incite_cost
Definition comments.c:75
#define MAX_LEN_MSG
Definition conn_types.h:37
#define conn_list_iterate(connlist, pconn)
Definition connection.h:108
#define conn_list_iterate_end
Definition connection.h:110
int counter_index(const struct counter *pcount)
Definition counters.c:174
const char * counter_name_translation(const struct counter *counter)
Definition counters.c:157
const char * counter_rule_name(struct counter *pcount)
Definition counters.c:165
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:74
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:748
struct extra_type * extra_type_by_rule_name(const char *name)
Definition extras.c:212
struct player * extra_owner(const struct tile *ptile)
Definition extras.c:1114
#define extra_type_iterate(_p)
Definition extras.h:315
#define extra_type_iterate_end
Definition extras.h:321
#define is_extra_caused_by(e, c)
Definition extras.h:203
#define extra_type_by_cause_iterate_end
Definition extras.h:339
#define extra_type_by_cause_iterate(_cause, _extra)
Definition extras.h:333
static bool is_server(void)
unsigned char citizens
Definition fc_types.h:388
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:62
struct world wld
Definition game.c:63
const char * government_name_translation(const struct government *pgovern)
Definition government.c:143
const char * government_rule_name(const struct government *pgovern)
Definition government.c:133
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(condition)
Definition log.h:176
#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
#define LUASCRIPT_CHECK(L, check, 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)
Definition map.c:641
struct tile * map_pos_to_tile(const struct civ_map *nmap, int map_x, int map_y)
Definition map.c:419
bool normalize_map_pos(const struct civ_map *nmap, int *x, int *y)
Definition map.c:979
#define index_to_native_pos_y(mindex)
Definition map.h:162
static int index_to_map_pos_y(int mindex)
Definition map.h:724
static int index_to_map_pos_x(int mindex)
Definition map.h:715
#define index_to_native_pos_x(mindex)
Definition map.h:160
#define index_to_map_pos(pmap_x, pmap_y, mindex)
Definition map.h:233
bool can_exist_at_tile(const struct civ_map *nmap, const struct unit_type *utype, const struct tile *ptile)
Definition movement.c:290
const char * nation_rule_name(const struct nation_type *pnation)
Definition nation.c:138
const char * nation_adjective_translation(const struct nation_type *pnation)
Definition nation.c:149
const char * nation_plural_translation(const struct nation_type *pnation)
Definition nation.c:159
int player_count(void)
Definition player.c:817
int player_number(const struct player *pplayer)
Definition player.c:837
bool can_player_see_unit(const struct player *pplayer, const struct unit *punit)
Definition player.c:1104
bool player_has_flag(const struct player *pplayer, enum plr_flag_id flag)
Definition player.c:1990
struct city * player_primary_capital(const struct player *pplayer)
Definition player.c:1337
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1405
#define players_iterate_end
Definition player.h:537
#define players_iterate(_pplayer)
Definition player.h:532
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:273
int research_total_bulbs_required(const struct research *presearch, Tech_type_id tech, bool loss_value)
Definition research.c:868
const char * research_rule_name(const struct research *presearch)
Definition research.c:143
struct research * research_get(const struct player *pplayer)
Definition research.c:128
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
int research_pretty_name(const struct research *presearch, char *buf, size_t buf_len)
Definition research.c:169
#define ARRAY_SIZE(x)
Definition shared.h:85
Definition city.h:320
int * counter_values
Definition city.h:408
enum capital_type capital
Definition city.h:328
bool happy
Definition city.h:462
struct tile * tile
Definition city.h:322
bool unhappy
Definition city.h:463
struct city::@17::@20 client
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:242
struct civ_game::@31::@35 server
int num_iterate_outwards_indices
Definition map_types.h:77
struct iter_index * iterate_outwards_indices
Definition map_types.h:76
enum gui_type client_gui
Definition connection.h:179
int dist
Definition city.h:110
int dx
Definition city.h:110
int dy
Definition city.h:110
enum tech_leakage_style tech_leakage
enum tech_cost_style tech_cost_style
char name[MAX_LEN_NAME]
int infra_points
Definition player.h:65
struct city_list * cities
Definition player.h:279
struct unit_list * units
Definition player.h:280
struct conn_list * connections
Definition player.h:296
struct player_economic economic
Definition player.h:282
Definition tile.h:50
struct unit_list * units
Definition tile.h:58
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
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:107
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_index(const struct advance *padvance)
Definition tech.c:89
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
#define A_FUTURE
Definition tech.h:46
#define A_FIRST
Definition tech.h:44
#define A_UNSET
Definition tech.h:48
#define A_UNKNOWN
Definition tech.h:49
#define A_LAST
Definition tech.h:45
const char * terrain_name_translation(const struct terrain *pterrain)
Definition terrain.c:238
const char * terrain_rule_name(const struct terrain *pterrain)
Definition terrain.c:247
enum terrain_class terrain_type_terrain_class(const struct terrain *pterrain)
Definition terrain.c:582
enum known_type tile_get_known(const struct tile *ptile, const struct player *pplayer)
Definition tile.c:392
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:88
@ TILE_UNKNOWN
Definition tile.h:36
@ TILE_KNOWN_SEEN
Definition tile.h:38
#define tile_has_extra(ptile, pextra)
Definition tile.h:147
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:1956
enum unit_upgrade_result unit_upgrade_test(const struct civ_map *nmap, const struct unit *punit, bool is_free)
Definition unit.c:1988
#define unit_tile(_pu)
Definition unit.h:397
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:432
bool can_player_build_unit_direct(const struct player *p, const struct unit_type *punittype, bool consider_reg_impr_req)
Definition unittype.c:1968
bool utype_has_role(const struct unit_type *punittype, int role)
Definition unittype.c:199
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1703
const char * utype_rule_name(const struct unit_type *punittype)
Definition unittype.c:1578
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1560
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:617