Freeciv-3.2
Loading...
Searching...
No Matches
edithand.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#include <limits.h> /* USHRT_MAX */
19
20/* utility */
21#include "bitvector.h"
22#include "fcintl.h"
23#include "log.h"
24#include "shared.h"
25#include "support.h"
26
27/* common */
28#include "events.h"
29#include "game.h"
30#include "government.h"
31#include "map.h"
32#include "movement.h"
33#include "nation.h"
34#include "terrain.h"
35#include "research.h"
36#include "unitlist.h"
37
38/* server */
39#include "aiiface.h"
40#include "citytools.h"
41#include "cityturn.h"
42#include "connecthand.h"
43#include "gamehand.h"
44#include <hand_gen.h> /* <> so looked from the build directory first. */
45#include "maphand.h"
46#include "plrhand.h"
47#include "notify.h"
48#include "sanitycheck.h"
49#include "stdinhand.h"
50#include "techtools.h"
51#include "unittools.h"
52
53/* server/generator */
54#include "mapgen_utils.h"
55
56/* server/savegame */
57#include "savemain.h"
58
59#include "edithand.h"
60
61/* Set if anything in a sequence of edits triggers the expensive
62 * assign_continent_numbers() check, which will be done once when the
63 * sequence is complete. */
65/* Hold pointers to tiles which were changed during the edit sequence,
66 * so that they can be sanity-checked when the sequence is complete
67 * and final global fix-ups have been done. */
68static struct tile_hash *modified_tile_table = NULL;
69
70/* Array of size player_slot_count() indexed by player
71 * number to tell whether a given player has fog of war
72 * disabled in edit mode. */
73static bool *unfogged_players;
74
75/************************************************************************/
92
93/************************************************************************/
108
109/************************************************************************/
113{
116
117 if (NULL == dest) {
118 dest = game.est_connections;
119 }
120
121 /* Send map start positions. */
124 startpos.removal = FALSE;
125 startpos.tag = 0;
126
128
129 conn_list_iterate(dest, pconn) {
130 if (can_conn_edit(pconn)) {
133 }
136}
137
138/************************************************************************/
143{
148
149 /* FIXME: adv / ai phase handling like in check_terrain_change() */
150 }
151
152#ifdef SANITY_CHECKING
154 sanity_check_tile(ptile);
156#endif /* SANITY_CHECKING */
158}
159
160/************************************************************************/
164static void check_leaving_edit_mode(void)
165{
166 bool unfogged;
167
169 players_iterate(pplayer) {
171 if (unfogged && game.info.fogofwar) {
173 } else if (!unfogged && !game.info.fogofwar) {
175 }
177
178 /* Clear the whole array. */
179 memset(unfogged_players, 0, player_slot_count() * sizeof(bool));
180
183}
184
185/************************************************************************/
188void handle_edit_mode(struct connection *pc, bool is_edit_mode)
189{
191 return;
192 }
193
194 if (!game.info.is_edit_mode && is_edit_mode) {
195 /* Someone could be cheating! Warn people. */
197 _(" *** Server set to edit mode by %s! *** "),
199 }
200
201 if (game.info.is_edit_mode && !is_edit_mode) {
203 _(" *** Edit mode canceled by %s. *** "),
205
207 }
208
209 if (game.info.is_edit_mode != is_edit_mode) {
210 game.info.is_edit_mode = is_edit_mode;
211
214 }
215}
216
217/************************************************************************/
221static bool edit_tile_terrain_handling(struct tile *ptile,
222 struct terrain *pterrain,
223 bool send_info)
224{
225 struct terrain *old_terrain = tile_terrain(ptile);
226
227 if (old_terrain == pterrain
228 || (terrain_has_flag(pterrain, TER_NO_CITIES)
229 && NULL != tile_city(ptile))) {
230 return FALSE;
231 }
232
233 tile_change_terrain(ptile, pterrain);
238 }
239
240 if (send_info) {
242 }
243
245
246 return TRUE;
247}
248
249/************************************************************************/
253static bool edit_tile_extra_handling(struct tile *ptile,
254 struct extra_type *pextra,
255 bool remove_mode, bool send_info)
256{
257 if (remove_mode) {
258 if (!tile_has_extra(ptile, pextra)) {
259 return FALSE;
260 }
261
262 if (!tile_extra_rm_apply(ptile, pextra)) {
263 return FALSE;
264 }
265
266 terrain_changed(ptile);
267
268 } else {
269 if (tile_has_extra(ptile, pextra)) {
270 return FALSE;
271 }
272
273 if (!tile_extra_apply(ptile, pextra)) {
274 return FALSE;
275 }
276
278 && terrain_has_resource(ptile->terrain, pextra)) {
279 tile_set_resource(ptile, pextra);
280 }
281 }
282
283 if (send_info) {
285 }
286
288
289 return TRUE;
290}
291
292/************************************************************************/
300{
301 struct terrain *pterrain;
302 struct tile *ptile_center;
303
305 if (!ptile_center) {
307 _("Cannot edit the tile because %d is not a valid "
308 "tile index on this map!"), tile);
309 return;
310 }
311
312 pterrain = terrain_by_number(terrain);
313 if (!pterrain) {
315 /* TRANS: ..." the tile <tile-coordinates> because"... */
316 _("Cannot modify terrain for the tile %s because "
317 "%d is not a valid terrain id."),
319 return;
320 }
321
323 /* This iterates outward, which gives any units that can't survive on
324 * changed terrain the best chance of survival. */
325 square_iterate(&(wld.map), ptile_center, size - 1, ptile) {
326 edit_tile_terrain_handling(ptile, pterrain, TRUE);
329}
330
331/************************************************************************/
336 int id, bool removal, int eowner, int size)
337{
338 struct tile *ptile_center;
339 struct player *plr_eowner;
340
342 if (!ptile_center) {
344 _("Cannot edit the tile because %d is not a valid "
345 "tile index on this map!"), tile);
346 return;
347 }
348
351 /* TRANS: ..." the tile <tile-coordinates> because"... */
352 _("Cannot modify extras for the tile %s because "
353 "%d is not a valid extra id."),
355 return;
356 }
357
358 if (eowner != MAP_TILE_OWNER_NULL) {
360 } else {
362 }
363
365 square_iterate(&(wld.map), ptile_center, size - 1, ptile) {
366 ptile->extras_owner = plr_eowner;
367 edit_tile_extra_handling(ptile, extra_by_number(id), removal, TRUE);
370}
371
372/************************************************************************/
376 const struct packet_edit_tile *packet)
377{
378 struct tile *ptile;
379 struct player *eowner;
380 bool changed = FALSE;
381
382 ptile = index_to_tile(&(wld.map), packet->tile);
383 if (!ptile) {
385 _("Cannot edit the tile because %d is not a valid "
386 "tile index on this map!"), packet->tile);
387 return;
388 }
389
390 if (packet->eowner != MAP_TILE_OWNER_NULL) {
391 eowner = player_by_number(packet->eowner);
392 } else {
393 eowner = NULL;
394 }
395
396 /* Handle changes in extras. */
397 if (!BV_ARE_EQUAL(packet->extras, ptile->extras)) {
398 extra_type_iterate(pextra) {
399 if (edit_tile_extra_handling(ptile, pextra,
400 !BV_ISSET(packet->extras, extra_number(pextra)),
401 FALSE)) {
402 changed = TRUE;
403 }
405 }
406
407 if (ptile->extras_owner != eowner) {
408 ptile->extras_owner = eowner;
409 changed = TRUE;
410 }
411
412 /* Handle changes in label */
413 if (tile_set_label(ptile, packet->label)) {
414 changed = TRUE;
415 }
416
417 /* TODO: Handle more property edits. */
418
419
420 /* Send the new state to all affected. */
421 if (changed) {
423 send_tile_info(NULL, ptile, FALSE);
424 }
425
427}
428
429/************************************************************************/
434 Unit_type_id utid, int count, int tag)
435{
436 struct tile *ptile;
437 struct unit_type *punittype;
438 struct player *pplayer;
439 struct city *homecity;
440 struct unit *punit;
441 int id, i;
442
443 ptile = index_to_tile(&(wld.map), tile);
444 if (!ptile) {
446 _("Cannot create units because %d is not a valid "
447 "tile index on this map!"), tile);
448 return;
449 }
450
452 if (!punittype) {
453 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
454 /* TRANS: ..." at <tile-coordinates> because"... */
455 _("Cannot create a unit at %s because the "
456 "given unit type id %d is invalid."),
457 tile_link(ptile), utid);
458 return;
459 }
460
461 pplayer = player_by_number(owner);
462 if (!pplayer) {
463 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
464 /* TRANS: ..." type <unit-type> at <tile-coordinates>"... */
465 _("Cannot create a unit of type %s at %s "
466 "because the given owner's player id %d is "
467 "invalid."), utype_name_translation(punittype),
468 tile_link(ptile), owner);
469 return;
470 }
471
474 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
475 _("Cannot create another instance of unique unit type %s. "
476 "Player already has one such unit."),
478 return;
479 }
480 if (count > 1) {
481 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
482 _("Cannot create multiple instances of unique unit type %s."),
484 return;
485 }
486 }
487
488 if (is_non_allied_unit_tile(ptile, pplayer)
489 || (tile_city(ptile)
490 && !pplayers_allied(pplayer, city_owner(tile_city(ptile))))) {
491 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
492 /* TRANS: ..." type <unit-type> on enemy tile
493 * <tile-coordinates>"... */
494 _("Cannot create unit of type %s on enemy tile "
496 tile_link(ptile));
497 return;
498 }
499
500 if (!can_exist_at_tile(&(wld.map), punittype, ptile)) {
501 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
502 /* TRANS: ..." type <unit-type> on the terrain at
503 * <tile-coordinates>"... */
504 _("Cannot create a unit of type %s on the terrain "
505 "at %s."),
507 return;
508 }
509
510 if (count > 0 && !pplayer->is_alive) {
511 pplayer->is_alive = TRUE;
512 send_player_info_c(pplayer, NULL);
513 }
514
515 homecity = find_closest_city(ptile, NULL, pplayer, FALSE, FALSE, FALSE,
517 id = homecity ? homecity->id : 0;
518
520 map_show_circle(pplayer, ptile, punittype->vision_radius_sq);
521 for (i = 0; i < count; i++) {
522 /* As far as I can see create_unit is guaranteed to
523 * never return NULL. */
524 punit = create_unit(pplayer, ptile, punittype, 0, id, -1);
525 if (tag > 0) {
527 }
528 }
530}
531
532/************************************************************************/
537 int tile, Unit_type_id utid, int count)
538{
539 struct tile *ptile;
540 struct unit_type *punittype;
541 struct player *pplayer;
542 int i;
543
544 ptile = index_to_tile(&(wld.map), tile);
545 if (!ptile) {
547 _("Cannot remove units because %d is not a valid "
548 "tile index on this map!"), tile);
549 return;
550 }
551
553 if (!punittype) {
554 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
555 /* TRANS: ..." at <tile-coordinates> because"... */
556 _("Cannot remove a unit at %s because the "
557 "given unit type id %d is invalid."),
558 tile_link(ptile), utid);
559 return;
560 }
561
562 pplayer = player_by_number(owner);
563 if (!pplayer) {
564 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
565 /* TRANS: ..." type <unit-type> at <tile-coordinates>
566 * because"... */
567 _("Cannot remove a unit of type %s at %s "
568 "because the given owner's player id %d is "
569 "invalid."), utype_name_translation(punittype),
570 tile_link(ptile), owner);
571 return;
572 }
573
574 i = 0;
576 if (i >= count) {
577 break;
578 }
580 || unit_owner(punit) != pplayer) {
581 continue;
582 }
584 i++;
586}
587
588/************************************************************************/
592{
593 struct unit *punit;
594
596 if (!punit) {
598 _("No such unit (ID %d)."), id);
599 return;
600 }
601
603}
604
605/************************************************************************/
609 const struct packet_edit_unit *packet)
610{
611 const struct unit_type *putype;
612 struct unit *punit;
613 int id;
614 bool changed = FALSE;
615 int fuel, hp;
616
617 id = packet->id;
619 if (!punit) {
621 _("No such unit (ID %d)."), id);
622 return;
623 }
624
626
627 if (packet->moves_left != punit->moves_left) {
628 punit->moves_left = packet->moves_left;
629 changed = TRUE;
630 }
631
632 fuel = CLIP(0, packet->fuel, utype_fuel(putype));
633 if (fuel != punit->fuel) {
634 punit->fuel = fuel;
635 changed = TRUE;
636 }
637
638 if (packet->moved != punit->moved) {
639 punit->moved = packet->moved;
640 changed = TRUE;
641 }
642
643 if (packet->done_moving != punit->done_moving) {
644 punit->done_moving = packet->done_moving;
645 changed = TRUE;
646 }
647
648 hp = CLIP(1, packet->hp, putype->hp);
649 if (hp != punit->hp) {
650 punit->hp = hp;
651 changed = TRUE;
652 }
653
654 if (packet->veteran != punit->veteran) {
655 int v = packet->veteran;
656 if (!utype_veteran_level(putype, v)) {
658 _("Invalid veteran level %d for unit %d (%s)."),
659 v, id, unit_link(punit));
660 } else {
661 punit->veteran = v;
662 changed = TRUE;
663 }
664 }
665
666 if (packet->stay != punit->stay) {
667 punit->stay = packet->stay;
668 changed = TRUE;
669 }
670
671 /* TODO: Handle more property edits. */
672
673
674 /* Send the new state to all affected. */
675 if (changed) {
677 }
678}
679
680/************************************************************************/
685 int size, int tag)
686{
687 struct tile *ptile;
688 struct city *pcity;
689 struct player *pplayer;
690
691 ptile = index_to_tile(&(wld.map), tile);
692 if (!ptile) {
694 _("Cannot create a city because %d is not a valid "
695 "tile index on this map!"), tile);
696 return;
697 }
698
699 pplayer = player_by_number(owner);
700 if (!pplayer) {
701 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
702 /* TRANS: ..." at <tile-coordinates> because"... */
703 _("Cannot create a city at %s because the "
704 "given owner's player id %d is invalid"),
705 tile_link(ptile), owner);
706 return;
707
708 }
709
711
712 if (!create_city_for_player(pplayer, ptile, NULL)) {
713 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
714 /* TRANS: ..." at <tile-coordinates>." */
715 _("A city may not be built at %s."), tile_link(ptile));
717
718 return;
719 }
720
721 pcity = tile_city(ptile);
722
723 if (size > 1) {
724 /* FIXME: Slow and inefficient for large size changes. */
725 city_change_size(pcity, CLIP(1, size, MAX_CITY_SIZE), pplayer, NULL);
726 send_city_info(NULL, pcity);
727 }
728
729 if (tag > 0) {
731 }
732
734}
735
736
737/************************************************************************/
741 const struct packet_edit_city *packet)
742{
743 struct tile *ptile;
744 struct city *pcity, *oldcity;
745 struct player *pplayer;
746 char buf[1024];
747 int id;
748 bool changed = FALSE;
749 bool need_game_info = FALSE;
751
752 pcity = game_city_by_number(packet->id);
753 if (!pcity) {
755 _("Cannot edit city with invalid city ID %d."),
756 packet->id);
757 return;
758 }
759
760 pplayer = city_owner(pcity);
761 ptile = city_tile(pcity);
763
764 /* Handle name change. */
765 if (0 != strcmp(pcity->name, packet->name)) {
766 if (!is_allowed_city_name(pplayer, packet->name, buf, sizeof(buf))) {
767 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
768 _("Cannot edit city name: %s"), buf);
769 } else {
770 city_name_set(pcity, packet->name);
771 changed = TRUE;
772 }
773 }
774
775 /* Handle size change. */
776 if (packet->size != city_size_get(pcity)) {
777 if (!(0 < packet->size && packet->size <= MAX_CITY_SIZE)) {
778 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
779 _("Invalid city size %d for city %s."),
780 packet->size, city_link(pcity));
781 } else {
782 /* FIXME: Slow and inefficient for large size changes. */
783 city_change_size(pcity, packet->size, NULL, NULL);
784 changed = TRUE;
785 }
786 }
787
788 if (packet->history != pcity->history) {
789 pcity->history = packet->history;
790 changed = TRUE;
791 }
792
793 /* Handle city improvement changes. */
794 improvement_iterate(pimprove) {
795 oldcity = NULL;
796 id = improvement_number(pimprove);
797
798 if (is_special_improvement(pimprove)) {
799 if (packet->built[id] >= 0) {
800 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
801 _("It is impossible for a city to have %s!"),
803 }
804 continue;
805 }
806
807 /* FIXME: game.info.great_wonder_owners and pplayer->wonders
808 * logic duplication with city_build_building. */
809
810 if (city_has_building(pcity, pimprove) && packet->built[id] < 0) {
811
812 city_remove_improvement(pcity, pimprove);
813 changed = TRUE;
814
815 } else if (!city_has_building(pcity, pimprove)
816 && packet->built[id] >= 0) {
817 struct player *old_owner = NULL;
818
819 oldcity = build_or_move_building(pcity, pimprove, &old_owner);
820 if (oldcity != pcity) {
822 }
823 if (oldcity && old_owner != pplayer) {
824 /* Great wonders make more changes. */
826 if (old_owner) {
828 }
829 }
830
831 if (oldcity) {
833 }
834 changed = TRUE;
835 }
837
838 /* Handle food stock change. */
839 if (packet->food_stock != pcity->food_stock) {
840 int max = city_granary_size(city_size_get(pcity));
841 if (!(0 <= packet->food_stock && packet->food_stock <= max)) {
842 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
843 _("Invalid city food stock amount %d for city %s "
844 "(allowed range is %d to %d)."),
845 packet->food_stock, city_link(pcity), 0, max);
846 } else {
847 pcity->food_stock = packet->food_stock;
848 changed = TRUE;
849 }
850 }
851
852 /* Handle shield stock change. */
853 if (packet->shield_stock != pcity->shield_stock) {
854 int max = USHRT_MAX; /* Limited to uint16 by city info packet. */
855
856 if (!(0 <= packet->shield_stock && packet->shield_stock <= max)) {
857 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
858 _("Invalid city shield stock amount %d for city %s "
859 "(allowed range is %d to %d)."),
860 packet->shield_stock, city_link(pcity), 0, max);
861 } else {
862 pcity->shield_stock = packet->shield_stock;
863 /* Make sure the shields stay if changing production back and forth */
864 pcity->before_change_shields = packet->shield_stock;
865 changed = TRUE;
866 }
867 }
868
869 /* TODO: Handle more property edits. */
870
871
872 if (changed) {
876
877 /* FIXME: city_refresh_queue_processing only sends to city owner? */
878 send_city_info(NULL, pcity);
879
881 }
882
883 /* Update wonder infos. */
884 if (need_game_info) {
886 }
890 /* No need to send to detached connections. */
892 }
894 }
895}
896
897/************************************************************************/
901{
902 struct player *pplayer;
903 struct nation_type *pnation;
904 struct research *presearch;
905 int existing = player_count();
906
907 if (existing >= player_slot_count()) {
909 _("No more players can be added because the maximum "
910 "number of players (%d) has been reached."),
912 return;
913 }
914
917 _("No more players can be added because there's "
918 "already maximum number of players allowed by maxplayers setting (value %d)"),
920 return;
921 }
922
923 if (existing >= nation_count() ) {
925 _("No more players can be added because there are "
926 "no available nations (%d used)."),
927 nation_count());
928 return;
929 }
930
932 if (!pnation) {
934 _("Player cannot be created because random nation "
935 "selection failed."));
936 return;
937 }
938
940 NULL, FALSE);
941 if (!pplayer) {
943 _("Player creation failed."));
944 return;
945 }
946 server_player_init(pplayer, TRUE, TRUE);
947
948 player_nation_defaults(pplayer, pnation, TRUE);
949 if (game_was_started()) {
950 /* Find a color for the new player. */
952 }
954 pplayer->unassigned_user = TRUE;
955 pplayer->is_connected = FALSE;
956 pplayer->government = init_government_of_nation(pnation);
957 BV_CLR(pplayer->flags, PLRF_FIRST_CITY);
958
959 pplayer->economic.gold = 0;
960 pplayer->economic.infra_points = 0;
962
963 presearch = research_get(pplayer);
966
967 send_player_all_c(pplayer, NULL);
968 /* Send research info after player info, else the client will complain
969 * about invalid team. */
971 if (tag > 0) {
973 }
974}
975
976/************************************************************************/
980{
981 struct player *pplayer;
982
983 pplayer = player_by_number(id);
984 if (pplayer == NULL) {
986 _("No such player (ID %d)."), id);
987 return;
988 }
989
990 /* Don't use conn_list_iterate here because connection_detach() can be
991 * recursive and free the next connection pointer. */
992 while (conn_list_size(pplayer->connections) > 0) {
994 }
995
996 kill_player(pplayer);
997 server_remove_player(pplayer);
998}
999
1000/************************************************************************/
1004 const struct packet_edit_player *packet)
1005{
1006 struct player *pplayer;
1007 bool changed = FALSE, update_research = FALSE;
1008 struct nation_type *pnation;
1009 struct research *research;
1010 enum tech_state known;
1011 struct government *gov;
1012
1013 pplayer = player_by_number(packet->id);
1014 if (!pplayer) {
1016 _("Cannot edit player with invalid player ID %d."),
1017 packet->id);
1018 return;
1019 }
1020
1021 research = research_get(pplayer);
1022
1023
1024 /* Handle player name change. */
1025 if (0 != strcmp(packet->name, player_name(pplayer))) {
1026 char error_buf[256];
1027
1028 if (server_player_set_name_full(pc, pplayer, NULL, packet->name,
1029 error_buf, sizeof(error_buf))) {
1030 changed = TRUE;
1031 } else {
1033 _("Cannot change name of player (%d) '%s' to '%s': %s"),
1034 player_number(pplayer), player_name(pplayer),
1035 packet->name, error_buf);
1036 }
1037 }
1038
1039 /* Handle nation change. */
1040 pnation = nation_by_number(packet->nation);
1041 if (nation_of_player(pplayer) != pnation) {
1042 if (pnation == NULL) {
1044 _("Cannot change nation for player %d (%s) "
1045 "because the given nation ID %d is invalid."),
1046 player_number(pplayer), player_name(pplayer),
1047 packet->nation);
1048 } else if (pnation->player != NULL) {
1050 _("Cannot change nation for player %d (%s) "
1051 "to nation %d (%s) because that nation is "
1052 "already assigned to player %d (%s)."),
1053 player_number(pplayer), player_name(pplayer),
1054 packet->nation, nation_plural_translation(pnation),
1055 player_number(pnation->player),
1056 player_name(pnation->player));
1057 } else if (!nation_is_in_current_set(pnation)) {
1059 _("Cannot change nation for player %d (%s) "
1060 "to nation %d (%s) because that nation is "
1061 "not in the current nation set."),
1062 player_number(pplayer), player_name(pplayer),
1063 packet->nation, nation_plural_translation(pnation));
1064 } else if (pplayer->ai_common.barbarian_type
1065 != nation_barbarian_type(pnation)
1066 || (!is_barbarian(pplayer) && !is_nation_playable(pnation))) {
1068 _("Cannot change nation for player %d (%s) "
1069 "to nation %d (%s) because that nation is "
1070 "unsuitable for this player."),
1071 player_number(pplayer), player_name(pplayer),
1072 packet->nation, nation_plural_translation(pnation));
1073 } else {
1074 changed = player_set_nation(pplayer, pnation);
1075 }
1076 }
1077
1078 /* Handle a change in research progress. */
1079 if (packet->bulbs_researched != research->bulbs_researched) {
1081 changed = TRUE;
1083 }
1084
1085 /* Handle a change in known inventions. */
1087 known = research_invention_state(research, tech);
1088 if ((packet->inventions[tech] && known == TECH_KNOWN)
1089 || (!packet->inventions[tech] && known != TECH_KNOWN)) {
1090 continue;
1091 }
1092 if (packet->inventions[tech]) {
1093 /* FIXME: Side-effect modifies game.info.global_advances. */
1096 } else {
1099 }
1100 changed = TRUE;
1103
1104 /* Handle a change in the player's gold. */
1105 if (packet->gold != pplayer->economic.gold) {
1106 if (!(0 <= packet->gold && packet->gold <= 1000000)) {
1108 _("Cannot set gold for player %d (%s) because "
1109 "the value %d is outside the allowed range."),
1110 player_number(pplayer), player_name(pplayer),
1111 packet->gold);
1112 } else {
1113 pplayer->economic.gold = packet->gold;
1114 changed = TRUE;
1115 }
1116 }
1117
1118 /* Handle a change in the player's autoselect weight. */
1119 if (packet->autoselect_weight != pplayer->autoselect_weight) {
1120 pplayer->autoselect_weight = packet->autoselect_weight;
1121 changed = TRUE;
1122 }
1123
1124 /* Handle player government change */
1125 gov = government_by_number(packet->government);
1126 if (gov != pplayer->government) {
1128 government_change(pplayer, gov, FALSE);
1129 } else {
1130 int turns = revolution_length(gov, pplayer);
1131
1132 if (turns >= 0) {
1133 pplayer->government = gov;
1134 pplayer->revolution_finishes = game.info.turn + turns;
1135 }
1136 }
1137
1138 changed = TRUE;
1139 }
1140
1141 if (packet->scenario_reserved) {
1142 if (!player_has_flag(pplayer, PLRF_SCENARIO_RESERVED)) {
1143 changed = TRUE;
1145 }
1146 } else {
1148 changed = TRUE;
1150 }
1151 }
1152
1153 /* TODO: Handle more property edits. */
1154
1155 if (update_research) {
1156 Tech_type_id current, goal;
1157
1159
1160 /* FIXME: Modifies struct research directly. */
1161
1162 current = research->researching;
1163 goal = research->tech_goal;
1164
1165 if (current != A_UNSET) {
1166 if (current != A_FUTURE) {
1167 known = research_invention_state(research, current);
1168 if (known != TECH_PREREQS_KNOWN) {
1170 }
1171 } else {
1172 /* Future Tech is legal only if all techs are known */
1175 if (known != TECH_KNOWN) {
1177 break;
1178 }
1180 }
1181 }
1182 if (goal != A_UNSET) {
1183 if (goal != A_FUTURE) {
1184 known = research_invention_state(research, goal);
1185 if (known == TECH_KNOWN) {
1187 }
1188 }
1189 }
1190 changed = TRUE;
1191
1192 /* Inform everybody about global advances */
1195 }
1196
1197 if (changed) {
1198 send_player_all_c(pplayer, NULL);
1199 }
1200}
1201
1202/************************************************************************/
1206 int tile, bool known, int size)
1207{
1208 struct player *pplayer;
1209 struct tile *ptile_center;
1210
1212 if (!ptile_center) {
1214 _("Cannot edit vision because %d is not a valid "
1215 "tile index on this map!"), tile);
1216 return;
1217 }
1218
1219 pplayer = player_by_number(plr_no);
1220 if (!pplayer) {
1222 /* TRANS: ..." at <tile-coordinates> because"... */
1223 _("Cannot edit vision for the tile at %s because "
1224 "given player id %d is invalid."),
1226 return;
1227 }
1228
1230 square_iterate(&(wld.map), ptile_center, size - 1, ptile) {
1231
1232 if (!known) {
1233 struct city *pcity = tile_city(ptile);
1235
1236 if (pcity && city_owner(pcity) == pplayer) {
1237 continue;
1238 }
1239
1240 unit_list_iterate(ptile->units, punit) {
1241 if (unit_owner(punit) == pplayer
1242 || really_gives_vision(pplayer, unit_owner(punit))) {
1244 break;
1245 }
1247
1248 if (cannot_make_unknown) {
1249 continue;
1250 }
1251
1252 /* The client expects tiles which become unseen to
1253 * contain no units (client/packhand.c +2368).
1254 * So here we tell it to remove units that do
1255 * not give it vision. */
1256 unit_list_iterate(ptile->units, punit) {
1261 }
1262
1263 if (known) {
1264 map_show_tile(pplayer, ptile);
1265 } else {
1266 map_hide_tile(pplayer, ptile);
1267 }
1270}
1271
1272/************************************************************************/
1281
1282/************************************************************************/
1286{
1287 struct city *pcity;
1288
1289 pcity = game_city_by_number(id);
1290 if (pcity == NULL) {
1292 _("No such city (ID %d)."), id);
1293 return;
1294 }
1295
1296 remove_city(pcity);
1297}
1298
1299/************************************************************************/
1306
1307/************************************************************************/
1313{
1314 struct player *pplayer;
1315
1316 if (!game.info.fogofwar) {
1318 _("Cannot toggle fog-of-war when it is already "
1319 "disabled."));
1320 return;
1321 }
1322
1323 pplayer = player_by_number(plr_no);
1324 if (!pplayer) {
1326 _("Cannot toggle fog-of-war for invalid player ID %d."),
1327 plr_no);
1328 return;
1329 }
1330
1332 if (unfogged_players[player_number(pplayer)]) {
1333 enable_fog_of_war_player(pplayer);
1335 } else {
1338 }
1340}
1341
1342/************************************************************************/
1346 const struct packet_edit_startpos *packet)
1347{
1348 struct tile *ptile = index_to_tile(&(wld.map), packet->id);
1349 bool changed;
1350
1351 /* Check. */
1352 if (NULL == ptile) {
1354 _("Invalid tile index %d for start position."), packet->id);
1355 return;
1356 }
1357
1358 /* Handle. */
1359 if (packet->removal) {
1360 changed = map_startpos_remove(ptile);
1361 } else {
1362 if (NULL != map_startpos_get(ptile)) {
1363 changed = FALSE;
1364 } else {
1365 map_startpos_new(ptile);
1366 changed = TRUE;
1367 }
1368 }
1369
1370 /* Notify. */
1371 if (changed) {
1373 if (can_conn_edit(aconn)) {
1375 }
1377 }
1378}
1379
1380/************************************************************************/
1384 const struct packet_edit_startpos_full *
1385 packet)
1386{
1387 struct tile *ptile = index_to_tile(&(wld.map), packet->id);
1388 struct startpos *psp;
1389
1390 /* Check. */
1391 if (NULL == ptile) {
1393 _("Invalid tile index %d for start position."),
1394 packet->id);
1395 return;
1396 }
1397
1398 psp = map_startpos_get(ptile);
1399 if (NULL == psp) {
1401 _("Cannot edit start position nations at (%d, %d) "
1402 "because there is no start position there."),
1403 TILE_XY(ptile));
1404 return;
1405 }
1406
1407 /* Handle. */
1408 if (startpos_unpack(psp, packet)) {
1409 /* Notify. */
1411 if (can_conn_edit(aconn)) {
1413 }
1415 }
1416}
1417
1418/************************************************************************/
1422 const struct packet_edit_game *packet)
1423{
1424 bool changed = FALSE;
1425
1426 if (packet->scenario != game.scenario.is_scenario) {
1428 changed = TRUE;
1429 }
1430
1431 if (fc_strncmp(packet->scenario_name, game.scenario.name, 256)) {
1433 changed = TRUE;
1434 }
1435
1436 FC_STATIC_ASSERT(sizeof(packet->scenario_authors) == sizeof(game.scenario.authors),
1438
1440 sizeof(game.scenario.authors))) {
1442 changed = TRUE;
1443 }
1444
1445 if (packet->scenario_random != game.scenario.save_random) {
1447 changed = TRUE;
1448 }
1449
1450 if (packet->scenario_players != game.scenario.players) {
1452 changed = TRUE;
1453 }
1454
1457 changed = TRUE;
1458 }
1459
1462 changed = TRUE;
1463 }
1464
1465 if (packet->lake_flooding != game.scenario.lake_flooding) {
1467 changed = TRUE;
1468 }
1469
1470 if (packet->ruleset_locked != game.scenario.ruleset_locked) {
1472 changed = TRUE;
1473 }
1474
1475 if (changed) {
1478 }
1479}
1480
1481/************************************************************************/
1484void handle_edit_scenario_desc(struct connection *pc, const char *scenario_desc)
1485{
1486 if (fc_strncmp(scenario_desc, game.scenario_desc.description,
1487 MAX_LEN_PACKET)) {
1488 sz_strlcpy(game.scenario_desc.description, scenario_desc);
1490 }
1491}
1492
1493/************************************************************************/
1496void handle_save_scenario(struct connection *pc, const char *name)
1497{
1498 if (pc->access_level != ALLOW_HACK) {
1500 _("No permissions to remotely save scenario."));
1501 return;
1502 }
1503
1504 if (!game.scenario.is_scenario) {
1505 /* Scenario information not available */
1507 _("Scenario information not set. Cannot save scenario."));
1508 return;
1509 }
1510
1511 /* Client initiated scenario saving is not handmade */
1513
1514 save_game(name, "Scenario", TRUE);
1515}
const char * default_ai_type_name(void)
Definition aiiface.c:266
#define BV_CLR_ALL(bv)
Definition bitvector.h:95
#define BV_SET(bv, bit)
Definition bitvector.h:81
#define BV_ARE_EQUAL(vec1, vec2)
Definition bitvector.h:113
#define BV_ISSET(bv, bit)
Definition bitvector.h:78
#define BV_ISSET_ANY(vec)
Definition bitvector.h:109
#define BV_CLR(bv, bit)
Definition bitvector.h:86
void city_name_set(struct city *pcity, const char *new_name)
Definition city.c:1136
int city_granary_size(int city_size)
Definition city.c:2123
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:1231
void city_remove_improvement(struct city *pcity, const struct impr_type *pimprove)
Definition city.c:3359
#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
#define MAX_CITY_SIZE
Definition city.h:106
void send_city_info(struct player *dest, struct city *pcity)
Definition citytools.c:2343
struct city * build_or_move_building(struct city *pcity, struct impr_type *pimprove, struct player **oldcity_owner)
Definition citytools.c:2990
struct city * find_closest_city(const struct tile *ptile, const struct city *pexclcity, const struct player *pplayer, bool only_ocean, bool only_continent, bool only_known, bool only_player, bool only_enemy, const struct unit_class *pclass)
Definition citytools.c:851
bool is_allowed_city_name(struct player *pplayer, const char *cityname, char *error_buf, size_t bufsz)
Definition citytools.c:369
void remove_city(struct city *pcity)
Definition citytools.c:1699
bool create_city_for_player(struct player *pplayer, struct tile *ptile, const char *name)
Definition citytools.c:1673
void city_refresh_queue_add(struct city *pcity)
Definition cityturn.c:197
bool city_change_size(struct city *pcity, citizens size, struct player *nationality, const char *reason)
Definition cityturn.c:1031
void city_refresh_queue_processing(void)
Definition cityturn.c:213
char * incite_cost
Definition comments.c:74
#define MAX_LEN_PACKET
Definition conn_types.h:29
void connection_detach(struct connection *pconn, bool remove_unused_player)
void conn_list_do_unbuffer(struct conn_list *dest)
Definition connection.c:366
bool can_conn_edit(const struct connection *pconn)
Definition connection.c:511
void conn_list_do_buffer(struct conn_list *dest)
Definition connection.c:356
bool can_conn_enable_editing(const struct connection *pconn)
Definition connection.c:521
const char * conn_description(const struct connection *pconn)
Definition connection.c:474
#define conn_list_iterate(connlist, pconn)
Definition connection.h:108
#define conn_list_iterate_end
Definition connection.h:110
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
int int id
Definition editgui_g.h:28
void handle_edit_unit_remove_by_id(struct connection *pc, Unit_type_id id)
Definition edithand.c:591
void handle_edit_tile(struct connection *pc, const struct packet_edit_tile *packet)
Definition edithand.c:375
void handle_edit_scenario_desc(struct connection *pc, const char *scenario_desc)
Definition edithand.c:1484
void handle_edit_check_tiles(struct connection *pc)
Definition edithand.c:1302
void handle_edit_mode(struct connection *pc, bool is_edit_mode)
Definition edithand.c:188
void handle_edit_tile_terrain(struct connection *pc, int tile, Terrain_type_id terrain, int size)
Definition edithand.c:298
void handle_edit_player(struct connection *pc, const struct packet_edit_player *packet)
Definition edithand.c:1003
static bool need_continents_reassigned
Definition edithand.c:64
void edithand_send_initial_packets(struct conn_list *dest)
Definition edithand.c:112
static bool * unfogged_players
Definition edithand.c:73
static struct tile_hash * modified_tile_table
Definition edithand.c:68
void handle_edit_player_remove(struct connection *pc, int id)
Definition edithand.c:979
static bool edit_tile_terrain_handling(struct tile *ptile, struct terrain *pterrain, bool send_info)
Definition edithand.c:221
void handle_edit_city_remove(struct connection *pc, int id)
Definition edithand.c:1285
void edithand_free(void)
Definition edithand.c:96
void handle_edit_player_vision(struct connection *pc, int plr_no, int tile, bool known, int size)
Definition edithand.c:1205
void handle_edit_city(struct connection *pc, const struct packet_edit_city *packet)
Definition edithand.c:740
void edithand_init(void)
Definition edithand.c:78
void handle_edit_city_create(struct connection *pc, int owner, int tile, int size, int tag)
Definition edithand.c:684
static bool edit_tile_extra_handling(struct tile *ptile, struct extra_type *pextra, bool remove_mode, bool send_info)
Definition edithand.c:253
void handle_edit_game(struct connection *pc, const struct packet_edit_game *packet)
Definition edithand.c:1421
void handle_edit_unit_remove(struct connection *pc, int owner, int tile, Unit_type_id utid, int count)
Definition edithand.c:536
void handle_edit_toggle_fogofwar(struct connection *pc, int plr_no)
Definition edithand.c:1312
void handle_edit_startpos_full(struct connection *pconn, const struct packet_edit_startpos_full *packet)
Definition edithand.c:1383
static void check_leaving_edit_mode(void)
Definition edithand.c:164
void handle_edit_player_create(struct connection *pc, int tag)
Definition edithand.c:900
void handle_edit_recalculate_borders(struct connection *pc)
Definition edithand.c:1277
void handle_save_scenario(struct connection *pc, const char *name)
Definition edithand.c:1496
void handle_edit_tile_extra(struct connection *pc, int tile, int id, bool removal, int eowner, int size)
Definition edithand.c:335
void handle_edit_unit_create(struct connection *pc, int owner, int tile, Unit_type_id utid, int count, int tag)
Definition edithand.c:433
void handle_edit_unit(struct connection *pc, const struct packet_edit_unit *packet)
Definition edithand.c:608
static void check_edited_tile_terrains(void)
Definition edithand.c:142
void handle_edit_startpos(struct connection *pconn, const struct packet_edit_startpos *packet)
Definition edithand.c:1345
int extra_number(const struct extra_type *pextra)
Definition extras.c:161
struct extra_type * extra_by_number(int id)
Definition extras.c:183
#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
int Tech_type_id
Definition fc_types.h:380
int Terrain_type_id
Definition fc_types.h:376
int Unit_type_id
Definition fc_types.h:385
#define _(String)
Definition fcintl.h:67
const char * tile_link(const struct tile *ptile)
const struct ft_color ftc_editor
const char * city_link(const struct city *pcity)
const char * unit_link(const struct unit *punit)
struct civ_game game
Definition game.c:62
struct world wld
Definition game.c:63
struct unit * game_unit_by_number(int id)
Definition game.c:116
struct city * game_city_by_number(int id)
Definition game.c:107
void send_scenario_description(struct conn_list *dest)
Definition gamehand.c:964
void send_scenario_info(struct conn_list *dest)
Definition gamehand.c:950
void send_game_info(struct conn_list *dest)
Definition gamehand.c:907
struct government * government_by_number(const Government_type_id gov)
Definition government.c:103
struct city * owner
Definition citydlg.c:220
bool is_special_improvement(const struct impr_type *pimprove)
Impr_type_id improvement_number(const struct impr_type *pimprove)
const char * improvement_name_translation(const struct impr_type *pimprove)
#define improvement_iterate_end
#define improvement_iterate(_p)
const char * name
Definition inputfile.c:127
#define FC_STATIC_ASSERT(cond, tag)
Definition log.h:235
struct startpos * map_startpos_get(const struct tile *ptile)
Definition map.c:1883
struct startpos * map_startpos_new(struct tile *ptile)
Definition map.c:1866
struct tile * startpos_tile(const struct startpos *psp)
Definition map.c:1676
bool startpos_pack(const struct startpos *psp, struct packet_edit_startpos_full *packet)
Definition map.c:1706
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Definition map.c:456
bool map_startpos_remove(struct tile *ptile)
Definition map.c:1899
bool startpos_unpack(struct startpos *psp, const struct packet_edit_startpos_full *packet)
Definition map.c:1726
#define map_startpos_iterate(NAME_psp)
Definition map.h:130
#define square_iterate(nmap, center_tile, radius, tile_itr)
Definition map.h:391
#define square_iterate_end
Definition map.h:394
#define map_startpos_iterate_end
Definition map.h:133
#define MAP_TILE_OWNER_NULL
Definition map.h:602
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:1921
void disable_fog_of_war_player(struct player *pplayer)
Definition maphand.c:1768
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:2689
void terrain_changed(struct tile *ptile)
Definition maphand.c:1940
void map_calculate_borders(void)
Definition maphand.c:2351
void fix_tile_on_terrain_change(struct tile *ptile, struct terrain *oldter, bool extend_rivers)
Definition maphand.c:1959
void enable_fog_of_war_player(struct player *pplayer)
Definition maphand.c:1744
void map_show_circle(struct player *pplayer, struct tile *ptile, int radius_sq)
Definition maphand.c:864
void update_tile_knowledge(struct tile *ptile)
Definition maphand.c:1436
void map_hide_tile(struct player *src_player, struct tile *ptile)
Definition maphand.c:820
#define fc_calloc(n, esz)
Definition mem.h:38
bool can_exist_at_tile(const struct civ_map *nmap, const struct unit_type *utype, const struct tile *ptile)
Definition movement.c:290
Nation_type_id nation_count(void)
Definition nation.c:507
struct nation_type * nation_by_number(const Nation_type_id nation)
Definition nation.c:475
struct nation_type * nation_of_player(const struct player *pplayer)
Definition nation.c:444
bool is_nation_playable(const struct nation_type *nation)
Definition nation.c:200
const char * nation_plural_translation(const struct nation_type *pnation)
Definition nation.c:159
enum barbarian_type nation_barbarian_type(const struct nation_type *nation)
Definition nation.c:211
struct government * init_government_of_nation(const struct nation_type *pnation)
Definition nation.c:659
void notify_conn(struct conn_list *dest, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Definition notify.c:239
int dsend_packet_unit_remove(struct connection *pc, int unit_id)
int send_packet_edit_startpos_full(struct connection *pc, const struct packet_edit_startpos_full *packet)
int dsend_packet_edit_object_created(struct connection *pc, int tag, int id)
int send_packet_edit_startpos(struct connection *pc, const struct packet_edit_startpos *packet)
struct player * player_by_number(const int player_id)
Definition player.c:849
int player_count(void)
Definition player.c:817
int player_slot_count(void)
Definition player.c:418
int player_number(const struct player *pplayer)
Definition player.c:837
const char * player_name(const struct player *pplayer)
Definition player.c:895
bool player_has_flag(const struct player *pplayer, enum plr_flag_id flag)
Definition player.c:1990
int player_index(const struct player *pplayer)
Definition player.c:829
bool player_set_nation(struct player *pplayer, struct nation_type *pnation)
Definition player.c:861
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
#define ANON_USER_NAME
Definition player.h:48
static bool is_barbarian(const struct player *pplayer)
Definition player.h:489
void send_player_all_c(struct player *src, struct conn_list *dest)
Definition plrhand.c:1125
struct player * server_create_player(int player_id, const char *ai_tname, struct rgbcolor *prgbcolor, bool allow_ai_type_fallbacking)
Definition plrhand.c:1889
void player_limit_to_max_rates(struct player *pplayer)
Definition plrhand.c:2052
bool server_player_set_name_full(const struct connection *caller, struct player *pplayer, const struct nation_type *pnation, const char *name, char *error_buf, size_t error_buf_len)
Definition plrhand.c:2163
struct nation_type * pick_a_nation(const struct nation_list *choices, bool ignore_conflicts, bool needs_startpos, enum barbarian_type barb_type)
Definition plrhand.c:2448
void kill_player(struct player *pplayer)
Definition plrhand.c:126
void send_player_info_c(struct player *src, struct conn_list *dest)
Definition plrhand.c:1142
void server_remove_player(struct player *pplayer)
Definition plrhand.c:1938
void government_change(struct player *pplayer, struct government *gov, bool revolution_finished)
Definition plrhand.c:337
void server_player_init(struct player *pplayer, bool initmap, bool needs_team)
Definition plrhand.c:1614
void assign_player_colors(void)
Definition plrhand.c:1729
bool nation_is_in_current_set(const struct nation_type *pnation)
Definition plrhand.c:2585
int revolution_length(struct government *gov, struct player *plr)
Definition plrhand.c:550
enum tech_state research_invention_set(struct research *presearch, Tech_type_id tech, enum tech_state value)
Definition research.c:637
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
void research_update(struct research *presearch)
Definition research.c:501
#define sanity_check_tile(x)
Definition sanitycheck.h:42
void save_game(const char *orig_filename, const char *save_reason, bool scenario)
Definition savemain.c:142
#define CLIP(lower, current, upper)
Definition shared.h:57
size_t size
Definition specvec.h:72
void player_nation_defaults(struct player *pplayer, struct nation_type *pnation, bool set_name)
Definition srv_main.c:2579
bool game_was_started(void)
Definition srv_main.c:349
Definition city.h:320
int food_stock
Definition city.h:367
int history
Definition city.h:410
int id
Definition city.h:326
char * name
Definition city.h:321
int before_change_shields
Definition city.h:389
int shield_stock
Definition city.h:368
struct packet_scenario_description scenario_desc
Definition game.h:88
struct packet_ruleset_control control
Definition game.h:83
struct conn_list * est_connections
Definition game.h:97
struct packet_game_info info
Definition game.h:89
struct packet_scenario_info scenario
Definition game.h:87
struct civ_game::@31::@35 server
int max_players
Definition game.h:156
struct government * government_during_revolution
Definition game.h:94
struct player * player
Definition nation.h:118
int built[B_LAST]
char name[MAX_LEN_CITYNAME]
char scenario_name[256]
char scenario_authors[MAX_LEN_PACKET/3]
Nation_type_id nation
char name[MAX_LEN_NAME]
Government_type_id government
bool inventions[A_LAST+1]
char label[MAX_LEN_NAME]
char description[MAX_LEN_CONTENT]
char authors[MAX_LEN_PACKET/3]
enum barbarian_type barbarian_type
Definition player.h:120
int infra_points
Definition player.h:65
struct player_ai ai_common
Definition player.h:286
bv_plr_flags flags
Definition player.h:290
int autoselect_weight
Definition player.h:297
char username[MAX_LEN_NAME]
Definition player.h:250
bool is_connected
Definition player.h:294
int revolution_finishes
Definition player.h:271
struct government * government
Definition player.h:256
struct conn_list * connections
Definition player.h:296
bool is_alive
Definition player.h:266
struct player_economic economic
Definition player.h:282
bool unassigned_user
Definition player.h:251
Tech_type_id researching
Definition research.h:52
Tech_type_id tech_goal
Definition research.h:83
int techs_researched
Definition research.h:42
int bulbs_researched
Definition research.h:53
Definition map.c:41
Definition tile.h:50
bv_extras extras
Definition tile.h:55
struct unit_list * units
Definition tile.h:58
struct player * extras_owner
Definition tile.h:63
struct terrain * terrain
Definition tile.h:57
Definition unit.h:138
int moves_left
Definition unit.h:150
int id
Definition unit.h:145
bool moved
Definition unit.h:173
int hp
Definition unit.h:151
int fuel
Definition unit.h:153
bool stay
Definition unit.h:205
int homecity
Definition unit.h:146
bool done_moving
Definition unit.h:181
int veteran
Definition unit.h:152
struct civ_map map
#define sz_strlcpy(dest, src)
Definition support.h:189
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define fc_strncmp(_s1_, _s2_, _len_)
Definition support.h:154
#define A_FUTURE
Definition tech.h:46
#define advance_index_iterate_end
Definition tech.h:248
#define A_FIRST
Definition tech.h:44
#define A_UNSET
Definition tech.h:48
#define advance_index_iterate(_start, _index)
Definition tech.h:244
void init_tech(struct research *research, bool update)
Definition techtools.c:1093
void send_research_info(const struct research *presearch, const struct conn_list *dest)
Definition techtools.c:293
void give_initial_techs(struct research *presearch, int num_random_techs)
Definition techtools.c:1187
struct terrain * terrain_by_number(const Terrain_type_id type)
Definition terrain.c:156
bool terrain_has_resource(const struct terrain *pterrain, const struct extra_type *presource)
Definition terrain.c:255
#define terrain_has_flag(terr, flag)
Definition terrain.h:283
bool tile_extra_apply(struct tile *ptile, struct extra_type *tgt)
Definition tile.c:575
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
void tile_set_resource(struct tile *ptile, struct extra_type *presource)
Definition tile.c:349
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:88
#define tile_hash_iterate(hash, ptile)
Definition tile.h:82
#define tile_terrain(_tile)
Definition tile.h:110
#define tile_hash_iterate_end
Definition tile.h:84
#define TILE_XY(ptile)
Definition tile.h:43
#define tile_has_extra(ptile, pextra)
Definition tile.h:147
#define unit_owner(_pu)
Definition unit.h:389
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:425
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_safe(unitlist, _unit)
Definition unitlist.h:39
#define unit_list_iterate_end
Definition unitlist.h:33
#define unit_list_iterate_safe_end
Definition unitlist.h:61
void send_unit_info(struct conn_list *dest, struct unit *punit)
Definition unittools.c:2725
struct unit * create_unit(struct player *pplayer, struct tile *ptile, const struct unit_type *type, int veteran_level, int homecity_id, int moves_left)
Definition unittools.c:1601
void wipe_unit(struct unit *punit, enum unit_loss_reason reason, struct player *killer)
Definition unittools.c:2135
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
bool utype_player_already_has_this_unique(const struct player *pplayer, const struct unit_type *putype)
Definition unittype.c:1927
struct unit_type * utype_by_number(const Unit_type_id id)
Definition unittype.c:112
const struct veteran_level * utype_veteran_level(const struct unit_type *punittype, int level)
Definition unittype.c:2583
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1560
#define utype_class(_t_)
Definition unittype.h:749
#define utype_fuel(ptype)
Definition unittype.h:836
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:617