Freeciv-3.4
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 }
134
135 if (pconn->playing != NULL) {
138 }
141}
142
143/************************************************************************/
148{
153
154 /* FIXME: adv / ai phase handling like in check_terrain_change() */
155 }
156
157#ifdef SANITY_CHECKING
159 sanity_check_tile(ptile);
161#endif /* SANITY_CHECKING */
163}
164
165/************************************************************************/
169static void check_leaving_edit_mode(void)
170{
171 bool unfogged;
172
174 players_iterate(pplayer) {
176 if (unfogged && game.info.fogofwar) {
178 } else if (!unfogged && !game.info.fogofwar) {
180 }
182
183 /* Clear the whole array. */
184 memset(unfogged_players, 0, player_slot_count() * sizeof(bool));
185
188}
189
190/************************************************************************/
193void handle_edit_mode(struct connection *pc, bool is_edit_mode)
194{
196 return;
197 }
198
199 if (!game.info.is_edit_mode && is_edit_mode) {
200 /* Someone could be cheating! Warn people. */
202 _(" *** Server set to edit mode by %s! *** "),
204 }
205
206 if (game.info.is_edit_mode && !is_edit_mode) {
208 _(" *** Edit mode canceled by %s. *** "),
210
212 }
213
214 if (game.info.is_edit_mode != is_edit_mode) {
215 game.info.is_edit_mode = is_edit_mode;
216
219 }
220}
221
222/************************************************************************/
226static bool edit_tile_terrain_handling(struct tile *ptile,
227 struct terrain *pterrain,
228 bool send_info)
229{
230 struct terrain *old_terrain = tile_terrain(ptile);
231
232 if (old_terrain == pterrain
233 || (terrain_has_flag(pterrain, TER_NO_CITIES)
234 && NULL != tile_city(ptile))) {
235 return FALSE;
236 }
237
238 tile_change_terrain(ptile, pterrain);
243 }
244
245 if (send_info) {
247 }
248
250
251 return TRUE;
252}
253
254/************************************************************************/
258static bool edit_tile_extra_handling(struct tile *ptile,
259 struct extra_type *pextra,
260 bool remove_mode, bool send_info)
261{
262 if (remove_mode) {
263 if (!tile_has_extra(ptile, pextra)) {
264 return FALSE;
265 }
266
267 if (!tile_extra_rm_apply(ptile, pextra)) {
268 return FALSE;
269 }
270
271 terrain_changed(ptile);
272
273 } else {
274 if (tile_has_extra(ptile, pextra)) {
275 return FALSE;
276 }
277
278 if (!tile_extra_apply(ptile, pextra)) {
279 return FALSE;
280 }
281
283 && terrain_has_resource(ptile->terrain, pextra)) {
284 tile_set_resource(ptile, pextra);
285 }
286 }
287
288 if (send_info) {
290 }
291
293
294 return TRUE;
295}
296
297/************************************************************************/
305{
306 struct terrain *pterrain;
307 struct tile *ptile_center;
308
310 if (!ptile_center) {
312 _("Cannot edit the tile because %d is not a valid "
313 "tile index on this map!"), tile);
314 return;
315 }
316
317 pterrain = terrain_by_number(terrain);
318 if (!pterrain) {
320 /* TRANS: ..." the tile <tile-coordinates> because"... */
321 _("Cannot modify terrain for the tile %s because "
322 "%d is not a valid terrain id."),
324 return;
325 }
326
328 /* This iterates outward, which gives any units that can't survive on
329 * changed terrain the best chance of survival. */
330 square_iterate(&(wld.map), ptile_center, size - 1, ptile) {
331 edit_tile_terrain_handling(ptile, pterrain, TRUE);
334}
335
336/************************************************************************/
341 int id, bool removal, int eowner, int size)
342{
343 struct tile *ptile_center;
344 struct player *plr_eowner;
345
347 if (!ptile_center) {
349 _("Cannot edit the tile because %d is not a valid "
350 "tile index on this map!"), tile);
351 return;
352 }
353
356 /* TRANS: ..." the tile <tile-coordinates> because"... */
357 _("Cannot modify extras for the tile %s because "
358 "%d is not a valid extra id."),
360 return;
361 }
362
363 if (eowner != MAP_TILE_OWNER_NULL) {
365 } else {
367 }
368
370 square_iterate(&(wld.map), ptile_center, size - 1, ptile) {
371 ptile->extras_owner = plr_eowner;
372 edit_tile_extra_handling(ptile, extra_by_number(id), removal, TRUE);
375}
376
377/************************************************************************/
381 const struct packet_edit_tile *packet)
382{
383 struct tile *ptile;
384 struct player *eowner;
385 bool changed = FALSE;
386
387 ptile = index_to_tile(&(wld.map), packet->tile);
388 if (!ptile) {
390 _("Cannot edit the tile because %d is not a valid "
391 "tile index on this map!"), packet->tile);
392 return;
393 }
394
395 if (packet->eowner != MAP_TILE_OWNER_NULL) {
396 eowner = player_by_number(packet->eowner);
397 } else {
398 eowner = NULL;
399 }
400
401 /* Handle changes in extras. */
402 if (!BV_ARE_EQUAL(packet->extras, ptile->extras)) {
403 extra_type_iterate(pextra) {
404 if (edit_tile_extra_handling(ptile, pextra,
405 !BV_ISSET(packet->extras, extra_number(pextra)),
406 FALSE)) {
407 changed = TRUE;
408 }
410 }
411
412 if (ptile->extras_owner != eowner) {
413 ptile->extras_owner = eowner;
414 changed = TRUE;
415 }
416
417 /* Handle changes in label */
418 if (tile_set_label(ptile, packet->label)) {
419 changed = TRUE;
420 }
421
422 /* TODO: Handle more property edits. */
423
424
425 /* Send the new state to all affected. */
426 if (changed) {
428 send_tile_info(NULL, ptile, FALSE);
429 }
430
432}
433
434/************************************************************************/
439 Unit_type_id utid, int count, int tag)
440{
441 struct tile *ptile;
442 struct unit_type *punittype;
443 struct player *pplayer;
444 struct city *homecity;
445 struct unit *punit;
446 struct city *pcity;
447 int id, i;
448
449 ptile = index_to_tile(&(wld.map), tile);
450 if (!ptile) {
452 _("Cannot create units because %d is not a valid "
453 "tile index on this map!"), tile);
454 return;
455 }
456
458 if (!punittype) {
459 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
460 /* TRANS: ..." at <tile-coordinates> because"... */
461 _("Cannot create a unit at %s because the "
462 "given unit type id %d is invalid."),
463 tile_link(ptile), utid);
464 return;
465 }
466
467 pplayer = player_by_number(owner);
468 if (!pplayer) {
469 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
470 /* TRANS: ..." type <unit-type> at <tile-coordinates>"... */
471 _("Cannot create a unit of type %s at %s "
472 "because the given owner's player id %d is "
473 "invalid."), utype_name_translation(punittype),
474 tile_link(ptile), owner);
475 return;
476 }
477
480 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
481 _("Cannot create another instance of unique unit type %s. "
482 "Player already has one such unit."),
484 return;
485 }
486 if (count > 1) {
487 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
488 _("Cannot create multiple instances of unique unit type %s."),
490 return;
491 }
492 }
493
494 pcity = tile_city(ptile);
495 if (is_non_allied_unit_tile(ptile, pplayer,
497 || (pcity != NULL
498 && !pplayers_allied(pplayer, city_owner(pcity)))) {
499 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
500 /* TRANS: ..." type <unit-type> on enemy tile
501 * <tile-coordinates>"... */
502 _("Cannot create unit of type %s on enemy tile "
504 tile_link(ptile));
505 return;
506 }
507
508 if (!can_exist_at_tile(&(wld.map), punittype, ptile)) {
509 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
510 /* TRANS: ..." type <unit-type> on the terrain at
511 * <tile-coordinates>"... */
512 _("Cannot create a unit of type %s on the terrain "
513 "at %s."),
515 return;
516 }
517
518 if (count > 0 && !pplayer->is_alive) {
519 pplayer->is_alive = TRUE;
520 send_player_info_c(pplayer, NULL);
521 }
522
523 homecity = find_closest_city(ptile, NULL, pplayer, FALSE, FALSE, FALSE,
525 id = homecity ? homecity->id : 0;
526
528 map_show_circle(pplayer, ptile, punittype->vision_radius_sq);
529 for (i = 0; i < count; i++) {
530 /* As far as I can see create_unit is guaranteed to
531 * never return NULL. */
532 punit = create_unit(pplayer, ptile, punittype, 0, id, -1);
533 if (tag > 0) {
535 }
536 }
538}
539
540/************************************************************************/
545 int tile, Unit_type_id utid, int count)
546{
547 struct tile *ptile;
548 struct unit_type *punittype;
549 struct player *pplayer;
550 int i;
551
552 ptile = index_to_tile(&(wld.map), tile);
553 if (!ptile) {
555 _("Cannot remove units because %d is not a valid "
556 "tile index on this map!"), tile);
557 return;
558 }
559
561 if (!punittype) {
562 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
563 /* TRANS: ..." at <tile-coordinates> because"... */
564 _("Cannot remove a unit at %s because the "
565 "given unit type id %d is invalid."),
566 tile_link(ptile), utid);
567 return;
568 }
569
570 pplayer = player_by_number(owner);
571 if (!pplayer) {
572 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
573 /* TRANS: ..." type <unit-type> at <tile-coordinates>
574 * because"... */
575 _("Cannot remove a unit of type %s at %s "
576 "because the given owner's player id %d is "
577 "invalid."), utype_name_translation(punittype),
578 tile_link(ptile), owner);
579 return;
580 }
581
582 i = 0;
584 if (i >= count) {
585 break;
586 }
588 || unit_owner(punit) != pplayer) {
589 continue;
590 }
592 i++;
594}
595
596/************************************************************************/
600{
601 struct unit *punit;
602
604 if (!punit) {
606 _("No such unit (ID %d)."), id);
607 return;
608 }
609
611}
612
613/************************************************************************/
617 const struct packet_edit_unit *packet)
618{
619 const struct unit_type *putype;
620 struct unit *punit;
621 int id;
622 bool changed = FALSE;
623 int fuel, hp;
624
625 id = packet->id;
627 if (!punit) {
629 _("No such unit (ID %d)."), id);
630 return;
631 }
632
634
635 if (packet->moves_left != punit->moves_left) {
636 punit->moves_left = packet->moves_left;
637 changed = TRUE;
638 }
639
640 fuel = CLIP(0, packet->fuel, utype_fuel(putype));
641 if (fuel != punit->fuel) {
642 punit->fuel = fuel;
643 changed = TRUE;
644 }
645
646 if (packet->moved != punit->moved) {
647 punit->moved = packet->moved;
648 changed = TRUE;
649 }
650
651 if (packet->done_moving != punit->done_moving) {
652 punit->done_moving = packet->done_moving;
653 changed = TRUE;
654 }
655
656 hp = CLIP(1, packet->hp, putype->hp);
657 if (hp != punit->hp) {
658 punit->hp = hp;
659 changed = TRUE;
660 }
661
662 if (packet->veteran != punit->veteran) {
663 int v = packet->veteran;
664
665 if (utype_veteran_level(putype, v) == NULL) {
667 _("Invalid veteran level %d for unit %d (%s)."),
668 v, id, unit_link(punit));
669 } else {
670 punit->veteran = v;
671 changed = TRUE;
672 }
673 }
674
675 if (packet->stay != punit->stay) {
676 punit->stay = packet->stay;
677 changed = TRUE;
678 }
679
680 /* TODO: Handle more property edits. */
681
682
683 /* Send the new state to all affected. */
684 if (changed) {
686 }
687}
688
689/************************************************************************/
694 int size, int tag)
695{
696 struct tile *ptile;
697 struct city *pcity;
698 struct player *pplayer;
699
700 ptile = index_to_tile(&(wld.map), tile);
701 if (!ptile) {
703 _("Cannot create a city because %d is not a valid "
704 "tile index on this map!"), tile);
705 return;
706 }
707
708 pplayer = player_by_number(owner);
709 if (!pplayer) {
710 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
711 /* TRANS: ..." at <tile-coordinates> because"... */
712 _("Cannot create a city at %s because the "
713 "given owner's player id %d is invalid"),
714 tile_link(ptile), owner);
715 return;
716
717 }
718
720
721 if (!create_city_for_player(pplayer, ptile, nullptr, nullptr)) {
722 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
723 /* TRANS: ..." at <tile-coordinates>." */
724 _("A city may not be built at %s."), tile_link(ptile));
726
727 return;
728 }
729
730 pcity = tile_city(ptile);
731
732 if (size > 1) {
733 /* FIXME: Slow and inefficient for large size changes. */
735 -1, nullptr);
737 }
738
739 if (tag > 0) {
741 }
742
744}
745
746
747/************************************************************************/
751 const struct packet_edit_city *packet)
752{
753 struct tile *ptile;
754 struct city *pcity, *oldcity;
755 struct player *pplayer;
756 char buf[1024];
757 int id;
758 bool changed = FALSE;
759 bool need_game_info = FALSE;
761
762 pcity = game_city_by_number(packet->id);
763 if (!pcity) {
765 _("Cannot edit city with invalid city ID %d."),
766 packet->id);
767 return;
768 }
769
770 pplayer = city_owner(pcity);
771 ptile = city_tile(pcity);
773
774 /* Handle name change. */
775 if (0 != strcmp(pcity->name, packet->name)) {
776 if (!is_allowed_city_name(pplayer, packet->name, buf, sizeof(buf))) {
777 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
778 _("Cannot edit city name: %s"), buf);
779 } else {
780 city_name_set(pcity, packet->name);
781 changed = TRUE;
782 }
783 }
784
785 /* Handle size change. */
786 if (packet->size != city_size_get(pcity)) {
787 if (!(0 < packet->size && packet->size <= MAX_CITY_SIZE)) {
788 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
789 _("Invalid city size %d for city %s."),
790 packet->size, city_link(pcity));
791 } else {
792 /* FIXME: Slow and inefficient for large size changes. */
793 city_change_size(pcity, packet->size, nullptr, -1, nullptr);
794 changed = TRUE;
795 }
796 }
797
798 if (packet->history != pcity->history) {
799 pcity->history = packet->history;
800 changed = TRUE;
801 }
802
803 /* Handle city improvement changes. */
804 improvement_iterate(pimprove) {
805 oldcity = NULL;
806 id = improvement_number(pimprove);
807
808 if (is_special_improvement(pimprove)) {
809 if (packet->built[id] >= 0) {
810 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
811 _("It is impossible for a city to have %s!"),
813 }
814 continue;
815 }
816
817 /* FIXME: game.info.great_wonder_owners and pplayer->wonders
818 * logic duplication with city_build_building. */
819
820 if (city_has_building(pcity, pimprove) && packet->built[id] < 0) {
821
823 changed = TRUE;
824
825 } else if (!city_has_building(pcity, pimprove)
826 && packet->built[id] >= 0) {
827 struct player *old_owner = NULL;
828
830 if (oldcity != pcity) {
832 }
833 if (oldcity && old_owner != pplayer) {
834 /* Great wonders make more changes. */
836 if (old_owner) {
838 }
839 }
840
841 if (oldcity) {
843 }
844 changed = TRUE;
845 }
847
848 /* Handle food stock change. */
849 if (packet->food_stock != pcity->food_stock) {
851 if (!(0 <= packet->food_stock && packet->food_stock <= max)) {
852 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
853 _("Invalid city food stock amount %d for city %s "
854 "(allowed range is %d to %d)."),
855 packet->food_stock, city_link(pcity), 0, max);
856 } else {
857 pcity->food_stock = packet->food_stock;
858 changed = TRUE;
859 }
860 }
861
862 /* Handle shield stock change. */
863 if (packet->shield_stock != pcity->shield_stock) {
864 int max = USHRT_MAX; /* Limited to uint16 by city info packet. */
865
866 if (!(0 <= packet->shield_stock && packet->shield_stock <= max)) {
867 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
868 _("Invalid city shield stock amount %d for city %s "
869 "(allowed range is %d to %d)."),
870 packet->shield_stock, city_link(pcity), 0, max);
871 } else {
872 pcity->shield_stock = packet->shield_stock;
873 /* Make sure the shields stay if changing production back and forth */
874 pcity->before_change_shields = packet->shield_stock;
875 changed = TRUE;
876 }
877 }
878
879 /* TODO: Handle more property edits. */
880
881
882 if (changed) {
886
887 /* FIXME: city_refresh_queue_processing only sends to city owner? */
889
891 }
892
893 /* Update wonder infos. */
894 if (need_game_info) {
896 }
900 /* No need to send to detached connections. */
902 }
904 }
905}
906
907/************************************************************************/
911{
912 struct player *pplayer;
913 struct nation_type *pnation;
914 struct research *presearch;
915 int existing = player_count();
916
917 if (existing >= player_slot_count()) {
919 _("No more players can be added because the maximum "
920 "number of players (%d) has been reached."),
922 return;
923 }
924
927 _("No more players can be added because there's "
928 "already maximum number of players allowed by maxplayers setting (value %d)"),
930 return;
931 }
932
933 if (existing >= nation_count() ) {
935 _("No more players can be added because there are "
936 "no available nations (%d used)."),
937 nation_count());
938 return;
939 }
940
942 if (!pnation) {
944 _("Player cannot be created because random nation "
945 "selection failed."));
946 return;
947 }
948
950 NULL, FALSE);
951 if (!pplayer) {
953 _("Player creation failed."));
954 return;
955 }
956 server_player_init(pplayer, TRUE, TRUE);
957
958 player_nation_defaults(pplayer, pnation, TRUE);
959 if (game_was_started()) {
960 /* Find a color for the new player. */
962 }
964 pplayer->unassigned_user = TRUE;
965 pplayer->is_connected = FALSE;
966 pplayer->government = init_government_of_nation(pnation);
967 BV_CLR(pplayer->flags, PLRF_FIRST_CITY);
968
969 pplayer->economic.gold = 0;
970 pplayer->economic.infra_points = 0;
972
973 presearch = research_get(pplayer);
976
977 send_player_all_c(pplayer, NULL);
978 /* Send research info after player info, else the client will complain
979 * about invalid team. */
981 if (tag > 0) {
983 }
984}
985
986/************************************************************************/
990{
991 struct player *pplayer;
992
993 pplayer = player_by_number(id);
994 if (pplayer == NULL) {
996 _("No such player (ID %d)."), id);
997 return;
998 }
999
1000 /* Don't use conn_list_iterate here because connection_detach() can be
1001 * recursive and free the next connection pointer. */
1002 while (conn_list_size(pplayer->connections) > 0) {
1004 }
1005
1006 kill_player(pplayer);
1007 server_remove_player(pplayer);
1008}
1009
1010/************************************************************************/
1014 const struct packet_edit_player *packet)
1015{
1016 struct player *pplayer;
1017 bool changed = FALSE, update_research = FALSE;
1018 struct nation_type *pnation;
1019 struct research *research;
1020 enum tech_state known;
1021 struct government *gov;
1022
1023 pplayer = player_by_number(packet->id);
1024 if (!pplayer) {
1026 _("Cannot edit player with invalid player ID %d."),
1027 packet->id);
1028 return;
1029 }
1030
1031 research = research_get(pplayer);
1032
1033
1034 /* Handle player name change. */
1035 if (0 != strcmp(packet->name, player_name(pplayer))) {
1036 char error_buf[256];
1037
1038 if (server_player_set_name_full(pc, pplayer, NULL, packet->name,
1039 error_buf, sizeof(error_buf))) {
1040 changed = TRUE;
1041 } else {
1043 _("Cannot change name of player (%d) '%s' to '%s': %s"),
1044 player_number(pplayer), player_name(pplayer),
1045 packet->name, error_buf);
1046 }
1047 }
1048
1049 /* Handle nation change. */
1050 pnation = nation_by_number(packet->nation);
1051 if (nation_of_player(pplayer) != pnation) {
1052 if (pnation == NULL) {
1054 _("Cannot change nation for player %d (%s) "
1055 "because the given nation ID %d is invalid."),
1056 player_number(pplayer), player_name(pplayer),
1057 packet->nation);
1058 } else if (pnation->player != NULL) {
1060 _("Cannot change nation for player %d (%s) "
1061 "to nation %d (%s) because that nation is "
1062 "already assigned to player %d (%s)."),
1063 player_number(pplayer), player_name(pplayer),
1064 packet->nation, nation_plural_translation(pnation),
1065 player_number(pnation->player),
1066 player_name(pnation->player));
1067 } else if (!nation_is_in_current_set(pnation)) {
1069 _("Cannot change nation for player %d (%s) "
1070 "to nation %d (%s) because that nation is "
1071 "not in the current nation set."),
1072 player_number(pplayer), player_name(pplayer),
1073 packet->nation, nation_plural_translation(pnation));
1074 } else if (pplayer->ai_common.barbarian_type
1075 != nation_barbarian_type(pnation)
1076 || (!is_barbarian(pplayer) && !is_nation_playable(pnation))) {
1078 _("Cannot change nation for player %d (%s) "
1079 "to nation %d (%s) because that nation is "
1080 "unsuitable for this player."),
1081 player_number(pplayer), player_name(pplayer),
1082 packet->nation, nation_plural_translation(pnation));
1083 } else {
1084 changed = player_set_nation(pplayer, pnation);
1085 }
1086 }
1087
1088 /* Handle a change in research progress. */
1089 if (packet->bulbs_researched != research->bulbs_researched) {
1091 changed = TRUE;
1093 }
1094
1095 /* Handle a change in known inventions. */
1097 known = research_invention_state(research, tech);
1098 if ((packet->inventions[tech] && known == TECH_KNOWN)
1099 || (!packet->inventions[tech] && known != TECH_KNOWN)) {
1100 continue;
1101 }
1102 if (packet->inventions[tech]) {
1103 /* FIXME: Side-effect modifies game.info.global_advances. */
1106 } else {
1109 }
1110 changed = TRUE;
1113
1114 /* Handle a change in the player's gold. */
1115 if (packet->gold != pplayer->economic.gold) {
1116 if (!(0 <= packet->gold && packet->gold <= 1000000)) {
1118 _("Cannot set gold for player %d (%s) because "
1119 "the value %d is outside the allowed range."),
1120 player_number(pplayer), player_name(pplayer),
1121 packet->gold);
1122 } else {
1123 pplayer->economic.gold = packet->gold;
1124 changed = TRUE;
1125 }
1126 }
1127
1128 /* Handle a change in the player's infrapoints. */
1129 if (packet->infrapoints != pplayer->economic.infra_points) {
1130 if (!(0 <= packet->infrapoints && packet->infrapoints <= 1000000)) {
1132 _("Cannot set infrapoints for player %d (%s) because "
1133 "the value %d is outside the allowed range."),
1134 player_number(pplayer), player_name(pplayer),
1135 packet->infrapoints);
1136 } else {
1137 pplayer->economic.infra_points = packet->infrapoints;
1138 changed = TRUE;
1139 }
1140 }
1141
1142 /* Handle a change in the player's autoselect weight. */
1143 if (packet->autoselect_weight != pplayer->autoselect_weight) {
1144 pplayer->autoselect_weight = packet->autoselect_weight;
1145 changed = TRUE;
1146 }
1147
1148 /* Handle player government change */
1149 gov = government_by_number(packet->government);
1150 if (gov != pplayer->government) {
1152 government_change(pplayer, gov, FALSE);
1153 } else {
1154 int turns = revolution_length(gov, pplayer);
1155
1156 if (turns >= 0) {
1157 pplayer->government = gov;
1158 pplayer->revolution_finishes = game.info.turn + turns;
1159 }
1160 }
1161
1162 changed = TRUE;
1163 }
1164
1165 if (packet->scenario_reserved) {
1166 if (!player_has_flag(pplayer, PLRF_SCENARIO_RESERVED)) {
1167 changed = TRUE;
1169 }
1170 } else {
1172 changed = TRUE;
1174 }
1175 }
1176
1177 /* TODO: Handle more property edits. */
1178
1179 if (update_research) {
1180 Tech_type_id current, goal;
1181
1183
1184 /* FIXME: Modifies struct research directly. */
1185
1186 current = research->researching;
1187 goal = research->tech_goal;
1188
1189 if (current != A_UNSET) {
1190 if (current != A_FUTURE) {
1191 known = research_invention_state(research, current);
1192 if (known != TECH_PREREQS_KNOWN) {
1194 }
1195 } else {
1196 /* Future Tech is legal only if all techs are known */
1199 if (known != TECH_KNOWN) {
1201 break;
1202 }
1204 }
1205 }
1206 if (goal != A_UNSET) {
1207 if (goal != A_FUTURE) {
1208 known = research_invention_state(research, goal);
1209 if (known == TECH_KNOWN) {
1211 }
1212 }
1213 }
1214 changed = TRUE;
1215
1216 /* Inform everybody about global advances */
1219 }
1220
1221 if (changed) {
1222 send_player_all_c(pplayer, NULL);
1223 }
1224}
1225
1226/************************************************************************/
1230 int tile, bool known, int size)
1231{
1232 struct player *pplayer;
1233 struct tile *ptile_center;
1234
1236 if (!ptile_center) {
1238 _("Cannot edit vision because %d is not a valid "
1239 "tile index on this map!"), tile);
1240 return;
1241 }
1242
1243 pplayer = player_by_number(plr_no);
1244 if (!pplayer) {
1246 /* TRANS: ..." at <tile-coordinates> because"... */
1247 _("Cannot edit vision for the tile at %s because "
1248 "given player id %d is invalid."),
1250 return;
1251 }
1252
1254 square_iterate(&(wld.map), ptile_center, size - 1, ptile) {
1255
1256 if (!known) {
1257 struct city *pcity = tile_city(ptile);
1259
1260 if (pcity && city_owner(pcity) == pplayer) {
1261 continue;
1262 }
1263
1264 unit_list_iterate(ptile->units, punit) {
1265 if (unit_owner(punit) == pplayer
1266 || really_gives_vision(pplayer, unit_owner(punit))) {
1268 break;
1269 }
1271
1272 if (cannot_make_unknown) {
1273 continue;
1274 }
1275
1276 /* The client expects tiles which become unseen to
1277 * contain no units (client/packhand.c +2368).
1278 * So here we tell it to remove units that do
1279 * not give it vision. */
1280 unit_list_iterate(ptile->units, punit) {
1285 }
1286
1287 if (known) {
1288 map_show_tile(pplayer, ptile);
1289 } else {
1290 map_hide_tile(pplayer, ptile);
1291 }
1294}
1295
1296/************************************************************************/
1305
1306/************************************************************************/
1310{
1311 struct city *pcity;
1312
1314 if (pcity == NULL) {
1316 _("No such city (ID %d)."), id);
1317 return;
1318 }
1319
1321}
1322
1323/************************************************************************/
1330
1331/************************************************************************/
1337{
1338 struct player *pplayer;
1339
1340 if (!game.info.fogofwar) {
1342 _("Cannot toggle fog-of-war when it is already "
1343 "disabled."));
1344 return;
1345 }
1346
1347 pplayer = player_by_number(plr_no);
1348 if (!pplayer) {
1350 _("Cannot toggle fog-of-war for invalid player ID %d."),
1351 plr_no);
1352 return;
1353 }
1354
1356 if (unfogged_players[plr_no]) {
1357 enable_fog_of_war_player(pplayer);
1359 } else {
1362 }
1364}
1365
1366/************************************************************************/
1370 const struct packet_edit_startpos *packet)
1371{
1372 struct tile *ptile = index_to_tile(&(wld.map), packet->id);
1373 bool changed;
1374
1375 /* Check. */
1376 if (NULL == ptile) {
1378 _("Invalid tile index %d for start position."), packet->id);
1379 return;
1380 }
1381
1382 /* Handle. */
1383 if (packet->removal) {
1384 changed = map_startpos_remove(ptile);
1385 } else {
1386 if (NULL != map_startpos_get(ptile)) {
1387 changed = FALSE;
1388 } else {
1389 map_startpos_new(ptile);
1390 changed = TRUE;
1391 }
1392 }
1393
1394 /* Notify. */
1395 if (changed) {
1397 if (can_conn_edit(aconn)) {
1399 }
1401 }
1402}
1403
1404/************************************************************************/
1408 const struct packet_edit_startpos_full *
1409 packet)
1410{
1411 struct tile *ptile = index_to_tile(&(wld.map), packet->id);
1412 struct startpos *psp;
1413
1414 /* Check. */
1415 if (NULL == ptile) {
1417 _("Invalid tile index %d for start position."),
1418 packet->id);
1419 return;
1420 }
1421
1422 psp = map_startpos_get(ptile);
1423 if (NULL == psp) {
1425 _("Cannot edit start position nations at (%d, %d) "
1426 "because there is no start position there."),
1427 TILE_XY(ptile));
1428 return;
1429 }
1430
1431 /* Handle. */
1432 if (startpos_unpack(psp, packet)) {
1433 /* Notify. */
1435 if (can_conn_edit(aconn)) {
1437 }
1439 }
1440}
1441
1442/************************************************************************/
1446 const struct packet_edit_game *packet)
1447{
1448 bool changed = FALSE;
1449
1450 if (packet->scenario != game.scenario.is_scenario) {
1452 changed = TRUE;
1453 }
1454
1455 if (fc_strncmp(packet->scenario_name, game.scenario.name, 256)) {
1457 changed = TRUE;
1458 }
1459
1460 FC_STATIC_ASSERT(sizeof(packet->scenario_authors) == sizeof(game.scenario.authors),
1462
1464 sizeof(game.scenario.authors))) {
1466 changed = TRUE;
1467 }
1468
1469 if (packet->scenario_random != game.scenario.save_random) {
1471 changed = TRUE;
1472 }
1473
1474 if (packet->scenario_players != game.scenario.players) {
1476 changed = TRUE;
1477 }
1478
1481 changed = TRUE;
1482 }
1483
1486 changed = TRUE;
1487 }
1488
1489 if (packet->lake_flooding != game.scenario.lake_flooding) {
1491 changed = TRUE;
1492 }
1493
1494 if (packet->ruleset_locked != game.scenario.ruleset_locked) {
1496 changed = TRUE;
1497 }
1498
1499 if (changed) {
1502 }
1503}
1504
1505/************************************************************************/
1508void handle_edit_scenario_desc(struct connection *pc, const char *scenario_desc)
1509{
1510 if (fc_strncmp(scenario_desc, game.scenario_desc.description,
1511 MAX_LEN_PACKET)) {
1512 sz_strlcpy(game.scenario_desc.description, scenario_desc);
1514 }
1515}
1516
1517/************************************************************************/
1520void handle_save_scenario(struct connection *pc, const char *name)
1521{
1522 if (pc->access_level != ALLOW_HACK) {
1524 _("No permissions to remotely save scenario."));
1525 return;
1526 }
1527
1528 if (!game.scenario.is_scenario) {
1529 /* Scenario information not available */
1531 _("Scenario information not set. Cannot save scenario."));
1532 return;
1533 }
1534
1535 /* Client initiated scenario saving is not handmade */
1537
1538 save_game(name, "Scenario", TRUE);
1539}
const char * default_ai_type_name(void)
Definition aiiface.c:249
#define BV_CLR_ALL(bv)
Definition bitvector.h:103
#define BV_SET(bv, bit)
Definition bitvector.h:89
#define BV_ARE_EQUAL(vec1, vec2)
Definition bitvector.h:121
#define BV_ISSET(bv, bit)
Definition bitvector.h:86
#define BV_ISSET_ANY(vec)
Definition bitvector.h:117
#define BV_CLR(bv, bit)
Definition bitvector.h:94
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:3411
#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:104
bool create_city_for_player(struct player *pplayer, struct tile *ptile, const char *name, struct player *nationality)
Definition citytools.c:1681
void send_city_info(struct player *dest, struct city *pcity)
Definition citytools.c:2368
struct city * build_or_move_building(struct city *pcity, struct impr_type *pimprove, struct player **oldcity_owner)
Definition citytools.c:3032
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:1713
void city_refresh_queue_add(struct city *pcity)
Definition cityturn.c:197
bool city_change_size(struct city *pcity, citizens size, struct player *nationality, Specialist_type_id sid, const char *reason)
Definition cityturn.c:1067
void city_refresh_queue_processing(void)
Definition cityturn.c:213
char * incite_cost
Definition comments.c:76
#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:368
bool can_conn_edit(const struct connection *pconn)
Definition connection.c:513
void conn_list_do_buffer(struct conn_list *dest)
Definition connection.c:358
bool can_conn_enable_editing(const struct connection *pconn)
Definition connection.c:523
const char * conn_description(const struct connection *pconn)
Definition connection.c:476
#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
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
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:599
void handle_edit_tile(struct connection *pc, const struct packet_edit_tile *packet)
Definition edithand.c:380
void handle_edit_scenario_desc(struct connection *pc, const char *scenario_desc)
Definition edithand.c:1508
void handle_edit_check_tiles(struct connection *pc)
Definition edithand.c:1326
void handle_edit_mode(struct connection *pc, bool is_edit_mode)
Definition edithand.c:193
void handle_edit_tile_terrain(struct connection *pc, int tile, Terrain_type_id terrain, int size)
Definition edithand.c:303
void handle_edit_player(struct connection *pc, const struct packet_edit_player *packet)
Definition edithand.c:1013
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:989
static bool edit_tile_terrain_handling(struct tile *ptile, struct terrain *pterrain, bool send_info)
Definition edithand.c:226
void handle_edit_city_remove(struct connection *pc, int id)
Definition edithand.c:1309
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:1229
void handle_edit_city(struct connection *pc, const struct packet_edit_city *packet)
Definition edithand.c:750
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:693
static bool edit_tile_extra_handling(struct tile *ptile, struct extra_type *pextra, bool remove_mode, bool send_info)
Definition edithand.c:258
void handle_edit_game(struct connection *pc, const struct packet_edit_game *packet)
Definition edithand.c:1445
void handle_edit_unit_remove(struct connection *pc, int owner, int tile, Unit_type_id utid, int count)
Definition edithand.c:544
void handle_edit_toggle_fogofwar(struct connection *pc, int plr_no)
Definition edithand.c:1336
void handle_edit_startpos_full(struct connection *pconn, const struct packet_edit_startpos_full *packet)
Definition edithand.c:1407
static void check_leaving_edit_mode(void)
Definition edithand.c:169
void handle_edit_player_create(struct connection *pc, int tag)
Definition edithand.c:910
void handle_edit_recalculate_borders(struct connection *pc)
Definition edithand.c:1301
void handle_save_scenario(struct connection *pc, const char *name)
Definition edithand.c:1520
void handle_edit_tile_extra(struct connection *pc, int tile, int id, bool removal, int eowner, int size)
Definition edithand.c:340
void handle_edit_unit_create(struct connection *pc, int owner, int tile, Unit_type_id utid, int count, int tag)
Definition edithand.c:438
void handle_edit_unit(struct connection *pc, const struct packet_edit_unit *packet)
Definition edithand.c:616
static void check_edited_tile_terrains(void)
Definition edithand.c:147
void handle_edit_startpos(struct connection *pconn, const struct packet_edit_startpos *packet)
Definition edithand.c:1369
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:237
int Terrain_type_id
Definition fc_types.h:233
int Unit_type_id
Definition fc_types.h:242
#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: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:105
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: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 startpos * map_startpos_get(const struct tile *ptile)
Definition map.c:2038
struct startpos * map_startpos_new(struct tile *ptile)
Definition map.c:2021
struct tile * startpos_tile(const struct startpos *psp)
Definition map.c:1820
bool startpos_pack(const struct startpos *psp, struct packet_edit_startpos_full *packet)
Definition map.c:1854
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Definition map.c:471
bool map_startpos_remove(struct tile *ptile)
Definition map.c:2054
bool startpos_unpack(struct startpos *psp, const struct packet_edit_startpos_full *packet)
Definition map.c:1875
#define map_startpos_iterate(NAME_psp)
Definition map.h:136
#define square_iterate(nmap, center_tile, radius, tile_itr)
Definition map.h:388
#define square_iterate_end
Definition map.h:391
#define map_startpos_iterate_end
Definition map.h:139
#define MAP_TILE_OWNER_NULL
Definition map.h:630
void assign_continent_numbers(void)
bool really_gives_vision(struct player *me, struct player *them)
Definition maphand.c:343
void send_tile_info(struct conn_list *dest, struct tile *ptile, bool send_unknown)
Definition maphand.c:489
void send_all_known_tiles(struct conn_list *dest)
Definition maphand.c:442
bool need_to_reassign_continents(const struct terrain *oldter, const struct terrain *newter)
Definition maphand.c:1944
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:773
void tile_change_side_effects(struct tile *ptile, bool refresh_city)
Definition maphand.c:2680
void terrain_changed(struct tile *ptile)
Definition maphand.c:1963
void map_calculate_borders(void)
Definition maphand.c:2329
void fix_tile_on_terrain_change(struct tile *ptile, struct terrain *oldter, bool extend_rivers)
Definition maphand.c:1982
void enable_fog_of_war_player(struct player *pplayer)
Definition maphand.c:1752
void map_show_circle(struct player *pplayer, struct tile *ptile, int radius_sq)
Definition maphand.c:869
void update_tile_knowledge(struct tile *ptile)
Definition maphand.c:1444
void map_hide_tile(struct player *src_player, struct tile *ptile)
Definition maphand.c:825
#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:278
Nation_type_id nation_count(void)
Definition nation.c:528
struct nation_type * nation_by_number(const Nation_type_id nation)
Definition nation.c:493
struct nation_type * nation_of_player(const struct player *pplayer)
Definition nation.c:458
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:682
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
struct player * player_by_number(const int player_id)
Definition player.c:852
int player_count(void)
Definition player.c:819
int player_slot_count(void)
Definition player.c:420
int player_number(const struct player *pplayer)
Definition player.c:839
const char * player_name(const struct player *pplayer)
Definition player.c:900
bool player_has_flag(const struct player *pplayer, enum plr_flag_id flag)
Definition player.c:2004
int player_index(const struct player *pplayer)
Definition player.c:831
bool player_set_nation(struct player *pplayer, struct nation_type *pnation)
Definition player.c:864
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1417
#define players_iterate_end
Definition player.h:542
#define players_iterate(_pplayer)
Definition player.h:537
#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:1131
struct player * server_create_player(int player_id, const char *ai_tname, struct rgbcolor *prgbcolor, bool allow_ai_type_fallbacking)
Definition plrhand.c:1896
void player_limit_to_max_rates(struct player *pplayer)
Definition plrhand.c:2059
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:2170
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:2458
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:1148
void server_remove_player(struct player *pplayer)
Definition plrhand.c:1945
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:1620
void assign_player_colors(void)
Definition plrhand.c:1736
bool nation_is_in_current_set(const struct nation_type *pnation)
Definition plrhand.c:2595
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:640
struct research * research_get(const struct player *pplayer)
Definition research.c:130
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:622
void research_update(struct research *presearch)
Definition research.c:504
#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:2627
bool game_was_started(void)
Definition srv_main.c:355
Definition city.h:318
int id
Definition city.h:324
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::@32::@36 server
int max_players
Definition game.h:163
struct government * government_during_revolution
Definition game.h:94
struct player * player
Definition nation.h:118
char name[MAX_LEN_CITYNAME]
int built[B_LAST]
char scenario_name[256]
char scenario_authors[MAX_LEN_PACKET/3]
Nation_type_id nation
bool inventions[A_LAST+1]
char name[MAX_LEN_NAME]
Government_type_id government
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: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:246
#define A_FIRST
Definition tech.h:44
#define A_UNSET
Definition tech.h:48
#define advance_index_iterate(_start, _index)
Definition tech.h:242
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:158
bool terrain_has_resource(const struct terrain *pterrain, const struct extra_type *presource)
Definition terrain.c:258
#define terrain_has_flag(terr, flag)
Definition terrain.h:176
bool tile_extra_apply(struct tile *ptile, struct extra_type *tgt)
Definition tile.c:576
void tile_change_terrain(struct tile *ptile, struct terrain *pterrain)
Definition tile.c:497
bool tile_extra_rm_apply(struct tile *ptile, struct extra_type *tgt)
Definition tile.c:602
bool tile_set_label(struct tile *ptile, const char *label)
Definition tile.c:1098
void tile_set_resource(struct tile *ptile, struct extra_type *presource)
Definition tile.c:350
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:115
#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:152
#define unit_owner(_pu)
Definition unit.h:406
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer, bool everyone_non_allied)
Definition unit.h:443
#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:2882
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:1610
void wipe_unit(struct unit *punit, enum unit_loss_reason reason, struct player *killer)
Definition unittools.c:2144
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:126
bool utype_player_already_has_this_unique(const struct player *pplayer, const struct unit_type *putype)
Definition unittype.c:1953
struct unit_type * utype_by_number(const Unit_type_id id)
Definition unittype.c:114
const struct veteran_level * utype_veteran_level(const struct unit_type *punittype, int level)
Definition unittype.c:2629
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1586
#define utype_class(_t_)
Definition unittype.h:756
#define utype_fuel(ptype)
Definition unittype.h:847
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:624