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 "capability.h"
23#include "fcintl.h"
24#include "log.h"
25#include "shared.h"
26#include "support.h"
27
28/* common */
29#include "events.h"
30#include "game.h"
31#include "government.h"
32#include "map.h"
33#include "movement.h"
34#include "nation.h"
35#include "terrain.h"
36#include "research.h"
37#include "unitlist.h"
38
39/* server */
40#include "aiiface.h"
41#include "citytools.h"
42#include "cityturn.h"
43#include "connecthand.h"
44#include "gamehand.h"
45#include <hand_gen.h> /* <> so looked from the build directory first. */
46#include "maphand.h"
47#include "plrhand.h"
48#include "notify.h"
49#include "sanitycheck.h"
50#include "stdinhand.h"
51#include "techtools.h"
52#include "unittools.h"
53
54/* server/generator */
55#include "mapgen_utils.h"
56
57/* server/savegame */
58#include "savemain.h"
59
60#include "edithand.h"
61
62/* Set if anything in a sequence of edits triggers the expensive
63 * assign_continent_numbers() check, which will be done once when the
64 * sequence is complete. */
66/* Hold pointers to tiles which were changed during the edit sequence,
67 * so that they can be sanity-checked when the sequence is complete
68 * and final global fix-ups have been done. */
69static struct tile_hash *modified_tile_table = NULL;
70
71/* Array of size player_slot_count() indexed by player
72 * number to tell whether a given player has fog of war
73 * disabled in edit mode. */
74static bool *unfogged_players;
75
76/************************************************************************/
93
94/************************************************************************/
109
110/************************************************************************/
114{
117
118 if (NULL == dest) {
119 dest = game.est_connections;
120 }
121
122 /* Send map start positions. */
125 startpos.removal = FALSE;
126 startpos.tag = 0;
127
129
130 conn_list_iterate(dest, pconn) {
131 if (can_conn_edit(pconn)) {
134 }
135
136 if (pconn->playing != NULL) {
139 }
142}
143
144/************************************************************************/
149{
154
155 /* FIXME: adv / ai phase handling like in check_terrain_change() */
156 }
157
158#ifdef SANITY_CHECKING
160 sanity_check_tile(ptile);
162#endif /* SANITY_CHECKING */
164}
165
166/************************************************************************/
170static void check_leaving_edit_mode(void)
171{
172 bool unfogged;
173
175 players_iterate(pplayer) {
177 if (unfogged && game.info.fogofwar) {
179 } else if (!unfogged && !game.info.fogofwar) {
181 }
183
184 /* Clear the whole array. */
185 memset(unfogged_players, 0, player_slot_count() * sizeof(bool));
186
189}
190
191/************************************************************************/
194void handle_edit_mode(struct connection *pc, bool is_edit_mode)
195{
197 return;
198 }
199
200 if (!game.info.is_edit_mode && is_edit_mode) {
201 /* Someone could be cheating! Warn people. */
203 _(" *** Server set to edit mode by %s! *** "),
205 }
206
207 if (game.info.is_edit_mode && !is_edit_mode) {
209 _(" *** Edit mode canceled by %s. *** "),
211
213 }
214
215 if (game.info.is_edit_mode != is_edit_mode) {
216 game.info.is_edit_mode = is_edit_mode;
217
220 }
221}
222
223/************************************************************************/
227static bool edit_tile_terrain_handling(struct tile *ptile,
228 struct terrain *pterrain,
229 bool send_info)
230{
231 struct terrain *old_terrain = tile_terrain(ptile);
232
233 if (old_terrain == pterrain
234 || (terrain_has_flag(pterrain, TER_NO_CITIES)
235 && NULL != tile_city(ptile))) {
236 return FALSE;
237 }
238
239 tile_change_terrain(ptile, pterrain);
244 }
245
246 if (send_info) {
248 }
249
251
252 return TRUE;
253}
254
255/************************************************************************/
259static bool edit_tile_extra_handling(struct tile *ptile,
260 struct extra_type *pextra,
261 bool remove_mode, bool send_info)
262{
263 if (remove_mode) {
264 if (!tile_has_extra(ptile, pextra)) {
265 return FALSE;
266 }
267
268 if (!tile_extra_rm_apply(ptile, pextra)) {
269 return FALSE;
270 }
271
272 terrain_changed(ptile);
273
274 } else {
275 if (tile_has_extra(ptile, pextra)) {
276 return FALSE;
277 }
278
279 if (!tile_extra_apply(ptile, pextra)) {
280 return FALSE;
281 }
282
284 && terrain_has_resource(ptile->terrain, pextra)) {
285 tile_set_resource(ptile, pextra);
286 }
287 }
288
289 if (send_info) {
291 }
292
294
295 return TRUE;
296}
297
298/************************************************************************/
306{
307 struct terrain *pterrain;
308 struct tile *ptile_center;
309
311 if (!ptile_center) {
313 _("Cannot edit the tile because %d is not a valid "
314 "tile index on this map!"), tile);
315 return;
316 }
317
318 pterrain = terrain_by_number(terrain);
319 if (!pterrain) {
321 /* TRANS: ..." the tile <tile-coordinates> because"... */
322 _("Cannot modify terrain for the tile %s because "
323 "%d is not a valid terrain id."),
325 return;
326 }
327
329 /* This iterates outward, which gives any units that can't survive on
330 * changed terrain the best chance of survival. */
331 square_iterate(&(wld.map), ptile_center, size - 1, ptile) {
332 edit_tile_terrain_handling(ptile, pterrain, TRUE);
335}
336
337/************************************************************************/
342 int id, bool removal, int eowner, int size)
343{
344 struct tile *ptile_center;
345 struct player *plr_eowner;
346
348 if (!ptile_center) {
350 _("Cannot edit the tile because %d is not a valid "
351 "tile index on this map!"), tile);
352 return;
353 }
354
357 /* TRANS: ..." the tile <tile-coordinates> because"... */
358 _("Cannot modify extras for the tile %s because "
359 "%d is not a valid extra id."),
361 return;
362 }
363
364 if (eowner != MAP_TILE_OWNER_NULL
365 && (eowner != MAX_UINT8
366 || has_capability("ownernull16", pc->capability))) {
368 } else {
370 }
371
373 square_iterate(&(wld.map), ptile_center, size - 1, ptile) {
374 ptile->extras_owner = plr_eowner;
375 edit_tile_extra_handling(ptile, extra_by_number(id), removal, TRUE);
378}
379
380/************************************************************************/
384 const struct packet_edit_tile *packet)
385{
386 struct tile *ptile;
387 struct player *eowner;
388 bool changed = FALSE;
389
390 ptile = index_to_tile(&(wld.map), packet->tile);
391 if (!ptile) {
393 _("Cannot edit the tile because %d is not a valid "
394 "tile index on this map!"), packet->tile);
395 return;
396 }
397
398 if (packet->eowner != MAP_TILE_OWNER_NULL
399 && (packet->eowner != MAX_UINT8
400 || has_capability("ownernull16", pc->capability))) {
401 eowner = player_by_number(packet->eowner);
402 } else {
403 eowner = NULL;
404 }
405
406 /* Handle changes in extras. */
407 if (!BV_ARE_EQUAL(packet->extras, ptile->extras)) {
408 extra_type_iterate(pextra) {
409 if (edit_tile_extra_handling(ptile, pextra,
410 !BV_ISSET(packet->extras, extra_number(pextra)),
411 FALSE)) {
412 changed = TRUE;
413 }
415 }
416
417 if (ptile->extras_owner != eowner) {
418 ptile->extras_owner = eowner;
419 changed = TRUE;
420 }
421
422 /* Handle changes in label */
423 if (tile_set_label(ptile, packet->label)) {
424 changed = TRUE;
425 }
426
427 /* TODO: Handle more property edits. */
428
429
430 /* Send the new state to all affected. */
431 if (changed) {
433 send_tile_info(NULL, ptile, FALSE);
434 }
435
437}
438
439/************************************************************************/
444 Unit_type_id utid, int count, int tag)
445{
446 struct tile *ptile;
447 struct unit_type *punittype;
448 struct player *pplayer;
449 struct city *homecity;
450 struct unit *punit;
451 int id, i;
452
453 ptile = index_to_tile(&(wld.map), tile);
454 if (!ptile) {
456 _("Cannot create units because %d is not a valid "
457 "tile index on this map!"), tile);
458 return;
459 }
460
462 if (!punittype) {
463 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
464 /* TRANS: ..." at <tile-coordinates> because"... */
465 _("Cannot create a unit at %s because the "
466 "given unit type id %d is invalid."),
467 tile_link(ptile), utid);
468 return;
469 }
470
471 pplayer = player_by_number(owner);
472 if (!pplayer) {
473 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
474 /* TRANS: ..." type <unit-type> at <tile-coordinates>"... */
475 _("Cannot create a unit of type %s at %s "
476 "because the given owner's player id %d is "
477 "invalid."), utype_name_translation(punittype),
478 tile_link(ptile), owner);
479 return;
480 }
481
484 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
485 _("Cannot create another instance of unique unit type %s. "
486 "Player already has one such unit."),
488 return;
489 }
490 if (count > 1) {
491 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
492 _("Cannot create multiple instances of unique unit type %s."),
494 return;
495 }
496 }
497
498 if (is_non_allied_unit_tile(ptile, pplayer)
499 || (tile_city(ptile)
500 && !pplayers_allied(pplayer, city_owner(tile_city(ptile))))) {
501 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
502 /* TRANS: ..." type <unit-type> on enemy tile
503 * <tile-coordinates>"... */
504 _("Cannot create unit of type %s on enemy tile "
506 tile_link(ptile));
507 return;
508 }
509
510 if (!can_exist_at_tile(&(wld.map), punittype, ptile)) {
511 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
512 /* TRANS: ..." type <unit-type> on the terrain at
513 * <tile-coordinates>"... */
514 _("Cannot create a unit of type %s on the terrain "
515 "at %s."),
517 return;
518 }
519
520 if (count > 0 && !pplayer->is_alive) {
521 pplayer->is_alive = TRUE;
522 send_player_info_c(pplayer, NULL);
523 }
524
525 homecity = find_closest_city(ptile, NULL, pplayer, FALSE, FALSE, FALSE,
527 id = homecity ? homecity->id : 0;
528
530 map_show_circle(pplayer, ptile, punittype->vision_radius_sq);
531 for (i = 0; i < count; i++) {
532 /* As far as I can see create_unit is guaranteed to
533 * never return NULL. */
534 punit = create_unit(pplayer, ptile, punittype, 0, id, -1);
535 if (tag > 0) {
537 }
538 }
540}
541
542/************************************************************************/
547 int tile, Unit_type_id utid, int count)
548{
549 struct tile *ptile;
550 struct unit_type *punittype;
551 struct player *pplayer;
552 int i;
553
554 ptile = index_to_tile(&(wld.map), tile);
555 if (!ptile) {
557 _("Cannot remove units because %d is not a valid "
558 "tile index on this map!"), tile);
559 return;
560 }
561
563 if (!punittype) {
564 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
565 /* TRANS: ..." at <tile-coordinates> because"... */
566 _("Cannot remove a unit at %s because the "
567 "given unit type id %d is invalid."),
568 tile_link(ptile), utid);
569 return;
570 }
571
572 pplayer = player_by_number(owner);
573 if (!pplayer) {
574 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
575 /* TRANS: ..." type <unit-type> at <tile-coordinates>
576 * because"... */
577 _("Cannot remove a unit of type %s at %s "
578 "because the given owner's player id %d is "
579 "invalid."), utype_name_translation(punittype),
580 tile_link(ptile), owner);
581 return;
582 }
583
584 i = 0;
586 if (i >= count) {
587 break;
588 }
590 || unit_owner(punit) != pplayer) {
591 continue;
592 }
594 i++;
596}
597
598/************************************************************************/
602{
603 struct unit *punit;
604
606 if (!punit) {
608 _("No such unit (ID %d)."), id);
609 return;
610 }
611
613}
614
615/************************************************************************/
619 const struct packet_edit_unit *packet)
620{
621 const struct unit_type *putype;
622 struct unit *punit;
623 int id;
624 bool changed = FALSE;
625 int fuel, hp;
626
627 id = packet->id;
629 if (!punit) {
631 _("No such unit (ID %d)."), id);
632 return;
633 }
634
636
637 if (packet->moves_left != punit->moves_left) {
638 punit->moves_left = packet->moves_left;
639 changed = TRUE;
640 }
641
642 fuel = CLIP(0, packet->fuel, utype_fuel(putype));
643 if (fuel != punit->fuel) {
644 punit->fuel = fuel;
645 changed = TRUE;
646 }
647
648 if (packet->moved != punit->moved) {
649 punit->moved = packet->moved;
650 changed = TRUE;
651 }
652
653 if (packet->done_moving != punit->done_moving) {
654 punit->done_moving = packet->done_moving;
655 changed = TRUE;
656 }
657
658 hp = CLIP(1, packet->hp, putype->hp);
659 if (hp != punit->hp) {
660 punit->hp = hp;
661 changed = TRUE;
662 }
663
664 if (packet->veteran != punit->veteran) {
665 int v = packet->veteran;
666
667 if (utype_veteran_level(putype, v) == NULL) {
669 _("Invalid veteran level %d for unit %d (%s)."),
670 v, id, unit_link(punit));
671 } else {
672 punit->veteran = v;
673 changed = TRUE;
674 }
675 }
676
677 if (packet->stay != punit->stay) {
678 punit->stay = packet->stay;
679 changed = TRUE;
680 }
681
682 /* TODO: Handle more property edits. */
683
684
685 /* Send the new state to all affected. */
686 if (changed) {
688 }
689}
690
691/************************************************************************/
696 int size, int tag)
697{
698 struct tile *ptile;
699 struct city *pcity;
700 struct player *pplayer;
701
702 ptile = index_to_tile(&(wld.map), tile);
703 if (!ptile) {
705 _("Cannot create a city because %d is not a valid "
706 "tile index on this map!"), tile);
707 return;
708 }
709
710 pplayer = player_by_number(owner);
711 if (!pplayer) {
712 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
713 /* TRANS: ..." at <tile-coordinates> because"... */
714 _("Cannot create a city at %s because the "
715 "given owner's player id %d is invalid"),
716 tile_link(ptile), owner);
717 return;
718
719 }
720
722
723 if (!create_city_for_player(pplayer, ptile, NULL)) {
724 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
725 /* TRANS: ..." at <tile-coordinates>." */
726 _("A city may not be built at %s."), tile_link(ptile));
728
729 return;
730 }
731
732 pcity = tile_city(ptile);
733
734 if (size > 1) {
735 /* FIXME: Slow and inefficient for large size changes. */
736 city_change_size(pcity, CLIP(1, size, MAX_CITY_SIZE), pplayer, NULL);
737 send_city_info(NULL, pcity);
738 }
739
740 if (tag > 0) {
742 }
743
745}
746
747
748/************************************************************************/
752 const struct packet_edit_city *packet)
753{
754 struct tile *ptile;
755 struct city *pcity, *oldcity;
756 struct player *pplayer;
757 char buf[1024];
758 int id;
759 bool changed = FALSE;
760 bool need_game_info = FALSE;
762
763 pcity = game_city_by_number(packet->id);
764 if (!pcity) {
766 _("Cannot edit city with invalid city ID %d."),
767 packet->id);
768 return;
769 }
770
771 pplayer = city_owner(pcity);
772 ptile = city_tile(pcity);
774
775 /* Handle name change. */
776 if (0 != strcmp(pcity->name, packet->name)) {
777 if (!is_allowed_city_name(pplayer, packet->name, buf, sizeof(buf))) {
778 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
779 _("Cannot edit city name: %s"), buf);
780 } else {
781 city_name_set(pcity, packet->name);
782 changed = TRUE;
783 }
784 }
785
786 /* Handle size change. */
787 if (packet->size != city_size_get(pcity)) {
788 if (!(0 < packet->size && packet->size <= MAX_CITY_SIZE)) {
789 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
790 _("Invalid city size %d for city %s."),
791 packet->size, city_link(pcity));
792 } else {
793 /* FIXME: Slow and inefficient for large size changes. */
794 city_change_size(pcity, packet->size, NULL, NULL);
795 changed = TRUE;
796 }
797 }
798
799 if (packet->history != pcity->history) {
800 pcity->history = packet->history;
801 changed = TRUE;
802 }
803
804 /* Handle city improvement changes. */
805 improvement_iterate(pimprove) {
806 oldcity = NULL;
807 id = improvement_number(pimprove);
808
809 if (is_special_improvement(pimprove)) {
810 if (packet->built[id] >= 0) {
811 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
812 _("It is impossible for a city to have %s!"),
814 }
815 continue;
816 }
817
818 /* FIXME: game.info.great_wonder_owners and pplayer->wonders
819 * logic duplication with city_build_building. */
820
821 if (city_has_building(pcity, pimprove) && packet->built[id] < 0) {
822
823 city_remove_improvement(pcity, pimprove);
824 changed = TRUE;
825
826 } else if (!city_has_building(pcity, pimprove)
827 && packet->built[id] >= 0) {
828 struct player *old_owner = NULL;
829
830 oldcity = build_or_move_building(pcity, pimprove, &old_owner);
831 if (oldcity != pcity) {
833 }
834 if (oldcity && old_owner != pplayer) {
835 /* Great wonders make more changes. */
837 if (old_owner) {
839 }
840 }
841
842 if (oldcity) {
844 }
845 changed = TRUE;
846 }
848
849 /* Handle food stock change. */
850 if (packet->food_stock != pcity->food_stock) {
851 int max = city_granary_size(city_size_get(pcity));
852 if (!(0 <= packet->food_stock && packet->food_stock <= max)) {
853 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
854 _("Invalid city food stock amount %d for city %s "
855 "(allowed range is %d to %d)."),
856 packet->food_stock, city_link(pcity), 0, max);
857 } else {
858 pcity->food_stock = packet->food_stock;
859 changed = TRUE;
860 }
861 }
862
863 /* Handle shield stock change. */
864 if (packet->shield_stock != pcity->shield_stock) {
865 int max = USHRT_MAX; /* Limited to uint16 by city info packet. */
866
867 if (!(0 <= packet->shield_stock && packet->shield_stock <= max)) {
868 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
869 _("Invalid city shield stock amount %d for city %s "
870 "(allowed range is %d to %d)."),
871 packet->shield_stock, city_link(pcity), 0, max);
872 } else {
873 pcity->shield_stock = packet->shield_stock;
874 /* Make sure the shields stay if changing production back and forth */
875 pcity->before_change_shields = packet->shield_stock;
876 changed = TRUE;
877 }
878 }
879
880 /* TODO: Handle more property edits. */
881
882
883 if (changed) {
887
888 /* FIXME: city_refresh_queue_processing only sends to city owner? */
889 send_city_info(NULL, pcity);
890
892 }
893
894 /* Update wonder infos. */
895 if (need_game_info) {
897 }
901 /* No need to send to detached connections. */
903 }
905 }
906}
907
908/************************************************************************/
912{
913 struct player *pplayer;
914 struct nation_type *pnation;
915 struct research *presearch;
916 int existing = player_count();
917
918 if (existing >= player_slot_count()) {
920 _("No more players can be added because the maximum "
921 "number of players (%d) has been reached."),
923 return;
924 }
925
928 _("No more players can be added because there's "
929 "already maximum number of players allowed by maxplayers setting (value %d)"),
931 return;
932 }
933
934 if (existing >= nation_count() ) {
936 _("No more players can be added because there are "
937 "no available nations (%d used)."),
938 nation_count());
939 return;
940 }
941
943 if (!pnation) {
945 _("Player cannot be created because random nation "
946 "selection failed."));
947 return;
948 }
949
951 NULL, FALSE);
952 if (!pplayer) {
954 _("Player creation failed."));
955 return;
956 }
957 server_player_init(pplayer, TRUE, TRUE);
958
959 player_nation_defaults(pplayer, pnation, TRUE);
960 if (game_was_started()) {
961 /* Find a color for the new player. */
963 }
965 pplayer->unassigned_user = TRUE;
966 pplayer->is_connected = FALSE;
967 pplayer->government = init_government_of_nation(pnation);
968 BV_CLR(pplayer->flags, PLRF_FIRST_CITY);
969
970 pplayer->economic.gold = 0;
971 pplayer->economic.infra_points = 0;
973
974 presearch = research_get(pplayer);
977
978 send_player_all_c(pplayer, NULL);
979 /* Send research info after player info, else the client will complain
980 * about invalid team. */
982 if (tag > 0) {
984 }
985}
986
987/************************************************************************/
991{
992 struct player *pplayer;
993
994 pplayer = player_by_number(id);
995 if (pplayer == NULL) {
997 _("No such player (ID %d)."), id);
998 return;
999 }
1000
1001 /* Don't use conn_list_iterate here because connection_detach() can be
1002 * recursive and free the next connection pointer. */
1003 while (conn_list_size(pplayer->connections) > 0) {
1005 }
1006
1007 kill_player(pplayer);
1008 server_remove_player(pplayer);
1009}
1010
1011/************************************************************************/
1015 const struct packet_edit_player *packet)
1016{
1017 struct player *pplayer;
1018 bool changed = FALSE, update_research = FALSE;
1019 struct nation_type *pnation;
1020 struct research *research;
1021 enum tech_state known;
1022 struct government *gov;
1023
1024 pplayer = player_by_number(packet->id);
1025 if (!pplayer) {
1027 _("Cannot edit player with invalid player ID %d."),
1028 packet->id);
1029 return;
1030 }
1031
1032 research = research_get(pplayer);
1033
1034
1035 /* Handle player name change. */
1036 if (0 != strcmp(packet->name, player_name(pplayer))) {
1037 char error_buf[256];
1038
1039 if (server_player_set_name_full(pc, pplayer, NULL, packet->name,
1040 error_buf, sizeof(error_buf))) {
1041 changed = TRUE;
1042 } else {
1044 _("Cannot change name of player (%d) '%s' to '%s': %s"),
1045 player_number(pplayer), player_name(pplayer),
1046 packet->name, error_buf);
1047 }
1048 }
1049
1050 /* Handle nation change. */
1051 pnation = nation_by_number(packet->nation);
1052 if (nation_of_player(pplayer) != pnation) {
1053 if (pnation == NULL) {
1055 _("Cannot change nation for player %d (%s) "
1056 "because the given nation ID %d is invalid."),
1057 player_number(pplayer), player_name(pplayer),
1058 packet->nation);
1059 } else if (pnation->player != NULL) {
1061 _("Cannot change nation for player %d (%s) "
1062 "to nation %d (%s) because that nation is "
1063 "already assigned to player %d (%s)."),
1064 player_number(pplayer), player_name(pplayer),
1065 packet->nation, nation_plural_translation(pnation),
1066 player_number(pnation->player),
1067 player_name(pnation->player));
1068 } else if (!nation_is_in_current_set(pnation)) {
1070 _("Cannot change nation for player %d (%s) "
1071 "to nation %d (%s) because that nation is "
1072 "not in the current nation set."),
1073 player_number(pplayer), player_name(pplayer),
1074 packet->nation, nation_plural_translation(pnation));
1075 } else if (pplayer->ai_common.barbarian_type
1076 != nation_barbarian_type(pnation)
1077 || (!is_barbarian(pplayer) && !is_nation_playable(pnation))) {
1079 _("Cannot change nation for player %d (%s) "
1080 "to nation %d (%s) because that nation is "
1081 "unsuitable for this player."),
1082 player_number(pplayer), player_name(pplayer),
1083 packet->nation, nation_plural_translation(pnation));
1084 } else {
1085 changed = player_set_nation(pplayer, pnation);
1086 }
1087 }
1088
1089 /* Handle a change in research progress. */
1090 if (packet->bulbs_researched != research->bulbs_researched) {
1092 changed = TRUE;
1094 }
1095
1096 /* Handle a change in known inventions. */
1098 known = research_invention_state(research, tech);
1099 if ((packet->inventions[tech] && known == TECH_KNOWN)
1100 || (!packet->inventions[tech] && known != TECH_KNOWN)) {
1101 continue;
1102 }
1103 if (packet->inventions[tech]) {
1104 /* FIXME: Side-effect modifies game.info.global_advances. */
1107 } else {
1110 }
1111 changed = TRUE;
1114
1115 /* Handle a change in the player's gold. */
1116 if (packet->gold != pplayer->economic.gold) {
1117 if (!(0 <= packet->gold && packet->gold <= 1000000)) {
1119 _("Cannot set gold for player %d (%s) because "
1120 "the value %d is outside the allowed range."),
1121 player_number(pplayer), player_name(pplayer),
1122 packet->gold);
1123 } else {
1124 pplayer->economic.gold = packet->gold;
1125 changed = TRUE;
1126 }
1127 }
1128
1129 /* Handle a change in the player's infrapoints. */
1130 if (packet->infrapoints != pplayer->economic.infra_points) {
1131 if (!(0 <= packet->infrapoints && packet->infrapoints <= 1000000)) {
1133 _("Cannot set infrapoints for player %d (%s) because "
1134 "the value %d is outside the allowed range."),
1135 player_number(pplayer), player_name(pplayer),
1136 packet->infrapoints);
1137 } else {
1138 pplayer->economic.infra_points = packet->infrapoints;
1139 changed = TRUE;
1140 }
1141 }
1142
1143 /* Handle a change in the player's autoselect weight. */
1144 if (packet->autoselect_weight != pplayer->autoselect_weight) {
1145 pplayer->autoselect_weight = packet->autoselect_weight;
1146 changed = TRUE;
1147 }
1148
1149 /* Handle player government change */
1150 gov = government_by_number(packet->government);
1151 if (gov != pplayer->government) {
1153 government_change(pplayer, gov, FALSE);
1154 } else {
1155 int turns = revolution_length(gov, pplayer);
1156
1157 if (turns >= 0) {
1158 pplayer->government = gov;
1159 pplayer->revolution_finishes = game.info.turn + turns;
1160 }
1161 }
1162
1163 changed = TRUE;
1164 }
1165
1166 if (packet->scenario_reserved) {
1167 if (!player_has_flag(pplayer, PLRF_SCENARIO_RESERVED)) {
1168 changed = TRUE;
1170 }
1171 } else {
1173 changed = TRUE;
1175 }
1176 }
1177
1178 /* TODO: Handle more property edits. */
1179
1180 if (update_research) {
1181 Tech_type_id current, goal;
1182
1184
1185 /* FIXME: Modifies struct research directly. */
1186
1187 current = research->researching;
1188 goal = research->tech_goal;
1189
1190 if (current != A_UNSET) {
1191 if (current != A_FUTURE) {
1192 known = research_invention_state(research, current);
1193 if (known != TECH_PREREQS_KNOWN) {
1195 }
1196 } else {
1197 /* Future Tech is legal only if all techs are known */
1200 if (known != TECH_KNOWN) {
1202 break;
1203 }
1205 }
1206 }
1207 if (goal != A_UNSET) {
1208 if (goal != A_FUTURE) {
1209 known = research_invention_state(research, goal);
1210 if (known == TECH_KNOWN) {
1212 }
1213 }
1214 }
1215 changed = TRUE;
1216
1217 /* Inform everybody about global advances */
1220 }
1221
1222 if (changed) {
1223 send_player_all_c(pplayer, NULL);
1224 }
1225}
1226
1227/************************************************************************/
1231 int tile, bool known, int size)
1232{
1233 struct player *pplayer;
1234 struct tile *ptile_center;
1235
1237 if (!ptile_center) {
1239 _("Cannot edit vision because %d is not a valid "
1240 "tile index on this map!"), tile);
1241 return;
1242 }
1243
1244 pplayer = player_by_number(plr_no);
1245 if (!pplayer) {
1247 /* TRANS: ..." at <tile-coordinates> because"... */
1248 _("Cannot edit vision for the tile at %s because "
1249 "given player id %d is invalid."),
1251 return;
1252 }
1253
1255 square_iterate(&(wld.map), ptile_center, size - 1, ptile) {
1256
1257 if (!known) {
1258 struct city *pcity = tile_city(ptile);
1260
1261 if (pcity && city_owner(pcity) == pplayer) {
1262 continue;
1263 }
1264
1265 unit_list_iterate(ptile->units, punit) {
1266 if (unit_owner(punit) == pplayer
1267 || really_gives_vision(pplayer, unit_owner(punit))) {
1269 break;
1270 }
1272
1273 if (cannot_make_unknown) {
1274 continue;
1275 }
1276
1277 /* The client expects tiles which become unseen to
1278 * contain no units (client/packhand.c +2368).
1279 * So here we tell it to remove units that do
1280 * not give it vision. */
1281 unit_list_iterate(ptile->units, punit) {
1286 }
1287
1288 if (known) {
1289 map_show_tile(pplayer, ptile);
1290 } else {
1291 map_hide_tile(pplayer, ptile);
1292 }
1295}
1296
1297/************************************************************************/
1306
1307/************************************************************************/
1311{
1312 struct city *pcity;
1313
1314 pcity = game_city_by_number(id);
1315 if (pcity == NULL) {
1317 _("No such city (ID %d)."), id);
1318 return;
1319 }
1320
1321 remove_city(pcity);
1322}
1323
1324/************************************************************************/
1331
1332/************************************************************************/
1338{
1339 struct player *pplayer;
1340
1341 if (!game.info.fogofwar) {
1343 _("Cannot toggle fog-of-war when it is already "
1344 "disabled."));
1345 return;
1346 }
1347
1348 pplayer = player_by_number(plr_no);
1349 if (!pplayer) {
1351 _("Cannot toggle fog-of-war for invalid player ID %d."),
1352 plr_no);
1353 return;
1354 }
1355
1357 if (unfogged_players[plr_no]) {
1358 enable_fog_of_war_player(pplayer);
1360 } else {
1363 }
1365}
1366
1367/************************************************************************/
1371 const struct packet_edit_startpos *packet)
1372{
1373 struct tile *ptile = index_to_tile(&(wld.map), packet->id);
1374 bool changed;
1375
1376 /* Check. */
1377 if (NULL == ptile) {
1379 _("Invalid tile index %d for start position."), packet->id);
1380 return;
1381 }
1382
1383 /* Handle. */
1384 if (packet->removal) {
1385 changed = map_startpos_remove(ptile);
1386 } else {
1387 if (NULL != map_startpos_get(ptile)) {
1388 changed = FALSE;
1389 } else {
1390 map_startpos_new(ptile);
1391 changed = TRUE;
1392 }
1393 }
1394
1395 /* Notify. */
1396 if (changed) {
1398 if (can_conn_edit(aconn)) {
1400 }
1402 }
1403}
1404
1405/************************************************************************/
1409 const struct packet_edit_startpos_full *
1410 packet)
1411{
1412 struct tile *ptile = index_to_tile(&(wld.map), packet->id);
1413 struct startpos *psp;
1414
1415 /* Check. */
1416 if (NULL == ptile) {
1418 _("Invalid tile index %d for start position."),
1419 packet->id);
1420 return;
1421 }
1422
1423 psp = map_startpos_get(ptile);
1424 if (NULL == psp) {
1426 _("Cannot edit start position nations at (%d, %d) "
1427 "because there is no start position there."),
1428 TILE_XY(ptile));
1429 return;
1430 }
1431
1432 /* Handle. */
1433 if (startpos_unpack(psp, packet)) {
1434 /* Notify. */
1436 if (can_conn_edit(aconn)) {
1438 }
1440 }
1441}
1442
1443/************************************************************************/
1447 const struct packet_edit_game *packet)
1448{
1449 bool changed = FALSE;
1450
1451 if (packet->scenario != game.scenario.is_scenario) {
1453 changed = TRUE;
1454 }
1455
1456 if (fc_strncmp(packet->scenario_name, game.scenario.name, 256)) {
1458 changed = TRUE;
1459 }
1460
1461 FC_STATIC_ASSERT(sizeof(packet->scenario_authors) == sizeof(game.scenario.authors),
1463
1465 sizeof(game.scenario.authors))) {
1467 changed = TRUE;
1468 }
1469
1470 if (packet->scenario_random != game.scenario.save_random) {
1472 changed = TRUE;
1473 }
1474
1475 if (packet->scenario_players != game.scenario.players) {
1477 changed = TRUE;
1478 }
1479
1482 changed = TRUE;
1483 }
1484
1487 changed = TRUE;
1488 }
1489
1490 if (packet->lake_flooding != game.scenario.lake_flooding) {
1492 changed = TRUE;
1493 }
1494
1495 if (packet->ruleset_locked != game.scenario.ruleset_locked) {
1497 changed = TRUE;
1498 }
1499
1500 if (changed) {
1503 }
1504}
1505
1506/************************************************************************/
1509void handle_edit_scenario_desc(struct connection *pc, const char *scenario_desc)
1510{
1511 if (fc_strncmp(scenario_desc, game.scenario_desc.description,
1512 MAX_LEN_PACKET)) {
1513 sz_strlcpy(game.scenario_desc.description, scenario_desc);
1515 }
1516}
1517
1518/************************************************************************/
1521void handle_save_scenario(struct connection *pc, const char *name)
1522{
1523 if (pc->access_level != ALLOW_HACK) {
1525 _("No permissions to remotely save scenario."));
1526 return;
1527 }
1528
1529 if (!game.scenario.is_scenario) {
1530 /* Scenario information not available */
1532 _("Scenario information not set. Cannot save scenario."));
1533 return;
1534 }
1535
1536 /* Client initiated scenario saving is not handmade */
1538
1539 save_game(name, "Scenario", TRUE);
1540}
const char * default_ai_type_name(void)
Definition aiiface.c:251
#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
bool has_capability(const char *cap, const char *capstr)
Definition capability.c:77
void city_name_set(struct city *pcity, const char *new_name)
Definition city.c:1145
int city_granary_size(int city_size)
Definition city.c:2132
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:1240
void city_remove_improvement(struct city *pcity, const struct impr_type *pimprove)
Definition city.c:3371
#define city_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:2363
struct city * build_or_move_building(struct city *pcity, struct impr_type *pimprove, struct player **oldcity_owner)
Definition citytools.c:3019
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:856
bool is_allowed_city_name(struct player *pplayer, const char *cityname, char *error_buf, size_t bufsz)
Definition citytools.c:374
void remove_city(struct city *pcity)
Definition citytools.c:1708
bool create_city_for_player(struct player *pplayer, struct tile *ptile, const char *name)
Definition citytools.c:1680
void city_refresh_queue_add(struct city *pcity)
Definition cityturn.c:198
bool city_change_size(struct city *pcity, citizens size, struct player *nationality, const char *reason)
Definition cityturn.c:1029
void city_refresh_queue_processing(void)
Definition cityturn.c:214
char * incite_cost
Definition comments.c:75
#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:601
void handle_edit_tile(struct connection *pc, const struct packet_edit_tile *packet)
Definition edithand.c:383
void handle_edit_scenario_desc(struct connection *pc, const char *scenario_desc)
Definition edithand.c:1509
void handle_edit_check_tiles(struct connection *pc)
Definition edithand.c:1327
void handle_edit_mode(struct connection *pc, bool is_edit_mode)
Definition edithand.c:194
void handle_edit_tile_terrain(struct connection *pc, int tile, Terrain_type_id terrain, int size)
Definition edithand.c:304
void handle_edit_player(struct connection *pc, const struct packet_edit_player *packet)
Definition edithand.c:1014
static bool need_continents_reassigned
Definition edithand.c:65
void edithand_send_initial_packets(struct conn_list *dest)
Definition edithand.c:113
static bool * unfogged_players
Definition edithand.c:74
static struct tile_hash * modified_tile_table
Definition edithand.c:69
void handle_edit_player_remove(struct connection *pc, int id)
Definition edithand.c:990
static bool edit_tile_terrain_handling(struct tile *ptile, struct terrain *pterrain, bool send_info)
Definition edithand.c:227
void handle_edit_city_remove(struct connection *pc, int id)
Definition edithand.c:1310
void edithand_free(void)
Definition edithand.c:97
void handle_edit_player_vision(struct connection *pc, int plr_no, int tile, bool known, int size)
Definition edithand.c:1230
void handle_edit_city(struct connection *pc, const struct packet_edit_city *packet)
Definition edithand.c:751
void edithand_init(void)
Definition edithand.c:79
void handle_edit_city_create(struct connection *pc, int owner, int tile, int size, int tag)
Definition edithand.c:695
static bool edit_tile_extra_handling(struct tile *ptile, struct extra_type *pextra, bool remove_mode, bool send_info)
Definition edithand.c:259
void handle_edit_game(struct connection *pc, const struct packet_edit_game *packet)
Definition edithand.c:1446
void handle_edit_unit_remove(struct connection *pc, int owner, int tile, Unit_type_id utid, int count)
Definition edithand.c:546
void handle_edit_toggle_fogofwar(struct connection *pc, int plr_no)
Definition edithand.c:1337
void handle_edit_startpos_full(struct connection *pconn, const struct packet_edit_startpos_full *packet)
Definition edithand.c:1408
static void check_leaving_edit_mode(void)
Definition edithand.c:170
void handle_edit_player_create(struct connection *pc, int tag)
Definition edithand.c:911
void handle_edit_recalculate_borders(struct connection *pc)
Definition edithand.c:1302
void handle_save_scenario(struct connection *pc, const char *name)
Definition edithand.c:1521
void handle_edit_tile_extra(struct connection *pc, int tile, int id, bool removal, int eowner, int size)
Definition edithand.c:341
void handle_edit_unit_create(struct connection *pc, int owner, int tile, Unit_type_id utid, int count, int tag)
Definition edithand.c:443
void handle_edit_unit(struct connection *pc, const struct packet_edit_unit *packet)
Definition edithand.c:618
static void check_edited_tile_terrains(void)
Definition edithand.c:148
void handle_edit_startpos(struct connection *pconn, const struct packet_edit_startpos *packet)
Definition edithand.c:1370
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:377
int Terrain_type_id
Definition fc_types.h:373
int Unit_type_id
Definition fc_types.h:382
#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: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: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:1937
void disable_fog_of_war_player(struct player *pplayer)
Definition maphand.c:1773
void map_show_tile(struct player *src_player, struct tile *ptile)
Definition maphand.c:768
void tile_change_side_effects(struct tile *ptile, bool refresh_city)
Definition maphand.c:2724
void terrain_changed(struct tile *ptile)
Definition maphand.c:1956
void map_calculate_borders(void)
Definition maphand.c:2373
void fix_tile_on_terrain_change(struct tile *ptile, struct terrain *oldter, bool extend_rivers)
Definition maphand.c:1975
void enable_fog_of_war_player(struct player *pplayer)
Definition maphand.c:1747
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:1439
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:279
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:238
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)
int dsend_packet_edit_fogofwar_state(struct connection *pc, bool enabled)
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: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:2453
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: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:337
void server_player_init(struct player *pplayer, bool initmap, bool needs_team)
Definition plrhand.c:1619
void assign_player_colors(void)
Definition plrhand.c:1734
bool nation_is_in_current_set(const struct nation_type *pnation)
Definition plrhand.c:2590
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:152
#define MAX_UINT8
Definition shared.h:83
#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:2581
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:160
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:195
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define fc_strncmp(_s1_, _s2_, _len_)
Definition support.h:160
#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:1094
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:1188
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:114
#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:151
#define unit_owner(_pu)
Definition unit.h:396
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:432
#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:2723
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:1598
void wipe_unit(struct unit *punit, enum unit_loss_reason reason, struct player *killer)
Definition unittools.c:2132
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:2597
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:839
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:617