Freeciv-3.4
Loading...
Searching...
No Matches
api_server_edit.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 "rand.h"
20
21/* common */
22#include "citizens.h"
23#include "map.h"
24#include "movement.h"
25#include "research.h"
26#include "unittype.h"
27
28/* common/scriptcore */
29#include "api_game_find.h"
30#include "luascript.h"
31
32/* server */
33#include "aiiface.h"
34#include "barbarian.h"
35#include "citytools.h"
36#include "cityturn.h" /* city_refresh() auto_arrange_workers() */
37#include "console.h" /* enum rfc_status */
38#include "gamehand.h"
39#include "maphand.h"
40#include "notify.h"
41#include "plrhand.h"
42#include "srv_main.h" /* game_was_started() */
43#include "stdinhand.h"
44#include "techtools.h"
45#include "unithand.h"
46#include "unittools.h"
47
48/* server/scripting */
49#include "script_server.h"
50
51/* server/generator */
52#include "mapgen_utils.h"
53
54#include "api_server_edit.h"
55
56
57/**********************************************************************/
67
68/**********************************************************************/
72static bool
74 int vet_loss)
75{
77 /* Avoid getting overt veteranship if a user requests increasing it */
78 if (vet_loss < 0) {
80
81 vl = punit->veteran - vl + 1;
82 if (vl >= 0) {
83 vet_loss = 0;
84 } else {
86 }
87 }
89
90 return TRUE;
91 } else {
92 return FALSE;
93 }
94}
95
96/**********************************************************************/
100 int count, int sq_radius)
101{
103 LUASCRIPT_CHECK_ARG_NIL(L, ptile, 2, Tile);
104 LUASCRIPT_CHECK_ARG_NIL(L, pplayer, 3, Player);
105 LUASCRIPT_CHECK_ARG(L, 0 <= sq_radius, 5, "radius must be positive");
107 "no partisans in ruleset");
108
109 return place_partisans(ptile, pplayer, count, sq_radius);
110}
111
112/**********************************************************************/
117 City *homecity, int moves_left)
118{
119 return api_edit_create_unit_full(L, pplayer, ptile, ptype, veteran_level,
120 homecity, moves_left, -1, nullptr);
121}
122
123/**********************************************************************/
127 Tile *ptile,
129 City *homecity, int moves_left,
130 int hp_left,
132{
133 struct fc_lua *fcl;
134 struct city *pcity;
135 struct unit *punit;
136#ifndef FREECIV_NDEBUG
137 bool placed;
138#endif
139
140 LUASCRIPT_CHECK_STATE(L, nullptr);
141 LUASCRIPT_CHECK_ARG_NIL(L, pplayer, 2, Player, nullptr);
142 LUASCRIPT_CHECK_ARG_NIL(L, ptile, 3, Tile, nullptr);
143
145
146 LUASCRIPT_CHECK(L, fcl != nullptr, "Undefined Freeciv lua state!", nullptr);
147
148 if (ptype == nullptr
150 return nullptr;
151 }
152
153 if (is_non_allied_unit_tile(ptile, pplayer,
155 luascript_log(fcl, LOG_ERROR, "create_unit_full: tile is occupied by "
156 "enemy unit");
157 return nullptr;
158 }
159
160 pcity = tile_city(ptile);
161 if (pcity != nullptr && !pplayers_allied(pplayer, city_owner(pcity))) {
162 luascript_log(fcl, LOG_ERROR, "create_unit_full: tile is occupied by "
163 "enemy city");
164 return nullptr;
165 }
166
169 "create_unit_full: player already has unique unit");
170 return nullptr;
171 }
172
174 homecity ? homecity->id : 0,
176 if (ptransport) {
177 /* The unit maybe can't freely load into the transport
178 * but must be able to be in it, see can_unit_load() */
179 int ret = same_pos(ptile, unit_tile(ptransport))
181
182 if (!ret) {
184 luascript_log(fcl, LOG_ERROR, "create_unit_full: '%s' cannot transport "
185 "'%s' here",
188 return nullptr;
189 }
190 } else if (!can_exist_at_tile(&(wld.map), ptype, ptile)) {
192 luascript_log(fcl, LOG_ERROR, "create_unit_full: '%s' cannot exist at "
193 "tile", utype_rule_name(ptype));
194 return nullptr;
195 }
196
197#ifndef FREECIV_NDEBUG
198 placed =
199#endif
202
203 return punit;
204}
205
206/**********************************************************************/
211 bool conquer_city, bool conquer_extra,
212 bool enter_hut, bool frighten_hut)
213{
214 bool alive;
215
219
221 "Can't both enter and frighten a hut at the same time",
222 TRUE);
223
225 /* Can't leave the transport. */
226 return TRUE;
227 }
228
230 unit_tile(punit), dest, FALSE,
231 embark_to, TRUE) != MR_OK) {
232 /* Can't teleport to target. Return that unit is still alive. */
233 return TRUE;
234 }
235
236 /* Teleport first so destination is revealed even if unit dies */
237 alive = unit_move(punit, dest, 0,
238 embark_to, embark_to != nullptr,
241 if (alive) {
242 struct player *owner = unit_owner(punit);
243 struct city *pcity = tile_city(dest);
244
245 if (!can_unit_exist_at_tile(&(wld.map), punit, dest)
246 && !unit_transported(punit)) {
248 return FALSE;
249 }
252 || (pcity != nullptr
255 return FALSE;
256 }
257 }
258
259 return alive;
260}
261
262/***********************************************************************/
266 Action *paction, City *tgt)
267{
272 "Not a unit-performed action", FALSE);
274 "Not a city-targeted action", FALSE);
276
280 tgt->id, IDENTITY_NUMBER_ZERO, "",
282 } else {
283 /* Action not enabled */
284 return FALSE;
285 }
286}
287
288/***********************************************************************/
292 Action *paction, City *tgt,
294{
299 "Not a unit-performed action", FALSE);
301 "Not a city-targeted action", FALSE);
304
308 tgt->id, sub_tgt->item_number, "",
310 } else {
311 /* Action not enabled */
312 return FALSE;
313 }
314}
315
316/***********************************************************************/
320 Action *paction, City *tgt,
322{
327 "Not a unit-performed action", FALSE);
329 "Not a city-targeted action", FALSE);
332
336 tgt->id, sub_tgt->item_number, "",
338 } else {
339 /* Action not enabled */
340 return FALSE;
341 }
342}
343
344/***********************************************************************/
348 Action *paction, Unit *tgt)
349{
350 const struct civ_map *nmap = &(wld.map);
351
356 "Not a unit-performed action", FALSE);
358 "Not a unit-targeted action", FALSE);
360
364 tgt->id, IDENTITY_NUMBER_ZERO, "",
366 } else {
367 /* Action not enabled */
368 return FALSE;
369 }
370}
371
372/***********************************************************************/
376 Action *paction, Tile *tgt)
377{
378 bool enabled = FALSE;
379 const struct civ_map *nmap = &(wld.map);
380
385 "Not a unit-performed action", FALSE);
387
389 case ATK_STACK:
391 break;
392 case ATK_TILE:
394 tgt, nullptr);
395 break;
396 case ATK_EXTRAS:
398 tgt, nullptr);
399 break;
400 case ATK_CITY:
401 /* Not handled here. */
403 "City-targeted action applied to tile", FALSE);
404 break;
405 case ATK_UNIT:
406 /* Not handled here. */
408 "Unit-targeted action applied to tile", FALSE);
409 break;
410 case ATK_SELF:
411 /* Not handled here. */
413 "Self-targeted action applied to tile", FALSE);
414 break;
415 case ATK_COUNT:
416 /* Should not exist */
418 break;
419 }
420
421 if (enabled) {
426 } else {
427 /* Action not enabled */
428 return FALSE;
429 }
430}
431
432/***********************************************************************/
436 Action *paction, Tile *tgt,
437 const char *sub_tgt)
438{
439 struct extra_type *sub_target;
440 bool enabled = FALSE;
441 const struct civ_map *nmap = &(wld.map);
442
447 "Not a unit-performed action", FALSE);
450
451 sub_target = extra_type_by_rule_name(sub_tgt);
452 LUASCRIPT_CHECK_ARG(L, sub_target != nullptr, 5, "No such extra", FALSE);
453
455 case ATK_STACK:
457 break;
458 case ATK_TILE:
460 tgt, sub_target);
461 break;
462 case ATK_EXTRAS:
464 tgt, sub_target);
465 break;
466 case ATK_CITY:
467 /* Not handled here. */
469 "City-targeted action applied to tile", FALSE);
470 break;
471 case ATK_UNIT:
472 /* Not handled here. */
474 "Unit-targeted action applied to tile", FALSE);
475 break;
476 case ATK_SELF:
477 /* Not handled here. */
479 "Self-targeted action applied to tile", FALSE);
480 break;
481 case ATK_COUNT:
482 /* Should not exist */
484 break;
485 }
486
487 if (enabled) {
489 tile_index(tgt), sub_target->id,
492 } else {
493 /* Action not enabled */
494 return FALSE;
495 }
496}
497
498/***********************************************************************/
503{
504 const struct civ_map *nmap = &(wld.map);
505
510 "Not a unit-performed action", FALSE);
512 "Not a self-targeted action", FALSE);
517 "",
519 } else {
520 /* Action not enabled */
521 return FALSE;
522 }
523}
524
525/**********************************************************************/
529{
532
533 if (direction8_is_valid(dir)) {
534 punit->facing = dir;
535
536 send_unit_info(nullptr, punit);
537 } else {
538 log_error("Illegal direction %d for unit from lua script", dir);
539 }
540}
541
542/**********************************************************************/
559
560/**********************************************************************/
573
574/**********************************************************************/
593
594/**********************************************************************/
598 const char *reason, Player *killer)
599{
602
603 self->hp += change;
604
605 if (self->hp <= 0) {
608
610
611 /* Intentionally only after wiping, so that unit is never left with
612 * zero or less hit points. */
614 "Invalid unit loss reason", FALSE);
615
616 return FALSE;
617 } else {
618 int max = unit_type_get(self)->hp;
619
620 if (self->hp > max) {
621 self->hp = max;
622 }
623 }
624
625 send_unit_info(nullptr, self);
626
627 return TRUE;
628}
629
630/**********************************************************************/
634{
635 bool was_exhausted = FALSE;
636
639
640 if (self->moves_left == 0 && self->done_moving) {
642 }
643
644 self->moves_left += change;
645
646 if (self->moves_left <= 0) {
647 self->moves_left = 0;
648 } else if (was_exhausted && !unit_has_orders(self)) {
649 /* Unit has regained ability to move. */
650 self->done_moving = FALSE;
651 }
652
653 send_unit_info(nullptr, self);
654}
655
656/**********************************************************************/
660{
661 struct terrain *old_terrain;
662
664 LUASCRIPT_CHECK_ARG_NIL(L, ptile, 2, Tile, FALSE);
666
667 old_terrain = tile_terrain(ptile);
668
669 if (old_terrain == pterr
671 && tile_city(ptile) != nullptr)) {
672 return FALSE;
673 }
674
679
680 /* FIXME: adv / ai phase handling like in check_terrain_change() */
681
682 send_all_known_tiles(nullptr);
683 }
684
686
688
689 return TRUE;
690}
691
692/**********************************************************************/
696 const char *name, Player *nationality)
697{
699 LUASCRIPT_CHECK_ARG_NIL(L, pplayer, 2, Player, FALSE);
700 LUASCRIPT_CHECK_ARG_NIL(L, ptile, 3, Tile, FALSE);
701
702 return create_city_for_player(pplayer, ptile, name, nationality);
703}
704
705/**********************************************************************/
715
716/**********************************************************************/
727
728/**********************************************************************/
732{
736 /* FIXME: may "Special" impr be buildable? */
738 "It is a special item, not a city building");
739
740 if (!city_has_building(pcity, impr)) {
741 bool need_game_info = FALSE;
742 bool need_plr_info = FALSE;
743 struct player *old_owner = nullptr, *pplayer = city_owner(pcity);
744 struct city *oldcity;
745
747 if (oldcity) {
749 }
750 if (old_owner && old_owner != pplayer) {
751 /* Great wonders make more changes. */
753 }
754
755 if (oldcity) {
756 if (city_refresh(oldcity)) {
758 }
759 send_city_info(nullptr, oldcity);
760 }
761
762 if (city_refresh(pcity)) {
764 }
765 send_city_info(nullptr, pcity);
766 if (need_game_info) {
767 send_game_info(nullptr);
769 }
770 if (need_plr_info) {
771 send_player_info_c(pplayer, nullptr);
772 }
773 }
774}
775
776/**********************************************************************/
780{
784
785 if (city_has_building(pcity, impr)) {
787 send_city_info(nullptr, pcity);
788
789 if (is_wonder(impr)) {
790 if (is_great_wonder(impr)) {
791 send_game_info(nullptr);
792 }
794 }
795 }
796}
797
798/**********************************************************************/
806 Specialist *s, int amount)
807{
809
813 LUASCRIPT_CHECK_ARG(L, amount >= 0, 3, "must be non-negative", FALSE);
814
815 from = specialist_index(s);
816 if (pcity->specialists[from] < amount) {
817 return FALSE;
818 }
819
820 if (is_super_specialist_id(from)) {
821 /* Just reduce superspecialists */
822 pcity->specialists[from] -= amount;
823 } else {
824 /* Toggle normal specialist */
825 Specialist_type_id to = from;
826
827 do {
828 to = (to + 1) % normal_specialist_count();
829 } while (to != from && !city_can_use_specialist(pcity, to));
830
831 if (to == from) {
832 /* We can use only the default specialist */
833 return FALSE;
834 } else {
835 /* City population must be correct */
836 fc_assert_ret_val_msg(pcity->specialists[to] <= amount - MAX_CITY_SIZE,
837 FALSE, "Wrong specialist number in %s",
839 pcity->specialists[from] -= amount;
840 pcity->specialists[to] += amount;
841 }
842 }
843
845 /* sanity_check_city(pcity); -- hopefully we don't break things here? */
847
848 return TRUE;
849}
850
851/**********************************************************************/
858 Specialist *s, int amount)
859{
861 int csize = 0;
862
866 LUASCRIPT_CHECK_ARG(L, amount >= 0, 3, "must be non-negative", FALSE);
867
869
871 /* Can't employ this one */
872 return FALSE;
873 }
874 if (is_super_specialist(s)) {
875 if (pcity->specialists[sid] > MAX_CITY_SIZE - amount) {
876 /* No place for the specialist */
877 return FALSE;
878 }
879 pcity->specialists[sid] += amount;
882 } else {
884
885 if (csize > MAX_CITY_SIZE - amount) {
886 /* No place for the specialist */
887 return FALSE;
888 }
891 send_city_info(nullptr, pcity);
892 }
893
894 return TRUE;
895}
896
897/**********************************************************************/
900Player *api_edit_create_player(lua_State *L, const char *username,
901 Nation_Type *pnation, const char *ai)
902{
903 struct player *pplayer = nullptr;
904 char buf[128] = "";
905 struct fc_lua *fcl;
906
907 LUASCRIPT_CHECK_STATE(L, nullptr);
908 LUASCRIPT_CHECK_ARG_NIL(L, username, 2, string, nullptr);
909
910 if (!ai) {
912 }
913
915
916 LUASCRIPT_CHECK(L, fcl != nullptr, "Undefined Freeciv lua state!", nullptr);
917
918 if (game_was_started()) {
919 create_command_newcomer(username, ai, FALSE, pnation, &pplayer,
920 buf, sizeof(buf));
921 } else {
922 create_command_pregame(username, ai, FALSE, &pplayer,
923 buf, sizeof(buf));
924 }
925
926 if (strlen(buf) > 0) {
928 }
929
930 return pplayer;
931}
932
933/**********************************************************************/
937{
939 LUASCRIPT_CHECK_ARG_NIL(L, pplayer, 2, Player);
940
941 pplayer->economic.gold = MAX(0, pplayer->economic.gold + amount);
942
943 send_player_info_c(pplayer, nullptr);
944}
945
946/**********************************************************************/
950{
952 LUASCRIPT_CHECK_ARG_NIL(L, pplayer, 2, Player);
953
954 pplayer->economic.infra_points
955 = MAX(0, pplayer->economic.infra_points + amount);
956
957 send_player_info_c(pplayer, nullptr);
958}
959
960/**********************************************************************/
967 Tech_Type *ptech, int cost,
968 bool notify,
969 const char *reason)
970{
971 struct research *presearch;
973 Tech_Type *result;
974
975 LUASCRIPT_CHECK_STATE(L, nullptr);
976 LUASCRIPT_CHECK_ARG_NIL(L, pplayer, 2, Player, nullptr);
977 LUASCRIPT_CHECK_ARG(L, cost >= -3, 4, "Unknown give_tech() cost value", nullptr);
978
979 presearch = research_get(pplayer);
980 if (ptech) {
981 id = advance_number(ptech);
982 } else {
984 }
985
986 if (is_future_tech(id)
988 if (cost < 0) {
989 if (cost == -1) {
991 } else if (cost == -2) {
993 } else if (cost == -3) {
995 } else {
996 cost = 0;
997 }
998 }
1001 result = advance_by_number(id);
1002 script_tech_learned(presearch, pplayer, result, reason);
1003
1004 if (notify && result != nullptr) {
1006 char research_name[MAX_LEN_NAME * 2];
1007
1009
1010 notify_player(pplayer, nullptr, E_TECH_GAIN, ftc_server,
1011 Q_("?fromscript:You acquire %s."), adv_name);
1013 /* TRANS: "The Greeks ..." or "The members of
1014 * team Red ..." */
1015 Q_("?fromscript:The %s acquire %s and share this "
1016 "advance with you."),
1019 /* TRANS: "The Greeks ..." or "The members of
1020 * team Red ..." */
1021 Q_("?fromscript:The %s acquire %s."),
1023 }
1024
1025 return result;
1026 } else {
1027 return nullptr;
1028 }
1029}
1030
1031/**********************************************************************/
1035 const char *tname, const int mod)
1036{
1037 enum trait tr;
1038
1040 LUASCRIPT_CHECK_ARG_NIL(L, pplayer, 2, Player, FALSE);
1041 LUASCRIPT_CHECK_ARG_NIL(L, tname, 3, string, FALSE);
1042
1044
1045 LUASCRIPT_CHECK_ARG(L, trait_is_valid(tr), 3, "no such trait", 0);
1046
1047 pplayer->ai_common.traits[tr].mod += mod;
1048
1049 return TRUE;
1050}
1051
1052/**********************************************************************/
1056 const char *name, Player *pplayer)
1057{
1058 struct extra_type *pextra;
1059
1061 LUASCRIPT_CHECK_ARG_NIL(L, ptile, 2, Tile);
1062
1063 if (name == nullptr) {
1064 return;
1065 }
1066
1067 pextra = extra_type_by_rule_name(name);
1068
1069 if (pextra != nullptr) {
1070 create_extra(ptile, pextra, pplayer);
1071 update_tile_knowledge(ptile);
1073 }
1074}
1075
1076/**********************************************************************/
1079void api_edit_create_extra(lua_State *L, Tile *ptile, const char *name)
1080{
1081 api_edit_create_owned_extra(L, ptile, name, nullptr);
1082}
1083
1084/**********************************************************************/
1087void api_edit_create_base(lua_State *L, Tile *ptile, const char *name,
1088 Player *pplayer)
1089{
1090 api_edit_create_owned_extra(L, ptile, name, pplayer);
1091}
1092
1093/**********************************************************************/
1096void api_edit_create_road(lua_State *L, Tile *ptile, const char *name)
1097{
1098 api_edit_create_owned_extra(L, ptile, name, nullptr);
1099}
1100
1101/**********************************************************************/
1104void api_edit_remove_extra(lua_State *L, Tile *ptile, const char *name)
1105{
1106 struct extra_type *pextra;
1107
1109 LUASCRIPT_CHECK_ARG_NIL(L, ptile, 2, Tile);
1110
1111 if (name == nullptr) {
1112 return;
1113 }
1114
1115 pextra = extra_type_by_rule_name(name);
1116
1117 if (pextra != nullptr && tile_has_extra(ptile, pextra)) {
1118 tile_extra_rm_apply(ptile, pextra);
1119 update_tile_knowledge(ptile);
1121 }
1122}
1123
1124/**********************************************************************/
1127void api_edit_tile_set_label(lua_State *L, Tile *ptile, const char *label)
1128{
1130 LUASCRIPT_CHECK_SELF(L, ptile);
1131 LUASCRIPT_CHECK_ARG_NIL(L, label, 3, string);
1132
1133 tile_set_label(ptile, label);
1134 if (server_state() >= S_S_RUNNING) {
1135 send_tile_info(nullptr, ptile, FALSE);
1136 }
1137}
1138
1139/**********************************************************************/
1142void api_edit_tile_show(lua_State *L, Tile *ptile, Player *pplayer)
1143{
1145 LUASCRIPT_CHECK_SELF(L, ptile);
1146 LUASCRIPT_CHECK_ARG_NIL(L, pplayer, 3, Player);
1147
1148 map_show_tile(pplayer, ptile);
1149}
1150
1151/**********************************************************************/
1154bool api_edit_tile_hide(lua_State *L, Tile *ptile, Player *pplayer)
1155{
1156 struct city *pcity;
1157
1159 LUASCRIPT_CHECK_SELF(L, ptile, FALSE);
1160 LUASCRIPT_CHECK_ARG_NIL(L, pplayer, 3, Player, FALSE);
1161
1162 if (map_is_known_and_seen(ptile, pplayer, V_MAIN)) {
1163 /* Can't hide currently seen tile */
1164 return FALSE;
1165 }
1166
1167 pcity = tile_city(ptile);
1168
1169 if (pcity != nullptr) {
1170 trade_partners_iterate(pcity, partner) {
1171 if (really_gives_vision(pplayer, city_owner(partner))) {
1172 /* Can't remove vision about trade partner */
1173 return FALSE;
1174 }
1176 }
1177
1178 dbv_clr(&pplayer->tile_known, tile_index(ptile));
1179
1180 send_tile_info(pplayer->connections, ptile, TRUE);
1181
1182 return TRUE;
1183}
1184
1185/**********************************************************************/
1189 int effect)
1190{
1194 2, "invalid climate change type");
1195 LUASCRIPT_CHECK_ARG(L, effect > 0, 3, "effect must be greater than zero");
1196
1198}
1199
1200/**********************************************************************/
1204{
1205 LUASCRIPT_CHECK_STATE(L, nullptr);
1206 LUASCRIPT_CHECK_ARG_NIL(L, pplayer, 2, Player, nullptr);
1208 3, "must be a percentage", nullptr);
1209
1210 if (!civil_war_possible(pplayer, FALSE, FALSE)) {
1211 return nullptr;
1212 }
1213
1214 if (probability == 0) {
1215 /* Calculate chance with normal rules */
1216 if (!civil_war_triggered(pplayer)) {
1217 return nullptr;
1218 }
1219 } else {
1220 /* Fixed chance specified by script */
1221 if (fc_rand(100) >= probability) {
1222 return nullptr;
1223 }
1224 }
1225
1226 return civil_war(pplayer);
1227}
1228
1229/**********************************************************************/
1233{
1235 LUASCRIPT_CHECK_SELF(L, pplayer);
1236
1238}
1239
1240/**********************************************************************/
1244 int movecost,
1245 Unit *embark_to, bool disembark,
1246 bool conquer_city, bool conquer_extra,
1247 bool enter_hut, bool frighten_hut)
1248{
1251 LUASCRIPT_CHECK_ARG_NIL(L, ptile, 3, Tile, FALSE);
1252 LUASCRIPT_CHECK_ARG(L, movecost >= 0, 4, "Negative move cost!", FALSE);
1253
1255 "Can't both enter and frighten a hut at the same time",
1256 TRUE);
1257
1258 if (!disembark && unit_transported(punit)) {
1259 /* Can't leave the transport. */
1260 return TRUE;
1261 }
1262
1264 unit_tile(punit), ptile, TRUE,
1265 FALSE, embark_to, TRUE) != MR_OK) {
1266 /* Can't move to target. Return that unit is still alive. */
1267 return TRUE;
1268 }
1269
1270 return unit_move(punit, ptile, movecost,
1271 embark_to, embark_to != nullptr,
1274}
1275
1276/**********************************************************************/
1280{
1283
1284 if (punit != nullptr) {
1285 punit->stay = TRUE;
1286 }
1287}
1288
1289/**********************************************************************/
1293{
1296
1297 if (punit != nullptr) {
1298 punit->stay = FALSE;
1299 }
1300}
1301
1302/**********************************************************************/
1306{
1309
1310 pcity->history += amount;
1311}
1312
1313/**********************************************************************/
1317{
1319 LUASCRIPT_CHECK_SELF(L, pplayer);
1320
1321 pplayer->history += amount;
1322}
1323
1324/**********************************************************************/
1336 Tech_Type *tech)
1337{
1338 struct research *presearch;
1339
1341 LUASCRIPT_CHECK_SELF(L, pplayer);
1342 presearch = research_get(pplayer);
1344
1345 if (!tech) {
1346 update_bulbs(pplayer, amount, TRUE, TRUE);
1347
1348 send_research_info(presearch, nullptr);
1349 } else if (advance_number(tech) == presearch->researching) {
1350 update_bulbs(pplayer, amount, TRUE, FALSE);
1351 /* Clean the saved tech to get no surprises switching */
1352 presearch->researching_saved = A_UNKNOWN;
1353
1354 send_research_info(presearch, nullptr);
1355 } else {
1356 /* Sometimes we may set negative bulbs, it's normal though lurking */
1358 presearch->inventions[advance_number(tech)].bulbs_researched_saved
1359 += amount;
1360 /* Currently, multiresearch data are not sent to clients */
1361 } else {
1362 int oldb = presearch->bulbs_researched;
1363
1364 /* NOTE: We can set a tech we already know / can't research here.
1365 * Probably it's safe as we can't switch into it any way. */
1366 if (presearch->researching_saved != advance_number(tech)) {
1367 presearch->researching_saved = advance_number(tech);
1368 presearch->bulbs_researching_saved
1369 = amount + presearch->free_bulbs;
1370 } else {
1371 presearch->bulbs_researching_saved
1372 += amount + presearch->free_bulbs;
1373 }
1374 /* For consistency, modify current bulbs alongside
1375 * (sometimes getting into "overresearch" situation, but ok) */
1376 presearch->bulbs_researched = amount
1377 - amount * game.server.techpenalty / 100 + presearch->free_bulbs;
1378 if (oldb != presearch->bulbs_researched) {
1379 send_research_info(presearch, nullptr);
1380 }
1381 }
1382 }
1383}
1384
1385/**********************************************************************/
1389{
1390 struct player *pplayer, *partner_player;
1391
1393 LUASCRIPT_CHECK_ARG_NIL(L, from, 2, City, FALSE);
1395
1396 /* Priority zero -> never replace old routes. */
1397 if (!can_establish_trade_route(from, to, 0)) {
1398 return FALSE;
1399 }
1400
1401 create_trade_route(from, to, goods_from_city_to_unit(from, nullptr));
1402
1403 /* Refresh the cities. */
1404 city_refresh(from);
1405 city_refresh(to);
1406
1407 pplayer = city_owner(from);
1409
1410 send_city_info(pplayer, from);
1412
1413 /* Notify each player about the other's cities. */
1414 if (pplayer != partner_player && game.info.reveal_trade_partner) {
1417 map_show_tile(pplayer, city_tile(to));
1418 send_city_info(pplayer, to);
1419 }
1420
1421 return TRUE;
1422}
1423
1424/**********************************************************************/
1428 Player *nationality)
1429{
1432
1433 if (nationality == nullptr) {
1434 nationality = city_owner(pcity);
1435 }
1436
1437 city_change_size(pcity, city_size_get(pcity) + change, nationality,
1438 -1, "script");
1439}
1440
1441/**********************************************************************/
enum action_actor_kind action_get_actor_kind(const struct action *paction)
Definition actions.c:1119
bool is_action_enabled_unit_on_stack(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct tile *target_tile)
Definition actions.c:3270
bool is_action_enabled_unit_on_tile(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:3346
bool is_action_enabled_unit_on_city(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct city *target_city)
Definition actions.c:3105
bool is_action_enabled_unit_on_unit(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct unit *target_unit)
Definition actions.c:3182
enum action_target_kind action_get_target_kind(const struct action *paction)
Definition actions.c:1129
bool is_action_enabled_unit_on_self(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit)
Definition actions.c:3495
bool is_action_enabled_unit_on_extras(const struct civ_map *nmap, const action_id wanted_action, const struct unit *actor_unit, const struct tile *target_tile, const struct extra_type *target_extra)
Definition actions.c:3423
#define action_has_result(_act_, _res_)
Definition actions.h:184
const char * default_ai_type_name(void)
Definition aiiface.c:249
void api_edit_change_city_size(lua_State *L, City *pcity, int change, Player *nationality)
static bool ur_transform_unit(struct unit *punit, const struct unit_type *to_unit, int vet_loss)
bool api_edit_perform_action_unit_vs_tile_extra(lua_State *L, Unit *punit, Action *paction, Tile *tgt, const char *sub_tgt)
bool api_edit_perform_action_unit_vs_tile(lua_State *L, Unit *punit, Action *paction, Tile *tgt)
void api_edit_climate_change(lua_State *L, enum climate_change_type type, int effect)
void api_edit_player_give_bulbs(lua_State *L, Player *pplayer, int amount, Tech_Type *tech)
bool api_edit_city_add_specialist(lua_State *L, City *pcity, Specialist *s, int amount)
void api_edit_unit_moving_allow(lua_State *L, Unit *punit)
void api_edit_remove_city(lua_State *L, City *pcity)
bool api_edit_trait_mod_set(lua_State *L, Player *pplayer, const char *tname, const int mod)
bool api_edit_unleash_barbarians(lua_State *L, Tile *ptile)
void api_edit_remove_building(lua_State *L, City *pcity, Building_Type *impr)
void api_edit_player_victory(lua_State *L, Player *pplayer)
void api_edit_create_extra(lua_State *L, Tile *ptile, const char *name)
void api_edit_unit_movepoints(lua_State *L, Unit *self, int change)
Unit * api_edit_create_unit(lua_State *L, Player *pplayer, Tile *ptile, Unit_Type *ptype, int veteran_level, City *homecity, int moves_left)
bool api_edit_perform_action_unit_vs_unit(lua_State *L, Unit *punit, Action *paction, Unit *tgt)
void api_edit_player_add_history(lua_State *L, Player *pplayer, int amount)
Tech_Type * api_edit_give_technology(lua_State *L, Player *pplayer, Tech_Type *ptech, int cost, bool notify, const char *reason)
bool api_edit_perform_action_unit_vs_city_impr(lua_State *L, Unit *punit, Action *paction, City *tgt, Building_Type *sub_tgt)
void api_edit_create_building(lua_State *L, City *pcity, Building_Type *impr)
Unit * api_edit_create_unit_full(lua_State *L, Player *pplayer, Tile *ptile, Unit_Type *ptype, int veteran_level, City *homecity, int moves_left, int hp_left, Unit *ptransport)
bool api_edit_transfer_city(lua_State *L, City *pcity, Player *new_owner)
bool api_edit_change_terrain(lua_State *L, Tile *ptile, Terrain *pterr)
void api_edit_create_owned_extra(lua_State *L, Tile *ptile, const char *name, Player *pplayer)
void api_edit_tile_show(lua_State *L, Tile *ptile, Player *pplayer)
void api_edit_unit_kill(lua_State *L, Unit *punit, const char *reason, Player *killer)
bool api_edit_tile_hide(lua_State *L, Tile *ptile, Player *pplayer)
void api_edit_unit_turn(lua_State *L, Unit *punit, Direction dir)
void api_edit_place_partisans(lua_State *L, Tile *ptile, Player *pplayer, int count, int sq_radius)
void api_edit_remove_extra(lua_State *L, Tile *ptile, const char *name)
bool api_edit_city_reduce_specialists(lua_State *L, City *pcity, Specialist *s, int amount)
bool api_edit_unit_hitpoints(lua_State *L, Unit *self, int change, const char *reason, Player *killer)
void api_edit_tile_set_label(lua_State *L, Tile *ptile, const char *label)
void api_edit_create_road(lua_State *L, Tile *ptile, const char *name)
void api_edit_change_citizen_nationality(lua_State *L, City *pcity, Player *from, Player *to, int amount)
bool api_edit_perform_action_unit_vs_city(lua_State *L, Unit *punit, Action *paction, City *tgt)
void api_edit_city_add_history(lua_State *L, City *pcity, int amount)
bool api_edit_unit_teleport(lua_State *L, Unit *punit, Tile *dest, Unit *embark_to, bool allow_disembark, bool conquer_city, bool conquer_extra, bool enter_hut, bool frighten_hut)
void api_edit_unit_moving_disallow(lua_State *L, Unit *punit)
bool api_edit_unit_upgrade(lua_State *L, Unit *punit, int vet_loss)
bool api_edit_create_city(lua_State *L, Player *pplayer, Tile *ptile, const char *name, Player *nationality)
bool api_edit_create_trade_route(lua_State *L, City *from, City *to)
bool api_edit_unit_move(lua_State *L, Unit *punit, Tile *ptile, int movecost, Unit *embark_to, bool disembark, bool conquer_city, bool conquer_extra, bool enter_hut, bool frighten_hut)
void api_edit_change_infrapoints(lua_State *L, Player *pplayer, int amount)
bool api_edit_perform_action_unit_vs_self(lua_State *L, Unit *punit, Action *paction)
Player * api_edit_create_player(lua_State *L, const char *username, Nation_Type *pnation, const char *ai)
bool api_edit_unit_transform(lua_State *L, Unit *punit, Unit_Type *ptype, int vet_loss)
void api_edit_change_gold(lua_State *L, Player *pplayer, int amount)
Player * api_edit_civil_war(lua_State *L, Player *pplayer, int probability)
bool api_edit_perform_action_unit_vs_city_tech(lua_State *L, Unit *punit, Action *paction, City *tgt, Tech_Type *sub_tgt)
void api_edit_create_base(lua_State *L, Tile *ptile, const char *name, Player *pplayer)
climate_change_type
@ CLIMATE_CHANGE_GLOBAL_WARMING
@ CLIMATE_CHANGE_NUCLEAR_WINTER
bool unleash_barbarians(struct tile *ptile)
Definition barbarian.c:272
void dbv_clr(struct dbv *pdbv, int bit)
Definition bitvector.c:163
void citizens_nation_move(struct city *pcity, const struct player_slot *pslot_from, const struct player_slot *pslot_to, int move)
Definition citizens.c:130
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:1292
const char * city_name_get(const struct city *pcity)
Definition city.c:1157
void city_remove_improvement(struct city *pcity, const struct impr_type *pimprove)
Definition city.c:3479
bool city_can_use_specialist(const struct city *pcity, Specialist_type_id type)
Definition city.c:1083
#define city_tile(_pcity_)
Definition city.h:565
static citizens city_size_get(const struct city *pcity)
Definition city.h:570
#define city_owner(_pcity_)
Definition city.h:564
#define MAX_CITY_SIZE
Definition city.h:104
bool create_city_for_player(struct player *pplayer, struct tile *ptile, const char *name, struct player *nationality)
Definition citytools.c:1687
const char * city_name_suggestion(struct player *pplayer, struct tile *ptile)
Definition citytools.c:458
void send_city_info(struct player *dest, struct city *pcity)
Definition citytools.c:2374
struct city * build_or_move_building(struct city *pcity, struct impr_type *pimprove, struct player **oldcity_owner)
Definition citytools.c:3038
void remove_city(struct city *pcity)
Definition citytools.c:1719
bool transfer_city(struct player *ptaker, struct city *pcity, int kill_outside, bool transfer_unit_verbose, bool resolve_stack, bool raze, bool build_free)
Definition citytools.c:1077
void auto_arrange_workers(struct city *pcity)
Definition cityturn.c:367
bool city_refresh(struct city *pcity)
Definition cityturn.c:159
bool city_change_size(struct city *pcity, citizens size, struct player *nationality, Specialist_type_id sid, const char *reason)
Definition cityturn.c:1069
static struct ai_type * self
Definition classicai.c:47
char * incite_cost
Definition comments.c:77
static void enter_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2829
static void frighten_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2889
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
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:77
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
Definition dialogs_g.h:73
int int id
Definition editgui_g.h:28
struct extra_type * extra_type_by_rule_name(const char *name)
Definition extras.c:212
int Tech_type_id
Definition fc_types.h:238
int Specialist_type_id
Definition fc_types.h:236
#define MAX_LEN_NAME
Definition fc_types.h:68
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:94
#define Q_(String)
Definition fcintl.h:70
const struct ft_color ftc_server
struct civ_game game
Definition game.c:62
struct world wld
Definition game.c:63
void send_game_info(struct conn_list *dest)
Definition gamehand.c:910
struct city * owner
Definition citydlg.c:226
GType type
Definition repodlgs.c:1313
bool is_special_improvement(const struct impr_type *pimprove)
bool is_wonder(const struct impr_type *pimprove)
bool is_great_wonder(const struct impr_type *pimprove)
const char * name
Definition inputfile.c:127
#define fc_assert_ret(condition)
Definition log.h:192
#define fc_assert(condition)
Definition log.h:177
#define fc_assert_ret_val(condition, val)
Definition log.h:195
#define fc_assert_action(condition, action)
Definition log.h:188
@ LOG_ERROR
Definition log.h:31
@ LOG_NORMAL
Definition log.h:33
#define log_error(message,...)
Definition log.h:104
#define fc_assert_ret_val_msg(condition, val, message,...)
Definition log.h:209
void luascript_log(struct fc_lua *fcl, enum log_level level, const char *format,...)
Definition luascript.c:409
struct fc_lua * luascript_get_fcl(lua_State *L)
Definition luascript.c:366
#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
enum direction8 Direction
bool same_pos(const struct tile *tile1, const struct tile *tile2)
Definition map.c:1085
void assign_continent_numbers(void)
bool really_gives_vision(struct player *me, struct player *them)
Definition maphand.c:344
void send_tile_info(struct conn_list *dest, struct tile *ptile, bool send_unknown)
Definition maphand.c:490
void send_all_known_tiles(struct conn_list *dest)
Definition maphand.c:443
bool need_to_reassign_continents(const struct terrain *oldter, const struct terrain *newter)
Definition maphand.c:1947
void climate_change(bool warming, int effect)
Definition maphand.c:131
void create_extra(struct tile *ptile, struct extra_type *pextra, struct player *pplayer)
Definition maphand.c:2515
void map_show_tile(struct player *src_player, struct tile *ptile)
Definition maphand.c:775
void tile_change_side_effects(struct tile *ptile, bool refresh_city)
Definition maphand.c:2683
bool map_is_known_and_seen(const struct tile *ptile, const struct player *pplayer, enum vision_layer vlayer)
Definition maphand.c:927
void fix_tile_on_terrain_change(struct tile *ptile, struct terrain *oldter, bool extend_rivers)
Definition maphand.c:1985
void update_tile_knowledge(struct tile *ptile)
Definition maphand.c:1447
bool can_exist_at_tile(const struct civ_map *nmap, const struct unit_type *utype, const struct tile *ptile)
Definition movement.c:278
enum unit_move_result unit_move_to_tile_test(const struct civ_map *nmap, const struct unit *punit, enum unit_activity activity, const struct tile *src_tile, const struct tile *dst_tile, bool igzoc, bool enter_transport, struct unit *embark_to, bool enter_enemy_city)
Definition movement.c:661
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:350
enum unit_move_result unit_teleport_to_tile_test(const struct civ_map *nmap, const struct unit *punit, enum unit_activity activity, const struct tile *src_tile, const struct tile *dst_tile, bool enter_transport, struct unit *embark_to, bool enter_enemy_city)
Definition movement.c:815
@ MR_OK
Definition movement.h:35
const char * nation_plural_for_player(const struct player *pplayer)
Definition nation.c:178
void notify_research(const struct research *presearch, const struct player *exclude, enum event_type event, const struct ft_color color, const char *format,...)
Definition notify.c:393
void notify_player(const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Definition notify.c:291
void notify_research_embassies(const struct research *presearch, const struct player *exclude, enum event_type event, const struct ft_color color, const char *format,...)
Definition notify.c:433
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1397
void player_status_add(struct player *plr, enum player_status pstatus)
Definition plrhand.c:3225
bool civil_war_triggered(struct player *pplayer)
Definition plrhand.c:2971
void send_player_info_c(struct player *src, struct conn_list *dest)
Definition plrhand.c:1148
struct player * civil_war(struct player *pplayer)
Definition plrhand.c:3016
bool civil_war_possible(struct player *pplayer, bool conquering_city, bool honour_server_option)
Definition plrhand.c:2923
#define fc_rand(_size)
Definition rand.h:56
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:276
struct research * research_get(const struct player *pplayer)
Definition research.c:130
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:622
int research_pretty_name(const struct research *presearch, char *buf, size_t buf_len)
Definition research.c:171
#define MAX(x, y)
Definition shared.h:54
bool is_super_specialist_id(Specialist_type_id sp)
Definition specialist.c:184
Specialist_type_id specialist_index(const struct specialist *sp)
Definition specialist.c:90
Specialist_type_id normal_specialist_count(void)
Definition specialist.c:79
bool is_super_specialist(const struct specialist *sp)
Definition specialist.c:208
bool game_was_started(void)
Definition srv_main.c:357
enum server_states server_state(void)
Definition srv_main.c:341
enum rfc_status create_command_newcomer(const char *name, const char *ai, bool check, struct nation_type *pnation, struct player **newplayer, char *buf, size_t buflen)
Definition stdinhand.c:782
enum rfc_status create_command_pregame(const char *name, const char *ai, bool check, struct player **newplayer, char *buf, size_t buflen)
Definition stdinhand.c:970
int mod
Definition traits.h:39
Definition city.h:318
int id
Definition city.h:324
bool multiresearch
Definition game.h:170
struct packet_game_info info
Definition game.h:89
int diplbulbcost
Definition game.h:146
int conquercost
Definition game.h:143
int freecost
Definition game.h:155
struct civ_game::@32::@36 server
int techpenalty
Definition game.h:203
int id
Definition extras.h:89
struct ai_trait * traits
Definition player.h:126
int infra_points
Definition player.h:67
struct player_ai ai_common
Definition player.h:288
struct dbv tile_known
Definition player.h:310
struct conn_list * connections
Definition player.h:298
struct player_economic economic
Definition player.h:284
struct player_slot * slot
Definition player.h:250
int history
Definition player.h:316
Definition tile.h:50
Definition unit.h:139
int moves_left
Definition unit.h:151
int id
Definition unit.h:146
bool stay
Definition unit.h:207
enum direction8 facing
Definition unit.h:143
int homecity
Definition unit.h:147
int veteran
Definition unit.h:153
struct civ_map map
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:186
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:110
bool is_future_tech(Tech_type_id tech)
Definition tech.c:286
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:100
#define A_UNKNOWN
Definition tech.h:49
void found_new_tech(struct research *presearch, Tech_type_id tech_found, bool was_discovery, bool saving_bulbs)
Definition techtools.c:347
void research_apply_penalty(struct research *presearch, Tech_type_id tech, int penalty_percent)
Definition techtools.c:67
Tech_type_id pick_free_tech(struct research *presearch)
Definition techtools.c:1462
void send_research_info(const struct research *presearch, const struct conn_list *dest)
Definition techtools.c:293
void script_tech_learned(struct research *presearch, struct player *originating_plr, struct advance *tech, const char *reason)
Definition techtools.c:84
void update_bulbs(struct player *pplayer, int bulbs, bool check_tech, bool free_bulbs)
Definition techtools.c:726
#define terrain_has_flag(terr, flag)
Definition terrain.h:177
void tile_change_terrain(struct tile *ptile, struct terrain *pterrain)
Definition tile.c:497
bool tile_extra_rm_apply(struct tile *ptile, struct extra_type *tgt)
Definition tile.c:602
bool tile_set_label(struct tile *ptile, const char *label)
Definition tile.c:1098
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:89
#define tile_terrain(_tile)
Definition tile.h:115
#define tile_has_extra(ptile, pextra)
Definition tile.h:152
struct goods_type * goods_from_city_to_unit(const struct city *src, const struct unit *punit)
bool can_establish_trade_route(const struct city *pc1, const struct city *pc2, int priority)
#define trade_partners_iterate_end
#define trade_partners_iterate(c, p)
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:2012
void unit_virtual_destroy(struct unit *punit)
Definition unit.c:1787
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2512
bool unit_has_orders(const struct unit *punit)
Definition unit.c:221
bool could_unit_be_in_transport(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:709
#define unit_tile(_pu)
Definition unit.h:408
#define unit_owner(_pu)
Definition unit.h:407
@ UU_OK
Definition unit.h:61
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer, bool everyone_non_allied)
Definition unit.h:446
bool unit_perform_action(struct player *pplayer, const int actor_id, const int target_id, const int sub_tgt_id_incoming, const char *name, const action_id action_type, const enum action_requester requester)
Definition unithand.c:3374
void create_trade_route(struct city *from, struct city *to, struct goods_type *goods)
Definition unithand.c:6422
void place_partisans(struct tile *pcenter, struct player *powner, int count, int sq_radius)
Definition unittools.c:1172
void transform_unit(struct unit *punit, const struct unit_type *to_unit, int vet_loss)
Definition unittools.c:1566
void send_unit_info(struct conn_list *dest, struct unit *punit)
Definition unittools.c:2895
bool place_unit(struct unit *punit, struct player *pplayer, struct city *pcity, struct unit *ptrans, bool force)
Definition unittools.c:1726
struct unit * unit_virtual_prepare(struct player *pplayer, struct tile *ptile, const struct unit_type *type, int veteran_level, int homecity_id, int moves_left, int hp_left)
Definition unittools.c:1678
void wipe_unit(struct unit *punit, enum unit_loss_reason reason, struct player *killer)
Definition unittools.c:2157
bool unit_move(struct unit *punit, struct tile *pdesttile, int move_cost, struct unit *embark_to, bool find_embark_target, bool conquer_city_allowed, bool conquer_extras_allowed, bool enter_hut, bool frighten_hut)
Definition unittools.c:4096
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:126
struct unit_type * unit_type_array_first(void)
Definition unittype.c:58
int num_role_units(int role)
Definition unittype.c:2234
bool utype_player_already_has_this_unique(const struct player *pplayer, const struct unit_type *putype)
Definition unittype.c:1954
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1729
int utype_veteran_levels(const struct unit_type *punittype)
Definition unittype.c:2662
const char * utype_rule_name(const struct unit_type *punittype)
Definition unittype.c:1604
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Definition unittype.c:215
const struct unit_type * unit_type_array_last(void)
Definition unittype.c:70
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:624