Freeciv-3.2
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 "map.h"
23#include "movement.h"
24#include "research.h"
25#include "unittype.h"
26
27/* common/scriptcore */
28#include "api_game_find.h"
29#include "luascript.h"
30
31/* server */
32#include "aiiface.h"
33#include "barbarian.h"
34#include "citytools.h"
35#include "cityturn.h" /* city_refresh() auto_arrange_workers() */
36#include "console.h" /* enum rfc_status */
37#include "gamehand.h"
38#include "maphand.h"
39#include "notify.h"
40#include "plrhand.h"
41#include "srv_main.h" /* game_was_started() */
42#include "stdinhand.h"
43#include "techtools.h"
44#include "unithand.h"
45#include "unittools.h"
46
47/* server/scripting */
48#include "script_server.h"
49
50/* server/generator */
51#include "mapgen_utils.h"
52
53#include "api_server_edit.h"
54
55
56/**********************************************************************/
66
67/**********************************************************************/
71static bool
73 int vet_loss)
74{
76 /* Avoid getting overt veteranship if a user requests increasing it */
77 if (vet_loss < 0) {
79
80 vl = punit->veteran - vl + 1;
81 if (vl >= 0) {
82 vet_loss = 0;
83 } else {
85 }
86 }
88 return TRUE;
89 } else {
90 return FALSE;
91 }
92}
93
94/**********************************************************************/
98 int count, int sq_radius)
99{
101 LUASCRIPT_CHECK_ARG_NIL(L, ptile, 2, Tile);
102 LUASCRIPT_CHECK_ARG_NIL(L, pplayer, 3, Player);
103 LUASCRIPT_CHECK_ARG(L, 0 <= sq_radius, 5, "radius must be positive");
105 "no partisans in ruleset");
106
107 return place_partisans(ptile, pplayer, count, sq_radius);
108}
109
110/**********************************************************************/
115 City *homecity, int moves_left)
116{
117 return api_edit_create_unit_full(L, pplayer, ptile, ptype, veteran_level,
118 homecity, moves_left, -1, NULL);
119}
120
121/**********************************************************************/
125 Tile *ptile,
127 City *homecity, int moves_left,
128 int hp_left,
130{
131 struct fc_lua *fcl;
132 struct city *pcity;
133 struct unit *punit;
134#ifndef FREECIV_NDEBUG
135 bool placed;
136#endif
137
139 LUASCRIPT_CHECK_ARG_NIL(L, pplayer, 2, Player, NULL);
140 LUASCRIPT_CHECK_ARG_NIL(L, ptile, 3, Tile, NULL);
141
143
144 LUASCRIPT_CHECK(L, fcl != NULL, "Undefined Freeciv lua state!", NULL);
145
146 if (ptype == NULL
148 return NULL;
149 }
150
151 if (is_non_allied_unit_tile(ptile, pplayer)) {
152 luascript_log(fcl, LOG_ERROR, "create_unit_full: tile is occupied by "
153 "enemy unit");
154 return NULL;
155 }
156
157 pcity = tile_city(ptile);
158 if (pcity != NULL && !pplayers_allied(pplayer, city_owner(pcity))) {
159 luascript_log(fcl, LOG_ERROR, "create_unit_full: tile is occupied by "
160 "enemy city");
161 return NULL;
162 }
163
166 "create_unit_full: player already has unique unit");
167 return NULL;
168 }
169
171 homecity ? homecity->id : 0,
173 if (ptransport) {
174 /* The unit maybe can't freely load into the transport
175 * but must be able to be in it, see can_unit_load() */
176 int ret = same_pos(ptile, unit_tile(ptransport))
178
179 if (!ret) {
181 luascript_log(fcl, LOG_ERROR, "create_unit_full: '%s' cannot transport "
182 "'%s' here",
185 return NULL;
186 }
187 } else if (!can_exist_at_tile(&(wld.map), ptype, ptile)) {
189 luascript_log(fcl, LOG_ERROR, "create_unit_full: '%s' cannot exist at "
190 "tile", utype_rule_name(ptype));
191 return NULL;
192 }
193
194#ifndef FREECIV_NDEBUG
195 placed =
196#endif
199
200 return punit;
201}
202
203/**********************************************************************/
208 bool conquer_city, bool conquer_extra,
209 bool enter_hut, bool frighten_hut)
210{
211 bool alive;
212
216
218 "Can't both enter and frighten a hut at the same time",
219 TRUE);
220
222 /* Can't leave the transport. */
223 return TRUE;
224 }
225
227 unit_tile(punit), dest, FALSE,
228 embark_to, TRUE) != MR_OK) {
229 /* Can't teleport to target. Return that unit is still alive. */
230 return TRUE;
231 }
232
233 /* Teleport first so destination is revealed even if unit dies */
234 alive = unit_move(punit, dest, 0,
238 if (alive) {
239 struct player *owner = unit_owner(punit);
240 struct city *pcity = tile_city(dest);
241
242 if (!can_unit_exist_at_tile(&(wld.map), punit, dest)
243 && !unit_transported(punit)) {
245 return FALSE;
246 }
248 || (pcity && !pplayers_allied(city_owner(pcity), owner))) {
250 return FALSE;
251 }
252 }
253
254 return alive;
255}
256
257/***********************************************************************/
281
282/***********************************************************************/
308
309/***********************************************************************/
335
336/***********************************************************************/
362
363/***********************************************************************/
367 Action *paction, Tile *tgt)
368{
369 bool enabled = FALSE;
370 const struct civ_map *nmap = &(wld.map);
371
376
379 case ATK_UNITS:
381 break;
382 case ATK_TILE:
384 tgt, NULL);
385 break;
386 case ATK_EXTRAS:
388 tgt, NULL);
389 break;
390 case ATK_CITY:
391 /* Not handled here. */
393 "City-targeted action applied to tile", FALSE);
394 break;
395 case ATK_UNIT:
396 /* Not handled here. */
398 "Unit-targeted action applied to tile", FALSE);
399 break;
400 case ATK_SELF:
401 /* Not handled here. */
403 "Self-targeted action applied to tile", FALSE);
404 break;
405 case ATK_COUNT:
406 /* Should not exist */
408 break;
409 }
410
411 if (enabled) {
416 } else {
417 /* Action not enabled */
418 return FALSE;
419 }
420}
421
422/***********************************************************************/
426 Action *paction, Tile *tgt,
427 const char *sub_tgt)
428{
429 struct extra_type *sub_target;
430 bool enabled = FALSE;
431 const struct civ_map *nmap = &(wld.map);
432
438
439 sub_target = extra_type_by_rule_name(sub_tgt);
440 LUASCRIPT_CHECK_ARG(L, sub_target != NULL, 5, "No such extra", FALSE);
441
444 case ATK_UNITS:
446 break;
447 case ATK_TILE:
449 tgt, sub_target);
450 break;
451 case ATK_EXTRAS:
453 tgt, sub_target);
454 break;
455 case ATK_CITY:
456 /* Not handled here. */
458 "City-targeted action applied to tile", FALSE);
459 break;
460 case ATK_UNIT:
461 /* Not handled here. */
463 "Unit-targeted action applied to tile", FALSE);
464 break;
465 case ATK_SELF:
466 /* Not handled here. */
468 "Self-targeted action applied to tile", FALSE);
469 break;
470 case ATK_COUNT:
471 /* Should not exist */
473 break;
474 }
475
476 if (enabled) {
478 tile_index(tgt), sub_target->id,
481 } else {
482 /* Action not enabled */
483 return FALSE;
484 }
485}
486
487/***********************************************************************/
513
514/**********************************************************************/
518{
521
522 if (direction8_is_valid(dir)) {
523 punit->facing = dir;
524
526 } else {
527 log_error("Illegal direction %d for unit from lua script", dir);
528 }
529}
530
531/**********************************************************************/
548
549/**********************************************************************/
562
563/**********************************************************************/
582
583/**********************************************************************/
587 const char *reason, Player *killer)
588{
591
592 self->hp += change;
593
594 if (self->hp <= 0) {
597
599
600 /* Intentionally only after wiping, so that unit is never left with
601 * zero or less hit points. */
603 "Invalid unit loss reason", FALSE);
604
605 return FALSE;
606 } else {
607 int max = unit_type_get(self)->hp;
608
609 if (self->hp > max) {
610 self->hp = max;
611 }
612 }
613
615
616 return TRUE;
617}
618
619/**********************************************************************/
623{
624 bool was_exhausted = FALSE;
625
628
629 if (self->moves_left == 0 && self->done_moving) {
631 }
632
633 self->moves_left += change;
634
635 if (self->moves_left <= 0) {
636 self->moves_left = 0;
637 } else if (was_exhausted && !unit_has_orders(self)) {
638 /* Unit has regained ability to move. */
639 self->done_moving = FALSE;
640 }
641
643}
644
645/**********************************************************************/
649{
650 struct terrain *old_terrain;
651
653 LUASCRIPT_CHECK_ARG_NIL(L, ptile, 2, Tile, FALSE);
655
656 old_terrain = tile_terrain(ptile);
657
658 if (old_terrain == pterr
660 && tile_city(ptile) != NULL)) {
661 return FALSE;
662 }
663
668
669 /* FIXME: adv / ai phase handling like in check_terrain_change() */
670
672 }
673
675
677
678 return TRUE;
679}
680
681/**********************************************************************/
685 const char *name)
686{
688 LUASCRIPT_CHECK_ARG_NIL(L, pplayer, 2, Player, FALSE);
689 LUASCRIPT_CHECK_ARG_NIL(L, ptile, 3, Tile, FALSE);
690
691 /* TODO: Allow initial citizen to be of nationality other than owner */
692 return create_city_for_player(pplayer, ptile, name);
693}
694
695/**********************************************************************/
699{
701 LUASCRIPT_CHECK_ARG_NIL(L, pcity, 2, City);
702
703 remove_city(pcity);
704}
705
706/**********************************************************************/
717
718/**********************************************************************/
722{
724 LUASCRIPT_CHECK_ARG_NIL(L, pcity, 2, City);
726 /* FIXME: may "Special" impr be buildable? */
728 "It is a special item, not a city building");
729
730 if (!city_has_building(pcity, impr)) {
731 bool need_game_info = FALSE;
732 bool need_plr_info = FALSE;
733 struct player *old_owner = NULL, *pplayer = city_owner(pcity);
734 struct city *oldcity;
735
737 if (oldcity) {
739 }
740 if (old_owner && old_owner != pplayer) {
741 /* Great wonders make more changes. */
743 }
744
745 if (oldcity) {
746 if (city_refresh(oldcity)) {
748 }
750 }
751
752 if (city_refresh(pcity)) {
754 }
755 send_city_info(NULL, pcity);
756 if (need_game_info) {
759 }
760 if (need_plr_info) {
761 send_player_info_c(pplayer, NULL);
762 }
763 }
764}
765
766/**********************************************************************/
770{
772 LUASCRIPT_CHECK_ARG_NIL(L, pcity, 2, City);
774
775 if (city_has_building(pcity, impr)) {
776 city_remove_improvement(pcity, impr);
777 send_city_info(NULL, pcity);
778
779 if (is_wonder(impr)) {
780 if (is_great_wonder(impr)) {
782 }
784 }
785 }
786}
787
788/**********************************************************************/
791Player *api_edit_create_player(lua_State *L, const char *username,
792 Nation_Type *pnation, const char *ai)
793{
794 struct player *pplayer = NULL;
795 char buf[128] = "";
796 struct fc_lua *fcl;
797
799 LUASCRIPT_CHECK_ARG_NIL(L, username, 2, string, NULL);
800 if (!ai) {
802 }
803
805
806 LUASCRIPT_CHECK(L, fcl != NULL, "Undefined Freeciv lua state!", NULL);
807
808 if (game_was_started()) {
809 create_command_newcomer(username, ai, FALSE, pnation, &pplayer,
810 buf, sizeof(buf));
811 } else {
812 create_command_pregame(username, ai, FALSE, &pplayer,
813 buf, sizeof(buf));
814 }
815
816 if (strlen(buf) > 0) {
818 }
819
820 return pplayer;
821}
822
823/**********************************************************************/
827{
829 LUASCRIPT_CHECK_ARG_NIL(L, pplayer, 2, Player);
830
831 pplayer->economic.gold = MAX(0, pplayer->economic.gold + amount);
832
833 send_player_info_c(pplayer, NULL);
834}
835
836/**********************************************************************/
840{
842 LUASCRIPT_CHECK_ARG_NIL(L, pplayer, 2, Player);
843
844 pplayer->economic.infra_points
845 = MAX(0, pplayer->economic.infra_points + amount);
846
847 send_player_info_c(pplayer, NULL);
848}
849
850/**********************************************************************/
857 Tech_Type *ptech, int cost,
858 bool notify,
859 const char *reason)
860{
861 struct research *presearch;
863 Tech_Type *result;
864
866 LUASCRIPT_CHECK_ARG_NIL(L, pplayer, 2, Player, NULL);
867 LUASCRIPT_CHECK_ARG(L, cost >= -3, 4, "Unknown give_tech() cost value", NULL);
868
869 presearch = research_get(pplayer);
870 if (ptech) {
871 id = advance_number(ptech);
872 } else {
874 }
875
876 if (is_future_tech(id)
878 if (cost < 0) {
879 if (cost == -1) {
881 } else if (cost == -2) {
883 } else if (cost == -3) {
885 } else {
886
887 cost = 0;
888 }
889 }
892 result = advance_by_number(id);
893 script_tech_learned(presearch, pplayer, result, reason);
894
895 if (notify && result != NULL) {
897 char research_name[MAX_LEN_NAME * 2];
898
900
902 Q_("?fromscript:You acquire %s."), adv_name);
904 /* TRANS: "The Greeks ..." or "The members of
905 * team Red ..." */
906 Q_("?fromscript:The %s acquire %s and share this "
907 "advance with you."),
910 /* TRANS: "The Greeks ..." or "The members of
911 * team Red ..." */
912 Q_("?fromscript:The %s acquire %s."),
914 }
915
916 return result;
917 } else {
918 return NULL;
919 }
920}
921
922/**********************************************************************/
926 const char *tname, const int mod)
927{
928 enum trait tr;
929
931 LUASCRIPT_CHECK_ARG_NIL(L, pplayer, 2, Player, FALSE);
932 LUASCRIPT_CHECK_ARG_NIL(L, tname, 3, string, FALSE);
933
935
936 LUASCRIPT_CHECK_ARG(L, trait_is_valid(tr), 3, "no such trait", 0);
937
938 pplayer->ai_common.traits[tr].mod += mod;
939
940 return TRUE;
941}
942
943/**********************************************************************/
947 const char *name, Player *pplayer)
948{
949 struct extra_type *pextra;
950
952 LUASCRIPT_CHECK_ARG_NIL(L, ptile, 2, Tile);
953
954 if (name == NULL) {
955 return;
956 }
957
959
960 if (pextra != NULL) {
961 create_extra(ptile, pextra, pplayer);
964 }
965}
966
967/**********************************************************************/
970void api_edit_create_extra(lua_State *L, Tile *ptile, const char *name)
971{
973}
974
975/**********************************************************************/
978void api_edit_create_base(lua_State *L, Tile *ptile, const char *name,
979 Player *pplayer)
980{
981 api_edit_create_owned_extra(L, ptile, name, pplayer);
982}
983
984/**********************************************************************/
987void api_edit_create_road(lua_State *L, Tile *ptile, const char *name)
988{
990}
991
992/**********************************************************************/
995void api_edit_remove_extra(lua_State *L, Tile *ptile, const char *name)
996{
997 struct extra_type *pextra;
998
1000 LUASCRIPT_CHECK_ARG_NIL(L, ptile, 2, Tile);
1001
1002 if (name == NULL) {
1003 return;
1004 }
1005
1006 pextra = extra_type_by_rule_name(name);
1007
1008 if (pextra != NULL && tile_has_extra(ptile, pextra)) {
1009 tile_extra_rm_apply(ptile, pextra);
1010 update_tile_knowledge(ptile);
1012 }
1013}
1014
1015/**********************************************************************/
1018void api_edit_tile_set_label(lua_State *L, Tile *ptile, const char *label)
1019{
1021 LUASCRIPT_CHECK_SELF(L, ptile);
1022 LUASCRIPT_CHECK_ARG_NIL(L, label, 3, string);
1023
1024 tile_set_label(ptile, label);
1025 if (server_state() >= S_S_RUNNING) {
1026 send_tile_info(NULL, ptile, FALSE);
1027 }
1028}
1029
1030/**********************************************************************/
1033void api_edit_tile_show(lua_State *L, Tile *ptile, Player *pplayer)
1034{
1036 LUASCRIPT_CHECK_SELF(L, ptile);
1037 LUASCRIPT_CHECK_ARG_NIL(L, pplayer, 3, Player);
1038
1039 map_show_tile(pplayer, ptile);
1040}
1041
1042/**********************************************************************/
1045bool api_edit_tile_hide(lua_State *L, Tile *ptile, Player *pplayer)
1046{
1047 struct city *pcity;
1048
1050 LUASCRIPT_CHECK_SELF(L, ptile, FALSE);
1051 LUASCRIPT_CHECK_ARG_NIL(L, pplayer, 3, Player, FALSE);
1052
1053 if (map_is_known_and_seen(ptile, pplayer, V_MAIN)) {
1054 /* Can't hide currently seen tile */
1055 return FALSE;
1056 }
1057
1058 pcity = tile_city(ptile);
1059
1060 if (pcity != NULL) {
1061 trade_partners_iterate(pcity, partner) {
1062 if (really_gives_vision(pplayer, city_owner(partner))) {
1063 /* Can't remove vision about trade partner */
1064 return FALSE;
1065 }
1067 }
1068
1069 dbv_clr(&pplayer->tile_known, tile_index(ptile));
1070
1071 send_tile_info(pplayer->connections, ptile, TRUE);
1072
1073 return TRUE;
1074}
1075
1076/**********************************************************************/
1080 int effect)
1081{
1085 2, "invalid climate change type");
1086 LUASCRIPT_CHECK_ARG(L, effect > 0, 3, "effect must be greater than zero");
1087
1089}
1090
1091/**********************************************************************/
1095{
1097 LUASCRIPT_CHECK_ARG_NIL(L, pplayer, 2, Player, NULL);
1099 3, "must be a percentage", NULL);
1100
1101 if (!civil_war_possible(pplayer, FALSE, FALSE)) {
1102 return NULL;
1103 }
1104
1105 if (probability == 0) {
1106 /* Calculate chance with normal rules */
1107 if (!civil_war_triggered(pplayer)) {
1108 return NULL;
1109 }
1110 } else {
1111 /* Fixed chance specified by script */
1112 if (fc_rand(100) >= probability) {
1113 return NULL;
1114 }
1115 }
1116
1117 return civil_war(pplayer);
1118}
1119
1120/**********************************************************************/
1124{
1126 LUASCRIPT_CHECK_SELF(L, pplayer);
1127
1129}
1130
1131/**********************************************************************/
1135 int movecost,
1136 Unit *embark_to, bool disembark,
1137 bool conquer_city, bool conquer_extra,
1138 bool enter_hut, bool frighten_hut)
1139{
1142 LUASCRIPT_CHECK_ARG_NIL(L, ptile, 3, Tile, FALSE);
1143 LUASCRIPT_CHECK_ARG(L, movecost >= 0, 4, "Negative move cost!", FALSE);
1144
1146 "Can't both enter and frighten a hut at the same time",
1147 TRUE);
1148
1149 if (!disembark && unit_transported(punit)) {
1150 /* Can't leave the transport. */
1151 return TRUE;
1152 }
1153
1155 unit_tile(punit), ptile, TRUE,
1156 FALSE, embark_to, TRUE) != MR_OK) {
1157 /* Can't move to target. Return that unit is still alive. */
1158 return TRUE;
1159 }
1160
1161 return unit_move(punit, ptile, movecost,
1165}
1166
1167/**********************************************************************/
1171{
1174
1175 if (punit != NULL) {
1176 punit->stay = TRUE;
1177 }
1178}
1179
1180/**********************************************************************/
1184{
1187
1188 if (punit != NULL) {
1189 punit->stay = FALSE;
1190 }
1191}
1192
1193/**********************************************************************/
1197{
1199 LUASCRIPT_CHECK_SELF(L, pcity);
1200
1201 pcity->history += amount;
1202}
1203
1204/**********************************************************************/
1208{
1210 LUASCRIPT_CHECK_SELF(L, pplayer);
1211
1212 pplayer->history += amount;
1213}
1214
1215/**********************************************************************/
1227 Tech_Type *tech)
1228{
1229 struct research *presearch;
1230
1232 LUASCRIPT_CHECK_SELF(L, pplayer);
1233 presearch = research_get(pplayer);
1235
1236 if (!tech) {
1237 update_bulbs(pplayer, amount, TRUE, TRUE);
1238
1240 } else if (advance_number(tech) == presearch->researching) {
1241 update_bulbs(pplayer, amount, TRUE, FALSE);
1242 /* Clean the saved tech to get no surprizes switching */
1243 presearch->researching_saved = A_UNKNOWN;
1244
1246 } else {
1247 /* Sometimes we may set negative bulbs, it's normal though lurking */
1249 presearch->inventions[advance_number(tech)].bulbs_researched_saved
1250 += amount;
1251 /* Currently, multiresearch data are not sent to clients */
1252 } else {
1253 int oldb = presearch->bulbs_researched;
1254
1255 /* NOTE: We can set a tech we already know / can't research here.
1256 * Probably it's safe as we can't switch into it any way. */
1257 if (presearch->researching_saved != advance_number(tech)) {
1258 presearch->researching_saved = advance_number(tech);
1259 presearch->bulbs_researching_saved
1260 = amount + presearch->free_bulbs;
1261 } else {
1262 presearch->bulbs_researching_saved
1263 += amount + presearch->free_bulbs;
1264 }
1265 /* For consistency, modify current bulbs alongside
1266 * (sometimes getting into "overresearch" situation, but ok) */
1267 presearch->bulbs_researched = amount
1268 - amount * game.server.techpenalty / 100 + presearch->free_bulbs;
1269 if (oldb != presearch->bulbs_researched) {
1271 }
1272 }
1273 }
1274}
enum action_actor_kind action_get_actor_kind(const struct action *paction)
Definition actions.c:1859
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:4006
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:4082
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:3841
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:3918
enum action_target_kind action_get_target_kind(const struct action *paction)
Definition actions.c:1869
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:4231
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:4159
#define action_has_result(_act_, _res_)
Definition actions.h:431
const char * default_ai_type_name(void)
Definition aiiface.c:251
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)
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_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)
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_create_city(lua_State *L, Player *pplayer, Tile *ptile, const char *name)
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_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:167
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:1240
void city_remove_improvement(struct city *pcity, const struct impr_type *pimprove)
Definition city.c:3371
#define city_owner(_pcity_)
Definition city.h:563
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:2363
struct city * build_or_move_building(struct city *pcity, struct impr_type *pimprove, struct player **oldcity_owner)
Definition citytools.c:3019
void remove_city(struct city *pcity)
Definition citytools.c:1708
bool create_city_for_player(struct player *pplayer, struct tile *ptile, const char *name)
Definition citytools.c:1680
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:1076
void auto_arrange_workers(struct city *pcity)
Definition cityturn.c:367
bool city_refresh(struct city *pcity)
Definition cityturn.c:159
static struct ai_type * self
Definition classicai.c:45
char * incite_cost
Definition comments.c:75
static void conquer_city(QVariant data1, QVariant data2)
Definition dialogs.cpp:1850
static void enter_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2655
static void frighten_hut(QVariant data1, QVariant data2)
Definition dialogs.cpp:2685
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
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:74
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:377
#define MAX_LEN_NAME
Definition fc_types.h:66
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:92
#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:907
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:191
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_ret_val(condition, val)
Definition log.h:194
#define fc_assert_action(condition, action)
Definition log.h:187
@ LOG_ERROR
Definition log.h:30
@ LOG_NORMAL
Definition log.h:32
#define log_error(message,...)
Definition log.h:103
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:940
void assign_continent_numbers(void)
bool really_gives_vision(struct player *me, struct player *them)
Definition maphand.c:345
void send_tile_info(struct conn_list *dest, struct tile *ptile, bool send_unknown)
Definition maphand.c:491
void send_all_known_tiles(struct conn_list *dest)
Definition maphand.c:444
bool need_to_reassign_continents(const struct terrain *oldter, const struct terrain *newter)
Definition maphand.c:1937
void climate_change(bool warming, int effect)
Definition maphand.c:133
void create_extra(struct tile *ptile, struct extra_type *pextra, struct player *pplayer)
Definition maphand.c:2556
void map_show_tile(struct player *src_player, struct tile *ptile)
Definition maphand.c:768
void tile_change_side_effects(struct tile *ptile, bool refresh_city)
Definition maphand.c:2724
bool map_is_known_and_seen(const struct tile *ptile, const struct player *pplayer, enum vision_layer vlayer)
Definition maphand.c:920
void fix_tile_on_terrain_change(struct tile *ptile, struct terrain *oldter, bool extend_rivers)
Definition maphand.c:1975
void update_tile_knowledge(struct tile *ptile)
Definition maphand.c:1439
bool can_exist_at_tile(const struct civ_map *nmap, const struct unit_type *utype, const struct tile *ptile)
Definition movement.c:279
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:662
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:351
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:806
@ 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:1405
void player_status_add(struct player *plr, enum player_status pstatus)
Definition plrhand.c:3213
bool civil_war_triggered(struct player *pplayer)
Definition plrhand.c:2956
void send_player_info_c(struct player *src, struct conn_list *dest)
Definition plrhand.c:1146
struct player * civil_war(struct player *pplayer)
Definition plrhand.c:3006
bool civil_war_possible(struct player *pplayer, bool conquering_city, bool honour_server_option)
Definition plrhand.c:2909
#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:273
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 MAX(x, y)
Definition shared.h:54
bool game_was_started(void)
Definition srv_main.c:349
enum server_states server_state(void)
Definition srv_main.c:333
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:812
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:996
int mod
Definition traits.h:39
Definition city.h:320
int history
Definition city.h:410
int id
Definition city.h:326
bool multiresearch
Definition game.h:167
int diplbulbcost
Definition game.h:143
int conquercost
Definition game.h:140
int freecost
Definition game.h:152
struct civ_game::@31::@35 server
int techpenalty
Definition game.h:200
int id
Definition extras.h:89
struct ai_trait * traits
Definition player.h:124
int infra_points
Definition player.h:65
struct player_ai ai_common
Definition player.h:286
struct dbv tile_known
Definition player.h:308
struct conn_list * connections
Definition player.h:296
struct player_economic economic
Definition player.h:282
int history
Definition player.h:314
Definition tile.h:50
Definition unit.h:138
int moves_left
Definition unit.h:150
int id
Definition unit.h:145
bool stay
Definition unit.h:205
enum direction8 facing
Definition unit.h:142
int homecity
Definition unit.h:146
int veteran
Definition unit.h:152
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
bool is_future_tech(Tech_type_id tech)
Definition tech.c:281
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
#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:1388
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:654
#define terrain_has_flag(terr, flag)
Definition terrain.h:283
void tile_change_terrain(struct tile *ptile, struct terrain *pterrain)
Definition tile.c:496
bool tile_extra_rm_apply(struct tile *ptile, struct extra_type *tgt)
Definition tile.c:601
bool tile_set_label(struct tile *ptile, const char *label)
Definition tile.c:1095
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:88
#define tile_terrain(_tile)
Definition tile.h:114
#define tile_has_extra(ptile, pextra)
Definition tile.h:151
#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:1964
void unit_virtual_destroy(struct unit *punit)
Definition unit.c:1737
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2433
bool unit_has_orders(const struct unit *punit)
Definition unit.c:210
bool could_unit_be_in_transport(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:676
#define unit_tile(_pu)
Definition unit.h:397
#define unit_owner(_pu)
Definition unit.h:396
@ UU_OK
Definition unit.h:61
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:432
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:3313
void place_partisans(struct tile *pcenter, struct player *powner, int count, int sq_radius)
Definition unittools.c:1158
void transform_unit(struct unit *punit, const struct unit_type *to_unit, int vet_loss)
Definition unittools.c:1546
void send_unit_info(struct conn_list *dest, struct unit *punit)
Definition unittools.c:2723
bool place_unit(struct unit *punit, struct player *pplayer, struct city *pcity, struct unit *ptrans, bool force)
Definition unittools.c:1706
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:1658
void wipe_unit(struct unit *punit, enum unit_loss_reason reason, struct player *killer)
Definition unittools.c:2132
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:3919
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
struct unit_type * unit_type_array_first(void)
Definition unittype.c:58
int num_role_units(int role)
Definition unittype.c:2203
bool utype_player_already_has_this_unique(const struct player *pplayer, const struct unit_type *putype)
Definition unittype.c:1927
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1703
int utype_veteran_levels(const struct unit_type *punittype)
Definition unittype.c:2625
const char * utype_rule_name(const struct unit_type *punittype)
Definition unittype.c:1578
const struct unit_type * unit_type_array_last(void)
Definition unittype.c:69