Freeciv-3.2: /fast/freeciv/nightly/S3_2/server/edithand.c Source File

Freeciv-3.2

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