Freeciv-3.3
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 struct city *pcity;
442 int id, i;
443
444 ptile = index_to_tile(&(wld.map), tile);
445 if (!ptile) {
447 _("Cannot create units because %d is not a valid "
448 "tile index on this map!"), tile);
449 return;
450 }
451
453 if (!punittype) {
454 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
455 /* TRANS: ..." at <tile-coordinates> because"... */
456 _("Cannot create a unit at %s because the "
457 "given unit type id %d is invalid."),
458 tile_link(ptile), utid);
459 return;
460 }
461
462 pplayer = player_by_number(owner);
463 if (!pplayer) {
464 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
465 /* TRANS: ..." type <unit-type> at <tile-coordinates>"... */
466 _("Cannot create a unit of type %s at %s "
467 "because the given owner's player id %d is "
468 "invalid."), utype_name_translation(punittype),
469 tile_link(ptile), owner);
470 return;
471 }
472
475 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
476 _("Cannot create another instance of unique unit type %s. "
477 "Player already has one such unit."),
479 return;
480 }
481 if (count > 1) {
482 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
483 _("Cannot create multiple instances of unique unit type %s."),
485 return;
486 }
487 }
488
489 pcity = tile_city(ptile);
490 if (is_non_allied_unit_tile(ptile, pplayer,
492 || (pcity != NULL
493 && !pplayers_allied(pplayer, city_owner(pcity)))) {
494 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
495 /* TRANS: ..." type <unit-type> on enemy tile
496 * <tile-coordinates>"... */
497 _("Cannot create unit of type %s on enemy tile "
499 tile_link(ptile));
500 return;
501 }
502
503 if (!can_exist_at_tile(&(wld.map), punittype, ptile)) {
504 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
505 /* TRANS: ..." type <unit-type> on the terrain at
506 * <tile-coordinates>"... */
507 _("Cannot create a unit of type %s on the terrain "
508 "at %s."),
510 return;
511 }
512
513 if (count > 0 && !pplayer->is_alive) {
514 pplayer->is_alive = TRUE;
515 send_player_info_c(pplayer, NULL);
516 }
517
518 homecity = find_closest_city(ptile, NULL, pplayer, FALSE, FALSE, FALSE,
520 id = homecity ? homecity->id : 0;
521
523 map_show_circle(pplayer, ptile, punittype->vision_radius_sq);
524 for (i = 0; i < count; i++) {
525 /* As far as I can see create_unit is guaranteed to
526 * never return NULL. */
527 punit = create_unit(pplayer, ptile, punittype, 0, id, -1);
528 if (tag > 0) {
530 }
531 }
533}
534
535/************************************************************************/
540 int tile, Unit_type_id utid, int count)
541{
542 struct tile *ptile;
543 struct unit_type *punittype;
544 struct player *pplayer;
545 int i;
546
547 ptile = index_to_tile(&(wld.map), tile);
548 if (!ptile) {
550 _("Cannot remove units because %d is not a valid "
551 "tile index on this map!"), tile);
552 return;
553 }
554
556 if (!punittype) {
557 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
558 /* TRANS: ..." at <tile-coordinates> because"... */
559 _("Cannot remove a unit at %s because the "
560 "given unit type id %d is invalid."),
561 tile_link(ptile), utid);
562 return;
563 }
564
565 pplayer = player_by_number(owner);
566 if (!pplayer) {
567 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
568 /* TRANS: ..." type <unit-type> at <tile-coordinates>
569 * because"... */
570 _("Cannot remove a unit of type %s at %s "
571 "because the given owner's player id %d is "
572 "invalid."), utype_name_translation(punittype),
573 tile_link(ptile), owner);
574 return;
575 }
576
577 i = 0;
579 if (i >= count) {
580 break;
581 }
583 || unit_owner(punit) != pplayer) {
584 continue;
585 }
587 i++;
589}
590
591/************************************************************************/
595{
596 struct unit *punit;
597
599 if (!punit) {
601 _("No such unit (ID %d)."), id);
602 return;
603 }
604
606}
607
608/************************************************************************/
612 const struct packet_edit_unit *packet)
613{
614 const struct unit_type *putype;
615 struct unit *punit;
616 int id;
617 bool changed = FALSE;
618 int fuel, hp;
619
620 id = packet->id;
622 if (!punit) {
624 _("No such unit (ID %d)."), id);
625 return;
626 }
627
629
630 if (packet->moves_left != punit->moves_left) {
631 punit->moves_left = packet->moves_left;
632 changed = TRUE;
633 }
634
635 fuel = CLIP(0, packet->fuel, utype_fuel(putype));
636 if (fuel != punit->fuel) {
637 punit->fuel = fuel;
638 changed = TRUE;
639 }
640
641 if (packet->moved != punit->moved) {
642 punit->moved = packet->moved;
643 changed = TRUE;
644 }
645
646 if (packet->done_moving != punit->done_moving) {
647 punit->done_moving = packet->done_moving;
648 changed = TRUE;
649 }
650
651 hp = CLIP(1, packet->hp, putype->hp);
652 if (hp != punit->hp) {
653 punit->hp = hp;
654 changed = TRUE;
655 }
656
657 if (packet->veteran != punit->veteran) {
658 int v = packet->veteran;
659 if (!utype_veteran_level(putype, v)) {
661 _("Invalid veteran level %d for unit %d (%s)."),
662 v, id, unit_link(punit));
663 } else {
664 punit->veteran = v;
665 changed = TRUE;
666 }
667 }
668
669 if (packet->stay != punit->stay) {
670 punit->stay = packet->stay;
671 changed = TRUE;
672 }
673
674 /* TODO: Handle more property edits. */
675
676
677 /* Send the new state to all affected. */
678 if (changed) {
680 }
681}
682
683/************************************************************************/
688 int size, int tag)
689{
690 struct tile *ptile;
691 struct city *pcity;
692 struct player *pplayer;
693
694 ptile = index_to_tile(&(wld.map), tile);
695 if (!ptile) {
697 _("Cannot create a city because %d is not a valid "
698 "tile index on this map!"), tile);
699 return;
700 }
701
702 pplayer = player_by_number(owner);
703 if (!pplayer) {
704 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
705 /* TRANS: ..." at <tile-coordinates> because"... */
706 _("Cannot create a city at %s because the "
707 "given owner's player id %d is invalid"),
708 tile_link(ptile), owner);
709 return;
710
711 }
712
714
715 if (!create_city_for_player(pplayer, ptile, NULL)) {
716 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
717 /* TRANS: ..." at <tile-coordinates>." */
718 _("A city may not be built at %s."), tile_link(ptile));
720
721 return;
722 }
723
724 pcity = tile_city(ptile);
725
726 if (size > 1) {
727 /* FIXME: Slow and inefficient for large size changes. */
728 city_change_size(pcity, CLIP(1, size, MAX_CITY_SIZE), pplayer, NULL);
729 send_city_info(NULL, pcity);
730 }
731
732 if (tag > 0) {
734 }
735
737}
738
739
740/************************************************************************/
744 const struct packet_edit_city *packet)
745{
746 struct tile *ptile;
747 struct city *pcity, *oldcity;
748 struct player *pplayer;
749 char buf[1024];
750 int id;
751 bool changed = FALSE;
752 bool need_game_info = FALSE;
754
755 pcity = game_city_by_number(packet->id);
756 if (!pcity) {
758 _("Cannot edit city with invalid city ID %d."),
759 packet->id);
760 return;
761 }
762
763 pplayer = city_owner(pcity);
764 ptile = city_tile(pcity);
766
767 /* Handle name change. */
768 if (0 != strcmp(pcity->name, packet->name)) {
769 if (!is_allowed_city_name(pplayer, packet->name, buf, sizeof(buf))) {
770 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
771 _("Cannot edit city name: %s"), buf);
772 } else {
773 city_name_set(pcity, packet->name);
774 changed = TRUE;
775 }
776 }
777
778 /* Handle size change. */
779 if (packet->size != city_size_get(pcity)) {
780 if (!(0 < packet->size && packet->size <= MAX_CITY_SIZE)) {
781 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
782 _("Invalid city size %d for city %s."),
783 packet->size, city_link(pcity));
784 } else {
785 /* FIXME: Slow and inefficient for large size changes. */
786 city_change_size(pcity, packet->size, NULL, NULL);
787 changed = TRUE;
788 }
789 }
790
791 if (packet->history != pcity->history) {
792 pcity->history = packet->history;
793 changed = TRUE;
794 }
795
796 /* Handle city improvement changes. */
797 improvement_iterate(pimprove) {
798 oldcity = NULL;
799 id = improvement_number(pimprove);
800
801 if (is_special_improvement(pimprove)) {
802 if (packet->built[id] >= 0) {
803 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
804 _("It is impossible for a city to have %s!"),
806 }
807 continue;
808 }
809
810 /* FIXME: game.info.great_wonder_owners and pplayer->wonders
811 * logic duplication with city_build_building. */
812
813 if (city_has_building(pcity, pimprove) && packet->built[id] < 0) {
814
815 city_remove_improvement(pcity, pimprove);
816 changed = TRUE;
817
818 } else if (!city_has_building(pcity, pimprove)
819 && packet->built[id] >= 0) {
820 struct player *old_owner = NULL;
821
822 oldcity = build_or_move_building(pcity, pimprove, &old_owner);
823 if (oldcity != pcity) {
825 }
826 if (oldcity && old_owner != pplayer) {
827 /* Great wonders make more changes. */
829 if (old_owner) {
831 }
832 }
833
834 if (oldcity) {
836 }
837 changed = TRUE;
838 }
840
841 /* Handle food stock change. */
842 if (packet->food_stock != pcity->food_stock) {
843 int max = city_granary_size(city_size_get(pcity));
844 if (!(0 <= packet->food_stock && packet->food_stock <= max)) {
845 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
846 _("Invalid city food stock amount %d for city %s "
847 "(allowed range is %d to %d)."),
848 packet->food_stock, city_link(pcity), 0, max);
849 } else {
850 pcity->food_stock = packet->food_stock;
851 changed = TRUE;
852 }
853 }
854
855 /* Handle shield stock change. */
856 if (packet->shield_stock != pcity->shield_stock) {
857 int max = USHRT_MAX; /* Limited to uint16 by city info packet. */
858
859 if (!(0 <= packet->shield_stock && packet->shield_stock <= max)) {
860 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
861 _("Invalid city shield stock amount %d for city %s "
862 "(allowed range is %d to %d)."),
863 packet->shield_stock, city_link(pcity), 0, max);
864 } else {
865 pcity->shield_stock = packet->shield_stock;
866 /* Make sure the shields stay if changing production back and forth */
867 pcity->before_change_shields = packet->shield_stock;
868 changed = TRUE;
869 }
870 }
871
872 /* TODO: Handle more property edits. */
873
874
875 if (changed) {
879
880 /* FIXME: city_refresh_queue_processing only sends to city owner? */
881 send_city_info(NULL, pcity);
882
884 }
885
886 /* Update wonder infos. */
887 if (need_game_info) {
889 }
893 /* No need to send to detached connections. */
895 }
897 }
898}
899
900/************************************************************************/
904{
905 struct player *pplayer;
906 struct nation_type *pnation;
907 struct research *presearch;
908 int existing = player_count();
909
910 if (existing >= player_slot_count()) {
912 _("No more players can be added because the maximum "
913 "number of players (%d) has been reached."),
915 return;
916 }
917
920 _("No more players can be added because there's "
921 "already maximum number of players allowed by maxplayers setting (value %d)"),
923 return;
924 }
925
926 if (existing >= nation_count() ) {
928 _("No more players can be added because there are "
929 "no available nations (%d used)."),
930 nation_count());
931 return;
932 }
933
935 if (!pnation) {
937 _("Player cannot be created because random nation "
938 "selection failed."));
939 return;
940 }
941
943 NULL, FALSE);
944 if (!pplayer) {
946 _("Player creation failed."));
947 return;
948 }
949 server_player_init(pplayer, TRUE, TRUE);
950
951 player_nation_defaults(pplayer, pnation, TRUE);
952 if (game_was_started()) {
953 /* Find a color for the new player. */
955 }
957 pplayer->unassigned_user = TRUE;
958 pplayer->is_connected = FALSE;
959 pplayer->government = init_government_of_nation(pnation);
960 BV_CLR(pplayer->flags, PLRF_FIRST_CITY);
961
962 pplayer->economic.gold = 0;
963 pplayer->economic.infra_points = 0;
965
966 presearch = research_get(pplayer);
969
970 send_player_all_c(pplayer, NULL);
971 /* Send research info after player info, else the client will complain
972 * about invalid team. */
974 if (tag > 0) {
976 }
977}
978
979/************************************************************************/
983{
984 struct player *pplayer;
985
986 pplayer = player_by_number(id);
987 if (pplayer == NULL) {
989 _("No such player (ID %d)."), id);
990 return;
991 }
992
993 /* Don't use conn_list_iterate here because connection_detach() can be
994 * recursive and free the next connection pointer. */
995 while (conn_list_size(pplayer->connections) > 0) {
997 }
998
999 kill_player(pplayer);
1000 server_remove_player(pplayer);
1001}
1002
1003/************************************************************************/
1007 const struct packet_edit_player *packet)
1008{
1009 struct player *pplayer;
1010 bool changed = FALSE, update_research = FALSE;
1011 struct nation_type *pnation;
1012 struct research *research;
1013 enum tech_state known;
1014 struct government *gov;
1015
1016 pplayer = player_by_number(packet->id);
1017 if (!pplayer) {
1019 _("Cannot edit player with invalid player ID %d."),
1020 packet->id);
1021 return;
1022 }
1023
1024 research = research_get(pplayer);
1025
1026
1027 /* Handle player name change. */
1028 if (0 != strcmp(packet->name, player_name(pplayer))) {
1029 char error_buf[256];
1030
1031 if (server_player_set_name_full(pc, pplayer, NULL, packet->name,
1032 error_buf, sizeof(error_buf))) {
1033 changed = TRUE;
1034 } else {
1036 _("Cannot change name of player (%d) '%s' to '%s': %s"),
1037 player_number(pplayer), player_name(pplayer),
1038 packet->name, error_buf);
1039 }
1040 }
1041
1042 /* Handle nation change. */
1043 pnation = nation_by_number(packet->nation);
1044 if (nation_of_player(pplayer) != pnation) {
1045 if (pnation == NULL) {
1047 _("Cannot change nation for player %d (%s) "
1048 "because the given nation ID %d is invalid."),
1049 player_number(pplayer), player_name(pplayer),
1050 packet->nation);
1051 } else if (pnation->player != NULL) {
1053 _("Cannot change nation for player %d (%s) "
1054 "to nation %d (%s) because that nation is "
1055 "already assigned to player %d (%s)."),
1056 player_number(pplayer), player_name(pplayer),
1057 packet->nation, nation_plural_translation(pnation),
1058 player_number(pnation->player),
1059 player_name(pnation->player));
1060 } else if (!nation_is_in_current_set(pnation)) {
1062 _("Cannot change nation for player %d (%s) "
1063 "to nation %d (%s) because that nation is "
1064 "not in the current nation set."),
1065 player_number(pplayer), player_name(pplayer),
1066 packet->nation, nation_plural_translation(pnation));
1067 } else if (pplayer->ai_common.barbarian_type
1068 != nation_barbarian_type(pnation)
1069 || (!is_barbarian(pplayer) && !is_nation_playable(pnation))) {
1071 _("Cannot change nation for player %d (%s) "
1072 "to nation %d (%s) because that nation is "
1073 "unsuitable for this player."),
1074 player_number(pplayer), player_name(pplayer),
1075 packet->nation, nation_plural_translation(pnation));
1076 } else {
1077 changed = player_set_nation(pplayer, pnation);
1078 }
1079 }
1080
1081 /* Handle a change in research progress. */
1082 if (packet->bulbs_researched != research->bulbs_researched) {
1084 changed = TRUE;
1086 }
1087
1088 /* Handle a change in known inventions. */
1090 known = research_invention_state(research, tech);
1091 if ((packet->inventions[tech] && known == TECH_KNOWN)
1092 || (!packet->inventions[tech] && known != TECH_KNOWN)) {
1093 continue;
1094 }
1095 if (packet->inventions[tech]) {
1096 /* FIXME: Side-effect modifies game.info.global_advances. */
1099 } else {
1102 }
1103 changed = TRUE;
1106
1107 /* Handle a change in the player's gold. */
1108 if (packet->gold != pplayer->economic.gold) {
1109 if (!(0 <= packet->gold && packet->gold <= 1000000)) {
1111 _("Cannot set gold for player %d (%s) because "
1112 "the value %d is outside the allowed range."),
1113 player_number(pplayer), player_name(pplayer),
1114 packet->gold);
1115 } else {
1116 pplayer->economic.gold = packet->gold;
1117 changed = TRUE;
1118 }
1119 }
1120
1121 /* Handle a change in the player's autoselect weight. */
1122 if (packet->autoselect_weight != pplayer->autoselect_weight) {
1123 pplayer->autoselect_weight = packet->autoselect_weight;
1124 changed = TRUE;
1125 }
1126
1127 /* Handle player government change */
1128 gov = government_by_number(packet->government);
1129 if (gov != pplayer->government) {
1131 government_change(pplayer, gov, FALSE);
1132 } else {
1133 int turns = revolution_length(gov, pplayer);
1134
1135 if (turns >= 0) {
1136 pplayer->government = gov;
1137 pplayer->revolution_finishes = game.info.turn + turns;
1138 }
1139 }
1140
1141 changed = TRUE;
1142 }
1143
1144 if (packet->scenario_reserved) {
1145 if (!player_has_flag(pplayer, PLRF_SCENARIO_RESERVED)) {
1146 changed = TRUE;
1148 }
1149 } else {
1151 changed = TRUE;
1153 }
1154 }
1155
1156 /* TODO: Handle more property edits. */
1157
1158 if (update_research) {
1159 Tech_type_id current, goal;
1160
1162
1163 /* FIXME: Modifies struct research directly. */
1164
1165 current = research->researching;
1166 goal = research->tech_goal;
1167
1168 if (current != A_UNSET) {
1169 if (current != A_FUTURE) {
1170 known = research_invention_state(research, current);
1171 if (known != TECH_PREREQS_KNOWN) {
1173 }
1174 } else {
1175 /* Future Tech is legal only if all techs are known */
1178 if (known != TECH_KNOWN) {
1180 break;
1181 }
1183 }
1184 }
1185 if (goal != A_UNSET) {
1186 if (goal != A_FUTURE) {
1187 known = research_invention_state(research, goal);
1188 if (known == TECH_KNOWN) {
1190 }
1191 }
1192 }
1193 changed = TRUE;
1194
1195 /* Inform everybody about global advances */
1198 }
1199
1200 if (changed) {
1201 send_player_all_c(pplayer, NULL);
1202 }
1203}
1204
1205/************************************************************************/
1209 int tile, bool known, int size)
1210{
1211 struct player *pplayer;
1212 struct tile *ptile_center;
1213
1215 if (!ptile_center) {
1217 _("Cannot edit vision because %d is not a valid "
1218 "tile index on this map!"), tile);
1219 return;
1220 }
1221
1222 pplayer = player_by_number(plr_no);
1223 if (!pplayer) {
1225 /* TRANS: ..." at <tile-coordinates> because"... */
1226 _("Cannot edit vision for the tile at %s because "
1227 "given player id %d is invalid."),
1229 return;
1230 }
1231
1233 square_iterate(&(wld.map), ptile_center, size - 1, ptile) {
1234
1235 if (!known) {
1236 struct city *pcity = tile_city(ptile);
1238
1239 if (pcity && city_owner(pcity) == pplayer) {
1240 continue;
1241 }
1242
1243 unit_list_iterate(ptile->units, punit) {
1244 if (unit_owner(punit) == pplayer
1245 || really_gives_vision(pplayer, unit_owner(punit))) {
1247 break;
1248 }
1250
1251 if (cannot_make_unknown) {
1252 continue;
1253 }
1254
1255 /* The client expects tiles which become unseen to
1256 * contain no units (client/packhand.c +2368).
1257 * So here we tell it to remove units that do
1258 * not give it vision. */
1259 unit_list_iterate(ptile->units, punit) {
1264 }
1265
1266 if (known) {
1267 map_show_tile(pplayer, ptile);
1268 } else {
1269 map_hide_tile(pplayer, ptile);
1270 }
1273}
1274
1275/************************************************************************/
1284
1285/************************************************************************/
1289{
1290 struct city *pcity;
1291
1292 pcity = game_city_by_number(id);
1293 if (pcity == NULL) {
1295 _("No such city (ID %d)."), id);
1296 return;
1297 }
1298
1299 remove_city(pcity);
1300}
1301
1302/************************************************************************/
1309
1310/************************************************************************/
1316{
1317 struct player *pplayer;
1318
1319 if (!game.info.fogofwar) {
1321 _("Cannot toggle fog-of-war when it is already "
1322 "disabled."));
1323 return;
1324 }
1325
1326 pplayer = player_by_number(plr_no);
1327 if (!pplayer) {
1329 _("Cannot toggle fog-of-war for invalid player ID %d."),
1330 plr_no);
1331 return;
1332 }
1333
1335 if (unfogged_players[player_number(pplayer)]) {
1336 enable_fog_of_war_player(pplayer);
1338 } else {
1341 }
1343}
1344
1345/************************************************************************/
1349 const struct packet_edit_startpos *packet)
1350{
1351 struct tile *ptile = index_to_tile(&(wld.map), packet->id);
1352 bool changed;
1353
1354 /* Check. */
1355 if (NULL == ptile) {
1357 _("Invalid tile index %d for start position."), packet->id);
1358 return;
1359 }
1360
1361 /* Handle. */
1362 if (packet->removal) {
1363 changed = map_startpos_remove(ptile);
1364 } else {
1365 if (NULL != map_startpos_get(ptile)) {
1366 changed = FALSE;
1367 } else {
1368 map_startpos_new(ptile);
1369 changed = TRUE;
1370 }
1371 }
1372
1373 /* Notify. */
1374 if (changed) {
1376 if (can_conn_edit(aconn)) {
1378 }
1380 }
1381}
1382
1383/************************************************************************/
1387 const struct packet_edit_startpos_full *
1388 packet)
1389{
1390 struct tile *ptile = index_to_tile(&(wld.map), packet->id);
1391 struct startpos *psp;
1392
1393 /* Check. */
1394 if (NULL == ptile) {
1396 _("Invalid tile index %d for start position."),
1397 packet->id);
1398 return;
1399 }
1400
1401 psp = map_startpos_get(ptile);
1402 if (NULL == psp) {
1404 _("Cannot edit start position nations at (%d, %d) "
1405 "because there is no start position there."),
1406 TILE_XY(ptile));
1407 return;
1408 }
1409
1410 /* Handle. */
1411 if (startpos_unpack(psp, packet)) {
1412 /* Notify. */
1414 if (can_conn_edit(aconn)) {
1416 }
1418 }
1419}
1420
1421/************************************************************************/
1425 const struct packet_edit_game *packet)
1426{
1427 bool changed = FALSE;
1428
1429 if (packet->scenario != game.scenario.is_scenario) {
1431 changed = TRUE;
1432 }
1433
1434 if (fc_strncmp(packet->scenario_name, game.scenario.name, 256)) {
1436 changed = TRUE;
1437 }
1438
1439 FC_STATIC_ASSERT(sizeof(packet->scenario_authors) == sizeof(game.scenario.authors),
1441
1443 sizeof(game.scenario.authors))) {
1445 changed = TRUE;
1446 }
1447
1448 if (packet->scenario_random != game.scenario.save_random) {
1450 changed = TRUE;
1451 }
1452
1453 if (packet->scenario_players != game.scenario.players) {
1455 changed = TRUE;
1456 }
1457
1460 changed = TRUE;
1461 }
1462
1465 changed = TRUE;
1466 }
1467
1468 if (packet->lake_flooding != game.scenario.lake_flooding) {
1470 changed = TRUE;
1471 }
1472
1473 if (packet->ruleset_locked != game.scenario.ruleset_locked) {
1475 changed = TRUE;
1476 }
1477
1478 if (changed) {
1481 }
1482}
1483
1484/************************************************************************/
1487void handle_edit_scenario_desc(struct connection *pc, const char *scenario_desc)
1488{
1489 if (fc_strncmp(scenario_desc, game.scenario_desc.description,
1490 MAX_LEN_PACKET)) {
1491 sz_strlcpy(game.scenario_desc.description, scenario_desc);
1493 }
1494}
1495
1496/************************************************************************/
1499void handle_save_scenario(struct connection *pc, const char *name)
1500{
1501 if (pc->access_level != ALLOW_HACK) {
1503 _("No permissions to remotely save scenario."));
1504 return;
1505 }
1506
1507 if (!game.scenario.is_scenario) {
1508 /* Scenario information not available */
1510 _("Scenario information not set. Cannot save scenario."));
1511 return;
1512 }
1513
1514 /* Client initiated scenario saving is not handmade */
1516
1517 save_game(name, "Scenario", TRUE);
1518}
const char * default_ai_type_name(void)
Definition aiiface.c:264
#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:1141
int city_granary_size(int city_size)
Definition city.c:2129
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:1236
void city_remove_improvement(struct city *pcity, const struct impr_type *pimprove)
Definition city.c:3367
#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:2351
struct city * build_or_move_building(struct city *pcity, struct impr_type *pimprove, struct player **oldcity_owner)
Definition citytools.c:3002
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:1702
bool create_city_for_player(struct player *pplayer, struct tile *ptile, const char *name)
Definition citytools.c:1674
void city_refresh_queue_add(struct city *pcity)
Definition cityturn.c:196
bool city_change_size(struct city *pcity, citizens size, struct player *nationality, const char *reason)
Definition cityturn.c:1030
void city_refresh_queue_processing(void)
Definition cityturn.c:212
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:594
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:1487
void handle_edit_check_tiles(struct connection *pc)
Definition edithand.c:1305
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:1006
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:982
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:1288
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:1208
void handle_edit_city(struct connection *pc, const struct packet_edit_city *packet)
Definition edithand.c:743
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:687
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:1424
void handle_edit_unit_remove(struct connection *pc, int owner, int tile, Unit_type_id utid, int count)
Definition edithand.c:539
void handle_edit_toggle_fogofwar(struct connection *pc, int plr_no)
Definition edithand.c:1315
void handle_edit_startpos_full(struct connection *pconn, const struct packet_edit_startpos_full *packet)
Definition edithand.c:1386
static void check_leaving_edit_mode(void)
Definition edithand.c:164
void handle_edit_player_create(struct connection *pc, int tag)
Definition edithand.c:903
void handle_edit_recalculate_borders(struct connection *pc)
Definition edithand.c:1280
void handle_save_scenario(struct connection *pc, const char *name)
Definition edithand.c:1499
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:611
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:1348
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:381
int Terrain_type_id
Definition fc_types.h:377
int Unit_type_id
Definition fc_types.h:386
#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:61
struct world wld
Definition game.c:62
struct unit * game_unit_by_number(int id)
Definition game.c:115
struct city * game_city_by_number(int id)
Definition game.c:106
void send_scenario_description(struct conn_list *dest)
Definition gamehand.c:967
void send_scenario_info(struct conn_list *dest)
Definition gamehand.c:953
void send_game_info(struct conn_list *dest)
Definition gamehand.c:910
struct government * government_by_number(const Government_type_id gov)
Definition government.c:103
struct city * owner
Definition citydlg.c:226
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:1912
struct startpos * map_startpos_new(struct tile *ptile)
Definition map.c:1895
struct tile * startpos_tile(const struct startpos *psp)
Definition map.c:1694
bool startpos_pack(const struct startpos *psp, struct packet_edit_startpos_full *packet)
Definition map.c:1728
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Definition map.c:462
bool map_startpos_remove(struct tile *ptile)
Definition map.c:1928
bool startpos_unpack(struct startpos *psp, const struct packet_edit_startpos_full *packet)
Definition map.c:1749
#define map_startpos_iterate(NAME_psp)
Definition map.h:125
#define square_iterate(nmap, center_tile, radius, tile_itr)
Definition map.h:377
#define square_iterate_end
Definition map.h:380
#define map_startpos_iterate_end
Definition map.h:128
#define MAP_TILE_OWNER_NULL
Definition map.h:588
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:1942
void disable_fog_of_war_player(struct player *pplayer)
Definition maphand.c:1778
void map_show_tile(struct player *src_player, struct tile *ptile)
Definition maphand.c:775
void tile_change_side_effects(struct tile *ptile, bool refresh_city)
Definition maphand.c:2729
void terrain_changed(struct tile *ptile)
Definition maphand.c:1961
void map_calculate_borders(void)
Definition maphand.c:2378
void fix_tile_on_terrain_change(struct tile *ptile, struct terrain *oldter, bool extend_rivers)
Definition maphand.c:1980
void enable_fog_of_war_player(struct player *pplayer)
Definition maphand.c:1754
void map_show_circle(struct player *pplayer, struct tile *ptile, int radius_sq)
Definition maphand.c:871
void update_tile_knowledge(struct tile *ptile)
Definition maphand.c:1446
void map_hide_tile(struct player *src_player, struct tile *ptile)
Definition maphand.c:827
#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:289
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:1996
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:1409
#define players_iterate_end
Definition player.h:539
#define players_iterate(_pplayer)
Definition player.h:534
#define ANON_USER_NAME
Definition player.h:48
static bool is_barbarian(const struct player *pplayer)
Definition player.h:491
void send_player_all_c(struct player *src, struct conn_list *dest)
Definition plrhand.c:1129
struct player * server_create_player(int player_id, const char *ai_tname, struct rgbcolor *prgbcolor, bool allow_ai_type_fallbacking)
Definition plrhand.c:1894
void player_limit_to_max_rates(struct player *pplayer)
Definition plrhand.c:2057
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:2168
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:2456
void kill_player(struct player *pplayer)
Definition plrhand.c:125
void send_player_info_c(struct player *src, struct conn_list *dest)
Definition plrhand.c:1146
void server_remove_player(struct player *pplayer)
Definition plrhand.c:1943
void government_change(struct player *pplayer, struct government *gov, bool revolution_finished)
Definition plrhand.c:336
void server_player_init(struct player *pplayer, bool initmap, bool needs_team)
Definition plrhand.c:1618
void assign_player_colors(void)
Definition plrhand.c:1734
bool nation_is_in_current_set(const struct nation_type *pnation)
Definition plrhand.c:2593
int revolution_length(struct government *gov, struct player *plr)
Definition plrhand.c:549
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:143
#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:2620
bool game_was_started(void)
Definition srv_main.c:354
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:122
int infra_points
Definition player.h:67
struct player_ai ai_common
Definition player.h:288
bv_plr_flags flags
Definition player.h:292
int autoselect_weight
Definition player.h:299
char username[MAX_LEN_NAME]
Definition player.h:252
bool is_connected
Definition player.h:296
int revolution_finishes
Definition player.h:273
struct government * government
Definition player.h:258
struct conn_list * connections
Definition player.h:298
bool is_alive
Definition player.h:268
struct player_economic economic
Definition player.h:284
bool unassigned_user
Definition player.h:253
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:40
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:140
int moves_left
Definition unit.h:152
int id
Definition unit.h:147
bool moved
Definition unit.h:176
int hp
Definition unit.h:153
int fuel
Definition unit.h:155
bool stay
Definition unit.h:208
bool done_moving
Definition unit.h:184
int veteran
Definition unit.h:154
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:249
#define A_FIRST
Definition tech.h:44
#define A_UNSET
Definition tech.h:48
#define advance_index_iterate(_start, _index)
Definition tech.h:245
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:176
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:1097
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:89
#define tile_hash_iterate(hash, ptile)
Definition tile.h:83
#define tile_terrain(_tile)
Definition tile.h:111
#define tile_hash_iterate_end
Definition tile.h:85
#define TILE_XY(ptile)
Definition tile.h:43
#define tile_has_extra(ptile, pextra)
Definition tile.h:148
#define unit_owner(_pu)
Definition unit.h:396
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer, bool everyone_non_allied)
Definition unit.h:433
#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:2878
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:1606
void wipe_unit(struct unit *punit, enum unit_loss_reason reason, struct player *killer)
Definition unittools.c:2140
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:756
#define utype_fuel(ptype)
Definition unittype.h:843
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:624