Freeciv-3.2
Loading...
Searching...
No Matches
packhand.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
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 <string.h>
19
20/* utility */
21#include "bitvector.h"
22#include "capability.h"
23#include "fcintl.h"
24#include "log.h"
25#include "mem.h"
26#include "rand.h"
27#include "string_vector.h"
28#include "support.h"
29
30/* common */
31#include "achievements.h"
32#include "actions.h"
33#include "capstr.h"
34#include "citizens.h"
35#include "counters.h"
36#include "events.h"
37#include "extras.h"
38#include "game.h"
39#include "government.h"
40#include "idex.h"
41#include "map.h"
42#include "name_translation.h"
43#include "movement.h"
44#include "multipliers.h"
45#include "nation.h"
46#include "packets.h"
47#include "player.h"
48#include "research.h"
49#include "rgbcolor.h"
50#include "road.h"
51#include "spaceship.h"
52#include "specialist.h"
53#include "style.h"
54#include "traderoutes.h"
55#include "unit.h"
56#include "unitlist.h"
57#include "worklist.h"
58
59/* client/include */
60#include "chatline_g.h"
61#include "citydlg_g.h"
62#include "cityrep_g.h"
63#include "connectdlg_g.h"
64#include "dialogs_g.h"
65#include "editgui_g.h"
66#include "gui_main_g.h"
67#include "inteldlg_g.h"
68#include "mapctrl_g.h" /* popup_newcity_dialog() */
69#include "mapview_g.h"
70#include "menu_g.h"
71#include "messagewin_g.h"
72#include "pages_g.h"
73#include "plrdlg_g.h"
74#include "ratesdlg_g.h"
75#include "repodlgs_g.h"
76#include "spaceshipdlg_g.h"
77#include "voteinfo_bar_g.h"
78#include "wldlg_g.h"
79
80/* client */
81#include "agents.h"
82#include "attribute.h"
83#include "audio.h"
84#include "client_main.h"
85#include "climap.h"
86#include "climisc.h"
87#include "clitreaty.h"
88#include "connectdlg_common.h"
89#include "control.h"
90#include "editor.h"
91#include "goto.h" /* client_goto_init() */
92#include "helpdata.h" /* boot_help_texts() */
93#include "mapview_common.h"
94#include "music.h"
95#include "options.h"
96#include "overview_common.h"
97#include "tilespec.h"
98#include "update_queue.h"
99#include "voteinfo.h"
100
101/* client/luascript */
102#include "script_client.h"
103
104#include "packhand.h"
105
106/* Define this macro to get additional debug output about the transport
107 * status of the units. */
108#undef DEBUG_TRANSPORT
109
110static void city_packet_common(struct city *pcity, struct tile *pcenter,
111 struct player *powner,
112 struct tile_list *worked_tiles,
113 bool is_new, bool popup, bool investigate);
114static bool handle_unit_packet_common(struct unit *packet_unit);
115
116
117/* The dumbest of cities, placeholders for unknown and unseen cities. */
118static struct {
119 struct city_list *cities;
121} invisible = {
122 .cities = NULL,
123 .placeholder = NULL
125
126static struct {
127 int len;
129 char *caption;
130 char *headline;
131 char *lines;
132 int parts;
133} page_msg_report = { .parts = 0 };
134
135extern const char forced_tileset_name[];
136
137static int last_turn = 0;
138
139/* Refresh the action selection dialog */
140#define REQEST_BACKGROUND_REFRESH (1)
141/* Get possible actions for fast auto attack. */
142#define REQEST_BACKGROUND_FAST_AUTO_ATTACK (2)
143
144/* A unit will auto attack with the following actions. */
160
161/* A unit will not auto attack if any of these actions are legal. */
209 /* Actually an attack but it needs a target to be specified. */
211 /* End the action list. */
213};
214
215/************************************************************************/
219{
220 if (NULL != invisible.cities) {
221 city_list_iterate(invisible.cities, pcity) {
222 idex_unregister_city(&wld, pcity);
225
227 invisible.cities = NULL;
228 }
229
230 if (NULL != invisible.placeholder) {
231 free(invisible.placeholder);
232 invisible.placeholder = NULL;
233 }
234}
235
236/************************************************************************/
239static void packhand_init(void)
240{
242
243 invisible.cities = city_list_new();
244
245 /* Can't use player_new() here, as it will register the player. */
246 invisible.placeholder = fc_calloc(1, sizeof(*invisible.placeholder));
247 memset(invisible.placeholder, 0, sizeof(*invisible.placeholder));
248 /* Set some values to prevent bugs ... */
249 sz_strlcpy(invisible.placeholder->name, ANON_PLAYER_NAME);
250 sz_strlcpy(invisible.placeholder->username, _(ANON_USER_NAME));
251 invisible.placeholder->unassigned_user = TRUE;
252 sz_strlcpy(invisible.placeholder->ranked_username, ANON_USER_NAME);
253 invisible.placeholder->unassigned_ranked = TRUE;
254}
255
256/************************************************************************/
264static struct unit *unpackage_unit(const struct packet_unit_info *packet)
265{
267 NULL,
268 utype_by_number(packet->type),
269 packet->veteran);
270
271 /* Owner, veteran, and type fields are already filled in by
272 * unit_virtual_create() */
274 punit->id = packet->id;
276 punit->facing = packet->facing;
277 punit->homecity = packet->homecity;
279 punit->upkeep[o] = packet->upkeep[o];
281 punit->moves_left = packet->movesleft;
282 punit->hp = packet->hp;
283 punit->activity = packet->activity;
285
286 if (packet->activity_tgt == EXTRA_NONE) {
288 } else {
290 }
291
294
295 if (packet->changed_from_tgt == EXTRA_NONE) {
297 } else {
299 }
300
302 punit->fuel = packet->fuel;
304 punit->paradropped = packet->paradropped;
305 punit->done_moving = packet->done_moving;
306 punit->stay = packet->stay;
307 punit->birth_turn = packet->birth_turn;
309
310 /* Transporter / transporting information. */
311 punit->client.occupied = packet->occupied;
312 if (packet->transported) {
314 } else {
316 }
317 if (packet->carrying >= 0) {
319 } else {
321 }
322
323 punit->battlegroup = packet->battlegroup;
324 punit->has_orders = packet->has_orders;
325 punit->orders.length = packet->orders_length;
326 punit->orders.index = packet->orders_index;
327 punit->orders.repeat = packet->orders_repeat;
329 if (punit->has_orders) {
330 int i;
331
332 for (i = 0; i < packet->orders_length; i++) {
333 /* Just an assert. The client doesn't use the action data. */
335 || action_id_exists(packet->orders[i].action));
336 }
338 = fc_malloc(punit->orders.length * sizeof(*punit->orders.list));
339 memcpy(punit->orders.list, packet->orders,
340 punit->orders.length * sizeof(*punit->orders.list));
341 }
342
346
348
349 return punit;
350}
351
352/************************************************************************/
362static struct unit *
364{
366 NULL,
367 utype_by_number(packet->type),
368 0);
369
370 /* Owner and type fields are already filled in by unit_virtual_create() */
371 punit->id = packet->id;
373 punit->facing = packet->facing;
375 punit->veteran = packet->veteran;
376 punit->hp = packet->hp;
377 punit->activity = packet->activity;
378
379 if (packet->activity_tgt == EXTRA_NONE) {
381 } else {
383 }
384
385 /* Transporter / transporting information. */
386 punit->client.occupied = packet->occupied;
387 if (packet->transported) {
389 } else {
391 }
392
393 return punit;
394}
395
396/************************************************************************/
400void handle_server_join_reply(bool you_can_join, const char *message,
401 const char *capability,
402 const char *challenge_file, int conn_id)
403{
404 const char *s_capability = client.conn.capability;
405
406 conn_set_capability(&client.conn, capability);
408
409 if (you_can_join) {
411
412 log_verbose("join game accept:%s", message);
414 client.conn.id = conn_id;
415
418
422 }
423
425#ifdef EMERGENCY_VERSION
426 client_info.emerg_version = EMERGENCY_VERSION;
427#else
428 client_info.emerg_version = 0;
429#endif
431 sizeof(client_info.distribution));
433
434 /* We could always use hack, verify we're local */
435#ifdef FREECIV_DEBUG
436 if (!hackless)
437#endif /* FREECIV_DEBUG */
438 {
439 send_client_wants_hack(challenge_file);
440 }
441
443 } else {
445 _("You were rejected from the game: %s"), message);
446 client.conn.id = -1; /* not in range of conn_info id */
447
448 if (auto_connect) {
449 log_normal(_("You were rejected from the game: %s"), message);
450 }
452
454 }
456 return;
457 }
458 output_window_printf(ftc_client, _("Client capability string: %s"),
460 output_window_printf(ftc_client, _("Server capability string: %s"),
462}
463
464/************************************************************************/
468void handle_city_remove(int city_id)
469{
470 struct city *pcity = game_city_by_number(city_id);
472
473 fc_assert_ret_msg(NULL != pcity, "Bad city %d.", city_id);
474
476
477 agents_city_remove(pcity);
479 client_remove_city(pcity);
480
481 /* Update menus if the focus unit is on the tile. */
482 if (need_menus_update) {
483 menus_update();
484 }
485}
486
487/************************************************************************/
491void handle_unit_remove(int unit_id)
492{
493 struct unit *punit = game_unit_by_number(unit_id);
494 struct unit_list *cargos;
495 struct player *powner;
497
498 if (!punit) {
499 log_error("Server wants us to remove unit id %d, "
500 "but we don't know about this unit!",
501 unit_id);
502 return;
503 }
504
505 /* Close the action selection dialog if the actor unit is lost. */
508 /* Open another action selection dialog if there are other actors in the
509 * current selection that want a decision. */
511 }
512
514 powner = unit_owner(punit);
515
516 /* Unload cargo if this is a transporter. */
518 if (unit_list_size(cargos) > 0) {
522 }
523
524 /* Unload unit if it is transported. */
527 }
529
533
534 if (!client_has_player() || powner == client_player()) {
537 }
539 }
540}
541
542/************************************************************************/
549
550/************************************************************************/
553void handle_team_name_info(int team_id, const char *team_name)
554{
555 struct team_slot *tslot = team_slot_by_number(team_id);
556
560}
561
562/************************************************************************/
569{
570 bool show_combat = FALSE;
573
574 if (punit0 && punit1) {
576 packet->attacker_hp, packet->defender_hp,
577 packet->make_att_veteran, packet->make_def_veteran);
584 } else {
586 }
588 }
589
590 if (show_combat) {
591 int hp0 = packet->attacker_hp, hp1 = packet->defender_hp;
592
594 unit_type_get(punit0)->sound_fight_alt,
595 NULL);
597 unit_type_get(punit1)->sound_fight_alt,
598 NULL);
599
602 } else {
603 punit0->hp = hp0;
604 punit1->hp = hp1;
605
609 }
610 }
611 if (packet->make_att_veteran && punit0) {
612 punit0->veteran++;
614 }
615 if (packet->make_def_veteran && punit1) {
616 punit1->veteran++;
618 }
619 }
620}
621
622/************************************************************************/
628static bool update_improvement_from_packet(struct city *pcity,
629 struct impr_type *pimprove,
630 bool have_impr)
631{
632 if (have_impr) {
633 if (pcity->built[improvement_index(pimprove)].turn <= I_NEVER) {
634 city_add_improvement(pcity, pimprove);
635 return TRUE;
636 }
637 } else {
638 if (pcity->built[improvement_index(pimprove)].turn > I_NEVER) {
639 city_remove_improvement(pcity, pimprove);
640 return TRUE;
641 }
642 }
643 return FALSE;
644}
645
646/************************************************************************/
650void handle_city_info(const struct packet_city_info *packet)
651{
652 struct universal product;
653 int i;
654 bool popup;
655 bool city_is_new = FALSE;
660 bool name_changed = FALSE;
663 bool production_changed = FALSE;
665 struct unit_list *pfocus_units = get_units_in_focus();
666 struct city *pcity = game_city_by_number(packet->id);
667 struct tile_list *worked_tiles = NULL;
668 struct tile *pcenter = index_to_tile(&(wld.map), packet->tile);
669 struct tile *ptile = NULL;
670 struct player *powner = player_by_number(packet->owner);
671
672 fc_assert_ret_msg(NULL != powner, "Bad player number %d.", packet->owner);
673 fc_assert_ret_msg(NULL != pcenter, "Invalid tile index %d.", packet->tile);
674
676 log_error("handle_city_info() bad production_kind %d.",
677 packet->production_kind);
678 product.kind = VUT_NONE;
679 } else {
681 packet->production_value);
682 if (!universals_n_is_valid(product.kind)) {
683 log_error("handle_city_info() "
684 "production_kind %d with bad production_value %d.",
685 packet->production_kind, packet->production_value);
686 product.kind = VUT_NONE;
687 }
688 }
689
690 if (NULL != pcity) {
691 ptile = city_tile(pcity);
692
693 if (NULL == ptile) {
694 /* Invisible worked city */
695 city_list_remove(invisible.cities, pcity);
697
698 pcity->tile = pcenter;
699 ptile = pcenter;
700 pcity->owner = powner;
701 } else if (city_owner(pcity) != powner) {
702 /* Remember what were the worked tiles. The server won't
703 * send them to us again. */
705 ptile, pworked, _index, _x, _y) {
706 if (pcity == tile_worked(pworked)) {
707 if (NULL == worked_tiles) {
708 worked_tiles = tile_list_new();
709 }
710 tile_list_append(worked_tiles, pworked);
711 }
713 client_remove_city(pcity);
714 pcity = NULL;
716 }
717 }
718
719 if (NULL == pcity) {
721 pcity = create_city_virtual(powner, pcenter, packet->name);
722 pcity->id = packet->id;
723 idex_register_city(&wld, pcity);
725 } else if (pcity->id != packet->id) {
726 log_error("handle_city_info() city id %d != id %d.",
727 pcity->id, packet->id);
728 return;
729 } else if (ptile != pcenter) {
730 log_error("handle_city_info() city tile (%d, %d) != (%d, %d).",
731 TILE_XY(ptile), TILE_XY(pcenter));
732 return;
733 } else {
734 name_changed = (fc_strncmp(packet->name, pcity->name, MAX_LEN_CITYNAME));
735
736 while (trade_route_list_size(pcity->routes) > packet->trade_route_count) {
737 struct trade_route *proute = trade_route_list_get(pcity->routes, -1);
738
742 }
743
744 /* Descriptions should probably be updated if the
745 * city name, production or time-to-grow changes.
746 * Note that if either the food stock or surplus
747 * have changed, the time-to-grow is likely to
748 * have changed as well. */
752 || pcity->surplus[O_SHIELD] != packet->surplus[O_SHIELD]
753 || pcity->shield_stock != packet->shield_stock))
755 && (pcity->food_stock != packet->food_stock
756 || pcity->surplus[O_FOOD] != packet->surplus[O_FOOD]))
758
759 city_name_set(pcity, packet->name);
760 }
761
762 pcity->original = player_by_number(packet->original);
763
764 /* Check data */
765 city_size_set(pcity, 0);
766 for (i = 0; i < FEELING_LAST; i++) {
767 pcity->feel[CITIZEN_HAPPY][i] = packet->ppl_happy[i];
768 pcity->feel[CITIZEN_CONTENT][i] = packet->ppl_content[i];
769 pcity->feel[CITIZEN_UNHAPPY][i] = packet->ppl_unhappy[i];
770 pcity->feel[CITIZEN_ANGRY][i] = packet->ppl_angry[i];
771 }
772 for (i = 0; i < CITIZEN_LAST; i++) {
773 city_size_add(pcity, pcity->feel[i][FEELING_FINAL]);
774 }
776 pcity->specialists[sp] = packet->specialists[sp];
777 city_size_add(pcity, pcity->specialists[sp]);
779
780 if (city_size_get(pcity) != packet->size) {
781 log_error("handle_city_info() "
782 "%d citizens not equal %d city size in \"%s\".",
783 city_size_get(pcity), packet->size, city_name_get(pcity));
784 city_size_set(pcity, packet->size);
785 }
786
787 pcity->history = packet->history;
788 pcity->client.culture = packet->culture;
789 pcity->client.buy_cost = packet->buy_cost;
790
791 pcity->city_radius_sq = packet->city_radius_sq;
792
793 pcity->city_options = packet->city_options;
794 pcity->wlcb = packet->wl_cb;
795
796 pcity->acquire_t = packet->acquire_type;
797
798 if (pcity->surplus[O_SCIENCE] != packet->surplus[O_SCIENCE]
799 || pcity->surplus[O_SCIENCE] != packet->surplus[O_SCIENCE]
800 || pcity->waste[O_SCIENCE] != packet->waste[O_SCIENCE]
801 || (pcity->unhappy_penalty[O_SCIENCE]
802 != packet->unhappy_penalty[O_SCIENCE])
803 || pcity->prod[O_SCIENCE] != packet->prod[O_SCIENCE]
804 || pcity->citizen_base[O_SCIENCE] != packet->citizen_base[O_SCIENCE]
805 || pcity->usage[O_SCIENCE] != packet->usage[O_SCIENCE]) {
807 }
808
809 pcity->food_stock = packet->food_stock;
810 if (pcity->shield_stock != packet->shield_stock) {
812 pcity->shield_stock = packet->shield_stock;
813 }
814 pcity->pollution = packet->pollution;
815 pcity->illness_trade = packet->illness_trade;
816
817 if (!are_universals_equal(&pcity->production, &product)) {
818 production_changed = TRUE;
819 }
820 /* Need to consider shield stock/surplus for unit dialog as used build
821 * slots may change, affecting number of "in-progress" units. */
822 if ((city_is_new && VUT_UTYPE == product.kind)
823 || (production_changed && (VUT_UTYPE == pcity->production.kind
824 || VUT_UTYPE == product.kind))
825 || pcity->surplus[O_SHIELD] != packet->surplus[O_SHIELD]
828 }
829 pcity->production = product;
830
832 pcity->surplus[o] = packet->surplus[o];
833 pcity->waste[o] = packet->waste[o];
834 pcity->unhappy_penalty[o] = packet->unhappy_penalty[o];
835 pcity->prod[o] = packet->prod[o];
836 pcity->citizen_base[o] = packet->citizen_base[o];
837 pcity->usage[o] = packet->usage[o];
839
840#ifdef DONE_BY_create_city_virtual
841 if (city_is_new) {
842 worklist_init(&pcity->worklist);
843
844 for (i = 0; i < ARRAY_SIZE(pcity->built); i++) {
845 pcity->built[i].turn = I_NEVER;
846 }
847 }
848#endif /* DONE_BY_create_city_virtual */
849
850 worklist_copy(&pcity->worklist, &packet->worklist);
851
852 pcity->airlift = packet->airlift;
853 pcity->did_buy = packet->did_buy;
854 pcity->did_sell = packet->did_sell;
855 pcity->was_happy = packet->was_happy;
856 pcity->had_famine = packet->had_famine;
857
858 if (has_capability("hap2clnt", client.conn.capability)) {
859 pcity->anarchy = packet->anarchy;
860 pcity->rapture = packet->rapture;
861 }
862
863 pcity->turn_founded = packet->turn_founded;
864 pcity->turn_last_built = packet->turn_last_built;
865
867 log_error("handle_city_info() bad changed_from_kind %d.",
868 packet->changed_from_kind);
869 product.kind = VUT_NONE;
870 } else {
872 packet->changed_from_value);
873 if (!universals_n_is_valid(product.kind)) {
874 log_error("handle_city_info() bad changed_from_value %d.",
875 packet->changed_from_value);
876 product.kind = VUT_NONE;
877 }
878 }
879 pcity->changed_from = product;
880
882 pcity->disbanded_shields = packet->disbanded_shields;
883 pcity->caravan_shields = packet->caravan_shields;
885
886 improvement_iterate(pimprove) {
887 bool have = BV_ISSET(packet->improvements, improvement_index(pimprove));
888
889 if (have && !city_is_new
890 && pcity->built[improvement_index(pimprove)].turn <= I_NEVER) {
891 audio_play_sound(pimprove->soundtag, pimprove->soundtag_alt,
892 pimprove->soundtag_alt2);
893 }
895 update_improvement_from_packet(pcity, pimprove, have);
897
898 /* We should be able to see units in the city. But for a diplomat
899 * investigating an enemy city we can't. In that case we don't update
900 * the occupied flag at all: it's already been set earlier and we'll
901 * get an update if it changes. */
903 pcity->client.occupied
904 = (unit_list_size(pcity->tile->units) > 0);
905 }
906
907 pcity->client.walls = packet->walls;
908 if (pcity->client.walls > NUM_WALL_TYPES) {
909 pcity->client.walls = NUM_WALL_TYPES;
910 }
911 pcity->style = packet->style;
912 pcity->capital = packet->capital;
913 if (packet->capital == CAPITAL_PRIMARY) {
914 powner->primary_capital_id = pcity->id;
915 } else if (powner->primary_capital_id == pcity->id) {
916 powner->primary_capital_id = 0;
917 }
918 pcity->client.city_image = packet->city_image;
919 pcity->steal = packet->steal;
920
921 pcity->client.happy = city_happy(pcity);
922 pcity->client.unhappy = city_unhappy(pcity);
923
925 && powner == client.conn.playing
927 || packet->diplomat_investigate;
928
929 city_packet_common(pcity, pcenter, powner, worked_tiles,
931
933 agents_city_new(pcity);
934 } else {
935 agents_city_changed(pcity);
936 }
937
938 /* Update the description if necessary. */
941 }
942
943 /* Update focus unit info label if necessary. */
944 if (name_changed) {
946 if (pfocus_unit->homecity == pcity->id) {
948 break;
949 }
951 }
952
953 /* Update the science dialog if necessary. */
956 }
957
958 /* Update the units dialog if necessary. */
961 }
962
963 /* Update the economy dialog if necessary. */
966 }
967
968 /* Update the panel text (including civ population). */
970
971 /* Update caravan dialog */
972 if ((production_changed || shield_stock_changed)
973 && action_selection_target_city() == pcity->id) {
977 city_tile(pcity)->index,
980 }
981
984 || (city_is_new && 0 < city_num_trade_routes(pcity)))) {
986 }
987}
988
989/************************************************************************/
993{
994 struct city *pcity = game_city_by_number(packet->id);
995
996 /* The nationality of the citizens. */
997 if (pcity != NULL && game.info.citizen_nationality) {
998 int i;
999
1000 citizens_init(pcity);
1001 for (i = 0; i < packet->nationalities_count; i++) {
1003 packet->nation_citizens[i]);
1004 }
1005 fc_assert(citizens_count(pcity) == city_size_get(pcity));
1006 }
1007}
1008
1009/************************************************************************/
1013{
1014 struct city *pcity = game_city_by_number(packet->id);
1015
1016 if (pcity != NULL) {
1017 city_rally_point_receive(packet, pcity);
1018 }
1019}
1020
1021/************************************************************************/
1026static void city_packet_common(struct city *pcity, struct tile *pcenter,
1027 struct player *powner,
1028 struct tile_list *worked_tiles,
1029 bool is_new, bool popup, bool investigate)
1030{
1031 if (NULL != worked_tiles) {
1032 /* We need to transfer the worked infos because the server will assume
1033 * those infos are kept in our side and won't send to us again. */
1034 tile_list_iterate(worked_tiles, pwork) {
1035 tile_set_worked(pwork, pcity);
1037 tile_list_destroy(worked_tiles);
1038 }
1039
1040 if (is_new) {
1041 tile_set_worked(pcenter, pcity); /* is_free_worked() */
1042 city_list_prepend(powner->cities, pcity);
1043
1044 if (client_is_global_observer() || powner == client_player()) {
1046 }
1047
1049 unit_list_iterate(pp->units, punit) {
1050 if (punit->homecity == pcity->id) {
1052 }
1055
1057 } else {
1058 if (client_is_global_observer() || powner == client_player()) {
1060 }
1061 }
1062
1063 if (can_client_change_view()) {
1065 }
1066
1067 if (city_workers_display == pcity) {
1069 }
1070
1071 if (investigate) {
1072 /* Commit the collected supported and present units. */
1074 /* We got units, let's move the unit lists. */
1076
1078 pcity->client.info_units_present =
1081
1086 } else {
1087 /* We didn't get any unit, let's clear the unit lists. */
1089
1092 }
1093 }
1094
1095 if (popup
1096 && NULL != client.conn.playing
1099 menus_update();
1100 if (!city_dialog_is_open(pcity)) {
1101 popup_city_dialog(pcity);
1102 }
1103 }
1104
1105 if (!is_new
1107 refresh_city_dialog(pcity);
1108 }
1109
1110 /* update menus if the focus unit is on the tile. */
1112 menus_update();
1113 }
1114
1115 if (is_new) {
1116 log_debug("(%d,%d) creating city %d, %s %s", TILE_XY(pcenter),
1117 pcity->id, nation_rule_name(nation_of_city(pcity)),
1118 city_name_get(pcity));
1119 }
1120
1122}
1123
1124/************************************************************************/
1129{
1130 struct city *pcity = game_city_by_number(packet->city);
1131 struct trade_route *proute;
1132 bool city_changed = FALSE;
1133
1134 if (pcity == NULL) {
1135 return;
1136 }
1137
1138 proute = trade_route_list_get(pcity->routes, packet->index);
1139 if (proute == NULL) {
1140 fc_assert(trade_route_list_size(pcity->routes) == packet->index);
1141
1142 proute = fc_malloc(sizeof(struct trade_route));
1145 }
1146
1147 proute->partner = packet->partner;
1148 proute->value = packet->value;
1149 proute->dir = packet->direction;
1150 proute->goods = goods_by_number(packet->goods);
1151
1155 }
1156}
1157
1158/************************************************************************/
1164{
1166 bool city_is_new = FALSE;
1167 bool name_changed = FALSE;
1169 struct city *pcity = game_city_by_number(packet->id);
1170 struct tile *pcenter = index_to_tile(&(wld.map), packet->tile);
1171 struct tile *ptile = NULL;
1172 struct tile_list *worked_tiles = NULL;
1173 struct player *powner = player_by_number(packet->owner);
1174 struct player *original = player_by_number(packet->original);
1175 int radius_sq = game.info.init_city_radius_sq;
1176
1177 fc_assert_ret_msg(NULL != powner, "Bad player number %d.", packet->owner);
1178 fc_assert_ret_msg(NULL != pcenter, "Invalid tile index %d.", packet->tile);
1179
1180 if (NULL != pcity) {
1181 ptile = city_tile(pcity);
1182
1183 if (NULL == ptile) {
1184 /* Invisible worked city */
1185 city_list_remove(invisible.cities, pcity);
1186 city_is_new = TRUE;
1187
1188 pcity->tile = pcenter;
1189 pcity->owner = powner;
1190 pcity->original = original;
1191
1193 if (wtile->worked == pcity) {
1195
1196 if (dist_sq > city_map_radius_sq_get(pcity)) {
1198 }
1199 }
1201 } else if (city_owner(pcity) != powner) {
1202 /* Remember what were the worked tiles. The server won't
1203 * send to us again. */
1205 pworked, _index, _x, _y) {
1206 if (pcity == tile_worked(pworked)) {
1207 if (NULL == worked_tiles) {
1208 worked_tiles = tile_list_new();
1209 }
1210 tile_list_append(worked_tiles, pworked);
1211 }
1213 radius_sq = city_map_radius_sq_get(pcity);
1214 client_remove_city(pcity);
1215 pcity = NULL;
1217 }
1218 }
1219
1220 if (NULL == pcity) {
1221 city_is_new = TRUE;
1222 pcity = create_city_virtual(powner, pcenter, packet->name);
1223 pcity->id = packet->id;
1224 pcity->original = original;
1225 city_map_radius_sq_set(pcity, radius_sq);
1226 idex_register_city(&wld, pcity);
1227 } else if (pcity->id != packet->id) {
1228 log_error("handle_city_short_info() city id %d != id %d.",
1229 pcity->id, packet->id);
1230 return;
1231 } else if (city_tile(pcity) != pcenter) {
1232 log_error("handle_city_short_info() city tile (%d, %d) != (%d, %d).",
1233 TILE_XY(city_tile(pcity)), TILE_XY(pcenter));
1234 return;
1235 } else {
1236 name_changed = (fc_strncmp(packet->name, pcity->name, MAX_LEN_CITYNAME));
1237
1238 /* Check if city descriptions should be updated */
1241 }
1242
1243 city_name_set(pcity, packet->name);
1244
1245 memset(pcity->feel, 0, sizeof(pcity->feel));
1246 memset(pcity->specialists, 0, sizeof(pcity->specialists));
1247 }
1248
1249 pcity->specialists[DEFAULT_SPECIALIST] = packet->size;
1250 city_size_set(pcity, packet->size);
1251
1252 /* We can't actually see the internals of the city, but the server tells
1253 * us this much. */
1254 if (pcity->client.occupied != packet->occupied) {
1255 pcity->client.occupied = packet->occupied;
1258 }
1259 }
1260 pcity->client.walls = packet->walls;
1261 if (pcity->client.walls > NUM_WALL_TYPES) {
1262 pcity->client.walls = NUM_WALL_TYPES;
1263 }
1264 pcity->style = packet->style;
1265 pcity->capital = packet->capital;
1266 if (packet->capital == CAPITAL_PRIMARY) {
1267 powner->primary_capital_id = pcity->id;
1268 } else if (powner->primary_capital_id == pcity->id) {
1269 powner->primary_capital_id = 0;
1270 }
1271 pcity->client.city_image = packet->city_image;
1272
1273 pcity->client.happy = packet->happy;
1274 pcity->client.unhappy = packet->unhappy;
1275
1276 pcity->rapture = 0;
1277 pcity->anarchy = 0;
1278
1279 improvement_iterate(pimprove) {
1280 /* Don't update the non-visible improvements, they could hide the
1281 * previously seen information about the city (diplomat investigation).
1282 */
1283 if (is_improvement_visible(pimprove)) {
1284 bool have = BV_ISSET(packet->improvements,
1285 improvement_index(pimprove));
1286 update_improvement_from_packet(pcity, pimprove, have);
1287 }
1289
1290 city_packet_common(pcity, pcenter, powner, worked_tiles,
1292
1294 agents_city_new(pcity);
1295 } else {
1296 agents_city_changed(pcity);
1297 }
1298
1299 /* Update the description if necessary. */
1300 if (update_descriptions) {
1302 }
1303}
1304
1305/************************************************************************/
1308void handle_worker_task(const struct packet_worker_task *packet)
1309{
1310 struct city *pcity = game_city_by_number(packet->city_id);
1311 struct worker_task *ptask = NULL;
1312
1313 if (pcity == NULL
1314 || (pcity->owner != client.conn.playing && !client_is_global_observer())) {
1315 return;
1316 }
1317
1319 if (tile_index(ptask_old->ptile) == packet->tile_id) {
1320 ptask = ptask_old;
1321 break;
1322 }
1324
1325 if (ptask == NULL) {
1326 if (packet->activity == ACTIVITY_LAST) {
1327 return;
1328 } else {
1329 ptask = fc_malloc(sizeof(struct worker_task));
1331 }
1332 } else {
1333 if (packet->activity == ACTIVITY_LAST) {
1335 free(ptask);
1336 ptask = NULL;
1337 }
1338 }
1339
1340 if (ptask != NULL) {
1341 ptask->ptile = index_to_tile(&(wld.map), packet->tile_id);
1342 ptask->act = packet->activity;
1343 if (packet->tgt >= 0) {
1344 ptask->tgt = extra_by_number(packet->tgt);
1345 } else {
1346 ptask->tgt = NULL;
1347 }
1348 ptask->want = packet->want;
1349 }
1350
1351 if (ptask && !worker_task_is_sane(ptask)) {
1352 log_debug("Bad worker task");
1354 free(ptask);
1355 ptask = NULL;
1356 return;
1357 }
1358
1359 refresh_city_dialog(pcity);
1360}
1361
1362/************************************************************************/
1365void handle_new_year(int year, int fragments, int turn)
1366{
1367 game.info.year = year;
1368 game.info.fragment_count = fragments;
1369 /*
1370 * The turn was increased in handle_end_turn()
1371 */
1372 fc_assert(game.info.turn == turn);
1374
1377
1379 menus_update();
1380
1382
1383#if 0
1384 /* This information shouldn't be needed, but if it is this is the only
1385 * way we can get it. */
1386 if (NULL != client.conn.playing) {
1390 }
1391#endif
1392
1395
1398 _("Start of turn %d"), game.info.turn);
1399 }
1400
1402
1403 if (last_turn != turn) {
1404 start_turn();
1405 last_turn = turn;
1406 }
1407}
1408
1409/************************************************************************/
1415{
1416 /* Messagewindow will contain events happened since our own phase ended,
1417 * so player of the first phase and last phase are in equal situation. */
1419}
1420
1421/************************************************************************/
1425void handle_start_phase(int phase)
1426{
1428 /* We are on detached state, let ignore this packet. */
1429 return;
1430 }
1431
1432 if (phase < 0
1434 && phase >= player_count())
1436 && phase >= team_count())) {
1437 log_error("handle_start_phase() illegal phase %d.", phase);
1438 return;
1439 }
1440
1442
1443 game.info.phase = phase;
1444
1445 /* Possibly replace wait cursor with something else */
1446 if (phase == 0) {
1447 /* TODO: Have server set as busy also if switching phase
1448 * is taking long in a alternating phases mode. */
1450 }
1451
1452 if (NULL != client.conn.playing
1453 && is_player_phase(client.conn.playing, phase)) {
1456
1458
1462 }
1463
1465
1467 pcity->client.colored = FALSE;
1469
1473
1475 }
1476
1478}
1479
1480/************************************************************************/
1485{
1486 log_debug("handle_begin_turn()");
1487
1488 /* Server is still considered busy until it handles also the beginning
1489 * of the first phase. */
1490
1492}
1493
1494/************************************************************************/
1499{
1500 log_debug("handle_end_turn()");
1501
1502 /* Make sure wait cursor is in use */
1504
1506
1507 /*
1508 * The local idea of the game.info.turn is increased here since the
1509 * client will get unit updates (reset of move points for example)
1510 * between handle_end_turn() and handle_new_year(). These
1511 * unit updates will look like they did take place in the old turn
1512 * which is incorrect. If we get the authoritative information about
1513 * the game.info.turn in handle_new_year() we will check it.
1514 */
1515 game.info.turn++;
1516
1517 log_verbose(_("Beginning turn %d"), game.info.turn);
1518
1520}
1521
1522/************************************************************************/
1526{
1527 const char *sound_tag = get_event_tag(type);
1528
1529 if (sound_tag) {
1530 audio_play_sound(sound_tag, NULL, NULL);
1531 }
1532}
1533
1534/************************************************************************/
1538void handle_chat_msg(const struct packet_chat_msg *packet)
1539{
1540 handle_event(packet->message,
1541 index_to_tile(&(wld.map), packet->tile),
1542 packet->event,
1543 packet->turn,
1544 packet->phase,
1545 packet->conn_id);
1546}
1547
1548/************************************************************************/
1559{
1560 handle_event(packet->message,
1561 index_to_tile(&(wld.map), packet->tile),
1562 packet->event,
1563 packet->turn,
1564 packet->phase,
1565 packet->conn_id);
1566}
1567
1568/************************************************************************/
1573{
1574 popup_connect_msg(_("Welcome"), message);
1575}
1576
1577/************************************************************************/
1581void handle_server_info(const char *version_label, int major_version,
1582 int minor_version, int patch_version, int emerg_version)
1583{
1584 if (emerg_version > 0) {
1585 log_verbose("Server has version %d.%d.%d.%d%s",
1586 major_version, minor_version, patch_version, emerg_version,
1587 version_label);
1588 } else {
1589 log_verbose("Server has version %d.%d.%d%s",
1590 major_version, minor_version, patch_version, version_label);
1591 }
1592}
1593
1594/************************************************************************/
1597void handle_page_msg(const char *caption, const char *headline,
1598 enum event_type event, int len, int parts)
1599{
1600 if (!client_has_player()
1602 || event != E_BROADCAST_REPORT) {
1603 if (page_msg_report.parts > 0) {
1604 /* Previous one was never finished */
1605 free(page_msg_report.caption);
1606 free(page_msg_report.headline);
1607 free(page_msg_report.lines);
1608 }
1609 page_msg_report.len = len;
1610 page_msg_report.event = event;
1613 page_msg_report.parts = parts;
1614 page_msg_report.lines = fc_malloc(len + 1);
1615 page_msg_report.lines[0] = '\0';
1616
1617 if (parts == 0) {
1618 /* Empty report - handle as if last part was just received. */
1619 page_msg_report.parts = 1;
1621 }
1622 }
1623}
1624
1625/************************************************************************/
1629{
1630 if (page_msg_report.lines != NULL) {
1631 /* We have already decided to show the message at the time we got
1632 * the header packet. */
1634 page_msg_report.parts--;
1635
1636 if (page_msg_report.parts == 0) {
1637 /* This is the final part */
1639 page_msg_report.headline,
1640 page_msg_report.lines);
1642
1643 free(page_msg_report.caption);
1644 free(page_msg_report.headline);
1645 free(page_msg_report.lines);
1646 page_msg_report.lines = NULL;
1647 }
1648 }
1649}
1650
1651/************************************************************************/
1654void handle_unit_info(const struct packet_unit_info *packet)
1655{
1656 struct unit *punit;
1657
1658 punit = unpackage_unit(packet);
1662 }
1663}
1664
1665/**********************************************************************/
1671{
1674 if (utype_can_do_action(unit_type_get(punit), act_id)) {
1675 /* An auto action like auto attack could be legal. Check for those
1676 * at once so they won't have to wait for player focus. */
1678 punit->id,
1681 EXTRA_NONE,
1683 return;
1684 }
1686 }
1687
1688 /* This should be done in the foreground */
1690}
1691
1692/************************************************************************/
1709{
1710 struct city *pcity;
1711 struct unit *punit;
1712 bool need_menus_update = FALSE;
1715 bool repaint_unit = FALSE;
1716 bool repaint_city = FALSE; /* regards unit's homecity */
1717 struct tile *old_tile = NULL;
1718 bool check_focus = FALSE; /* conservative focus change */
1719 bool moved = FALSE;
1720 bool ret = FALSE;
1721
1723 if (!punit && game_unit_by_number(packet_unit->id)) {
1724 /* This means unit has changed owner. We deal with this here
1725 * by simply deleting the old one and creating a new one. */
1727 }
1728
1729 if (punit) {
1730 /* In some situations, the size of repaint units require can change;
1731 * in particular, city-builder units sometimes get a potential-city
1732 * outline, but to speed up redraws we don't repaint this whole area
1733 * unnecessarily. We need to ensure that when the footprint shrinks,
1734 * old bits aren't left behind on the canvas.
1735 * If the current (old) status of the unit is such that it gets a large
1736 * repaint, as a special case, queue a large repaint immediately, to
1737 * schedule the correct amount/location to be redrawn; but rely on the
1738 * repaint being deferred until the unit is updated, so that what's
1739 * drawn reflects the new status (e.g., no city outline). */
1742 }
1743
1744 ret = TRUE;
1745 punit->activity_count = packet_unit->activity_count;
1747 if (punit->ssa_controller != packet_unit->ssa_controller) {
1748 punit->ssa_controller = packet_unit->ssa_controller;
1750 /* AI is set: may change focus */
1751 /* AI is cleared: keep focus */
1752 if (packet_unit->ssa_controller != SSA_NONE
1753 && unit_is_in_focus(punit)) {
1754 check_focus = TRUE;
1755 }
1756 }
1757
1758 if (punit->facing != packet_unit->facing) {
1759 punit->facing = packet_unit->facing;
1761 }
1762
1763 if (punit->activity != packet_unit->activity
1764 || punit->activity_target == packet_unit->activity_target
1765 || punit->client.transported_by != packet_unit->client.transported_by
1766 || punit->client.occupied != packet_unit->client.occupied
1767 || punit->has_orders != packet_unit->has_orders
1768 || punit->orders.repeat != packet_unit->orders.repeat
1769 || punit->orders.vigilant != packet_unit->orders.vigilant
1770 || punit->orders.index != packet_unit->orders.index) {
1771
1772 /*** Change in activity or activity's target. ***/
1773
1774 /* May change focus if focus unit gets a new activity.
1775 * But if new activity is Idle, it means user specifically selected
1776 * the unit */
1778 && (packet_unit->activity != ACTIVITY_IDLE
1779 || packet_unit->has_orders)) {
1780 check_focus = TRUE;
1781 }
1782
1784
1785 /* Wakeup Focus */
1787 && NULL != client.conn.playing
1791 && packet_unit->activity == ACTIVITY_IDLE
1794 /* many wakeup units per tile are handled */
1796 check_focus = FALSE; /* and keep it */
1797 }
1798
1799 punit->activity = packet_unit->activity;
1800 punit->activity_target = packet_unit->activity_target;
1801
1803 != packet_unit->client.transported_by) {
1804 if (packet_unit->client.transported_by == -1) {
1805 /* The unit was unloaded from its transport. The check for a new
1806 * transport is done below. */
1808 }
1809
1810 punit->client.transported_by = packet_unit->client.transported_by;
1811 }
1812
1813 if (punit->client.occupied != packet_unit->client.occupied) {
1815 /* Special case: (un)loading a unit in a transporter on the same
1816 *tile as the focus unit may (dis)allow the focus unit to be
1817 * loaded. Thus the orders->(un)load menu item needs updating. */
1819 }
1820 punit->client.occupied = packet_unit->client.occupied;
1821 }
1822
1823 punit->has_orders = packet_unit->has_orders;
1824 punit->orders.length = packet_unit->orders.length;
1825 punit->orders.index = packet_unit->orders.index;
1826 punit->orders.repeat = packet_unit->orders.repeat;
1827 punit->orders.vigilant = packet_unit->orders.vigilant;
1828
1829 /* We cheat by just stealing the packet unit's list. */
1830 if (punit->orders.list) {
1832 }
1833 punit->orders.list = packet_unit->orders.list;
1834 packet_unit->orders.list = NULL;
1835
1836 if (NULL == client.conn.playing
1839 }
1840 } /*** End of Change in activity or activity's target. ***/
1841
1842 /* These two lines force the menus to be updated as appropriate when
1843 * the focus unit changes. */
1844 if (unit_is_in_focus(punit)) {
1846 }
1847
1848 if (punit->homecity != packet_unit->homecity) {
1849 /* change homecity */
1850 struct city *hcity;
1851
1853 unit_list_remove(hcity->units_supported, punit);
1855 }
1856
1857 punit->homecity = packet_unit->homecity;
1859 unit_list_prepend(hcity->units_supported, punit);
1861 }
1862
1863 /* This can change total upkeep figures */
1865 }
1866
1867 if (punit->hp != packet_unit->hp) {
1868 /* hp changed */
1869 punit->hp = packet_unit->hp;
1871 }
1872
1874 /* Unit type has changed (been upgraded) */
1875 struct city *ccity = tile_city(unit_tile(punit));
1876
1880 if (ccity != NULL && (ccity->id != punit->homecity)) {
1882 }
1883 if (unit_is_in_focus(punit)) {
1884 /* Update the orders menu -- the unit might have new abilities */
1886 }
1888 }
1889
1890 /* May change focus if an attempted move or attack exhausted unit */
1891 if (punit->moves_left != packet_unit->moves_left
1892 && unit_is_in_focus(punit)) {
1893 check_focus = TRUE;
1894 }
1895
1897 /*** Change position ***/
1898 struct city *ccity = tile_city(unit_tile(punit));
1899
1901 moved = TRUE;
1902
1903 /* Show where the unit is going. */
1905
1906 if (ccity != NULL) {
1908 /* Unit moved out of a city - update the occupied status. */
1909 bool new_occupied =
1910 (unit_list_size(ccity->tile->units) > 0);
1911
1912 if (ccity->client.occupied != new_occupied) {
1913 ccity->client.occupied = new_occupied;
1917 }
1918 }
1919 }
1920
1921 if (ccity->id == punit->homecity) {
1923 } else {
1925 }
1926 }
1927
1928 if ((ccity = tile_city(unit_tile(punit)))) {
1930 /* Unit moved into a city - obviously it's occupied. */
1931 if (!ccity->client.occupied) {
1932 ccity->client.occupied = TRUE;
1936 }
1937 }
1938 }
1939
1940 if (ccity->id == punit->homecity) {
1942 } else {
1944 }
1945 }
1946
1947 } /*** End of Change position. ***/
1948
1949 if (repaint_city || repaint_unit) {
1950 /* We repaint the city if the unit itself needs repainting or if
1951 * there is a special city-only redrawing to be done. */
1952 if ((pcity = game_city_by_number(punit->homecity))) {
1953 refresh_city_dialog(pcity);
1954 }
1956 && tile_city(unit_tile(punit)) != pcity) {
1957 /* Refresh the city we're occupying too. */
1959 }
1960 }
1961
1963 != packet_unit->upkeep[O_GOLD]);
1964 /* unit upkeep information */
1966 punit->upkeep[o] = packet_unit->upkeep[o];
1968
1969 punit->nationality = packet_unit->nationality;
1970 punit->veteran = packet_unit->veteran;
1971 punit->moves_left = packet_unit->moves_left;
1972 punit->fuel = packet_unit->fuel;
1973 punit->goto_tile = packet_unit->goto_tile;
1974 punit->paradropped = packet_unit->paradropped;
1975 punit->stay = packet_unit->stay;
1976 if (punit->done_moving != packet_unit->done_moving) {
1977 punit->done_moving = packet_unit->done_moving;
1978 check_focus = TRUE;
1979 }
1980 punit->carrying = packet_unit->carrying;
1981
1982 /* This won't change punit; it enqueues the call for later handling. */
1985
1986 if ((punit->action_decision_want != packet_unit->action_decision_want
1988 != packet_unit->action_decision_tile))
1990 /* The unit wants the player to decide. */
1992 /* Pop up an action selection dialog if the unit has focus or give
1993 * the unit higher priority in the focus queue if not. */
1994 punit->action_decision_tile = packet_unit->action_decision_tile;
1996 check_focus = TRUE;
1997 } else {
1998 /* Refresh already open action selection dialog. */
2002 tile_index(
2003 packet_unit->action_decision_tile),
2006 }
2007 }
2008 punit->action_decision_want = packet_unit->action_decision_want;
2009 punit->action_decision_tile = packet_unit->action_decision_tile;
2010 } else {
2011 /*** Create new unit ***/
2014
2017
2019
2020 if ((pcity = game_city_by_number(punit->homecity))) {
2022 }
2023
2024 log_debug("New %s %s id %d (%d %d) hc %d %s",
2028 (pcity ? city_name_get(pcity) : "(unknown)"));
2029
2032
2033 /* Check if we should link cargo units.
2034 * (This might be necessary if the cargo info was sent to us before
2035 * this transporter.) */
2036 if (punit->client.occupied) {
2038 if (aunit->client.transported_by == punit->id) {
2039 fc_assert(aunit->transporter == NULL);
2041 }
2043 }
2044
2045 if ((pcity = tile_city(unit_tile(punit)))) {
2046 /* The unit is in a city - obviously it's occupied. */
2047 pcity->client.occupied = TRUE;
2048 }
2049
2051 /* The unit wants the player to decide. */
2053 check_focus = TRUE;
2054 }
2055
2057 } /*** End of Create new unit ***/
2058
2060
2061 /* Check if we have to load the unit on a transporter. */
2062 if (punit->client.transported_by != -1) {
2063 struct unit *ptrans
2064 = game_unit_by_number(packet_unit->client.transported_by);
2065
2066 /* Load unit only if transporter is known by the client.
2067 * (If not, cargo will be loaded later when the transporter info is
2068 * sent to the client.) */
2070 /* First, we have to unload the unit from its old transporter. */
2073#ifdef DEBUG_TRANSPORT
2074 log_debug("load %s (ID: %d) onto %s (ID: %d)",
2077 } else if (ptrans && ptrans == unit_transport_get(punit)) {
2078 log_debug("%s (ID: %d) is loaded onto %s (ID: %d)",
2081 } else {
2082 log_debug("%s (ID: %d) is not loaded", unit_name_translation(punit),
2083 punit->id);
2084#endif /* DEBUG_TRANSPORT */
2085 }
2086 }
2087
2092 /* Update (an possible active) unit select dialog. */
2094 }
2095
2096 if (repaint_unit) {
2098 }
2099
2100 if ((check_focus || get_num_units_in_focus() == 0)
2101 && NULL != client.conn.playing
2105 }
2106
2107 if (need_menus_update) {
2108 menus_update();
2109 }
2110
2114 }
2117 }
2118 }
2119
2120 return ret;
2121}
2122
2123/************************************************************************/
2130{
2131 struct city *pcity = game_city_by_number(packet->city_id);
2132
2133 if (!pcity) {
2134 log_error("Investigate city: unknown city id %d!",
2135 packet->city_id);
2136 return;
2137 }
2138
2139 /* Start collecting supported and present units. */
2140
2141 /* Ensure we are not already in an investigate cycle. */
2148}
2149
2150/************************************************************************/
2154{
2155}
2156
2157/************************************************************************/
2161{
2162 struct city *pcity;
2163 struct unit *punit;
2164
2165 /* Special case for a diplomat/spy investigating a city: The investigator
2166 * needs to know the supported and present units of a city, whether or not
2167 * they are fogged. So, we send a list of them all before sending the city
2168 * info. */
2170 || packet->packet_use == UNIT_INFO_CITY_PRESENT) {
2171
2172 pcity = game_city_by_number(packet->info_city_id);
2173 if (!pcity) {
2174 log_error("Investigate city: unknown city id %d!",
2175 packet->info_city_id);
2176 return;
2177 }
2178
2179 /* Append a unit struct to the proper list. */
2180 punit = unpackage_short_unit(packet);
2181 if (packet->packet_use == UNIT_INFO_CITY_SUPPORTED) {
2184 } else {
2188 }
2189
2190 /* Done with special case. */
2191 return;
2192 }
2193
2194 if (player_by_number(packet->owner) == client.conn.playing) {
2195 log_error("handle_unit_short_info() for own unit.");
2196 }
2197
2198 punit = unpackage_short_unit(packet);
2202 }
2203}
2204
2205/************************************************************************/
2208void handle_set_topology(int topology_id, int wrap_id)
2209{
2210 wld.map.topology_id = topology_id;
2211 wld.map.wrap_id = wrap_id;
2212
2213 if (forced_tileset_name[0] == '\0'
2214 && (tileset_map_topo_compatible(topology_id, tileset, NULL)
2217 const char *ts_to_load;
2218
2220
2221 if (ts_to_load != NULL && ts_to_load[0] != '\0' && strcmp(tileset_basename(tileset), ts_to_load)) {
2223 }
2224 }
2225}
2226
2227/************************************************************************/
2231void handle_map_info(const struct packet_map_info *packet)
2232{
2233 int ts_topo;
2234
2235 if (!map_is_empty()) {
2236 map_free(&(wld.map));
2238 }
2239
2240 wld.map.xsize = packet->xsize;
2241 wld.map.ysize = packet->ysize;
2242
2245
2248 _("Map topology (%s) and tileset (%s) incompatible."),
2250 }
2251
2252 wld.map.topology_id = packet->topology_id;
2253 wld.map.wrap_id = packet->wrap_id;
2254
2259 mapdeco_init();
2260
2262
2264
2265 packhand_init();
2266}
2267
2268/************************************************************************/
2272{
2273 bool boot_help;
2275 bool toggle_edit_ui = FALSE;
2276
2277 if (game.info.aifill != pinfo->aifill) {
2279 }
2280 if (game.info.skill_level != pinfo->skill_level) {
2282 }
2283
2284 if (game.info.is_edit_mode != pinfo->is_edit_mode) {
2286
2288 /* Clears the current goto command. */
2290
2291 if (pinfo->is_edit_mode) {
2293 /* Gui didn't handle this */
2295 _("This scenario may have manually set properties the editor "
2296 "cannot handle."));
2298 _("They won't be saved when scenario is saved from the editor."));
2299 }
2300 }
2301 }
2302
2303 game.info = *pinfo;
2304
2305 /* check the values! */
2306#define VALIDATE(_count, _maximum, _string) \
2307 if (game.info._count > _maximum) { \
2308 log_error("handle_game_info(): Too many " _string "; using %d of %d", \
2309 _maximum, game.info._count); \
2310 game.info._count = _maximum; \
2311 }
2312
2313 VALIDATE(granary_num_inis, MAX_GRANARY_INIS, "granary entries");
2314#undef VALIDATE
2315
2320
2322 && game.info.victory_conditions != pinfo->victory_conditions);
2323 if (boot_help) {
2324 boot_help_texts(); /* reboot, after setting game.spacerace */
2325 }
2327 menus_update();
2331 }
2332
2333 if (can_client_change_view()) {
2335 }
2336
2337 if (toggle_edit_ui) {
2339 }
2340
2342}
2343
2344/************************************************************************/
2351
2352/************************************************************************/
2355void handle_timeout_info(float seconds_to_phasedone, float last_turn_change_time)
2356{
2357 if (current_turn_timeout() != 0 && seconds_to_phasedone >= 0) {
2358 /* If this packet is received in the middle of a turn, this value
2359 * represents the number of seconds from now to the end of the turn
2360 * (not from the start of the turn). So we need to restart our
2361 * timer. */
2362 set_seconds_to_turndone(seconds_to_phasedone);
2363 }
2364
2365 game.tinfo.last_turn_change_time = last_turn_change_time;
2366}
2367
2368/************************************************************************/
2380
2381/************************************************************************/
2390
2391/************************************************************************/
2396void handle_player_remove(int playerno)
2397{
2398 struct player_slot *pslot;
2399 struct player *pplayer;
2400 int plr_nbr;
2401
2402 pslot = player_slot_by_number(playerno);
2403
2404 if (NULL == pslot || !player_slot_is_used(pslot)) {
2405 /* Ok, just ignore. */
2406 return;
2407 }
2408
2409 pplayer = player_slot_get_player(pslot);
2410
2411 if (can_client_change_view()) {
2412 close_intel_dialog(pplayer);
2413 }
2414
2415 /* Update the connection information. */
2416 if (client_player() == pplayer) {
2418 }
2420 pconn->playing = NULL;
2422 conn_list_clear(pplayer->connections);
2423
2424 /* Save player number before player is freed */
2425 plr_nbr = player_number(pplayer);
2426
2427 player_destroy(pplayer);
2428
2431
2434}
2435
2436/************************************************************************/
2442{
2443 bool is_new_nation = FALSE;
2444 bool turn_done_changed = FALSE;
2445 bool new_player = FALSE;
2446 int i;
2447 struct player *pplayer, *my_player;
2448 struct nation_type *pnation;
2449 struct government *pgov, *ptarget_gov;
2450 struct player_slot *pslot;
2451 struct team_slot *tslot;
2452 bool gov_change;
2453
2454 /* Player. */
2455 pslot = player_slot_by_number(pinfo->playerno);
2456 fc_assert(NULL != pslot);
2458 pplayer = player_new(pslot);
2459
2460 if ((pplayer->rgb == NULL) != !pinfo->color_valid
2461 || (pinfo->color_valid
2462 && (pplayer->rgb->r != pinfo->color_red
2463 || pplayer->rgb->g != pinfo->color_green
2464 || pplayer->rgb->b != pinfo->color_blue))) {
2465 struct rgbcolor *prgbcolor;
2466
2467 if (pinfo->color_valid) {
2468 prgbcolor = rgbcolor_new(pinfo->color_red,
2469 pinfo->color_green,
2470 pinfo->color_blue);
2472 } else {
2473 prgbcolor = NULL;
2474 }
2475
2476 player_set_color(pplayer, prgbcolor);
2477 tileset_player_init(tileset, pplayer);
2478
2480
2481 /* Queue a map update -- may need to redraw borders, etc. */
2483 }
2484 pplayer->client.color_changeable = pinfo->color_changeable;
2485
2486 if (new_player) {
2487 /* Initialise client side player data (tile vision). At the moment
2488 * redundant as the values are initialised with 0 due to fc_calloc(). */
2489 client_player_init(pplayer);
2490 }
2491
2492 /* Team. */
2494 fc_assert(NULL != tslot);
2495
2496 /* Should never fail when slot given is not NULL */
2497 team_add_player(pplayer, team_new(tslot));
2498
2499 pnation = nation_by_number(pinfo->nation);
2500 pgov = government_by_number(pinfo->government);
2501 ptarget_gov = government_by_number(pinfo->target_government);
2502
2503 /* Now update the player information. */
2504 sz_strlcpy(pplayer->name, pinfo->name);
2505 sz_strlcpy(pplayer->username, pinfo->username);
2506 pplayer->unassigned_user = pinfo->unassigned_user;
2507
2508 is_new_nation = player_set_nation(pplayer, pnation);
2509 pplayer->is_male = pinfo->is_male;
2510 pplayer->score.game = pinfo->score;
2511 pplayer->was_created = pinfo->was_created;
2512
2513 pplayer->autoselect_weight = pinfo->autoselect_weight;
2514 pplayer->economic.gold = pinfo->gold;
2515 pplayer->economic.tax = pinfo->tax;
2516 pplayer->economic.science = pinfo->science;
2517 pplayer->economic.luxury = pinfo->luxury;
2518 if (has_capability("tu32", client.conn.capability)) {
2519 pplayer->client.tech_upkeep = pinfo->tech_upkeep_32;
2520 } else {
2521 pplayer->client.tech_upkeep = pinfo->tech_upkeep_16;
2522 }
2523 gov_change = (!new_player && pgov != pplayer->government
2524 && pplayer->government != NULL);
2525 pplayer->government = pgov;
2526 pplayer->target_government = ptarget_gov;
2527 pplayer->real_embassy = pinfo->real_embassy;
2528 pplayer->gives_shared_vision = pinfo->gives_shared_vision;
2529 pplayer->gives_shared_tiles = pinfo->gives_shared_tiles;
2530 pplayer->style = style_by_number(pinfo->style);
2531
2532 if (pplayer == client.conn.playing) {
2533 bool music_change = FALSE;
2534
2535 if (pplayer->music_style != pinfo->music_style) {
2536 pplayer->music_style = pinfo->music_style;
2538 }
2539 if (pplayer->client.mood != pinfo->mood) {
2540 pplayer->client.mood = pinfo->mood;
2542 }
2543
2544 if (music_change) {
2546 }
2547
2548 if (gov_change) {
2549 audio_play_sound(pgov->sound_str, pgov->sound_alt, pgov->sound_alt2);
2550 }
2551 }
2552
2553 pplayer->history = pinfo->history;
2554 pplayer->client.culture = pinfo->culture;
2555
2556 if (pplayer->economic.infra_points != pinfo->infrapoints) {
2557 pplayer->economic.infra_points = pinfo->infrapoints;
2559 }
2560
2561 /* Don't use player_iterate or player_slot_count here, because we ignore
2562 * the real number of players and we want to read all the datas. */
2563 fc_assert(ARRAY_SIZE(pplayer->ai_common.love) >= ARRAY_SIZE(pinfo->love));
2564 for (i = 0; i < ARRAY_SIZE(pinfo->love); i++) {
2565 pplayer->ai_common.love[i] = pinfo->love[i];
2566 }
2567
2569
2570 pplayer->is_connected = pinfo->is_connected;
2571
2572 for (i = 0; i < B_LAST; i++) {
2573 pplayer->wonders[i] = pinfo->wonders[i];
2574 }
2575
2576 /* Set AI.control. */
2577 if (is_ai(pplayer) != BV_ISSET(pinfo->flags, PLRF_AI)) {
2578 BV_SET_VAL(pplayer->flags, PLRF_AI, BV_ISSET(pinfo->flags, PLRF_AI));
2579 if (pplayer == my_player) {
2580 if (is_ai(my_player)) {
2581 output_window_append(ftc_client, _("AI mode is now ON."));
2582 if (!gui_options.ai_manual_turn_done && !pplayer->phase_done) {
2583 /* End turn immediately */
2585 }
2586 } else {
2587 output_window_append(ftc_client, _("AI mode is now OFF."));
2588 }
2589 }
2590 }
2591
2592 pplayer->flags = pinfo->flags;
2593
2594 pplayer->ai_common.science_cost = pinfo->science_cost;
2595
2596 turn_done_changed = (pplayer->phase_done != pinfo->phase_done
2597 || (BV_ISSET(pplayer->flags, PLRF_AI) !=
2598 BV_ISSET(pinfo->flags, PLRF_AI)));
2599 pplayer->phase_done = pinfo->phase_done;
2600
2601 pplayer->is_ready = pinfo->is_ready;
2602 pplayer->nturns_idle = pinfo->nturns_idle;
2603 pplayer->is_alive = pinfo->is_alive;
2604 pplayer->turns_alive = pinfo->turns_alive;
2605 pplayer->ai_common.barbarian_type = pinfo->barbarian_type;
2606 pplayer->revolution_finishes = pinfo->revolution_finishes;
2607 pplayer->ai_common.skill_level = pinfo->ai_skill_level;
2608
2609 fc_assert(pinfo->multip_count == multiplier_count());
2610 game.control.num_multipliers = pinfo->multip_count;
2611 multipliers_iterate(pmul) {
2612 int idx = multiplier_index(pmul);
2613
2614 pplayer->multipliers[idx].value = pinfo->multiplier[idx];
2615 pplayer->multipliers[idx].target = pinfo->multiplier_target[idx];
2616 pplayer->multipliers[idx].changed = pinfo->multiplier_changed[idx];
2618
2619 /* if the server requests that the client reset, then information about
2620 * connections to this player are lost. If this is the case, insert the
2621 * correct conn back into the player->connections list */
2622 if (conn_list_size(pplayer->connections) == 0) {
2624 if (pplayer == pconn->playing) {
2625 /* insert the controller into first position */
2626 if (pconn->observer) {
2628 } else {
2630 }
2631 }
2633 }
2634
2635
2636 /* The player information is now fully set. Update the GUI. */
2637
2638 if (pplayer == my_player && can_client_change_view()) {
2639 if (turn_done_changed) {
2641 }
2648 menus_update();
2649 }
2650
2652
2655
2656 if (is_new_nation) {
2658
2659 /* When changing nation during a running game, some refreshing is needed.
2660 * This may not be the only one! */
2662 }
2663
2664 if (can_client_change_view()) {
2665 /* Just about any changes above require an update to the intelligence
2666 * dialog. */
2667 update_intel_dialog(pplayer);
2668 }
2669
2672 FALSE);
2673}
2674
2675/************************************************************************/
2679{
2680 struct research *presearch;
2681 bool tech_changed = FALSE;
2682 bool poptechup = FALSE;
2684 int gained_techs_num = 0, i;
2686
2687#ifdef FREECIV_DEBUG
2688 log_verbose("Research nb %d inventions: %s",
2689 packet->id,
2690 packet->inventions);
2691#endif
2692 presearch = research_by_number(packet->id);
2694
2695 poptechup = (presearch->researching != packet->researching
2696 || presearch->tech_goal != packet->tech_goal);
2697 presearch->techs_researched = packet->techs_researched;
2698 if (presearch->future_tech == 0 && packet->future_tech > 0) {
2700 }
2701 presearch->future_tech = packet->future_tech;
2702 presearch->researching = packet->researching;
2703 presearch->client.researching_cost = packet->researching_cost;
2704 presearch->bulbs_researched = packet->bulbs_researched;
2705 presearch->tech_goal = packet->tech_goal;
2706 presearch->client.total_bulbs_prod = packet->total_bulbs_prod;
2707
2709 newstate = packet->inventions[advi] - '0';
2711
2712 if (newstate != oldstate) {
2713 if (TECH_KNOWN == newstate) {
2715 if (A_NONE != advi) {
2717 }
2718 } else if (TECH_KNOWN == oldstate) {
2720 }
2721 }
2723
2725
2726 if (C_S_RUNNING == client_state()) {
2728 if (poptechup && is_human(client_player())) {
2730 }
2732 if (tech_changed) {
2733 /* Some ways a new or lost tech can affect menus:
2734 * - If tech is needed for certain governments, the government
2735 * switching menus need updating.
2736 * - If we just learned/lost bridge building and focus is on a
2737 * worker on a river, the road menu item needs updating. */
2738 menus_update();
2739
2740 script_client_signal_emit("new_tech");
2741
2742 /* If we got a new tech the tech tree news an update. */
2744 }
2745 for (i = 0; i < gained_techs_num; i++) {
2747 }
2748 }
2749 if (editor_is_active()) {
2753 FALSE);
2755 }
2756 }
2757}
2758
2759/************************************************************************/
2763{
2765
2766 if (presearch == NULL) {
2767 log_error("Received unknown research for clearing: %d.", id);
2768 return;
2769 }
2770
2771 /* Do we need to set other fields? */
2772 presearch->researching = A_UNKNOWN;
2773 presearch->future_tech = 0;
2774 presearch->tech_goal = A_UNKNOWN;
2775
2779
2780 if (editor_is_active()) {
2784 FALSE);
2786 }
2787}
2788
2789/************************************************************************/
2793{
2794 struct player *plr1 = player_by_number(packet->plr1);
2795 struct player *plr2 = player_by_number(packet->plr2);
2796 struct player *my_player = client_player();
2797 struct player_diplstate *ds = player_diplstate_get(plr1, plr2);
2799
2800 fc_assert_ret(ds != NULL);
2801
2802 if (client_has_player() && my_player == plr2) {
2803 if (ds->type != packet->type) {
2805 }
2806
2807 /* Check if we detect change to armistice with us. If so,
2808 * ready all units for movement out of the territory in
2809 * question; otherwise they will be disbanded. */
2811 && DS_ARMISTICE == packet->type) {
2814 || tile_owner(unit_tile(punit)) != plr1) {
2815 continue;
2816 }
2819 }
2820 if (punit->activity != ACTIVITY_IDLE) {
2822 }
2824 }
2825 }
2826
2827 ds->type = packet->type;
2828 ds->turns_left = packet->turns_left;
2829 ds->has_reason_to_cancel = packet->has_reason_to_cancel;
2830 ds->contact_turns_left = packet->contact_turns_left;
2831
2834 }
2835
2838 /* An action selection dialog is open and our diplomatic state just
2839 * changed. Find out if the relationship that changed was to a
2840 * potential target. */
2841 struct tile *tgt_tile = NULL;
2842
2843 /* Is a refresh needed because of a unit target? */
2845 struct unit *tgt_unit;
2846
2848
2849 if (tgt_unit != NULL && tgt_unit->owner == plr1) {
2850 /* An update is needed because of this unit target. */
2853 }
2854 }
2855
2856 /* Is a refresh needed because of a city target? */
2858 struct city *tgt_city;
2859
2861
2862 if (tgt_city != NULL && tgt_city->owner == plr1) {
2863 /* An update is needed because of this city target.
2864 * Overwrites any target tile from a unit. */
2867 }
2868 }
2869
2870 if (tgt_tile
2871 || ((tgt_tile = index_to_tile(&(wld.map),
2873 && tile_owner(tgt_tile) == plr1)) {
2874 /* The diplomatic relationship to the target in an open action
2875 * selection dialog have changed. This probably changes
2876 * the set of available actions. */
2880 tgt_tile->index,
2883 }
2884 }
2885}
2886
2887/************************************************************************/
2894{
2895 struct connection *pconn = conn_by_number(pinfo->id);
2897
2898 log_debug("conn_info id%d used%d est%d plr%d obs%d acc%d",
2899 pinfo->id, pinfo->used, pinfo->established, pinfo->player_num,
2900 pinfo->observer, (int) pinfo->access_level);
2901 log_debug("conn_info \"%s\" \"%s\" \"%s\"",
2902 pinfo->username, pinfo->addr, pinfo->capability);
2903
2904 if (!pinfo->used) {
2905 /* Forget the connection */
2906 if (!pconn) {
2907 log_verbose("Server removed unknown connection %d", pinfo->id);
2908 return;
2909 }
2911 pconn = NULL;
2912 } else {
2913 struct player_slot *pslot = player_slot_by_number(pinfo->player_num);
2914 struct player *pplayer = NULL;
2915
2916 if (NULL != pslot) {
2917 pplayer = player_slot_get_player(pslot);
2918 }
2919
2920 if (!pconn) {
2921 log_verbose("Server reports new connection %d %s",
2922 pinfo->id, pinfo->username);
2923
2924 pconn = fc_calloc(1, sizeof(struct connection));
2925 pconn->buffer = NULL;
2926 pconn->send_buffer = NULL;
2927 pconn->ping_time = -1.0;
2928 if (pplayer) {
2930 }
2933 } else {
2934 log_packet("Server reports updated connection %d %s",
2935 pinfo->id, pinfo->username);
2936 if (pplayer != pconn->playing) {
2937 if (NULL != pconn->playing) {
2938 conn_list_remove(pconn->playing->connections, pconn);
2939 }
2940 if (pplayer) {
2942 }
2943 }
2944 }
2945
2946 pconn->id = pinfo->id;
2947 pconn->established = pinfo->established;
2948 pconn->observer = pinfo->observer;
2949 pconn->access_level = pinfo->access_level;
2950 pconn->playing = pplayer;
2951
2952 sz_strlcpy(pconn->username, pinfo->username);
2953 sz_strlcpy(pconn->addr, pinfo->addr);
2954 sz_strlcpy(pconn->capability, pinfo->capability);
2955
2956 if (pinfo->id == client.conn.id) {
2957 /* NB: In this case, pconn is not a duplication of client.conn.
2958 *
2959 * pconn->addr is our address that the server knows whereas
2960 * client.conn.addr is the address to the server. Also,
2961 * pconn->capability stores our capabilites known at server side
2962 * whereas client.conn.capability represents the capabilities of the
2963 * server. */
2964 if (client.conn.playing != pplayer
2965 || client.conn.observer != pinfo->observer) {
2966 /* Our connection state changed, let prepare the changes and reset
2967 * the game. */
2969 }
2970
2971 /* Copy our current state into the static structure (our connection
2972 * to the server). */
2973 client.conn.established = pinfo->established;
2974 client.conn.observer = pinfo->observer;
2975 client.conn.access_level = pinfo->access_level;
2976 client.conn.playing = pplayer;
2977 sz_strlcpy(client.conn.username, pinfo->username);
2978 }
2979 }
2980
2983
2984 if (pinfo->used && pinfo->id == client.conn.id) {
2985 /* For updating the sensitivity of the "Edit Mode" menu item,
2986 * among other things. */
2987 menus_update();
2988 }
2989
2992 }
2993}
2994
2995/************************************************************************/
2999void handle_conn_ping_info(int connections, const int *conn_id,
3000 const float *ping_time)
3001{
3002 int i;
3003
3004 for (i = 0; i < connections; i++) {
3005 struct connection *pconn = conn_by_number(conn_id[i]);
3006
3007 if (!pconn) {
3008 continue;
3009 }
3010
3011 pconn->ping_time = ping_time[i];
3012 log_debug("conn-id=%d, ping=%fs", pconn->id, pconn->ping_time);
3013 }
3014 /* The old_ping_time data is ignored. */
3015
3017}
3018
3019/************************************************************************/
3022void handle_achievement_info(int id, bool gained, bool first)
3023{
3024 struct achievement *pach;
3025
3027 log_error("Received illegal achievement info %d", id);
3028 return;
3029 }
3030
3032
3033 if (gained) {
3034 BV_SET(pach->achievers, player_index(client_player()));
3035 } else {
3036 BV_CLR(pach->achievers, player_index(client_player()));
3037 }
3038
3039 if (first) {
3040 pach->first = client_player();
3041 }
3042}
3043
3044/************************************************************************/
3059static bool spaceship_autoplace(struct player *pplayer,
3060 struct player_spaceship *ship)
3061{
3064
3065 if (next_spaceship_component(pplayer, ship, &place)) {
3067
3068 return TRUE;
3069 }
3070 }
3071
3072 return FALSE;
3073}
3074
3075/************************************************************************/
3079{
3080 struct player_spaceship *ship;
3081 struct player *pplayer = player_by_number(p->player_num);
3082
3083 fc_assert_ret_msg(NULL != pplayer, "Invalid player number %d.",
3084 p->player_num);
3085
3086 ship = &pplayer->spaceship;
3087 ship->state = p->sship_state;
3088 ship->structurals = p->structurals;
3089 ship->components = p->components;
3090 ship->modules = p->modules;
3091 ship->fuel = p->fuel;
3092 ship->propulsion = p->propulsion;
3093 ship->habitation = p->habitation;
3094 ship->life_support = p->life_support;
3095 ship->solar_panels = p->solar_panels;
3096 ship->launch_year = p->launch_year;
3097 ship->population = p->population;
3098 ship->mass = p->mass;
3099 ship->support_rate = p->support_rate;
3100 ship->energy_rate = p->energy_rate;
3101 ship->success_rate = p->success_rate;
3102 ship->travel_time = p->travel_time;
3103 ship->structure = p->structure;
3104
3105 if (pplayer != client_player()) {
3106 refresh_spaceship_dialog(pplayer);
3107 menus_update();
3108 return;
3109 }
3110
3111 if (!spaceship_autoplace(pplayer, ship)) {
3112 /* We refresh the dialog when the packet did *not* cause placing
3113 * of new part. That's because those cases where part is placed, are
3114 * followed by exactly one case where there's no more parts to place -
3115 * we want to refresh the dialog only when that last packet comes. */
3116 refresh_spaceship_dialog(pplayer);
3117 }
3118}
3119
3120/************************************************************************/
3123void handle_tile_info(const struct packet_tile_info *packet)
3124{
3125 enum known_type new_known;
3126 enum known_type old_known;
3127 bool known_changed = FALSE;
3128 bool tile_changed = FALSE;
3129 struct player *powner = player_by_number(packet->owner);
3130 struct player *eowner = player_by_number(packet->extras_owner);
3131 struct extra_type *presource = NULL;
3132 struct terrain *pterrain = terrain_by_number(packet->terrain);
3133 struct tile *ptile = index_to_tile(&(wld.map), packet->tile);
3134
3135 fc_assert_ret_msg(NULL != ptile, "Invalid tile index %d.", packet->tile);
3137
3138 if (packet->resource != MAX_EXTRA_TYPES) {
3139 presource = extra_by_number(packet->resource);
3140 }
3141
3142 if (NULL == tile_terrain(ptile) || pterrain != tile_terrain(ptile)) {
3144 switch (old_known) {
3145 case TILE_UNKNOWN:
3146 tile_set_terrain(ptile, pterrain);
3147 break;
3148 case TILE_KNOWN_UNSEEN:
3149 case TILE_KNOWN_SEEN:
3150 if (NULL != pterrain || TILE_UNKNOWN == packet->known) {
3151 tile_set_terrain(ptile, pterrain);
3152 } else {
3154 log_error("handle_tile_info() unknown terrain (%d, %d).",
3155 TILE_XY(ptile));
3156 }
3157 break;
3158 };
3159 }
3160
3161 if (!BV_ARE_EQUAL(ptile->extras, packet->extras)) {
3162 ptile->extras = packet->extras;
3164 }
3165
3166 tile_changed = tile_changed || (tile_resource(ptile) != presource);
3167
3168 /* always called after setting terrain */
3169 tile_set_resource(ptile, presource);
3170
3171 if (tile_owner(ptile) != powner) {
3172 tile_set_owner(ptile, powner, NULL);
3174 }
3175 if (extra_owner(ptile) != eowner) {
3176 ptile->extras_owner = eowner;
3178 }
3179
3180 if (packet->placing < 0) {
3181 if (ptile->placing != NULL) {
3183 ptile->placing = NULL;
3184 ptile->infra_turns = 0;
3185 }
3186 } else {
3187 struct extra_type *old = ptile->placing;
3188
3189 ptile->placing = extra_by_number(packet->placing);
3190 if (ptile->placing != old
3191 || ptile->infra_turns != packet->place_turn - game.info.turn) {
3193 }
3194 ptile->infra_turns = packet->place_turn - game.info.turn;
3195 }
3196
3197 if (NULL == tile_worked(ptile)
3198 || tile_worked(ptile)->id != packet->worked) {
3199 if (IDENTITY_NUMBER_ZERO != packet->worked) {
3200 struct city *pwork = game_city_by_number(packet->worked);
3201
3202 if (NULL == pwork) {
3203 char named[MAX_LEN_CITYNAME];
3204
3205 /* New unseen ("invisible") city, or before city_info */
3206 fc_snprintf(named, sizeof(named), "%06u", packet->worked);
3207
3208 pwork = create_city_virtual(invisible.placeholder, NULL, named);
3209 pwork->id = packet->worked;
3211
3213
3214 log_debug("(%d,%d) invisible city %d, %s",
3215 TILE_XY(ptile), pwork->id, city_name_get(pwork));
3216 } else if (NULL == city_tile(pwork)) {
3217 /* Old unseen ("invisible") city, or before city_info */
3218 if (NULL != powner && city_owner(pwork) != powner) {
3219 /* Update placeholder with current owner */
3220 pwork->owner = powner;
3221 pwork->original = NULL;
3222 }
3223 } else {
3224 /* We have a real (not invisible) city record for this ID, but
3225 * perhaps our info about that city is out of date. */
3226 int dist_sq = sq_map_distance(city_tile(pwork), ptile);
3227
3229 /* This is probably enemy city which has grown in diameter since we
3230 * last saw it. We need city_radius_sq to be at least big enough so
3231 * that all workers fit in, so set it so. */
3233 }
3234 /* This might be a known city that is open in a dialog.
3235 * (And this might be our only prompt to refresh the worked tiles
3236 * display in its city map, if a worker rearrangement does not
3237 * change anything else about the city such as output.) */
3238 {
3239 struct city *oldwork = tile_worked(ptile);
3240 if (oldwork && NULL != city_tile(oldwork)) {
3241 /* Refresh previous city too if it's real and different */
3243 }
3244 /* Refresh new city working tile (which we already know is real) */
3246 }
3247 }
3248
3249 /* This marks tile worked by (possibly invisible) city. Other
3250 * parts of the code have to handle invisible cities correctly
3251 * (ptile->worked->tile == NULL) */
3252 tile_set_worked(ptile, pwork);
3253 } else {
3254 /* Tile is no longer being worked by a city.
3255 * (Again, this might be our only prompt to refresh the worked tiles
3256 * display for the previous working city.) */
3257 if (tile_worked(ptile) && NULL != city_tile(tile_worked(ptile))) {
3259 }
3260 tile_set_worked(ptile, NULL);
3261 }
3262
3264 }
3265
3266 if (old_known != packet->known) {
3268 }
3269
3270 if (NULL != client.conn.playing) {
3275
3276 switch (packet->known) {
3277 case TILE_KNOWN_SEEN:
3282 break;
3283 case TILE_KNOWN_UNSEEN:
3285 break;
3286 case TILE_UNKNOWN:
3287 break;
3288 default:
3289 log_error("handle_tile_info() invalid known (%d).", packet->known);
3290 break;
3291 };
3292 }
3294
3295 if (packet->spec_sprite[0] != '\0') {
3296 if (!ptile->spec_sprite
3297 || strcmp(ptile->spec_sprite, packet->spec_sprite) != 0) {
3298 if (ptile->spec_sprite) {
3299 free(ptile->spec_sprite);
3300 }
3301 ptile->spec_sprite = fc_strdup(packet->spec_sprite);
3303 }
3304 } else {
3305 if (ptile->spec_sprite) {
3306 free(ptile->spec_sprite);
3307 ptile->spec_sprite = NULL;
3309 }
3310 }
3311
3313 /* This is an error. So first we log the error,
3314 * then make an assertion. */
3315 unit_list_iterate(ptile->units, punit) {
3316 log_error("%p %d %s at (%d,%d) %s", punit, punit->id,
3320 fc_assert_msg(0 == unit_list_size(ptile->units), "Ghost units seen");
3321 /* Repairing... */
3322 unit_list_clear(ptile->units);
3323 }
3324
3325 ptile->continent = packet->continent;
3327
3328 if (packet->label[0] == '\0') {
3329 if (ptile->label != NULL) {
3330 FC_FREE(ptile->label);
3331 ptile->label = NULL;
3333 }
3334 } else if (ptile->label == NULL || strcmp(packet->label, ptile->label)) {
3335 tile_set_label(ptile, packet->label);
3337 }
3338
3339 if (known_changed || tile_changed) {
3340 /*
3341 * A tile can only change if it was known before and is still
3342 * known. In the other cases the tile is new or removed.
3343 */
3345 agents_tile_new(ptile);
3346 } else if (known_changed && TILE_KNOWN_UNSEEN == new_known) {
3347 agents_tile_remove(ptile);
3348 } else {
3349 agents_tile_changed(ptile);
3350 }
3352 }
3353
3354 /* refresh tiles */
3355 if (can_client_change_view()) {
3356 /* the tile itself (including the necessary parts of adjacent tiles) */
3357 if (tile_changed || old_known != new_known) {
3359 }
3360 }
3361
3362 /* update menus if the focus unit is on the tile. */
3363 if (tile_changed) {
3364 if (get_focus_unit_on_tile(ptile)) {
3365 menus_update();
3366 }
3367 }
3368
3369 /* FIXME: we really ought to call refresh_city_dialog() for any city
3370 * whose radii include this tile, to update the city map display.
3371 * But that would be expensive. We deal with the (common) special
3372 * case of changes in worked tiles above. */
3373}
3374
3375/************************************************************************/
3395
3396/************************************************************************/
3399void handle_scenario_description(const char *description)
3400{
3402
3404}
3405
3406/************************************************************************/
3412{
3413 /* The ruleset is going to load new nations. So close
3414 * the nation selection dialog if it is open. */
3416
3422 game.control = *packet;
3423
3424 /* check the values! */
3425#define VALIDATE(_count, _maximum, _string) \
3426 if (game.control._count > _maximum) { \
3427 log_error("handle_ruleset_control(): Too many " _string \
3428 "; using %d of %d", _maximum, game.control._count); \
3429 game.control._count = _maximum; \
3430 }
3431
3432 VALIDATE(num_unit_classes, UCL_LAST, "unit classes");
3433 VALIDATE(num_unit_types, U_LAST, "unit types");
3434 VALIDATE(num_impr_types, B_LAST, "improvements");
3435 VALIDATE(num_tech_types, A_LAST, "advances");
3436 VALIDATE(num_base_types, MAX_EXTRA_TYPES, "bases");
3437 VALIDATE(num_road_types, MAX_EXTRA_TYPES, "roads");
3438 VALIDATE(num_resource_types, MAX_EXTRA_TYPES, "resources");
3439 VALIDATE(num_disaster_types, MAX_DISASTER_TYPES, "disasters");
3440 VALIDATE(num_achievement_types, MAX_ACHIEVEMENT_TYPES, "achievements");
3441 VALIDATE(num_counters, MAX_COUNTERS, "counters");
3442
3443 /* game.control.government_count, game.control.nation_count and
3444 * game.control.num_city_styles are allocated dynamically, and do
3445 * not need a size check. See the allocation below. */
3446
3448
3449 VALIDATE(num_specialist_types, SP_MAX, "specialists");
3450#undef VALIDATE
3451
3457
3458 if (game.control.desc_length > 0) {
3460 game.ruleset_description[0] = '\0';
3461 }
3462
3463 if (packet->preferred_tileset[0] != '\0') {
3464 /* There is tileset suggestion */
3466 /* It's not currently in use */
3469 } else {
3471 }
3472 }
3473 }
3474
3475 if (packet->preferred_soundset[0] != '\0') {
3476 /* There is soundset suggestion */
3478 /* It's not currently in use */
3481 } else {
3483 }
3484 }
3485 }
3486
3487 if (packet->preferred_musicset[0] != '\0') {
3488 /* There is musicset suggestion */
3490 /* It's not currently in use */
3493 } else {
3495 }
3496 }
3497 }
3498
3500
3502}
3503
3504/************************************************************************/
3508{
3509 int len;
3510
3511 if (game.ruleset_summary != NULL) {
3513 }
3514
3515 len = strlen(packet->text);
3516
3518
3519 fc_strlcpy(game.ruleset_summary, packet->text, len + 1);
3520}
3521
3522/************************************************************************/
3531
3532/************************************************************************/
3536{
3537 /* Setup extra hiders caches */
3538 extra_type_iterate(pextra) {
3539 pextra->hiders = extra_type_list_new();
3541 if (BV_ISSET(pextra->hidden_by, extra_index(phider))) {
3542 extra_type_list_append(pextra->hiders, phider);
3543 }
3545 pextra->bridged = extra_type_list_new();
3547 if (BV_ISSET(pextra->bridged_over, extra_index(pbridged))) {
3548 extra_type_list_append(pextra->bridged, pbridged);
3549 }
3552
3557
3558 /* Setup improvement feature caches */
3560
3561 /* Setup road integrators caches */
3563
3564 /* Pre calculate action related data. */
3566
3567 /* Setup unit unknown move cost caches */
3569 ptype->unknown_move_cost = utype_unknown_move_cost(ptype);
3573
3574 /* Cache what city production can receive help from caravans. */
3576
3577 /* Adjust editor for changed ruleset. */
3579
3580 /* We are not going to crop any more sprites from big sprites, free them. */
3582
3584}
3585
3586/************************************************************************/
3590{
3591 struct unit_class *c = uclass_by_number(p->id);
3592
3593 fc_assert_ret_msg(NULL != c, "Bad unit_class %d.", p->id);
3594
3595 names_set(&c->name, NULL, p->name, p->rule_name);
3596 c->min_speed = p->min_speed;
3597 c->hp_loss_pct = p->hp_loss_pct;
3599 c->flags = p->flags;
3600
3602}
3603
3604/************************************************************************/
3608{
3609 int i;
3610 struct unit_type *u = utype_by_number(p->id);
3611
3612 fc_assert_ret_msg(NULL != u, "Bad unit_type %d.", p->id);
3613
3614 names_set(&u->name, NULL, p->name, p->rule_name);
3622
3624 u->build_cost = p->build_cost;
3625 u->pop_cost = p->pop_cost;
3628 u->move_rate = p->move_rate;
3629 for (i = 0; i < p->build_reqs_count; i++) {
3631 }
3634 u->hp = p->hp;
3635 u->firepower = p->firepower;
3638 u->convert_time = p->convert_time;
3639 u->fuel = p->fuel;
3640 u->flags = p->flags;
3641 u->roles = p->roles;
3642 u->happy_cost = p->happy_cost;
3644 u->upkeep[o] = p->upkeep[o];
3647 u->bombard_rate = p->bombard_rate;
3648 u->city_size = p->city_size;
3649 u->city_slots = p->city_slots;
3650 u->tp_defense = p->tp_defense;
3651 u->cargo = p->cargo;
3652 u->targets = p->targets;
3653 u->embarks = p->embarks;
3654 u->disembarks = p->disembarks;
3655 u->vlayer = p->vlayer;
3656
3657 if (p->veteran_levels == 0) {
3658 u->veteran = NULL;
3659 } else {
3661
3662 for (i = 0; i < p->veteran_levels; i++) {
3664 p->power_fact[i], p->move_bonus[i],
3665 p->base_raise_chance[i],
3666 p->work_raise_chance[i]);
3667 }
3668 }
3669
3671
3672 u->adv.worker = p->worker;
3673
3675}
3676
3677/************************************************************************/
3681{
3682 struct unit_type *u = utype_by_number(p->unit);
3683 struct combat_bonus *bonus;
3684
3685 fc_assert_ret_msg(NULL != u, "Bad unit_type %d.", p->unit);
3686
3687 bonus = malloc(sizeof(*bonus));
3688
3689 bonus->flag = p->flag;
3690 bonus->type = p->type;
3691 bonus->value = p->value;
3692 bonus->quiet = p->quiet;
3693
3695}
3696
3697/************************************************************************/
3701{
3702 const char *flagname;
3703 const char *helptxt;
3704
3705 fc_assert_ret_msg(p->id >= UTYF_USER_FLAG_1 && p->id <= UTYF_LAST_USER_FLAG, "Bad user flag %d.", p->id);
3706
3707 if (p->name[0] == '\0') {
3708 flagname = NULL;
3709 } else {
3710 flagname = p->name;
3711 }
3712
3713 if (p->helptxt[0] == '\0') {
3714 helptxt = NULL;
3715 } else {
3716 helptxt = p->helptxt;
3717 }
3718
3720}
3721
3722/************************************************************************/
3726 const struct packet_ruleset_unit_class_flag *p)
3727{
3728 const char *flagname;
3729 const char *helptxt;
3730
3732 "Bad user flag %d.", p->id);
3733
3734 if (p->name[0] == '\0') {
3735 flagname = NULL;
3736 } else {
3737 flagname = p->name;
3738 }
3739
3740 if (p->helptxt[0] == '\0') {
3741 helptxt = NULL;
3742 } else {
3743 helptxt = p->helptxt;
3744 }
3745
3747}
3748
3749/************************************************************************/
3757static int unpack_tech_req(const enum tech_req r_num,
3758 const int reqs_size,
3759 const struct requirement *reqs,
3760 struct advance *a,
3761 int i)
3762{
3763 if (i < reqs_size
3764 && reqs[i].source.kind == VUT_ADVANCE) {
3765 /* Extract the tech req so the old code can reason about it. */
3766
3767 /* This IS a traditional tech req... right? */
3768 fc_assert(reqs[i].present);
3770
3771 /* Put it in the advance structure. */
3772 a->require[r_num] = reqs[i].source.value.advance;
3773
3774 /* Move on in the requirement vector. */
3775 i++;
3776 } else {
3777 /* No tech req. */
3779 }
3780
3781 return i;
3782}
3783
3784/************************************************************************/
3788{
3789 int i;
3790 struct advance *a = advance_by_number(p->id);
3791
3792 fc_assert_ret_msg(NULL != a, "Bad advance %d.", p->id);
3793
3794 names_set(&a->name, NULL, p->name, p->rule_name);
3797
3798 i = 0;
3799
3801 if (p->tclass >= 0) {
3803 } else {
3804 a->tclass = NULL;
3805 }
3806
3807 /* The tech requirements req1 and req2 are send inside research_reqs
3808 * since they too are required to be fulfilled before the tech can be
3809 * researched. */
3810
3811 if (p->removed) {
3812 /* The Freeciv data structures currently records that a tech is removed
3813 * by setting req1 and req2 to "Never". */
3814 a->require[AR_ONE] = A_NEVER;
3815 a->require[AR_TWO] = A_NEVER;
3816 } else {
3817 /* Unpack req1 and req2 from the research_reqs requirement vector. */
3820 }
3821
3822 /* Any remaining requirements are a part of the research_reqs requirement
3823 * vector. */
3824 for (; i < p->research_reqs_count; i++) {
3826 }
3827
3828 /* The packet's research_reqs should contain req1, req2 and the
3829 * requirements of the tech's research_reqs. */
3830 fc_assert((a->research_reqs.size
3831 + ((a->require[AR_ONE]
3832 && (advance_number(a->require[AR_ONE]) != A_NONE)) ?
3833 1 : 0)
3834 + ((a->require[AR_TWO]
3835 && (advance_number(a->require[AR_TWO]) != A_NONE)) ?
3836 1 : 0))
3837 == p->research_reqs_count);
3838
3840
3841 a->flags = p->flags;
3842 a->cost = p->cost;
3843 a->num_reqs = p->num_reqs;
3845
3847}
3848
3849/************************************************************************/
3853{
3855
3856 fc_assert_ret_msg(NULL != ptclass, "Bad tech_class %d.", p->id);
3857
3858 names_set(&ptclass->name, NULL, p->name, p->rule_name);
3859 ptclass->cost_pct = p->cost_pct;
3860}
3861
3862/************************************************************************/
3866{
3867 const char *flagname;
3868 const char *helptxt;
3869
3870 fc_assert_ret_msg(p->id >= TECH_USER_1 && p->id <= TECH_USER_LAST, "Bad user flag %d.", p->id);
3871
3872 if (p->name[0] == '\0') {
3873 flagname = NULL;
3874 } else {
3875 flagname = p->name;
3876 }
3877
3878 if (p->helptxt[0] == '\0') {
3879 helptxt = NULL;
3880 } else {
3881 helptxt = p->helptxt;
3882 }
3883
3884 set_user_tech_flag_name(p->id, flagname, helptxt);
3885}
3886
3887/************************************************************************/
3891{
3892 int i;
3893 struct impr_type *b = improvement_by_number(p->id);
3894
3895 fc_assert_ret_msg(NULL != b, "Bad improvement %d.", p->id);
3896
3897 b->genus = p->genus;
3898 names_set(&b->name, NULL, p->name, p->rule_name);
3902 for (i = 0; i < p->reqs_count; i++) {
3904 }
3905 fc_assert(b->reqs.size == p->reqs_count);
3906 for (i = 0; i < p->obs_count; i++) {
3908 }
3909 fc_assert(b->obsolete_by.size == p->obs_count);
3910 b->build_cost = p->build_cost;
3911 b->upkeep = p->upkeep;
3912 b->sabotage = p->sabotage;
3913 b->flags = p->flags;
3918
3919#ifdef FREECIV_DEBUG
3920 if (p->id == improvement_count() - 1) {
3922 log_debug("Improvement: %s...", improvement_rule_name(bdbg));
3923 log_debug(" build_cost %3d", bdbg->build_cost);
3924 log_debug(" upkeep %2d", bdbg->upkeep);
3925 log_debug(" sabotage %3d", bdbg->sabotage);
3926 if (NULL != bdbg->helptext) {
3927 strvec_iterate(bdbg->helptext, text) {
3928 log_debug(" helptext %s", text);
3930 }
3932 }
3933#endif /* FREECIV_DEBUG */
3934
3936}
3937
3938/************************************************************************/
3942{
3943 const char *flagname;
3944 const char *helptxt;
3945
3947 "Bad user flag %d.", p->id);
3948
3949 if (p->name[0] == '\0') {
3950 flagname = NULL;
3951 } else {
3952 flagname = p->name;
3953 }
3954
3955 if (p->helptxt[0] == '\0') {
3956 helptxt = NULL;
3957 } else {
3958 helptxt = p->helptxt;
3959 }
3960
3961 set_user_impr_flag_name(p->id, flagname, helptxt);
3962}
3963
3964/************************************************************************/
3968{
3969 struct multiplier *pmul = multiplier_by_number(p->id);
3970 int j;
3971
3972 fc_assert_ret_msg(NULL != pmul, "Bad multiplier %d.", p->id);
3973
3974 pmul->start = p->start;
3975 pmul->stop = p->stop;
3976 pmul->step = p->step;
3977 pmul->def = p->def;
3978 pmul->offset = p->offset;
3979 pmul->factor = p->factor;
3980 pmul->minimum_turns = p->minimum_turns;
3981
3982 names_set(&pmul->name, NULL, p->name, p->rule_name);
3983
3984 for (j = 0; j < p->reqs_count; j++) {
3985 requirement_vector_append(&pmul->reqs, p->reqs[j]);
3986 }
3987 fc_assert(pmul->reqs.size == p->reqs_count);
3988
3990}
3991
3992/************************************************************************/
3996{
3997 int j;
3998 struct government *gov = government_by_number(p->id);
3999
4000 fc_assert_ret_msg(NULL != gov, "Bad government %d.", p->id);
4001
4002 gov->item_number = p->id;
4003
4004 for (j = 0; j < p->reqs_count; j++) {
4005 requirement_vector_append(&gov->reqs, p->reqs[j]);
4006 }
4007 fc_assert(gov->reqs.size == p->reqs_count);
4008
4009 names_set(&gov->name, NULL, p->name, p->rule_name);
4012 sz_strlcpy(gov->sound_str, p->sound_str);
4013 sz_strlcpy(gov->sound_alt, p->sound_alt);
4015
4017
4019}
4020
4021/************************************************************************/
4025 (const struct packet_ruleset_government_ruler_title *packet)
4026{
4027 struct government *gov = government_by_number(packet->gov);
4028
4029 fc_assert_ret_msg(NULL != gov, "Bad government %d.", packet->gov);
4030
4032 packet->male_title,
4033 packet->female_title);
4034}
4035
4036/************************************************************************/
4040{
4041 int j;
4042 struct terrain *pterrain = terrain_by_number(p->id);
4043
4044 fc_assert_ret_msg(NULL != pterrain, "Bad terrain %d.", p->id);
4045
4046 pterrain->tclass = p->tclass;
4047 pterrain->native_to = p->native_to;
4048 names_set(&pterrain->name, NULL, p->name, p->rule_name);
4049 sz_strlcpy(pterrain->graphic_str, p->graphic_str);
4050 sz_strlcpy(pterrain->graphic_alt, p->graphic_alt);
4051 sz_strlcpy(pterrain->graphic_alt2, p->graphic_alt2);
4052 pterrain->movement_cost = p->movement_cost;
4053 pterrain->defense_bonus = p->defense_bonus;
4054
4056 pterrain->output[o] = p->output[o];
4058
4059 if (pterrain->resources != NULL) {
4060 free(pterrain->resources);
4061 }
4062 pterrain->resources = fc_calloc(p->num_resources + 1,
4063 sizeof(*pterrain->resources));
4064 if (pterrain->resource_freq != NULL) {
4065 free(pterrain->resource_freq);
4066 }
4067 pterrain->resource_freq = fc_calloc(p->num_resources + 1,
4068 sizeof(*pterrain->resource_freq));
4069 for (j = 0; j < p->num_resources; j++) {
4070 pterrain->resources[j] = extra_by_number(p->resources[j]);
4071 if (!pterrain->resources[j]) {
4072 log_error("handle_ruleset_terrain() "
4073 "Mismatched resource %d for terrain \"%s\".",
4074 p->resources[j], terrain_rule_name(pterrain));
4075 }
4076 pterrain->resource_freq[j] = p->resource_freq[j];
4077 }
4078 pterrain->resources[p->num_resources] = NULL;
4079 pterrain->resource_freq[p->num_resources] = 0;
4080
4084
4085 pterrain->base_time = p->base_time;
4086 pterrain->road_time = p->road_time;
4088 pterrain->cultivate_time = p->cultivate_time;
4090 pterrain->plant_time = p->plant_time;
4092 pterrain->irrigation_time = p->irrigation_time;
4094 pterrain->mining_time = p->mining_time;
4095 if (p->animal < 0) {
4096 pterrain->animal = NULL;
4097 } else {
4098 pterrain->animal = utype_by_number(p->animal);
4099 }
4101 pterrain->transform_time = p->transform_time;
4102 pterrain->placing_time = p->placing_time;
4103 pterrain->pillage_time = p->pillage_time;
4104
4105 for (j = 0; j < p->extra_count; j++) {
4106 pterrain->extra_removal_times[j] = p->extra_removal_times[j];
4107 }
4108
4109 pterrain->flags = p->flags;
4110
4111 fc_assert_ret(pterrain->rgb == NULL);
4112 pterrain->rgb = rgbcolor_new(p->color_red, p->color_green, p->color_blue);
4113
4115
4117}
4118
4119/************************************************************************/
4123{
4124 const char *flagname;
4125 const char *helptxt;
4126
4127 fc_assert_ret_msg(p->id >= TER_USER_1 && p->id <= TER_USER_LAST, "Bad user flag %d.", p->id);
4128
4129 if (p->name[0] == '\0') {
4130 flagname = NULL;
4131 } else {
4132 flagname = p->name;
4133 }
4134
4135 if (p->helptxt[0] == '\0') {
4136 helptxt = NULL;
4137 } else {
4138 helptxt = p->helptxt;
4139 }
4140
4142}
4143
4144/************************************************************************/
4148{
4149 struct resource_type *presource;
4150
4151 if (p->id < 0 || p->id > MAX_EXTRA_TYPES) {
4152 log_error("Bad resource %d.", p->id);
4153 return;
4154 }
4155
4156 presource = resource_type_init(extra_by_number(p->id));
4157
4159 presource->output[o] = p->output[o];
4161}
4162
4163/************************************************************************/
4167{
4168 struct extra_type *pextra = extra_by_number(p->id);
4169 int i;
4170 bool cbase;
4171 bool croad;
4172 bool cres;
4173
4174 fc_assert_ret_msg(NULL != pextra, "Bad extra %d.", p->id);
4175
4176 names_set(&pextra->name, NULL, p->name, p->rule_name);
4177
4178 pextra->category = p->category;
4179
4180 pextra->causes = 0;
4181 for (i = 0; i < EC_COUNT; i++) {
4182 if (BV_ISSET(p->causes, i)) {
4183 pextra->causes |= (1 << i);
4184 }
4185 }
4186
4187 pextra->rmcauses = 0;
4188 for (i = 0; i < ERM_COUNT; i++) {
4189 if (BV_ISSET(p->rmcauses, i)) {
4190 pextra->rmcauses |= (1 << i);
4191 }
4192 }
4193
4194 if (pextra->causes == 0) {
4196 } else {
4197 for (i = 0; i < EC_COUNT; i++) {
4198 if (is_extra_caused_by(pextra, i)) {
4199 extra_to_caused_by_list(pextra, i);
4200 }
4201 }
4202 }
4203
4204 cbase = is_extra_caused_by(pextra, EC_BASE);
4205 croad = is_extra_caused_by(pextra, EC_ROAD);
4207 if (cbase) {
4208 /* Index is one less than size of list when this base is already added. */
4210 }
4211 if (croad) {
4212 /* Index is one less than size of list when this road is already added. */
4214 }
4215 if (!cbase && !croad && !cres) {
4218 }
4219
4220 for (i = 0; i < ERM_COUNT; i++) {
4221 if (is_extra_removed_by(pextra, i)) {
4222 extra_to_removed_by_list(pextra, i);
4223 }
4224 }
4225
4227 sz_strlcpy(pextra->act_gfx_alt, p->act_gfx_alt);
4229 sz_strlcpy(pextra->rmact_gfx, p->rmact_gfx);
4232 sz_strlcpy(pextra->graphic_str, p->graphic_str);
4233 sz_strlcpy(pextra->graphic_alt, p->graphic_alt);
4234
4235 for (i = 0; i < p->reqs_count; i++) {
4236 requirement_vector_append(&pextra->reqs, p->reqs[i]);
4237 }
4238 fc_assert(pextra->reqs.size == p->reqs_count);
4239
4240 for (i = 0; i < p->rmreqs_count; i++) {
4242 }
4243 fc_assert(pextra->rmreqs.size == p->rmreqs_count);
4244
4246 for (i = 0; i < p->appearance_reqs_count; i++) {
4248 }
4250
4252 for (i = 0; i < p->disappearance_reqs_count; i++) {
4254 }
4256
4257 pextra->visibility_req = p->visibility_req;
4258 pextra->buildable = p->buildable;
4259 pextra->generated = p->generated;
4260 pextra->build_time = p->build_time;
4262 pextra->removal_time = p->removal_time;
4264 pextra->infracost = p->infracost;
4265 pextra->defense_bonus = p->defense_bonus;
4266
4267 if (pextra->defense_bonus != 0) {
4268 if (extra_has_flag(pextra, EF_NATURAL_DEFENSE)) {
4270 } else {
4272 }
4273 }
4274
4276
4277 pextra->eus = p->eus;
4278 if (pextra->eus == EUS_HIDDEN) {
4280 }
4281
4282 pextra->native_to = p->native_to;
4283
4284 pextra->flags = p->flags;
4285 if (pextra->no_aggr_near_city >= 0) {
4287 }
4288 if (extra_has_flag(pextra, EF_CAUSE_ZOC)) {
4290 }
4291
4292 pextra->hidden_by = p->hidden_by;
4293 pextra->bridged_over = p->bridged_over;
4294 pextra->conflicts = p->conflicts;
4295
4297
4299}
4300
4301/************************************************************************/
4305{
4306 const char *flagname;
4307 const char *helptxt;
4308
4310 "Bad user flag %d.", p->id);
4311
4312 if (p->name[0] == '\0') {
4313 flagname = NULL;
4314 } else {
4315 flagname = p->name;
4316 }
4317
4318 if (p->helptxt[0] == '\0') {
4319 helptxt = NULL;
4320 } else {
4321 helptxt = p->helptxt;
4322 }
4323
4324 set_user_extra_flag_name(p->id, flagname, helptxt);
4325}
4326
4327/************************************************************************/
4331{
4332 struct base_type *pbase = base_by_number(p->id);
4333
4334 fc_assert_ret_msg(NULL != pbase, "Bad base %d.", p->id);
4335
4336 pbase->gui_type = p->gui_type;
4337 pbase->border_sq = p->border_sq;
4338 pbase->vision_main_sq = p->vision_main_sq;
4339 pbase->vision_invis_sq = p->vision_invis_sq;
4340 pbase->vision_subs_sq = p->vision_subs_sq;
4341
4345 }
4346}
4347
4348/************************************************************************/
4352{
4353 int i;
4354 struct road_type *proad = road_by_number(p->id);
4355
4356 fc_assert_ret_msg(NULL != proad, "Bad road %d.", p->id);
4357
4358 proad->gui_type = p->gui_type;
4359
4360 for (i = 0; i < p->first_reqs_count; i++) {
4361 requirement_vector_append(&proad->first_reqs, p->first_reqs[i]);
4362 }
4363 fc_assert(proad->first_reqs.size == p->first_reqs_count);
4364
4365 proad->move_cost = p->move_cost;
4366 proad->move_mode = p->move_mode;
4367
4369 proad->tile_incr_const[o] = p->tile_incr_const[o];
4370 proad->tile_incr[o] = p->tile_incr[o];
4371 proad->tile_bonus[o] = p->tile_bonus[o];
4373
4374 proad->compat = p->compat;
4375 proad->integrates = p->integrates;
4376 proad->flags = p->flags;
4377}
4378
4379/************************************************************************/
4383{
4384 struct goods_type *pgood = goods_by_number(p->id);
4385 int i;
4386
4387 fc_assert_ret_msg(NULL != pgood, "Bad goods %d.", p->id);
4388
4389 names_set(&pgood->name, NULL, p->name, p->rule_name);
4390
4391 for (i = 0; i < p->reqs_count; i++) {
4393 }
4394 fc_assert(pgood->reqs.size == p->reqs_count);
4395
4396 pgood->from_pct = p->from_pct;
4397 pgood->to_pct = p->to_pct;
4398 pgood->onetime_pct = p->onetime_pct;
4399 pgood->flags = p->flags;
4400
4401 PACKET_STRVEC_EXTRACT(pgood->helptext, p->helptext);
4402}
4403
4404/************************************************************************/
4408{
4409 struct action *act;
4410
4411 if (!action_id_exists(p->id)) {
4412 /* Action id out of range */
4413 log_error("handle_ruleset_action() the action id %d is out of range.",
4414 p->id);
4415
4416 return;
4417 }
4418
4419 act = action_by_number(p->id);
4420
4421 sz_strlcpy(act->ui_name, p->ui_name);
4422 act->quiet = p->quiet;
4423
4424 act->result = p->result;
4425 act->sub_results = p->sub_results;
4427
4428 act->actor_kind = p->act_kind;
4429 act->target_kind = p->tgt_kind;
4430 act->sub_target_kind = p->sub_tgt_kind;
4431
4432 act->min_distance = p->min_distance;
4433 act->max_distance = p->max_distance;
4434 act->blocked_by = p->blocked_by;
4435}
4436
4437/************************************************************************/
4440void
4442{
4443 struct action_enabler *enabler;
4444 int i;
4445
4447 /* Non existing action */
4448 log_error("handle_ruleset_action_enabler() the action %d "
4449 "doesn't exist.",
4450 p->enabled_action);
4451
4452 return;
4453 }
4454
4456
4457 enabler->action = p->enabled_action;
4458
4459 for (i = 0; i < p->actor_reqs_count; i++) {
4460 requirement_vector_append(&enabler->actor_reqs, p->actor_reqs[i]);
4461 }
4462 fc_assert(enabler->actor_reqs.size == p->actor_reqs_count);
4463
4464 for (i = 0; i < p->target_reqs_count; i++) {
4465 requirement_vector_append(&enabler->target_reqs, p->target_reqs[i]);
4466 }
4467 fc_assert(enabler->target_reqs.size == p->target_reqs_count);
4468
4470}
4471
4472/************************************************************************/
4476{
4478 int i;
4479
4481
4482 auto_perf->cause = p->cause;
4483
4484 for (i = 0; i < p->reqs_count; i++) {
4486 }
4487 fc_assert(auto_perf->reqs.size == p->reqs_count);
4488
4489 for (i = 0; i < p->alternatives_count; i++) {
4490 auto_perf->alternatives[i] = p->alternatives[i];
4491 }
4492}
4493
4494/************************************************************************/
4498{
4500 int i;
4501
4502 fc_assert_ret_msg(NULL != pdis, "Bad disaster %d.", p->id);
4503
4504 names_set(&pdis->name, NULL, p->name, p->rule_name);
4505
4506 for (i = 0; i < p->reqs_count; i++) {
4507 requirement_vector_append(&pdis->reqs, p->reqs[i]);
4508 }
4509 fc_assert(pdis->reqs.size == p->reqs_count);
4510
4511 pdis->frequency = p->frequency;
4512
4513 pdis->effects = p->effects;
4514}
4515
4516/************************************************************************/
4520{
4522
4523 fc_assert_ret_msg(NULL != pach, "Bad achievement %d.", p->id);
4524
4525 names_set(&pach->name, NULL, p->name, p->rule_name);
4526
4527 pach->type = p->type;
4528 pach->unique = p->unique;
4529 pach->value = p->value;
4530}
4531
4532/************************************************************************/
4536{
4538
4539 if (pset != NULL) {
4540 pset->trade_pct = p->trade_pct;
4541 pset->cancelling = p->cancelling;
4542 pset->bonus_type = p->bonus_type;
4543 }
4544}
4545
4546/************************************************************************/
4550 (const struct packet_ruleset_terrain_control *p)
4551{
4552 /* Since terrain_control is the same as packet_ruleset_terrain_control
4553 * we can just copy the data directly. */
4554 terrain_control = *p;
4555 /* terrain_control.move_fragments likely changed */
4557}
4558
4559/************************************************************************/
4563 (const struct packet_ruleset_nation_sets *packet)
4564{
4565 int i;
4566
4567 for (i = 0; i < packet->nsets; i++) {
4568 struct nation_set *pset =
4569 nation_set_new(packet->names[i], packet->rule_names[i],
4570 packet->descriptions[i]);
4571
4572 if (pset == NULL) {
4573 break;
4574 } else {
4576 }
4577 }
4578}
4579
4580/************************************************************************/
4584 (const struct packet_ruleset_nation_groups *packet)
4585{
4586 int i;
4587
4588 for (i = 0; i < packet->ngroups; i++) {
4589 struct nation_group *pgroup;
4590
4591 pgroup = nation_group_new(packet->groups[i]);
4592
4593 if (pgroup != NULL) {
4595 pgroup->hidden = packet->hidden[i];
4596 } else {
4597 break;
4598 }
4599 }
4600}
4601
4602/************************************************************************/
4606{
4607 struct nation_type *pnation = nation_by_number(packet->id);
4608 int i;
4609
4610 fc_assert_ret_msg(NULL != pnation, "Bad nation %d.", packet->id);
4611
4612 if (packet->translation_domain[0] != '\0') {
4613 size_t len = strlen(packet->translation_domain) + 1;
4614 pnation->translation_domain = fc_malloc(len);
4616 } else {
4617 pnation->translation_domain = NULL;
4618 }
4619 names_set(&pnation->adjective, pnation->translation_domain,
4620 packet->adjective, packet->rule_name);
4621 name_set(&pnation->noun_plural, pnation->translation_domain, packet->noun_plural);
4622 sz_strlcpy(pnation->flag_graphic_str, packet->graphic_str);
4623 sz_strlcpy(pnation->flag_graphic_alt, packet->graphic_alt);
4624 pnation->style = style_by_number(packet->style);
4625 for (i = 0; i < packet->leader_count; i++) {
4626 (void) nation_leader_new(pnation, packet->leader_name[i],
4627 packet->leader_is_male[i]);
4628 }
4629
4630 /* set later by PACKET_NATION_AVAILABILITY */
4631 pnation->client.is_pickable = FALSE;
4632 pnation->is_playable = packet->is_playable;
4633 pnation->barb_type = packet->barbarian_type;
4634
4635 if ('\0' != packet->legend[0]) {
4636 pnation->legend = fc_strdup(nation_legend_translation(pnation, packet->legend));
4637 } else {
4638 pnation->legend = fc_strdup("");
4639 }
4640
4641 for (i = 0; i < packet->nsets; i++) {
4642 struct nation_set *pset = nation_set_by_number(packet->sets[i]);
4643
4644 if (NULL != pset) {
4645 nation_set_list_append(pnation->sets, pset);
4646 } else {
4647 log_error("handle_ruleset_nation() \"%s\" have unknown set %d.",
4648 nation_rule_name(pnation), packet->sets[i]);
4649 }
4650 }
4651
4652 for (i = 0; i < packet->ngroups; i++) {
4654
4655 if (NULL != pgroup) {
4657 } else {
4658 log_error("handle_ruleset_nation() \"%s\" have unknown group %d.",
4659 nation_rule_name(pnation), packet->groups[i]);
4660 }
4661 }
4662
4663 /* init_government may be NULL */
4665 for (i = 0; i < MAX_NUM_TECH_LIST; i++) {
4666 if (i < packet->init_techs_count) {
4667 pnation->init_techs[i] = packet->init_techs[i];
4668 } else {
4669 pnation->init_techs[i] = A_LAST;
4670 }
4671 }
4672 for (i = 0; i < MAX_NUM_UNIT_LIST; i++) {
4673 if (i < packet->init_units_count) {
4674 pnation->init_units[i] = utype_by_number(packet->init_units[i]);
4675 } else {
4676 /* TODO: should init_units be initialized in common/nation.c? */
4677 pnation->init_units[i] = utype_by_number(U_LAST);
4678 }
4679 }
4680 for (i = 0; i < MAX_NUM_BUILDING_LIST; i++) {
4681 if (i < packet->init_buildings_count) {
4682 pnation->init_buildings[i] = packet->init_buildings[i];
4683 } else {
4684 pnation->init_buildings[i] = B_LAST;
4685 }
4686 }
4687
4689}
4690
4691/************************************************************************/
4695void handle_nation_availability(int ncount, const bool *is_pickable,
4696 bool nationset_change)
4697{
4698 int i;
4699
4700 fc_assert_action(ncount == nation_count(),
4701 ncount = MIN(ncount, nation_count()));
4702
4703 for (i = 0; i < ncount; i++) {
4704 nation_by_number(i)->client.is_pickable = is_pickable[i];
4705 }
4706
4707 races_update_pickable(nationset_change);
4708}
4709
4710/************************************************************************/
4714{
4715 struct nation_style *pstyle = style_by_number(p->id);
4716
4717 fc_assert_ret_msg(NULL != pstyle, "Bad style %d.", p->id);
4718
4719 names_set(&pstyle->name, NULL, p->name, p->rule_name);
4720}
4721
4722/************************************************************************/
4726{
4727 struct clause_info *info = clause_info_get(p->type);
4728 int i;
4729
4730 fc_assert_ret_msg(NULL != info, "Bad clause %d.", p->type);
4731
4732 info->enabled = p->enabled;
4733
4734 for (i = 0; i < p->giver_reqs_count; i++) {
4736 }
4737 fc_assert(info->giver_reqs.size == p->giver_reqs_count);
4738
4739 for (i = 0; i < p->receiver_reqs_count; i++) {
4741 }
4743}
4744
4745/************************************************************************/
4749{
4750 int id, j;
4751 struct citystyle *cs;
4752
4753 id = packet->style_id;
4755 "Bad citystyle %d.", id);
4756 cs = &city_styles[id];
4757
4758 for (j = 0; j < packet->reqs_count; j++) {
4759 requirement_vector_append(&cs->reqs, packet->reqs[j]);
4760 }
4761 fc_assert(cs->reqs.size == packet->reqs_count);
4762
4763 names_set(&cs->name, NULL, packet->name, packet->rule_name);
4764 sz_strlcpy(cs->graphic, packet->graphic);
4765 sz_strlcpy(cs->graphic_alt, packet->graphic_alt);
4766 sz_strlcpy(cs->citizens_graphic, packet->citizens_graphic);
4767
4769}
4770
4771/************************************************************************/
4775{
4776 int id, j;
4777 struct music_style *pmus;
4778
4779 id = packet->id;
4781 "Bad music_style %d.", id);
4782
4784
4785 for (j = 0; j < packet->reqs_count; j++) {
4786 requirement_vector_append(&pmus->reqs, packet->reqs[j]);
4787 }
4788 fc_assert(pmus->reqs.size == packet->reqs_count);
4789
4790 sz_strlcpy(pmus->music_peaceful, packet->music_peaceful);
4791 sz_strlcpy(pmus->music_combat, packet->music_combat);
4792}
4793
4794/************************************************************************/
4798{
4799 int i;
4800
4801 /* Must set num_specialist_types before iterating over them. */
4803
4804 fc_assert_ret(packet->veteran_levels > 0);
4805
4807 game.veteran->levels = packet->veteran_levels;
4808
4809 for (i = 0; i < MAX_NUM_TECH_LIST; i++) {
4810 if (i < packet->global_init_techs_count) {
4812 } else {
4814 }
4815 }
4816 for (i = 0; i < MAX_NUM_BUILDING_LIST; i++) {
4817 if (i < packet->global_init_buildings_count) {
4819 } else {
4821 }
4822 }
4823
4824 for (i = 0; i < packet->veteran_levels; i++) {
4826 packet->power_fact[i], packet->move_bonus[i],
4827 packet->base_raise_chance[i],
4828 packet->work_raise_chance[i]);
4829 }
4830
4833 packet->background_green,
4834 packet->background_blue);
4835
4837}
4838
4839/************************************************************************/
4843{
4844 int j;
4845 struct specialist *s = specialist_by_number(p->id);
4846
4847 fc_assert_ret_msg(NULL != s, "Bad specialist %d.", p->id);
4848
4849 names_set(&s->name, NULL, p->plural_name, p->rule_name);
4851
4854
4855 for (j = 0; j < p->reqs_count; j++) {
4857 }
4858 fc_assert(s->reqs.size == p->reqs_count);
4859
4861
4863}
4864
4865/************************************************************************/
4868void handle_city_name_suggestion_info(int unit_id, const char *name)
4869{
4870 struct unit *punit = player_unit_by_number(client_player(), unit_id);
4871
4872 if (!can_client_issue_orders()) {
4873 return;
4874 }
4875
4876 if (punit) {
4878 bool other_asking = FALSE;
4879
4881 if (other->client.asking_city_name) {
4883 }
4886
4887 if (!other_asking) {
4889 }
4890 } else {
4892 unit_id, tile_index(unit_tile(punit)),
4893 0, name);
4894 }
4895 }
4896}
4897
4898/************************************************************************/
4904void handle_unit_action_answer(int actor_id, int target_id, int cost,
4905 action_id action_type,
4906 int request_kind)
4907{
4908 struct city *pcity = game_city_by_number(target_id);
4909 struct unit *punit = game_unit_by_number(target_id);
4910 struct unit *pactor = player_unit_by_number(client_player(), actor_id);
4911 struct action *paction = action_by_number(action_type);
4912
4913 if (ACTION_NONE != action_type
4914 && !action_id_exists(action_type)) {
4915 /* Non existing action */
4916 log_error("handle_unit_action_answer() the action %d doesn't exist.",
4917 action_type);
4918
4919 if (request_kind == REQEST_PLAYER_INITIATED) {
4923 }
4924
4925 return;
4926 }
4927
4928 if (!pactor) {
4929 log_debug("Bad actor %d.", actor_id);
4930
4931 if (request_kind == REQEST_PLAYER_INITIATED) {
4934 }
4935
4936 return;
4937 }
4938
4939 switch ((enum gen_action)action_type) {
4941 if (punit && client.conn.playing
4943 if (request_kind == REQEST_PLAYER_INITIATED) {
4944 /* Focus on the unit so the player knows where it is */
4946
4948 } else {
4949 /* Not in use (yet). */
4950 log_error("Unimplemented: received background unit bribe cost.");
4951 }
4952 } else {
4953 log_debug("Bad target %d.", target_id);
4954 if (request_kind == REQEST_PLAYER_INITIATED) {
4958 }
4959 }
4960 break;
4963 if (pcity && client.conn.playing
4965 if (request_kind == REQEST_PLAYER_INITIATED) {
4966 /* Focus on the unit so the player knows where it is */
4968
4970 } else {
4971 /* Not in use (yet). */
4972 log_error("Unimplemented: received background city incite cost.");
4973 }
4974 } else {
4975 log_debug("Bad target %d.", target_id);
4976 if (request_kind == REQEST_PLAYER_INITIATED) {
4980 }
4981 }
4982 break;
4984 if (pcity && client.conn.playing
4986 /* TODO: The bundled clients will have to start showing the upgrade
4987 * price sent from the server before it can be allowed to rely on
4988 * things the player can't see. (Example: it becomes legal to upgrade
4989 * a unit in a foreign city.) */
4990
4991 /* Getting unit upgrade cost from the server is currently only used by
4992 * Freeciv-web. */
4993 log_error("Received upgrade unit price but can't forward it.");
4994 }
4995 break;
4996 case ACTION_NONE:
4997 log_debug("Server didn't respond to query.");
4998 if (request_kind == REQEST_PLAYER_INITIATED) {
5002 }
5003 break;
5004 default:
5005 log_error("handle_unit_action_answer() invalid action_type (%d).",
5006 action_type);
5007 if (request_kind == REQEST_PLAYER_INITIATED) {
5011 }
5012 break;
5013 };
5014}
5015
5016/************************************************************************/
5021{
5023
5025 if (action_prob_possible(act_probs[act_id])) {
5026 /* An attack. */
5027 if (attack_action == ACTION_NONE) {
5028 /* No previous attack action found. */
5029 attack_action = act_id;
5030 } else {
5031 /* More than one legal attack action found. */
5032 return ACTION_NONE;
5033 }
5034 }
5037 if (action_prob_possible(act_probs[act_id])) {
5038 /* An interesting non attack action has been found. */
5039 return ACTION_NONE;
5040 }
5042
5043 return attack_action;
5044}
5045
5046/**********************************************************************/
5051 const struct act_prob *act_probs,
5052 struct unit *target_unit,
5053 struct city *target_city,
5054 struct tile *target_tile)
5055{
5057
5059
5061
5062 if (auto_action != ACTION_NONE) {
5063 /* No interesting actions except a single attack action has been
5064 * found. The player wants it performed without questions. */
5065
5066 /* The order requests below doesn't send additional details. */
5068
5069 /* Give the order. */
5071 case ATK_TILE:
5072 case ATK_UNITS:
5073 case ATK_EXTRAS:
5074 if (target_tile != NULL) {
5077 0, "");
5078 }
5079 break;
5080 case ATK_CITY:
5081 if (target_city != NULL) {
5084 0, "");
5085 }
5086 break;
5087 case ATK_UNIT:
5088 if (target_unit != NULL) {
5091 0, "");
5092 }
5093 break;
5094 case ATK_SELF:
5097 0, "");
5098 break;
5099 case ATK_COUNT:
5101 break;
5102 }
5103
5104 /* Clean up. */
5106 } else {
5107 /* This should be done in the foreground */
5109 }
5110}
5111
5112/************************************************************************/
5119{
5121
5122 struct tile *target_tile = index_to_tile(&(wld.map), packet->target_tile_id);
5123 struct extra_type *target_extra = packet->target_extra_id == EXTRA_NONE ?
5127
5128 const struct act_prob *act_probs = packet->action_probabilities;
5129
5130 int request_kind = packet->request_kind;
5131 bool valid = FALSE;
5132
5133 /* The dead can't act */
5135 /* At least one action must be possible */
5136 action_iterate(act) {
5137 if (action_prob_possible(act_probs[act])) {
5138 valid = TRUE;
5139 break;
5140 }
5142 }
5143
5144 switch (request_kind) {
5146 if (valid) {
5147 /* The player can select an action and should be informed. */
5148
5149 /* Show the client specific action dialog */
5153 act_probs);
5154 } else {
5155 /* Nothing to do. */
5159 }
5160 break;
5162 /* This was a background action selection dialog refresh. */
5163
5164 if (actor_unit != NULL
5166 /* The situation may have changed. */
5170 act_probs);
5171 }
5172 break;
5174 if (actor_unit != NULL) {
5177 }
5178 break;
5179 default:
5180 log_warn("Unknown request_kind %d in reply", request_kind);
5181 break;
5182 }
5183}
5184
5185/************************************************************************/
5188void handle_city_sabotage_list(int actor_id, int city_id,
5189 bv_imprs improvements,
5190 action_id act_id,
5191 int request_kind)
5192{
5193 struct city *pcity = game_city_by_number(city_id);
5194 struct unit *pactor = player_unit_by_number(client_player(), actor_id);
5195 struct action *paction = action_by_number(act_id);
5196
5197 if (!pactor) {
5198 log_debug("Bad diplomat %d.", actor_id);
5199
5200 if (request_kind == REQEST_PLAYER_INITIATED) {
5203 }
5204
5205 return;
5206 }
5207
5208 if (!pcity) {
5209 log_debug("Bad city %d.", city_id);
5210
5211 if (request_kind == REQEST_PLAYER_INITIATED) {
5215 }
5216
5217 return;
5218 }
5219
5221 improvement_iterate(pimprove) {
5222 update_improvement_from_packet(pcity, pimprove,
5223 BV_ISSET(improvements,
5224 improvement_index(pimprove)));
5226
5227 if (request_kind == REQEST_PLAYER_INITIATED) {
5228 /* Focus on the unit so the player knows where it is */
5230
5232 } else {
5233 /* Not in use (yet). */
5234 log_error("Unimplemented: received background city building list.");
5235 }
5236 } else {
5237 log_debug("Can't issue orders");
5238 if (request_kind == REQEST_PLAYER_INITIATED) {
5241 }
5242 }
5243}
5244
5245/************************************************************************/
5254
5255/************************************************************************/
5259{
5260 if (client_has_player()
5261 && packet->player_id == player_number(client_player())) {
5262 if (packet->winner) {
5263 start_menu_music("music_victory", NULL);
5264 } else {
5265 start_menu_music("music_defeat", NULL);
5266 }
5267 }
5269}
5270
5271/************************************************************************/
5275 (const struct packet_player_attribute_chunk *packet)
5276{
5277 if (!client_has_player()) {
5278 return;
5279 }
5280
5282
5283 if (packet->offset + packet->chunk_length == packet->total_length) {
5284 /* We successful received the last chunk. The attribute block is
5285 now complete. */
5287 }
5288}
5289
5290/************************************************************************/
5294{
5296
5300 client.last_processed_request_id_seen);
5302 request_id_of_currently_handled_packet);
5303
5304 log_debug("start processing packet %d",
5306}
5307
5308/************************************************************************/
5327
5328/************************************************************************/
5332 int packet_type, int size)
5333{
5334 fc_assert(pc == &client.conn);
5335 log_debug("incoming packet={type=%d, size=%d}", packet_type, size);
5336}
5337
5338/************************************************************************/
5342 int packet_type, int size,
5343 int request_id)
5344{
5345 fc_assert(pc == &client.conn);
5346 log_debug("outgoing packet={type=%d, size=%d, request_id=%d}",
5348
5350}
5351
5352/************************************************************************/
5356{
5357 log_debug("handle_freeze_client");
5358
5360}
5361
5362/************************************************************************/
5366{
5367 log_debug("handle_thaw_client");
5368
5371}
5372
5373/************************************************************************/
5377{
5379}
5380
5381/************************************************************************/
5385{
5386 log_verbose("server shutdown");
5387}
5388
5389/************************************************************************/
5393{
5394 recv_ruleset_effect(packet);
5395}
5396
5397/************************************************************************/
5403void handle_edit_object_created(int tag, int id)
5404{
5406}
5407
5408/************************************************************************/
5412{
5413 struct tile *ptile = index_to_tile(&(wld.map), packet->id);
5414 bool changed = FALSE;
5415
5416 /* Check. */
5417 if (NULL == ptile) {
5418 log_error("%s(): invalid tile index %d.", __FUNCTION__, packet->id);
5419 return;
5420 }
5421
5422 /* Handle. */
5423 if (packet->removal) {
5424 changed = map_startpos_remove(ptile);
5425 } else {
5426 if (NULL != map_startpos_get(ptile)) {
5427 changed = FALSE;
5428 } else {
5429 map_startpos_new(ptile);
5430 changed = TRUE;
5431 }
5432 }
5433
5434 /* Notify. */
5435 if (changed && can_client_change_view()) {
5437 if (packet->removal) {
5439 packet->id, TRUE);
5440 } else {
5441 editgui_notify_object_created(packet->tag, packet->id);
5442 }
5443 }
5444}
5445
5446/************************************************************************/
5450 packet)
5451{
5452 struct tile *ptile = index_to_tile(&(wld.map), packet->id);
5453 struct startpos *psp;
5454
5455 /* Check. */
5456 if (NULL == ptile) {
5457 log_error("%s(): invalid tile index %d.", __FUNCTION__, packet->id);
5458 return;
5459 }
5460
5461 psp = map_startpos_get(ptile);
5462 if (NULL == psp) {
5463 log_error("%s(): no start position at (%d, %d)",
5464 __FUNCTION__, TILE_XY(ptile));
5465 return;
5466 }
5467
5468 /* Handle. */
5469 if (startpos_unpack(psp, packet) && can_client_change_view()) {
5470 /* Notify. */
5473 FALSE);
5474 }
5475}
5476
5477/************************************************************************/
5481{
5482 game.client.fog_of_war = enabled;
5483
5484 menus_update();
5485}
5486
5487/************************************************************************/
5490void handle_vote_remove(int vote_no)
5491{
5494}
5495
5496/************************************************************************/
5499void handle_vote_update(int vote_no, int yes, int no, int abstain,
5500 int num_voters)
5501{
5502 struct voteinfo *vi;
5503
5505
5507 "Got packet_vote_update for non-existent vote %d!",
5508 vote_no);
5509
5510 vi->yes = yes;
5511 vi->no = no;
5512 vi->abstain = abstain;
5513 vi->num_voters = num_voters;
5514
5516}
5517
5518/************************************************************************/
5521void handle_vote_new(const struct packet_vote_new *packet)
5522{
5524 "Got a packet_vote_new for already existing "
5525 "vote %d!", packet->vote_no);
5526
5528 packet->user,
5529 packet->desc,
5530 packet->percent_required,
5531 packet->flags);
5533}
5534
5535/************************************************************************/
5539{
5540 struct voteinfo *vi;
5541
5543
5545 "Got packet_vote_resolve for non-existent vote %d!",
5546 vote_no);
5547
5548 vi->resolved = TRUE;
5549 vi->passed = passed;
5550
5552}
5553
5554/************************************************************************/
5557void handle_play_music(const char *tag)
5558{
5559 play_single_track(tag);
5560}
5561
5562/************************************************************************/
5565void handle_popup_image(const char *tag)
5566{
5567 popup_image(tag);
5568}
5569
5570/************************************************************************/
5573void handle_diplomacy_init_meeting(int counterpart, int initiated_from)
5574{
5575 client_init_meeting(counterpart, initiated_from);
5576}
5577
5578/************************************************************************/
5581void handle_diplomacy_accept_treaty(int counterpart, bool I_accepted,
5582 bool other_accepted)
5583{
5584 client_recv_accept_treaty(counterpart, I_accepted, other_accepted);
5585}
5586
5587/************************************************************************/
5590void handle_diplomacy_cancel_meeting(int counterpart, int initiated_from)
5591{
5592 client_recv_cancel_meeting(counterpart, initiated_from);
5593}
5594
5595/************************************************************************/
5598void handle_diplomacy_create_clause(int counterpart, int giver,
5599 enum clause_type type, int value)
5600{
5601 client_recv_create_clause(counterpart, giver, type, value);
5602}
5603
5604/************************************************************************/
5607void handle_diplomacy_remove_clause(int counterpart, int giver,
5608 enum clause_type type, int value)
5609{
5610 client_recv_remove_clause(counterpart, giver, type, value);
5611}
5612
5613/**********************************************************************/
5618{
5621
5622 names_set(&curr->name, NULL, packet->name, packet->rule_name);
5623 curr->checkpoint = packet->checkpoint;
5624 curr->type = packet->behavior;
5625 curr->target = packet->type;
5626 curr->def = packet->def;
5627
5629 || curr->target != CTGT_CITY) {
5630 return;
5631 }
5632
5633 PACKET_STRVEC_EXTRACT(curr->helptext, packet->helptext);
5635}
5636
5637/**********************************************************************/
5641{
5642 int i;
5643 int counters_count;
5644 struct city *pcity = game_city_by_number(packet->city);
5645
5646 if (NULL == pcity) {
5647 return;
5648 }
5649
5651 if (counters_count != packet->count) {
5652 return;
5653 }
5654
5655 for (i = 0; i < counters_count; i++) {
5656 pcity->counter_values[i] = packet->counters[i];
5657 }
5658
5659 if (pcity->tile != NULL) {
5660 /* City's location known */
5662 }
5663
5665}
5666
5667/**********************************************************************/
5671{
5672 options_sync_reply(serial);
5673}
struct achievement * achievement_by_number(int id)
struct action_auto_perf * action_auto_perf_slot_number(const int num)
Definition actions.c:6421
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5821
void actions_rs_pre_san_gen(void)
Definition actions.c:1654
void action_enabler_add(struct action_enabler *enabler)
Definition actions.c:2282
struct action_enabler * action_enabler_new(void)
Definition actions.c:2236
bool action_id_exists(const action_id act_id)
Definition actions.c:1829
static struct action * action_by_number(action_id act_id)
Definition actions.h:635
#define action_array_iterate(_act_array_, _act_id_)
Definition actions.h:497
#define action_id_requires_details(act_id)
Definition actions.h:673
#define action_array_iterate_end
Definition actions.h:509
#define action_iterate_end
Definition actions.h:465
#define action_iterate(_act_)
Definition actions.h:461
#define action_id_get_target_kind(act_id)
Definition actions.h:652
#define ACTION_NONE
Definition actions.h:311
void agents_unit_changed(struct unit *punit)
Definition agents.c:511
void agents_city_remove(struct city *pcity)
Definition agents.c:640
void agents_thaw_hint(void)
Definition agents.c:440
void agents_tile_remove(struct tile *ptile)
Definition agents.c:667
void agents_city_new(struct city *pcity)
Definition agents.c:614
void agents_start_turn(void)
Definition agents.c:474
void agents_tile_changed(struct tile *ptile)
Definition agents.c:691
void agents_unit_new(struct unit *punit)
Definition agents.c:536
void agents_unit_remove(struct unit *punit)
Definition agents.c:562
void agents_processing_started(void)
Definition agents.c:413
void agents_tile_new(struct tile *ptile)
Definition agents.c:715
void agents_processing_finished(void)
Definition agents.c:422
void agents_new_turn(void)
Definition agents.c:483
void agents_city_changed(struct city *pcity)
Definition agents.c:588
void agents_game_joined(void)
Definition agents.c:449
void agents_freeze_hint(void)
Definition agents.c:431
void agents_before_new_turn(void)
Definition agents.c:466
void attribute_restore(void)
Definition attribute.c:355
void audio_restart(const char *soundset_name, const char *musicset_name)
Definition audio.c:376
void audio_play_sound(const char *const tag, const char *const alt_tag, const char *const alt_tag2)
Definition audio.c:528
void base_type_init(struct extra_type *pextra, int idx)
Definition base.c:117
struct extra_type * base_extra_get(const struct base_type *pbase)
Definition base.c:101
struct base_type * base_by_number(const Base_type_id id)
Definition base.c:76
bool territory_claiming_base(const struct base_type *pbase)
Definition base.c:158
void dbv_set(struct dbv *pdbv, int bit)
Definition bitvector.c:144
void dbv_clr(struct dbv *pdbv, int bit)
Definition bitvector.c:167
#define BV_SET_VAL(bv, bit, val)
Definition bitvector.h:91
#define BV_SET(bv, bit)
Definition bitvector.h:81
#define BV_ARE_EQUAL(vec1, vec2)
Definition bitvector.h:113
#define BV_ISSET(bv, bit)
Definition bitvector.h:78
#define BV_CLR(bv, bit)
Definition bitvector.h:86
bool has_capability(const char *cap, const char *capstr)
Definition capability.c:77
const char *const our_capability
Definition capstr.c:32
void output_window_append(const struct ft_color color, const char *featured_text)
void output_window_printf(const struct ft_color color, const char *format,...)
void citizens_nation_set(struct city *pcity, const struct player_slot *pslot, citizens count)
Definition citizens.c:145
citizens citizens_count(const struct city *pcity)
Definition citizens.c:162
void citizens_init(struct city *pcity)
Definition citizens.c:32
void city_map_radius_sq_set(struct city *pcity, int radius_sq)
Definition city.c:148
void city_name_set(struct city *pcity, const char *new_name)
Definition city.c:1145
void city_styles_alloc(int num)
Definition city.c:3396
const char * city_name_get(const struct city *pcity)
Definition city.c:1137
void city_production_caravan_shields_init(void)
Definition city.c:1778
void city_remove_improvement(struct city *pcity, const struct impr_type *pimprove)
Definition city.c:3371
void city_size_add(struct city *pcity, int add)
Definition city.c:1164
void free_city_map_index(void)
Definition city.c:609
bool city_unhappy(const struct city *pcity)
Definition city.c:1626
struct city * create_city_virtual(struct player *pplayer, struct tile *ptile, const char *name)
Definition city.c:3430
bool city_happy(const struct city *pcity)
Definition city.c:1614
void city_size_set(struct city *pcity, citizens size)
Definition city.c:1180
void city_add_improvement(struct city *pcity, const struct impr_type *pimprove)
Definition city.c:3357
int city_map_radius_sq_get(const struct city *pcity)
Definition city.c:137
void destroy_city_virtual(struct city *pcity)
Definition city.c:3516
void city_rally_point_receive(const struct packet_city_rally_point *packet, struct city *pcity)
Definition city.c:3641
static const struct city struct citystyle * city_styles
Definition city.c:84
#define city_list_iterate(citylist, pcity)
Definition city.h:508
#define city_tile(_pcity_)
Definition city.h:564
static citizens city_size_get(const struct city *pcity)
Definition city.h:569
#define city_tile_iterate_skip_free_worked(_nmap, _radius_sq, _city_tile, _tile, _index, _x, _y)
Definition city.h:214
@ CITIZEN_LAST
Definition city.h:272
@ CITIZEN_ANGRY
Definition city.h:271
@ CITIZEN_HAPPY
Definition city.h:268
@ CITIZEN_CONTENT
Definition city.h:269
@ CITIZEN_UNHAPPY
Definition city.h:270
#define output_type_iterate(output)
Definition city.h:845
#define city_owner(_pcity_)
Definition city.h:563
#define city_tile_iterate_skip_free_worked_end
Definition city.h:222
#define city_list_iterate_end
Definition city.h:510
#define I_NEVER
Definition city.h:247
@ FEELING_FINAL
Definition city.h:284
@ FEELING_LAST
Definition city.h:285
#define output_type_iterate_end
Definition city.h:851
void generate_citydlg_dimensions(void)
void popup_city_dialog(struct city *pcity)
void refresh_city_dialog(struct city *pcity)
void city_report_dialog_update_city(struct city *pcity)
void city_report_dialog_update(void)
char music_set_name[512]
void start_turn_change_wait(void)
bool client_is_global_observer(void)
void client_remove_cli_conn(struct connection *pconn)
bool client_is_observer(void)
void stop_turn_change_wait(void)
void set_server_busy(bool busy)
void user_ended_turn(void)
struct civclient client
bool auto_connect
enum client_states client_state(void)
void set_seconds_to_turndone(double seconds)
char sound_set_name[512]
bool can_client_issue_orders(void)
bool client_has_player(void)
void set_client_state(enum client_states newstate)
bool can_client_change_view(void)
#define client_player()
@ C_S_PREPARING
Definition client_main.h:46
@ C_S_RUNNING
Definition client_main.h:47
@ C_S_OVER
Definition client_main.h:48
enum known_type client_tile_get_known(const struct tile *ptile)
Definition climap.c:36
void create_event(struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Definition climisc.c:1092
void client_player_init(struct player *pplayer)
Definition climisc.c:1372
void client_remove_city(struct city *pcity)
Definition climisc.c:134
void client_player_maps_reset(void)
Definition climisc.c:1383
void client_remove_unit(struct unit *punit)
Definition climisc.c:72
void unit_focus_set_status(struct player *pplayer)
Definition climisc.c:1362
void handle_event(const char *featured_text, struct tile *ptile, enum event_type event, int turn, int phase, int conn_id)
Definition climisc.c:967
void client_recv_remove_clause(int counterpart, int giver, enum clause_type type, int value)
Definition clitreaty.c:131
void client_recv_create_clause(int counterpart, int giver, enum clause_type type, int value)
Definition clitreaty.c:105
void client_recv_accept_treaty(int counterpart, bool I_accepted, bool other_accepted)
Definition clitreaty.c:59
void client_recv_cancel_meeting(int counterpart, int initiated_from)
Definition clitreaty.c:83
void client_init_meeting(int counterpart, int initiated_from)
Definition clitreaty.c:33
static void city_changed(int city_id)
Definition cma_core.c:448
char * incite_cost
Definition comments.c:75
void send_client_wants_hack(const char *filename)
int get_next_request_id(int old_request_id)
Definition connection.c:530
void conn_set_capability(struct connection *pconn, const char *capability)
Definition connection.c:661
struct connection * conn_by_number(int id)
Definition connection.c:421
#define conn_list_iterate(connlist, pconn)
Definition connection.h:108
#define conn_list_iterate_end
Definition connection.h:110
void do_move_unit(struct unit *punit, struct unit *target_unit)
Definition control.c:2802
bool unit_is_in_focus(const struct unit *punit)
Definition control.c:388
void action_selection_no_longer_in_progress(const int old_actor_id)
Definition control.c:1051
struct unit * get_focus_unit_on_tile(const struct tile *ptile)
Definition control.c:396
void action_decision_request(struct unit *actor_unit)
Definition control.c:1110
void set_units_in_combat(struct unit *pattacker, struct unit *pdefender)
Definition control.c:1032
void clear_hover_state(void)
Definition control.c:328
void unit_focus_set(struct unit *punit)
Definition control.c:506
bool should_ask_server_for_actions(const struct unit *punit)
Definition control.c:339
struct unit_list * get_units_in_focus(void)
Definition control.c:177
void request_do_action(action_id action, int actor_id, int target_id, int sub_tgt, const char *name)
Definition control.c:1730
void unit_focus_urgent(struct unit *punit)
Definition control.c:207
void unit_change_battlegroup(struct unit *punit, int battlegroup)
Definition control.c:255
bool non_ai_unit_focus
Definition control.c:125
void action_decision_clear_want(const int old_actor_id)
Definition control.c:1080
int get_num_units_in_focus(void)
Definition control.c:185
void unit_register_battlegroup(struct unit *punit)
Definition control.c:275
void unit_focus_update(void)
Definition control.c:789
void auto_center_on_focus_unit(void)
Definition control.c:434
void request_new_unit_activity(struct unit *punit, enum unit_activity act)
Definition control.c:1929
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1092
int counters_get_city_counters_count(void)
Definition counters.c:74
struct counter * counter_by_id(int id)
Definition counters.c:82
void attach_city_counter(struct counter *counter)
Definition counters.c:94
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:56
popup_action_selection
Definition dialogs_g.h:55
struct unit * actor_unit
Definition dialogs_g.h:55
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id popup_bribe_dialog
Definition dialogs_g.h:73
const char * caption
Definition dialogs_g.h:37
const char const char * headline
Definition dialogs_g.h:38
popup_notify_dialog
Definition dialogs_g.h:37
struct unit struct city struct unit struct tile * target_tile
Definition dialogs_g.h:57
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
struct unit struct city * target_city
Definition dialogs_g.h:56
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
Definition dialogs_g.h:74
struct unit struct city struct unit struct tile struct extra_type * target_extra
Definition dialogs_g.h:57
struct clause_info * clause_info_get(enum clause_type type)
Definition diptreaty.c:276
struct disaster_type * disaster_by_number(Disaster_type_id id)
Definition disaster.c:87
editgui_notify_object_changed
Definition editgui_g.h:27
int int id
Definition editgui_g.h:28
bool editor_is_active(void)
Definition editor.c:347
void editor_ruleset_changed(void)
Definition editor.c:181
@ OBJTYPE_PLAYER
Definition editor.h:30
@ OBJTYPE_UNIT
Definition editor.h:28
@ OBJTYPE_STARTPOS
Definition editor.h:27
@ OBJTYPE_GAME
Definition editor.h:31
@ OBJTYPE_CITY
Definition editor.h:29
@ OBJTYPE_TILE
Definition editor.h:26
void recv_ruleset_effect(const struct packet_ruleset_effect *packet)
Definition effects.c:591
struct @21::@22 reqs
enum event_type event
Definition events.c:81
const char * get_event_tag(enum event_type event)
Definition events.c:276
struct player * extra_owner(const struct tile *ptile)
Definition extras.c:1114
void set_user_extra_flag_name(enum extra_flag_id id, const char *name, const char *helptxt)
Definition extras.c:933
struct extra_type_list * extra_type_list_of_zoccers(void)
Definition extras.c:267
bool extra_has_flag(const struct extra_type *pextra, enum extra_flag_id flag)
Definition extras.c:861
struct extra_type_list * extra_type_list_by_cause(enum extra_cause cause)
Definition extras.c:249
void extra_to_caused_by_list(struct extra_type *pextra, enum extra_cause cause)
Definition extras.c:312
struct extra_type * extra_by_number(int id)
Definition extras.c:183
struct extra_type_list * extra_type_list_of_terr_claimers(void)
Definition extras.c:275
bool is_extra_removed_by(const struct extra_type *pextra, enum extra_rmcause rmcause)
Definition extras.c:353
struct extra_type_list * extra_type_list_of_unit_hiders(void)
Definition extras.c:259
#define extra_type_iterate(_p)
Definition extras.h:315
static void extra_to_removed_by_list(struct extra_type *pextra, enum extra_rmcause rmcause)
Definition extras.h:214
#define extra_type_iterate_end
Definition extras.h:321
#define is_extra_caused_by(e, c)
Definition extras.h:203
#define extra_index(_e_)
Definition extras.h:183
#define EXTRA_NONE
Definition extras.h:85
#define EF_LAST_USER_FLAG
Definition extras.h:82
#define MAX_DISASTER_TYPES
Definition fc_types.h:52
#define MAX_GRANARY_INIS
Definition fc_types.h:72
#define MAX_NUM_BUILDING_LIST
Definition fc_types.h:46
int Tech_type_id
Definition fc_types.h:377
#define EC_NATURAL_DEFENSIVE
Definition fc_types.h:1116
#define EC_SPECIAL
Definition fc_types.h:1114
int action_id
Definition fc_types.h:389
#define SP_MAX
Definition fc_types.h:409
#define EC_NONE
Definition fc_types.h:1113
#define EC_NOT_AGGRESSIVE
Definition fc_types.h:1117
#define EC_DEFENSIVE
Definition fc_types.h:1115
#define IF_LAST_USER_FLAG
Definition fc_types.h:677
#define MAX_NUM_UNIT_LIST
Definition fc_types.h:45
#define MAX_EXTRA_TYPES
Definition fc_types.h:50
@ CTGT_CITY
Definition fc_types.h:126
#define MAX_ACHIEVEMENT_TYPES
Definition fc_types.h:53
#define MAX_NUM_TECH_LIST
Definition fc_types.h:44
@ O_SHIELD
Definition fc_types.h:101
@ O_FOOD
Definition fc_types.h:101
@ O_SCIENCE
Definition fc_types.h:101
@ O_GOLD
Definition fc_types.h:101
#define MAX_LEN_CITYNAME
Definition fc_types.h:67
#define MAX_COUNTERS
Definition fc_types.h:106
#define UCL_LAST
Definition fc_types.h:417
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:92
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_client
struct civ_game game
Definition game.c:62
void game_ruleset_init(void)
Definition game.c:512
bool is_player_phase(const struct player *pplayer, int phase)
Definition game.c:707
int current_turn_timeout(void)
Definition game.c:848
void game_ruleset_free(void)
Definition game.c:561
struct world wld
Definition game.c:63
struct unit * game_unit_by_number(int id)
Definition game.c:116
struct city * game_city_by_number(int id)
Definition game.c:107
void init_client_goto(void)
Definition goto.c:152
struct ruler_title * government_ruler_title_new(struct government *pgovern, const struct nation_type *pnation, const char *ruler_male_title, const char *ruler_female_title)
Definition government.c:325
struct government * government_by_number(const Government_type_id gov)
Definition government.c:103
struct government * government_of_player(const struct player *pplayer)
Definition government.c:114
void governments_alloc(int num)
Definition government.c:529
Government_type_id government_number(const struct government *pgovern)
Definition government.c:91
int action_selection_target_extra(void)
int action_selection_target_tile(void)
int action_selection_actor_unit(void)
void action_selection_close(void)
int action_selection_target_city(void)
void action_selection_refresh(struct unit *actor_unit, struct city *target_city, struct unit *target_unit, struct tile *target_tile, struct extra_type *target_extra, const struct act_prob *act_probs)
void popup_sabotage_dialog(struct unit *actor, struct city *pcity, const struct action *paction)
int action_selection_target_unit(void)
void popup_incite_dialog(struct unit *actor, struct city *pcity, int cost, const struct action *paction)
bool city_dialog_is_open(struct city *pcity)
Definition citydlg.c:587
void popdown_all_city_dialogs(void)
Definition citydlg.c:607
void refresh_unit_city_dialogs(struct unit *punit)
Definition citydlg.c:546
void server_connect(void)
Definition connectdlg.c:60
void close_connection_dialog(void)
Definition connectdlg.c:52
void races_update_pickable(bool nationset_change)
Definition dialogs.c:731
void show_tech_gained_dialog(Tech_type_id tech)
Definition dialogs.c:1524
void popdown_races_dialog(void)
Definition dialogs.c:1230
void popup_connect_msg(const char *headline, const char *message)
Definition dialogs.c:239
bool handmade_scenario_warning(void)
Definition dialogs.c:1573
void races_toggles_set_sensitive(void)
Definition dialogs.c:1245
void popup_combat_info(int attacker_unit_id, int defender_unit_id, int attacker_hp, int defender_hp, bool make_att_veteran, bool make_def_veteran)
Definition dialogs.c:1583
void popup_image(const char *tag)
Definition dialogs.c:1636
void editgui_notify_object_created(int tag, int id)
Definition editgui.c:1924
void editgui_refresh(void)
Definition editgui.c:1798
static GtkWidget * source
Definition gotodlg.c:58
enum gui_type get_gui_type(void)
Definition gui_main.c:2077
void update_infra_dialog(void)
Definition infradlg.c:138
void close_intel_dialog(struct player *p)
Definition inteldlg.c:223
void update_intel_dialog(struct player *p)
Definition inteldlg.c:462
void popup_newcity_dialog(struct unit *punit, const char *suggestname)
Definition mapctrl.c:197
void update_info_label(void)
Definition mapview.c:138
void start_turn(void)
Definition mapview.c:805
void update_unit_info_label(struct unit_list *punits)
Definition mapview.c:275
void update_city_descriptions(void)
Definition mapview.c:488
void update_start_page(void)
Definition pages.c:1675
void science_report_dialog_popup(bool raise)
Definition repodlgs.c:716
void endgame_report_dialog_start(const struct packet_endgame_report *packet)
Definition repodlgs.c:1983
GType type
Definition repodlgs.c:1313
void science_report_dialog_redraw(void)
Definition repodlgs.c:761
void popup_musicset_suggestion_dialog(void)
void popup_soundset_suggestion_dialog(void)
void refresh_spaceship_dialog(struct player *pplayer)
void popup_tileset_suggestion_dialog(void)
Definition tileset_dlg.c:58
void voteinfo_gui_update(void)
void conn_list_dialog_update(void)
void boot_help_texts(void)
Definition helpdata.c:768
void idex_register_unit(struct world *iworld, struct unit *punit)
Definition idex.c:82
void idex_unregister_city(struct world *iworld, struct city *pcity)
Definition idex.c:97
void idex_register_city(struct world *iworld, struct city *pcity)
Definition idex.c:67
struct impr_type * improvement_by_number(const Impr_type_id id)
const char * improvement_rule_name(const struct impr_type *pimprove)
bool is_improvement_visible(const struct impr_type *pimprove)
Impr_type_id improvement_index(const struct impr_type *pimprove)
void improvement_feature_cache_init(void)
Definition improvement.c:92
void set_user_impr_flag_name(enum impr_flag_id id, const char *name, const char *helptxt)
Impr_type_id improvement_count(void)
#define improvement_iterate_end
#define improvement_iterate(_p)
#define B_LAST
Definition improvement.h:42
const char * name
Definition inputfile.c:127
#define fc_assert_msg(condition, message,...)
Definition log.h:181
#define fc_assert_ret(condition)
Definition log.h:191
#define log_packet
Definition log.h:137
#define log_warn(message,...)
Definition log.h:105
#define log_verbose(message,...)
Definition log.h:109
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_ret_msg(condition, message,...)
Definition log.h:205
#define fc_assert_ret_val(condition, val)
Definition log.h:194
#define fc_assert_action(condition, action)
Definition log.h:187
#define log_debug(message,...)
Definition log.h:115
#define log_normal(message,...)
Definition log.h:107
@ LOG_NORMAL
Definition log.h:32
#define log_error(message,...)
Definition log.h:103
struct startpos * map_startpos_get(const struct tile *ptile)
Definition map.c:1883
int startpos_number(const struct startpos *psp)
Definition map.c:1633
void map_free(struct civ_map *fmap)
Definition map.c:530
int sq_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:641
struct startpos * map_startpos_new(struct tile *ptile)
Definition map.c:1866
void map_init_topology(struct civ_map *nmap)
Definition map.c:303
void main_map_allocate(void)
Definition map.c:519
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Definition map.c:456
bool map_startpos_remove(struct tile *ptile)
Definition map.c:1899
bool same_pos(const struct tile *tile1, const struct tile *tile2)
Definition map.c:940
bool startpos_unpack(struct startpos *psp, const struct packet_edit_startpos_full *packet)
Definition map.c:1726
struct terrain_misc terrain_control
Definition map.c:69
bool map_is_empty(void)
Definition map.c:149
#define whole_map_iterate(_map, _tile)
Definition map.h:545
#define whole_map_iterate_end
Definition map.h:554
void upgrade_canvas_clipboard(void)
void update_turn_done_button_state(void)
struct city * city_workers_display
void put_nuke_mushroom_pixmaps(struct tile *ptile)
void update_map_canvas_visible(void)
bool tile_visible_mapcanvas(struct tile *ptile)
enum topo_comp_lvl tileset_map_topo_compatible(int topology_id, struct tileset *tset, int *tset_topo)
void refresh_city_mapcanvas(struct city *pcity, struct tile *ptile, bool full_refresh, bool write_to_screen)
void mapdeco_init(void)
void center_tile_mapcanvas(const struct tile *ptile)
void link_marks_decrease_turn_counters(void)
void update_city_description(struct city *pcity)
const char * describe_topology(int topo)
void refresh_tile_mapcanvas(struct tile *ptile, bool full_refresh, bool write_to_screen)
void refresh_unit_mapcanvas(struct unit *punit, struct tile *ptile, bool full_refresh, bool write_to_screen)
void decrease_unit_hp_smooth(struct unit *punit0, int hp0, struct unit *punit1, int hp1)
@ TOPO_INCOMP_HARD
#define fc_calloc(n, esz)
Definition mem.h:38
#define FC_FREE(ptr)
Definition mem.h:41
#define fc_strdup(str)
Definition mem.h:43
#define fc_malloc(sz)
Definition mem.h:34
void menus_update(void)
void meswin_clear_older(int turn, int phase)
int utype_unknown_move_cost(const struct unit_type *utype)
Definition movement.c:105
void init_move_fragments(void)
Definition movement.c:959
Multiplier_type_id multiplier_count(void)
Definition multipliers.c:88
struct multiplier * multiplier_by_number(Multiplier_type_id id)
Definition multipliers.c:57
Multiplier_type_id multiplier_index(const struct multiplier *pmul)
Definition multipliers.c:80
#define multipliers_iterate(_mul_)
Definition multipliers.h:61
#define multipliers_iterate_end
Definition multipliers.h:67
void play_single_track(const char *const tag)
Definition music.c:116
void start_menu_music(const char *const tag, char *const alt_tag)
Definition music.c:98
void start_style_music(void)
Definition music.c:44
static void name_set(struct name_translation *ptrans, const char *domain, const char *vernacular_name)
static void names_set(struct name_translation *ptrans, const char *domain, const char *vernacular_name, const char *rule_name)
const char * nation_rule_name(const struct nation_type *pnation)
Definition nation.c:138
int nation_group_index(const struct nation_group *pgroup)
Definition nation.c:943
Nation_type_id nation_count(void)
Definition nation.c:507
struct nation_group * nation_group_new(const char *name)
Definition nation.c:960
struct nation_type * nation_of_unit(const struct unit *punit)
Definition nation.c:463
struct nation_set * nation_set_new(const char *set_name, const char *set_rule_name, const char *set_description)
Definition nation.c:716
struct nation_type * nation_by_number(const Nation_type_id nation)
Definition nation.c:475
int nation_set_index(const struct nation_set *pset)
Definition nation.c:699
struct nation_type * nation_of_city(const struct city *pcity)
Definition nation.c:454
struct nation_set * nation_set_by_number(int id)
Definition nation.c:762
struct nation_group * nation_group_by_number(int id)
Definition nation.c:1004
struct nation_leader * nation_leader_new(struct nation_type *pnation, const char *name, bool is_male)
Definition nation.c:239
void nations_alloc(int num)
Definition nation.c:622
const char * nation_legend_translation(const struct nation_type *pnation, const char *legend)
Definition nation.c:299
void resend_desired_settable_options(void)
Definition options.c:5768
const char * tileset_name_for_topology(int topology_id)
Definition options.c:6580
void options_sync_reply(int serial)
Definition options.c:6130
struct client_options gui_options
Definition options.c:72
void calculate_overview_dimensions(void)
void generic_handle_player_attribute_chunk(struct player *pplayer, const struct packet_player_attribute_chunk *chunk)
Definition packets.c:690
#define PACKET_STRVEC_EXTRACT(strvec, str)
Definition packets.h:191
#define REQEST_PLAYER_INITIATED
Definition packets.h:63
@ UNIT_INFO_CITY_PRESENT
Definition packets.h:69
@ UNIT_INFO_CITY_SUPPORTED
Definition packets.h:68
int dsend_packet_spaceship_place(struct connection *pc, enum spaceship_place_type type, int num)
int send_packet_conn_pong(struct connection *pc)
int dsend_packet_unit_get_actions(struct connection *pc, int actor_unit_id, int target_unit_id, int target_tile_id, int target_extra_id, int request_kind)
int dsend_packet_player_change_government(struct connection *pc, Government_type_id government)
int send_packet_client_info(struct connection *pc, const struct packet_client_info *packet)
packet_type
void handle_ruleset_game(const struct packet_ruleset_game *packet)
Definition packhand.c:4797
void handle_player_diplstate(const struct packet_player_diplstate *packet)
Definition packhand.c:2792
static action_id auto_attack_act(const struct act_prob *act_probs)
Definition packhand.c:5020
void handle_ruleset_nation_sets(const struct packet_ruleset_nation_sets *packet)
Definition packhand.c:4563
void handle_ruleset_nation(const struct packet_ruleset_nation *packet)
Definition packhand.c:4605
void handle_city_name_suggestion_info(int unit_id, const char *name)
Definition packhand.c:4868
void handle_sync_serial_reply(int serial)
Definition packhand.c:5670
static struct unit * unpackage_short_unit(const struct packet_unit_short_info *packet)
Definition packhand.c:363
void handle_nuke_tile_info(int tile)
Definition packhand.c:545
void handle_unknown_research(int id)
Definition packhand.c:2762
const action_id auto_attack_blockers[]
Definition packhand.c:162
void handle_ruleset_government_ruler_title(const struct packet_ruleset_government_ruler_title *packet)
Definition packhand.c:4025
void handle_city_info(const struct packet_city_info *packet)
Definition packhand.c:650
void handle_end_turn(void)
Definition packhand.c:1498
static struct unit * unpackage_unit(const struct packet_unit_info *packet)
Definition packhand.c:264
char * caption
Definition packhand.c:129
enum event_type event
Definition packhand.c:128
void handle_conn_info(const struct packet_conn_info *pinfo)
Definition packhand.c:2893
void handle_vote_remove(int vote_no)
Definition packhand.c:5490
void handle_investigate_finished(const struct packet_investigate_finished *packet)
Definition packhand.c:2153
void handle_page_msg_part(const char *lines)
Definition packhand.c:1628
void handle_unit_combat_info(const struct packet_unit_combat_info *packet)
Definition packhand.c:568
void handle_ruleset_style(const struct packet_ruleset_style *p)
Definition packhand.c:4713
void handle_unit_remove(int unit_id)
Definition packhand.c:491
void handle_vote_update(int vote_no, int yes, int no, int abstain, int num_voters)
Definition packhand.c:5499
static int last_turn
Definition packhand.c:137
void handle_ruleset_multiplier(const struct packet_ruleset_multiplier *p)
Definition packhand.c:3967
void handle_player_info(const struct packet_player_info *pinfo)
Definition packhand.c:2441
void handle_ruleset_extra(const struct packet_ruleset_extra *p)
Definition packhand.c:4166
void handle_ruleset_action_auto(const struct packet_ruleset_action_auto *p)
Definition packhand.c:4475
void handle_map_info(const struct packet_map_info *packet)
Definition packhand.c:2231
void handle_ruleset_unit_bonus(const struct packet_ruleset_unit_bonus *p)
Definition packhand.c:3680
void handle_start_phase(int phase)
Definition packhand.c:1425
void start_revolution(void)
Definition packhand.c:2385
void handle_timeout_info(float seconds_to_phasedone, float last_turn_change_time)
Definition packhand.c:2355
void handle_ruleset_terrain_control(const struct packet_ruleset_terrain_control *p)
Definition packhand.c:4550
static struct @229 page_msg_report
const action_id auto_attack_actions[]
Definition packhand.c:145
void handle_play_music(const char *tag)
Definition packhand.c:5557
static struct @228 invisible
void handle_investigate_started(const struct packet_investigate_started *packet)
Definition packhand.c:2129
void handle_edit_object_created(int tag, int id)
Definition packhand.c:5403
int parts
Definition packhand.c:132
void handle_conn_ping(void)
Definition packhand.c:5376
void handle_ruleset_tech_class(const struct packet_ruleset_tech_class *p)
Definition packhand.c:3852
void handle_diplomacy_init_meeting(int counterpart, int initiated_from)
Definition packhand.c:5573
void handle_ruleset_control(const struct packet_ruleset_control *packet)
Definition packhand.c:3411
void handle_end_phase(void)
Definition packhand.c:1414
void handle_ruleset_counter(const struct packet_ruleset_counter *packet)
Definition packhand.c:5617
void handle_server_info(const char *version_label, int major_version, int minor_version, int patch_version, int emerg_version)
Definition packhand.c:1581
void handle_ruleset_nation_groups(const struct packet_ruleset_nation_groups *packet)
Definition packhand.c:4584
void handle_ruleset_effect(const struct packet_ruleset_effect *packet)
Definition packhand.c:5392
void handle_new_year(int year, int fragments, int turn)
Definition packhand.c:1365
char * headline
Definition packhand.c:130
void handle_research_info(const struct packet_research_info *packet)
Definition packhand.c:2678
void handle_ruleset_goods(const struct packet_ruleset_goods *p)
Definition packhand.c:4382
void handle_unit_info(const struct packet_unit_info *packet)
Definition packhand.c:1654
void handle_ruleset_city(const struct packet_ruleset_city *packet)
Definition packhand.c:4748
void handle_ruleset_unit_class(const struct packet_ruleset_unit_class *p)
Definition packhand.c:3589
void handle_ruleset_government(const struct packet_ruleset_government *p)
Definition packhand.c:3995
void handle_ruleset_terrain_flag(const struct packet_ruleset_terrain_flag *p)
Definition packhand.c:4122
void handle_connect_msg(const char *message)
Definition packhand.c:1572
#define REQEST_BACKGROUND_REFRESH
Definition packhand.c:140
void handle_rulesets_ready(void)
Definition packhand.c:3535
void handle_tile_info(const struct packet_tile_info *packet)
Definition packhand.c:3123
void handle_ruleset_action(const struct packet_ruleset_action *p)
Definition packhand.c:4407
static void action_decision_handle(struct unit *punit)
Definition packhand.c:1670
void handle_achievement_info(int id, bool gained, bool first)
Definition packhand.c:3022
void handle_scenario_description(const char *description)
Definition packhand.c:3399
void play_sound_for_event(enum event_type type)
Definition packhand.c:1525
void handle_edit_startpos(const struct packet_edit_startpos *packet)
Definition packhand.c:5411
void handle_processing_finished(void)
Definition packhand.c:5311
static int unpack_tech_req(const enum tech_req r_num, const int reqs_size, const struct requirement *reqs, struct advance *a, int i)
Definition packhand.c:3757
void handle_diplomacy_cancel_meeting(int counterpart, int initiated_from)
Definition packhand.c:5590
void handle_city_short_info(const struct packet_city_short_info *packet)
Definition packhand.c:1163
void handle_edit_fogofwar_state(bool enabled)
Definition packhand.c:5480
void handle_popup_image(const char *tag)
Definition packhand.c:5565
void handle_diplomacy_create_clause(int counterpart, int giver, enum clause_type type, int value)
Definition packhand.c:5598
void handle_endgame_player(const struct packet_endgame_player *packet)
Definition packhand.c:5258
void handle_ruleset_resource(const struct packet_ruleset_resource *p)
Definition packhand.c:4147
void handle_unit_action_answer(int actor_id, int target_id, int cost, action_id action_type, int request_kind)
Definition packhand.c:4904
void handle_ruleset_tech(const struct packet_ruleset_tech *p)
Definition packhand.c:3787
void handle_team_name_info(int team_id, const char *team_name)
Definition packhand.c:553
void handle_thaw_client(void)
Definition packhand.c:5365
void handle_calendar_info(const struct packet_calendar_info *pcalendar)
Definition packhand.c:2347
void packhand_free(void)
Definition packhand.c:218
void set_government_choice(struct government *government)
Definition packhand.c:2372
void handle_city_rally_point(const struct packet_city_rally_point *packet)
Definition packhand.c:1012
void handle_ruleset_disaster(const struct packet_ruleset_disaster *p)
Definition packhand.c:4497
static bool handle_unit_packet_common(struct unit *packet_unit)
Definition packhand.c:1708
void handle_ruleset_unit_class_flag(const struct packet_ruleset_unit_class_flag *p)
Definition packhand.c:3725
void handle_server_join_reply(bool you_can_join, const char *message, const char *capability, const char *challenge_file, int conn_id)
Definition packhand.c:400
void handle_ruleset_summary(const struct packet_ruleset_summary *packet)
Definition packhand.c:3507
void handle_set_topology(int topology_id, int wrap_id)
Definition packhand.c:2208
void handle_ruleset_impr_flag(const struct packet_ruleset_impr_flag *p)
Definition packhand.c:3941
void handle_page_msg(const char *caption, const char *headline, enum event_type event, int len, int parts)
Definition packhand.c:1597
void handle_city_update_counters(const struct packet_city_update_counters *packet)
Definition packhand.c:5640
void handle_edit_startpos_full(const struct packet_edit_startpos_full *packet)
Definition packhand.c:5449
void handle_conn_ping_info(int connections, const int *conn_id, const float *ping_time)
Definition packhand.c:2999
void handle_diplomacy_remove_clause(int counterpart, int giver, enum clause_type type, int value)
Definition packhand.c:5607
static bool spaceship_autoplace(struct player *pplayer, struct player_spaceship *ship)
Definition packhand.c:3059
void handle_player_remove(int playerno)
Definition packhand.c:2396
void handle_processing_started(void)
Definition packhand.c:5293
void handle_begin_turn(void)
Definition packhand.c:1484
void handle_endgame_report(const struct packet_endgame_report *packet)
Definition packhand.c:5249
void handle_early_chat_msg(const struct packet_early_chat_msg *packet)
Definition packhand.c:1558
void handle_ruleset_clause(const struct packet_ruleset_clause *p)
Definition packhand.c:4725
void handle_ruleset_road(const struct packet_ruleset_road *p)
Definition packhand.c:4351
void handle_unit_actions(const struct packet_unit_actions *packet)
Definition packhand.c:5118
void handle_ruleset_music(const struct packet_ruleset_music *packet)
Definition packhand.c:4774
void handle_ruleset_base(const struct packet_ruleset_base *p)
Definition packhand.c:4330
void notify_about_incoming_packet(struct connection *pc, int packet_type, int size)
Definition packhand.c:5331
void handle_freeze_client(void)
Definition packhand.c:5355
void handle_city_remove(int city_id)
Definition packhand.c:468
void handle_chat_msg(const struct packet_chat_msg *packet)
Definition packhand.c:1538
static void city_packet_common(struct city *pcity, struct tile *pcenter, struct player *powner, struct tile_list *worked_tiles, bool is_new, bool popup, bool investigate)
Definition packhand.c:1026
void handle_trade_route_info(const struct packet_trade_route_info *packet)
Definition packhand.c:1128
void handle_player_attribute_chunk(const struct packet_player_attribute_chunk *packet)
Definition packhand.c:5275
void handle_vote_new(const struct packet_vote_new *packet)
Definition packhand.c:5521
static void packhand_init(void)
Definition packhand.c:239
void handle_scenario_info(const struct packet_scenario_info *packet)
Definition packhand.c:3378
void handle_ruleset_extra_flag(const struct packet_ruleset_extra_flag *p)
Definition packhand.c:4304
char * lines
Definition packhand.c:131
void notify_about_outgoing_packet(struct connection *pc, int packet_type, int size, int request_id)
Definition packhand.c:5341
#define VALIDATE(_count, _maximum, _string)
const char forced_tileset_name[]
struct city_list * cities
Definition packhand.c:119
void handle_ruleset_tech_flag(const struct packet_ruleset_tech_flag *p)
Definition packhand.c:3865
void handle_nation_availability(int ncount, const bool *is_pickable, bool nationset_change)
Definition packhand.c:4695
void handle_spaceship_info(const struct packet_spaceship_info *p)
Definition packhand.c:3078
void handle_ruleset_specialist(const struct packet_ruleset_specialist *p)
Definition packhand.c:4842
void handle_unit_short_info(const struct packet_unit_short_info *packet)
Definition packhand.c:2160
void handle_diplomacy_accept_treaty(int counterpart, bool I_accepted, bool other_accepted)
Definition packhand.c:5581
void handle_ruleset_unit_flag(const struct packet_ruleset_unit_flag *p)
Definition packhand.c:3700
void handle_city_nationalities(const struct packet_city_nationalities *packet)
Definition packhand.c:992
void handle_server_shutdown(void)
Definition packhand.c:5384
void handle_ruleset_building(const struct packet_ruleset_building *p)
Definition packhand.c:3890
static bool update_improvement_from_packet(struct city *pcity, struct impr_type *pimprove, bool have_impr)
Definition packhand.c:628
void handle_ruleset_unit(const struct packet_ruleset_unit *p)
Definition packhand.c:3607
void handle_ruleset_terrain(const struct packet_ruleset_terrain *p)
Definition packhand.c:4039
static void action_decision_maybe_auto(struct unit *actor_unit, const struct act_prob *act_probs, struct unit *target_unit, struct city *target_city, struct tile *target_tile)
Definition packhand.c:5050
#define REQEST_BACKGROUND_FAST_AUTO_ATTACK
Definition packhand.c:142
void handle_city_sabotage_list(int actor_id, int city_id, bv_imprs improvements, action_id act_id, int request_kind)
Definition packhand.c:5188
void handle_ruleset_action_enabler(const struct packet_ruleset_action_enabler *p)
Definition packhand.c:4441
void handle_ruleset_achievement(const struct packet_ruleset_achievement *p)
Definition packhand.c:4519
void handle_game_info(const struct packet_game_info *pinfo)
Definition packhand.c:2271
struct player * placeholder
Definition packhand.c:120
void handle_vote_resolve(int vote_no, bool passed)
Definition packhand.c:5538
void handle_worker_task(const struct packet_worker_task *packet)
Definition packhand.c:1308
void handle_ruleset_description_part(const struct packet_ruleset_description_part *packet)
Definition packhand.c:3525
void handle_ruleset_trade(const struct packet_ruleset_trade *p)
Definition packhand.c:4535
int len
Definition packhand.c:127
void set_client_page(enum client_pages page)
enum client_pages get_client_page(void)
bool player_slot_is_used(const struct player_slot *pslot)
Definition player.c:448
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
Definition player.c:1229
struct player * player_new(struct player_slot *pslot)
Definition player.c:493
struct player * player_by_number(const int player_id)
Definition player.c:849
int player_count(void)
Definition player.c:817
struct player_slot * player_slot_by_number(int player_id)
Definition player.c:463
int player_number(const struct player *pplayer)
Definition player.c:837
const char * player_name(const struct player *pplayer)
Definition player.c:895
void player_set_color(struct player *pplayer, const struct rgbcolor *prgbcolor)
Definition player.c:648
int player_index(const struct player *pplayer)
Definition player.c:829
bool player_set_nation(struct player *pplayer, struct nation_type *pnation)
Definition player.c:861
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Definition player.c:324
bool can_player_see_units_in_city(const struct player *pplayer, const struct city *pcity)
Definition player.c:1133
struct player * player_slot_get_player(const struct player_slot *pslot)
Definition player.c:437
bool can_player_see_city_internals(const struct player *pplayer, const struct city *pcity)
Definition player.c:1149
void player_destroy(struct player *pplayer)
Definition player.c:756
#define players_iterate_end
Definition player.h:537
#define players_iterate(_pplayer)
Definition player.h:532
#define ANON_USER_NAME
Definition player.h:48
#define is_ai(plr)
Definition player.h:230
#define ANON_PLAYER_NAME
Definition player.h:43
#define is_human(plr)
Definition player.h:229
void players_dialog_update(void)
#define fc_rand(_size)
Definition rand.h:56
void multipliers_dialog_update(void)
const struct packet_endgame_player *packet void science_report_dialog_update(void)
void economy_report_dialog_update(void)
void units_report_dialog_update(void)
endgame_report_dialog_player
Definition repodlgs_g.h:33
struct universal universal_by_number(const enum universals_n kind, const int value)
bool are_universals_equal(const struct universal *psource1, const struct universal *psource2)
enum tech_state research_invention_set(struct research *presearch, Tech_type_id tech, enum tech_state value)
Definition research.c:637
struct research * research_by_number(int number)
Definition research.c:118
struct research * research_get(const struct player *pplayer)
Definition research.c:128
void research_update(struct research *presearch)
Definition research.c:501
#define research_players_iterate(_presearch, _pplayer)
Definition research.h:166
#define research_players_iterate_end
Definition research.h:170
void rgbcolor_destroy(struct rgbcolor *prgbcolor)
Definition rgbcolor.c:74
struct rgbcolor * rgbcolor_new(int r, int g, int b)
Definition rgbcolor.c:34
void road_integrators_cache_init(void)
Definition road.c:111
struct road_type * road_by_number(Road_type_id id)
Definition road.c:58
void road_type_init(struct extra_type *pextra, int idx)
Definition road.c:93
void script_client_signal_emit(const char *signal_name,...)
static struct connection connections[MAX_NUM_CONNECTIONS]
Definition sernet.c:94
#define ARRAY_SIZE(x)
Definition shared.h:85
#define MIN(x, y)
Definition shared.h:55
#define MAX(x, y)
Definition shared.h:54
bool next_spaceship_component(struct player *pplayer, struct player_spaceship *ship, struct spaceship_component *fill)
Definition spaceship.c:130
struct specialist * specialist_by_number(const Specialist_type_id id)
Definition specialist.c:100
#define specialist_type_iterate_end
Definition specialist.h:79
#define specialist_type_iterate(sp)
Definition specialist.h:73
#define DEFAULT_SPECIALIST
Definition specialist.h:43
size_t size
Definition specvec.h:72
#define strvec_iterate(psv, str)
#define strvec_iterate_end
struct player * first
bool actor_consuming_always
Definition actions.h:395
int max_distance
Definition actions.h:378
bool quiet
Definition actions.h:385
enum action_sub_target_kind sub_target_kind
Definition actions.h:370
enum action_result result
Definition actions.h:365
char ui_name[MAX_LEN_NAME]
Definition actions.h:381
bv_action_sub_results sub_results
Definition actions.h:366
enum action_actor_kind actor_kind
Definition actions.h:368
bv_actions blocked_by
Definition actions.h:389
enum action_target_kind target_kind
Definition actions.h:369
int min_distance
Definition actions.h:378
struct requirement_vector research_reqs
Definition tech.h:137
struct tech_class * tclass
Definition tech.h:130
double cost
Definition tech.h:150
struct advance * require[AR_SIZE]
Definition tech.h:132
struct name_translation name
Definition tech.h:126
struct strvec * helptext
Definition tech.h:140
bv_tech_flags flags
Definition tech.h:139
int num_reqs
Definition tech.h:156
char graphic_str[MAX_LEN_NAME]
Definition tech.h:128
char graphic_alt[MAX_LEN_NAME]
Definition tech.h:129
int turn
Definition city.h:246
Definition city.h:320
struct worker_task_list * task_reqs
Definition city.h:412
int turn_last_built
Definition city.h:387
int surplus[O_LAST]
Definition city.h:355
enum city_wl_cancel_behavior wlcb
Definition city.h:404
int food_stock
Definition city.h:367
struct built_status built[B_LAST]
Definition city.h:394
struct player * original
Definition city.h:324
int history
Definition city.h:410
int * counter_values
Definition city.h:408
int pollution
Definition city.h:369
bool did_sell
Definition city.h:380
int id
Definition city.h:326
int last_turns_shield_surplus
Definition city.h:392
enum capital_type capital
Definition city.h:328
int disbanded_shields
Definition city.h:391
int waste[O_LAST]
Definition city.h:356
struct unit_list * info_units_present
Definition city.h:474
bv_city_options city_options
Definition city.h:403
int city_radius_sq
Definition city.h:375
bool was_happy
Definition city.h:381
struct player * owner
Definition city.h:323
enum city_acquire_type acquire_t
Definition city.h:329
int turn_founded
Definition city.h:386
int airlift
Definition city.h:378
int citizen_base[O_LAST]
Definition city.h:359
int caravan_shields
Definition city.h:390
bool did_buy
Definition city.h:379
struct unit_list * info_units_supported
Definition city.h:473
char * name
Definition city.h:321
struct trade_route_list * routes
Definition city.h:344
int anarchy
Definition city.h:384
bool occupied
Definition city.h:460
int usage[O_LAST]
Definition city.h:360
struct worklist worklist
Definition city.h:401
struct universal production
Definition city.h:396
int walls
Definition city.h:461
bool happy
Definition city.h:462
struct unit_list * collecting_info_units_supported
Definition city.h:477
int steal
Definition city.h:414
int unhappy_penalty[O_LAST]
Definition city.h:357
unsigned char first_citizen_index
Definition city.h:483
int before_change_shields
Definition city.h:389
int culture
Definition city.h:465
int style
Definition city.h:327
bool had_famine
Definition city.h:382
struct unit_list * collecting_info_units_present
Definition city.h:478
int buy_cost
Definition city.h:466
citizens feel[CITIZEN_LAST][FEELING_LAST]
Definition city.h:333
citizens specialists[SP_MAX]
Definition city.h:336
struct tile * tile
Definition city.h:322
int shield_stock
Definition city.h:368
int prod[O_LAST]
Definition city.h:358
int city_image
Definition city.h:464
struct universal changed_from
Definition city.h:399
bool unhappy
Definition city.h:463
struct unit_list * units_supported
Definition city.h:406
int illness_trade
Definition city.h:370
struct city::@17::@20 client
int rapture
Definition city.h:385
bool fog_of_war
Definition game.h:121
struct rgbcolor * plr_bg_color
Definition game.h:103
struct packet_scenario_description scenario_desc
Definition game.h:88
struct packet_ruleset_control control
Definition game.h:83
char * ruleset_summary
Definition game.h:84
struct conn_list * est_connections
Definition game.h:97
int global_init_techs[MAX_NUM_TECH_LIST]
Definition game.h:110
struct packet_game_info info
Definition game.h:89
bool ruleset_ready
Definition game.h:119
int global_init_buildings[MAX_NUM_BUILDING_LIST]
Definition game.h:111
struct packet_scenario_info scenario
Definition game.h:87
char * ruleset_description
Definition game.h:85
struct conn_list * all_connections
Definition game.h:96
bool ruleset_init
Definition game.h:118
struct civ_game::@30 rgame
struct packet_timeout_info tinfo
Definition game.h:91
struct veteran_system * veteran
Definition game.h:101
struct packet_calendar_info calendar
Definition game.h:90
struct government * default_government
Definition game.h:93
struct civ_game::@31::@34 client
struct government * government_during_revolution
Definition game.h:94
int xsize
Definition map_types.h:78
int ysize
Definition map_types.h:78
int north_latitude
Definition map_types.h:79
Continent_id num_continents
Definition map_types.h:81
int south_latitude
Definition map_types.h:80
int topology_id
Definition map_types.h:72
int wrap_id
Definition map_types.h:73
struct connection conn
Definition client_main.h:96
struct requirement_vector receiver_reqs
Definition diptreaty.h:59
struct requirement_vector giver_reqs
Definition diptreaty.h:58
bool enabled
Definition diptreaty.h:57
bool sound_bell_at_new_turn
Definition options.h:150
bool autoaccept_tileset_suggestion
Definition options.h:183
bool autoaccept_musicset_suggestion
Definition options.h:185
bool draw_city_names
Definition options.h:196
bool draw_city_productions
Definition options.h:198
bool popup_new_cities
Definition options.h:167
bool draw_city_trade_routes
Definition options.h:200
bool wakeup_focus
Definition options.h:159
bool autoaccept_soundset_suggestion
Definition options.h:184
bool ask_city_name
Definition options.h:166
bool draw_city_growth
Definition options.h:197
bool ai_manual_turn_done
Definition options.h:154
int smooth_combat_step_msec
Definition options.h:153
bool draw_full_citybar
Definition options.h:216
bool auto_center_on_combat
Definition options.h:157
bool popup_attack_actions
Definition options.h:169
enum unit_type_flag_id flag
Definition unittype.h:467
enum combat_bonus_type type
Definition unittype.h:468
bool established
Definition connection.h:140
struct player * playing
Definition connection.h:151
int request_id_of_currently_handled_packet
Definition connection.h:193
struct connection::@58::@63 client
enum cmdlevel access_level
Definition connection.h:177
bool observer
Definition connection.h:147
char username[MAX_LEN_NAME]
Definition connection.h:164
char capability[MAX_LEN_CAPSTR]
Definition connection.h:171
int last_processed_request_id_seen
Definition connection.h:190
double ping_time
Definition connection.h:161
bv_unit_classes native_to
Definition extras.h:130
char rmact_gfx[MAX_LEN_NAME]
Definition extras.h:102
bv_extras conflicts
Definition extras.h:133
uint8_t rmcauses
Definition extras.h:95
char act_gfx_alt[MAX_LEN_NAME]
Definition extras.h:100
struct requirement_vector appearance_reqs
Definition extras.h:108
struct strvec * helptext
Definition extras.h:149
bv_extra_flags flags
Definition extras.h:132
char rmact_gfx_alt[MAX_LEN_NAME]
Definition extras.h:103
uint16_t causes
Definition extras.h:94
bv_extras bridged_over
Definition extras.h:135
struct extra_type::@25 data
int removal_time
Definition extras.h:120
char rmact_gfx_alt2[MAX_LEN_NAME]
Definition extras.h:104
int build_time_factor
Definition extras.h:119
struct requirement_vector disappearance_reqs
Definition extras.h:109
bool generated
Definition extras.h:117
int special_idx
Definition extras.h:153
struct requirement_vector rmreqs
Definition extras.h:107
Tech_type_id visibility_req
Definition extras.h:139
enum extra_category category
Definition extras.h:93
char graphic_alt[MAX_LEN_NAME]
Definition extras.h:98
char activity_gfx[MAX_LEN_NAME]
Definition extras.h:99
int disappearance_chance
Definition extras.h:126
int removal_time_factor
Definition extras.h:121
char act_gfx_alt2[MAX_LEN_NAME]
Definition extras.h:101
struct requirement_vector reqs
Definition extras.h:106
bool buildable
Definition extras.h:116
enum extra_unit_seen_type eus
Definition extras.h:128
int defense_bonus
Definition extras.h:124
int appearance_chance
Definition extras.h:125
char graphic_str[MAX_LEN_NAME]
Definition extras.h:97
int build_time
Definition extras.h:118
int infracost
Definition extras.h:122
int no_aggr_near_city
Definition extras.h:137
bv_extras hidden_by
Definition extras.h:134
struct name_translation name
Definition extras.h:90
struct strvec * helptext
Definition government.h:65
struct requirement_vector reqs
Definition government.h:62
char graphic_alt[MAX_LEN_NAME]
Definition government.h:58
Government_type_id item_number
Definition government.h:53
char sound_alt2[MAX_LEN_NAME]
Definition government.h:61
struct name_translation name
Definition government.h:54
char sound_str[MAX_LEN_NAME]
Definition government.h:59
char graphic_str[MAX_LEN_NAME]
Definition government.h:57
char sound_alt[MAX_LEN_NAME]
Definition government.h:60
int build_cost
Definition improvement.h:60
char graphic_str[MAX_LEN_NAME]
Definition improvement.h:55
char graphic_alt2[MAX_LEN_NAME]
Definition improvement.h:57
enum impr_genus_id genus
Definition improvement.h:63
char graphic_alt[MAX_LEN_NAME]
Definition improvement.h:56
struct requirement_vector obsolete_by
Definition improvement.h:59
char soundtag_alt[MAX_LEN_NAME]
Definition improvement.h:67
char soundtag_alt2[MAX_LEN_NAME]
Definition improvement.h:68
struct requirement_vector reqs
Definition improvement.h:58
struct strvec * helptext
Definition improvement.h:65
struct name_translation name
Definition improvement.h:52
bv_impr_flags flags
Definition improvement.h:64
char soundtag[MAX_LEN_NAME]
Definition improvement.h:66
struct requirement_vector reqs
Definition multipliers.h:42
struct strvec * helptext
Definition multipliers.h:43
int minimum_turns
Definition multipliers.h:41
struct name_translation name
Definition multipliers.h:33
int init_buildings[MAX_NUM_BUILDING_LIST]
Definition nation.h:123
struct nation_group_list * groups
Definition nation.h:116
struct name_translation noun_plural
Definition nation.h:102
struct nation_set_list * sets
Definition nation.h:113
char flag_graphic_str[MAX_LEN_NAME]
Definition nation.h:103
struct name_translation adjective
Definition nation.h:101
char flag_graphic_alt[MAX_LEN_NAME]
Definition nation.h:104
struct government * init_government
Definition nation.h:124
bool is_pickable
Definition nation.h:161
struct unit_type * init_units[MAX_NUM_UNIT_LIST]
Definition nation.h:125
char * legend
Definition nation.h:107
enum barbarian_type barb_type
Definition nation.h:110
struct nation_type::@51::@54 client
char * translation_domain
Definition nation.h:100
struct nation_style * style
Definition nation.h:106
int init_techs[MAX_NUM_TECH_LIST]
Definition nation.h:122
bool is_playable
Definition nation.h:109
char message[MAX_LEN_MSG]
enum event_type event
int last_turns_shield_surplus
int usage[O_LAST]
int ppl_content[FEELING_LAST]
bv_city_options city_options
enum capital_type capital
int surplus[O_LAST]
enum city_acquire_type acquire_type
int ppl_unhappy[FEELING_LAST]
int citizen_base[O_LAST]
enum city_wl_cancel_behavior wl_cb
int specialists[SP_MAX]
int ppl_angry[FEELING_LAST]
bv_imprs improvements
struct worklist worklist
char name[MAX_LEN_CITYNAME]
int ppl_happy[FEELING_LAST]
int prod[O_LAST]
int unhappy_penalty[O_LAST]
int waste[O_LAST]
int nation_id[MAX_CITY_NATIONALITIES]
int nation_citizens[MAX_CITY_NATIONALITIES]
enum capital_type capital
char name[MAX_LEN_CITYNAME]
int counters[MAX_COUNTERS]
enum event_type event
char message[MAX_LEN_MSG]
Government_type_id government_during_revolution_id
enum ai_level skill_level
enum phase_mode_type phase_mode
enum victory_condition_type victory_conditions
Government_type_id default_government_id
enum diplstate_type type
char inventions[A_LAST+1]
char rule_name[MAX_LEN_NAME]
enum achievement_type type
char name[MAX_LEN_NAME]
action_id alternatives[MAX_NUM_ACTIONS]
struct requirement reqs[MAX_NUM_REQS]
enum action_auto_perf_cause cause
struct requirement actor_reqs[MAX_NUM_REQS]
struct requirement target_reqs[MAX_NUM_REQS]
enum action_sub_target_kind sub_tgt_kind
enum action_actor_kind act_kind
bv_action_sub_results sub_results
char ui_name[MAX_LEN_NAME]
enum action_target_kind tgt_kind
enum action_result result
enum base_gui_type gui_type
char helptext[MAX_LEN_PACKET]
struct requirement obs_reqs[MAX_NUM_REQS]
char soundtag_alt[MAX_LEN_NAME]
struct requirement reqs[MAX_NUM_REQS]
enum impr_genus_id genus
char name[MAX_LEN_NAME]
char soundtag[MAX_LEN_NAME]
char soundtag_alt2[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
char graphic_alt2[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
char graphic_alt[MAX_LEN_NAME]
char citizens_graphic[MAX_LEN_NAME]
char name[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
char graphic_alt[MAX_LEN_NAME]
char graphic[MAX_LEN_NAME]
struct requirement reqs[MAX_NUM_REQS]
enum clause_type type
struct requirement receiver_reqs[MAX_NUM_REQS]
struct requirement giver_reqs[MAX_NUM_REQS]
char preferred_soundset[MAX_LEN_NAME]
char preferred_tileset[MAX_LEN_NAME]
char preferred_musicset[MAX_LEN_NAME]
enum counter_target type
char name[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
char helptext[MAX_LEN_PACKET]
enum counter_behavior behavior
char text[MAX_LEN_CONTENT]
char rule_name[MAX_LEN_NAME]
struct requirement reqs[MAX_NUM_REQS]
bv_disaster_effects effects
char name[MAX_LEN_NAME]
char helptxt[MAX_LEN_PACKET]
char name[MAX_LEN_NAME]
bv_unit_classes native_to
char rmact_gfx_alt2[MAX_LEN_NAME]
struct requirement reqs[MAX_NUM_REQS]
char graphic_alt[MAX_LEN_NAME]
char act_gfx_alt2[MAX_LEN_NAME]
struct requirement disappearance_reqs[MAX_NUM_REQS]
bv_extra_flags flags
char act_gfx_alt[MAX_LEN_NAME]
char activity_gfx[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
enum extra_unit_seen_type eus
struct requirement appearance_reqs[MAX_NUM_REQS]
char name[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
char rmact_gfx_alt[MAX_LEN_NAME]
char rmact_gfx[MAX_LEN_NAME]
struct requirement rmreqs[MAX_NUM_REQS]
char helptext[MAX_LEN_PACKET]
int work_raise_chance[MAX_VET_LEVELS]
int base_raise_chance[MAX_VET_LEVELS]
int global_init_techs[MAX_NUM_TECH_LIST]
int move_bonus[MAX_VET_LEVELS]
char veteran_name[MAX_VET_LEVELS][MAX_LEN_NAME]
Impr_type_id global_init_buildings[MAX_NUM_BUILDING_LIST]
int power_fact[MAX_VET_LEVELS]
char helptext[MAX_LEN_PACKET]
bv_goods_flags flags
char name[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
struct requirement reqs[MAX_NUM_REQS]
char sound_alt[MAX_LEN_NAME]
char graphic_alt[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
char name[MAX_LEN_NAME]
Government_type_id id
char sound_str[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
struct requirement reqs[MAX_NUM_REQS]
char helptext[MAX_LEN_PACKET]
char sound_alt2[MAX_LEN_NAME]
char name[MAX_LEN_NAME]
char helptxt[MAX_LEN_PACKET]
char name[MAX_LEN_NAME]
Multiplier_type_id id
struct requirement reqs[MAX_NUM_REQS]
char rule_name[MAX_LEN_NAME]
char helptext[MAX_LEN_PACKET]
char music_combat[MAX_LEN_NAME]
struct requirement reqs[MAX_NUM_REQS]
char music_peaceful[MAX_LEN_NAME]
char groups[MAX_NUM_NATION_GROUPS][MAX_LEN_NAME]
bool hidden[MAX_NUM_NATION_GROUPS]
char rule_names[MAX_NUM_NATION_SETS][MAX_LEN_NAME]
char names[MAX_NUM_NATION_SETS][MAX_LEN_NAME]
char descriptions[MAX_NUM_NATION_SETS][MAX_LEN_MSG]
int init_techs[MAX_NUM_TECH_LIST]
char leader_name[MAX_NUM_LEADERS][MAX_LEN_NAME]
char noun_plural[MAX_LEN_NAME]
char adjective[MAX_LEN_NAME]
Impr_type_id init_buildings[MAX_NUM_BUILDING_LIST]
Unit_type_id init_units[MAX_NUM_UNIT_LIST]
bool leader_is_male[MAX_NUM_LEADERS]
char translation_domain[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
Government_type_id init_government_id
int groups[MAX_NUM_NATION_GROUPS]
enum barbarian_type barbarian_type
int sets[MAX_NUM_NATION_SETS]
char graphic_alt[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
char legend[MAX_LEN_MSG]
bv_road_flags flags
int tile_incr_const[O_LAST]
enum road_gui_type gui_type
bv_max_extras integrates
enum road_compat compat
enum road_move_mode move_mode
int tile_bonus[O_LAST]
int tile_incr[O_LAST]
struct requirement first_reqs[MAX_NUM_REQS]
char rule_name[MAX_LEN_NAME]
char graphic_alt[MAX_LEN_NAME]
struct requirement reqs[MAX_NUM_REQS]
Specialist_type_id id
char helptext[MAX_LEN_PACKET]
char short_name[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
char plural_name[MAX_LEN_NAME]
char name[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
char text[MAX_LEN_CONTENT]
char name[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
char name[MAX_LEN_NAME]
char helptxt[MAX_LEN_PACKET]
char name[MAX_LEN_NAME]
struct requirement research_reqs[MAX_NUM_REQS]
char graphic_str[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
char graphic_alt[MAX_LEN_NAME]
bv_tech_flags flags
char helptext[MAX_LEN_PACKET]
char name[MAX_LEN_NAME]
char helptxt[MAX_LEN_PACKET]
int extra_removal_times[MAX_EXTRA_TYPES]
Terrain_type_id transform_result
int resource_freq[MAX_EXTRA_TYPES]
char helptext[MAX_LEN_PACKET]
Resource_type_id resources[MAX_EXTRA_TYPES]
bv_terrain_flags flags
char graphic_str[MAX_LEN_NAME]
bv_unit_classes native_to
Terrain_type_id cultivate_result
Terrain_type_id plant_result
char name[MAX_LEN_NAME]
int road_output_incr_pct[O_LAST]
char graphic_alt[MAX_LEN_NAME]
char graphic_alt2[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
enum trade_route_illegal_cancelling cancelling
enum trade_route_bonus_type bonus_type
enum combat_bonus_type type
enum unit_type_flag_id flag
char helptxt[MAX_LEN_PACKET]
char rule_name[MAX_LEN_NAME]
bv_unit_class_flags flags
char name[MAX_LEN_NAME]
char helptext[MAX_LEN_PACKET]
char name[MAX_LEN_NAME]
char helptxt[MAX_LEN_PACKET]
char graphic_alt[MAX_LEN_NAME]
enum vision_layer vlayer
enum transp_def_type tp_defense
char rule_name[MAX_LEN_NAME]
int power_fact[MAX_VET_LEVELS]
char name[MAX_LEN_NAME]
char graphic_alt2[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
char sound_fight_alt[MAX_LEN_NAME]
bv_unit_classes disembarks
bv_unit_classes cargo
bv_unit_type_flags flags
char sound_move_alt[MAX_LEN_NAME]
bv_unit_classes targets
struct requirement build_reqs[MAX_NUM_REQS]
int base_raise_chance[MAX_VET_LEVELS]
int work_raise_chance[MAX_VET_LEVELS]
char sound_fight[MAX_LEN_NAME]
bv_unit_classes embarks
char veteran_name[MAX_VET_LEVELS][MAX_LEN_NAME]
char sound_move[MAX_LEN_NAME]
char helptext[MAX_LEN_PACKET]
bv_unit_type_roles roles
int move_bonus[MAX_VET_LEVELS]
char description[MAX_LEN_CONTENT]
char authors[MAX_LEN_PACKET/3]
bv_spaceship_structure structure
Resource_type_id resource
enum known_type known
char label[MAX_LEN_MAP_LABEL]
Continent_id continent
Definition packets_gen.h:99
Terrain_type_id terrain
char spec_sprite[MAX_LEN_NAME]
enum route_direction direction
struct act_prob action_probabilities[MAX_NUM_ACTIONS]
int upkeep[O_LAST]
enum action_decision action_decision_want
struct unit_order orders[MAX_LEN_ROUTE]
enum unit_activity activity
Unit_type_id type
enum unit_activity changed_from
enum direction8 facing
enum server_side_agent ssa_controller
enum direction8 facing
char user[MAX_LEN_NAME]
enum unit_activity activity
enum ai_level skill_level
Definition player.h:114
enum barbarian_type barbarian_type
Definition player.h:120
int science_cost
Definition player.h:117
int love[MAX_NUM_PLAYER_SLOTS]
Definition player.h:122
int infra_points
Definition player.h:65
enum spaceship_state state
Definition spaceship.h:108
struct city_list * cities
Definition player.h:279
struct player_ai ai_common
Definition player.h:286
bv_plr_flags flags
Definition player.h:290
struct dbv tile_vision[V_COUNT]
Definition player.h:357
int primary_capital_id
Definition player.h:273
bool is_male
Definition player.h:255
int wonders[B_LAST]
Definition player.h:303
struct government * target_government
Definition player.h:257
int autoselect_weight
Definition player.h:297
char username[MAX_LEN_NAME]
Definition player.h:250
bool is_connected
Definition player.h:294
int revolution_finishes
Definition player.h:271
int nturns_idle
Definition player.h:263
struct government * government
Definition player.h:256
struct dbv tile_known
Definition player.h:308
int turns_alive
Definition player.h:264
bool was_created
Definition player.h:292
int tech_upkeep
Definition player.h:361
struct unit_list * units
Definition player.h:280
struct conn_list * connections
Definition player.h:296
bool is_alive
Definition player.h:266
bv_player real_embassy
Definition player.h:275
struct player::@70::@73 client
struct player_economic economic
Definition player.h:282
int culture
Definition player.h:365
struct player_spaceship spaceship
Definition player.h:284
char name[MAX_LEN_NAME]
Definition player.h:249
bv_player gives_shared_vision
Definition player.h:300
enum mood_type mood
Definition player.h:359
struct player_score score
Definition player.h:281
struct multiplier_value multipliers[MAX_NUM_MULTIPLIERS]
Definition player.h:312
bool color_changeable
Definition player.h:363
int music_style
Definition player.h:278
struct nation_style * style
Definition player.h:277
bool phase_done
Definition player.h:261
bv_player gives_shared_tiles
Definition player.h:302
bool is_ready
Definition player.h:260
int history
Definition player.h:314
struct rgbcolor * rgb
Definition player.h:310
bool unassigned_user
Definition player.h:251
int output[O_LAST]
Definition terrain.h:49
int g
Definition rgbcolor.h:34
int b
Definition rgbcolor.h:34
int r
Definition rgbcolor.h:34
struct requirement_vector reqs
Definition specialist.h:38
char graphic_alt[MAX_LEN_NAME]
Definition specialist.h:36
struct strvec * helptext
Definition specialist.h:40
char graphic_str[MAX_LEN_NAME]
Definition specialist.h:35
struct name_translation name
Definition specialist.h:31
struct name_translation abbreviation
Definition specialist.h:32
Definition map.c:41
struct terrain * cultivate_result
Definition terrain.h:215
int placing_time
Definition terrain.h:227
struct extra_type ** resources
Definition terrain.h:204
struct strvec * helptext
Definition terrain.h:263
char graphic_alt2[MAX_LEN_NAME]
Definition terrain.h:189
bv_terrain_flags flags
Definition terrain.h:259
int * resource_freq
Definition terrain.h:205
bv_unit_classes native_to
Definition terrain.h:257
int road_time
Definition terrain.h:213
struct name_translation name
Definition terrain.h:184
int plant_time
Definition terrain.h:219
struct terrain * plant_result
Definition terrain.h:218
int irrigation_food_incr
Definition terrain.h:221
int defense_bonus
Definition terrain.h:200
int cultivate_time
Definition terrain.h:216
int movement_cost
Definition terrain.h:199
const struct unit_type * animal
Definition terrain.h:237
int pillage_time
Definition terrain.h:232
int output[O_LAST]
Definition terrain.h:202
int transform_time
Definition terrain.h:231
char graphic_alt[MAX_LEN_NAME]
Definition terrain.h:188
int mining_time
Definition terrain.h:225
struct rgbcolor * rgb
Definition terrain.h:261
char graphic_str[MAX_LEN_NAME]
Definition terrain.h:187
enum terrain_class tclass
Definition terrain.h:197
int road_output_incr_pct[O_LAST]
Definition terrain.h:211
int extra_removal_times[MAX_EXTRA_TYPES]
Definition terrain.h:235
struct terrain * transform_result
Definition terrain.h:229
int irrigation_time
Definition terrain.h:222
int base_time
Definition terrain.h:212
int mining_shield_incr
Definition terrain.h:224
Definition tile.h:50
char * spec_sprite
Definition tile.h:66
char * label
Definition tile.h:65
bv_extras extras
Definition tile.h:55
struct unit_list * units
Definition tile.h:58
struct player * extras_owner
Definition tile.h:63
int infra_turns
Definition tile.h:62
struct extra_type * placing
Definition tile.h:61
Continent_id continent
Definition tile.h:54
int hp_loss_pct
Definition unittype.h:155
int non_native_def_pct
Definition unittype.h:156
int min_speed
Definition unittype.h:154
struct name_translation name
Definition unittype.h:151
struct strvec * helptext
Definition unittype.h:159
bv_unit_class_flags flags
Definition unittype.h:157
enum unit_orders order
Definition unit.h:93
int action
Definition unit.h:100
int transport_capacity
Definition unittype.h:523
struct unit_type::@87 adv
struct unit_class * uclass
Definition unittype.h:556
int pop_cost
Definition unittype.h:513
struct requirement_vector build_reqs
Definition unittype.h:520
int defense_strength
Definition unittype.h:516
bv_unit_classes cargo
Definition unittype.h:558
int firepower
Definition unittype.h:525
int paratroopers_range
Definition unittype.h:541
char graphic_alt[MAX_LEN_NAME]
Definition unittype.h:506
bool worker
Definition unittype.h:575
char sound_move_alt[MAX_LEN_NAME]
Definition unittype.h:509
int build_cost
Definition unittype.h:512
int convert_time
Definition unittype.h:531
int city_size
Definition unittype.h:550
struct veteran_system * veteran
Definition unittype.h:544
const struct unit_type * obsoleted_by
Definition unittype.h:529
int vision_radius_sq
Definition unittype.h:522
int move_rate
Definition unittype.h:517
bv_unit_classes targets
Definition unittype.h:561
enum vision_layer vlayer
Definition unittype.h:569
struct strvec * helptext
Definition unittype.h:571
int bombard_rate
Definition unittype.h:547
char graphic_str[MAX_LEN_NAME]
Definition unittype.h:505
int city_slots
Definition unittype.h:552
char sound_move[MAX_LEN_NAME]
Definition unittype.h:508
char sound_fight_alt[MAX_LEN_NAME]
Definition unittype.h:511
struct name_translation name
Definition unittype.h:502
bv_unit_type_roles roles
Definition unittype.h:535
enum transp_def_type tp_defense
Definition unittype.h:554
int upkeep[O_LAST]
Definition unittype.h:538
char graphic_alt2[MAX_LEN_NAME]
Definition unittype.h:507
bv_unit_classes disembarks
Definition unittype.h:567
const struct unit_type * converted_to
Definition unittype.h:530
bv_unit_type_flags flags
Definition unittype.h:534
char sound_fight[MAX_LEN_NAME]
Definition unittype.h:510
bv_unit_classes embarks
Definition unittype.h:564
int attack_strength
Definition unittype.h:515
int happy_cost
Definition unittype.h:537
struct combat_bonus_list * bonuses
Definition unittype.h:526
Definition unit.h:138
int length
Definition unit.h:195
int upkeep[O_LAST]
Definition unit.h:148
bool has_orders
Definition unit.h:193
struct unit::@80 orders
bool occupied
Definition unit.h:219
enum action_decision action_decision_want
Definition unit.h:202
int battlegroup
Definition unit.h:191
enum unit_activity activity
Definition unit.h:157
int moves_left
Definition unit.h:150
struct unit::@81::@83 client
int id
Definition unit.h:145
bool moved
Definition unit.h:173
int index
Definition unit.h:195
bool vigilant
Definition unit.h:197
int hp
Definition unit.h:151
int fuel
Definition unit.h:153
struct extra_type * changed_from_target
Definition unit.h:170
int current_form_turn
Definition unit.h:208
bool stay
Definition unit.h:205
bool colored
Definition unit.h:222
enum direction8 facing
Definition unit.h:142
bool asking_city_name
Definition unit.h:225
struct extra_type * activity_target
Definition unit.h:164
int activity_count
Definition unit.h:162
struct unit_order * list
Definition unit.h:198
enum unit_activity changed_from
Definition unit.h:168
struct player * nationality
Definition unit.h:144
int transported_by
Definition unit.h:216
bool repeat
Definition unit.h:196
int homecity
Definition unit.h:146
bool paradropped
Definition unit.h:174
bool done_moving
Definition unit.h:181
int birth_turn
Definition unit.h:207
struct goods_type * carrying
Definition unit.h:186
struct tile * goto_tile
Definition unit.h:155
struct tile * action_decision_tile
Definition unit.h:203
const struct unit_type * utype
Definition unit.h:139
int veteran
Definition unit.h:152
int changed_from_count
Definition unit.h:169
enum unit_focus_status focus_status
Definition unit.h:214
enum server_side_agent ssa_controller
Definition unit.h:172
enum universals_n kind
Definition fc_types.h:902
int yes
Definition voteinfo.h:36
int num_voters
Definition voteinfo.h:39
bool passed
Definition voteinfo.h:41
int abstain
Definition voteinfo.h:38
int vote_no
Definition voteinfo.h:31
int no
Definition voteinfo.h:37
struct civ_map map
struct nation_style * style_by_number(int id)
Definition style.c:88
void styles_alloc(int count)
Definition style.c:36
struct music_style * music_style_by_number(int id)
Definition style.c:171
void music_styles_alloc(int count)
Definition style.c:133
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
size_t fc_strlcpy(char *dest, const char *src, size_t n)
Definition support.c:791
size_t fc_strlcat(char *dest, const char *src, size_t n)
Definition support.c:836
#define sz_strlcpy(dest, src)
Definition support.h:195
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define fc_strncmp(_s1_, _s2_, _len_)
Definition support.h:160
int team_count(void)
Definition team.c:375
struct team_slot * team_slot_by_number(int team_id)
Definition team.c:175
bool team_add_player(struct player *pplayer, struct team *pteam)
Definition team.c:467
struct team * team_new(struct team_slot *tslot)
Definition team.c:317
void team_slot_set_defined_name(struct team_slot *tslot, const char *team_name)
Definition team.c:288
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:107
void set_user_tech_flag_name(enum tech_flag_id id, const char *name, const char *helptxt)
Definition tech.c:394
struct tech_class * tech_class_by_number(const int idx)
Definition tech.c:320
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
#define A_FUTURE
Definition tech.h:46
#define A_NEVER
Definition tech.h:51
#define advance_index_iterate_end
Definition tech.h:248
tech_req
Definition tech.h:110
@ AR_TWO
Definition tech.h:112
@ AR_ROOT
Definition tech.h:113
@ AR_ONE
Definition tech.h:111
static Tech_type_id advance_count(void)
Definition tech.h:170
#define A_NONE
Definition tech.h:43
#define A_UNKNOWN
Definition tech.h:49
#define A_LAST
Definition tech.h:45
#define advance_index_iterate(_start, _index)
Definition tech.h:244
Terrain_type_id terrain_count(void)
Definition terrain.c:118
struct terrain * terrain_by_number(const Terrain_type_id type)
Definition terrain.c:156
const char * terrain_rule_name(const struct terrain *pterrain)
Definition terrain.c:247
struct resource_type * resource_type_init(struct extra_type *pextra)
Definition terrain.c:272
void set_user_terrain_flag_name(enum terrain_flag_id id, const char *name, const char *helptxt)
Definition terrain.c:788
#define MAX_NUM_TERRAINS
Definition terrain.h:64
void tile_set_terrain(struct tile *ptile, struct terrain *pterrain)
Definition tile.c:124
void tile_set_owner(struct tile *ptile, struct player *pplayer, struct tile *claimer)
Definition tile.c:69
bool tile_set_label(struct tile *ptile, const char *label)
Definition tile.c:1095
void tile_set_resource(struct tile *ptile, struct extra_type *presource)
Definition tile.c:349
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
void tile_set_worked(struct tile *ptile, struct city *pcity)
Definition tile.c:106
#define tile_index(_pt_)
Definition tile.h:88
#define tile_worked(_tile)
Definition tile.h:118
#define tile_resource(_tile)
Definition tile.h:102
known_type
Definition tile.h:35
@ TILE_KNOWN_UNSEEN
Definition tile.h:37
@ TILE_UNKNOWN
Definition tile.h:36
@ TILE_KNOWN_SEEN
Definition tile.h:38
#define tile_list_iterate(tile_list, ptile)
Definition tile.h:73
#define tile_terrain(_tile)
Definition tile.h:114
#define TILE_XY(ptile)
Definition tile.h:43
#define tile_list_iterate_end
Definition tile.h:75
#define tile_owner(_tile)
Definition tile.h:96
void tileset_setup_unit_type(struct tileset *t, struct unit_type *ut)
Definition tilespec.c:3806
void tileset_setup_government(struct tileset *t, struct government *gov)
Definition tilespec.c:4420
void tileset_setup_specialist_type_default_set(struct tileset *t, Specialist_type_id id)
Definition tilespec.c:2891
void tileset_setup_tile_type(struct tileset *t, const struct terrain *pterrain)
Definition tilespec.c:4154
void tileset_player_init(struct tileset *t, struct player *pplayer)
Definition tilespec.c:7372
bool unit_drawn_with_city_outline(const struct unit *punit, bool check_focus)
Definition tilespec.c:5512
void tileset_setup_impr_type(struct tileset *t, struct impr_type *pimprove)
Definition tilespec.c:3840
void tileset_background_init(struct tileset *t)
Definition tilespec.c:7452
void tileset_setup_tech_type(struct tileset *t, struct advance *padvance)
Definition tilespec.c:3856
void tileset_setup_city_tiles(struct tileset *t, int style)
Definition tilespec.c:6455
void tilespec_reread_frozen_refresh(const char *tname)
Definition tilespec.c:1545
void tileset_setup_extra(struct tileset *t, struct extra_type *pextra)
Definition tilespec.c:3875
const char * tileset_basename(const struct tileset *t)
Definition tilespec.c:704
void finish_loading_sprites(struct tileset *t)
Definition tilespec.c:3612
const char * tileset_name_get(struct tileset *t)
Definition tilespec.c:7523
void tileset_error(enum log_level level, const char *tset_name, const char *format,...)
Definition tilespec.c:624
bool tilespec_reread(const char *new_tileset_name, bool game_fully_initialized, float scale)
Definition tilespec.c:1355
void tileset_setup_nation_flag(struct tileset *t, struct nation_type *nation)
Definition tilespec.c:4435
void tileset_ruleset_reset(struct tileset *t)
Definition tilespec.c:7487
#define MAX_NUM_CITIZEN_SPRITES
Definition tilespec.h:197
#define NUM_WALL_TYPES
Definition tilespec.h:359
int city_num_trade_routes(const struct city *pcity)
struct trade_route_settings * trade_route_settings_by_type(enum trade_route_type type)
struct goods_type * goods_by_number(Goods_type_id id)
bool unit_transport_load(struct unit *pcargo, struct unit *ptrans, bool force)
Definition unit.c:2378
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2449
bool unit_transport_unload(struct unit *pcargo)
Definition unit.c:2398
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Definition unit.c:1632
void unit_virtual_destroy(struct unit *punit)
Definition unit.c:1737
void unit_tile_set(struct unit *punit, struct tile *ptile)
Definition unit.c:1263
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2433
struct unit_list * unit_transport_cargo(const struct unit *ptrans)
Definition unit.c:2459
#define unit_tile(_pu)
Definition unit.h:397
@ FOCUS_AVAIL
Definition unit.h:53
@ FOCUS_WAIT
Definition unit.h:53
@ ORDER_PERFORM_ACTION
Definition unit.h:47
#define unit_owner(_pu)
Definition unit.h:396
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
void set_unit_class_caches(struct unit_class *pclass)
Definition unittype.c:2756
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c:1569
const char * unit_rule_name(const struct unit *punit)
Definition unittype.c:1587
void set_unit_move_type(struct unit_class *puclass)
Definition unittype.c:2924
void set_unit_type_caches(struct unit_type *ptype)
Definition unittype.c:2815
struct unit_class * uclass_by_number(const Unit_Class_id id)
Definition unittype.c:2477
void veteran_system_definition(struct veteran_system *vsystem, int level, const char *vlist_name, int vlist_power, int vlist_move, int vlist_raise, int vlist_wraise)
Definition unittype.c:2685
struct unit_type * utype_by_number(const Unit_type_id id)
Definition unittype.c:112
void unit_type_action_cache_set(struct unit_type *ptype)
Definition unittype.c:915
void set_user_unit_class_flag_name(enum unit_class_flag_id id, const char *name, const char *helptxt)
Definition unittype.c:1812
struct veteran_system * veteran_system_new(int count)
Definition unittype.c:2654
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Definition unittype.c:371
void set_user_unit_type_flag_name(enum unit_type_flag_id id, const char *name, const char *helptxt)
Definition unittype.c:1876
#define UCF_LAST_USER_FLAG
Definition unittype.h:127
#define unit_class_iterate(_p)
Definition unittype.h:908
#define UTYF_LAST_USER_FLAG
Definition unittype.h:331
#define unit_type_iterate(_p)
Definition unittype.h:855
#define U_LAST
Definition unittype.h:40
#define unit_class_iterate_end
Definition unittype.h:915
#define unit_type_iterate_end
Definition unittype.h:862
void update_queue_processing_finished(int request_id)
void update_queue_processing_started(int request_id)
void unit_select_dialog_update(void)
#define vision_layer_iterate(v)
Definition vision.h:77
#define vision_layer_iterate_end
Definition vision.h:80
void voteinfo_queue_delayed_remove(int vote_no)
Definition voteinfo.c:53
struct voteinfo * voteinfo_queue_find(int vote_no)
Definition voteinfo.c:150
void voteinfo_queue_add(int vote_no, const char *user, const char *desc, int percent_required, int flags)
Definition voteinfo.c:123
bool worker_task_is_sane(struct worker_task *ptask)
Definition workertask.c:40
#define worker_task_list_iterate(tasklist, ptask)
Definition workertask.h:33
#define worker_task_list_iterate_end
Definition workertask.h:35
void worklist_copy(struct worklist *dst, const struct worklist *src)
Definition worklist.c:112
void worklist_init(struct worklist *pwl)
Definition worklist.c:38