Freeciv-3.1: /fast/freeciv/nightly/S3_1/server/edithand.c Source File

Freeciv-3.1

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. */
65 static bool need_continents_reassigned = FALSE;
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. */
69 static 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. */
74 static bool *unfogged_players;
75
76/************************************************************************/
79 void edithand_init(void)
80{
81 if (NULL != modified_tile_table) {
82 tile_hash_destroy(modified_tile_table);
83 }
84 modified_tile_table = tile_hash_new();
85
86 need_continents_reassigned = FALSE;
87
88 if (unfogged_players != NULL) {
89 free(unfogged_players);
90 }
91 unfogged_players = fc_calloc(player_slot_count(), sizeof(bool));
92}
93
94/************************************************************************/
97 void edithand_free(void)
98{
99 if (NULL != modified_tile_table) {
100 tile_hash_destroy(modified_tile_table);
101 modified_tile_table = NULL;
102 }
103
104 if (unfogged_players != NULL) {
105 free(unfogged_players);
106 unfogged_players = NULL;
107 }
108}
109
110/************************************************************************/
113 void edithand_send_initial_packets(struct conn_list *dest)
114{
115 struct packet_edit_startpos startpos;
116 struct packet_edit_startpos_full startpos_full;
117
118 if (NULL == dest) {
119 dest = game.est_connections;
120 }
121
122 /* Send map start positions. */
123 map_startpos_iterate(psp) {
124 startpos.id = tile_index(startpos_tile(psp));
125 startpos.removal = FALSE;
126 startpos.tag = 0;
127
128 startpos_pack(psp, &startpos_full);
129
130 conn_list_iterate(dest, pconn) {
131 if (can_conn_edit(pconn)) {
132 send_packet_edit_startpos(pconn, &startpos);
133 send_packet_edit_startpos_full(pconn, &startpos_full);
134 }
135 } conn_list_iterate_end;
136 } map_startpos_iterate_end;
137}
138
139/************************************************************************/
143 static void check_edited_tile_terrains(void)
144{
145 if (need_continents_reassigned) {
146 assign_continent_numbers();
147 send_all_known_tiles(NULL);
148 need_continents_reassigned = FALSE;
149
150 /* FIXME: adv / ai phase handling like in check_terrain_change() */
151 }
152
153#ifdef SANITY_CHECKING
154 tile_hash_iterate(modified_tile_table, ptile) {
155 sanity_check_tile(ptile);
156 } tile_hash_iterate_end;
157#endif /* SANITY_CHECKING */
158 tile_hash_clear(modified_tile_table);
159}
160
161/************************************************************************/
165 static void check_leaving_edit_mode(void)
166{
167 bool unfogged;
168
169 conn_list_do_buffer(game.est_connections);
170 players_iterate(pplayer) {
171 unfogged = unfogged_players[player_number(pplayer)];
172 if (unfogged && game.info.fogofwar) {
173 enable_fog_of_war_player(pplayer);
174 } else if (!unfogged && !game.info.fogofwar) {
175 disable_fog_of_war_player(pplayer);
176 }
177 } players_iterate_end;
178
179 /* Clear the whole array. */
180 memset(unfogged_players, 0, player_slot_count() * sizeof(bool));
181
182 check_edited_tile_terrains();
183 conn_list_do_unbuffer(game.est_connections);
184}
185
186/************************************************************************/
189 void handle_edit_mode(struct connection *pc, bool is_edit_mode)
190{
191 if (!can_conn_enable_editing(pc)) {
192 return;
193 }
194
195 if (!game.info.is_edit_mode && is_edit_mode) {
196 /* Someone could be cheating! Warn people. */
197 notify_conn(NULL, NULL, E_SETTING, ftc_editor,
198 _(" *** Server set to edit mode by %s! *** "),
199 conn_description(pc));
200 }
201
202 if (game.info.is_edit_mode && !is_edit_mode) {
203 notify_conn(NULL, NULL, E_SETTING, ftc_editor,
204 _(" *** Edit mode canceled by %s. *** "),
205 conn_description(pc));
206
207 check_leaving_edit_mode();
208 }
209
210 if (game.info.is_edit_mode != is_edit_mode) {
211 game.info.is_edit_mode = is_edit_mode;
212
213 send_game_info(NULL);
214 edithand_send_initial_packets(NULL);
215 }
216}
217
218/************************************************************************/
222 static bool edit_tile_terrain_handling(struct tile *ptile,
223 struct terrain *pterrain,
224 bool send_info)
225{
226 struct terrain *old_terrain = tile_terrain(ptile);
227
228 if (old_terrain == pterrain
229 || (terrain_has_flag(pterrain, TER_NO_CITIES)
230 && NULL != tile_city(ptile))) {
231 return FALSE;
232 }
233
234 tile_change_terrain(ptile, pterrain);
235 fix_tile_on_terrain_change(ptile, old_terrain, FALSE);
236 tile_hash_insert(modified_tile_table, ptile, NULL);
237 if (need_to_reassign_continents(old_terrain, pterrain)) {
238 need_continents_reassigned = TRUE;
239 }
240
241 if (send_info) {
242 update_tile_knowledge(ptile);
243 }
244
245 tile_change_side_effects(ptile, TRUE);
246
247 return TRUE;
248}
249
250/************************************************************************/
254 static bool edit_tile_extra_handling(struct tile *ptile,
255 struct extra_type *pextra,
256 bool remove_mode, bool send_info)
257{
258 if (remove_mode) {
259 if (!tile_has_extra(ptile, pextra)) {
260 return FALSE;
261 }
262
263 if (!tile_extra_rm_apply(ptile, pextra)) {
264 return FALSE;
265 }
266
267 terrain_changed(ptile);
268
269 } else {
270 if (tile_has_extra(ptile, pextra)) {
271 return FALSE;
272 }
273
274 if (!tile_extra_apply(ptile, pextra)) {
275 return FALSE;
276 }
277
278 if (is_extra_caused_by(pextra, EC_RESOURCE)
279 && terrain_has_resource(ptile->terrain, pextra)) {
280 tile_set_resource(ptile, pextra);
281 }
282 }
283
284 if (send_info) {
285 update_tile_knowledge(ptile);
286 }
287
288 tile_change_side_effects(ptile, TRUE);
289
290 return TRUE;
291}
292
293/************************************************************************/
299 void handle_edit_tile_terrain(struct connection *pc, int tile,
300 Terrain_type_id terrain, int size)
301{
302 struct terrain *pterrain;
303 struct tile *ptile_center;
304
305 ptile_center = index_to_tile(&(wld.map), tile);
306 if (!ptile_center) {
307 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
308 _("Cannot edit the tile because %d is not a valid "
309 "tile index on this map!"), tile);
310 return;
311 }
312
313 pterrain = terrain_by_number(terrain);
314 if (!pterrain) {
315 notify_conn(pc->self, ptile_center, E_BAD_COMMAND, ftc_editor,
316 /* TRANS: ..." the tile <tile-coordinates> because"... */
317 _("Cannot modify terrain for the tile %s because "
318 "%d is not a valid terrain id."),
319 tile_link(ptile_center), terrain);
320 return;
321 }
322
323 conn_list_do_buffer(game.est_connections);
324 /* This iterates outward, which gives any units that can't survive on
325 * changed terrain the best chance of survival. */
326 square_iterate(&(wld.map), ptile_center, size - 1, ptile) {
327 edit_tile_terrain_handling(ptile, pterrain, TRUE);
328 } square_iterate_end;
329 conn_list_do_unbuffer(game.est_connections);
330}
331
332/************************************************************************/
336 void handle_edit_tile_extra(struct connection *pc, int tile,
337 int id, bool removal, int eowner, int size)
338{
339 struct tile *ptile_center;
340 struct player *plr_eowner;
341
342 ptile_center = index_to_tile(&(wld.map), tile);
343 if (!ptile_center) {
344 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
345 _("Cannot edit the tile because %d is not a valid "
346 "tile index on this map!"), tile);
347 return;
348 }
349
350 if (id < 0 || id >= game.control.num_extra_types) {
351 notify_conn(pc->self, ptile_center, E_BAD_COMMAND, ftc_editor,
352 /* TRANS: ..." the tile <tile-coordinates> because"... */
353 _("Cannot modify extras for the tile %s because "
354 "%d is not a valid extra id."),
355 tile_link(ptile_center), id);
356 return;
357 }
358
359 if (eowner != MAP_TILE_OWNER_NULL) {
360 plr_eowner = player_by_number(eowner);
361 } else {
362 plr_eowner = NULL;
363 }
364
365 conn_list_do_buffer(game.est_connections);
366 square_iterate(&(wld.map), ptile_center, size - 1, ptile) {
367 ptile->extras_owner = plr_eowner;
368 edit_tile_extra_handling(ptile, extra_by_number(id), removal, TRUE);
369 } square_iterate_end;
370 conn_list_do_unbuffer(game.est_connections);
371}
372
373/************************************************************************/
376 void handle_edit_tile(struct connection *pc,
377 const struct packet_edit_tile *packet)
378{
379 struct tile *ptile;
380 struct player *eowner;
381 bool changed = FALSE;
382
383 ptile = index_to_tile(&(wld.map), packet->tile);
384 if (!ptile) {
385 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
386 _("Cannot edit the tile because %d is not a valid "
387 "tile index on this map!"), packet->tile);
388 return;
389 }
390
391 if (packet->eowner != MAP_TILE_OWNER_NULL) {
392 eowner = player_by_number(packet->eowner);
393 } else {
394 eowner = NULL;
395 }
396
397 /* Handle changes in extras. */
398 if (!BV_ARE_EQUAL(packet->extras, ptile->extras)) {
399 extra_type_iterate(pextra) {
400 if (edit_tile_extra_handling(ptile, pextra,
401 !BV_ISSET(packet->extras, extra_number(pextra)),
402 FALSE)) {
403 changed = TRUE;
404 }
405 } extra_type_iterate_end;
406 }
407
408 if (ptile->extras_owner != eowner) {
409 ptile->extras_owner = eowner;
410 changed = TRUE;
411 }
412
413 /* Handle changes in label */
414 if (tile_set_label(ptile, packet->label)) {
415 changed = TRUE;
416 }
417
418 /* TODO: Handle more property edits. */
419
420
421 /* Send the new state to all affected. */
422 if (changed) {
423 update_tile_knowledge(ptile);
424 send_tile_info(NULL, ptile, FALSE);
425 }
426
427 tile_change_side_effects(ptile, TRUE);
428}
429
430/************************************************************************/
434 void handle_edit_unit_create(struct connection *pc, int owner, int tile,
435 Unit_type_id utid, int count, int tag)
436{
437 struct tile *ptile;
438 struct unit_type *punittype;
439 struct player *pplayer;
440 struct city *homecity;
441 struct unit *punit;
442 int id, i;
443
444 ptile = index_to_tile(&(wld.map), tile);
445 if (!ptile) {
446 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
447 _("Cannot create units because %d is not a valid "
448 "tile index on this map!"), tile);
449 return;
450 }
451
452 punittype = utype_by_number(utid);
453 if (!punittype) {
454 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
455 /* TRANS: ..." at <tile-coordinates> because"... */
456 _("Cannot create a unit at %s because the "
457 "given unit type id %d is invalid."),
458 tile_link(ptile), utid);
459 return;
460 }
461
462 pplayer = player_by_number(owner);
463 if (!pplayer) {
464 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
465 /* TRANS: ..." type <unit-type> at <tile-coordinates>"... */
466 _("Cannot create a unit of type %s at %s "
467 "because the given owner's player id %d is "
468 "invalid."), utype_name_translation(punittype),
469 tile_link(ptile), owner);
470 return;
471 }
472
473 if (utype_has_flag(punittype, UTYF_UNIQUE)) {
474 if (utype_player_already_has_this_unique(pplayer, punittype)) {
475 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
476 _("Cannot create another instance of unique unit type %s. "
477 "Player already has one such unit."),
478 utype_name_translation(punittype));
479 return;
480 }
481 if (count > 1) {
482 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
483 _("Cannot create multiple instances of unique unit type %s."),
484 utype_name_translation(punittype));
485 return;
486 }
487 }
488
489 if (is_non_allied_unit_tile(ptile, pplayer)
490 || (tile_city(ptile)
491 && !pplayers_allied(pplayer, city_owner(tile_city(ptile))))) {
492 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
493 /* TRANS: ..." type <unit-type> on enemy tile
494 * <tile-coordinates>"... */
495 _("Cannot create unit of type %s on enemy tile "
496 "%s."), utype_name_translation(punittype),
497 tile_link(ptile));
498 return;
499 }
500
501 if (!can_exist_at_tile(&(wld.map), punittype, ptile)) {
502 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
503 /* TRANS: ..." type <unit-type> on the terrain at
504 * <tile-coordinates>"... */
505 _("Cannot create a unit of type %s on the terrain "
506 "at %s."),
507 utype_name_translation(punittype), tile_link(ptile));
508 return;
509 }
510
511 if (count > 0 && !pplayer->is_alive) {
512 pplayer->is_alive = TRUE;
513 send_player_info_c(pplayer, NULL);
514 }
515
516 homecity = find_closest_city(ptile, NULL, pplayer, FALSE, FALSE, FALSE,
517 TRUE, FALSE, utype_class(punittype));
518 id = homecity ? homecity->id : 0;
519
520 conn_list_do_buffer(game.est_connections);
521 map_show_circle(pplayer, ptile, punittype->vision_radius_sq);
522 for (i = 0; i < count; i++) {
523 /* As far as I can see create_unit is guaranteed to
524 * never return NULL. */
525 punit = create_unit(pplayer, ptile, punittype, 0, id, -1);
526 if (tag > 0) {
527 dsend_packet_edit_object_created(pc, tag, punit->id);
528 }
529 }
530 conn_list_do_unbuffer(game.est_connections);
531}
532
533/************************************************************************/
537 void handle_edit_unit_remove(struct connection *pc, int owner,
538 int tile, Unit_type_id utid, int count)
539{
540 struct tile *ptile;
541 struct unit_type *punittype;
542 struct player *pplayer;
543 int i;
544
545 ptile = index_to_tile(&(wld.map), tile);
546 if (!ptile) {
547 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
548 _("Cannot remove units because %d is not a valid "
549 "tile index on this map!"), tile);
550 return;
551 }
552
553 punittype = utype_by_number(utid);
554 if (!punittype) {
555 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
556 /* TRANS: ..." at <tile-coordinates> because"... */
557 _("Cannot remove a unit at %s because the "
558 "given unit type id %d is invalid."),
559 tile_link(ptile), utid);
560 return;
561 }
562
563 pplayer = player_by_number(owner);
564 if (!pplayer) {
565 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
566 /* TRANS: ..." type <unit-type> at <tile-coordinates>
567 * because"... */
568 _("Cannot remove a unit of type %s at %s "
569 "because the given owner's player id %d is "
570 "invalid."), utype_name_translation(punittype),
571 tile_link(ptile), owner);
572 return;
573 }
574
575 i = 0;
576 unit_list_iterate_safe(ptile->units, punit) {
577 if (i >= count) {
578 break;
579 }
580 if (unit_type_get(punit) != punittype
581 || unit_owner(punit) != pplayer) {
582 continue;
583 }
584 wipe_unit(punit, ULR_EDITOR, NULL);
585 i++;
586 } unit_list_iterate_safe_end;
587}
588
589/************************************************************************/
592 void handle_edit_unit_remove_by_id(struct connection *pc, Unit_type_id id16,
593 Unit_type_id id32)
594{
595 struct unit *punit;
596
597 if (!has_capability("ids32", pc->capability)) {
598 id32 = id16;
599 }
600
601 punit = game_unit_by_number(id32);
602 if (punit == NULL) {
603 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
604 _("No such unit (ID %d)."), id32);
605 return;
606 }
607
608 wipe_unit(punit, ULR_EDITOR, NULL);
609}
610
611/************************************************************************/
614 void handle_edit_unit(struct connection *pc,
615 const struct packet_edit_unit *packet)
616{
617 const struct unit_type *putype;
618 struct unit *punit;
619 int id;
620 bool changed = FALSE;
621 int fuel, hp;
622
623 if (!has_capability("ids32", pc->capability)) {
624 id = packet->id16;
625 } else {
626 id = packet->id32;
627 }
628
629 punit = game_unit_by_number(id);
630 if (punit == NULL) {
631 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
632 _("No such unit (ID %d)."), id);
633 return;
634 }
635
636 putype = unit_type_get(punit);
637
638 if (packet->moves_left != punit->moves_left) {
639 punit->moves_left = packet->moves_left;
640 changed = TRUE;
641 }
642
643 fuel = CLIP(0, packet->fuel, utype_fuel(putype));
644 if (fuel != punit->fuel) {
645 punit->fuel = fuel;
646 changed = TRUE;
647 }
648
649 if (packet->moved != punit->moved) {
650 punit->moved = packet->moved;
651 changed = TRUE;
652 }
653
654 if (packet->done_moving != punit->done_moving) {
655 punit->done_moving = packet->done_moving;
656 changed = TRUE;
657 }
658
659 hp = CLIP(1, packet->hp, putype->hp);
660 if (hp != punit->hp) {
661 punit->hp = hp;
662 changed = TRUE;
663 }
664
665 if (packet->veteran != punit->veteran) {
666 int v = packet->veteran;
667 if (!utype_veteran_level(putype, v)) {
668 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
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) {
687 send_unit_info(NULL, punit);
688 }
689}
690
691/************************************************************************/
695 void handle_edit_city_create(struct connection *pc, int owner, int tile,
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) {
704 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
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
721 conn_list_do_buffer(game.est_connections);
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));
727 conn_list_do_unbuffer(game.est_connections);
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) {
741 dsend_packet_edit_object_created(pc, tag, pcity->id);
742 }
743
744 conn_list_do_unbuffer(game.est_connections);
745}
746
747
748/************************************************************************/
751 void handle_edit_city(struct connection *pc,
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;
761 bv_player need_player_info;
762 int cid;
763
764 if (!has_capability("ids32", pc->capability)) {
765 cid = packet->id16;
766 } else {
767 cid = packet->id32;
768 }
769
770 pcity = game_city_by_number(cid);
771 if (pcity == NULL) {
772 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
773 _("Cannot edit city with invalid city ID %d."),
774 cid);
775 return;
776 }
777
778 pplayer = city_owner(pcity);
779 ptile = city_tile(pcity);
780 BV_CLR_ALL(need_player_info);
781
782 /* Handle name change. */
783 if (0 != strcmp(pcity->name, packet->name)) {
784 if (!is_allowed_city_name(pplayer, packet->name, buf, sizeof(buf))) {
785 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
786 _("Cannot edit city name: %s"), buf);
787 } else {
788 city_name_set(pcity, packet->name);
789 changed = TRUE;
790 }
791 }
792
793 /* Handle size change. */
794 if (packet->size != city_size_get(pcity)) {
795 if (!(0 < packet->size && packet->size <= MAX_CITY_SIZE)) {
796 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
797 _("Invalid city size %d for city %s."),
798 packet->size, city_link(pcity));
799 } else {
800 /* FIXME: Slow and inefficient for large size changes. */
801 city_change_size(pcity, packet->size, NULL, NULL);
802 changed = TRUE;
803 }
804 }
805
806 if (packet->history != pcity->history) {
807 pcity->history = packet->history;
808 changed = TRUE;
809 }
810
811 /* Handle city improvement changes. */
812 improvement_iterate(pimprove) {
813 oldcity = NULL;
814 id = improvement_number(pimprove);
815
816 if (is_special_improvement(pimprove)) {
817 if (packet->built[id] >= 0) {
818 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
819 _("It is impossible for a city to have %s!"),
820 improvement_name_translation(pimprove));
821 }
822 continue;
823 }
824
825 /* FIXME: game.info.great_wonder_owners and pplayer->wonders
826 * logic duplication with city_build_building. */
827
828 if (city_has_building(pcity, pimprove) && packet->built[id] < 0) {
829
830 city_remove_improvement(pcity, pimprove);
831 changed = TRUE;
832
833 } else if (!city_has_building(pcity, pimprove)
834 && packet->built[id] >= 0) {
835 struct player *old_owner = NULL;
836
837 oldcity = build_or_move_building(pcity, pimprove, &old_owner);
838 if (oldcity != pcity) {
839 BV_SET(need_player_info, player_index(pplayer));
840 }
841 if (oldcity && old_owner != pplayer) {
842 /* Great wonders make more changes. */
843 need_game_info = TRUE;
844 if (old_owner) {
845 BV_SET(need_player_info, player_index(old_owner));
846 }
847 }
848
849 if (oldcity) {
850 city_refresh_queue_add(oldcity);
851 }
852 changed = TRUE;
853 }
854 } improvement_iterate_end;
855
856 /* Handle food stock change. */
857 if (packet->food_stock != pcity->food_stock) {
858 int max = city_granary_size(city_size_get(pcity));
859 if (!(0 <= packet->food_stock && packet->food_stock <= max)) {
860 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
861 _("Invalid city food stock amount %d for city %s "
862 "(allowed range is %d to %d)."),
863 packet->food_stock, city_link(pcity), 0, max);
864 } else {
865 pcity->food_stock = packet->food_stock;
866 changed = TRUE;
867 }
868 }
869
870 /* Handle shield stock change. */
871 if (packet->shield_stock != pcity->shield_stock) {
872 int max = USHRT_MAX; /* Limited to uint16 by city info packet. */
873
874 if (!(0 <= packet->shield_stock && packet->shield_stock <= max)) {
875 notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor,
876 _("Invalid city shield stock amount %d for city %s "
877 "(allowed range is %d to %d)."),
878 packet->shield_stock, city_link(pcity), 0, max);
879 } else {
880 pcity->shield_stock = packet->shield_stock;
881 /* Make sure the shields stay if changing production back and forth */
882 pcity->before_change_shields = packet->shield_stock;
883 changed = TRUE;
884 }
885 }
886
887 /* TODO: Handle more property edits. */
888
889
890 if (changed) {
891 city_refresh_queue_add(pcity);
892 conn_list_do_buffer(game.est_connections);
893 city_refresh_queue_processing();
894
895 /* FIXME: city_refresh_queue_processing only sends to city owner? */
896 send_city_info(NULL, pcity);
897
898 conn_list_do_unbuffer(game.est_connections);
899 }
900
901 /* Update wonder infos. */
902 if (need_game_info) {
903 send_game_info(NULL);
904 }
905 if (BV_ISSET_ANY(need_player_info)) {
906 players_iterate(aplayer) {
907 if (BV_ISSET(need_player_info, player_index(aplayer))) {
908 /* No need to send to detached connections. */
909 send_player_info_c(aplayer, NULL);
910 }
911 } players_iterate_end;
912 }
913}
914
915/************************************************************************/
918 void handle_edit_player_create(struct connection *pc, int tag)
919{
920 struct player *pplayer;
921 struct nation_type *pnation;
922 struct research *presearch;
923 int existing = player_count();
924
925 if (existing >= player_slot_count()) {
926 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
927 _("No more players can be added because the maximum "
928 "number of players (%d) has been reached."),
929 player_slot_count());
930 return;
931 }
932
933 if (existing >= game.server.max_players) {
934 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
935 _("No more players can be added because there's "
936 "already maximum number of players allowed by maxplayers setting (value %d)"),
937 game.server.max_players);
938 return;
939 }
940
941 if (existing >= nation_count() ) {
942 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
943 _("No more players can be added because there are "
944 "no available nations (%d used)."),
945 nation_count());
946 return;
947 }
948
949 pnation = pick_a_nation(NULL, TRUE, TRUE, NOT_A_BARBARIAN);
950 if (!pnation) {
951 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
952 _("Player cannot be created because random nation "
953 "selection failed."));
954 return;
955 }
956
957 pplayer = server_create_player(-1, default_ai_type_name(),
958 NULL, FALSE);
959 if (!pplayer) {
960 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
961 _("Player creation failed."));
962 return;
963 }
964 server_player_init(pplayer, TRUE, TRUE);
965
966 player_nation_defaults(pplayer, pnation, TRUE);
967 if (game_was_started()) {
968 /* Find a color for the new player. */
969 assign_player_colors();
970 }
971 sz_strlcpy(pplayer->username, _(ANON_USER_NAME));
972 pplayer->unassigned_user = TRUE;
973 pplayer->is_connected = FALSE;
974 pplayer->government = init_government_of_nation(pnation);
975 pplayer->server.got_first_city = FALSE;
976
977 pplayer->economic.gold = 0;
978 pplayer->economic.infra_points = 0;
979 player_limit_to_max_rates(pplayer);
980
981 presearch = research_get(pplayer);
982 init_tech(presearch, TRUE);
983 give_initial_techs(presearch, 0);
984
985 send_player_all_c(pplayer, NULL);
986 /* Send research info after player info, else the client will complain
987 * about invalid team. */
988 send_research_info(presearch, NULL);
989 if (tag > 0) {
990 dsend_packet_edit_object_created(pc, tag, player_number(pplayer));
991 }
992}
993
994/************************************************************************/
997 void handle_edit_player_remove(struct connection *pc, int id)
998{
999 struct player *pplayer;
1000
1001 pplayer = player_by_number(id);
1002 if (pplayer == NULL) {
1003 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
1004 _("No such player (ID %d)."), id);
1005 return;
1006 }
1007
1008 /* Don't use conn_list_iterate here because connection_detach() can be
1009 * recursive and free the next connection pointer. */
1010 while (conn_list_size(pplayer->connections) > 0) {
1011 connection_detach(conn_list_get(pplayer->connections, 0), FALSE);
1012 }
1013
1014 kill_player(pplayer);
1015 server_remove_player(pplayer);
1016}
1017
1018/************************************************************************/
1021 void handle_edit_player(struct connection *pc,
1022 const struct packet_edit_player *packet)
1023{
1024 struct player *pplayer;
1025 bool changed = FALSE, update_research = FALSE;
1026 struct nation_type *pnation;
1027 struct research *research;
1028 enum tech_state known;
1029 struct government *gov;
1030
1031 pplayer = player_by_number(packet->id);
1032 if (!pplayer) {
1033 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
1034 _("Cannot edit player with invalid player ID %d."),
1035 packet->id);
1036 return;
1037 }
1038
1039 research = research_get(pplayer);
1040
1041
1042 /* Handle player name change. */
1043 if (0 != strcmp(packet->name, player_name(pplayer))) {
1044 char error_buf[256];
1045
1046 if (server_player_set_name_full(pc, pplayer, NULL, packet->name,
1047 error_buf, sizeof(error_buf))) {
1048 changed = TRUE;
1049 } else {
1050 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
1051 _("Cannot change name of player (%d) '%s' to '%s': %s"),
1052 player_number(pplayer), player_name(pplayer),
1053 packet->name, error_buf);
1054 }
1055 }
1056
1057 /* Handle nation change. */
1058 pnation = nation_by_number(packet->nation);
1059 if (nation_of_player(pplayer) != pnation) {
1060 if (pnation == NULL) {
1061 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
1062 _("Cannot change nation for player %d (%s) "
1063 "because the given nation ID %d is invalid."),
1064 player_number(pplayer), player_name(pplayer),
1065 packet->nation);
1066 } else if (pnation->player != NULL) {
1067 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
1068 _("Cannot change nation for player %d (%s) "
1069 "to nation %d (%s) because that nation is "
1070 "already assigned to player %d (%s)."),
1071 player_number(pplayer), player_name(pplayer),
1072 packet->nation, nation_plural_translation(pnation),
1073 player_number(pnation->player),
1074 player_name(pnation->player));
1075 } else if (!nation_is_in_current_set(pnation)) {
1076 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
1077 _("Cannot change nation for player %d (%s) "
1078 "to nation %d (%s) because that nation is "
1079 "not in the current nation set."),
1080 player_number(pplayer), player_name(pplayer),
1081 packet->nation, nation_plural_translation(pnation));
1082 } else if (pplayer->ai_common.barbarian_type
1083 != nation_barbarian_type(pnation)
1084 || (!is_barbarian(pplayer) && !is_nation_playable(pnation))) {
1085 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
1086 _("Cannot change nation for player %d (%s) "
1087 "to nation %d (%s) because that nation is "
1088 "unsuitable for this player."),
1089 player_number(pplayer), player_name(pplayer),
1090 packet->nation, nation_plural_translation(pnation));
1091 } else {
1092 changed = player_set_nation(pplayer, pnation);
1093 }
1094 }
1095
1096 /* Handle a change in research progress. */
1097 if (packet->bulbs_researched != research->bulbs_researched) {
1098 research->bulbs_researched = packet->bulbs_researched;
1099 changed = TRUE;
1100 update_research = TRUE;
1101 }
1102
1103 /* Handle a change in known inventions. */
1104 advance_index_iterate(A_FIRST, tech) {
1105 known = research_invention_state(research, tech);
1106 if ((packet->inventions[tech] && known == TECH_KNOWN)
1107 || (!packet->inventions[tech] && known != TECH_KNOWN)) {
1108 continue;
1109 }
1110 if (packet->inventions[tech]) {
1111 /* FIXME: Side-effect modifies game.info.global_advances. */
1112 research_invention_set(research, tech, TECH_KNOWN);
1113 research->techs_researched++;
1114 } else {
1115 research_invention_set(research, tech, TECH_UNKNOWN);
1116 research->techs_researched--;
1117 }
1118 changed = TRUE;
1119 update_research = TRUE;
1120 } advance_index_iterate_end;
1121
1122 /* Handle a change in the player's gold. */
1123 if (packet->gold != pplayer->economic.gold) {
1124 if (!(0 <= packet->gold && packet->gold <= 1000000)) {
1125 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
1126 _("Cannot set gold for player %d (%s) because "
1127 "the value %d is outside the allowed range."),
1128 player_number(pplayer), player_name(pplayer),
1129 packet->gold);
1130 } else {
1131 pplayer->economic.gold = packet->gold;
1132 changed = TRUE;
1133 }
1134 }
1135
1136 /* Handle player government change */
1137 gov = government_by_number(packet->government);
1138 if (gov != pplayer->government) {
1139 if (gov != game.government_during_revolution) {
1140 government_change(pplayer, gov, FALSE);
1141 } else {
1142 int turns = revolution_length(gov, pplayer);
1143
1144 if (turns >= 0) {
1145 pplayer->government = gov;
1146 pplayer->revolution_finishes = game.info.turn + turns;
1147 }
1148 }
1149
1150 changed = TRUE;
1151 }
1152
1153 if (packet->scenario_reserved) {
1154 if (!player_has_flag(pplayer, PLRF_SCENARIO_RESERVED)) {
1155 changed = TRUE;
1156 BV_SET(pplayer->flags, PLRF_SCENARIO_RESERVED);
1157 }
1158 } else {
1159 if (player_has_flag(pplayer, PLRF_SCENARIO_RESERVED)) {
1160 changed = TRUE;
1161 BV_CLR(pplayer->flags, PLRF_SCENARIO_RESERVED);
1162 }
1163 }
1164
1165 /* TODO: Handle more property edits. */
1166
1167 if (update_research) {
1168 Tech_type_id current, goal;
1169
1170 research_update(research);
1171
1172 /* FIXME: Modifies struct research directly. */
1173
1174 current = research->researching;
1175 goal = research->tech_goal;
1176
1177 if (current != A_UNSET) {
1178 if (current != A_FUTURE) {
1179 known = research_invention_state(research, current);
1180 if (known != TECH_PREREQS_KNOWN) {
1181 research->researching = A_UNSET;
1182 }
1183 } else {
1184 /* Future Tech is legal only if all techs are known */
1185 advance_index_iterate(A_FIRST, tech_i) {
1186 known = research_invention_state(research, tech_i);
1187 if (known != TECH_KNOWN) {
1188 research->researching = A_UNSET;
1189 break;
1190 }
1191 } advance_index_iterate_end;
1192 }
1193 }
1194 if (goal != A_UNSET) {
1195 if (goal != A_FUTURE) {
1196 known = research_invention_state(research, goal);
1197 if (known == TECH_KNOWN) {
1198 research->tech_goal = A_UNSET;
1199 }
1200 }
1201 }
1202 changed = TRUE;
1203
1204 /* Inform everybody about global advances */
1205 send_game_info(NULL);
1206 send_research_info(research, NULL);
1207 }
1208
1209 if (changed) {
1210 send_player_all_c(pplayer, NULL);
1211 }
1212}
1213
1214/************************************************************************/
1217 void handle_edit_player_vision(struct connection *pc, int plr_no,
1218 int tile, bool known, int size)
1219{
1220 struct player *pplayer;
1221 struct tile *ptile_center;
1222
1223 ptile_center = index_to_tile(&(wld.map), tile);
1224 if (!ptile_center) {
1225 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
1226 _("Cannot edit vision because %d is not a valid "
1227 "tile index on this map!"), tile);
1228 return;
1229 }
1230
1231 pplayer = player_by_number(plr_no);
1232 if (!pplayer) {
1233 notify_conn(pc->self, ptile_center, E_BAD_COMMAND, ftc_editor,
1234 /* TRANS: ..." at <tile-coordinates> because"... */
1235 _("Cannot edit vision for the tile at %s because "
1236 "given player id %d is invalid."),
1237 tile_link(ptile_center), plr_no);
1238 return;
1239 }
1240
1241 conn_list_do_buffer(game.est_connections);
1242 square_iterate(&(wld.map), ptile_center, size - 1, ptile) {
1243
1244 if (!known) {
1245 struct city *pcity = tile_city(ptile);
1246 bool cannot_make_unknown = FALSE;
1247
1248 if (pcity && city_owner(pcity) == pplayer) {
1249 continue;
1250 }
1251
1252 unit_list_iterate(ptile->units, punit) {
1253 if (unit_owner(punit) == pplayer
1254 || really_gives_vision(pplayer, unit_owner(punit))) {
1255 cannot_make_unknown = TRUE;
1256 break;
1257 }
1258 } unit_list_iterate_end;
1259
1260 if (cannot_make_unknown) {
1261 continue;
1262 }
1263
1264 /* The client expects tiles which become unseen to
1265 * contain no units (client/packhand.c +2368).
1266 * So here we tell it to remove units that do
1267 * not give it vision. */
1268 unit_list_iterate(ptile->units, punit) {
1269 conn_list_iterate(pplayer->connections, pconn) {
1270 dsend_packet_unit_remove(pconn, punit->id, punit->id);
1271 } conn_list_iterate_end;
1272 } unit_list_iterate_end;
1273 }
1274
1275 if (known) {
1276 map_show_tile(pplayer, ptile);
1277 } else {
1278 map_hide_tile(pplayer, ptile);
1279 }
1280 } square_iterate_end;
1281 conn_list_do_unbuffer(game.est_connections);
1282}
1283
1284/************************************************************************/
1289 void handle_edit_recalculate_borders(struct connection *pc)
1290{
1291 map_calculate_borders();
1292}
1293
1294/************************************************************************/
1297 void handle_edit_city_remove(struct connection *pc, int id16, int id32)
1298{
1299 struct city *pcity;
1300
1301 if (!has_capability("ids32", pc->capability)) {
1302 id32 = id16;
1303 }
1304
1305 pcity = game_city_by_number(id32);
1306 if (pcity == NULL) {
1307 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
1308 _("No such city (ID %d)."), id32);
1309 return;
1310 }
1311
1312 remove_city(pcity);
1313}
1314
1315/************************************************************************/
1318 void handle_edit_check_tiles(struct connection *pc)
1319{
1320 check_edited_tile_terrains();
1321}
1322
1323/************************************************************************/
1328 void handle_edit_toggle_fogofwar(struct connection *pc, int plr_no)
1329{
1330 struct player *pplayer;
1331
1332 if (!game.info.fogofwar) {
1333 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
1334 _("Cannot toggle fog-of-war when it is already "
1335 "disabled."));
1336 return;
1337 }
1338
1339 pplayer = player_by_number(plr_no);
1340 if (!pplayer) {
1341 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
1342 _("Cannot toggle fog-of-war for invalid player ID %d."),
1343 plr_no);
1344 return;
1345 }
1346
1347 conn_list_do_buffer(game.est_connections);
1348 if (unfogged_players[player_number(pplayer)]) {
1349 enable_fog_of_war_player(pplayer);
1350 unfogged_players[player_number(pplayer)] = FALSE;
1351 } else {
1352 disable_fog_of_war_player(pplayer);
1353 unfogged_players[player_number(pplayer)] = TRUE;
1354 }
1355 conn_list_do_unbuffer(game.est_connections);
1356}
1357
1358/************************************************************************/
1361 void handle_edit_startpos(struct connection *pconn,
1362 const struct packet_edit_startpos *packet)
1363{
1364 struct tile *ptile = index_to_tile(&(wld.map), packet->id);
1365 bool changed;
1366
1367 /* Check. */
1368 if (NULL == ptile) {
1369 notify_conn(pconn->self, NULL, E_BAD_COMMAND, ftc_editor,
1370 _("Invalid tile index %d for start position."), packet->id);
1371 return;
1372 }
1373
1374 /* Handle. */
1375 if (packet->removal) {
1376 changed = map_startpos_remove(ptile);
1377 } else {
1378 if (NULL != map_startpos_get(ptile)) {
1379 changed = FALSE;
1380 } else {
1381 map_startpos_new(ptile);
1382 changed = TRUE;
1383 }
1384 }
1385
1386 /* Notify. */
1387 if (changed) {
1388 conn_list_iterate(game.est_connections, aconn) {
1389 if (can_conn_edit(aconn)) {
1390 send_packet_edit_startpos(aconn, packet);
1391 }
1392 } conn_list_iterate_end;
1393 }
1394}
1395
1396/************************************************************************/
1399 void handle_edit_startpos_full(struct connection *pconn,
1400 const struct packet_edit_startpos_full *
1401 packet)
1402{
1403 struct tile *ptile = index_to_tile(&(wld.map), packet->id);
1404 struct startpos *psp;
1405
1406 /* Check. */
1407 if (NULL == ptile) {
1408 notify_conn(pconn->self, NULL, E_BAD_COMMAND, ftc_editor,
1409 _("Invalid tile index %d for start position."),
1410 packet->id);
1411 return;
1412 }
1413
1414 psp = map_startpos_get(ptile);
1415 if (NULL == psp) {
1416 notify_conn(pconn->self, ptile, E_BAD_COMMAND, ftc_editor,
1417 _("Cannot edit start position nations at (%d, %d) "
1418 "because there is no start position there."),
1419 TILE_XY(ptile));
1420 return;
1421 }
1422
1423 /* Handle. */
1424 if (startpos_unpack(psp, packet)) {
1425 /* Notify. */
1426 conn_list_iterate(game.est_connections, aconn) {
1427 if (can_conn_edit(aconn)) {
1428 send_packet_edit_startpos_full(aconn, packet);
1429 }
1430 } conn_list_iterate_end;
1431 }
1432}
1433
1434/************************************************************************/
1437 void handle_edit_game(struct connection *pc,
1438 const struct packet_edit_game *packet)
1439{
1440 bool changed = FALSE;
1441
1442 if (packet->scenario != game.scenario.is_scenario) {
1443 game.scenario.is_scenario = packet->scenario;
1444 changed = TRUE;
1445 }
1446
1447 if (0 != strncmp(packet->scenario_name, game.scenario.name, 256)) {
1448 sz_strlcpy(game.scenario.name, packet->scenario_name);
1449 changed = TRUE;
1450 }
1451
1452 FC_STATIC_ASSERT(sizeof(packet->scenario_authors) == sizeof(game.scenario.authors),
1453 scen_authors_field_size_mismatch);
1454
1455 if (0 != strncmp(packet->scenario_authors, game.scenario.authors,
1456 sizeof(game.scenario.authors))) {
1457 sz_strlcpy(game.scenario.authors, packet->scenario_authors);
1458 changed = TRUE;
1459 }
1460
1461 if (packet->scenario_random != game.scenario.save_random) {
1462 game.scenario.save_random = packet->scenario_random;
1463 changed = TRUE;
1464 }
1465
1466 if (packet->scenario_players != game.scenario.players) {
1467 game.scenario.players = packet->scenario_players;
1468 changed = TRUE;
1469 }
1470
1471 if (packet->startpos_nations != game.scenario.startpos_nations) {
1472 game.scenario.startpos_nations = packet->startpos_nations;
1473 changed = TRUE;
1474 }
1475
1476 if (packet->prevent_new_cities != game.scenario.prevent_new_cities) {
1477 game.scenario.prevent_new_cities = packet->prevent_new_cities;
1478 changed = TRUE;
1479 }
1480
1481 if (packet->lake_flooding != game.scenario.lake_flooding) {
1482 game.scenario.lake_flooding = packet->lake_flooding;
1483 changed = TRUE;
1484 }
1485
1486 if (packet->ruleset_locked != game.scenario.ruleset_locked) {
1487 game.scenario.ruleset_locked = packet->ruleset_locked;
1488 changed = TRUE;
1489 }
1490
1491 if (changed) {
1492 send_scenario_info(NULL);
1493 send_game_info(NULL);
1494 }
1495}
1496
1497/************************************************************************/
1500 void handle_edit_scenario_desc(struct connection *pc, const char *scenario_desc)
1501{
1502 if (0 != strncmp(scenario_desc, game.scenario_desc.description,
1503 MAX_LEN_PACKET)) {
1504 sz_strlcpy(game.scenario_desc.description, scenario_desc);
1505 send_scenario_description(NULL);
1506 }
1507}
1508
1509/************************************************************************/
1512 void handle_save_scenario(struct connection *pc, const char *name)
1513{
1514 if (pc->access_level != ALLOW_HACK) {
1515 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
1516 _("No permissions to remotely save scenario."));
1517 return;
1518 }
1519
1520 if (!game.scenario.is_scenario) {
1521 /* Scenario information not available */
1522 notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor,
1523 _("Scenario information not set. Cannot save scenario."));
1524 return;
1525 }
1526
1527 /* Client initiated scenario saving is not handmade */
1528 game.scenario.handmade = FALSE;
1529
1530 save_game(name, "Scenario", TRUE);
1531}
default_ai_type_name
const char * default_ai_type_name(void)
Definition aiiface.c:262
aiiface.h
bitvector.h
BV_CLR_ALL
#define BV_CLR_ALL(bv)
Definition bitvector.h:95
BV_SET
#define BV_SET(bv, bit)
Definition bitvector.h:81
BV_ARE_EQUAL
#define BV_ARE_EQUAL(vec1, vec2)
Definition bitvector.h:113
BV_ISSET
#define BV_ISSET(bv, bit)
Definition bitvector.h:78
BV_ISSET_ANY
#define BV_ISSET_ANY(vec)
Definition bitvector.h:109
BV_CLR
#define BV_CLR(bv, bit)
Definition bitvector.h:86
has_capability
bool has_capability(const char *cap, const char *capstr)
Definition capability.c:77
capability.h
city_name_set
void city_name_set(struct city *pcity, const char *new_name)
Definition city.c:1114
city_granary_size
int city_granary_size(int city_size)
Definition city.c:2095
city_has_building
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:1207
city_remove_improvement
void city_remove_improvement(struct city *pcity, const struct impr_type *pimprove)
Definition city.c:3272
city_tile
#define city_tile(_pcity_)
Definition city.h:544
city_size_get
static citizens city_size_get(const struct city *pcity)
Definition city.h:549
city_owner
#define city_owner(_pcity_)
Definition city.h:543
MAX_CITY_SIZE
#define MAX_CITY_SIZE
Definition city.h:98
send_city_info
void send_city_info(struct player *dest, struct city *pcity)
Definition citytools.c:2313
build_or_move_building
struct city * build_or_move_building(struct city *pcity, struct impr_type *pimprove, struct player **oldcity_owner)
Definition citytools.c:2918
find_closest_city
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:849
is_allowed_city_name
bool is_allowed_city_name(struct player *pplayer, const char *cityname, char *error_buf, size_t bufsz)
Definition citytools.c:367
remove_city
void remove_city(struct city *pcity)
Definition citytools.c:1675
create_city_for_player
bool create_city_for_player(struct player *pplayer, struct tile *ptile, const char *name)
Definition citytools.c:1649
citytools.h
city_refresh_queue_add
void city_refresh_queue_add(struct city *pcity)
Definition cityturn.c:199
city_change_size
bool city_change_size(struct city *pcity, citizens size, struct player *nationality, const char *reason)
Definition cityturn.c:1060
city_refresh_queue_processing
void city_refresh_queue_processing(void)
Definition cityturn.c:215
cityturn.h
cid
int cid
Definition climisc.h:31
connection_detach
void connection_detach(struct connection *pconn, bool remove_unused_player)
Definition connecthand.c:765
connecthand.h
conn_list_do_unbuffer
void conn_list_do_unbuffer(struct conn_list *dest)
Definition connection.c:365
can_conn_edit
bool can_conn_edit(const struct connection *pconn)
Definition connection.c:510
conn_list_do_buffer
void conn_list_do_buffer(struct conn_list *dest)
Definition connection.c:355
can_conn_enable_editing
bool can_conn_enable_editing(const struct connection *pconn)
Definition connection.c:520
conn_description
const char * conn_description(const struct connection *pconn)
Definition connection.c:473
MAX_LEN_PACKET
#define MAX_LEN_PACKET
Definition connection.h:56
conn_list_iterate
#define conn_list_iterate(connlist, pconn)
Definition connection.h:113
conn_list_iterate_end
#define conn_list_iterate_end
Definition connection.h:115
punit
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:73
id
int int id
Definition editgui_g.h:28
handle_edit_tile
void handle_edit_tile(struct connection *pc, const struct packet_edit_tile *packet)
Definition edithand.c:376
handle_edit_scenario_desc
void handle_edit_scenario_desc(struct connection *pc, const char *scenario_desc)
Definition edithand.c:1500
handle_edit_check_tiles
void handle_edit_check_tiles(struct connection *pc)
Definition edithand.c:1318
handle_edit_mode
void handle_edit_mode(struct connection *pc, bool is_edit_mode)
Definition edithand.c:189
handle_edit_tile_terrain
void handle_edit_tile_terrain(struct connection *pc, int tile, Terrain_type_id terrain, int size)
Definition edithand.c:299
handle_edit_player
void handle_edit_player(struct connection *pc, const struct packet_edit_player *packet)
Definition edithand.c:1021
need_continents_reassigned
static bool need_continents_reassigned
Definition edithand.c:65
edithand_send_initial_packets
void edithand_send_initial_packets(struct conn_list *dest)
Definition edithand.c:113
unfogged_players
static bool * unfogged_players
Definition edithand.c:74
modified_tile_table
static struct tile_hash * modified_tile_table
Definition edithand.c:69
handle_edit_player_remove
void handle_edit_player_remove(struct connection *pc, int id)
Definition edithand.c:997
edit_tile_terrain_handling
static bool edit_tile_terrain_handling(struct tile *ptile, struct terrain *pterrain, bool send_info)
Definition edithand.c:222
edithand_free
void edithand_free(void)
Definition edithand.c:97
handle_edit_player_vision
void handle_edit_player_vision(struct connection *pc, int plr_no, int tile, bool known, int size)
Definition edithand.c:1217
handle_edit_city
void handle_edit_city(struct connection *pc, const struct packet_edit_city *packet)
Definition edithand.c:751
edithand_init
void edithand_init(void)
Definition edithand.c:79
handle_edit_city_create
void handle_edit_city_create(struct connection *pc, int owner, int tile, int size, int tag)
Definition edithand.c:695
handle_edit_unit_remove_by_id
void handle_edit_unit_remove_by_id(struct connection *pc, Unit_type_id id16, Unit_type_id id32)
Definition edithand.c:592
edit_tile_extra_handling
static bool edit_tile_extra_handling(struct tile *ptile, struct extra_type *pextra, bool remove_mode, bool send_info)
Definition edithand.c:254
handle_edit_game
void handle_edit_game(struct connection *pc, const struct packet_edit_game *packet)
Definition edithand.c:1437
handle_edit_city_remove
void handle_edit_city_remove(struct connection *pc, int id16, int id32)
Definition edithand.c:1297
handle_edit_unit_remove
void handle_edit_unit_remove(struct connection *pc, int owner, int tile, Unit_type_id utid, int count)
Definition edithand.c:537
handle_edit_toggle_fogofwar
void handle_edit_toggle_fogofwar(struct connection *pc, int plr_no)
Definition edithand.c:1328
handle_edit_startpos_full
void handle_edit_startpos_full(struct connection *pconn, const struct packet_edit_startpos_full *packet)
Definition edithand.c:1399
check_leaving_edit_mode
static void check_leaving_edit_mode(void)
Definition edithand.c:165
handle_edit_player_create
void handle_edit_player_create(struct connection *pc, int tag)
Definition edithand.c:918
handle_edit_recalculate_borders
void handle_edit_recalculate_borders(struct connection *pc)
Definition edithand.c:1289
handle_save_scenario
void handle_save_scenario(struct connection *pc, const char *name)
Definition edithand.c:1512
handle_edit_tile_extra
void handle_edit_tile_extra(struct connection *pc, int tile, int id, bool removal, int eowner, int size)
Definition edithand.c:336
handle_edit_unit_create
void handle_edit_unit_create(struct connection *pc, int owner, int tile, Unit_type_id utid, int count, int tag)
Definition edithand.c:434
handle_edit_unit
void handle_edit_unit(struct connection *pc, const struct packet_edit_unit *packet)
Definition edithand.c:614
check_edited_tile_terrains
static void check_edited_tile_terrains(void)
Definition edithand.c:143
handle_edit_startpos
void handle_edit_startpos(struct connection *pconn, const struct packet_edit_startpos *packet)
Definition edithand.c:1361
edithand.h
events.h
extra_number
int extra_number(const struct extra_type *pextra)
Definition extras.c:153
extra_by_number
struct extra_type * extra_by_number(int id)
Definition extras.c:175
extra_type_iterate
#define extra_type_iterate(_p)
Definition extras.h:291
extra_type_iterate_end
#define extra_type_iterate_end
Definition extras.h:297
is_extra_caused_by
#define is_extra_caused_by(e, c)
Definition extras.h:196
Tech_type_id
int Tech_type_id
Definition fc_types.h:347
Terrain_type_id
int Terrain_type_id
Definition fc_types.h:343
Unit_type_id
int Unit_type_id
Definition fc_types.h:352
fcintl.h
_
#define _(String)
Definition fcintl.h:67
tile_link
const char * tile_link(const struct tile *ptile)
Definition featured_text.c:1106
ftc_editor
const struct ft_color ftc_editor
Definition featured_text.c:79
city_link
const char * city_link(const struct city *pcity)
Definition featured_text.c:1072
unit_link
const char * unit_link(const struct unit *punit)
Definition featured_text.c:1200
game
struct civ_game game
Definition game.c:57
wld
struct world wld
Definition game.c:58
game_unit_by_number
struct unit * game_unit_by_number(int id)
Definition game.c:111
game_city_by_number
struct city * game_city_by_number(int id)
Definition game.c:102
game.h
send_scenario_description
void send_scenario_description(struct conn_list *dest)
Definition gamehand.c:962
send_scenario_info
void send_scenario_info(struct conn_list *dest)
Definition gamehand.c:948
send_game_info
void send_game_info(struct conn_list *dest)
Definition gamehand.c:905
gamehand.h
government_by_number
struct government * government_by_number(const Government_type_id gov)
Definition government.c:102
government.h
owner
struct city * owner
Definition citydlg.c:219
hand_gen.h
is_special_improvement
bool is_special_improvement(const struct impr_type *pimprove)
Definition improvement.c:792
improvement_number
Impr_type_id improvement_number(const struct impr_type *pimprove)
Definition improvement.c:182
improvement_name_translation
const char * improvement_name_translation(const struct impr_type *pimprove)
Definition improvement.c:241
improvement_iterate_end
#define improvement_iterate_end
Definition improvement.h:211
improvement_iterate
#define improvement_iterate(_p)
Definition improvement.h:205
name
const char * name
Definition inputfile.c:127
log.h
FC_STATIC_ASSERT
#define FC_STATIC_ASSERT(cond, tag)
Definition log.h:235
map_startpos_get
struct startpos * map_startpos_get(const struct tile *ptile)
Definition map.c:1686
map_startpos_new
struct startpos * map_startpos_new(struct tile *ptile)
Definition map.c:1669
startpos_tile
struct tile * startpos_tile(const struct startpos *psp)
Definition map.c:1479
startpos_pack
bool startpos_pack(const struct startpos *psp, struct packet_edit_startpos_full *packet)
Definition map.c:1509
index_to_tile
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Definition map.c:454
map_startpos_remove
bool map_startpos_remove(struct tile *ptile)
Definition map.c:1702
startpos_unpack
bool startpos_unpack(struct startpos *psp, const struct packet_edit_startpos_full *packet)
Definition map.c:1529
map.h
map_startpos_iterate
#define map_startpos_iterate(NAME_psp)
Definition map.h:124
square_iterate
#define square_iterate(nmap, center_tile, radius, tile_itr)
Definition map.h:385
square_iterate_end
#define square_iterate_end
Definition map.h:388
map_startpos_iterate_end
#define map_startpos_iterate_end
Definition map.h:127
MAP_TILE_OWNER_NULL
#define MAP_TILE_OWNER_NULL
Definition map.h:568
assign_continent_numbers
void assign_continent_numbers(void)
Definition mapgen_utils.c:449
mapgen_utils.h
really_gives_vision
bool really_gives_vision(struct player *me, struct player *them)
Definition maphand.c:342
send_tile_info
void send_tile_info(struct conn_list *dest, struct tile *ptile, bool send_unknown)
Definition maphand.c:488
send_all_known_tiles
void send_all_known_tiles(struct conn_list *dest)
Definition maphand.c:441
need_to_reassign_continents
bool need_to_reassign_continents(const struct terrain *oldter, const struct terrain *newter)
Definition maphand.c:1909
disable_fog_of_war_player
void disable_fog_of_war_player(struct player *pplayer)
Definition maphand.c:1756
map_show_tile
void map_show_tile(struct player *src_player, struct tile *ptile)
Definition maphand.c:760
tile_change_side_effects
void tile_change_side_effects(struct tile *ptile, bool refresh_city)
Definition maphand.c:2677
terrain_changed
void terrain_changed(struct tile *ptile)
Definition maphand.c:1928
map_calculate_borders
void map_calculate_borders(void)
Definition maphand.c:2339
fix_tile_on_terrain_change
void fix_tile_on_terrain_change(struct tile *ptile, struct terrain *oldter, bool extend_rivers)
Definition maphand.c:1947
enable_fog_of_war_player
void enable_fog_of_war_player(struct player *pplayer)
Definition maphand.c:1732
map_show_circle
void map_show_circle(struct player *pplayer, struct tile *ptile, int radius_sq)
Definition maphand.c:856
update_tile_knowledge
void update_tile_knowledge(struct tile *ptile)
Definition maphand.c:1424
map_hide_tile
void map_hide_tile(struct player *src_player, struct tile *ptile)
Definition maphand.c:812
maphand.h
fc_calloc
#define fc_calloc(n, esz)
Definition mem.h:38
can_exist_at_tile
bool can_exist_at_tile(const struct civ_map *nmap, const struct unit_type *utype, const struct tile *ptile)
Definition movement.c:275
movement.h
nation_count
Nation_type_id nation_count(void)
Definition nation.c:506
nation_by_number
struct nation_type * nation_by_number(const Nation_type_id nation)
Definition nation.c:474
nation_of_player
struct nation_type * nation_of_player(const struct player *pplayer)
Definition nation.c:443
is_nation_playable
bool is_nation_playable(const struct nation_type *nation)
Definition nation.c:199
nation_plural_translation
const char * nation_plural_translation(const struct nation_type *pnation)
Definition nation.c:158
nation_barbarian_type
enum barbarian_type nation_barbarian_type(const struct nation_type *nation)
Definition nation.c:210
init_government_of_nation
struct government * init_government_of_nation(const struct nation_type *pnation)
Definition nation.c:658
nation.h
notify_conn
void notify_conn(struct conn_list *dest, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Definition notify.c:239
notify.h
send_packet_edit_startpos_full
int send_packet_edit_startpos_full(struct connection *pc, const struct packet_edit_startpos_full *packet)
Definition packets_gen.c:86091
dsend_packet_edit_object_created
int dsend_packet_edit_object_created(struct connection *pc, int tag, int id)
Definition packets_gen.c:94608
dsend_packet_unit_remove
int dsend_packet_unit_remove(struct connection *pc, int unit_id16, int unit_id32)
Definition packets_gen.c:38003
send_packet_edit_startpos
int send_packet_edit_startpos(struct connection *pc, const struct packet_edit_startpos *packet)
Definition packets_gen.c:86000
player_by_number
struct player * player_by_number(const int player_id)
Definition player.c:840
player_count
int player_count(void)
Definition player.c:808
player_slot_count
int player_slot_count(void)
Definition player.c:411
player_number
int player_number(const struct player *pplayer)
Definition player.c:828
player_name
const char * player_name(const struct player *pplayer)
Definition player.c:886
player_has_flag
bool player_has_flag(const struct player *pplayer, enum plr_flag_id flag)
Definition player.c:1954
player_index
int player_index(const struct player *pplayer)
Definition player.c:820
player_set_nation
bool player_set_nation(struct player *pplayer, struct nation_type *pnation)
Definition player.c:852
pplayers_allied
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1381
players_iterate_end
#define players_iterate_end
Definition player.h:535
players_iterate
#define players_iterate(_pplayer)
Definition player.h:530
ANON_USER_NAME
#define ANON_USER_NAME
Definition player.h:48
is_barbarian
static bool is_barbarian(const struct player *pplayer)
Definition player.h:488
send_player_all_c
void send_player_all_c(struct player *src, struct conn_list *dest)
Definition plrhand.c:983
server_create_player
struct player * server_create_player(int player_id, const char *ai_tname, struct rgbcolor *prgbcolor, bool allow_ai_type_fallbacking)
Definition plrhand.c:1723
player_limit_to_max_rates
void player_limit_to_max_rates(struct player *pplayer)
Definition plrhand.c:1886
server_player_set_name_full
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:1997
pick_a_nation
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:2282
kill_player
void kill_player(struct player *pplayer)
Definition plrhand.c:125
send_player_info_c
void send_player_info_c(struct player *src, struct conn_list *dest)
Definition plrhand.c:1000
server_remove_player
void server_remove_player(struct player *pplayer)
Definition plrhand.c:1772
government_change
void government_change(struct player *pplayer, struct government *gov, bool revolution_finished)
Definition plrhand.c:336
server_player_init
void server_player_init(struct player *pplayer, bool initmap, bool needs_team)
Definition plrhand.c:1450
assign_player_colors
void assign_player_colors(void)
Definition plrhand.c:1563
nation_is_in_current_set
bool nation_is_in_current_set(const struct nation_type *pnation)
Definition plrhand.c:2419
revolution_length
int revolution_length(struct government *gov, struct player *plr)
Definition plrhand.c:438
plrhand.h
research_invention_set
enum tech_state research_invention_set(struct research *presearch, Tech_type_id tech, enum tech_state value)
Definition research.c:634
research_get
struct research * research_get(const struct player *pplayer)
Definition research.c:126
research_invention_state
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:616
research_update
void research_update(struct research *presearch)
Definition research.c:499
research.h
sanitycheck.h
sanity_check_tile
#define sanity_check_tile(x)
Definition sanitycheck.h:42
save_game
void save_game(const char *orig_filename, const char *save_reason, bool scenario)
Definition savemain.c:142
savemain.h
shared.h
CLIP
#define CLIP(lower, current, upper)
Definition shared.h:57
size
size_t size
Definition specvec.h:72
player_nation_defaults
void player_nation_defaults(struct player *pplayer, struct nation_type *pnation, bool set_name)
Definition srv_main.c:2510
game_was_started
bool game_was_started(void)
Definition srv_main.c:339
stdinhand.h
city
Definition city.h:309
city::food_stock
int food_stock
Definition city.h:354
city::history
int history
Definition city.h:393
city::id
int id
Definition city.h:315
city::name
char * name
Definition city.h:310
city::before_change_shields
int before_change_shields
Definition city.h:375
city::shield_stock
int shield_stock
Definition city.h:355
civ_game::server
struct civ_game::@30::@34 server
civ_game::scenario_desc
struct packet_scenario_description scenario_desc
Definition game.h:88
civ_game::control
struct packet_ruleset_control control
Definition game.h:83
civ_game::est_connections
struct conn_list * est_connections
Definition game.h:97
civ_game::info
struct packet_game_info info
Definition game.h:89
civ_game::scenario
struct packet_scenario_info scenario
Definition game.h:87
civ_game::max_players
int max_players
Definition game.h:155
civ_game::government_during_revolution
struct government * government_during_revolution
Definition game.h:94
connection
Definition connection.h:141
connection::access_level
enum cmdlevel access_level
Definition connection.h:182
connection::self
struct conn_list * self
Definition connection.h:168
connection::capability
char capability[MAX_LEN_CAPSTR]
Definition connection.h:176
extra_type
Definition extras.h:85
government
Definition government.h:52
nation_type
Definition nation.h:97
nation_type::player
struct player * player
Definition nation.h:117
packet_edit_city
Definition packets_gen.h:1766
packet_edit_city::shield_stock
int shield_stock
Definition packets_gen.h:1781
packet_edit_city::built
int built[B_LAST]
Definition packets_gen.h:1792
packet_edit_city::name
char name[MAX_LEN_CITYNAME]
Definition packets_gen.h:1769
packet_edit_city::history
int history
Definition packets_gen.h:1773
packet_edit_city::food_stock
int food_stock
Definition packets_gen.h:1780
packet_edit_city::id16
int id16
Definition packets_gen.h:1767
packet_edit_city::id32
int id32
Definition packets_gen.h:1768
packet_edit_city::size
int size
Definition packets_gen.h:1772
packet_edit_game
Definition packets_gen.h:1841
packet_edit_game::ruleset_locked
bool ruleset_locked
Definition packets_gen.h:1850
packet_edit_game::scenario_players
bool scenario_players
Definition packets_gen.h:1846
packet_edit_game::lake_flooding
bool lake_flooding
Definition packets_gen.h:1849
packet_edit_game::startpos_nations
bool startpos_nations
Definition packets_gen.h:1847
packet_edit_game::scenario_name
char scenario_name[256]
Definition packets_gen.h:1843
packet_edit_game::prevent_new_cities
bool prevent_new_cities
Definition packets_gen.h:1848
packet_edit_game::scenario
bool scenario
Definition packets_gen.h:1842
packet_edit_game::scenario_authors
char scenario_authors[MAX_LEN_PACKET/3]
Definition packets_gen.h:1844
packet_edit_game::scenario_random
bool scenario_random
Definition packets_gen.h:1845
packet_edit_player
Definition packets_gen.h:1806
packet_edit_player::gold
int gold
Definition packets_gen.h:1822
packet_edit_player::scenario_reserved
bool scenario_reserved
Definition packets_gen.h:1831
packet_edit_player::nation
Nation_type_id nation
Definition packets_gen.h:1815
packet_edit_player::name
char name[MAX_LEN_NAME]
Definition packets_gen.h:1808
packet_edit_player::id
int id
Definition packets_gen.h:1807
packet_edit_player::government
Government_type_id government
Definition packets_gen.h:1813
packet_edit_player::inventions
bool inventions[A_LAST+1]
Definition packets_gen.h:1829
packet_edit_player::bulbs_researched
int bulbs_researched
Definition packets_gen.h:1828
packet_edit_startpos_full
Definition packets_gen.h:1695
packet_edit_startpos_full::id
int id
Definition packets_gen.h:1696
packet_edit_startpos
Definition packets_gen.h:1689
packet_edit_startpos::removal
bool removal
Definition packets_gen.h:1691
packet_edit_startpos::id
int id
Definition packets_gen.h:1690
packet_edit_tile
Definition packets_gen.h:1701
packet_edit_tile::eowner
int eowner
Definition packets_gen.h:1707
packet_edit_tile::label
char label[MAX_LEN_NAME]
Definition packets_gen.h:1708
packet_edit_tile::extras
bv_extras extras
Definition packets_gen.h:1703
packet_edit_tile::tile
int tile
Definition packets_gen.h:1702
packet_edit_unit
Definition packets_gen.h:1731
packet_edit_unit::stay
bool stay
Definition packets_gen.h:1751
packet_edit_unit::moved
bool moved
Definition packets_gen.h:1746
packet_edit_unit::done_moving
bool done_moving
Definition packets_gen.h:1748
packet_edit_unit::id16
int id16
Definition packets_gen.h:1732
packet_edit_unit::moves_left
int moves_left
Definition packets_gen.h:1738
packet_edit_unit::id32
int id32
Definition packets_gen.h:1733
packet_edit_unit::hp
int hp
Definition packets_gen.h:1739
packet_edit_unit::fuel
int fuel
Definition packets_gen.h:1741
packet_edit_unit::veteran
int veteran
Definition packets_gen.h:1740
packet_game_info::is_edit_mode
bool is_edit_mode
Definition packets_gen.h:185
packet_game_info::turn
int turn
Definition packets_gen.h:241
packet_game_info::fogofwar
bool fogofwar
Definition packets_gen.h:152
packet_ruleset_control::num_extra_types
int num_extra_types
Definition packets_gen.h:1460
packet_scenario_description::description
char description[MAX_LEN_CONTENT]
Definition packets_gen.h:1622
packet_scenario_info::lake_flooding
bool lake_flooding
Definition packets_gen.h:1612
packet_scenario_info::is_scenario
bool is_scenario
Definition packets_gen.h:1605
packet_scenario_info::ruleset_locked
bool ruleset_locked
Definition packets_gen.h:1615
packet_scenario_info::players
bool players
Definition packets_gen.h:1608
packet_scenario_info::authors
char authors[MAX_LEN_PACKET/3]
Definition packets_gen.h:1607
packet_scenario_info::name
char name[256]
Definition packets_gen.h:1606
packet_scenario_info::prevent_new_cities
bool prevent_new_cities
Definition packets_gen.h:1611
packet_scenario_info::handmade
bool handmade
Definition packets_gen.h:1613
packet_scenario_info::startpos_nations
bool startpos_nations
Definition packets_gen.h:1609
packet_scenario_info::save_random
bool save_random
Definition packets_gen.h:1610
player_ai::barbarian_type
enum barbarian_type barbarian_type
Definition player.h:128
player_economic::infra_points
int infra_points
Definition player.h:74
player_economic::gold
int gold
Definition player.h:70
player
Definition player.h:249
player::ai_common
struct player_ai ai_common
Definition player.h:288
player::flags
bv_plr_flags flags
Definition player.h:292
player::got_first_city
bool got_first_city
Definition player.h:320
player::username
char username[MAX_LEN_NAME]
Definition player.h:252
player::is_connected
bool is_connected
Definition player.h:296
player::revolution_finishes
int revolution_finishes
Definition player.h:273
player::government
struct government * government
Definition player.h:258
player::connections
struct conn_list * connections
Definition player.h:298
player::is_alive
bool is_alive
Definition player.h:268
player::economic
struct player_economic economic
Definition player.h:284
player::server
struct player::@69::@71 server
player::unassigned_user
bool unassigned_user
Definition player.h:253
research
Definition research.h:39
research::researching
Tech_type_id researching
Definition research.h:52
research::tech_goal
Tech_type_id tech_goal
Definition research.h:85
research::techs_researched
int techs_researched
Definition research.h:42
research::bulbs_researched
int bulbs_researched
Definition research.h:53
startpos
Definition map.c:41
terrain
Definition terrain.h:176
tile
Definition tile.h:49
tile::extras
bv_extras extras
Definition tile.h:54
tile::units
struct unit_list * units
Definition tile.h:57
tile::extras_owner
struct player * extras_owner
Definition tile.h:62
tile::terrain
struct terrain * terrain
Definition tile.h:56
unit_type
Definition unittype.h:481
unit_type::vision_radius_sq
int vision_radius_sq
Definition unittype.h:503
unit_type::hp
int hp
Definition unittype.h:505
unit
Definition unit.h:138
unit::moves_left
int moves_left
Definition unit.h:150
unit::id
int id
Definition unit.h:145
unit::moved
bool moved
Definition unit.h:173
unit::hp
int hp
Definition unit.h:151
unit::fuel
int fuel
Definition unit.h:153
unit::stay
bool stay
Definition unit.h:205
unit::homecity
int homecity
Definition unit.h:146
unit::done_moving
bool done_moving
Definition unit.h:181
unit::veteran
int veteran
Definition unit.h:152
world::map
struct civ_map map
Definition world_object.h:38
support.h
sz_strlcpy
#define sz_strlcpy(dest, src)
Definition support.h:161
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
A_FUTURE
#define A_FUTURE
Definition tech.h:46
advance_index_iterate_end
#define advance_index_iterate_end
Definition tech.h:248
A_FIRST
#define A_FIRST
Definition tech.h:44
A_UNSET
#define A_UNSET
Definition tech.h:48
advance_index_iterate
#define advance_index_iterate(_start, _index)
Definition tech.h:244
init_tech
void init_tech(struct research *research, bool update)
Definition techtools.c:1069
send_research_info
void send_research_info(const struct research *presearch, const struct conn_list *dest)
Definition techtools.c:273
give_initial_techs
void give_initial_techs(struct research *presearch, int num_random_techs)
Definition techtools.c:1161
techtools.h
terrain_by_number
struct terrain * terrain_by_number(const Terrain_type_id type)
Definition terrain.c:144
terrain_has_resource
bool terrain_has_resource(const struct terrain *pterrain, const struct extra_type *presource)
Definition terrain.c:243
terrain.h
terrain_has_flag
#define terrain_has_flag(terr, flag)
Definition terrain.h:269
tile_extra_apply
bool tile_extra_apply(struct tile *ptile, struct extra_type *tgt)
Definition tile.c:552
tile_change_terrain
void tile_change_terrain(struct tile *ptile, struct terrain *pterrain)
Definition tile.c:473
tile_extra_rm_apply
bool tile_extra_rm_apply(struct tile *ptile, struct extra_type *tgt)
Definition tile.c:578
tile_set_label
bool tile_set_label(struct tile *ptile, const char *label)
Definition tile.c:1080
tile_set_resource
void tile_set_resource(struct tile *ptile, struct extra_type *presource)
Definition tile.c:343
tile_city
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
tile_index
#define tile_index(_pt_)
Definition tile.h:87
tile_hash_iterate
#define tile_hash_iterate(hash, ptile)
Definition tile.h:81
tile_terrain
#define tile_terrain(_tile)
Definition tile.h:109
tile_hash_iterate_end
#define tile_hash_iterate_end
Definition tile.h:83
TILE_XY
#define TILE_XY(ptile)
Definition tile.h:42
tile_has_extra
#define tile_has_extra(ptile, pextra)
Definition tile.h:146
unit_owner
#define unit_owner(_pu)
Definition unit.h:387
is_non_allied_unit_tile
static bool is_non_allied_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:423
unitlist.h
unit_list_iterate
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
unit_list_iterate_safe
#define unit_list_iterate_safe(unitlist, _unit)
Definition unitlist.h:39
unit_list_iterate_end
#define unit_list_iterate_end
Definition unitlist.h:33
unit_list_iterate_safe_end
#define unit_list_iterate_safe_end
Definition unitlist.h:61
send_unit_info
void send_unit_info(struct conn_list *dest, struct unit *punit)
Definition unittools.c:2797
create_unit
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:1619
wipe_unit
void wipe_unit(struct unit *punit, enum unit_loss_reason reason, struct player *killer)
Definition unittools.c:2251
unittools.h
unit_type_get
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
utype_player_already_has_this_unique
bool utype_player_already_has_this_unique(const struct player *pplayer, const struct unit_type *putype)
Definition unittype.c:1979
utype_by_number
struct unit_type * utype_by_number(const Unit_type_id id)
Definition unittype.c:112
utype_veteran_level
const struct veteran_level * utype_veteran_level(const struct unit_type *punittype, int level)
Definition unittype.c:2631
utype_name_translation
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1612
utype_class
#define utype_class(_t_)
Definition unittype.h:736
utype_fuel
#define utype_fuel(ptype)
Definition unittype.h:822
utype_has_flag
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:604