Freeciv-3.3
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) {
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 nullptr,
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) {
287 punit->activity_target = nullptr;
288 } else {
290 }
291
294
295 if (packet->changed_from_tgt == EXTRA_NONE) {
296 punit->changed_from_target = nullptr;
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 {
320 punit->carrying = nullptr;
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{
365 struct unit *punit;
366 struct player *owner;
367
368 if (packet->owner == OWNER_NONE) {
369 owner = nullptr;
370 } else {
371 owner = player_by_number(packet->owner);
372 }
373
375 utype_by_number(packet->type),
376 0);
377
378 /* Owner and type fields are already filled in by unit_virtual_create() */
379 punit->id = packet->id;
381 punit->facing = packet->facing;
382 punit->nationality = nullptr;
383 punit->veteran = packet->veteran;
384 punit->hp = packet->hp;
385 punit->activity = packet->activity;
386
387 if (packet->activity_tgt == EXTRA_NONE) {
388 punit->activity_target = nullptr;
389 } else {
391 }
392
393 /* Transporter / transporting information. */
394 punit->client.occupied = packet->occupied;
395 if (packet->transported) {
397 } else {
399 }
400
401 return punit;
402}
403
404/************************************************************************/
408void handle_server_join_reply(bool you_can_join, const char *message,
409 const char *capability,
410 const char *challenge_file, int conn_id)
411{
412 const char *s_capability = client.conn.capability;
413
414 conn_set_capability(&client.conn, capability);
416
417 if (you_can_join) {
419
420 log_verbose("join game accept:%s", message);
422 client.conn.id = conn_id;
423
426
430 }
431
433#ifdef EMERGENCY_VERSION
434 client_info.emerg_version = EMERGENCY_VERSION;
435#else
436 client_info.emerg_version = 0;
437#endif
439 sizeof(client_info.distribution));
441
442 /* We could always use hack, verify we're local */
443#ifdef FREECIV_DEBUG
444 if (!hackless)
445#endif /* FREECIV_DEBUG */
446 {
447 send_client_wants_hack(challenge_file);
448 }
449
451 } else {
453 _("You were rejected from the game: %s"), message);
454 client.conn.id = -1; /* not in range of conn_info id */
455
456 if (auto_connect) {
457 log_normal(_("You were rejected from the game: %s"), message);
458 }
460
462 }
464 return;
465 }
466 output_window_printf(ftc_client, _("Client capability string: %s"),
468 output_window_printf(ftc_client, _("Server capability string: %s"),
470}
471
472/************************************************************************/
476void handle_city_remove(int city_id)
477{
478 struct city *pcity = game_city_by_number(city_id);
480
481 fc_assert_ret_msg(NULL != pcity, "Bad city %d.", city_id);
482
484
488
489 /* Update menus if the focus unit is on the tile. */
490 if (need_menus_update) {
491 menus_update();
492 }
493}
494
495/************************************************************************/
499void handle_unit_remove(int unit_id)
500{
501 struct unit *punit = game_unit_by_number(unit_id);
502 struct unit_list *cargos;
503 struct player *powner;
505
506 if (!punit) {
507 log_error("Server wants us to remove unit id %d, "
508 "but we don't know about this unit!",
509 unit_id);
510 return;
511 }
512
513 /* Close the action selection dialog if the actor unit is lost. */
516 /* Open another action selection dialog if there are other actors in the
517 * current selection that want a decision. */
519 }
520
522 powner = unit_owner(punit);
523
524 /* Unload cargo if this is a transporter. */
526 if (unit_list_size(cargos) > 0) {
530 }
531
532 /* Unload unit if it is transported. */
535 }
537
541
542 if (!client_has_player() || powner == client_player()) {
545 }
547 }
548}
549
550/************************************************************************/
557
558/************************************************************************/
561void handle_team_name_info(int team_id, const char *team_name)
562{
563 struct team_slot *tslot = team_slot_by_number(team_id);
564
568}
569
570/************************************************************************/
577{
578 bool show_combat = FALSE;
581
582 if (punit0 && punit1) {
584 packet->attacker_hp, packet->defender_hp,
585 packet->make_att_veteran, packet->make_def_veteran);
592 } else {
594 }
596 }
597
598 if (show_combat) {
599 int hp0 = packet->attacker_hp, hp1 = packet->defender_hp;
600
602 unit_type_get(punit0)->sound_fight_alt,
603 NULL);
605 unit_type_get(punit1)->sound_fight_alt,
606 NULL);
607
610 } else {
611 punit0->hp = hp0;
612 punit1->hp = hp1;
613
617 }
618 }
619 if (packet->make_att_veteran && punit0) {
620 punit0->veteran++;
622 }
623 if (packet->make_def_veteran && punit1) {
624 punit1->veteran++;
626 }
627 }
628}
629
630/************************************************************************/
637 struct impr_type *pimprove,
638 bool have_impr)
639{
640 if (have_impr) {
641 if (pcity->built[improvement_index(pimprove)].turn <= I_NEVER) {
642 city_add_improvement(pcity, pimprove);
643 return TRUE;
644 }
645 } else {
646 if (pcity->built[improvement_index(pimprove)].turn > I_NEVER) {
648 return TRUE;
649 }
650 }
651 return FALSE;
652}
653
654/************************************************************************/
658void handle_city_info(const struct packet_city_info *packet)
659{
660 struct universal product;
661 int i;
662 bool popup;
663 bool city_is_new = FALSE;
668 bool name_changed = FALSE;
671 bool production_changed = FALSE;
673 struct unit_list *pfocus_units = get_units_in_focus();
674 struct city *pcity = game_city_by_number(packet->id);
675 struct tile_list *worked_tiles = NULL;
676 struct tile *pcenter = index_to_tile(&(wld.map), packet->tile);
677 struct tile *ptile = NULL;
678 struct player *powner = player_by_number(packet->owner);
679
680 fc_assert_ret_msg(NULL != powner, "Bad player number %d.", packet->owner);
681 fc_assert_ret_msg(NULL != pcenter, "Invalid tile index %d.", packet->tile);
682
684 log_error("handle_city_info() bad production_kind %d.",
685 packet->production_kind);
686 product.kind = VUT_NONE;
687 } else {
689 packet->production_value);
690 if (!universals_n_is_valid(product.kind)) {
691 log_error("handle_city_info() "
692 "production_kind %d with bad production_value %d.",
693 packet->production_kind, packet->production_value);
694 product.kind = VUT_NONE;
695 }
696 }
697
698 if (NULL != pcity) {
699 ptile = city_tile(pcity);
700
701 if (NULL == ptile) {
702 /* Invisible worked city */
705
706 pcity->tile = pcenter;
707 ptile = pcenter;
708 pcity->owner = powner;
709 } else if (city_owner(pcity) != powner) {
710 /* Remember what were the worked tiles. The server won't
711 * send them to us again. */
713 ptile, pworked, _index, _x, _y) {
714 if (pcity == tile_worked(pworked)) {
715 if (NULL == worked_tiles) {
716 worked_tiles = tile_list_new();
717 }
718 tile_list_append(worked_tiles, pworked);
719 }
722 pcity = NULL;
724 }
725 }
726
727 if (NULL == pcity) {
729 pcity = create_city_virtual(powner, pcenter, packet->name);
730 pcity->id = packet->id;
733 } else if (pcity->id != packet->id) {
734 log_error("handle_city_info() city id %d != id %d.",
735 pcity->id, packet->id);
736 return;
737 } else if (ptile != pcenter) {
738 log_error("handle_city_info() city tile (%d, %d) != (%d, %d).",
739 TILE_XY(ptile), TILE_XY(pcenter));
740 return;
741 } else {
743
744 while (trade_route_list_size(pcity->routes) > packet->trade_route_count) {
745 struct trade_route *proute = trade_route_list_get(pcity->routes, -1);
746
750 }
751
752 /* Descriptions should probably be updated if the
753 * city name, production or time-to-grow changes.
754 * Note that if either the food stock or surplus
755 * have changed, the time-to-grow is likely to
756 * have changed as well. */
759 && (!are_universals_equal(&pcity->production, &product)
760 || pcity->surplus[O_SHIELD] != packet->surplus[O_SHIELD]
761 || pcity->shield_stock != packet->shield_stock))
763 && (pcity->food_stock != packet->food_stock
764 || pcity->surplus[O_FOOD] != packet->surplus[O_FOOD]))
766
767 city_name_set(pcity, packet->name);
768 }
769
770 pcity->original = player_by_number(packet->original);
771
772 /* Check data */
774 for (i = 0; i < FEELING_LAST; i++) {
775 pcity->feel[CITIZEN_HAPPY][i] = packet->ppl_happy[i];
776 pcity->feel[CITIZEN_CONTENT][i] = packet->ppl_content[i];
777 pcity->feel[CITIZEN_UNHAPPY][i] = packet->ppl_unhappy[i];
778 pcity->feel[CITIZEN_ANGRY][i] = packet->ppl_angry[i];
779 }
780 for (i = 0; i < CITIZEN_LAST; i++) {
782 }
784 pcity->specialists[sp] = packet->specialists[sp];
785 city_size_add(pcity, pcity->specialists[sp]);
787
788 if (city_size_get(pcity) != packet->size) {
789 log_error("handle_city_info() "
790 "%d citizens not equal %d city size in \"%s\".",
792 city_size_set(pcity, packet->size);
793 }
794
795 pcity->history = packet->history;
796 pcity->client.culture = packet->culture;
797 pcity->client.buy_cost = packet->buy_cost;
798
799 pcity->city_radius_sq = packet->city_radius_sq;
800
801 pcity->city_options = packet->city_options;
802 pcity->wlcb = packet->wl_cb;
803
804 pcity->acquire_t = packet->acquire_type;
805
806 if (pcity->surplus[O_SCIENCE] != packet->surplus[O_SCIENCE]
807 || pcity->surplus[O_SCIENCE] != packet->surplus[O_SCIENCE]
808 || pcity->waste[O_SCIENCE] != packet->waste[O_SCIENCE]
809 || (pcity->unhappy_penalty[O_SCIENCE]
810 != packet->unhappy_penalty[O_SCIENCE])
811 || pcity->prod[O_SCIENCE] != packet->prod[O_SCIENCE]
812 || pcity->citizen_base[O_SCIENCE] != packet->citizen_base[O_SCIENCE]
813 || pcity->usage[O_SCIENCE] != packet->usage[O_SCIENCE]) {
815 }
816
817 pcity->food_stock = packet->food_stock;
818 if (pcity->shield_stock != packet->shield_stock) {
820 pcity->shield_stock = packet->shield_stock;
821 }
822 pcity->pollution = packet->pollution;
823 pcity->illness_trade = packet->illness_trade;
824
825 if (!are_universals_equal(&pcity->production, &product)) {
826 production_changed = TRUE;
827 }
828 /* Need to consider shield stock/surplus for unit dialog as used build
829 * slots may change, affecting number of "in-progress" units. */
830 if ((city_is_new && VUT_UTYPE == product.kind)
831 || (production_changed && (VUT_UTYPE == pcity->production.kind
832 || VUT_UTYPE == product.kind))
833 || pcity->surplus[O_SHIELD] != packet->surplus[O_SHIELD]
836 }
837 pcity->production = product;
838
840 pcity->surplus[o] = packet->surplus[o];
841 pcity->waste[o] = packet->waste[o];
842 pcity->unhappy_penalty[o] = packet->unhappy_penalty[o];
843 pcity->prod[o] = packet->prod[o];
844 pcity->citizen_base[o] = packet->citizen_base[o];
845 pcity->usage[o] = packet->usage[o];
847
848#ifdef DONE_BY_create_city_virtual
849 if (city_is_new) {
850 worklist_init(&pcity->worklist);
851
852 for (i = 0; i < ARRAY_SIZE(pcity->built); i++) {
853 pcity->built[i].turn = I_NEVER;
854 }
855 }
856#endif /* DONE_BY_create_city_virtual */
857
858 worklist_copy(&pcity->worklist, &packet->worklist);
859
860 pcity->airlift = packet->airlift;
861 pcity->did_buy = packet->did_buy;
862 pcity->did_sell = packet->did_sell;
863 pcity->was_happy = packet->was_happy;
864 pcity->had_famine = packet->had_famine;
865
866 pcity->anarchy = packet->anarchy;
867 pcity->rapture = packet->rapture;
868
869 pcity->turn_founded = packet->turn_founded;
870 pcity->turn_last_built = packet->turn_last_built;
871
873 log_error("handle_city_info() bad changed_from_kind %d.",
874 packet->changed_from_kind);
875 product.kind = VUT_NONE;
876 } else {
878 packet->changed_from_value);
879 if (!universals_n_is_valid(product.kind)) {
880 log_error("handle_city_info() bad changed_from_value %d.",
881 packet->changed_from_value);
882 product.kind = VUT_NONE;
883 }
884 }
886
887 pcity->before_change_shields = packet->before_change_shields;
888 pcity->disbanded_shields = packet->disbanded_shields;
889 pcity->caravan_shields = packet->caravan_shields;
890 pcity->last_turns_shield_surplus = packet->last_turns_shield_surplus;
891
892 improvement_iterate(pimprove) {
893 bool have = BV_ISSET(packet->improvements, improvement_index(pimprove));
894
895 if (have && !city_is_new
896 && pcity->built[improvement_index(pimprove)].turn <= I_NEVER) {
897 audio_play_sound(pimprove->soundtag, pimprove->soundtag_alt,
898 pimprove->soundtag_alt2);
899 }
903
904 /* We should be able to see units in the city. But for a diplomat
905 * investigating an enemy city we can't. In that case we don't update
906 * the occupied flag at all: it's already been set earlier and we'll
907 * get an update if it changes. */
910 = (unit_list_size(pcity->tile->units) > 0);
911 }
912
913 pcity->client.walls = packet->walls;
914 if (pcity->client.walls > NUM_WALL_TYPES) {
915 pcity->client.walls = NUM_WALL_TYPES;
916 }
917 pcity->style = packet->style;
918 pcity->capital = packet->capital;
919 if (packet->capital == CAPITAL_PRIMARY) {
920 powner->primary_capital_id = pcity->id;
921 } else if (powner->primary_capital_id == pcity->id) {
922 powner->primary_capital_id = 0;
923 }
924 pcity->client.city_image = packet->city_image;
925 pcity->steal = packet->steal;
926
927 pcity->client.happy = city_happy(pcity);
928 pcity->client.unhappy = city_unhappy(pcity);
929
931 && powner == client.conn.playing
933 || packet->diplomat_investigate;
934
935 city_packet_common(pcity, pcenter, powner, worked_tiles,
937
940 } else {
942 }
943
944 /* Update the description if necessary. */
947 }
948
949 /* Update focus unit info label if necessary. */
950 if (name_changed) {
952 if (pfocus_unit->homecity == pcity->id) {
954 break;
955 }
957 }
958
959 /* Update the science dialog if necessary. */
962 }
963
964 /* Update the units dialog if necessary. */
967 }
968
969 /* Update the economy dialog if necessary. */
972 }
973
974 /* Update the panel text (including civ population). */
976
977 /* Update caravan dialog */
978 if ((production_changed || shield_stock_changed)
983 city_tile(pcity)->index,
986 }
987
992 }
993}
994
995/************************************************************************/
999{
1000 struct city *pcity = game_city_by_number(packet->id);
1001
1002 /* The nationality of the citizens. */
1004 int i;
1005
1007 for (i = 0; i < packet->nationalities_count; i++) {
1009 packet->nation_citizens[i]);
1010 }
1012 }
1013}
1014
1015/************************************************************************/
1019{
1020 struct city *pcity = game_city_by_number(packet->id);
1021
1022 if (pcity != NULL) {
1024 }
1025}
1026
1027/************************************************************************/
1032static void city_packet_common(struct city *pcity, struct tile *pcenter,
1033 struct player *powner,
1034 struct tile_list *worked_tiles,
1035 bool is_new, bool popup, bool investigate)
1036{
1037 if (NULL != worked_tiles) {
1038 /* We need to transfer the worked infos because the server will assume
1039 * those infos are kept in our side and won't send to us again. */
1040 tile_list_iterate(worked_tiles, pwork) {
1043 tile_list_destroy(worked_tiles);
1044 }
1045
1046 if (is_new) {
1047 tile_set_worked(pcenter, pcity); /* is_free_worked() */
1048 city_list_prepend(powner->cities, pcity);
1049
1050 if (client_is_global_observer() || powner == client_player()) {
1052 }
1053
1055 unit_list_iterate(pp->units, punit) {
1056 if (punit->homecity == pcity->id) {
1057 unit_list_prepend(pcity->units_supported, punit);
1058 }
1061
1062 pcity->client.first_citizen_index = fc_rand(MAX_NUM_CITIZEN_SPRITES);
1063 } else {
1064 if (client_is_global_observer() || powner == client_player()) {
1066 }
1067 }
1068
1069 if (can_client_change_view()) {
1071 }
1072
1073 if (city_workers_display == pcity) {
1075 }
1076
1077 if (investigate) {
1078 /* Commit the collected supported and present units. */
1079 if (pcity->client.collecting_info_units_supported != NULL) {
1080 /* We got units, let's move the unit lists. */
1081 fc_assert(pcity->client.collecting_info_units_present != NULL);
1082
1083 unit_list_destroy(pcity->client.info_units_present);
1084 pcity->client.info_units_present =
1085 pcity->client.collecting_info_units_present;
1086 pcity->client.collecting_info_units_present = NULL;
1087
1088 unit_list_destroy(pcity->client.info_units_supported);
1089 pcity->client.info_units_supported =
1090 pcity->client.collecting_info_units_supported;
1091 pcity->client.collecting_info_units_supported = NULL;
1092 } else {
1093 /* We didn't get any unit, let's clear the unit lists. */
1094 fc_assert(pcity->client.collecting_info_units_present == NULL);
1095
1096 unit_list_clear(pcity->client.info_units_supported);
1097 unit_list_clear(pcity->client.info_units_present);
1098 }
1099 }
1100
1101 if (popup
1102 && NULL != client.conn.playing
1105 menus_update();
1106 if (!city_dialog_is_open(pcity)) {
1108 }
1109 }
1110
1111 if (!is_new
1114 }
1115
1116 /* update menus if the focus unit is on the tile. */
1118 menus_update();
1119 }
1120
1121 if (is_new) {
1122 log_debug("(%d,%d) creating city %d, %s %s", TILE_XY(pcenter),
1125 }
1126
1128}
1129
1130/************************************************************************/
1135{
1136 struct city *pcity = game_city_by_number(packet->city);
1137 struct trade_route *proute;
1138 bool city_changed = FALSE;
1139
1140 if (pcity == NULL) {
1141 return;
1142 }
1143
1144 proute = trade_route_list_get(pcity->routes, packet->index);
1145 if (proute == NULL) {
1146 fc_assert(trade_route_list_size(pcity->routes) == packet->index);
1147
1148 proute = fc_malloc(sizeof(struct trade_route));
1151 }
1152
1153 proute->partner = packet->partner;
1154 proute->value = packet->value;
1155 proute->dir = packet->direction;
1156 proute->goods = goods_by_number(packet->goods);
1157
1161 }
1162}
1163
1164/************************************************************************/
1170{
1172 bool city_is_new = FALSE;
1173 bool name_changed = FALSE;
1175 struct city *pcity = game_city_by_number(packet->id);
1176 struct tile *pcenter = index_to_tile(&(wld.map), packet->tile);
1177 struct tile *ptile = NULL;
1178 struct tile_list *worked_tiles = NULL;
1179 struct player *powner = player_by_number(packet->owner);
1180 struct player *original = player_by_number(packet->original);
1181 int radius_sq = game.info.init_city_radius_sq;
1182
1183 fc_assert_ret_msg(NULL != powner, "Bad player number %d.", packet->owner);
1184 fc_assert_ret_msg(NULL != pcenter, "Invalid tile index %d.", packet->tile);
1185
1186 if (NULL != pcity) {
1187 ptile = city_tile(pcity);
1188
1189 if (NULL == ptile) {
1190 /* Invisible worked city */
1192 city_is_new = TRUE;
1193
1194 pcity->tile = pcenter;
1195 pcity->owner = powner;
1196 pcity->original = original;
1197
1199 if (wtile->worked == pcity) {
1201
1204 }
1205 }
1207 } else if (city_owner(pcity) != powner) {
1208 /* Remember what were the worked tiles. The server won't
1209 * send to us again. */
1211 pworked, _index, _x, _y) {
1212 if (pcity == tile_worked(pworked)) {
1213 if (NULL == worked_tiles) {
1214 worked_tiles = tile_list_new();
1215 }
1216 tile_list_append(worked_tiles, pworked);
1217 }
1219 radius_sq = city_map_radius_sq_get(pcity);
1221 pcity = NULL;
1223 }
1224 }
1225
1226 if (NULL == pcity) {
1227 city_is_new = TRUE;
1228 pcity = create_city_virtual(powner, pcenter, packet->name);
1229 pcity->id = packet->id;
1230 pcity->original = original;
1231 city_map_radius_sq_set(pcity, radius_sq);
1233 } else if (pcity->id != packet->id) {
1234 log_error("handle_city_short_info() city id %d != id %d.",
1235 pcity->id, packet->id);
1236 return;
1237 } else if (city_tile(pcity) != pcenter) {
1238 log_error("handle_city_short_info() city tile (%d, %d) != (%d, %d).",
1240 return;
1241 } else {
1242 name_changed = (fc_strncmp(packet->name, pcity->name, MAX_LEN_CITYNAME));
1243
1244 /* Check if city descriptions should be updated */
1247 }
1248
1249 city_name_set(pcity, packet->name);
1250
1251 memset(pcity->feel, 0, sizeof(pcity->feel));
1252 memset(pcity->specialists, 0, sizeof(pcity->specialists));
1253 }
1254
1255 pcity->specialists[DEFAULT_SPECIALIST] = packet->size;
1256 city_size_set(pcity, packet->size);
1257
1258 /* We can't actually see the internals of the city, but the server tells
1259 * us this much. */
1260 if (pcity->client.occupied != packet->occupied) {
1261 pcity->client.occupied = packet->occupied;
1264 }
1265 }
1266 pcity->client.walls = packet->walls;
1267 if (pcity->client.walls > NUM_WALL_TYPES) {
1268 pcity->client.walls = NUM_WALL_TYPES;
1269 }
1270 pcity->style = packet->style;
1271 pcity->capital = packet->capital;
1272 if (packet->capital == CAPITAL_PRIMARY) {
1273 powner->primary_capital_id = pcity->id;
1274 } else if (powner->primary_capital_id == pcity->id) {
1275 powner->primary_capital_id = 0;
1276 }
1277 pcity->client.city_image = packet->city_image;
1278
1279 pcity->client.happy = packet->happy;
1280 pcity->client.unhappy = packet->unhappy;
1281
1282 pcity->rapture = 0;
1283 pcity->anarchy = 0;
1284
1285 improvement_iterate(pimprove) {
1286 /* Don't update the non-visible improvements, they could hide the
1287 * previously seen information about the city (diplomat investigation).
1288 */
1289 if (is_improvement_visible(pimprove)) {
1290 bool have = BV_ISSET(packet->improvements,
1291 improvement_index(pimprove));
1293 }
1295
1296 city_packet_common(pcity, pcenter, powner, worked_tiles,
1298
1301 } else {
1303 }
1304
1305 /* Update the description if necessary. */
1306 if (update_descriptions) {
1308 }
1309}
1310
1311/************************************************************************/
1314void handle_worker_task(const struct packet_worker_task *packet)
1315{
1316 struct city *pcity = game_city_by_number(packet->city_id);
1317 struct worker_task *ptask = NULL;
1318
1319 if (pcity == NULL
1321 return;
1322 }
1323
1325 if (tile_index(ptask_old->ptile) == packet->tile_id) {
1326 ptask = ptask_old;
1327 break;
1328 }
1330
1331 if (ptask == NULL) {
1332 if (packet->activity == ACTIVITY_LAST) {
1333 return;
1334 } else {
1335 ptask = fc_malloc(sizeof(struct worker_task));
1336 worker_task_list_append(pcity->task_reqs, ptask);
1337 }
1338 } else {
1339 if (packet->activity == ACTIVITY_LAST) {
1340 worker_task_list_remove(pcity->task_reqs, ptask);
1341 free(ptask);
1342 ptask = NULL;
1343 }
1344 }
1345
1346 if (ptask != NULL) {
1347 ptask->ptile = index_to_tile(&(wld.map), packet->tile_id);
1348 ptask->act = packet->activity;
1349 if (packet->tgt >= 0) {
1350 ptask->tgt = extra_by_number(packet->tgt);
1351 } else {
1352 ptask->tgt = NULL;
1353 }
1354 ptask->want = packet->want;
1355 }
1356
1357 if (ptask && !worker_task_is_sane(ptask)) {
1358 log_debug("Bad worker task");
1359 worker_task_list_remove(pcity->task_reqs, ptask);
1360 free(ptask);
1361 ptask = NULL;
1362 return;
1363 }
1364
1366}
1367
1368/************************************************************************/
1371void handle_new_year(int year, int fragments, int turn)
1372{
1373 game.info.year = year;
1374 game.info.fragment_count = fragments;
1375 /*
1376 * The turn was increased in handle_end_turn()
1377 */
1378 fc_assert(game.info.turn == turn);
1380
1383
1385 menus_update();
1386
1388
1389#if 0
1390 /* This information shouldn't be needed, but if it is this is the only
1391 * way we can get it. */
1392 if (NULL != client.conn.playing) {
1396 }
1397#endif
1398
1401
1404 _("Start of turn %d"), game.info.turn);
1405 }
1406
1408
1409 if (last_turn != turn) {
1410 start_turn();
1411 last_turn = turn;
1412 }
1413}
1414
1415/************************************************************************/
1421{
1422 /* Messagewindow will contain events happened since our own phase ended,
1423 * so player of the first phase and last phase are in equal situation. */
1425}
1426
1427/************************************************************************/
1431void handle_start_phase(int phase)
1432{
1434 /* We are on detached state, let ignore this packet. */
1435 return;
1436 }
1437
1438 if (phase < 0
1440 && phase >= player_count())
1442 && phase >= team_count())) {
1443 log_error("handle_start_phase() illegal phase %d.", phase);
1444 return;
1445 }
1446
1448
1449 game.info.phase = phase;
1450
1451 /* Possibly replace wait cursor with something else */
1452 if (phase == 0) {
1453 /* TODO: Have server set as busy also if switching phase
1454 * is taking long in a alternating phases mode. */
1456 }
1457
1458 if (NULL != client.conn.playing
1459 && is_player_phase(client.conn.playing, phase)) {
1462
1464
1468 }
1469
1471
1475
1479
1481 }
1482
1484}
1485
1486/************************************************************************/
1491{
1492 log_debug("handle_begin_turn()");
1493
1494 /* Server is still considered busy until it handles also the beginning
1495 * of the first phase. */
1496
1498}
1499
1500/************************************************************************/
1505{
1506 log_debug("handle_end_turn()");
1507
1508 /* Make sure wait cursor is in use */
1510
1512
1513 /*
1514 * The local idea of the game.info.turn is increased here since the
1515 * client will get unit updates (reset of move points for example)
1516 * between handle_end_turn() and handle_new_year(). These
1517 * unit updates will look like they did take place in the old turn
1518 * which is incorrect. If we get the authoritative information about
1519 * the game.info.turn in handle_new_year() we will check it.
1520 */
1521 game.info.turn++;
1522
1523 log_verbose(_("Beginning turn %d"), game.info.turn);
1524
1526}
1527
1528/************************************************************************/
1532{
1533 const char *sound_tag = get_event_tag(type);
1534
1535 if (sound_tag) {
1536 audio_play_sound(sound_tag, NULL, NULL);
1537 }
1538}
1539
1540/************************************************************************/
1544void handle_chat_msg(const struct packet_chat_msg *packet)
1545{
1546 handle_event(packet->message,
1547 index_to_tile(&(wld.map), packet->tile),
1548 packet->event,
1549 packet->turn,
1550 packet->phase,
1551 packet->conn_id);
1552}
1553
1554/************************************************************************/
1565{
1566 handle_event(packet->message,
1567 index_to_tile(&(wld.map), packet->tile),
1568 packet->event,
1569 packet->turn,
1570 packet->phase,
1571 packet->conn_id);
1572}
1573
1574/************************************************************************/
1579{
1580 popup_connect_msg(_("Welcome"), message);
1581}
1582
1583/************************************************************************/
1587void handle_server_info(const char *version_label, int major_version,
1588 int minor_version, int patch_version, int emerg_version)
1589{
1590 if (emerg_version > 0) {
1591 log_verbose("Server has version %d.%d.%d.%d%s",
1592 major_version, minor_version, patch_version, emerg_version,
1593 version_label);
1594 } else {
1595 log_verbose("Server has version %d.%d.%d%s",
1596 major_version, minor_version, patch_version, version_label);
1597 }
1598}
1599
1600/************************************************************************/
1603void handle_page_msg(const char *caption, const char *headline,
1604 enum event_type event, int len, int parts)
1605{
1606 if (!client_has_player()
1608 || event != E_BROADCAST_REPORT) {
1609 if (page_msg_report.parts > 0) {
1610 /* Previous one was never finished */
1611 free(page_msg_report.caption);
1612 free(page_msg_report.headline);
1613 free(page_msg_report.lines);
1614 }
1615 page_msg_report.len = len;
1616 page_msg_report.event = event;
1619 page_msg_report.parts = parts;
1620 page_msg_report.lines = fc_malloc(len + 1);
1621 page_msg_report.lines[0] = '\0';
1622
1623 if (parts == 0) {
1624 /* Empty report - handle as if last part was just received. */
1625 page_msg_report.parts = 1;
1627 }
1628 }
1629}
1630
1631/************************************************************************/
1635{
1636 if (page_msg_report.lines != NULL) {
1637 /* We have already decided to show the message at the time we got
1638 * the header packet. */
1640 page_msg_report.parts--;
1641
1642 if (page_msg_report.parts == 0) {
1643 /* This is the final part */
1645 page_msg_report.headline,
1646 page_msg_report.lines);
1648
1649 free(page_msg_report.caption);
1650 free(page_msg_report.headline);
1651 free(page_msg_report.lines);
1652 page_msg_report.lines = NULL;
1653 }
1654 }
1655}
1656
1657/************************************************************************/
1660void handle_unit_info(const struct packet_unit_info *packet)
1661{
1662 struct unit *punit;
1663
1664 punit = unpackage_unit(packet);
1668 }
1669}
1670
1671/**********************************************************************/
1677{
1680 if (utype_can_do_action(unit_type_get(punit), act_id)) {
1681 /* An auto action like auto attack could be legal. Check for those
1682 * at once so they won't have to wait for player focus. */
1684 punit->id,
1687 EXTRA_NONE,
1689 return;
1690 }
1692 }
1693
1694 /* This should be done in the foreground */
1696}
1697
1698/************************************************************************/
1715{
1716 struct city *pcity;
1717 struct unit *punit;
1718 bool need_menus_update = FALSE;
1721 bool repaint_unit = FALSE;
1722 bool repaint_city = FALSE; /* regards unit's homecity */
1723 struct tile *old_tile = nullptr;
1724 bool check_focus = FALSE; /* conservative focus change */
1725 bool moved = FALSE;
1726 bool ret = FALSE;
1728 struct player *plr = client_player();
1729
1730 if (owner == nullptr) {
1731 punit = nullptr;
1732 } else {
1734 }
1735
1736 if (punit == nullptr && game_unit_by_number(packet_unit->id)) {
1737 /* This means unit has changed owner. We deal with this here
1738 * by simply deleting the old one and creating a new one. */
1740 }
1741
1742 if (punit != nullptr) {
1743 /* In some situations, the size of repaint units require can change;
1744 * in particular, city-builder units sometimes get a potential-city
1745 * outline, but to speed up redraws we don't repaint this whole area
1746 * unnecessarily. We need to ensure that when the footprint shrinks,
1747 * old bits aren't left behind on the canvas.
1748 * If the current (old) status of the unit is such that it gets a large
1749 * repaint, as a special case, queue a large repaint immediately, to
1750 * schedule the correct amount/location to be redrawn; but rely on the
1751 * repaint being deferred until the unit is updated, so that what's
1752 * drawn reflects the new status (e.g., no city outline). */
1755 }
1756
1757 ret = TRUE;
1758 punit->activity_count = packet_unit->activity_count;
1760 if (punit->ssa_controller != packet_unit->ssa_controller) {
1761 punit->ssa_controller = packet_unit->ssa_controller;
1763 /* AI is set: May change focus */
1764 /* AI is cleared: Keep focus */
1765 if (packet_unit->ssa_controller != SSA_NONE
1766 && unit_is_in_focus(punit)) {
1767 check_focus = TRUE;
1768 }
1769 }
1770
1771 if (punit->facing != packet_unit->facing) {
1772 punit->facing = packet_unit->facing;
1774 }
1775
1776 if (punit->activity != packet_unit->activity
1777 || punit->activity_target == packet_unit->activity_target
1778 || punit->client.transported_by != packet_unit->client.transported_by
1779 || punit->client.occupied != packet_unit->client.occupied
1780 || punit->has_orders != packet_unit->has_orders
1781 || punit->orders.repeat != packet_unit->orders.repeat
1782 || punit->orders.vigilant != packet_unit->orders.vigilant
1783 || punit->orders.index != packet_unit->orders.index) {
1784
1785 /*** Change in activity or activity's target. ***/
1786
1787 /* May change focus if focus unit gets a new activity.
1788 * But if new activity is Idle, it means user specifically selected
1789 * the unit */
1791 && (packet_unit->activity != ACTIVITY_IDLE
1792 || packet_unit->has_orders)) {
1793 check_focus = TRUE;
1794 }
1795
1797
1798 /* Wakeup Focus */
1800 && plr != nullptr
1801 && is_human(plr)
1802 && owner == plr
1804 && packet_unit->activity == ACTIVITY_IDLE
1806 && is_player_phase(plr, game.info.phase)) {
1807 /* Many wakeup units per tile are handled */
1809 check_focus = FALSE; /* and keep it */
1810 }
1811
1812 punit->activity = packet_unit->activity;
1813 punit->activity_target = packet_unit->activity_target;
1814
1816 != packet_unit->client.transported_by) {
1817 if (packet_unit->client.transported_by == -1) {
1818 /* The unit was unloaded from its transport. The check for a new
1819 * transport is done below. */
1821 }
1822
1823 punit->client.transported_by = packet_unit->client.transported_by;
1824 }
1825
1826 if (punit->client.occupied != packet_unit->client.occupied) {
1828 /* Special case: (un)loading a unit in a transporter on the same
1829 * tile as the focus unit may (dis)allow the focus unit to be
1830 * loaded. Thus the orders->(un)load menu item needs updating. */
1832 }
1833 punit->client.occupied = packet_unit->client.occupied;
1834 }
1835
1836 punit->has_orders = packet_unit->has_orders;
1837 punit->orders.length = packet_unit->orders.length;
1838 punit->orders.index = packet_unit->orders.index;
1839 punit->orders.repeat = packet_unit->orders.repeat;
1840 punit->orders.vigilant = packet_unit->orders.vigilant;
1841
1842 /* We cheat by just stealing the packet unit's list. */
1843 if (punit->orders.list) {
1845 }
1846 punit->orders.list = packet_unit->orders.list;
1847 packet_unit->orders.list = nullptr;
1848
1849 if (plr == nullptr || owner == plr) {
1851 }
1852 } /*** End of Change in activity or activity's target. ***/
1853
1854 /* These two lines force the menus to be updated as appropriate when
1855 * the focus unit changes. */
1856 if (unit_is_in_focus(punit)) {
1858 }
1859
1860 if (punit->homecity != packet_unit->homecity) {
1861 /* change homecity */
1862 struct city *hcity;
1863
1865 unit_list_remove(hcity->units_supported, punit);
1867 }
1868
1869 punit->homecity = packet_unit->homecity;
1871 unit_list_prepend(hcity->units_supported, punit);
1873 }
1874
1875 /* This can change total upkeep figures */
1877 }
1878
1879 if (punit->hp != packet_unit->hp) {
1880 /* hp changed */
1881 punit->hp = packet_unit->hp;
1883 }
1884
1886 /* Unit type has changed (been upgraded) */
1887 struct city *ccity = tile_city(unit_tile(punit));
1888
1892 if (ccity != NULL && (ccity->id != punit->homecity)) {
1894 }
1895 if (unit_is_in_focus(punit)) {
1896 /* Update the orders menu -- the unit might have new abilities */
1898 }
1900 }
1901
1902 /* May change focus if an attempted move or attack exhausted unit */
1903 if (punit->moves_left != packet_unit->moves_left
1904 && unit_is_in_focus(punit)) {
1905 check_focus = TRUE;
1906 }
1907
1909 /*** Change position ***/
1910 struct city *ccity = tile_city(unit_tile(punit));
1911
1913 moved = TRUE;
1914
1915 /* Show where the unit is going. */
1917
1918 if (ccity != nullptr) {
1920 /* Unit moved out of a city - update the occupied status. */
1921 bool new_occupied =
1922 (unit_list_size(ccity->tile->units) > 0);
1923
1924 if (ccity->client.occupied != new_occupied) {
1925 ccity->client.occupied = new_occupied;
1929 }
1930 }
1931 }
1932
1933 if (ccity->id == punit->homecity) {
1935 } else {
1937 }
1938 }
1939
1940 if ((ccity = tile_city(unit_tile(punit)))) {
1942 /* Unit moved into a city - obviously it's occupied. */
1943 if (!ccity->client.occupied) {
1944 ccity->client.occupied = TRUE;
1948 }
1949 }
1950 }
1951
1952 if (ccity->id == punit->homecity) {
1954 } else {
1956 }
1957 }
1958
1959 } /*** End of Change position. ***/
1960
1961 if (repaint_city || repaint_unit) {
1962 /* We repaint the city if the unit itself needs repainting or if
1963 * there is a special city-only redrawing to be done. */
1966 }
1968 && tile_city(unit_tile(punit)) != pcity) {
1969 /* Refresh the city we're occupying too. */
1971 }
1972 }
1973
1975 != packet_unit->upkeep[O_GOLD]);
1976 /* unit upkeep information */
1978 punit->upkeep[o] = packet_unit->upkeep[o];
1980
1981 punit->nationality = packet_unit->nationality;
1982 punit->veteran = packet_unit->veteran;
1983 punit->moves_left = packet_unit->moves_left;
1984 punit->fuel = packet_unit->fuel;
1985 punit->goto_tile = packet_unit->goto_tile;
1986 punit->paradropped = packet_unit->paradropped;
1987 punit->stay = packet_unit->stay;
1988 if (punit->done_moving != packet_unit->done_moving) {
1989 punit->done_moving = packet_unit->done_moving;
1990 check_focus = TRUE;
1991 }
1992 punit->carrying = packet_unit->carrying;
1993
1994 /* This won't change punit; it enqueues the call for later handling. */
1997
1998 if ((punit->action_decision_want != packet_unit->action_decision_want
2000 != packet_unit->action_decision_tile))
2002 /* The unit wants the player to decide. */
2004 /* Pop up an action selection dialog if the unit has focus or give
2005 * the unit higher priority in the focus queue if not. */
2006 punit->action_decision_tile = packet_unit->action_decision_tile;
2008 check_focus = TRUE;
2009 } else {
2010 /* Refresh already open action selection dialog. */
2014 tile_index(
2015 packet_unit->action_decision_tile),
2018 }
2019 }
2020 punit->action_decision_want = packet_unit->action_decision_want;
2021 punit->action_decision_tile = packet_unit->action_decision_tile;
2022 } else {
2023 /*** Create new unit ***/
2026
2027 if (owner != nullptr) {
2028 unit_list_prepend(owner->units, punit);
2029 }
2031
2033
2035 unit_list_prepend(pcity->units_supported, punit);
2036 }
2037
2038 log_debug("New %s %s id %d (%d %d) hc %d %s",
2042 (pcity ? city_name_get(pcity) : "(unknown)"));
2043
2046
2047 /* Check if we should link cargo units.
2048 * (This might be necessary if the cargo info was sent to us before
2049 * this transporter.) */
2050 if (punit->client.occupied) {
2052 if (aunit->client.transported_by == punit->id) {
2053 fc_assert(aunit->transporter == NULL);
2055 }
2057 }
2058
2059 if ((pcity = tile_city(unit_tile(punit)))) {
2060 /* The unit is in a city - obviously it's occupied. */
2062 }
2063
2065 /* The unit wants the player to decide. */
2067 check_focus = TRUE;
2068 }
2069
2071 } /*** End of Create new unit ***/
2072
2074
2075 /* Check if we have to load the unit on a transporter. */
2076 if (punit->client.transported_by != -1) {
2077 struct unit *ptrans
2078 = game_unit_by_number(packet_unit->client.transported_by);
2079
2080 /* Load unit only if transporter is known by the client.
2081 * (If not, cargo will be loaded later when the transporter info is
2082 * sent to the client.) */
2084 /* First, we have to unload the unit from its old transporter. */
2087
2088#ifdef DEBUG_TRANSPORT
2089 log_debug("load %s (ID: %d) onto %s (ID: %d)",
2092 } else if (ptrans && ptrans == unit_transport_get(punit)) {
2093 log_debug("%s (ID: %d) is loaded onto %s (ID: %d)",
2096 } else {
2097 log_debug("%s (ID: %d) is not loaded", unit_name_translation(punit),
2098 punit->id);
2099#endif /* DEBUG_TRANSPORT */
2100
2101 }
2102 }
2103
2108 /* Update (an possible active) unit select dialog. */
2110 }
2111
2112 if (repaint_unit) {
2114 }
2115
2116 if ((check_focus || get_num_units_in_focus() == 0)
2117 && plr != nullptr
2118 && is_human(plr)
2119 && is_player_phase(plr, game.info.phase)) {
2121 }
2122
2123 if (need_menus_update) {
2124 menus_update();
2125 }
2126
2127 if (!client_has_player() || owner == plr) {
2130 }
2133 }
2134 }
2135
2136 return ret;
2137}
2138
2139/************************************************************************/
2146{
2147 struct city *pcity = game_city_by_number(packet->city_id);
2148
2149 if (!pcity) {
2150 log_error("Investigate city: unknown city id %d!",
2151 packet->city_id);
2152 return;
2153 }
2154
2155 /* Start collecting supported and present units. */
2156
2157 /* Ensure we are not already in an investigate cycle. */
2158 fc_assert(pcity->client.collecting_info_units_supported == NULL);
2159 fc_assert(pcity->client.collecting_info_units_present == NULL);
2160 pcity->client.collecting_info_units_supported =
2162 pcity->client.collecting_info_units_present =
2164}
2165
2166/************************************************************************/
2170{
2171}
2172
2173/************************************************************************/
2177{
2178 struct city *pcity;
2179 struct unit *punit;
2180
2181 /* Special case for a diplomat/spy investigating a city: The investigator
2182 * needs to know the supported and present units of a city, whether or not
2183 * they are fogged. So, we send a list of them all before sending the city
2184 * info. */
2186 || packet->packet_use == UNIT_INFO_CITY_PRESENT) {
2187
2189 if (!pcity) {
2190 log_error("Investigate city: unknown city id %d!",
2191 packet->info_city_id);
2192 return;
2193 }
2194
2195 /* Append a unit struct to the proper list. */
2196 punit = unpackage_short_unit(packet);
2197 if (punit != nullptr) {
2198 if (packet->packet_use == UNIT_INFO_CITY_SUPPORTED) {
2199 fc_assert(pcity->client.collecting_info_units_supported != NULL);
2200 unit_list_append(pcity->client.collecting_info_units_supported, punit);
2201 } else {
2203 fc_assert(pcity->client.collecting_info_units_present != NULL);
2204 unit_list_append(pcity->client.collecting_info_units_present, punit);
2205 }
2206 }
2207
2208 /* Done with special case. */
2209 return;
2210 }
2211
2212 if (player_by_number(packet->owner) == client.conn.playing) {
2213 log_error("handle_unit_short_info() for own unit.");
2214 }
2215
2216 punit = unpackage_short_unit(packet);
2217 if (punit != nullptr && handle_unit_packet_common(punit)) {
2220 }
2221}
2222
2223/************************************************************************/
2226void handle_set_topology(int topology_id, int wrap_id)
2227{
2228 wld.map.topology_id = topology_id;
2229 wld.map.wrap_id = wrap_id;
2230
2231 if (forced_tileset_name[0] == '\0'
2232 && (tileset_map_topo_compatible(topology_id, tileset, NULL)
2235 const char *ts_to_load;
2236
2238
2239 if (ts_to_load != NULL && ts_to_load[0] != '\0' && strcmp(tileset_basename(tileset), ts_to_load)) {
2241 }
2242 }
2243}
2244
2245/************************************************************************/
2249void handle_map_info(const struct packet_map_info *packet)
2250{
2251 int ts_topo;
2252
2253 if (!map_is_empty()) {
2254 map_free(&(wld.map), FALSE);
2256 }
2257
2258 wld.map.xsize = packet->xsize;
2259 wld.map.ysize = packet->ysize;
2260
2264
2268 _("Map topology (%s) and tileset (%s) incompatible."),
2270 }
2271
2272 wld.map.topology_id = packet->topology_id;
2273 wld.map.wrap_id = packet->wrap_id;
2274
2279 mapdeco_init();
2280
2282
2284
2285 packhand_init();
2286}
2287
2288/************************************************************************/
2292{
2293 bool boot_help;
2295 bool toggle_edit_ui = FALSE;
2296
2297 if (game.info.aifill != pinfo->aifill) {
2299 }
2300 if (game.info.skill_level != pinfo->skill_level) {
2302 }
2303
2304 if (game.info.is_edit_mode != pinfo->is_edit_mode) {
2306
2308 /* Clears the current goto command. */
2310
2311 if (pinfo->is_edit_mode) {
2313 /* Gui didn't handle this */
2315 _("This scenario may have manually set properties the editor "
2316 "cannot handle."));
2318 _("They won't be saved when scenario is saved from the editor."));
2319 }
2320 }
2321 }
2322
2323 game.info = *pinfo;
2324
2325 /* check the values! */
2326#define VALIDATE(_count, _maximum, _string) \
2327 if (game.info._count > _maximum) { \
2328 log_error("handle_game_info(): Too many " _string "; using %d of %d", \
2329 _maximum, game.info._count); \
2330 game.info._count = _maximum; \
2331 }
2332
2333 VALIDATE(granary_num_inis, MAX_GRANARY_INIS, "granary entries");
2334#undef VALIDATE
2335
2340
2342 && game.info.victory_conditions != pinfo->victory_conditions);
2343 if (boot_help) {
2344 boot_help_texts(); /* reboot, after setting game.spacerace */
2345 }
2347 menus_update();
2351 }
2352
2353 if (can_client_change_view()) {
2355 }
2356
2357 if (toggle_edit_ui) {
2359 }
2360
2362}
2363
2364/************************************************************************/
2371
2372/************************************************************************/
2375void handle_timeout_info(float seconds_to_phasedone, float last_turn_change_time)
2376{
2377 if (current_turn_timeout() != 0 && seconds_to_phasedone >= 0) {
2378 /* If this packet is received in the middle of a turn, this value
2379 * represents the number of seconds from now to the end of the turn
2380 * (not from the start of the turn). So we need to restart our
2381 * timer. */
2382 set_seconds_to_turndone(seconds_to_phasedone);
2383 }
2384
2385 game.tinfo.last_turn_change_time = last_turn_change_time;
2386}
2387
2388/************************************************************************/
2400
2401/************************************************************************/
2410
2411/************************************************************************/
2416void handle_player_remove(int playerno)
2417{
2418 struct player_slot *pslot;
2419 struct player *pplayer;
2420 int plr_nbr;
2421
2422 pslot = player_slot_by_number(playerno);
2423
2424 if (NULL == pslot || !player_slot_is_used(pslot)) {
2425 /* Ok, just ignore. */
2426 return;
2427 }
2428
2429 pplayer = player_slot_get_player(pslot);
2430
2431 if (can_client_change_view()) {
2432 close_intel_dialog(pplayer);
2433 }
2434
2435 /* Update the connection information. */
2436 if (client_player() == pplayer) {
2438 }
2440 pconn->playing = NULL;
2442 conn_list_clear(pplayer->connections);
2443
2444 /* Save player number before player is freed */
2445 plr_nbr = player_number(pplayer);
2446
2447 player_destroy(pplayer);
2448
2451
2454}
2455
2456/************************************************************************/
2462{
2463 bool is_new_nation = FALSE;
2464 bool turn_done_changed = FALSE;
2465 bool new_player = FALSE;
2466 int i;
2467 struct player *pplayer, *my_player;
2468 struct nation_type *pnation;
2469 struct government *pgov, *ptarget_gov;
2470 struct player_slot *pslot;
2471 struct team_slot *tslot;
2472 bool gov_change;
2473
2474 /* Player. */
2475 pslot = player_slot_by_number(pinfo->playerno);
2476 fc_assert(NULL != pslot);
2478 pplayer = player_new(pslot);
2479
2480 if ((pplayer->rgb == NULL) != !pinfo->color_valid
2481 || (pinfo->color_valid
2482 && (pplayer->rgb->r != pinfo->color_red
2483 || pplayer->rgb->g != pinfo->color_green
2484 || pplayer->rgb->b != pinfo->color_blue))) {
2485 struct rgbcolor *prgbcolor;
2486
2487 if (pinfo->color_valid) {
2488 prgbcolor = rgbcolor_new(pinfo->color_red,
2489 pinfo->color_green,
2490 pinfo->color_blue);
2492 } else {
2493 prgbcolor = NULL;
2494 }
2495
2496 player_set_color(pplayer, prgbcolor);
2497 tileset_player_init(tileset, pplayer);
2498
2500
2501 /* Queue a map update -- may need to redraw borders, etc. */
2503 }
2504 pplayer->client.color_changeable = pinfo->color_changeable;
2505
2506 if (new_player) {
2507 /* Initialise client side player data (tile vision). At the moment
2508 * redundant as the values are initialised with 0 due to fc_calloc(). */
2509 client_player_init(pplayer);
2510 }
2511
2512 /* Team. */
2514 fc_assert(NULL != tslot);
2515
2516 /* Should never fail when slot given is not nullptr */
2517 team_add_player(pplayer, team_new(tslot));
2518
2519 pnation = nation_by_number(pinfo->nation);
2520 pgov = government_by_number(pinfo->government);
2521 ptarget_gov = government_by_number(pinfo->target_government);
2522
2523 /* Now update the player information. */
2524 sz_strlcpy(pplayer->name, pinfo->name);
2525 sz_strlcpy(pplayer->username, pinfo->username);
2526 pplayer->unassigned_user = pinfo->unassigned_user;
2527
2528 is_new_nation = player_set_nation(pplayer, pnation);
2529 pplayer->is_male = pinfo->is_male;
2530 pplayer->score.game = pinfo->score;
2531 pplayer->was_created = pinfo->was_created;
2532
2533 pplayer->autoselect_weight = pinfo->autoselect_weight;
2534 pplayer->economic.gold = pinfo->gold;
2535 pplayer->economic.tax = pinfo->tax;
2536 pplayer->economic.science = pinfo->science;
2537 pplayer->economic.luxury = pinfo->luxury;
2538 pplayer->client.tech_upkeep = pinfo->tech_upkeep;
2539 gov_change = (!new_player && pgov != pplayer->government
2540 && pplayer->government != NULL);
2541 pplayer->government = pgov;
2542 pplayer->target_government = ptarget_gov;
2543 pplayer->real_embassy = pinfo->real_embassy;
2544 pplayer->gives_shared_vision = pinfo->gives_shared_vision;
2545 pplayer->gives_shared_tiles = pinfo->gives_shared_tiles;
2546 pplayer->style = style_by_number(pinfo->style);
2547
2548 if (pplayer == client.conn.playing) {
2549 bool music_change = FALSE;
2550
2551 if (pplayer->music_style != pinfo->music_style) {
2552 pplayer->music_style = pinfo->music_style;
2554 }
2555 if (pplayer->client.mood != pinfo->mood) {
2556 pplayer->client.mood = pinfo->mood;
2558 }
2559
2560 if (music_change) {
2562 }
2563
2564 if (gov_change) {
2565 audio_play_sound(pgov->sound_str, pgov->sound_alt, pgov->sound_alt2);
2566 }
2567 }
2568
2569 pplayer->history = pinfo->history;
2570 pplayer->client.culture = pinfo->culture;
2571
2572 if (pplayer->economic.infra_points != pinfo->infrapoints) {
2573 pplayer->economic.infra_points = pinfo->infrapoints;
2575 }
2576
2577 /* Don't use player_iterate or player_slot_count here, because we ignore
2578 * the real number of players and we want to read all the datas. */
2579 fc_assert(ARRAY_SIZE(pplayer->ai_common.love) >= ARRAY_SIZE(pinfo->love));
2580 for (i = 0; i < ARRAY_SIZE(pinfo->love); i++) {
2581 pplayer->ai_common.love[i] = pinfo->love[i];
2582 }
2583
2585
2586 pplayer->is_connected = pinfo->is_connected;
2587
2588 for (i = 0; i < B_LAST; i++) {
2589 pplayer->wonders[i] = pinfo->wonders[i];
2590 }
2591
2592 /* Set AI.control. */
2593 if (is_ai(pplayer) != BV_ISSET(pinfo->flags, PLRF_AI)) {
2594 BV_SET_VAL(pplayer->flags, PLRF_AI, BV_ISSET(pinfo->flags, PLRF_AI));
2595 if (pplayer == my_player) {
2596 if (is_ai(my_player)) {
2597 output_window_append(ftc_client, _("AI mode is now ON."));
2598 if (!gui_options.ai_manual_turn_done && !pplayer->phase_done) {
2599 /* End turn immediately */
2601 }
2602 } else {
2603 output_window_append(ftc_client, _("AI mode is now OFF."));
2604 }
2605 }
2606 }
2607
2608 pplayer->flags = pinfo->flags;
2609
2610 pplayer->ai_common.science_cost = pinfo->science_cost;
2611
2612 turn_done_changed = (pplayer->phase_done != pinfo->phase_done
2613 || (BV_ISSET(pplayer->flags, PLRF_AI) !=
2614 BV_ISSET(pinfo->flags, PLRF_AI)));
2615 pplayer->phase_done = pinfo->phase_done;
2616
2617 pplayer->is_ready = pinfo->is_ready;
2618 pplayer->nturns_idle = pinfo->nturns_idle;
2619 pplayer->is_alive = pinfo->is_alive;
2620 pplayer->turns_alive = pinfo->turns_alive;
2621 pplayer->ai_common.barbarian_type = pinfo->barbarian_type;
2622 pplayer->revolution_finishes = pinfo->revolution_finishes;
2623 pplayer->ai_common.skill_level = pinfo->ai_skill_level;
2624
2625 fc_assert(pinfo->multip_count == multiplier_count());
2626 game.control.num_multipliers = pinfo->multip_count;
2627 multipliers_iterate(pmul) {
2628 int idx = multiplier_index(pmul);
2629
2630 pplayer->multipliers[idx].value = pinfo->multiplier[idx];
2631 pplayer->multipliers[idx].target = pinfo->multiplier_target[idx];
2632 pplayer->multipliers[idx].changed = pinfo->multiplier_changed[idx];
2634
2635 /* if the server requests that the client reset, then information about
2636 * connections to this player are lost. If this is the case, insert the
2637 * correct conn back into the player->connections list */
2638 if (conn_list_size(pplayer->connections) == 0) {
2640 if (pplayer == pconn->playing) {
2641 /* insert the controller into first position */
2642 if (pconn->observer) {
2644 } else {
2646 }
2647 }
2649 }
2650
2651
2652 /* The player information is now fully set. Update the GUI. */
2653
2654 if (pplayer == my_player && can_client_change_view()) {
2655 if (turn_done_changed) {
2657 }
2664 menus_update();
2665 }
2666
2668
2671
2672 if (is_new_nation) {
2674
2675 /* When changing nation during a running game, some refreshing is needed.
2676 * This may not be the only one! */
2678 }
2679
2680 if (can_client_change_view()) {
2681 /* Just about any changes above require an update to the intelligence
2682 * dialog. */
2683 update_intel_dialog(pplayer);
2684 }
2685
2688 FALSE);
2689}
2690
2691/************************************************************************/
2695{
2696 struct research *presearch;
2697 bool tech_changed = FALSE;
2698 bool poptechup = FALSE;
2700 int gained_techs_num = 0, i;
2702
2703#ifdef FREECIV_DEBUG
2704 log_verbose("Research nb %d inventions: %s",
2705 packet->id,
2706 packet->inventions);
2707#endif
2708 presearch = research_by_number(packet->id);
2710
2711 poptechup = (presearch->researching != packet->researching
2712 || presearch->tech_goal != packet->tech_goal);
2713 presearch->techs_researched = packet->techs_researched;
2714 if (presearch->future_tech == 0 && packet->future_tech > 0) {
2716 }
2717 presearch->future_tech = packet->future_tech;
2718 presearch->researching = packet->researching;
2719 presearch->client.researching_cost = packet->researching_cost;
2720 presearch->bulbs_researched = packet->bulbs_researched;
2721 presearch->tech_goal = packet->tech_goal;
2722 presearch->client.total_bulbs_prod = packet->total_bulbs_prod;
2723
2725 newstate = packet->inventions[advi] - '0';
2727
2728 if (newstate != oldstate) {
2729 if (TECH_KNOWN == newstate) {
2731 if (A_NONE != advi) {
2733 }
2734 } else if (TECH_KNOWN == oldstate) {
2736 }
2737 }
2739
2741
2742 if (C_S_RUNNING == client_state()) {
2744 if (poptechup && is_human(client_player())) {
2746 }
2748 if (tech_changed) {
2749 /* Some ways a new or lost tech can affect menus:
2750 * - If tech is needed for certain governments, the government
2751 * switching menus need updating.
2752 * - If we just learned/lost bridge building and focus is on a
2753 * worker on a river, the road menu item needs updating. */
2754 menus_update();
2755
2756 script_client_signal_emit("new_tech");
2757
2758 /* If we got a new tech the tech tree news an update. */
2760 }
2761 for (i = 0; i < gained_techs_num; i++) {
2763 }
2764 }
2765 if (editor_is_active()) {
2769 FALSE);
2771 }
2772 }
2773}
2774
2775/************************************************************************/
2779{
2781
2782 if (presearch == NULL) {
2783 log_error("Received unknown research for clearing: %d.", id);
2784 return;
2785 }
2786
2787 /* Do we need to set other fields? */
2788 presearch->researching = A_UNKNOWN;
2789 presearch->future_tech = 0;
2790 presearch->tech_goal = A_UNKNOWN;
2791
2795
2796 if (editor_is_active()) {
2800 FALSE);
2802 }
2803}
2804
2805/************************************************************************/
2809{
2810 struct player *plr1 = player_by_number(packet->plr1);
2811 struct player *plr2 = player_by_number(packet->plr2);
2812 struct player *my_player = client_player();
2813 struct player_diplstate *ds = player_diplstate_get(plr1, plr2);
2815
2816 fc_assert_ret(ds != NULL);
2817
2818 if (client_has_player() && my_player == plr2) {
2819 if (ds->type != packet->type) {
2821 }
2822
2823 /* Check if we detect change to armistice with us. If so,
2824 * ready all units for movement out of the territory in
2825 * question; otherwise they will be disbanded. */
2827 && DS_ARMISTICE == packet->type) {
2830 || tile_owner(unit_tile(punit)) != plr1) {
2831 continue;
2832 }
2835 }
2836 if (punit->activity != ACTIVITY_IDLE) {
2838 }
2840 }
2841 }
2842
2843 ds->type = packet->type;
2844 ds->turns_left = packet->turns_left;
2845 ds->has_reason_to_cancel = packet->has_reason_to_cancel;
2846 ds->contact_turns_left = packet->contact_turns_left;
2847
2850 }
2851
2854 /* An action selection dialog is open and our diplomatic state just
2855 * changed. Find out if the relationship that changed was to a
2856 * potential target. */
2857 struct tile *tgt_tile = NULL;
2858
2859 /* Is a refresh needed because of a unit target? */
2861 struct unit *tgt_unit;
2862
2864
2865 if (tgt_unit != NULL && tgt_unit->owner == plr1) {
2866 /* An update is needed because of this unit target. */
2869 }
2870 }
2871
2872 /* Is a refresh needed because of a city target? */
2874 struct city *tgt_city;
2875
2877
2878 if (tgt_city != NULL && tgt_city->owner == plr1) {
2879 /* An update is needed because of this city target.
2880 * Overwrites any target tile from a unit. */
2883 }
2884 }
2885
2886 if (tgt_tile
2887 || ((tgt_tile = index_to_tile(&(wld.map),
2889 && tile_owner(tgt_tile) == plr1)) {
2890 /* The diplomatic relationship to the target in an open action
2891 * selection dialog have changed. This probably changes
2892 * the set of available actions. */
2896 tgt_tile->index,
2899 }
2900 }
2901}
2902
2903/************************************************************************/
2910{
2911 struct connection *pconn = conn_by_number(pinfo->id);
2913
2914 log_debug("conn_info id%d used%d est%d plr%d obs%d acc%d",
2915 pinfo->id, pinfo->used, pinfo->established, pinfo->player_num,
2916 pinfo->observer, (int) pinfo->access_level);
2917 log_debug("conn_info \"%s\" \"%s\" \"%s\"",
2918 pinfo->username, pinfo->addr, pinfo->capability);
2919
2920 if (!pinfo->used) {
2921 /* Forget the connection */
2922 if (!pconn) {
2923 log_verbose("Server removed unknown connection %d", pinfo->id);
2924 return;
2925 }
2927 pconn = NULL;
2928 } else {
2929 struct player_slot *pslot = player_slot_by_number(pinfo->player_num);
2930 struct player *pplayer = NULL;
2931
2932 if (NULL != pslot) {
2933 pplayer = player_slot_get_player(pslot);
2934 }
2935
2936 if (!pconn) {
2937 log_verbose("Server reports new connection %d %s",
2938 pinfo->id, pinfo->username);
2939
2940 pconn = fc_calloc(1, sizeof(struct connection));
2941 pconn->buffer = NULL;
2942 pconn->send_buffer = NULL;
2943 pconn->ping_time = -1.0;
2944 if (pplayer) {
2946 }
2949 } else {
2950 log_packet("Server reports updated connection %d %s",
2951 pinfo->id, pinfo->username);
2952 if (pplayer != pconn->playing) {
2953 if (NULL != pconn->playing) {
2954 conn_list_remove(pconn->playing->connections, pconn);
2955 }
2956 if (pplayer) {
2958 }
2959 }
2960 }
2961
2962 pconn->id = pinfo->id;
2963 pconn->established = pinfo->established;
2964 pconn->observer = pinfo->observer;
2965 pconn->access_level = pinfo->access_level;
2966 pconn->playing = pplayer;
2967
2968 sz_strlcpy(pconn->username, pinfo->username);
2969 sz_strlcpy(pconn->addr, pinfo->addr);
2970 sz_strlcpy(pconn->capability, pinfo->capability);
2971
2972 if (pinfo->id == client.conn.id) {
2973 /* NB: In this case, pconn is not a duplication of client.conn.
2974 *
2975 * pconn->addr is our address that the server knows whereas
2976 * client.conn.addr is the address to the server. Also,
2977 * pconn->capability stores our capabilites known at server side
2978 * whereas client.conn.capability represents the capabilities of the
2979 * server. */
2980 if (client.conn.playing != pplayer
2981 || client.conn.observer != pinfo->observer) {
2982 /* Our connection state changed, let prepare the changes and reset
2983 * the game. */
2985 }
2986
2987 /* Copy our current state into the static structure (our connection
2988 * to the server). */
2989 client.conn.established = pinfo->established;
2990 client.conn.observer = pinfo->observer;
2991 client.conn.access_level = pinfo->access_level;
2992 client.conn.playing = pplayer;
2993 sz_strlcpy(client.conn.username, pinfo->username);
2994 }
2995 }
2996
2999
3000 if (pinfo->used && pinfo->id == client.conn.id) {
3001 /* For updating the sensitivity of the "Edit Mode" menu item,
3002 * among other things. */
3003 menus_update();
3004 }
3005
3008 }
3009}
3010
3011/************************************************************************/
3015void handle_conn_ping_info(int connections, const int *conn_id,
3016 const float *ping_time)
3017{
3018 int i;
3019
3020 for (i = 0; i < connections; i++) {
3021 struct connection *pconn = conn_by_number(conn_id[i]);
3022
3023 if (!pconn) {
3024 continue;
3025 }
3026
3027 pconn->ping_time = ping_time[i];
3028 log_debug("conn-id=%d, ping=%fs", pconn->id, pconn->ping_time);
3029 }
3030 /* The old_ping_time data is ignored. */
3031
3033}
3034
3035/************************************************************************/
3038void handle_achievement_info(int id, bool gained, bool first)
3039{
3040 struct achievement *pach;
3041
3043 log_error("Received illegal achievement info %d", id);
3044 return;
3045 }
3046
3048
3049 if (gained) {
3050 BV_SET(pach->achievers, player_index(client_player()));
3051 } else {
3052 BV_CLR(pach->achievers, player_index(client_player()));
3053 }
3054
3055 if (first) {
3056 pach->first = client_player();
3057 }
3058}
3059
3060/************************************************************************/
3075static bool spaceship_autoplace(struct player *pplayer,
3076 struct player_spaceship *ship)
3077{
3080
3081 if (next_spaceship_component(pplayer, ship, &place)) {
3083
3084 return TRUE;
3085 }
3086 }
3087
3088 return FALSE;
3089}
3090
3091/************************************************************************/
3095{
3096 struct player_spaceship *ship;
3097 struct player *pplayer = player_by_number(p->player_num);
3098
3099 fc_assert_ret_msg(NULL != pplayer, "Invalid player number %d.",
3100 p->player_num);
3101
3102 ship = &pplayer->spaceship;
3103 ship->state = p->sship_state;
3104 ship->structurals = p->structurals;
3105 ship->components = p->components;
3106 ship->modules = p->modules;
3107 ship->fuel = p->fuel;
3108 ship->propulsion = p->propulsion;
3109 ship->habitation = p->habitation;
3110 ship->life_support = p->life_support;
3111 ship->solar_panels = p->solar_panels;
3112 ship->launch_year = p->launch_year;
3113 ship->population = p->population;
3114 ship->mass = p->mass;
3115 ship->support_rate = p->support_rate;
3116 ship->energy_rate = p->energy_rate;
3117 ship->success_rate = p->success_rate;
3118 ship->travel_time = p->travel_time;
3119 ship->structure = p->structure;
3120
3121 if (pplayer != client_player()) {
3122 refresh_spaceship_dialog(pplayer);
3123 menus_update();
3124 return;
3125 }
3126
3127 if (!spaceship_autoplace(pplayer, ship)) {
3128 /* We refresh the dialog when the packet did *not* cause placing
3129 * of new part. That's because those cases where part is placed, are
3130 * followed by exactly one case where there's no more parts to place -
3131 * we want to refresh the dialog only when that last packet comes. */
3132 refresh_spaceship_dialog(pplayer);
3133 }
3134}
3135
3136/**********************************************************************/
3142{
3143 if (cont1 == cont2) {
3144 return nullptr;
3145 } else if (cont1 >= 0 && cont2 <= 0) {
3146 return &wld.map.client.adj_matrix[cont1][-cont2];
3147 } else if (cont1 <= 0 && cont2 >= 0) {
3148 return &wld.map.client.adj_matrix[cont2][-cont1];
3149 }
3150 return nullptr;
3151}
3152
3153/**********************************************************************/
3160static inline void update_continent_cache(const struct tile *ptile,
3163{
3164 /* Update known continents */
3166 int cont;
3167
3168 /* Expand sizes array */
3170 (new_cont + 1) * sizeof(*wld.map.continent_sizes));
3171
3172 /* Expand adjacency matrix */
3174 (new_cont + 1) * sizeof(*wld.map.client.adj_matrix));
3175
3176 /* Initialize new spots */
3177 for (cont = wld.map.num_continents + 1; cont <= new_cont; cont++) {
3178 wld.map.continent_sizes[cont] = 0;
3180 sizeof(*wld.map.client.adj_matrix[cont]));
3181 }
3182
3184 } else if (new_cont < -wld.map.num_oceans) {
3185 int cont, ocean;
3186
3187 /* Expand sizes array */
3189 (-new_cont + 1) * sizeof(*wld.map.ocean_sizes));
3190
3191 /* Initialize new spots */
3192 for (ocean = wld.map.num_oceans + 1; ocean <= -new_cont; ocean++) {
3193 wld.map.ocean_sizes[ocean] = 0;
3194 }
3195
3196 /* Expand adjacency matrix */
3197 for (cont = 0; cont <= wld.map.num_continents; cont++) {
3199 wld.map.client.adj_matrix[cont],
3200 (-new_cont + 1) * sizeof(*wld.map.client.adj_matrix[cont])
3201 );
3202
3203 for (ocean = wld.map.num_oceans + 1; ocean <= -new_cont; ocean++) {
3204 wld.map.client.adj_matrix[cont][ocean] = 0;
3205 }
3206 }
3207
3209 }
3210
3211 /* Decrement old continent/ocean size */
3212 if (old_cont > 0) {
3214 } else if (old_cont < 0) {
3216 }
3217
3218 /* Increment new continent/ocean size */
3219 if (new_cont > 0) {
3221 } else if (new_cont < 0) {
3223 }
3224
3225 /* Update tile adjacency counts */
3226 adjc_iterate(&(wld.map), ptile, adj_tile) {
3228 int *padjc_count;
3229
3230 /* Decrement old adjacency */
3232 if (padjc_count) {
3233 fc_assert(*padjc_count > 0);
3234 (*padjc_count)--;
3235 }
3236
3237 /* Increment new adjacency */
3239 if (padjc_count) {
3240 (*padjc_count)++;
3241 }
3243}
3244
3245/************************************************************************/
3248void handle_tile_info(const struct packet_tile_info *packet)
3249{
3250 enum known_type new_known;
3251 enum known_type old_known;
3252 bool known_changed = FALSE;
3253 bool tile_changed = FALSE;
3254 struct player *powner = player_by_number(packet->owner);
3255 struct player *eowner = player_by_number(packet->extras_owner);
3256 struct extra_type *presource = NULL;
3257 struct terrain *pterrain = terrain_by_number(packet->terrain);
3258 struct tile *ptile = index_to_tile(&(wld.map), packet->tile);
3259
3260 fc_assert_ret_msg(NULL != ptile, "Invalid tile index %d.", packet->tile);
3262
3263 if (packet->resource != MAX_EXTRA_TYPES) {
3264 presource = extra_by_number(packet->resource);
3265 }
3266
3267 if (NULL == tile_terrain(ptile) || pterrain != tile_terrain(ptile)) {
3269 switch (old_known) {
3270 case TILE_UNKNOWN:
3271 tile_set_terrain(ptile, pterrain);
3272 break;
3273 case TILE_KNOWN_UNSEEN:
3274 case TILE_KNOWN_SEEN:
3275 if (NULL != pterrain || TILE_UNKNOWN == packet->known) {
3276 tile_set_terrain(ptile, pterrain);
3277 } else {
3279 log_error("handle_tile_info() unknown terrain (%d, %d).",
3280 TILE_XY(ptile));
3281 }
3282 break;
3283 };
3284 }
3285
3286 if (!BV_ARE_EQUAL(ptile->extras, packet->extras)) {
3287 ptile->extras = packet->extras;
3289 }
3290
3291 tile_changed = tile_changed || (tile_resource(ptile) != presource);
3292
3293 /* Always called after setting terrain */
3294 tile_set_resource(ptile, presource);
3295
3296 if (tile_owner(ptile) != powner) {
3297 tile_set_owner(ptile, powner, NULL);
3299 }
3300 if (extra_owner(ptile) != eowner) {
3301 ptile->extras_owner = eowner;
3303 }
3304
3305 ptile->altitude = packet->altitude;
3306
3307 if (packet->placing < 0) {
3308 if (ptile->placing != NULL) {
3310 ptile->placing = NULL;
3311 ptile->infra_turns = 0;
3312 }
3313 } else {
3314 struct extra_type *old = ptile->placing;
3315
3316 ptile->placing = extra_by_number(packet->placing);
3317 if (ptile->placing != old
3318 || ptile->infra_turns != packet->place_turn - game.info.turn) {
3320 }
3321 ptile->infra_turns = packet->place_turn - game.info.turn;
3322 }
3323
3324 if (NULL == tile_worked(ptile)
3325 || tile_worked(ptile)->id != packet->worked) {
3326 if (IDENTITY_NUMBER_ZERO != packet->worked) {
3327 struct city *pwork = game_city_by_number(packet->worked);
3328
3329 if (NULL == pwork) {
3330 char named[MAX_LEN_CITYNAME];
3331
3332 /* New unseen ("invisible") city, or before city_info */
3333 fc_snprintf(named, sizeof(named), "%06u", packet->worked);
3334
3335 pwork = create_city_virtual(invisible.placeholder, NULL, named);
3336 pwork->id = packet->worked;
3338
3340
3341 log_debug("(%d,%d) invisible city %d, %s",
3342 TILE_XY(ptile), pwork->id, city_name_get(pwork));
3343 } else if (NULL == city_tile(pwork)) {
3344 /* Old unseen ("invisible") city, or before city_info */
3345 if (NULL != powner && city_owner(pwork) != powner) {
3346 /* Update placeholder with current owner */
3347 pwork->owner = powner;
3348 pwork->original = NULL;
3349 }
3350 } else {
3351 /* We have a real (not invisible) city record for this ID, but
3352 * perhaps our info about that city is out of date. */
3353 int dist_sq = sq_map_distance(city_tile(pwork), ptile);
3354
3356 /* This is probably enemy city which has grown in diameter since we
3357 * last saw it. We need city_radius_sq to be at least big enough so
3358 * that all workers fit in, so set it so. */
3360 }
3361 /* This might be a known city that is open in a dialog.
3362 * (And this might be our only prompt to refresh the worked tiles
3363 * display in its city map, if a worker rearrangement does not
3364 * change anything else about the city such as output.) */
3365 {
3366 struct city *oldwork = tile_worked(ptile);
3367 if (oldwork && NULL != city_tile(oldwork)) {
3368 /* Refresh previous city too if it's real and different */
3370 }
3371 /* Refresh new city working tile (which we already know is real) */
3373 }
3374 }
3375
3376 /* This marks tile worked by (possibly invisible) city. Other
3377 * parts of the code have to handle invisible cities correctly
3378 * (ptile->worked->tile == NULL) */
3379 tile_set_worked(ptile, pwork);
3380 } else {
3381 /* Tile is no longer being worked by a city.
3382 * (Again, this might be our only prompt to refresh the worked tiles
3383 * display for the previous working city.) */
3384 if (tile_worked(ptile) && NULL != city_tile(tile_worked(ptile))) {
3386 }
3387 tile_set_worked(ptile, NULL);
3388 }
3389
3391 }
3392
3393 if (old_known != packet->known) {
3395 }
3396
3397 if (NULL != client.conn.playing) {
3402
3403 switch (packet->known) {
3404 case TILE_KNOWN_SEEN:
3409 break;
3410 case TILE_KNOWN_UNSEEN:
3412 break;
3413 case TILE_UNKNOWN:
3414 break;
3415 default:
3416 log_error("handle_tile_info() invalid known (%d).", packet->known);
3417 break;
3418 };
3419 }
3421
3422 if (packet->spec_sprite[0] != '\0') {
3423 if (!ptile->spec_sprite
3424 || strcmp(ptile->spec_sprite, packet->spec_sprite) != 0) {
3425 if (ptile->spec_sprite) {
3426 free(ptile->spec_sprite);
3427 }
3428 ptile->spec_sprite = fc_strdup(packet->spec_sprite);
3430 }
3431 } else {
3432 if (ptile->spec_sprite) {
3433 free(ptile->spec_sprite);
3434 ptile->spec_sprite = NULL;
3436 }
3437 }
3438
3440 /* This is an error. So first we log the error,
3441 * then make an assertion. */
3442 unit_list_iterate(ptile->units, punit) {
3443 log_error("%p %d %s at (%d,%d) %s", punit, punit->id,
3447 fc_assert_msg(0 == unit_list_size(ptile->units), "Ghost units seen");
3448 /* Repairing... */
3449 unit_list_clear(ptile->units);
3450 }
3451
3452 if (ptile->continent != packet->continent) {
3453 update_continent_cache(ptile, ptile->continent, packet->continent);
3454 }
3455 ptile->continent = packet->continent;
3456
3457 if (packet->label[0] == '\0') {
3458 if (ptile->label != NULL) {
3459 FC_FREE(ptile->label);
3460 ptile->label = NULL;
3462 }
3463 } else if (ptile->label == NULL || strcmp(packet->label, ptile->label)) {
3464 tile_set_label(ptile, packet->label);
3466 }
3467
3468 if (known_changed || tile_changed) {
3469 /*
3470 * A tile can only change if it was known before and is still
3471 * known. In the other cases the tile is new or removed.
3472 */
3474 agents_tile_new(ptile);
3475 } else if (known_changed && TILE_KNOWN_UNSEEN == new_known) {
3476 agents_tile_remove(ptile);
3477 } else {
3478 agents_tile_changed(ptile);
3479 }
3481 }
3482
3483 /* refresh tiles */
3484 if (can_client_change_view()) {
3485 /* the tile itself (including the necessary parts of adjacent tiles) */
3486 if (tile_changed || old_known != new_known) {
3488 }
3489 }
3490
3491 /* update menus if the focus unit is on the tile. */
3492 if (tile_changed) {
3493 if (get_focus_unit_on_tile(ptile)) {
3494 menus_update();
3495 }
3496 }
3497
3498 /* FIXME: we really ought to call refresh_city_dialog() for any city
3499 * whose radii include this tile, to update the city map display.
3500 * But that would be expensive. We deal with the (common) special
3501 * case of changes in worked tiles above. */
3502}
3503
3504/************************************************************************/
3524
3525/************************************************************************/
3528void handle_scenario_description(const char *description)
3529{
3531
3533}
3534
3535/************************************************************************/
3541{
3542 /* The ruleset is going to load new nations. So close
3543 * the nation selection dialog if it is open. */
3545
3551 game.control = *packet;
3552
3553 /* check the values! */
3554#define VALIDATE(_count, _maximum, _string) \
3555 if (game.control._count > _maximum) { \
3556 log_error("handle_ruleset_control(): Too many " _string \
3557 "; using %d of %d", _maximum, game.control._count); \
3558 game.control._count = _maximum; \
3559 }
3560
3561 VALIDATE(num_unit_classes, UCL_LAST, "unit classes");
3562 VALIDATE(num_unit_types, U_LAST, "unit types");
3563 VALIDATE(num_impr_types, B_LAST, "improvements");
3564 VALIDATE(num_tech_types, A_LAST, "advances");
3565 VALIDATE(num_base_types, MAX_EXTRA_TYPES, "bases");
3566 VALIDATE(num_road_types, MAX_EXTRA_TYPES, "roads");
3567 VALIDATE(num_resource_types, MAX_EXTRA_TYPES, "resources");
3568 VALIDATE(num_disaster_types, MAX_DISASTER_TYPES, "disasters");
3569 VALIDATE(num_achievement_types, MAX_ACHIEVEMENT_TYPES, "achievements");
3570 VALIDATE(num_counters, MAX_COUNTERS, "counters");
3571
3572 /* game.control.government_count, game.control.nation_count and
3573 * game.control.num_city_styles are allocated dynamically, and do
3574 * not need a size check. See the allocation below. */
3575
3577
3578 VALIDATE(num_specialist_types, SP_MAX, "specialists");
3579#undef VALIDATE
3580
3586
3587 if (game.control.desc_length > 0) {
3589 game.ruleset_description[0] = '\0';
3590 }
3591
3592 if (packet->preferred_tileset[0] != '\0') {
3593 /* There is tileset suggestion */
3595 /* It's not currently in use */
3598 } else {
3600 }
3601 }
3602 }
3603
3604 if (packet->preferred_soundset[0] != '\0') {
3605 /* There is soundset suggestion */
3607 /* It's not currently in use */
3610 } else {
3612 }
3613 }
3614 }
3615
3616 if (packet->preferred_musicset[0] != '\0') {
3617 /* There is musicset suggestion */
3619 /* It's not currently in use */
3622 } else {
3624 }
3625 }
3626 }
3627
3629
3631}
3632
3633/************************************************************************/
3637{
3638 int len;
3639
3640 if (game.ruleset_summary != NULL) {
3642 }
3643
3644 len = strlen(packet->text);
3645
3647
3648 fc_strlcpy(game.ruleset_summary, packet->text, len + 1);
3649}
3650
3651/************************************************************************/
3660
3661/************************************************************************/
3665{
3666 /* Setup extra hiders caches */
3667 extra_type_iterate(pextra) {
3668 pextra->hiders = extra_type_list_new();
3670 if (BV_ISSET(pextra->hidden_by, extra_index(phider))) {
3671 extra_type_list_append(pextra->hiders, phider);
3672 }
3674 pextra->bridged = extra_type_list_new();
3676 if (BV_ISSET(pextra->bridged_over, extra_index(pbridged))) {
3677 extra_type_list_append(pextra->bridged, pbridged);
3678 }
3681
3686
3687 /* Setup improvement feature caches */
3689
3690 /* Setup road integrators caches */
3692
3693 /* Pre calculate action related data. */
3695
3696 /* Setup unit unknown move cost caches */
3698 ptype->unknown_move_cost = utype_unknown_move_cost(ptype);
3702
3703 /* Cache what city production can receive help from caravans. */
3705
3706 /* Adjust editor for changed ruleset. */
3708
3709 /* We are not going to crop any more sprites from big sprites, free them. */
3711
3713}
3714
3715/************************************************************************/
3719{
3720 struct unit_class *c = uclass_by_number(p->id);
3721
3722 fc_assert_ret_msg(NULL != c, "Bad unit_class %d.", p->id);
3723
3724 names_set(&c->name, NULL, p->name, p->rule_name);
3725 c->min_speed = p->min_speed;
3726 c->hp_loss_pct = p->hp_loss_pct;
3728 c->flags = p->flags;
3729
3731}
3732
3733/************************************************************************/
3737{
3738 int i;
3739 struct unit_type *u = utype_by_number(p->id);
3740
3741 fc_assert_ret_msg(NULL != u, "Bad unit_type %d.", p->id);
3742
3743 names_set(&u->name, NULL, p->name, p->rule_name);
3751
3753 u->build_cost = p->build_cost;
3754 u->pop_cost = p->pop_cost;
3757 u->move_rate = p->move_rate;
3761 u->hp = p->hp;
3762 u->firepower = p->firepower;
3765 u->convert_time = p->convert_time;
3766 u->fuel = p->fuel;
3767 u->flags = p->flags;
3768 u->roles = p->roles;
3769 u->happy_cost = p->happy_cost;
3771 u->upkeep[o] = p->upkeep[o];
3774 u->bombard_rate = p->bombard_rate;
3775 u->city_size = p->city_size;
3776 u->city_slots = p->city_slots;
3777 u->tp_defense = p->tp_defense;
3778 u->cargo = p->cargo;
3779 u->targets = p->targets;
3780 u->embarks = p->embarks;
3781 u->disembarks = p->disembarks;
3782 u->vlayer = p->vlayer;
3783
3784 if (p->veteran_levels == 0) {
3785 u->veteran = NULL;
3786 } else {
3788
3789 for (i = 0; i < p->veteran_levels; i++) {
3791 p->power_fact[i], p->move_bonus[i],
3792 p->base_raise_chance[i],
3793 p->work_raise_chance[i]);
3794 }
3795 }
3796
3798
3799 u->adv.worker = p->worker;
3800
3802}
3803
3804/************************************************************************/
3808{
3809 struct unit_type *u = utype_by_number(p->unit);
3810 struct combat_bonus *bonus;
3811
3812 fc_assert_ret_msg(NULL != u, "Bad unit_type %d.", p->unit);
3813
3814 bonus = malloc(sizeof(*bonus));
3815
3816 bonus->flag = p->flag;
3817 bonus->type = p->type;
3818 bonus->value = p->value;
3819 bonus->quiet = p->quiet;
3820
3822}
3823
3824/************************************************************************/
3828{
3829 const char *flagname;
3830 const char *helptxt;
3831
3832 fc_assert_ret_msg(p->id >= UTYF_USER_FLAG_1 && p->id <= UTYF_LAST_USER_FLAG, "Bad user flag %d.", p->id);
3833
3834 if (p->name[0] == '\0') {
3835 flagname = NULL;
3836 } else {
3837 flagname = p->name;
3838 }
3839
3840 if (p->helptxt[0] == '\0') {
3841 helptxt = NULL;
3842 } else {
3843 helptxt = p->helptxt;
3844 }
3845
3847}
3848
3849/************************************************************************/
3853 const struct packet_ruleset_unit_class_flag *p)
3854{
3855 const char *flagname;
3856 const char *helptxt;
3857
3859 "Bad user flag %d.", p->id);
3860
3861 if (p->name[0] == '\0') {
3862 flagname = NULL;
3863 } else {
3864 flagname = p->name;
3865 }
3866
3867 if (p->helptxt[0] == '\0') {
3868 helptxt = NULL;
3869 } else {
3870 helptxt = p->helptxt;
3871 }
3872
3874}
3875
3876/************************************************************************/
3882static int unpack_tech_req(const enum tech_req r_num,
3883 const struct requirement_vector *reqs,
3884 struct advance *a,
3885 int i)
3886{
3889 /* Extract the tech req so the old code can reason about it. */
3890
3891 /* This IS a traditional tech req... right? */
3894
3895 /* Put it in the advance structure. */
3896 a->require[r_num] = requirement_vector_get(reqs, i)->source.value.advance;
3897
3898 /* Move on in the requirement vector. */
3899 i++;
3900 } else {
3901 /* No tech req. */
3903 }
3904
3905 return i;
3906}
3907
3908/************************************************************************/
3912{
3913 int i;
3914 struct advance *a = advance_by_number(p->id);
3915
3916 fc_assert_ret_msg(NULL != a, "Bad advance %d.", p->id);
3917
3918 names_set(&a->name, NULL, p->name, p->rule_name);
3921
3922 i = 0;
3923
3925 if (p->tclass >= 0) {
3927 } else {
3928 a->tclass = NULL;
3929 }
3930
3931 /* The tech requirements req1 and req2 are send inside research_reqs
3932 * since they too are required to be fulfilled before the tech can be
3933 * researched. */
3934
3935 if (p->removed) {
3936 /* The Freeciv data structures currently records that a tech is removed
3937 * by setting req1 and req2 to "Never". */
3938 a->require[AR_ONE] = A_NEVER;
3939 a->require[AR_TWO] = A_NEVER;
3940 } else {
3941 /* Unpack req1 and req2 from the research_reqs requirement vector. */
3944 }
3945
3946 /* Any remaining requirements are a part of the research_reqs requirement
3947 * vector. */
3949 /* slice of the vector starting at index i */
3950 &(const struct requirement_vector) {
3951 .p = p->research_reqs.p + i,
3952 .size = p->research_reqs.size - i,
3953 /* .size_alloc shouldn't matter */
3954 });
3955
3956 /* The packet's research_reqs should contain req1, req2 and the
3957 * requirements of the tech's research_reqs. */
3958 fc_assert((a->research_reqs.size
3959 + ((a->require[AR_ONE]
3960 && (advance_number(a->require[AR_ONE]) != A_NONE)) ?
3961 1 : 0)
3962 + ((a->require[AR_TWO]
3963 && (advance_number(a->require[AR_TWO]) != A_NONE)) ?
3964 1 : 0))
3966
3968
3969 a->flags = p->flags;
3970 a->cost = p->cost;
3971 a->num_reqs = p->num_reqs;
3973
3975}
3976
3977/************************************************************************/
3981{
3983
3984 fc_assert_ret_msg(NULL != ptclass, "Bad tech_class %d.", p->id);
3985
3986 names_set(&ptclass->name, NULL, p->name, p->rule_name);
3987 ptclass->cost_pct = p->cost_pct;
3988}
3989
3990/************************************************************************/
3994{
3995 const char *flagname;
3996 const char *helptxt;
3997
3998 fc_assert_ret_msg(p->id >= TECH_USER_1 && p->id <= TECH_USER_LAST, "Bad user flag %d.", p->id);
3999
4000 if (p->name[0] == '\0') {
4001 flagname = NULL;
4002 } else {
4003 flagname = p->name;
4004 }
4005
4006 if (p->helptxt[0] == '\0') {
4007 helptxt = NULL;
4008 } else {
4009 helptxt = p->helptxt;
4010 }
4011
4012 set_user_tech_flag_name(p->id, flagname, helptxt);
4013}
4014
4015/************************************************************************/
4019{
4020 struct impr_type *b = improvement_by_number(p->id);
4021
4022 fc_assert_ret_msg(NULL != b, "Bad improvement %d.", p->id);
4023
4024 b->genus = p->genus;
4025 names_set(&b->name, NULL, p->name, p->rule_name);
4031 b->build_cost = p->build_cost;
4032 b->upkeep = p->upkeep;
4033 b->sabotage = p->sabotage;
4034 b->flags = p->flags;
4039
4040#ifdef FREECIV_DEBUG
4041 if (p->id == improvement_count() - 1) {
4043 log_debug("Improvement: %s...", improvement_rule_name(bdbg));
4044 log_debug(" build_cost %3d", bdbg->build_cost);
4045 log_debug(" upkeep %2d", bdbg->upkeep);
4046 log_debug(" sabotage %3d", bdbg->sabotage);
4047 if (NULL != bdbg->helptext) {
4048 strvec_iterate(bdbg->helptext, text) {
4049 log_debug(" helptext %s", text);
4051 }
4053 }
4054#endif /* FREECIV_DEBUG */
4055
4057}
4058
4059/************************************************************************/
4063{
4064 const char *flagname;
4065 const char *helptxt;
4066
4068 "Bad user flag %d.", p->id);
4069
4070 if (p->name[0] == '\0') {
4071 flagname = NULL;
4072 } else {
4073 flagname = p->name;
4074 }
4075
4076 if (p->helptxt[0] == '\0') {
4077 helptxt = NULL;
4078 } else {
4079 helptxt = p->helptxt;
4080 }
4081
4082 set_user_impr_flag_name(p->id, flagname, helptxt);
4083}
4084
4085/************************************************************************/
4089{
4090 struct multiplier *pmul = multiplier_by_number(p->id);
4091
4092 fc_assert_ret_msg(NULL != pmul, "Bad multiplier %d.", p->id);
4093
4094 pmul->start = p->start;
4095 pmul->stop = p->stop;
4096 pmul->step = p->step;
4097 pmul->def = p->def;
4098 pmul->offset = p->offset;
4099 pmul->factor = p->factor;
4100 pmul->minimum_turns = p->minimum_turns;
4101
4102 names_set(&pmul->name, NULL, p->name, p->rule_name);
4103 requirement_vector_copy(&pmul->reqs, &p->reqs);
4105}
4106
4107/************************************************************************/
4111{
4112 struct government *gov = government_by_number(p->id);
4113
4114 fc_assert_ret_msg(NULL != gov, "Bad government %d.", p->id);
4115
4116 gov->item_number = p->id;
4117
4118 requirement_vector_copy(&gov->reqs, &p->reqs);
4119 names_set(&gov->name, NULL, p->name, p->rule_name);
4122 sz_strlcpy(gov->sound_str, p->sound_str);
4123 sz_strlcpy(gov->sound_alt, p->sound_alt);
4125
4127
4129}
4130
4131/************************************************************************/
4135 (const struct packet_ruleset_government_ruler_title *packet)
4136{
4137 struct government *gov = government_by_number(packet->gov);
4138
4139 fc_assert_ret_msg(NULL != gov, "Bad government %d.", packet->gov);
4140
4142 packet->male_title,
4143 packet->female_title);
4144}
4145
4146/************************************************************************/
4150{
4151 int j;
4152 struct terrain *pterrain = terrain_by_number(p->id);
4153
4154 fc_assert_ret_msg(NULL != pterrain, "Bad terrain %d.", p->id);
4155
4156 pterrain->tclass = p->tclass;
4157 pterrain->native_to = p->native_to;
4158 names_set(&pterrain->name, NULL, p->name, p->rule_name);
4159 sz_strlcpy(pterrain->graphic_str, p->graphic_str);
4160 sz_strlcpy(pterrain->graphic_alt, p->graphic_alt);
4161 sz_strlcpy(pterrain->graphic_alt2, p->graphic_alt2);
4162 pterrain->movement_cost = p->movement_cost;
4163 pterrain->defense_bonus = p->defense_bonus;
4164
4166 pterrain->output[o] = p->output[o];
4168
4169 if (pterrain->resources != NULL) {
4170 free(pterrain->resources);
4171 }
4172 pterrain->resources = fc_calloc(p->num_resources + 1,
4173 sizeof(*pterrain->resources));
4174 if (pterrain->resource_freq != NULL) {
4175 free(pterrain->resource_freq);
4176 }
4177 pterrain->resource_freq = fc_calloc(p->num_resources + 1,
4178 sizeof(*pterrain->resource_freq));
4179 for (j = 0; j < p->num_resources; j++) {
4180 pterrain->resources[j] = extra_by_number(p->resources[j]);
4181 if (!pterrain->resources[j]) {
4182 log_error("handle_ruleset_terrain() "
4183 "Mismatched resource %d for terrain \"%s\".",
4184 p->resources[j], terrain_rule_name(pterrain));
4185 }
4186 pterrain->resource_freq[j] = p->resource_freq[j];
4187 }
4188 pterrain->resources[p->num_resources] = NULL;
4189 pterrain->resource_freq[p->num_resources] = 0;
4190
4194
4195 pterrain->base_time = p->base_time;
4196 pterrain->road_time = p->road_time;
4198 pterrain->cultivate_time = p->cultivate_time;
4200 pterrain->plant_time = p->plant_time;
4202 pterrain->irrigation_time = p->irrigation_time;
4204 pterrain->mining_time = p->mining_time;
4205 if (p->animal < 0) {
4206 pterrain->animal = NULL;
4207 } else {
4208 pterrain->animal = utype_by_number(p->animal);
4209 }
4211 pterrain->transform_time = p->transform_time;
4212 pterrain->placing_time = p->placing_time;
4213 pterrain->pillage_time = p->pillage_time;
4214
4215 for (j = 0; j < p->extra_count; j++) {
4216 pterrain->extra_removal_times[j] = p->extra_removal_times[j];
4217 }
4218
4219 pterrain->flags = p->flags;
4220
4221 fc_assert_ret(pterrain->rgb == NULL);
4222 pterrain->rgb = rgbcolor_new(p->color_red, p->color_green, p->color_blue);
4223
4225
4227}
4228
4229/************************************************************************/
4233{
4234 const char *flagname;
4235 const char *helptxt;
4236
4237 fc_assert_ret_msg(p->id >= TER_USER_1 && p->id <= TER_USER_LAST, "Bad user flag %d.", p->id);
4238
4239 if (p->name[0] == '\0') {
4240 flagname = NULL;
4241 } else {
4242 flagname = p->name;
4243 }
4244
4245 if (p->helptxt[0] == '\0') {
4246 helptxt = NULL;
4247 } else {
4248 helptxt = p->helptxt;
4249 }
4250
4252}
4253
4254/************************************************************************/
4258{
4259 struct resource_type *presource;
4260
4261 if (p->id < 0 || p->id > MAX_EXTRA_TYPES) {
4262 log_error("Bad resource %d.", p->id);
4263 return;
4264 }
4265
4266 presource = resource_type_init(extra_by_number(p->id));
4267
4269 presource->output[o] = p->output[o];
4271}
4272
4273/************************************************************************/
4277{
4278 struct extra_type *pextra = extra_by_number(p->id);
4279 int i;
4280 bool cbase;
4281 bool croad;
4282 bool cres;
4283
4284 fc_assert_ret_msg(NULL != pextra, "Bad extra %d.", p->id);
4285
4286 names_set(&pextra->name, NULL, p->name, p->rule_name);
4287
4288 pextra->category = p->category;
4289
4290 pextra->causes = 0;
4291 for (i = 0; i < EC_COUNT; i++) {
4292 if (BV_ISSET(p->causes, i)) {
4293 pextra->causes |= (1 << i);
4294 }
4295 }
4296
4297 pextra->rmcauses = 0;
4298 for (i = 0; i < ERM_COUNT; i++) {
4299 if (BV_ISSET(p->rmcauses, i)) {
4300 pextra->rmcauses |= (1 << i);
4301 }
4302 }
4303
4304 if (pextra->causes == 0) {
4306 } else {
4307 for (i = 0; i < EC_COUNT; i++) {
4308 if (is_extra_caused_by(pextra, i)) {
4309 extra_to_caused_by_list(pextra, i);
4310 }
4311 }
4312 }
4313
4314 cbase = is_extra_caused_by(pextra, EC_BASE);
4315 croad = is_extra_caused_by(pextra, EC_ROAD);
4317 if (cbase) {
4318 /* Index is one less than size of list when this base is already added. */
4320 }
4321 if (croad) {
4322 /* Index is one less than size of list when this road is already added. */
4324 }
4325 if (!cbase && !croad && !cres) {
4328 }
4329
4330 for (i = 0; i < ERM_COUNT; i++) {
4331 if (is_extra_removed_by(pextra, i)) {
4332 extra_to_removed_by_list(pextra, i);
4333 }
4334 }
4335
4337 sz_strlcpy(pextra->act_gfx_alt, p->act_gfx_alt);
4339 sz_strlcpy(pextra->rmact_gfx, p->rmact_gfx);
4342 sz_strlcpy(pextra->graphic_str, p->graphic_str);
4343 sz_strlcpy(pextra->graphic_alt, p->graphic_alt);
4344
4345 requirement_vector_copy(&pextra->reqs, &p->reqs);
4346 requirement_vector_copy(&pextra->rmreqs, &p->rmreqs);
4347
4350
4353
4354 pextra->visibility_req = p->visibility_req;
4355 pextra->buildable = p->buildable;
4356 pextra->generated = p->generated;
4357 pextra->build_time = p->build_time;
4359 pextra->removal_time = p->removal_time;
4361 pextra->infracost = p->infracost;
4362 pextra->defense_bonus = p->defense_bonus;
4363
4364 if (pextra->defense_bonus != 0) {
4365 if (extra_has_flag(pextra, EF_NATURAL_DEFENSE)) {
4367 } else {
4369 }
4370 }
4371
4373
4374 pextra->eus = p->eus;
4375 if (pextra->eus == EUS_HIDDEN) {
4377 }
4378
4379 pextra->native_to = p->native_to;
4380
4381 pextra->flags = p->flags;
4382 if (pextra->no_aggr_near_city >= 0) {
4384 }
4385 if (extra_has_flag(pextra, EF_CAUSE_ZOC)) {
4387 }
4388
4389 pextra->hidden_by = p->hidden_by;
4390 pextra->bridged_over = p->bridged_over;
4391 pextra->conflicts = p->conflicts;
4392
4394
4396}
4397
4398/************************************************************************/
4402{
4403 const char *flagname;
4404 const char *helptxt;
4405
4407 "Bad user flag %d.", p->id);
4408
4409 if (p->name[0] == '\0') {
4410 flagname = NULL;
4411 } else {
4412 flagname = p->name;
4413 }
4414
4415 if (p->helptxt[0] == '\0') {
4416 helptxt = NULL;
4417 } else {
4418 helptxt = p->helptxt;
4419 }
4420
4421 set_user_extra_flag_name(p->id, flagname, helptxt);
4422}
4423
4424/************************************************************************/
4428{
4429 struct base_type *pbase = base_by_number(p->id);
4430
4431 fc_assert_ret_msg(NULL != pbase, "Bad base %d.", p->id);
4432
4433 pbase->gui_type = p->gui_type;
4434 pbase->border_sq = p->border_sq;
4435 pbase->vision_main_sq = p->vision_main_sq;
4436 pbase->vision_invis_sq = p->vision_invis_sq;
4437 pbase->vision_subs_sq = p->vision_subs_sq;
4438
4442 }
4443}
4444
4445/************************************************************************/
4449{
4450 struct road_type *proad = road_by_number(p->id);
4451
4452 fc_assert_ret_msg(NULL != proad, "Bad road %d.", p->id);
4453
4454 proad->gui_type = p->gui_type;
4455
4456 requirement_vector_copy(&proad->first_reqs, &p->first_reqs);
4457
4458 proad->move_cost = p->move_cost;
4459 proad->move_mode = p->move_mode;
4460
4462 proad->tile_incr_const[o] = p->tile_incr_const[o];
4463 proad->tile_incr[o] = p->tile_incr[o];
4464 proad->tile_bonus[o] = p->tile_bonus[o];
4466
4467 proad->compat = p->compat;
4468 proad->integrates = p->integrates;
4469 proad->flags = p->flags;
4470}
4471
4472/************************************************************************/
4476{
4477 struct goods_type *pgood = goods_by_number(p->id);
4478
4479 fc_assert_ret_msg(NULL != pgood, "Bad goods %d.", p->id);
4480
4481 names_set(&pgood->name, NULL, p->name, p->rule_name);
4482
4483 requirement_vector_copy(&pgood->reqs, &p->reqs);
4484
4485 pgood->from_pct = p->from_pct;
4486 pgood->to_pct = p->to_pct;
4487 pgood->onetime_pct = p->onetime_pct;
4488 pgood->select_priority = p->select_priority;
4489 pgood->replace_priority = p->replace_priority;
4490 pgood->flags = p->flags;
4491
4492 PACKET_STRVEC_EXTRACT(pgood->helptext, p->helptext);
4493}
4494
4495/************************************************************************/
4499{
4500 struct action *act;
4501
4502 if (!action_id_exists(p->id)) {
4503 /* Action id out of range */
4504 log_error("handle_ruleset_action() the action id %d is out of range.",
4505 p->id);
4506
4507 return;
4508 }
4509
4510 act = action_by_number(p->id);
4511
4512 sz_strlcpy(act->ui_name, p->ui_name);
4513 act->quiet = p->quiet;
4514
4515 act->result = p->result;
4516 act->sub_results = p->sub_results;
4518
4519 act->actor_kind = p->act_kind;
4520 act->target_kind = p->tgt_kind;
4521 act->sub_target_kind = p->sub_tgt_kind;
4522
4523 act->min_distance = p->min_distance;
4524 act->max_distance = p->max_distance;
4525 act->blocked_by = p->blocked_by;
4526}
4527
4528/************************************************************************/
4531void
4533{
4534 struct action_enabler *enabler;
4535
4537 /* Non existing action */
4538 log_error("handle_ruleset_action_enabler() the action %d "
4539 "doesn't exist.",
4540 p->enabled_action);
4541
4542 return;
4543 }
4544
4546
4547 enabler->action = p->enabled_action;
4548
4549 requirement_vector_copy(&enabler->actor_reqs, &p->actor_reqs);
4550 requirement_vector_copy(&enabler->target_reqs, &p->target_reqs);
4551
4553}
4554
4555/************************************************************************/
4559{
4561 int i;
4562
4564
4565 auto_perf->cause = p->cause;
4566
4568
4569 for (i = 0; i < p->alternatives_count; i++) {
4570 auto_perf->alternatives[i] = p->alternatives[i];
4571 }
4572}
4573
4574/************************************************************************/
4578{
4580
4581 fc_assert_ret_msg(NULL != pdis, "Bad disaster %d.", p->id);
4582
4583 names_set(&pdis->name, NULL, p->name, p->rule_name);
4584
4585 requirement_vector_copy(&pdis->reqs, &p->reqs);
4586
4587 pdis->frequency = p->frequency;
4588
4589 pdis->effects = p->effects;
4590}
4591
4592/************************************************************************/
4596{
4598
4599 fc_assert_ret_msg(NULL != pach, "Bad achievement %d.", p->id);
4600
4601 names_set(&pach->name, NULL, p->name, p->rule_name);
4602
4603 pach->type = p->type;
4604 pach->unique = p->unique;
4605 pach->value = p->value;
4606}
4607
4608/************************************************************************/
4612{
4614
4615 if (pset != NULL) {
4616 pset->trade_pct = p->trade_pct;
4617 pset->cancelling = p->cancelling;
4618 pset->bonus_type = p->bonus_type;
4619 }
4620}
4621
4622/************************************************************************/
4626 (const struct packet_ruleset_terrain_control *p)
4627{
4628 /* Since terrain_control is the same as packet_ruleset_terrain_control
4629 * we can just copy the data directly. */
4630 terrain_control = *p;
4631 /* terrain_control.move_fragments likely changed */
4633}
4634
4635/************************************************************************/
4639 (const struct packet_ruleset_nation_sets *packet)
4640{
4641 int i;
4642
4643 for (i = 0; i < packet->nsets; i++) {
4644 struct nation_set *pset =
4645 nation_set_new(packet->names[i], packet->rule_names[i],
4646 packet->descriptions[i]);
4647
4648 if (pset == NULL) {
4649 break;
4650 } else {
4652 }
4653 }
4654}
4655
4656/************************************************************************/
4660 (const struct packet_ruleset_nation_groups *packet)
4661{
4662 int i;
4663
4664 for (i = 0; i < packet->ngroups; i++) {
4665 struct nation_group *pgroup;
4666
4667 pgroup = nation_group_new(packet->groups[i]);
4668
4669 if (pgroup != NULL) {
4671 pgroup->hidden = packet->hidden[i];
4672 } else {
4673 break;
4674 }
4675 }
4676}
4677
4678/************************************************************************/
4682{
4683 struct nation_type *pnation = nation_by_number(packet->id);
4684 int i;
4685
4686 fc_assert_ret_msg(NULL != pnation, "Bad nation %d.", packet->id);
4687
4688 if (packet->translation_domain[0] != '\0') {
4689 size_t len = strlen(packet->translation_domain) + 1;
4690 pnation->translation_domain = fc_malloc(len);
4692 } else {
4693 pnation->translation_domain = NULL;
4694 }
4695 names_set(&pnation->adjective, pnation->translation_domain,
4696 packet->adjective, packet->rule_name);
4697 name_set(&pnation->noun_plural, pnation->translation_domain, packet->noun_plural);
4698 sz_strlcpy(pnation->flag_graphic_str, packet->graphic_str);
4699 sz_strlcpy(pnation->flag_graphic_alt, packet->graphic_alt);
4700 pnation->style = style_by_number(packet->style);
4701 for (i = 0; i < packet->leader_count; i++) {
4702 (void) nation_leader_new(pnation, packet->leader_name[i],
4703 packet->leader_is_male[i]);
4704 }
4705
4706 /* set later by PACKET_NATION_AVAILABILITY */
4707 pnation->client.is_pickable = FALSE;
4708 pnation->is_playable = packet->is_playable;
4709 pnation->barb_type = packet->barbarian_type;
4710
4711 if ('\0' != packet->legend[0]) {
4712 pnation->legend = fc_strdup(nation_legend_translation(pnation, packet->legend));
4713 } else {
4714 pnation->legend = fc_strdup("");
4715 }
4716
4717 for (i = 0; i < packet->nsets; i++) {
4718 struct nation_set *pset = nation_set_by_number(packet->sets[i]);
4719
4720 if (NULL != pset) {
4721 nation_set_list_append(pnation->sets, pset);
4722 } else {
4723 log_error("handle_ruleset_nation() \"%s\" have unknown set %d.",
4724 nation_rule_name(pnation), packet->sets[i]);
4725 }
4726 }
4727
4728 for (i = 0; i < packet->ngroups; i++) {
4730
4731 if (NULL != pgroup) {
4733 } else {
4734 log_error("handle_ruleset_nation() \"%s\" have unknown group %d.",
4735 nation_rule_name(pnation), packet->groups[i]);
4736 }
4737 }
4738
4739 /* init_government may be NULL */
4741 for (i = 0; i < MAX_NUM_TECH_LIST; i++) {
4742 if (i < packet->init_techs_count) {
4743 pnation->init_techs[i] = packet->init_techs[i];
4744 } else {
4745 pnation->init_techs[i] = A_LAST;
4746 }
4747 }
4748 for (i = 0; i < MAX_NUM_UNIT_LIST; i++) {
4749 if (i < packet->init_units_count) {
4750 pnation->init_units[i] = utype_by_number(packet->init_units[i]);
4751 } else {
4752 /* TODO: should init_units be initialized in common/nation.c? */
4753 pnation->init_units[i] = utype_by_number(U_LAST);
4754 }
4755 }
4756 for (i = 0; i < MAX_NUM_BUILDING_LIST; i++) {
4757 if (i < packet->init_buildings_count) {
4758 pnation->init_buildings[i] = packet->init_buildings[i];
4759 } else {
4760 pnation->init_buildings[i] = B_LAST;
4761 }
4762 }
4763
4765}
4766
4767/************************************************************************/
4771void handle_nation_availability(int ncount, const bool *is_pickable,
4772 bool nationset_change)
4773{
4774 int i;
4775
4776 fc_assert_action(ncount == nation_count(),
4777 ncount = MIN(ncount, nation_count()));
4778
4779 for (i = 0; i < ncount; i++) {
4780 nation_by_number(i)->client.is_pickable = is_pickable[i];
4781 }
4782
4783 races_update_pickable(nationset_change);
4784}
4785
4786/************************************************************************/
4790{
4791 struct nation_style *pstyle = style_by_number(p->id);
4792
4793 fc_assert_ret_msg(NULL != pstyle, "Bad style %d.", p->id);
4794
4795 names_set(&pstyle->name, NULL, p->name, p->rule_name);
4796}
4797
4798/************************************************************************/
4802{
4803 struct clause_info *info = clause_info_get(p->type);
4804
4805 fc_assert_ret_msg(NULL != info, "Bad clause %d.", p->type);
4806
4807 info->enabled = p->enabled;
4808
4812}
4813
4814/************************************************************************/
4818{
4819 int id;
4820 struct citystyle *cs;
4821
4822 id = packet->style_id;
4824 "Bad citystyle %d.", id);
4825 cs = &city_styles[id];
4826
4827 requirement_vector_copy(&cs->reqs, &packet->reqs);
4828 names_set(&cs->name, NULL, packet->name, packet->rule_name);
4829 sz_strlcpy(cs->graphic, packet->graphic);
4830 sz_strlcpy(cs->graphic_alt, packet->graphic_alt);
4831 sz_strlcpy(cs->citizens_graphic, packet->citizens_graphic);
4832
4834}
4835
4836/************************************************************************/
4840{
4841 int id;
4842 struct music_style *pmus;
4843
4844 id = packet->id;
4846 "Bad music_style %d.", id);
4847
4849
4850 requirement_vector_copy(&pmus->reqs, &packet->reqs);
4851 sz_strlcpy(pmus->music_peaceful, packet->music_peaceful);
4852 sz_strlcpy(pmus->music_combat, packet->music_combat);
4853}
4854
4855/************************************************************************/
4859{
4860 int i;
4861
4862 /* Must set num_specialist_types before iterating over them. */
4864
4865 fc_assert_ret(packet->veteran_levels > 0);
4866
4868 game.veteran->levels = packet->veteran_levels;
4869
4870 for (i = 0; i < MAX_NUM_TECH_LIST; i++) {
4871 if (i < packet->global_init_techs_count) {
4873 } else {
4875 }
4876 }
4877 for (i = 0; i < MAX_NUM_BUILDING_LIST; i++) {
4878 if (i < packet->global_init_buildings_count) {
4880 } else {
4882 }
4883 }
4884
4885 for (i = 0; i < packet->veteran_levels; i++) {
4887 packet->power_fact[i], packet->move_bonus[i],
4888 packet->base_raise_chance[i],
4889 packet->work_raise_chance[i]);
4890 }
4891
4894 packet->background_green,
4895 packet->background_blue);
4896
4898}
4899
4900/************************************************************************/
4904{
4905 struct specialist *s = specialist_by_number(p->id);
4906
4907 fc_assert_ret_msg(NULL != s, "Bad specialist %d.", p->id);
4908
4909 names_set(&s->name, NULL, p->plural_name, p->rule_name);
4911
4916
4918}
4919
4920/************************************************************************/
4923void handle_city_name_suggestion_info(int unit_id, const char *name)
4924{
4925 struct unit *punit = player_unit_by_number(client_player(), unit_id);
4926
4927 if (!can_client_issue_orders()) {
4928 return;
4929 }
4930
4931 if (punit) {
4933 bool other_asking = FALSE;
4934
4936 if (other->client.asking_city_name) {
4938 }
4941
4942 if (!other_asking) {
4944 }
4945 } else {
4947 unit_id, tile_index(unit_tile(punit)),
4948 0, name);
4949 }
4950 }
4951}
4952
4953/************************************************************************/
4959void handle_unit_action_answer(int actor_id, int target_id, int cost,
4960 action_id action_type,
4961 int request_kind)
4962{
4963 struct city *pcity = game_city_by_number(target_id);
4964 struct unit *punit = game_unit_by_number(target_id);
4965 struct tile *ptile = index_to_tile(&(wld.map), target_id);
4966 struct unit *pactor = player_unit_by_number(client_player(), actor_id);
4967 struct action *paction = action_by_number(action_type);
4968
4969 if (ACTION_NONE != action_type
4970 && !action_id_exists(action_type)) {
4971 /* Non existing action */
4972 log_error("handle_unit_action_answer() the action %d doesn't exist.",
4973 action_type);
4974
4975 if (request_kind == REQEST_PLAYER_INITIATED) {
4979 }
4980
4981 return;
4982 }
4983
4984 if (!pactor) {
4985 log_debug("Bad actor %d.", actor_id);
4986
4987 if (request_kind == REQEST_PLAYER_INITIATED) {
4990 }
4991
4992 return;
4993 }
4994
4995 switch ((enum gen_action)action_type) {
4997 if (punit != nullptr && client.conn.playing
4999 if (request_kind == REQEST_PLAYER_INITIATED) {
5000 /* Focus on the unit so the player knows where it is */
5002
5004 } else {
5005 /* Not in use (yet). */
5006 log_error("Unimplemented: received background unit bribe cost.");
5007 }
5008 } else {
5009 log_debug("Bad target %d.", target_id);
5010 if (request_kind == REQEST_PLAYER_INITIATED) {
5014 }
5015 }
5016 break;
5018 if (ptile != nullptr && client.conn.playing
5020 if (request_kind == REQEST_PLAYER_INITIATED) {
5021 /* Focus on the unit so the player knows where it is */
5023
5025 } else {
5026 /* Not in use (yet). */
5027 log_error("Unimplemented: received background stack bribe cost.");
5028 }
5029 } else {
5030 log_debug("Bad target %d.", target_id);
5031 if (request_kind == REQEST_PLAYER_INITIATED) {
5035 }
5036 }
5037 break;
5040 if (pcity && client.conn.playing
5042 if (request_kind == REQEST_PLAYER_INITIATED) {
5043 /* Focus on the unit so the player knows where it is */
5045
5047 } else {
5048 /* Not in use (yet). */
5049 log_error("Unimplemented: received background city incite cost.");
5050 }
5051 } else {
5052 log_debug("Bad target %d.", target_id);
5053 if (request_kind == REQEST_PLAYER_INITIATED) {
5057 }
5058 }
5059 break;
5061 if (pcity && client.conn.playing
5063 /* TODO: The bundled clients will have to start showing the upgrade
5064 * price sent from the server before it can be allowed to rely on
5065 * things the player can't see. (Example: it becomes legal to upgrade
5066 * a unit in a foreign city.) */
5067
5068 /* Getting unit upgrade cost from the server is currently only used by
5069 * Freeciv-web. */
5070 log_error("Received upgrade unit price but can't forward it.");
5071 }
5072 break;
5073 case ACTION_NONE:
5074 log_debug("Server didn't respond to query.");
5075 if (request_kind == REQEST_PLAYER_INITIATED) {
5079 }
5080 break;
5081 default:
5082 log_error("handle_unit_action_answer() invalid action_type (%d).",
5083 action_type);
5084 if (request_kind == REQEST_PLAYER_INITIATED) {
5088 }
5089 break;
5090 };
5091}
5092
5093/************************************************************************/
5098{
5100
5102 if (action_prob_possible(act_probs[act_id])) {
5103 /* An attack. */
5104 if (attack_action == ACTION_NONE) {
5105 /* No previous attack action found. */
5106 attack_action = act_id;
5107 } else {
5108 /* More than one legal attack action found. */
5109 return ACTION_NONE;
5110 }
5111 }
5114 if (action_prob_possible(act_probs[act_id])) {
5115 /* An interesting non attack action has been found. */
5116 return ACTION_NONE;
5117 }
5119
5120 return attack_action;
5121}
5122
5123/**********************************************************************/
5128 const struct act_prob *act_probs,
5129 struct unit *target_unit,
5130 struct city *target_city,
5131 struct tile *target_tile)
5132{
5134
5136
5138
5139 if (auto_action != ACTION_NONE) {
5140 /* No interesting actions except a single attack action has been
5141 * found. The player wants it performed without questions. */
5142
5143 /* The order requests below doesn't send additional details. */
5145
5146 /* Give the order. */
5148 case ATK_TILE:
5149 case ATK_STACK:
5150 case ATK_EXTRAS:
5151 if (target_tile != NULL) {
5154 0, "");
5155 }
5156 break;
5157 case ATK_CITY:
5158 if (target_city != NULL) {
5161 0, "");
5162 }
5163 break;
5164 case ATK_UNIT:
5165 if (target_unit != NULL) {
5168 0, "");
5169 }
5170 break;
5171 case ATK_SELF:
5174 0, "");
5175 break;
5176 case ATK_COUNT:
5178 break;
5179 }
5180
5181 /* Clean up. */
5183 } else {
5184 /* This should be done in the foreground */
5186 }
5187}
5188
5189/************************************************************************/
5196{
5198
5199 struct tile *target_tile = index_to_tile(&(wld.map), packet->target_tile_id);
5200 struct extra_type *target_extra = packet->target_extra_id == EXTRA_NONE ?
5204
5205 const struct act_prob *act_probs = packet->action_probabilities;
5206
5207 int request_kind = packet->request_kind;
5208 bool valid = FALSE;
5209
5210 /* The dead can't act */
5212 /* At least one action must be possible */
5213 action_iterate(act) {
5214 if (action_prob_possible(act_probs[act])) {
5215 valid = TRUE;
5216 break;
5217 }
5219 }
5220
5221 switch (request_kind) {
5223 if (valid) {
5224 /* The player can select an action and should be informed. */
5225
5226 /* Show the client specific action dialog */
5230 act_probs);
5231 } else {
5232 /* Nothing to do. */
5236 }
5237 break;
5239 /* This was a background action selection dialog refresh. */
5240
5241 if (actor_unit != NULL
5243 /* The situation may have changed. */
5247 act_probs);
5248 }
5249 break;
5251 if (actor_unit != NULL) {
5254 }
5255 break;
5256 default:
5257 log_warn("Unknown request_kind %d in reply", request_kind);
5258 break;
5259 }
5260}
5261
5262/************************************************************************/
5265void handle_city_sabotage_list(int actor_id, int city_id,
5266 bv_imprs improvements,
5267 action_id act_id,
5268 int request_kind)
5269{
5270 struct city *pcity = game_city_by_number(city_id);
5271 struct unit *pactor = player_unit_by_number(client_player(), actor_id);
5272 struct action *paction = action_by_number(act_id);
5273
5274 if (!pactor) {
5275 log_debug("Bad diplomat %d.", actor_id);
5276
5277 if (request_kind == REQEST_PLAYER_INITIATED) {
5280 }
5281
5282 return;
5283 }
5284
5285 if (!pcity) {
5286 log_debug("Bad city %d.", city_id);
5287
5288 if (request_kind == REQEST_PLAYER_INITIATED) {
5292 }
5293
5294 return;
5295 }
5296
5298 improvement_iterate(pimprove) {
5300 BV_ISSET(improvements,
5301 improvement_index(pimprove)));
5303
5304 if (request_kind == REQEST_PLAYER_INITIATED) {
5305 /* Focus on the unit so the player knows where it is */
5307
5309 } else {
5310 /* Not in use (yet). */
5311 log_error("Unimplemented: received background city building list.");
5312 }
5313 } else {
5314 log_debug("Can't issue orders");
5315 if (request_kind == REQEST_PLAYER_INITIATED) {
5318 }
5319 }
5320}
5321
5322/************************************************************************/
5331
5332/************************************************************************/
5336{
5337 if (client_has_player()
5338 && packet->player_id == player_number(client_player())) {
5339 if (packet->winner) {
5340 start_menu_music("music_victory", NULL);
5341 } else {
5342 start_menu_music("music_defeat", NULL);
5343 }
5344 }
5346}
5347
5348/************************************************************************/
5352 (const struct packet_player_attribute_chunk *packet)
5353{
5354 if (!client_has_player()) {
5355 return;
5356 }
5357
5359
5360 if (packet->offset + packet->chunk_length == packet->total_length) {
5361 /* We successful received the last chunk. The attribute block is
5362 now complete. */
5364 }
5365}
5366
5367/************************************************************************/
5371{
5373
5377 client.last_processed_request_id_seen);
5379 request_id_of_currently_handled_packet);
5380
5381 log_debug("start processing packet %d",
5383}
5384
5385/************************************************************************/
5404
5405/************************************************************************/
5409 int packet_type, int size)
5410{
5411 fc_assert(pc == &client.conn);
5412 log_debug("incoming packet={type=%d, size=%d}", packet_type, size);
5413}
5414
5415/************************************************************************/
5419 int packet_type, int size,
5420 int request_id)
5421{
5422 fc_assert(pc == &client.conn);
5423 log_debug("outgoing packet={type=%d, size=%d, request_id=%d}",
5425
5427}
5428
5429/************************************************************************/
5433{
5434 log_debug("handle_freeze_client");
5435
5437}
5438
5439/************************************************************************/
5443{
5444 log_debug("handle_thaw_client");
5445
5448}
5449
5450/************************************************************************/
5454{
5456}
5457
5458/************************************************************************/
5462{
5463 log_verbose("server shutdown");
5464}
5465
5466/************************************************************************/
5470{
5471 recv_ruleset_effect(packet);
5472}
5473
5474/************************************************************************/
5480void handle_edit_object_created(int tag, int id)
5481{
5483}
5484
5485/************************************************************************/
5489{
5490 struct tile *ptile = index_to_tile(&(wld.map), packet->id);
5491 bool changed = FALSE;
5492
5493 /* Check. */
5494 if (NULL == ptile) {
5495 log_error("%s(): invalid tile index %d.", __FUNCTION__, packet->id);
5496 return;
5497 }
5498
5499 /* Handle. */
5500 if (packet->removal) {
5501 changed = map_startpos_remove(ptile);
5502 } else {
5503 if (NULL != map_startpos_get(ptile)) {
5504 changed = FALSE;
5505 } else {
5506 map_startpos_new(ptile);
5507 changed = TRUE;
5508 }
5509 }
5510
5511 /* Notify. */
5512 if (changed && can_client_change_view()) {
5514 if (packet->removal) {
5516 packet->id, TRUE);
5517 } else {
5518 editgui_notify_object_created(packet->tag, packet->id);
5519 }
5520 }
5521}
5522
5523/************************************************************************/
5527 packet)
5528{
5529 struct tile *ptile = index_to_tile(&(wld.map), packet->id);
5530 struct startpos *psp;
5531
5532 /* Check. */
5533 if (NULL == ptile) {
5534 log_error("%s(): invalid tile index %d.", __FUNCTION__, packet->id);
5535 return;
5536 }
5537
5538 psp = map_startpos_get(ptile);
5539 if (NULL == psp) {
5540 log_error("%s(): no start position at (%d, %d)",
5541 __FUNCTION__, TILE_XY(ptile));
5542 return;
5543 }
5544
5545 /* Handle. */
5546 if (startpos_unpack(psp, packet) && can_client_change_view()) {
5547 /* Notify. */
5550 FALSE);
5551 }
5552}
5553
5554/************************************************************************/
5558{
5559 game.client.fog_of_war = enabled;
5560
5561 menus_update();
5562}
5563
5564/************************************************************************/
5567void handle_vote_remove(int vote_no)
5568{
5571}
5572
5573/************************************************************************/
5576void handle_vote_update(int vote_no, int yes, int no, int abstain,
5577 int num_voters)
5578{
5579 struct voteinfo *vi;
5580
5582
5584 "Got packet_vote_update for non-existent vote %d!",
5585 vote_no);
5586
5587 vi->yes = yes;
5588 vi->no = no;
5589 vi->abstain = abstain;
5590 vi->num_voters = num_voters;
5591
5593}
5594
5595/************************************************************************/
5598void handle_vote_new(const struct packet_vote_new *packet)
5599{
5601 "Got a packet_vote_new for already existing "
5602 "vote %d!", packet->vote_no);
5603
5605 packet->user,
5606 packet->desc,
5607 packet->percent_required,
5608 packet->flags);
5610}
5611
5612/************************************************************************/
5616{
5617 struct voteinfo *vi;
5618
5620
5622 "Got packet_vote_resolve for non-existent vote %d!",
5623 vote_no);
5624
5625 vi->resolved = TRUE;
5626 vi->passed = passed;
5627
5629}
5630
5631/************************************************************************/
5634void handle_play_music(const char *tag)
5635{
5636 play_single_track(tag);
5637}
5638
5639/************************************************************************/
5642void handle_popup_image(const char *tag)
5643{
5644 popup_image(tag);
5645}
5646
5647/************************************************************************/
5650void handle_diplomacy_init_meeting(int counterpart, int initiated_from)
5651{
5652 client_init_meeting(counterpart, initiated_from);
5653}
5654
5655/************************************************************************/
5658void handle_diplomacy_accept_treaty(int counterpart, bool I_accepted,
5659 bool other_accepted)
5660{
5661 client_recv_accept_treaty(counterpart, I_accepted, other_accepted);
5662}
5663
5664/************************************************************************/
5667void handle_diplomacy_cancel_meeting(int counterpart, int initiated_from)
5668{
5669 client_recv_cancel_meeting(counterpart, initiated_from);
5670}
5671
5672/************************************************************************/
5675void handle_diplomacy_create_clause(int counterpart, int giver,
5676 enum clause_type type, int value)
5677{
5678 client_recv_create_clause(counterpart, giver, type, value);
5679}
5680
5681/************************************************************************/
5684void handle_diplomacy_remove_clause(int counterpart, int giver,
5685 enum clause_type type, int value)
5686{
5687 client_recv_remove_clause(counterpart, giver, type, value);
5688}
5689
5690/**********************************************************************/
5695{
5698
5699 names_set(&curr->name, NULL, packet->name, packet->rule_name);
5700 curr->checkpoint = packet->checkpoint;
5701 curr->type = packet->behavior;
5702 curr->target = packet->type;
5703 curr->def = packet->def;
5704
5706 || curr->target != CTGT_CITY) {
5707 return;
5708 }
5709
5710 PACKET_STRVEC_EXTRACT(curr->helptext, packet->helptext);
5712}
5713
5714/**********************************************************************/
5718{
5719 int i;
5720 int counters_count;
5721 struct city *pcity = game_city_by_number(packet->city);
5722
5723 if (NULL == pcity) {
5724 return;
5725 }
5726
5728 if (counters_count != packet->count) {
5729 return;
5730 }
5731
5732 for (i = 0; i < counters_count; i++) {
5733 pcity->counter_values[i] = packet->counters[i];
5734 }
5735
5736 if (pcity->tile != NULL) {
5737 /* City's location known */
5739 }
5740
5742}
5743
5744/**********************************************************************/
5748{
5749 options_sync_reply(serial);
5750}
struct achievement * achievement_by_number(int id)
struct action_auto_perf * action_auto_perf_slot_number(const int num)
Definition actions.c:5707
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5068
void actions_rs_pre_san_gen(void)
Definition actions.c:889
void action_enabler_add(struct action_enabler *enabler)
Definition actions.c:1526
struct action_enabler * action_enabler_new(void)
Definition actions.c:1475
bool action_id_exists(const action_id act_id)
Definition actions.c:1068
static struct action * action_by_number(action_id act_id)
Definition actions.h:400
#define action_array_iterate(_act_array_, _act_id_)
Definition actions.h:261
#define action_id_requires_details(act_id)
Definition actions.h:438
#define action_array_iterate_end
Definition actions.h:273
#define action_iterate_end
Definition actions.h:218
#define action_iterate(_act_)
Definition actions.h:214
#define action_id_get_target_kind(act_id)
Definition actions.h:417
#define ACTION_NONE
Definition actions.h:59
void agents_unit_changed(struct unit *punit)
Definition agents.c:512
void agents_city_remove(struct city *pcity)
Definition agents.c:641
void agents_thaw_hint(void)
Definition agents.c:441
void agents_tile_remove(struct tile *ptile)
Definition agents.c:668
void agents_city_new(struct city *pcity)
Definition agents.c:615
void agents_start_turn(void)
Definition agents.c:475
void agents_tile_changed(struct tile *ptile)
Definition agents.c:692
void agents_unit_new(struct unit *punit)
Definition agents.c:537
void agents_unit_remove(struct unit *punit)
Definition agents.c:563
void agents_processing_started(void)
Definition agents.c:414
void agents_tile_new(struct tile *ptile)
Definition agents.c:716
void agents_processing_finished(void)
Definition agents.c:423
void agents_new_turn(void)
Definition agents.c:484
void agents_city_changed(struct city *pcity)
Definition agents.c:589
void agents_game_joined(void)
Definition agents.c:450
void agents_freeze_hint(void)
Definition agents.c:432
void agents_before_new_turn(void)
Definition agents.c:467
void attribute_restore(void)
Definition attribute.c:361
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:121
struct extra_type * base_extra_get(const struct base_type *pbase)
Definition base.c:105
struct base_type * base_by_number(const Base_type_id id)
Definition base.c:80
bool territory_claiming_base(const struct base_type *pbase)
Definition base.c:162
void dbv_set(struct dbv *pdbv, int bit)
Definition bitvector.c:142
void dbv_clr(struct dbv *pdbv, int bit)
Definition bitvector.c:163
#define BV_SET_VAL(bv, bit, val)
Definition bitvector.h:99
#define BV_SET(bv, bit)
Definition bitvector.h:89
#define BV_ARE_EQUAL(vec1, vec2)
Definition bitvector.h:121
#define BV_ISSET(bv, bit)
Definition bitvector.h:86
#define BV_CLR(bv, bit)
Definition bitvector.h:94
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:3421
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:3396
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:3455
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:3382
int city_map_radius_sq_get(const struct city *pcity)
Definition city.c:137
void destroy_city_virtual(struct city *pcity)
Definition city.c:3541
void city_rally_point_receive(const struct packet_city_rally_point *packet, struct city *pcity)
Definition city.c:3666
static const struct city struct citystyle * city_styles
Definition city.c:84
#define city_list_iterate(citylist, pcity)
Definition city.h:505
#define city_tile(_pcity_)
Definition city.h:561
static citizens city_size_get(const struct city *pcity)
Definition city.h:566
#define city_tile_iterate_skip_free_worked(_nmap, _radius_sq, _city_tile, _tile, _index, _x, _y)
Definition city.h:211
@ CITIZEN_LAST
Definition city.h:269
@ CITIZEN_ANGRY
Definition city.h:268
@ CITIZEN_HAPPY
Definition city.h:265
@ CITIZEN_CONTENT
Definition city.h:266
@ CITIZEN_UNHAPPY
Definition city.h:267
#define output_type_iterate(output)
Definition city.h:842
#define city_owner(_pcity_)
Definition city.h:560
#define city_tile_iterate_skip_free_worked_end
Definition city.h:219
#define city_list_iterate_end
Definition city.h:507
#define I_NEVER
Definition city.h:244
@ FEELING_FINAL
Definition city.h:281
@ FEELING_LAST
Definition city.h:282
#define output_type_iterate_end
Definition city.h:848
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:1093
void client_player_init(struct player *pplayer)
Definition climisc.c:1373
void client_remove_city(struct city *pcity)
Definition climisc.c:134
void client_player_maps_reset(void)
Definition climisc.c:1384
void client_remove_unit(struct unit *punit)
Definition climisc.c:72
void unit_focus_set_status(struct player *pplayer)
Definition climisc.c:1363
void handle_event(const char *featured_text, struct tile *ptile, enum event_type event, int turn, int phase, int conn_id)
Definition climisc.c:968
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:76
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 struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id popup_bribe_unit_dialog
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction popup_sabotage_dialog
Definition dialogs_g.h:77
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
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 struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
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:292
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:346
void editor_ruleset_changed(void)
Definition editor.c:180
@ 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 @22::@23 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:1128
void set_user_extra_flag_name(enum extra_flag_id id, const char *name, const char *helptxt)
Definition extras.c:947
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:875
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:236
#define EC_NATURAL_DEFENSIVE
Definition fc_types.h:824
#define EC_SPECIAL
Definition fc_types.h:822
int action_id
Definition fc_types.h:248
#define SP_MAX
Definition fc_types.h:267
#define EC_NONE
Definition fc_types.h:821
#define EC_NOT_AGGRESSIVE
Definition fc_types.h:825
#define EC_DEFENSIVE
Definition fc_types.h:823
#define IF_LAST_USER_FLAG
Definition fc_types.h:509
#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
signed short Continent_id
Definition fc_types.h:231
#define MAX_COUNTERS
Definition fc_types.h:106
#define UCL_LAST
Definition fc_types.h:274
#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:61
void game_ruleset_init(void)
Definition game.c:517
bool is_player_phase(const struct player *pplayer, int phase)
Definition game.c:712
int current_turn_timeout(void)
Definition game.c:853
void game_ruleset_free(void)
Definition game.c:566
struct world wld
Definition game.c:62
struct unit * game_unit_by_number(int id)
Definition game.c:115
struct city * game_city_by_number(int id)
Definition game.c:106
void init_client_goto(void)
Definition goto.c:153
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 popup_bribe_stack_dialog(struct unit *actor, struct tile *ptile, int cost, const struct action *paction)
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)
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
struct city * owner
Definition citydlg.c:226
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:2078
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:182
#define fc_assert_ret(condition)
Definition log.h:192
#define log_packet
Definition log.h:138
#define log_warn(message,...)
Definition log.h:106
#define log_verbose(message,...)
Definition log.h:110
#define fc_assert(condition)
Definition log.h:177
#define fc_assert_ret_msg(condition, message,...)
Definition log.h:206
#define fc_assert_ret_val(condition, val)
Definition log.h:195
#define fc_assert_action(condition, action)
Definition log.h:188
#define log_debug(message,...)
Definition log.h:116
#define log_normal(message,...)
Definition log.h:108
@ LOG_NORMAL
Definition log.h:33
#define log_error(message,...)
Definition log.h:104
struct startpos * map_startpos_get(const struct tile *ptile)
Definition map.c:2038
int startpos_number(const struct startpos *psp)
Definition map.c:1776
int sq_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:686
struct startpos * map_startpos_new(struct tile *ptile)
Definition map.c:2021
void map_init_topology(struct civ_map *nmap)
Definition map.c:315
void main_map_allocate(void)
Definition map.c:534
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Definition map.c:471
bool map_startpos_remove(struct tile *ptile)
Definition map.c:2054
bool same_pos(const struct tile *tile1, const struct tile *tile2)
Definition map.c:1076
bool startpos_unpack(struct startpos *psp, const struct packet_edit_startpos_full *packet)
Definition map.c:1875
void map_free(struct civ_map *fmap, bool server_side)
Definition map.c:545
struct terrain_misc terrain_control
Definition map.c:68
bool map_is_empty(void)
Definition map.c:148
#define adjc_iterate_end
Definition map.h:430
#define adjc_iterate(nmap, center_tile, itr_tile)
Definition map.h:425
#define whole_map_iterate(_map, _tile)
Definition map.h:573
#define whole_map_iterate_end
Definition map.h:582
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_realloc(ptr, sz)
Definition mem.h:36
#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:104
void init_move_fragments(void)
Definition movement.c:960
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:6103
const char * tileset_name_for_topology(int topology_id)
Definition options.c:6910
void options_sync_reply(int serial)
Definition options.c:6458
struct client_options gui_options
Definition options.c:71
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(dest, src)
Definition packets.h:190
#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:4858
void handle_player_diplstate(const struct packet_player_diplstate *packet)
Definition packhand.c:2808
static action_id auto_attack_act(const struct act_prob *act_probs)
Definition packhand.c:5097
void handle_ruleset_nation_sets(const struct packet_ruleset_nation_sets *packet)
Definition packhand.c:4639
void handle_ruleset_nation(const struct packet_ruleset_nation *packet)
Definition packhand.c:4681
void handle_city_name_suggestion_info(int unit_id, const char *name)
Definition packhand.c:4923
void handle_sync_serial_reply(int serial)
Definition packhand.c:5747
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:553
void handle_unknown_research(int id)
Definition packhand.c:2778
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:4135
void handle_city_info(const struct packet_city_info *packet)
Definition packhand.c:658
void handle_end_turn(void)
Definition packhand.c:1504
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:2909
void handle_vote_remove(int vote_no)
Definition packhand.c:5567
void handle_investigate_finished(const struct packet_investigate_finished *packet)
Definition packhand.c:2169
void handle_page_msg_part(const char *lines)
Definition packhand.c:1634
void handle_unit_combat_info(const struct packet_unit_combat_info *packet)
Definition packhand.c:576
void handle_ruleset_style(const struct packet_ruleset_style *p)
Definition packhand.c:4789
void handle_unit_remove(int unit_id)
Definition packhand.c:499
void handle_vote_update(int vote_no, int yes, int no, int abstain, int num_voters)
Definition packhand.c:5576
static int last_turn
Definition packhand.c:137
void handle_ruleset_multiplier(const struct packet_ruleset_multiplier *p)
Definition packhand.c:4088
void handle_player_info(const struct packet_player_info *pinfo)
Definition packhand.c:2461
void handle_ruleset_extra(const struct packet_ruleset_extra *p)
Definition packhand.c:4276
void handle_ruleset_action_auto(const struct packet_ruleset_action_auto *p)
Definition packhand.c:4558
void handle_map_info(const struct packet_map_info *packet)
Definition packhand.c:2249
void handle_ruleset_unit_bonus(const struct packet_ruleset_unit_bonus *p)
Definition packhand.c:3807
void handle_start_phase(int phase)
Definition packhand.c:1431
void start_revolution(void)
Definition packhand.c:2405
void handle_timeout_info(float seconds_to_phasedone, float last_turn_change_time)
Definition packhand.c:2375
void handle_ruleset_terrain_control(const struct packet_ruleset_terrain_control *p)
Definition packhand.c:4626
const action_id auto_attack_actions[]
Definition packhand.c:145
void handle_play_music(const char *tag)
Definition packhand.c:5634
static void update_continent_cache(const struct tile *ptile, Continent_id old_cont, Continent_id new_cont)
Definition packhand.c:3160
void handle_investigate_started(const struct packet_investigate_started *packet)
Definition packhand.c:2145
void handle_edit_object_created(int tag, int id)
Definition packhand.c:5480
int parts
Definition packhand.c:132
void handle_conn_ping(void)
Definition packhand.c:5453
static int unpack_tech_req(const enum tech_req r_num, const struct requirement_vector *reqs, struct advance *a, int i)
Definition packhand.c:3882
void handle_ruleset_tech_class(const struct packet_ruleset_tech_class *p)
Definition packhand.c:3980
void handle_diplomacy_init_meeting(int counterpart, int initiated_from)
Definition packhand.c:5650
void handle_ruleset_control(const struct packet_ruleset_control *packet)
Definition packhand.c:3540
void handle_end_phase(void)
Definition packhand.c:1420
void handle_ruleset_counter(const struct packet_ruleset_counter *packet)
Definition packhand.c:5694
void handle_server_info(const char *version_label, int major_version, int minor_version, int patch_version, int emerg_version)
Definition packhand.c:1587
void handle_ruleset_nation_groups(const struct packet_ruleset_nation_groups *packet)
Definition packhand.c:4660
void handle_ruleset_effect(const struct packet_ruleset_effect *packet)
Definition packhand.c:5469
void handle_new_year(int year, int fragments, int turn)
Definition packhand.c:1371
char * headline
Definition packhand.c:130
void handle_research_info(const struct packet_research_info *packet)
Definition packhand.c:2694
void handle_ruleset_goods(const struct packet_ruleset_goods *p)
Definition packhand.c:4475
void handle_unit_info(const struct packet_unit_info *packet)
Definition packhand.c:1660
void handle_ruleset_city(const struct packet_ruleset_city *packet)
Definition packhand.c:4817
void handle_ruleset_unit_class(const struct packet_ruleset_unit_class *p)
Definition packhand.c:3718
void handle_ruleset_government(const struct packet_ruleset_government *p)
Definition packhand.c:4110
void handle_ruleset_terrain_flag(const struct packet_ruleset_terrain_flag *p)
Definition packhand.c:4232
void handle_connect_msg(const char *message)
Definition packhand.c:1578
#define REQEST_BACKGROUND_REFRESH
Definition packhand.c:140
void handle_rulesets_ready(void)
Definition packhand.c:3664
void handle_tile_info(const struct packet_tile_info *packet)
Definition packhand.c:3248
void handle_ruleset_action(const struct packet_ruleset_action *p)
Definition packhand.c:4498
static void action_decision_handle(struct unit *punit)
Definition packhand.c:1676
void handle_achievement_info(int id, bool gained, bool first)
Definition packhand.c:3038
void handle_scenario_description(const char *description)
Definition packhand.c:3528
void play_sound_for_event(enum event_type type)
Definition packhand.c:1531
void handle_edit_startpos(const struct packet_edit_startpos *packet)
Definition packhand.c:5488
void handle_processing_finished(void)
Definition packhand.c:5388
void handle_diplomacy_cancel_meeting(int counterpart, int initiated_from)
Definition packhand.c:5667
void handle_city_short_info(const struct packet_city_short_info *packet)
Definition packhand.c:1169
void handle_edit_fogofwar_state(bool enabled)
Definition packhand.c:5557
void handle_popup_image(const char *tag)
Definition packhand.c:5642
void handle_diplomacy_create_clause(int counterpart, int giver, enum clause_type type, int value)
Definition packhand.c:5675
void handle_endgame_player(const struct packet_endgame_player *packet)
Definition packhand.c:5335
void handle_ruleset_resource(const struct packet_ruleset_resource *p)
Definition packhand.c:4257
void handle_unit_action_answer(int actor_id, int target_id, int cost, action_id action_type, int request_kind)
Definition packhand.c:4959
void handle_ruleset_tech(const struct packet_ruleset_tech *p)
Definition packhand.c:3911
void handle_team_name_info(int team_id, const char *team_name)
Definition packhand.c:561
void handle_thaw_client(void)
Definition packhand.c:5442
void handle_calendar_info(const struct packet_calendar_info *pcalendar)
Definition packhand.c:2367
void packhand_free(void)
Definition packhand.c:218
void set_government_choice(struct government *government)
Definition packhand.c:2392
void handle_city_rally_point(const struct packet_city_rally_point *packet)
Definition packhand.c:1018
void handle_ruleset_disaster(const struct packet_ruleset_disaster *p)
Definition packhand.c:4577
static bool handle_unit_packet_common(struct unit *packet_unit)
Definition packhand.c:1714
void handle_ruleset_unit_class_flag(const struct packet_ruleset_unit_class_flag *p)
Definition packhand.c:3852
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:408
void handle_ruleset_summary(const struct packet_ruleset_summary *packet)
Definition packhand.c:3636
void handle_set_topology(int topology_id, int wrap_id)
Definition packhand.c:2226
void handle_ruleset_impr_flag(const struct packet_ruleset_impr_flag *p)
Definition packhand.c:4062
void handle_page_msg(const char *caption, const char *headline, enum event_type event, int len, int parts)
Definition packhand.c:1603
void handle_city_update_counters(const struct packet_city_update_counters *packet)
Definition packhand.c:5717
void handle_edit_startpos_full(const struct packet_edit_startpos_full *packet)
Definition packhand.c:5526
void handle_conn_ping_info(int connections, const int *conn_id, const float *ping_time)
Definition packhand.c:3015
void handle_diplomacy_remove_clause(int counterpart, int giver, enum clause_type type, int value)
Definition packhand.c:5684
static bool spaceship_autoplace(struct player *pplayer, struct player_spaceship *ship)
Definition packhand.c:3075
void handle_player_remove(int playerno)
Definition packhand.c:2416
void handle_processing_started(void)
Definition packhand.c:5370
void handle_begin_turn(void)
Definition packhand.c:1490
void handle_endgame_report(const struct packet_endgame_report *packet)
Definition packhand.c:5326
void handle_early_chat_msg(const struct packet_early_chat_msg *packet)
Definition packhand.c:1564
void handle_ruleset_clause(const struct packet_ruleset_clause *p)
Definition packhand.c:4801
void handle_ruleset_road(const struct packet_ruleset_road *p)
Definition packhand.c:4448
void handle_unit_actions(const struct packet_unit_actions *packet)
Definition packhand.c:5195
void handle_ruleset_music(const struct packet_ruleset_music *packet)
Definition packhand.c:4839
void handle_ruleset_base(const struct packet_ruleset_base *p)
Definition packhand.c:4427
void notify_about_incoming_packet(struct connection *pc, int packet_type, int size)
Definition packhand.c:5408
void handle_freeze_client(void)
Definition packhand.c:5432
void handle_city_remove(int city_id)
Definition packhand.c:476
void handle_chat_msg(const struct packet_chat_msg *packet)
Definition packhand.c:1544
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:1032
void handle_trade_route_info(const struct packet_trade_route_info *packet)
Definition packhand.c:1134
void handle_player_attribute_chunk(const struct packet_player_attribute_chunk *packet)
Definition packhand.c:5352
void handle_vote_new(const struct packet_vote_new *packet)
Definition packhand.c:5598
static void packhand_init(void)
Definition packhand.c:239
void handle_scenario_info(const struct packet_scenario_info *packet)
Definition packhand.c:3507
void handle_ruleset_extra_flag(const struct packet_ruleset_extra_flag *p)
Definition packhand.c:4401
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:5418
#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:3993
void handle_nation_availability(int ncount, const bool *is_pickable, bool nationset_change)
Definition packhand.c:4771
void handle_spaceship_info(const struct packet_spaceship_info *p)
Definition packhand.c:3094
void handle_ruleset_specialist(const struct packet_ruleset_specialist *p)
Definition packhand.c:4903
void handle_unit_short_info(const struct packet_unit_short_info *packet)
Definition packhand.c:2176
void handle_diplomacy_accept_treaty(int counterpart, bool I_accepted, bool other_accepted)
Definition packhand.c:5658
void handle_ruleset_unit_flag(const struct packet_ruleset_unit_flag *p)
Definition packhand.c:3827
void handle_city_nationalities(const struct packet_city_nationalities *packet)
Definition packhand.c:998
void handle_server_shutdown(void)
Definition packhand.c:5461
void handle_ruleset_building(const struct packet_ruleset_building *p)
Definition packhand.c:4018
static int * continent_adjacency_count(Continent_id cont1, Continent_id cont2)
Definition packhand.c:3140
static bool update_improvement_from_packet(struct city *pcity, struct impr_type *pimprove, bool have_impr)
Definition packhand.c:636
void handle_ruleset_unit(const struct packet_ruleset_unit *p)
Definition packhand.c:3736
void handle_ruleset_terrain(const struct packet_ruleset_terrain *p)
Definition packhand.c:4149
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:5127
static struct @233 invisible
#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:5265
void handle_ruleset_action_enabler(const struct packet_ruleset_action_enabler *p)
Definition packhand.c:4532
void handle_ruleset_achievement(const struct packet_ruleset_achievement *p)
Definition packhand.c:4595
void handle_game_info(const struct packet_game_info *pinfo)
Definition packhand.c:2291
struct player * placeholder
Definition packhand.c:120
void handle_vote_resolve(int vote_no, bool passed)
Definition packhand.c:5615
void handle_worker_task(const struct packet_worker_task *packet)
Definition packhand.c:1314
void handle_ruleset_description_part(const struct packet_ruleset_description_part *packet)
Definition packhand.c:3654
void handle_ruleset_trade(const struct packet_ruleset_trade *p)
Definition packhand.c:4611
static struct @234 page_msg_report
int len
Definition packhand.c:127
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:542
#define players_iterate(_pplayer)
Definition player.h:537
#define OWNER_NONE
Definition player.h:50
#define ANON_USER_NAME
Definition player.h:48
#define is_ai(plr)
Definition player.h:232
#define ANON_PLAYER_NAME
Definition player.h:43
#define is_human(plr)
Definition player.h:231
void players_dialog_update(void)
#define fc_rand(_size)
Definition rand.h:56
void multipliers_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
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:144
int max_distance
Definition actions.h:127
bool quiet
Definition actions.h:134
enum action_sub_target_kind sub_target_kind
Definition actions.h:119
enum action_result result
Definition actions.h:114
char ui_name[MAX_LEN_NAME]
Definition actions.h:130
bv_action_sub_results sub_results
Definition actions.h:115
enum action_actor_kind actor_kind
Definition actions.h:117
bv_actions blocked_by
Definition actions.h:138
enum action_target_kind target_kind
Definition actions.h:118
int min_distance
Definition actions.h:127
struct requirement_vector research_reqs
Definition tech.h:132
struct tech_class * tclass
Definition tech.h:125
double cost
Definition tech.h:145
struct advance * require[AR_SIZE]
Definition tech.h:127
struct name_translation name
Definition tech.h:121
struct strvec * helptext
Definition tech.h:135
bv_tech_flags flags
Definition tech.h:134
int num_reqs
Definition tech.h:151
char graphic_str[MAX_LEN_NAME]
Definition tech.h:123
char graphic_alt[MAX_LEN_NAME]
Definition tech.h:124
Definition city.h:317
int id
Definition city.h:323
struct civ_game::@32::@35 client
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
struct civ_game::@31 rgame
bool ruleset_init
Definition game.h:118
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 government * government_during_revolution
Definition game.h:94
int xsize
Definition map_types.h:79
int ysize
Definition map_types.h:79
int north_latitude
Definition map_types.h:80
Continent_id num_continents
Definition map_types.h:83
struct civ_map::@44::@47 client
int south_latitude
Definition map_types.h:81
bool altitude_info
Definition map_types.h:74
int topology_id
Definition map_types.h:72
int wrap_id
Definition map_types.h:73
int * continent_sizes
Definition map_types.h:92
int * ocean_sizes
Definition map_types.h:93
Continent_id num_oceans
Definition map_types.h:84
int ** adj_matrix
Definition map_types.h:153
struct connection conn
Definition client_main.h:96
struct requirement_vector receiver_reqs
Definition diptreaty.h:61
struct requirement_vector giver_reqs
Definition diptreaty.h:60
struct requirement_vector either_reqs
Definition diptreaty.h:62
bool enabled
Definition diptreaty.h:59
bool sound_bell_at_new_turn
Definition options.h:151
bool autoaccept_tileset_suggestion
Definition options.h:184
bool autoaccept_musicset_suggestion
Definition options.h:186
bool draw_city_names
Definition options.h:197
bool draw_city_productions
Definition options.h:199
bool popup_new_cities
Definition options.h:168
bool draw_city_trade_routes
Definition options.h:201
bool wakeup_focus
Definition options.h:160
bool autoaccept_soundset_suggestion
Definition options.h:185
bool ask_city_name
Definition options.h:167
bool draw_city_growth
Definition options.h:198
bool ai_manual_turn_done
Definition options.h:155
int smooth_combat_step_msec
Definition options.h:154
bool draw_full_citybar
Definition options.h:217
bool auto_center_on_combat
Definition options.h:158
bool popup_attack_actions
Definition options.h:170
enum unit_type_flag_id flag
Definition unittype.h:472
enum combat_bonus_type type
Definition unittype.h:473
bool established
Definition connection.h:140
struct player * playing
Definition connection.h:151
int request_id_of_currently_handled_packet
Definition connection.h:193
enum cmdlevel access_level
Definition connection.h:177
bool observer
Definition connection.h:147
char username[MAX_LEN_NAME]
Definition connection.h:164
struct connection::@61::@66 client
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
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 extra_type::@26 data
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
struct nation_type::@54::@57 client
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
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_vector reqs
enum action_auto_perf_cause cause
struct requirement_vector actor_reqs
struct requirement_vector target_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
struct strvec * helptext
struct requirement_vector reqs
struct requirement_vector obs_reqs
char soundtag_alt[MAX_LEN_NAME]
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]
struct requirement_vector reqs
char graphic_alt[MAX_LEN_NAME]
char graphic[MAX_LEN_NAME]
struct requirement_vector giver_reqs
enum clause_type type
struct requirement_vector receiver_reqs
struct requirement_vector either_reqs
char preferred_soundset[MAX_LEN_NAME]
char preferred_tileset[MAX_LEN_NAME]
char preferred_musicset[MAX_LEN_NAME]
enum counter_target type
struct strvec * helptext
char name[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
enum counter_behavior behavior
char text[MAX_LEN_CONTENT]
char rule_name[MAX_LEN_NAME]
struct requirement_vector 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_vector appearance_reqs
char graphic_alt[MAX_LEN_NAME]
char act_gfx_alt2[MAX_LEN_NAME]
struct requirement_vector disappearance_reqs
bv_extra_flags flags
char act_gfx_alt[MAX_LEN_NAME]
char activity_gfx[MAX_LEN_NAME]
struct requirement_vector rmreqs
char rule_name[MAX_LEN_NAME]
enum extra_unit_seen_type eus
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 strvec * helptext
struct requirement_vector reqs
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]
struct strvec * helptext
struct requirement_vector reqs
bv_goods_flags flags
char name[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
char sound_alt[MAX_LEN_NAME]
struct requirement_vector reqs
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]
char sound_alt2[MAX_LEN_NAME]
char name[MAX_LEN_NAME]
char helptxt[MAX_LEN_PACKET]
struct requirement_vector reqs
char name[MAX_LEN_NAME]
Multiplier_type_id id
char rule_name[MAX_LEN_NAME]
char music_combat[MAX_LEN_NAME]
struct requirement_vector 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_vector first_reqs
char rule_name[MAX_LEN_NAME]
char graphic_alt[MAX_LEN_NAME]
struct requirement_vector reqs
Specialist_type_id id
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]
char graphic_str[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
char graphic_alt[MAX_LEN_NAME]
bv_tech_flags flags
struct strvec * helptext
struct requirement_vector research_reqs
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]
Resource_type_id resources[MAX_EXTRA_TYPES]
bv_terrain_flags flags
char graphic_str[MAX_LEN_NAME]
struct strvec * helptext
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 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]
struct strvec * helptext
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_vector build_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]
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
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:116
enum barbarian_type barbarian_type
Definition player.h:122
int science_cost
Definition player.h:119
int love[MAX_NUM_PLAYER_SLOTS]
Definition player.h:124
int infra_points
Definition player.h:67
enum spaceship_state state
Definition spaceship.h:108
struct city_list * cities
Definition player.h:281
struct player_ai ai_common
Definition player.h:288
bv_plr_flags flags
Definition player.h:292
struct dbv tile_vision[V_COUNT]
Definition player.h:359
int primary_capital_id
Definition player.h:275
bool is_male
Definition player.h:257
int wonders[B_LAST]
Definition player.h:305
struct government * target_government
Definition player.h:259
int autoselect_weight
Definition player.h:299
char username[MAX_LEN_NAME]
Definition player.h:252
bool is_connected
Definition player.h:296
int revolution_finishes
Definition player.h:273
int nturns_idle
Definition player.h:265
struct government * government
Definition player.h:258
struct dbv tile_known
Definition player.h:310
int turns_alive
Definition player.h:266
bool was_created
Definition player.h:294
int tech_upkeep
Definition player.h:363
struct unit_list * units
Definition player.h:282
struct conn_list * connections
Definition player.h:298
bool is_alive
Definition player.h:268
bv_player real_embassy
Definition player.h:277
struct player_economic economic
Definition player.h:284
int culture
Definition player.h:367
struct player_spaceship spaceship
Definition player.h:286
char name[MAX_LEN_NAME]
Definition player.h:251
bv_player gives_shared_vision
Definition player.h:302
enum mood_type mood
Definition player.h:361
struct player_score score
Definition player.h:283
struct multiplier_value multipliers[MAX_NUM_MULTIPLIERS]
Definition player.h:314
bool color_changeable
Definition player.h:365
int music_style
Definition player.h:280
struct nation_style * style
Definition player.h:279
bool phase_done
Definition player.h:263
bv_player gives_shared_tiles
Definition player.h:304
bool is_ready
Definition player.h:262
int history
Definition player.h:316
struct player::@73::@76 client
struct rgbcolor * rgb
Definition player.h:312
bool unassigned_user
Definition player.h:253
int output[O_LAST]
Definition terrain.h:54
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:40
struct terrain * cultivate_result
Definition terrain.h:108
int placing_time
Definition terrain.h:120
struct extra_type ** resources
Definition terrain.h:97
struct strvec * helptext
Definition terrain.h:156
char graphic_alt2[MAX_LEN_NAME]
Definition terrain.h:82
bv_terrain_flags flags
Definition terrain.h:152
int * resource_freq
Definition terrain.h:98
bv_unit_classes native_to
Definition terrain.h:150
int road_time
Definition terrain.h:106
struct name_translation name
Definition terrain.h:77
int plant_time
Definition terrain.h:112
struct terrain * plant_result
Definition terrain.h:111
int irrigation_food_incr
Definition terrain.h:114
int defense_bonus
Definition terrain.h:93
int cultivate_time
Definition terrain.h:109
int movement_cost
Definition terrain.h:92
const struct unit_type * animal
Definition terrain.h:130
int pillage_time
Definition terrain.h:125
int output[O_LAST]
Definition terrain.h:95
int transform_time
Definition terrain.h:124
char graphic_alt[MAX_LEN_NAME]
Definition terrain.h:81
int mining_time
Definition terrain.h:118
struct rgbcolor * rgb
Definition terrain.h:154
char graphic_str[MAX_LEN_NAME]
Definition terrain.h:80
enum terrain_class tclass
Definition terrain.h:90
int road_output_incr_pct[O_LAST]
Definition terrain.h:104
int extra_removal_times[MAX_EXTRA_TYPES]
Definition terrain.h:128
struct terrain * transform_result
Definition terrain.h:122
int irrigation_time
Definition terrain.h:115
int base_time
Definition terrain.h:105
int mining_shield_incr
Definition terrain.h:117
Definition tile.h:50
char * spec_sprite
Definition tile.h:67
char * label
Definition tile.h:66
int altitude
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:94
int action
Definition unit.h:102
int transport_capacity
Definition unittype.h:528
struct unit_class * uclass
Definition unittype.h:561
int pop_cost
Definition unittype.h:518
struct requirement_vector build_reqs
Definition unittype.h:525
int defense_strength
Definition unittype.h:521
bv_unit_classes cargo
Definition unittype.h:563
int firepower
Definition unittype.h:530
int paratroopers_range
Definition unittype.h:546
char graphic_alt[MAX_LEN_NAME]
Definition unittype.h:511
bool worker
Definition unittype.h:580
char sound_move_alt[MAX_LEN_NAME]
Definition unittype.h:514
int build_cost
Definition unittype.h:517
int convert_time
Definition unittype.h:536
int city_size
Definition unittype.h:555
struct veteran_system * veteran
Definition unittype.h:549
const struct unit_type * obsoleted_by
Definition unittype.h:534
int vision_radius_sq
Definition unittype.h:527
int move_rate
Definition unittype.h:522
bv_unit_classes targets
Definition unittype.h:566
enum vision_layer vlayer
Definition unittype.h:574
struct strvec * helptext
Definition unittype.h:576
struct unit_type::@90 adv
int bombard_rate
Definition unittype.h:552
char graphic_str[MAX_LEN_NAME]
Definition unittype.h:510
int city_slots
Definition unittype.h:557
char sound_move[MAX_LEN_NAME]
Definition unittype.h:513
char sound_fight_alt[MAX_LEN_NAME]
Definition unittype.h:516
struct name_translation name
Definition unittype.h:507
bv_unit_type_roles roles
Definition unittype.h:540
enum transp_def_type tp_defense
Definition unittype.h:559
int upkeep[O_LAST]
Definition unittype.h:543
char graphic_alt2[MAX_LEN_NAME]
Definition unittype.h:512
bv_unit_classes disembarks
Definition unittype.h:572
const struct unit_type * converted_to
Definition unittype.h:535
bv_unit_type_flags flags
Definition unittype.h:539
char sound_fight[MAX_LEN_NAME]
Definition unittype.h:515
bv_unit_classes embarks
Definition unittype.h:569
int attack_strength
Definition unittype.h:520
int happy_cost
Definition unittype.h:542
struct combat_bonus_list * bonuses
Definition unittype.h:531
Definition unit.h:140
int length
Definition unit.h:198
int upkeep[O_LAST]
Definition unit.h:150
bool has_orders
Definition unit.h:196
bool occupied
Definition unit.h:222
enum action_decision action_decision_want
Definition unit.h:205
int battlegroup
Definition unit.h:194
enum unit_activity activity
Definition unit.h:159
int moves_left
Definition unit.h:152
int id
Definition unit.h:147
struct unit::@83 orders
bool moved
Definition unit.h:176
int index
Definition unit.h:198
bool vigilant
Definition unit.h:200
int hp
Definition unit.h:153
int fuel
Definition unit.h:155
struct extra_type * changed_from_target
Definition unit.h:173
int current_form_turn
Definition unit.h:211
bool stay
Definition unit.h:208
bool colored
Definition unit.h:225
enum direction8 facing
Definition unit.h:144
bool asking_city_name
Definition unit.h:228
struct tile * tile
Definition unit.h:142
struct unit::@84::@86 client
struct extra_type * activity_target
Definition unit.h:167
int activity_count
Definition unit.h:165
struct unit_order * list
Definition unit.h:201
enum unit_activity changed_from
Definition unit.h:171
struct player * nationality
Definition unit.h:146
int transported_by
Definition unit.h:219
bool repeat
Definition unit.h:199
int homecity
Definition unit.h:148
bool paradropped
Definition unit.h:177
bool done_moving
Definition unit.h:184
int birth_turn
Definition unit.h:210
struct goods_type * carrying
Definition unit.h:189
struct tile * goto_tile
Definition unit.h:157
struct tile * action_decision_tile
Definition unit.h:206
const struct unit_type * utype
Definition unit.h:141
int veteran
Definition unit.h:154
int changed_from_count
Definition unit.h:172
struct player * owner
Definition unit.h:145
enum unit_focus_status focus_status
Definition unit.h:217
enum server_side_agent ssa_controller
Definition unit.h:175
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:960
size_t fc_strlcpy(char *dest, const char *src, size_t n)
Definition support.c:777
size_t fc_strlcat(char *dest, const char *src, size_t n)
Definition support.c:822
#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:404
struct tech_class * tech_class_by_number(const int idx)
Definition tech.c:330
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:244
tech_req
Definition tech.h:105
@ AR_TWO
Definition tech.h:107
@ AR_ROOT
Definition tech.h:108
@ AR_ONE
Definition tech.h:106
static Tech_type_id advance_count(void)
Definition tech.h:165
#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:240
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:69
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:1097
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:89
#define tile_worked(_tile)
Definition tile.h:119
#define tile_resource(_tile)
Definition tile.h:103
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:74
#define tile_terrain(_tile)
Definition tile.h:115
#define TILE_XY(ptile)
Definition tile.h:43
#define tile_list_iterate_end
Definition tile.h:76
#define tile_continent(_tile)
Definition tile.h:93
#define tile_owner(_tile)
Definition tile.h:97
void tileset_setup_unit_type(struct tileset *t, struct unit_type *ut)
Definition tilespec.c:3996
void tileset_setup_government(struct tileset *t, struct government *gov)
Definition tilespec.c:4605
void tileset_setup_specialist_type_default_set(struct tileset *t, Specialist_type_id id)
Definition tilespec.c:3085
void tileset_setup_tile_type(struct tileset *t, const struct terrain *pterrain)
Definition tilespec.c:4339
void tileset_player_init(struct tileset *t, struct player *pplayer)
Definition tilespec.c:7621
bool unit_drawn_with_city_outline(const struct unit *punit, bool check_focus)
Definition tilespec.c:5711
void tileset_setup_impr_type(struct tileset *t, struct impr_type *pimprove)
Definition tilespec.c:4030
void tileset_background_init(struct tileset *t)
Definition tilespec.c:7701
void tileset_setup_tech_type(struct tileset *t, struct advance *padvance)
Definition tilespec.c:4046
void tileset_setup_city_tiles(struct tileset *t, int style)
Definition tilespec.c:6657
void tilespec_reread_frozen_refresh(const char *tname)
Definition tilespec.c:1591
void tileset_setup_extra(struct tileset *t, struct extra_type *pextra)
Definition tilespec.c:4065
const char * tileset_basename(const struct tileset *t)
Definition tilespec.c:730
void finish_loading_sprites(struct tileset *t)
Definition tilespec.c:3806
const char * tileset_name_get(struct tileset *t)
Definition tilespec.c:7772
void tileset_error(enum log_level level, const char *tset_name, const char *format,...)
Definition tilespec.c:650
bool tilespec_reread(const char *new_tileset_name, bool game_fully_initialized, float scale)
Definition tilespec.c:1401
void tileset_setup_nation_flag(struct tileset *t, struct nation_type *nation)
Definition tilespec.c:4620
void tileset_ruleset_reset(struct tileset *t)
Definition tilespec.c:7736
#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:2473
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2544
bool unit_transport_unload(struct unit *pcargo)
Definition unit.c:2493
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Definition unit.c:1687
void unit_virtual_destroy(struct unit *punit)
Definition unit.c:1792
void unit_tile_set(struct unit *punit, struct tile *ptile)
Definition unit.c:1310
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2528
struct unit_list * unit_transport_cargo(const struct unit *ptrans)
Definition unit.c:2554
#define unit_tile(_pu)
Definition unit.h:407
@ FOCUS_AVAIL
Definition unit.h:54
@ FOCUS_WAIT
Definition unit.h:54
@ ORDER_PERFORM_ACTION
Definition unit.h:48
#define unit_owner(_pu)
Definition unit.h:406
#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:2760
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:1573
const char * unit_rule_name(const struct unit *punit)
Definition unittype.c:1591
void set_unit_move_type(struct unit_class *puclass)
Definition unittype.c:2928
void set_unit_type_caches(struct unit_type *ptype)
Definition unittype.c:2819
struct unit_class * uclass_by_number(const Unit_Class_id id)
Definition unittype.c:2481
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:2689
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:919
void set_user_unit_class_flag_name(enum unit_class_flag_id id, const char *name, const char *helptxt)
Definition unittype.c:1816
struct veteran_system * veteran_system_new(int count)
Definition unittype.c:2658
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Definition unittype.c:375
void set_user_unit_type_flag_name(enum unit_type_flag_id id, const char *name, const char *helptxt)
Definition unittype.c:1880
#define UCF_LAST_USER_FLAG
Definition unittype.h:127
#define unit_class_iterate(_p)
Definition unittype.h:913
#define UTYF_LAST_USER_FLAG
Definition unittype.h:335
#define unit_type_iterate(_p)
Definition unittype.h:860
#define U_LAST
Definition unittype.h:40
#define unit_class_iterate_end
Definition unittype.h:920
#define unit_type_iterate_end
Definition unittype.h:867
void economy_report_dialog_update(void)
void set_client_page(enum client_pages page)
void science_report_dialog_update(void)
void update_queue_processing_finished(int request_id)
void units_report_dialog_update(void)
void update_queue_processing_started(int request_id)
enum client_pages get_client_page(void)
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