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->turn_founded = packet->turn_founded;
867 pcity->turn_last_built = packet->turn_last_built;
868
870 log_error("handle_city_info() bad changed_from_kind %d.",
871 packet->changed_from_kind);
872 product.kind = VUT_NONE;
873 } else {
875 packet->changed_from_value);
876 if (!universals_n_is_valid(product.kind)) {
877 log_error("handle_city_info() bad changed_from_value %d.",
878 packet->changed_from_value);
879 product.kind = VUT_NONE;
880 }
881 }
883
884 pcity->before_change_shields = packet->before_change_shields;
885 pcity->disbanded_shields = packet->disbanded_shields;
886 pcity->caravan_shields = packet->caravan_shields;
887 pcity->last_turns_shield_surplus = packet->last_turns_shield_surplus;
888
889 improvement_iterate(pimprove) {
890 bool have = BV_ISSET(packet->improvements, improvement_index(pimprove));
891
892 if (have && !city_is_new
893 && pcity->built[improvement_index(pimprove)].turn <= I_NEVER) {
894 audio_play_sound(pimprove->soundtag, pimprove->soundtag_alt,
895 pimprove->soundtag_alt2);
896 }
900
901 /* We should be able to see units in the city. But for a diplomat
902 * investigating an enemy city we can't. In that case we don't update
903 * the occupied flag at all: it's already been set earlier and we'll
904 * get an update if it changes. */
907 = (unit_list_size(pcity->tile->units) > 0);
908 }
909
910 pcity->client.walls = packet->walls;
911 if (pcity->client.walls > NUM_WALL_TYPES) {
912 pcity->client.walls = NUM_WALL_TYPES;
913 }
914 pcity->style = packet->style;
915 pcity->capital = packet->capital;
916 if (packet->capital == CAPITAL_PRIMARY) {
917 powner->primary_capital_id = pcity->id;
918 } else if (powner->primary_capital_id == pcity->id) {
919 powner->primary_capital_id = 0;
920 }
921 pcity->client.city_image = packet->city_image;
922 pcity->steal = packet->steal;
923
924 pcity->client.happy = city_happy(pcity);
925 pcity->client.unhappy = city_unhappy(pcity);
926
928 && powner == client.conn.playing
930 || packet->diplomat_investigate;
931
932 city_packet_common(pcity, pcenter, powner, worked_tiles,
934
937 } else {
939 }
940
941 /* Update the description if necessary. */
944 }
945
946 /* Update focus unit info label if necessary. */
947 if (name_changed) {
949 if (pfocus_unit->homecity == pcity->id) {
951 break;
952 }
954 }
955
956 /* Update the science dialog if necessary. */
959 }
960
961 /* Update the units dialog if necessary. */
964 }
965
966 /* Update the economy dialog if necessary. */
969 }
970
971 /* Update the panel text (including civ population). */
973
974 /* Update caravan dialog */
975 if ((production_changed || shield_stock_changed)
980 city_tile(pcity)->index,
983 }
984
989 }
990}
991
992/************************************************************************/
996{
997 struct city *pcity = game_city_by_number(packet->id);
998
999 /* The nationality of the citizens. */
1001 int i;
1002
1004 for (i = 0; i < packet->nationalities_count; i++) {
1006 packet->nation_citizens[i]);
1007 }
1009 }
1010}
1011
1012/************************************************************************/
1016{
1017 struct city *pcity = game_city_by_number(packet->id);
1018
1019 if (pcity != NULL) {
1021 }
1022}
1023
1024/************************************************************************/
1029static void city_packet_common(struct city *pcity, struct tile *pcenter,
1030 struct player *powner,
1031 struct tile_list *worked_tiles,
1032 bool is_new, bool popup, bool investigate)
1033{
1034 if (NULL != worked_tiles) {
1035 /* We need to transfer the worked infos because the server will assume
1036 * those infos are kept in our side and won't send to us again. */
1037 tile_list_iterate(worked_tiles, pwork) {
1040 tile_list_destroy(worked_tiles);
1041 }
1042
1043 if (is_new) {
1044 tile_set_worked(pcenter, pcity); /* is_free_worked() */
1045 city_list_prepend(powner->cities, pcity);
1046
1047 if (client_is_global_observer() || powner == client_player()) {
1049 }
1050
1052 unit_list_iterate(pp->units, punit) {
1053 if (punit->homecity == pcity->id) {
1054 unit_list_prepend(pcity->units_supported, punit);
1055 }
1058
1059 pcity->client.first_citizen_index = fc_rand(MAX_NUM_CITIZEN_SPRITES);
1060 } else {
1061 if (client_is_global_observer() || powner == client_player()) {
1063 }
1064 }
1065
1066 if (can_client_change_view()) {
1068 }
1069
1070 if (city_workers_display == pcity) {
1072 }
1073
1074 if (investigate) {
1075 /* Commit the collected supported and present units. */
1076 if (pcity->client.collecting_info_units_supported != NULL) {
1077 /* We got units, let's move the unit lists. */
1078 fc_assert(pcity->client.collecting_info_units_present != NULL);
1079
1080 unit_list_destroy(pcity->client.info_units_present);
1081 pcity->client.info_units_present =
1082 pcity->client.collecting_info_units_present;
1083 pcity->client.collecting_info_units_present = NULL;
1084
1085 unit_list_destroy(pcity->client.info_units_supported);
1086 pcity->client.info_units_supported =
1087 pcity->client.collecting_info_units_supported;
1088 pcity->client.collecting_info_units_supported = NULL;
1089 } else {
1090 /* We didn't get any unit, let's clear the unit lists. */
1091 fc_assert(pcity->client.collecting_info_units_present == NULL);
1092
1093 unit_list_clear(pcity->client.info_units_supported);
1094 unit_list_clear(pcity->client.info_units_present);
1095 }
1096 }
1097
1098 if (popup
1099 && NULL != client.conn.playing
1102 menus_update();
1103 if (!city_dialog_is_open(pcity)) {
1105 }
1106 }
1107
1108 if (!is_new
1111 }
1112
1113 /* update menus if the focus unit is on the tile. */
1115 menus_update();
1116 }
1117
1118 if (is_new) {
1119 log_debug("(%d,%d) creating city %d, %s %s", TILE_XY(pcenter),
1122 }
1123
1125}
1126
1127/************************************************************************/
1132{
1133 struct city *pcity = game_city_by_number(packet->city);
1134 struct trade_route *proute;
1135 bool city_changed = FALSE;
1136
1137 if (pcity == NULL) {
1138 return;
1139 }
1140
1141 proute = trade_route_list_get(pcity->routes, packet->index);
1142 if (proute == NULL) {
1143 fc_assert(trade_route_list_size(pcity->routes) == packet->index);
1144
1145 proute = fc_malloc(sizeof(struct trade_route));
1148 }
1149
1150 proute->partner = packet->partner;
1151 proute->value = packet->value;
1152 proute->dir = packet->direction;
1153 proute->goods = goods_by_number(packet->goods);
1154
1158 }
1159}
1160
1161/************************************************************************/
1167{
1169 bool city_is_new = FALSE;
1170 bool name_changed = FALSE;
1172 struct city *pcity = game_city_by_number(packet->id);
1173 struct tile *pcenter = index_to_tile(&(wld.map), packet->tile);
1174 struct tile *ptile = NULL;
1175 struct tile_list *worked_tiles = NULL;
1176 struct player *powner = player_by_number(packet->owner);
1177 struct player *original = player_by_number(packet->original);
1178 int radius_sq = game.info.init_city_radius_sq;
1179
1180 fc_assert_ret_msg(NULL != powner, "Bad player number %d.", packet->owner);
1181 fc_assert_ret_msg(NULL != pcenter, "Invalid tile index %d.", packet->tile);
1182
1183 if (NULL != pcity) {
1184 ptile = city_tile(pcity);
1185
1186 if (NULL == ptile) {
1187 /* Invisible worked city */
1189 city_is_new = TRUE;
1190
1191 pcity->tile = pcenter;
1192 pcity->owner = powner;
1193 pcity->original = original;
1194
1196 if (wtile->worked == pcity) {
1198
1201 }
1202 }
1204 } else if (city_owner(pcity) != powner) {
1205 /* Remember what were the worked tiles. The server won't
1206 * send to us again. */
1208 pworked, _index, _x, _y) {
1209 if (pcity == tile_worked(pworked)) {
1210 if (NULL == worked_tiles) {
1211 worked_tiles = tile_list_new();
1212 }
1213 tile_list_append(worked_tiles, pworked);
1214 }
1216 radius_sq = city_map_radius_sq_get(pcity);
1218 pcity = NULL;
1220 }
1221 }
1222
1223 if (NULL == pcity) {
1224 city_is_new = TRUE;
1225 pcity = create_city_virtual(powner, pcenter, packet->name);
1226 pcity->id = packet->id;
1227 pcity->original = original;
1228 city_map_radius_sq_set(pcity, radius_sq);
1230 } else if (pcity->id != packet->id) {
1231 log_error("handle_city_short_info() city id %d != id %d.",
1232 pcity->id, packet->id);
1233 return;
1234 } else if (city_tile(pcity) != pcenter) {
1235 log_error("handle_city_short_info() city tile (%d, %d) != (%d, %d).",
1237 return;
1238 } else {
1239 name_changed = (fc_strncmp(packet->name, pcity->name, MAX_LEN_CITYNAME));
1240
1241 /* Check if city descriptions should be updated */
1244 }
1245
1246 city_name_set(pcity, packet->name);
1247
1248 memset(pcity->feel, 0, sizeof(pcity->feel));
1249 memset(pcity->specialists, 0, sizeof(pcity->specialists));
1250 }
1251
1252 pcity->specialists[DEFAULT_SPECIALIST] = packet->size;
1253 city_size_set(pcity, packet->size);
1254
1255 /* We can't actually see the internals of the city, but the server tells
1256 * us this much. */
1257 if (pcity->client.occupied != packet->occupied) {
1258 pcity->client.occupied = packet->occupied;
1261 }
1262 }
1263 pcity->client.walls = packet->walls;
1264 if (pcity->client.walls > NUM_WALL_TYPES) {
1265 pcity->client.walls = NUM_WALL_TYPES;
1266 }
1267 pcity->style = packet->style;
1268 pcity->capital = packet->capital;
1269 if (packet->capital == CAPITAL_PRIMARY) {
1270 powner->primary_capital_id = pcity->id;
1271 } else if (powner->primary_capital_id == pcity->id) {
1272 powner->primary_capital_id = 0;
1273 }
1274 pcity->client.city_image = packet->city_image;
1275
1276 pcity->client.happy = packet->happy;
1277 pcity->client.unhappy = packet->unhappy;
1278
1279 improvement_iterate(pimprove) {
1280 /* Don't update the non-visible improvements, they could hide the
1281 * previously seen informations about the city (diplomat investigation).
1282 */
1283 if (is_improvement_visible(pimprove)) {
1284 bool have = BV_ISSET(packet->improvements,
1285 improvement_index(pimprove));
1287 }
1289
1290 city_packet_common(pcity, pcenter, powner, worked_tiles,
1292
1295 } else {
1297 }
1298
1299 /* Update the description if necessary. */
1300 if (update_descriptions) {
1302 }
1303}
1304
1305/************************************************************************/
1308void handle_worker_task(const struct packet_worker_task *packet)
1309{
1310 struct city *pcity = game_city_by_number(packet->city_id);
1311 struct worker_task *ptask = NULL;
1312
1313 if (pcity == NULL
1315 return;
1316 }
1317
1319 if (tile_index(ptask_old->ptile) == packet->tile_id) {
1320 ptask = ptask_old;
1321 break;
1322 }
1324
1325 if (ptask == NULL) {
1326 if (packet->activity == ACTIVITY_LAST) {
1327 return;
1328 } else {
1329 ptask = fc_malloc(sizeof(struct worker_task));
1330 worker_task_list_append(pcity->task_reqs, ptask);
1331 }
1332 } else {
1333 if (packet->activity == ACTIVITY_LAST) {
1334 worker_task_list_remove(pcity->task_reqs, ptask);
1335 free(ptask);
1336 ptask = NULL;
1337 }
1338 }
1339
1340 if (ptask != NULL) {
1341 ptask->ptile = index_to_tile(&(wld.map), packet->tile_id);
1342 ptask->act = packet->activity;
1343 if (packet->tgt >= 0) {
1344 ptask->tgt = extra_by_number(packet->tgt);
1345 } else {
1346 ptask->tgt = NULL;
1347 }
1348 ptask->want = packet->want;
1349 }
1350
1351 if (ptask && !worker_task_is_sane(ptask)) {
1352 log_debug("Bad worker task");
1353 worker_task_list_remove(pcity->task_reqs, ptask);
1354 free(ptask);
1355 ptask = NULL;
1356 return;
1357 }
1358
1360}
1361
1362/************************************************************************/
1365void handle_new_year(int year, int fragments, int turn)
1366{
1367 game.info.year = year;
1368 game.info.fragment_count = fragments;
1369 /*
1370 * The turn was increased in handle_end_turn()
1371 */
1372 fc_assert(game.info.turn == turn);
1374
1377
1379 menus_update();
1380
1382
1383#if 0
1384 /* This information shouldn't be needed, but if it is this is the only
1385 * way we can get it. */
1386 if (NULL != client.conn.playing) {
1390 }
1391#endif
1392
1395
1398 _("Start of turn %d"), game.info.turn);
1399 }
1400
1402
1403 if (last_turn != turn) {
1404 start_turn();
1405 last_turn = turn;
1406 }
1407}
1408
1409/************************************************************************/
1415{
1416 /* Messagewindow will contain events happened since our own phase ended,
1417 * so player of the first phase and last phase are in equal situation. */
1419}
1420
1421/************************************************************************/
1425void handle_start_phase(int phase)
1426{
1428 /* We are on detached state, let ignore this packet. */
1429 return;
1430 }
1431
1432 if (phase < 0
1434 && phase >= player_count())
1436 && phase >= team_count())) {
1437 log_error("handle_start_phase() illegal phase %d.", phase);
1438 return;
1439 }
1440
1442
1443 game.info.phase = phase;
1444
1445 /* Possibly replace wait cursor with something else */
1446 if (phase == 0) {
1447 /* TODO: Have server set as busy also if switching phase
1448 * is taking long in a alternating phases mode. */
1450 }
1451
1452 if (NULL != client.conn.playing
1453 && is_player_phase(client.conn.playing, phase)) {
1456
1458
1462 }
1463
1465
1469
1473
1475 }
1476
1478}
1479
1480/************************************************************************/
1485{
1486 log_debug("handle_begin_turn()");
1487
1488 /* Server is still considered busy until it handles also the beginning
1489 * of the first phase. */
1490
1492}
1493
1494/************************************************************************/
1499{
1500 log_debug("handle_end_turn()");
1501
1502 /* Make sure wait cursor is in use */
1504
1506
1507 /*
1508 * The local idea of the game.info.turn is increased here since the
1509 * client will get unit updates (reset of move points for example)
1510 * between handle_end_turn() and handle_new_year(). These
1511 * unit updates will look like they did take place in the old turn
1512 * which is incorrect. If we get the authoritative information about
1513 * the game.info.turn in handle_new_year() we will check it.
1514 */
1515 game.info.turn++;
1516
1517 log_verbose(_("Beginning turn %d"), game.info.turn);
1518
1520}
1521
1522/************************************************************************/
1526{
1527 const char *sound_tag = get_event_tag(type);
1528
1529 if (sound_tag) {
1530 audio_play_sound(sound_tag, NULL, NULL);
1531 }
1532}
1533
1534/************************************************************************/
1538void handle_chat_msg(const struct packet_chat_msg *packet)
1539{
1540 handle_event(packet->message,
1541 index_to_tile(&(wld.map), packet->tile),
1542 packet->event,
1543 packet->turn,
1544 packet->phase,
1545 packet->conn_id);
1546}
1547
1548/************************************************************************/
1559{
1560 handle_event(packet->message,
1561 index_to_tile(&(wld.map), packet->tile),
1562 packet->event,
1563 packet->turn,
1564 packet->phase,
1565 packet->conn_id);
1566}
1567
1568/************************************************************************/
1573{
1574 popup_connect_msg(_("Welcome"), message);
1575}
1576
1577/************************************************************************/
1581void handle_server_info(const char *version_label, int major_version,
1582 int minor_version, int patch_version, int emerg_version)
1583{
1584 if (emerg_version > 0) {
1585 log_verbose("Server has version %d.%d.%d.%d%s",
1586 major_version, minor_version, patch_version, emerg_version,
1587 version_label);
1588 } else {
1589 log_verbose("Server has version %d.%d.%d%s",
1590 major_version, minor_version, patch_version, version_label);
1591 }
1592}
1593
1594/************************************************************************/
1597void handle_page_msg(const char *caption, const char *headline,
1598 enum event_type event, int len, int parts)
1599{
1600 if (!client_has_player()
1602 || event != E_BROADCAST_REPORT) {
1603 if (page_msg_report.parts > 0) {
1604 /* Previous one was never finished */
1605 free(page_msg_report.caption);
1606 free(page_msg_report.headline);
1607 free(page_msg_report.lines);
1608 }
1609 page_msg_report.len = len;
1610 page_msg_report.event = event;
1613 page_msg_report.parts = parts;
1614 page_msg_report.lines = fc_malloc(len + 1);
1615 page_msg_report.lines[0] = '\0';
1616
1617 if (parts == 0) {
1618 /* Empty report - handle as if last part was just received. */
1619 page_msg_report.parts = 1;
1621 }
1622 }
1623}
1624
1625/************************************************************************/
1629{
1630 if (page_msg_report.lines != NULL) {
1631 /* We have already decided to show the message at the time we got
1632 * the header packet. */
1634 page_msg_report.parts--;
1635
1636 if (page_msg_report.parts == 0) {
1637 /* This is the final part */
1639 page_msg_report.headline,
1640 page_msg_report.lines);
1642
1643 free(page_msg_report.caption);
1644 free(page_msg_report.headline);
1645 free(page_msg_report.lines);
1646 page_msg_report.lines = NULL;
1647 }
1648 }
1649}
1650
1651/************************************************************************/
1654void handle_unit_info(const struct packet_unit_info *packet)
1655{
1656 struct unit *punit;
1657
1658 punit = unpackage_unit(packet);
1662 }
1663}
1664
1665/**********************************************************************/
1671{
1674 if (utype_can_do_action(unit_type_get(punit), act_id)) {
1675 /* An auto action like auto attack could be legal. Check for those
1676 * at once so they won't have to wait for player focus. */
1678 punit->id,
1681 EXTRA_NONE,
1683 return;
1684 }
1686 }
1687
1688 /* This should be done in the foreground */
1690}
1691
1692/************************************************************************/
1709{
1710 struct city *pcity;
1711 struct unit *punit;
1712 bool need_menus_update = FALSE;
1715 bool repaint_unit = FALSE;
1716 bool repaint_city = FALSE; /* regards unit's homecity */
1717 struct tile *old_tile = nullptr;
1718 bool check_focus = FALSE; /* conservative focus change */
1719 bool moved = FALSE;
1720 bool ret = FALSE;
1722 struct player *plr = client_player();
1723
1724 if (owner == nullptr) {
1725 punit = nullptr;
1726 } else {
1728 }
1729
1730 if (punit == nullptr && game_unit_by_number(packet_unit->id)) {
1731 /* This means unit has changed owner. We deal with this here
1732 * by simply deleting the old one and creating a new one. */
1734 }
1735
1736 if (punit != nullptr) {
1737 /* In some situations, the size of repaint units require can change;
1738 * in particular, city-builder units sometimes get a potential-city
1739 * outline, but to speed up redraws we don't repaint this whole area
1740 * unnecessarily. We need to ensure that when the footprint shrinks,
1741 * old bits aren't left behind on the canvas.
1742 * If the current (old) status of the unit is such that it gets a large
1743 * repaint, as a special case, queue a large repaint immediately, to
1744 * schedule the correct amount/location to be redrawn; but rely on the
1745 * repaint being deferred until the unit is updated, so that what's
1746 * drawn reflects the new status (e.g., no city outline). */
1749 }
1750
1751 ret = TRUE;
1752 punit->activity_count = packet_unit->activity_count;
1754 if (punit->ssa_controller != packet_unit->ssa_controller) {
1755 punit->ssa_controller = packet_unit->ssa_controller;
1757 /* AI is set: May change focus */
1758 /* AI is cleared: Keep focus */
1759 if (packet_unit->ssa_controller != SSA_NONE
1760 && unit_is_in_focus(punit)) {
1761 check_focus = TRUE;
1762 }
1763 }
1764
1765 if (punit->facing != packet_unit->facing) {
1766 punit->facing = packet_unit->facing;
1768 }
1769
1770 if (punit->activity != packet_unit->activity
1771 || punit->activity_target == packet_unit->activity_target
1772 || punit->client.transported_by != packet_unit->client.transported_by
1773 || punit->client.occupied != packet_unit->client.occupied
1774 || punit->has_orders != packet_unit->has_orders
1775 || punit->orders.repeat != packet_unit->orders.repeat
1776 || punit->orders.vigilant != packet_unit->orders.vigilant
1777 || punit->orders.index != packet_unit->orders.index) {
1778
1779 /*** Change in activity or activity's target. ***/
1780
1781 /* May change focus if focus unit gets a new activity.
1782 * But if new activity is Idle, it means user specifically selected
1783 * the unit */
1785 && (packet_unit->activity != ACTIVITY_IDLE
1786 || packet_unit->has_orders)) {
1787 check_focus = TRUE;
1788 }
1789
1791
1792 /* Wakeup Focus */
1794 && plr != nullptr
1795 && is_human(plr)
1796 && owner == plr
1798 && packet_unit->activity == ACTIVITY_IDLE
1800 && is_player_phase(plr, game.info.phase)) {
1801 /* Many wakeup units per tile are handled */
1803 check_focus = FALSE; /* and keep it */
1804 }
1805
1806 punit->activity = packet_unit->activity;
1807 punit->activity_target = packet_unit->activity_target;
1808
1810 != packet_unit->client.transported_by) {
1811 if (packet_unit->client.transported_by == -1) {
1812 /* The unit was unloaded from its transport. The check for a new
1813 * transport is done below. */
1815 }
1816
1817 punit->client.transported_by = packet_unit->client.transported_by;
1818 }
1819
1820 if (punit->client.occupied != packet_unit->client.occupied) {
1822 /* Special case: (un)loading a unit in a transporter on the same
1823 * tile as the focus unit may (dis)allow the focus unit to be
1824 * loaded. Thus the orders->(un)load menu item needs updating. */
1826 }
1827 punit->client.occupied = packet_unit->client.occupied;
1828 }
1829
1830 punit->has_orders = packet_unit->has_orders;
1831 punit->orders.length = packet_unit->orders.length;
1832 punit->orders.index = packet_unit->orders.index;
1833 punit->orders.repeat = packet_unit->orders.repeat;
1834 punit->orders.vigilant = packet_unit->orders.vigilant;
1835
1836 /* We cheat by just stealing the packet unit's list. */
1837 if (punit->orders.list) {
1839 }
1840 punit->orders.list = packet_unit->orders.list;
1841 packet_unit->orders.list = nullptr;
1842
1843 if (plr == nullptr || owner == plr) {
1845 }
1846 } /*** End of Change in activity or activity's target. ***/
1847
1848 /* These two lines force the menus to be updated as appropriate when
1849 * the focus unit changes. */
1850 if (unit_is_in_focus(punit)) {
1852 }
1853
1854 if (punit->homecity != packet_unit->homecity) {
1855 /* change homecity */
1856 struct city *hcity;
1857
1859 unit_list_remove(hcity->units_supported, punit);
1861 }
1862
1863 punit->homecity = packet_unit->homecity;
1865 unit_list_prepend(hcity->units_supported, punit);
1867 }
1868
1869 /* This can change total upkeep figures */
1871 }
1872
1873 if (punit->hp != packet_unit->hp) {
1874 /* hp changed */
1875 punit->hp = packet_unit->hp;
1877 }
1878
1880 /* Unit type has changed (been upgraded) */
1881 struct city *ccity = tile_city(unit_tile(punit));
1882
1886 if (ccity != NULL && (ccity->id != punit->homecity)) {
1888 }
1889 if (unit_is_in_focus(punit)) {
1890 /* Update the orders menu -- the unit might have new abilities */
1892 }
1894 }
1895
1896 /* May change focus if an attempted move or attack exhausted unit */
1897 if (punit->moves_left != packet_unit->moves_left
1898 && unit_is_in_focus(punit)) {
1899 check_focus = TRUE;
1900 }
1901
1903 /*** Change position ***/
1904 struct city *ccity = tile_city(unit_tile(punit));
1905
1907 moved = TRUE;
1908
1909 /* Show where the unit is going. */
1911
1912 if (ccity != nullptr) {
1914 /* Unit moved out of a city - update the occupied status. */
1915 bool new_occupied =
1916 (unit_list_size(ccity->tile->units) > 0);
1917
1918 if (ccity->client.occupied != new_occupied) {
1919 ccity->client.occupied = new_occupied;
1923 }
1924 }
1925 }
1926
1927 if (ccity->id == punit->homecity) {
1929 } else {
1931 }
1932 }
1933
1934 if ((ccity = tile_city(unit_tile(punit)))) {
1936 /* Unit moved into a city - obviously it's occupied. */
1937 if (!ccity->client.occupied) {
1938 ccity->client.occupied = TRUE;
1942 }
1943 }
1944 }
1945
1946 if (ccity->id == punit->homecity) {
1948 } else {
1950 }
1951 }
1952
1953 } /*** End of Change position. ***/
1954
1955 if (repaint_city || repaint_unit) {
1956 /* We repaint the city if the unit itself needs repainting or if
1957 * there is a special city-only redrawing to be done. */
1960 }
1962 && tile_city(unit_tile(punit)) != pcity) {
1963 /* Refresh the city we're occupying too. */
1965 }
1966 }
1967
1969 != packet_unit->upkeep[O_GOLD]);
1970 /* unit upkeep information */
1972 punit->upkeep[o] = packet_unit->upkeep[o];
1974
1975 punit->nationality = packet_unit->nationality;
1976 punit->veteran = packet_unit->veteran;
1977 punit->moves_left = packet_unit->moves_left;
1978 punit->fuel = packet_unit->fuel;
1979 punit->goto_tile = packet_unit->goto_tile;
1980 punit->paradropped = packet_unit->paradropped;
1981 punit->stay = packet_unit->stay;
1982 if (punit->done_moving != packet_unit->done_moving) {
1983 punit->done_moving = packet_unit->done_moving;
1984 check_focus = TRUE;
1985 }
1986
1987 /* This won't change punit; it enqueues the call for later handling. */
1990
1991 if ((punit->action_decision_want != packet_unit->action_decision_want
1993 != packet_unit->action_decision_tile))
1995 /* The unit wants the player to decide. */
1997 /* Pop up an action selection dialog if the unit has focus or give
1998 * the unit higher priority in the focus queue if not. */
1999 punit->action_decision_tile = packet_unit->action_decision_tile;
2001 check_focus = TRUE;
2002 } else {
2003 /* Refresh already open action selection dialog. */
2007 tile_index(
2008 packet_unit->action_decision_tile),
2011 }
2012 }
2013 punit->action_decision_want = packet_unit->action_decision_want;
2014 punit->action_decision_tile = packet_unit->action_decision_tile;
2015 } else {
2016 /*** Create new unit ***/
2019
2020 if (owner != nullptr) {
2021 unit_list_prepend(owner->units, punit);
2022 }
2024
2026
2028 unit_list_prepend(pcity->units_supported, punit);
2029 }
2030
2031 log_debug("New %s %s id %d (%d %d) hc %d %s",
2035 (pcity ? city_name_get(pcity) : "(unknown)"));
2036
2039
2040 /* Check if we should link cargo units.
2041 * (This might be necessary if the cargo info was sent to us before
2042 * this transporter.) */
2043 if (punit->client.occupied) {
2045 if (aunit->client.transported_by == punit->id) {
2046 fc_assert(aunit->transporter == NULL);
2048 }
2050 }
2051
2052 if ((pcity = tile_city(unit_tile(punit)))) {
2053 /* The unit is in a city - obviously it's occupied. */
2055 }
2056
2058 /* The unit wants the player to decide. */
2060 check_focus = TRUE;
2061 }
2062
2064 } /*** End of Create new unit ***/
2065
2067
2068 /* Check if we have to load the unit on a transporter. */
2069 if (punit->client.transported_by != -1) {
2070 struct unit *ptrans
2071 = game_unit_by_number(packet_unit->client.transported_by);
2072
2073 /* Load unit only if transporter is known by the client.
2074 * (If not, cargo will be loaded later when the transporter info is
2075 * sent to the client.) */
2077 /* First, we have to unload the unit from its old transporter. */
2080
2081#ifdef DEBUG_TRANSPORT
2082 log_debug("load %s (ID: %d) onto %s (ID: %d)",
2085 } else if (ptrans && ptrans == unit_transport_get(punit)) {
2086 log_debug("%s (ID: %d) is loaded onto %s (ID: %d)",
2089 } else {
2090 log_debug("%s (ID: %d) is not loaded", unit_name_translation(punit),
2091 punit->id);
2092#endif /* DEBUG_TRANSPORT */
2093
2094 }
2095 }
2096
2101 /* Update (an possible active) unit select dialog. */
2103 }
2104
2105 if (repaint_unit) {
2107 }
2108
2109 if ((check_focus || get_num_units_in_focus() == 0)
2110 && plr != nullptr
2111 && is_human(plr)
2112 && is_player_phase(plr, game.info.phase)) {
2114 }
2115
2116 if (need_menus_update) {
2117 menus_update();
2118 }
2119
2120 if (!client_has_player() || owner == plr) {
2123 }
2126 }
2127 }
2128
2129 return ret;
2130}
2131
2132/************************************************************************/
2139{
2140 struct city *pcity = game_city_by_number(packet->city_id);
2141
2142 if (!pcity) {
2143 log_error("Investigate city: unknown city id %d!",
2144 packet->city_id);
2145 return;
2146 }
2147
2148 /* Start collecting supported and present units. */
2149
2150 /* Ensure we are not already in an investigate cycle. */
2151 fc_assert(pcity->client.collecting_info_units_supported == NULL);
2152 fc_assert(pcity->client.collecting_info_units_present == NULL);
2153 pcity->client.collecting_info_units_supported =
2155 pcity->client.collecting_info_units_present =
2157}
2158
2159/************************************************************************/
2163{
2164}
2165
2166/************************************************************************/
2170{
2171 struct city *pcity;
2172 struct unit *punit;
2173
2174 /* Special case for a diplomat/spy investigating a city: The investigator
2175 * needs to know the supported and present units of a city, whether or not
2176 * they are fogged. So, we send a list of them all before sending the city
2177 * info. */
2179 || packet->packet_use == UNIT_INFO_CITY_PRESENT) {
2180
2182 if (!pcity) {
2183 log_error("Investigate city: unknown city id %d!",
2184 packet->info_city_id);
2185 return;
2186 }
2187
2188 /* Append a unit struct to the proper list. */
2189 punit = unpackage_short_unit(packet);
2190 if (punit != nullptr) {
2191 if (packet->packet_use == UNIT_INFO_CITY_SUPPORTED) {
2192 fc_assert(pcity->client.collecting_info_units_supported != NULL);
2193 unit_list_append(pcity->client.collecting_info_units_supported, punit);
2194 } else {
2196 fc_assert(pcity->client.collecting_info_units_present != NULL);
2197 unit_list_append(pcity->client.collecting_info_units_present, punit);
2198 }
2199 }
2200
2201 /* Done with special case. */
2202 return;
2203 }
2204
2205 if (player_by_number(packet->owner) == client.conn.playing) {
2206 log_error("handle_unit_short_info() for own unit.");
2207 }
2208
2209 punit = unpackage_short_unit(packet);
2210 if (punit != nullptr && handle_unit_packet_common(punit)) {
2213 }
2214}
2215
2216/************************************************************************/
2219void handle_set_topology(int topology_id, int wrap_id)
2220{
2221 wld.map.topology_id = topology_id;
2222 wld.map.wrap_id = wrap_id;
2223
2224 if (forced_tileset_name[0] == '\0'
2225 && (tileset_map_topo_compatible(topology_id, tileset, NULL)
2228 const char *ts_to_load;
2229
2231
2232 if (ts_to_load != NULL && ts_to_load[0] != '\0' && strcmp(tileset_basename(tileset), ts_to_load)) {
2234 }
2235 }
2236}
2237
2238/************************************************************************/
2242void handle_map_info(const struct packet_map_info *packet)
2243{
2244 int ts_topo;
2245
2246 if (!map_is_empty()) {
2247 map_free(&(wld.map), FALSE);
2249 }
2250
2251 wld.map.xsize = packet->xsize;
2252 wld.map.ysize = packet->ysize;
2253
2257
2261 _("Map topology (%s) and tileset (%s) incompatible."),
2263 }
2264
2265 wld.map.topology_id = packet->topology_id;
2266 wld.map.wrap_id = packet->wrap_id;
2267
2272 mapdeco_init();
2273
2275
2277
2278 packhand_init();
2279}
2280
2281/************************************************************************/
2285{
2286 bool boot_help;
2288 bool toggle_edit_ui = FALSE;
2289
2290 if (game.info.aifill != pinfo->aifill) {
2292 }
2293 if (game.info.skill_level != pinfo->skill_level) {
2295 }
2296
2297 if (game.info.is_edit_mode != pinfo->is_edit_mode) {
2299
2301 /* Clears the current goto command. */
2303
2304 if (pinfo->is_edit_mode) {
2306 /* Gui didn't handle this */
2308 _("This scenario may have manually set properties the editor "
2309 "cannot handle."));
2311 _("They won't be saved when scenario is saved from the editor."));
2312 }
2313 }
2314 }
2315
2316 game.info = *pinfo;
2317
2318 /* check the values! */
2319#define VALIDATE(_count, _maximum, _string) \
2320 if (game.info._count > _maximum) { \
2321 log_error("handle_game_info(): Too many " _string "; using %d of %d", \
2322 _maximum, game.info._count); \
2323 game.info._count = _maximum; \
2324 }
2325
2326 VALIDATE(granary_num_inis, MAX_GRANARY_INIS, "granary entries");
2327#undef VALIDATE
2328
2333
2335 && game.info.victory_conditions != pinfo->victory_conditions);
2336 if (boot_help) {
2337 boot_help_texts(); /* reboot, after setting game.spacerace */
2338 }
2340 menus_update();
2344 }
2345
2346 if (can_client_change_view()) {
2348 }
2349
2350 if (toggle_edit_ui) {
2352 }
2353
2355}
2356
2357/************************************************************************/
2364
2365/************************************************************************/
2368void handle_timeout_info(float seconds_to_phasedone, float last_turn_change_time)
2369{
2370 if (current_turn_timeout() != 0 && seconds_to_phasedone >= 0) {
2371 /* If this packet is received in the middle of a turn, this value
2372 * represents the number of seconds from now to the end of the turn
2373 * (not from the start of the turn). So we need to restart our
2374 * timer. */
2375 set_seconds_to_turndone(seconds_to_phasedone);
2376 }
2377
2378 game.tinfo.last_turn_change_time = last_turn_change_time;
2379}
2380
2381/************************************************************************/
2393
2394/************************************************************************/
2403
2404/************************************************************************/
2409void handle_player_remove(int playerno)
2410{
2411 struct player_slot *pslot;
2412 struct player *pplayer;
2413 int plr_nbr;
2414
2415 pslot = player_slot_by_number(playerno);
2416
2417 if (NULL == pslot || !player_slot_is_used(pslot)) {
2418 /* Ok, just ignore. */
2419 return;
2420 }
2421
2422 pplayer = player_slot_get_player(pslot);
2423
2424 if (can_client_change_view()) {
2425 close_intel_dialog(pplayer);
2426 }
2427
2428 /* Update the connection informations. */
2429 if (client_player() == pplayer) {
2431 }
2433 pconn->playing = NULL;
2435 conn_list_clear(pplayer->connections);
2436
2437 /* Save player number before player is freed */
2438 plr_nbr = player_number(pplayer);
2439
2440 player_destroy(pplayer);
2441
2444
2447}
2448
2449/************************************************************************/
2455{
2456 bool is_new_nation = FALSE;
2457 bool turn_done_changed = FALSE;
2458 bool new_player = FALSE;
2459 int i;
2460 struct player *pplayer, *my_player;
2461 struct nation_type *pnation;
2462 struct government *pgov, *ptarget_gov;
2463 struct player_slot *pslot;
2464 struct team_slot *tslot;
2465 bool gov_change;
2466
2467 /* Player. */
2468 pslot = player_slot_by_number(pinfo->playerno);
2469 fc_assert(NULL != pslot);
2471 pplayer = player_new(pslot);
2472
2473 if ((pplayer->rgb == NULL) != !pinfo->color_valid
2474 || (pinfo->color_valid
2475 && (pplayer->rgb->r != pinfo->color_red
2476 || pplayer->rgb->g != pinfo->color_green
2477 || pplayer->rgb->b != pinfo->color_blue))) {
2478 struct rgbcolor *prgbcolor;
2479
2480 if (pinfo->color_valid) {
2481 prgbcolor = rgbcolor_new(pinfo->color_red,
2482 pinfo->color_green,
2483 pinfo->color_blue);
2485 } else {
2486 prgbcolor = NULL;
2487 }
2488
2489 player_set_color(pplayer, prgbcolor);
2490 tileset_player_init(tileset, pplayer);
2491
2493
2494 /* Queue a map update -- may need to redraw borders, etc. */
2496 }
2497 pplayer->client.color_changeable = pinfo->color_changeable;
2498
2499 if (new_player) {
2500 /* Initialise client side player data (tile vision). At the moment
2501 * redundant as the values are initialised with 0 due to fc_calloc(). */
2502 client_player_init(pplayer);
2503 }
2504
2505 /* Team. */
2507 fc_assert(NULL != tslot);
2508
2509 /* Should never fail when slot given is not nullptr */
2510 team_add_player(pplayer, team_new(tslot));
2511
2512 pnation = nation_by_number(pinfo->nation);
2513 pgov = government_by_number(pinfo->government);
2514 ptarget_gov = government_by_number(pinfo->target_government);
2515
2516 /* Now update the player information. */
2517 sz_strlcpy(pplayer->name, pinfo->name);
2518 sz_strlcpy(pplayer->username, pinfo->username);
2519 pplayer->unassigned_user = pinfo->unassigned_user;
2520
2521 is_new_nation = player_set_nation(pplayer, pnation);
2522 pplayer->is_male = pinfo->is_male;
2523 pplayer->score.game = pinfo->score;
2524 pplayer->was_created = pinfo->was_created;
2525
2526 pplayer->autoselect_weight = pinfo->autoselect_weight;
2527 pplayer->economic.gold = pinfo->gold;
2528 pplayer->economic.tax = pinfo->tax;
2529 pplayer->economic.science = pinfo->science;
2530 pplayer->economic.luxury = pinfo->luxury;
2531 pplayer->client.tech_upkeep = pinfo->tech_upkeep;
2532 gov_change = (!new_player && pgov != pplayer->government
2533 && pplayer->government != NULL);
2534 pplayer->government = pgov;
2535 pplayer->target_government = ptarget_gov;
2536 pplayer->real_embassy = pinfo->real_embassy;
2537 pplayer->gives_shared_vision = pinfo->gives_shared_vision;
2538 pplayer->gives_shared_tiles = pinfo->gives_shared_tiles;
2539 pplayer->style = style_by_number(pinfo->style);
2540
2541 if (pplayer == client.conn.playing) {
2542 bool music_change = FALSE;
2543
2544 if (pplayer->music_style != pinfo->music_style) {
2545 pplayer->music_style = pinfo->music_style;
2547 }
2548 if (pplayer->client.mood != pinfo->mood) {
2549 pplayer->client.mood = pinfo->mood;
2551 }
2552
2553 if (music_change) {
2555 }
2556
2557 if (gov_change) {
2558 audio_play_sound(pgov->sound_str, pgov->sound_alt, pgov->sound_alt2);
2559 }
2560 }
2561
2562 pplayer->history = pinfo->history;
2563 pplayer->client.culture = pinfo->culture;
2564
2565 if (pplayer->economic.infra_points != pinfo->infrapoints) {
2566 pplayer->economic.infra_points = pinfo->infrapoints;
2568 }
2569
2570 /* Don't use player_iterate or player_slot_count here, because we ignore
2571 * the real number of players and we want to read all the datas. */
2572 fc_assert(ARRAY_SIZE(pplayer->ai_common.love) >= ARRAY_SIZE(pinfo->love));
2573 for (i = 0; i < ARRAY_SIZE(pinfo->love); i++) {
2574 pplayer->ai_common.love[i] = pinfo->love[i];
2575 }
2576
2578
2579 pplayer->is_connected = pinfo->is_connected;
2580
2581 for (i = 0; i < B_LAST; i++) {
2582 pplayer->wonders[i] = pinfo->wonders[i];
2583 }
2584
2585 /* Set AI.control. */
2586 if (is_ai(pplayer) != BV_ISSET(pinfo->flags, PLRF_AI)) {
2587 BV_SET_VAL(pplayer->flags, PLRF_AI, BV_ISSET(pinfo->flags, PLRF_AI));
2588 if (pplayer == my_player) {
2589 if (is_ai(my_player)) {
2590 output_window_append(ftc_client, _("AI mode is now ON."));
2591 if (!gui_options.ai_manual_turn_done && !pplayer->phase_done) {
2592 /* End turn immediately */
2594 }
2595 } else {
2596 output_window_append(ftc_client, _("AI mode is now OFF."));
2597 }
2598 }
2599 }
2600
2601 pplayer->flags = pinfo->flags;
2602
2603 pplayer->ai_common.science_cost = pinfo->science_cost;
2604
2605 turn_done_changed = (pplayer->phase_done != pinfo->phase_done
2606 || (BV_ISSET(pplayer->flags, PLRF_AI) !=
2607 BV_ISSET(pinfo->flags, PLRF_AI)));
2608 pplayer->phase_done = pinfo->phase_done;
2609
2610 pplayer->is_ready = pinfo->is_ready;
2611 pplayer->nturns_idle = pinfo->nturns_idle;
2612 pplayer->is_alive = pinfo->is_alive;
2613 pplayer->turns_alive = pinfo->turns_alive;
2614 pplayer->ai_common.barbarian_type = pinfo->barbarian_type;
2615 pplayer->revolution_finishes = pinfo->revolution_finishes;
2616 pplayer->ai_common.skill_level = pinfo->ai_skill_level;
2617
2618 fc_assert(pinfo->multip_count == multiplier_count());
2619 game.control.num_multipliers = pinfo->multip_count;
2620 multipliers_iterate(pmul) {
2621 int idx = multiplier_index(pmul);
2622
2623 pplayer->multipliers[idx].value = pinfo->multiplier[idx];
2624 pplayer->multipliers[idx].target = pinfo->multiplier_target[idx];
2625 pplayer->multipliers[idx].changed = pinfo->multiplier_changed[idx];
2627
2628 /* if the server requests that the client reset, then information about
2629 * connections to this player are lost. If this is the case, insert the
2630 * correct conn back into the player->connections list */
2631 if (conn_list_size(pplayer->connections) == 0) {
2633 if (pplayer == pconn->playing) {
2634 /* insert the controller into first position */
2635 if (pconn->observer) {
2637 } else {
2639 }
2640 }
2642 }
2643
2644
2645 /* The player information is now fully set. Update the GUI. */
2646
2647 if (pplayer == my_player && can_client_change_view()) {
2648 if (turn_done_changed) {
2650 }
2657 menus_update();
2658 }
2659
2661
2664
2665 if (is_new_nation) {
2667
2668 /* When changing nation during a running game, some refreshing is needed.
2669 * This may not be the only one! */
2671 }
2672
2673 if (can_client_change_view()) {
2674 /* Just about any changes above require an update to the intelligence
2675 * dialog. */
2676 update_intel_dialog(pplayer);
2677 }
2678
2681 FALSE);
2682}
2683
2684/************************************************************************/
2688{
2689 struct research *presearch;
2690 bool tech_changed = FALSE;
2691 bool poptechup = FALSE;
2693 int gained_techs_num = 0, i;
2695
2696#ifdef FREECIV_DEBUG
2697 log_verbose("Research nb %d inventions: %s",
2698 packet->id,
2699 packet->inventions);
2700#endif
2701 presearch = research_by_number(packet->id);
2703
2704 poptechup = (presearch->researching != packet->researching
2705 || presearch->tech_goal != packet->tech_goal);
2706 presearch->techs_researched = packet->techs_researched;
2707 if (presearch->future_tech == 0 && packet->future_tech > 0) {
2709 }
2710 presearch->future_tech = packet->future_tech;
2711 presearch->researching = packet->researching;
2712 presearch->client.researching_cost = packet->researching_cost;
2713 presearch->bulbs_researched = packet->bulbs_researched;
2714 presearch->tech_goal = packet->tech_goal;
2715 presearch->client.total_bulbs_prod = packet->total_bulbs_prod;
2716
2718 newstate = packet->inventions[advi] - '0';
2720
2721 if (newstate != oldstate) {
2722 if (TECH_KNOWN == newstate) {
2724 if (A_NONE != advi) {
2726 }
2727 } else if (TECH_KNOWN == oldstate) {
2729 }
2730 }
2732
2734
2735 if (C_S_RUNNING == client_state()) {
2737 if (poptechup && is_human(client_player())) {
2739 }
2741 if (tech_changed) {
2742 /* Some ways a new or lost tech can affect menus:
2743 * - If tech is needed for certain governments, the government
2744 * switching menus need updating.
2745 * - If we just learned/lost bridge building and focus is on a
2746 * worker on a river, the road menu item needs updating. */
2747 menus_update();
2748
2749 script_client_signal_emit("new_tech");
2750
2751 /* If we got a new tech the tech tree news an update. */
2753 }
2754 for (i = 0; i < gained_techs_num; i++) {
2756 }
2757 }
2758 if (editor_is_active()) {
2762 FALSE);
2764 }
2765 }
2766}
2767
2768/************************************************************************/
2772{
2774
2775 if (presearch == NULL) {
2776 log_error("Received unknown research for clearing: %d.", id);
2777 return;
2778 }
2779
2780 /* Do we need to set other fields? */
2781 presearch->researching = A_UNKNOWN;
2782 presearch->future_tech = 0;
2783 presearch->tech_goal = A_UNKNOWN;
2784
2788
2789 if (editor_is_active()) {
2793 FALSE);
2795 }
2796}
2797
2798/************************************************************************/
2802{
2803 struct player *plr1 = player_by_number(packet->plr1);
2804 struct player *plr2 = player_by_number(packet->plr2);
2805 struct player *my_player = client_player();
2806 struct player_diplstate *ds = player_diplstate_get(plr1, plr2);
2808
2809 fc_assert_ret(ds != NULL);
2810
2811 if (client_has_player() && my_player == plr2) {
2812 if (ds->type != packet->type) {
2814 }
2815
2816 /* Check if we detect change to armistice with us. If so,
2817 * ready all units for movement out of the territory in
2818 * question; otherwise they will be disbanded. */
2820 && DS_ARMISTICE == packet->type) {
2823 || tile_owner(unit_tile(punit)) != plr1) {
2824 continue;
2825 }
2828 }
2829 if (punit->activity != ACTIVITY_IDLE) {
2831 }
2833 }
2834 }
2835
2836 ds->type = packet->type;
2837 ds->turns_left = packet->turns_left;
2838 ds->has_reason_to_cancel = packet->has_reason_to_cancel;
2839 ds->contact_turns_left = packet->contact_turns_left;
2840
2843 }
2844
2847 /* An action selection dialog is open and our diplomatic state just
2848 * changed. Find out if the relationship that changed was to a
2849 * potential target. */
2850 struct tile *tgt_tile = NULL;
2851
2852 /* Is a refresh needed because of a unit target? */
2854 struct unit *tgt_unit;
2855
2857
2858 if (tgt_unit != NULL && tgt_unit->owner == plr1) {
2859 /* An update is needed because of this unit target. */
2862 }
2863 }
2864
2865 /* Is a refresh needed because of a city target? */
2867 struct city *tgt_city;
2868
2870
2871 if (tgt_city != NULL && tgt_city->owner == plr1) {
2872 /* An update is needed because of this city target.
2873 * Overwrites any target tile from a unit. */
2876 }
2877 }
2878
2879 if (tgt_tile
2880 || ((tgt_tile = index_to_tile(&(wld.map),
2882 && tile_owner(tgt_tile) == plr1)) {
2883 /* The diplomatic relationship to the target in an open action
2884 * selection dialog have changed. This probably changes
2885 * the set of available actions. */
2889 tgt_tile->index,
2892 }
2893 }
2894}
2895
2896/************************************************************************/
2903{
2904 struct connection *pconn = conn_by_number(pinfo->id);
2906
2907 log_debug("conn_info id%d used%d est%d plr%d obs%d acc%d",
2908 pinfo->id, pinfo->used, pinfo->established, pinfo->player_num,
2909 pinfo->observer, (int) pinfo->access_level);
2910 log_debug("conn_info \"%s\" \"%s\" \"%s\"",
2911 pinfo->username, pinfo->addr, pinfo->capability);
2912
2913 if (!pinfo->used) {
2914 /* Forget the connection */
2915 if (!pconn) {
2916 log_verbose("Server removed unknown connection %d", pinfo->id);
2917 return;
2918 }
2920 pconn = NULL;
2921 } else {
2922 struct player_slot *pslot = player_slot_by_number(pinfo->player_num);
2923 struct player *pplayer = NULL;
2924
2925 if (NULL != pslot) {
2926 pplayer = player_slot_get_player(pslot);
2927 }
2928
2929 if (!pconn) {
2930 log_verbose("Server reports new connection %d %s",
2931 pinfo->id, pinfo->username);
2932
2933 pconn = fc_calloc(1, sizeof(struct connection));
2934 pconn->buffer = NULL;
2935 pconn->send_buffer = NULL;
2936 pconn->ping_time = -1.0;
2937 if (pplayer) {
2939 }
2942 } else {
2943 log_packet("Server reports updated connection %d %s",
2944 pinfo->id, pinfo->username);
2945 if (pplayer != pconn->playing) {
2946 if (NULL != pconn->playing) {
2947 conn_list_remove(pconn->playing->connections, pconn);
2948 }
2949 if (pplayer) {
2951 }
2952 }
2953 }
2954
2955 pconn->id = pinfo->id;
2956 pconn->established = pinfo->established;
2957 pconn->observer = pinfo->observer;
2958 pconn->access_level = pinfo->access_level;
2959 pconn->playing = pplayer;
2960
2961 sz_strlcpy(pconn->username, pinfo->username);
2962 sz_strlcpy(pconn->addr, pinfo->addr);
2963 sz_strlcpy(pconn->capability, pinfo->capability);
2964
2965 if (pinfo->id == client.conn.id) {
2966 /* NB: In this case, pconn is not a duplication of client.conn.
2967 *
2968 * pconn->addr is our address that the server knows whereas
2969 * client.conn.addr is the address to the server. Also,
2970 * pconn->capability stores our capabilites known at server side
2971 * whereas client.conn.capability represents the capabilities of the
2972 * server. */
2973 if (client.conn.playing != pplayer
2974 || client.conn.observer != pinfo->observer) {
2975 /* Our connection state changed, let prepare the changes and reset
2976 * the game. */
2978 }
2979
2980 /* Copy our current state into the static structure (our connection
2981 * to the server). */
2982 client.conn.established = pinfo->established;
2983 client.conn.observer = pinfo->observer;
2984 client.conn.access_level = pinfo->access_level;
2985 client.conn.playing = pplayer;
2986 sz_strlcpy(client.conn.username, pinfo->username);
2987 }
2988 }
2989
2992
2993 if (pinfo->used && pinfo->id == client.conn.id) {
2994 /* For updating the sensitivity of the "Edit Mode" menu item,
2995 * among other things. */
2996 menus_update();
2997 }
2998
3001 }
3002}
3003
3004/************************************************************************/
3008void handle_conn_ping_info(int connections, const int *conn_id,
3009 const float *ping_time)
3010{
3011 int i;
3012
3013 for (i = 0; i < connections; i++) {
3014 struct connection *pconn = conn_by_number(conn_id[i]);
3015
3016 if (!pconn) {
3017 continue;
3018 }
3019
3020 pconn->ping_time = ping_time[i];
3021 log_debug("conn-id=%d, ping=%fs", pconn->id, pconn->ping_time);
3022 }
3023 /* The old_ping_time data is ignored. */
3024
3026}
3027
3028/************************************************************************/
3031void handle_achievement_info(int id, bool gained, bool first)
3032{
3033 struct achievement *pach;
3034
3036 log_error("Received illegal achievement info %d", id);
3037 return;
3038 }
3039
3041
3042 if (gained) {
3043 BV_SET(pach->achievers, player_index(client_player()));
3044 } else {
3045 BV_CLR(pach->achievers, player_index(client_player()));
3046 }
3047
3048 if (first) {
3049 pach->first = client_player();
3050 }
3051}
3052
3053/************************************************************************/
3068static bool spaceship_autoplace(struct player *pplayer,
3069 struct player_spaceship *ship)
3070{
3073
3074 if (next_spaceship_component(pplayer, ship, &place)) {
3076
3077 return TRUE;
3078 }
3079 }
3080
3081 return FALSE;
3082}
3083
3084/************************************************************************/
3088{
3089 struct player_spaceship *ship;
3090 struct player *pplayer = player_by_number(p->player_num);
3091
3092 fc_assert_ret_msg(NULL != pplayer, "Invalid player number %d.",
3093 p->player_num);
3094
3095 ship = &pplayer->spaceship;
3096 ship->state = p->sship_state;
3097 ship->structurals = p->structurals;
3098 ship->components = p->components;
3099 ship->modules = p->modules;
3100 ship->fuel = p->fuel;
3101 ship->propulsion = p->propulsion;
3102 ship->habitation = p->habitation;
3103 ship->life_support = p->life_support;
3104 ship->solar_panels = p->solar_panels;
3105 ship->launch_year = p->launch_year;
3106 ship->population = p->population;
3107 ship->mass = p->mass;
3108 ship->support_rate = p->support_rate;
3109 ship->energy_rate = p->energy_rate;
3110 ship->success_rate = p->success_rate;
3111 ship->travel_time = p->travel_time;
3112 ship->structure = p->structure;
3113
3114 if (pplayer != client_player()) {
3115 refresh_spaceship_dialog(pplayer);
3116 menus_update();
3117 return;
3118 }
3119
3120 if (!spaceship_autoplace(pplayer, ship)) {
3121 /* We refresh the dialog when the packet did *not* cause placing
3122 * of new part. That's because those cases where part is placed, are
3123 * followed by exactly one case where there's no more parts to place -
3124 * we want to refresh the dialog only when that last packet comes. */
3125 refresh_spaceship_dialog(pplayer);
3126 }
3127}
3128
3129/**********************************************************************/
3135{
3136 if (cont1 == cont2) {
3137 return nullptr;
3138 } else if (cont1 >= 0 && cont2 <= 0) {
3139 return &wld.map.client.adj_matrix[cont1][-cont2];
3140 } else if (cont1 <= 0 && cont2 >= 0) {
3141 return &wld.map.client.adj_matrix[cont2][-cont1];
3142 }
3143 return nullptr;
3144}
3145
3146/**********************************************************************/
3153static inline void update_continent_cache(const struct tile *ptile,
3156{
3157 /* Update known continents */
3159 int cont;
3160
3161 /* Expand sizes array */
3163 (new_cont + 1) * sizeof(*wld.map.continent_sizes));
3164
3165 /* Expand adjacency matrix */
3167 (new_cont + 1) * sizeof(*wld.map.client.adj_matrix));
3168
3169 /* Initialize new spots */
3170 for (cont = wld.map.num_continents + 1; cont <= new_cont; cont++) {
3171 wld.map.continent_sizes[cont] = 0;
3173 sizeof(*wld.map.client.adj_matrix[cont]));
3174 }
3175
3177 } else if (new_cont < -wld.map.num_oceans) {
3178 int cont, ocean;
3179
3180 /* Expand sizes array */
3182 (-new_cont + 1) * sizeof(*wld.map.ocean_sizes));
3183
3184 /* Initialize new spots */
3185 for (ocean = wld.map.num_oceans + 1; ocean <= -new_cont; ocean++) {
3186 wld.map.ocean_sizes[ocean] = 0;
3187 }
3188
3189 /* Expand adjacency matrix */
3190 for (cont = 0; cont <= wld.map.num_continents; cont++) {
3192 wld.map.client.adj_matrix[cont],
3193 (-new_cont + 1) * sizeof(*wld.map.client.adj_matrix[cont])
3194 );
3195
3196 for (ocean = wld.map.num_oceans + 1; ocean <= -new_cont; ocean++) {
3197 wld.map.client.adj_matrix[cont][ocean] = 0;
3198 }
3199 }
3200
3202 }
3203
3204 /* Decrement old continent/ocean size */
3205 if (old_cont > 0) {
3207 } else if (old_cont < 0) {
3209 }
3210
3211 /* Increment new continent/ocean size */
3212 if (new_cont > 0) {
3214 } else if (new_cont < 0) {
3216 }
3217
3218 /* Update tile adjacency counts */
3219 adjc_iterate(&(wld.map), ptile, adj_tile) {
3221 int *padjc_count;
3222
3223 /* Decrement old adjacency */
3225 if (padjc_count) {
3226 fc_assert(*padjc_count > 0);
3227 (*padjc_count)--;
3228 }
3229
3230 /* Increment new adjacency */
3232 if (padjc_count) {
3233 (*padjc_count)++;
3234 }
3236}
3237
3238/************************************************************************/
3241void handle_tile_info(const struct packet_tile_info *packet)
3242{
3243 enum known_type new_known;
3244 enum known_type old_known;
3245 bool known_changed = FALSE;
3246 bool tile_changed = FALSE;
3247 struct player *powner = player_by_number(packet->owner);
3248 struct player *eowner = player_by_number(packet->extras_owner);
3249 struct extra_type *presource = NULL;
3250 struct terrain *pterrain = terrain_by_number(packet->terrain);
3251 struct tile *ptile = index_to_tile(&(wld.map), packet->tile);
3252
3253 fc_assert_ret_msg(NULL != ptile, "Invalid tile index %d.", packet->tile);
3255
3256 if (packet->resource != MAX_EXTRA_TYPES) {
3257 presource = extra_by_number(packet->resource);
3258 }
3259
3260 if (NULL == tile_terrain(ptile) || pterrain != tile_terrain(ptile)) {
3262 switch (old_known) {
3263 case TILE_UNKNOWN:
3264 tile_set_terrain(ptile, pterrain);
3265 break;
3266 case TILE_KNOWN_UNSEEN:
3267 case TILE_KNOWN_SEEN:
3268 if (NULL != pterrain || TILE_UNKNOWN == packet->known) {
3269 tile_set_terrain(ptile, pterrain);
3270 } else {
3272 log_error("handle_tile_info() unknown terrain (%d, %d).",
3273 TILE_XY(ptile));
3274 }
3275 break;
3276 };
3277 }
3278
3279 if (!BV_ARE_EQUAL(ptile->extras, packet->extras)) {
3280 ptile->extras = packet->extras;
3282 }
3283
3284 tile_changed = tile_changed || (tile_resource(ptile) != presource);
3285
3286 /* Always called after setting terrain */
3287 tile_set_resource(ptile, presource);
3288
3289 if (tile_owner(ptile) != powner) {
3290 tile_set_owner(ptile, powner, NULL);
3292 }
3293 if (extra_owner(ptile) != eowner) {
3294 ptile->extras_owner = eowner;
3296 }
3297
3298 ptile->altitude = packet->altitude;
3299
3300 if (packet->placing < 0) {
3301 if (ptile->placing != NULL) {
3303 ptile->placing = NULL;
3304 ptile->infra_turns = 0;
3305 }
3306 } else {
3307 struct extra_type *old = ptile->placing;
3308
3309 ptile->placing = extra_by_number(packet->placing);
3310 if (ptile->placing != old
3311 || ptile->infra_turns != packet->place_turn - game.info.turn) {
3313 }
3314 ptile->infra_turns = packet->place_turn - game.info.turn;
3315 }
3316
3317 if (NULL == tile_worked(ptile)
3318 || tile_worked(ptile)->id != packet->worked) {
3319 if (IDENTITY_NUMBER_ZERO != packet->worked) {
3320 struct city *pwork = game_city_by_number(packet->worked);
3321
3322 if (NULL == pwork) {
3323 char named[MAX_LEN_CITYNAME];
3324
3325 /* New unseen ("invisible") city, or before city_info */
3326 fc_snprintf(named, sizeof(named), "%06u", packet->worked);
3327
3328 pwork = create_city_virtual(invisible.placeholder, NULL, named);
3329 pwork->id = packet->worked;
3331
3333
3334 log_debug("(%d,%d) invisible city %d, %s",
3335 TILE_XY(ptile), pwork->id, city_name_get(pwork));
3336 } else if (NULL == city_tile(pwork)) {
3337 /* Old unseen ("invisible") city, or before city_info */
3338 if (NULL != powner && city_owner(pwork) != powner) {
3339 /* Update placeholder with current owner */
3340 pwork->owner = powner;
3341 pwork->original = NULL;
3342 }
3343 } else {
3344 /* We have a real (not invisible) city record for this ID, but
3345 * perhaps our info about that city is out of date. */
3346 int dist_sq = sq_map_distance(city_tile(pwork), ptile);
3347
3349 /* This is probably enemy city which has grown in diameter since we
3350 * last saw it. We need city_radius_sq to be at least big enough so
3351 * that all workers fit in, so set it so. */
3353 }
3354 /* This might be a known city that is open in a dialog.
3355 * (And this might be our only prompt to refresh the worked tiles
3356 * display in its city map, if a worker rearrangement does not
3357 * change anything else about the city such as output.) */
3358 {
3359 struct city *oldwork = tile_worked(ptile);
3360 if (oldwork && NULL != city_tile(oldwork)) {
3361 /* Refresh previous city too if it's real and different */
3363 }
3364 /* Refresh new city working tile (which we already know is real) */
3366 }
3367 }
3368
3369 /* This marks tile worked by (possibly invisible) city. Other
3370 * parts of the code have to handle invisible cities correctly
3371 * (ptile->worked->tile == NULL) */
3372 tile_set_worked(ptile, pwork);
3373 } else {
3374 /* Tile is no longer being worked by a city.
3375 * (Again, this might be our only prompt to refresh the worked tiles
3376 * display for the previous working city.) */
3377 if (tile_worked(ptile) && NULL != city_tile(tile_worked(ptile))) {
3379 }
3380 tile_set_worked(ptile, NULL);
3381 }
3382
3384 }
3385
3386 if (old_known != packet->known) {
3388 }
3389
3390 if (NULL != client.conn.playing) {
3395
3396 switch (packet->known) {
3397 case TILE_KNOWN_SEEN:
3402 break;
3403 case TILE_KNOWN_UNSEEN:
3405 break;
3406 case TILE_UNKNOWN:
3407 break;
3408 default:
3409 log_error("handle_tile_info() invalid known (%d).", packet->known);
3410 break;
3411 };
3412 }
3414
3415 if (packet->spec_sprite[0] != '\0') {
3416 if (!ptile->spec_sprite
3417 || strcmp(ptile->spec_sprite, packet->spec_sprite) != 0) {
3418 if (ptile->spec_sprite) {
3419 free(ptile->spec_sprite);
3420 }
3421 ptile->spec_sprite = fc_strdup(packet->spec_sprite);
3423 }
3424 } else {
3425 if (ptile->spec_sprite) {
3426 free(ptile->spec_sprite);
3427 ptile->spec_sprite = NULL;
3429 }
3430 }
3431
3433 /* This is an error. So first we log the error,
3434 * then make an assertion. */
3435 unit_list_iterate(ptile->units, punit) {
3436 log_error("%p %d %s at (%d,%d) %s", punit, punit->id,
3440 fc_assert_msg(0 == unit_list_size(ptile->units), "Ghost units seen");
3441 /* Repairing... */
3442 unit_list_clear(ptile->units);
3443 }
3444
3445 if (ptile->continent != packet->continent) {
3446 update_continent_cache(ptile, ptile->continent, packet->continent);
3447 }
3448 ptile->continent = packet->continent;
3449
3450 if (packet->label[0] == '\0') {
3451 if (ptile->label != NULL) {
3452 FC_FREE(ptile->label);
3453 ptile->label = NULL;
3455 }
3456 } else if (ptile->label == NULL || strcmp(packet->label, ptile->label)) {
3457 tile_set_label(ptile, packet->label);
3459 }
3460
3461 if (known_changed || tile_changed) {
3462 /*
3463 * A tile can only change if it was known before and is still
3464 * known. In the other cases the tile is new or removed.
3465 */
3467 agents_tile_new(ptile);
3468 } else if (known_changed && TILE_KNOWN_UNSEEN == new_known) {
3469 agents_tile_remove(ptile);
3470 } else {
3471 agents_tile_changed(ptile);
3472 }
3474 }
3475
3476 /* refresh tiles */
3477 if (can_client_change_view()) {
3478 /* the tile itself (including the necessary parts of adjacent tiles) */
3479 if (tile_changed || old_known != new_known) {
3481 }
3482 }
3483
3484 /* update menus if the focus unit is on the tile. */
3485 if (tile_changed) {
3486 if (get_focus_unit_on_tile(ptile)) {
3487 menus_update();
3488 }
3489 }
3490
3491 /* FIXME: we really ought to call refresh_city_dialog() for any city
3492 * whose radii include this tile, to update the city map display.
3493 * But that would be expensive. We deal with the (common) special
3494 * case of changes in worked tiles above. */
3495}
3496
3497/************************************************************************/
3517
3518/************************************************************************/
3521void handle_scenario_description(const char *description)
3522{
3524
3526}
3527
3528/************************************************************************/
3534{
3535 /* The ruleset is going to load new nations. So close
3536 * the nation selection dialog if it is open. */
3538
3544 game.control = *packet;
3545
3546 /* check the values! */
3547#define VALIDATE(_count, _maximum, _string) \
3548 if (game.control._count > _maximum) { \
3549 log_error("handle_ruleset_control(): Too many " _string \
3550 "; using %d of %d", _maximum, game.control._count); \
3551 game.control._count = _maximum; \
3552 }
3553
3554 VALIDATE(num_unit_classes, UCL_LAST, "unit classes");
3555 VALIDATE(num_unit_types, U_LAST, "unit types");
3556 VALIDATE(num_impr_types, B_LAST, "improvements");
3557 VALIDATE(num_tech_types, A_LAST, "advances");
3558 VALIDATE(num_base_types, MAX_EXTRA_TYPES, "bases");
3559 VALIDATE(num_road_types, MAX_EXTRA_TYPES, "roads");
3560 VALIDATE(num_resource_types, MAX_EXTRA_TYPES, "resources");
3561 VALIDATE(num_disaster_types, MAX_DISASTER_TYPES, "disasters");
3562 VALIDATE(num_achievement_types, MAX_ACHIEVEMENT_TYPES, "achievements");
3563 VALIDATE(num_counters, MAX_COUNTERS, "counters");
3564
3565 /* game.control.government_count, game.control.nation_count and
3566 * game.control.num_city_styles are allocated dynamically, and do
3567 * not need a size check. See the allocation below. */
3568
3570
3571 VALIDATE(num_specialist_types, SP_MAX, "specialists");
3572#undef VALIDATE
3573
3579
3580 if (game.control.desc_length > 0) {
3582 game.ruleset_description[0] = '\0';
3583 }
3584
3585 if (packet->preferred_tileset[0] != '\0') {
3586 /* There is tileset suggestion */
3588 /* It's not currently in use */
3591 } else {
3593 }
3594 }
3595 }
3596
3597 if (packet->preferred_soundset[0] != '\0') {
3598 /* There is soundset suggestion */
3600 /* It's not currently in use */
3603 } else {
3605 }
3606 }
3607 }
3608
3609 if (packet->preferred_musicset[0] != '\0') {
3610 /* There is musicset suggestion */
3612 /* It's not currently in use */
3615 } else {
3617 }
3618 }
3619 }
3620
3622
3624}
3625
3626/************************************************************************/
3630{
3631 int len;
3632
3633 if (game.ruleset_summary != NULL) {
3635 }
3636
3637 len = strlen(packet->text);
3638
3640
3641 fc_strlcpy(game.ruleset_summary, packet->text, len + 1);
3642}
3643
3644/************************************************************************/
3653
3654/************************************************************************/
3658{
3659 /* Setup extra hiders caches */
3660 extra_type_iterate(pextra) {
3661 pextra->hiders = extra_type_list_new();
3663 if (BV_ISSET(pextra->hidden_by, extra_index(phider))) {
3664 extra_type_list_append(pextra->hiders, phider);
3665 }
3667 pextra->bridged = extra_type_list_new();
3669 if (BV_ISSET(pextra->bridged_over, extra_index(pbridged))) {
3670 extra_type_list_append(pextra->bridged, pbridged);
3671 }
3674
3679
3680 /* Setup improvement feature caches */
3682
3683 /* Setup road integrators caches */
3685
3686 /* Pre calculate action related data. */
3688
3689 /* Setup unit unknown move cost caches */
3691 ptype->unknown_move_cost = utype_unknown_move_cost(ptype);
3695
3696 /* Cache what city production can receive help from caravans. */
3698
3699 /* Adjust editor for changed ruleset. */
3701
3702 /* We are not going to crop any more sprites from big sprites, free them. */
3704
3706}
3707
3708/************************************************************************/
3712{
3713 struct unit_class *c = uclass_by_number(p->id);
3714
3715 fc_assert_ret_msg(NULL != c, "Bad unit_class %d.", p->id);
3716
3717 names_set(&c->name, NULL, p->name, p->rule_name);
3718 c->min_speed = p->min_speed;
3719 c->hp_loss_pct = p->hp_loss_pct;
3721 c->flags = p->flags;
3722
3724}
3725
3726/************************************************************************/
3730{
3731 int i;
3732 struct unit_type *u = utype_by_number(p->id);
3733
3734 fc_assert_ret_msg(NULL != u, "Bad unit_type %d.", p->id);
3735
3736 names_set(&u->name, NULL, p->name, p->rule_name);
3744
3746 u->build_cost = p->build_cost;
3747 u->pop_cost = p->pop_cost;
3750 u->move_rate = p->move_rate;
3754 u->hp = p->hp;
3755 u->firepower = p->firepower;
3758 u->convert_time = p->convert_time;
3759 u->fuel = p->fuel;
3760 u->flags = p->flags;
3761 u->roles = p->roles;
3762 u->happy_cost = p->happy_cost;
3764 u->upkeep[o] = p->upkeep[o];
3767 u->bombard_rate = p->bombard_rate;
3768 u->city_size = p->city_size;
3769 u->city_slots = p->city_slots;
3770 u->tp_defense = p->tp_defense;
3771 u->cargo = p->cargo;
3772 u->targets = p->targets;
3773 u->embarks = p->embarks;
3774 u->disembarks = p->disembarks;
3775 u->vlayer = p->vlayer;
3776
3777 if (p->veteran_levels == 0) {
3778 u->veteran = NULL;
3779 } else {
3781
3782 for (i = 0; i < p->veteran_levels; i++) {
3784 p->power_fact[i], p->move_bonus[i],
3785 p->base_raise_chance[i],
3786 p->work_raise_chance[i]);
3787 }
3788 }
3789
3791
3792 u->adv.worker = p->worker;
3793
3795}
3796
3797/************************************************************************/
3801{
3802 struct unit_type *u = utype_by_number(p->unit);
3803 struct combat_bonus *bonus;
3804
3805 fc_assert_ret_msg(NULL != u, "Bad unit_type %d.", p->unit);
3806
3807 bonus = malloc(sizeof(*bonus));
3808
3809 bonus->flag = p->flag;
3810 bonus->type = p->type;
3811 bonus->value = p->value;
3812 bonus->quiet = p->quiet;
3813
3815}
3816
3817/************************************************************************/
3821{
3822 const char *flagname;
3823 const char *helptxt;
3824
3825 fc_assert_ret_msg(p->id >= UTYF_USER_FLAG_1 && p->id <= UTYF_LAST_USER_FLAG, "Bad user flag %d.", p->id);
3826
3827 if (p->name[0] == '\0') {
3828 flagname = NULL;
3829 } else {
3830 flagname = p->name;
3831 }
3832
3833 if (p->helptxt[0] == '\0') {
3834 helptxt = NULL;
3835 } else {
3836 helptxt = p->helptxt;
3837 }
3838
3840}
3841
3842/************************************************************************/
3846 const struct packet_ruleset_unit_class_flag *p)
3847{
3848 const char *flagname;
3849 const char *helptxt;
3850
3852 "Bad user flag %d.", p->id);
3853
3854 if (p->name[0] == '\0') {
3855 flagname = NULL;
3856 } else {
3857 flagname = p->name;
3858 }
3859
3860 if (p->helptxt[0] == '\0') {
3861 helptxt = NULL;
3862 } else {
3863 helptxt = p->helptxt;
3864 }
3865
3867}
3868
3869/************************************************************************/
3875static int unpack_tech_req(const enum tech_req r_num,
3876 const struct requirement_vector *reqs,
3877 struct advance *a,
3878 int i)
3879{
3882 /* Extract the tech req so the old code can reason about it. */
3883
3884 /* This IS a traditional tech req... right? */
3887
3888 /* Put it in the advance structure. */
3889 a->require[r_num] = requirement_vector_get(reqs, i)->source.value.advance;
3890
3891 /* Move on in the requirement vector. */
3892 i++;
3893 } else {
3894 /* No tech req. */
3896 }
3897
3898 return i;
3899}
3900
3901/************************************************************************/
3905{
3906 int i;
3907 struct advance *a = advance_by_number(p->id);
3908
3909 fc_assert_ret_msg(NULL != a, "Bad advance %d.", p->id);
3910
3911 names_set(&a->name, NULL, p->name, p->rule_name);
3914
3915 i = 0;
3916
3918 if (p->tclass >= 0) {
3920 } else {
3921 a->tclass = NULL;
3922 }
3923
3924 /* The tech requirements req1 and req2 are send inside research_reqs
3925 * since they too are required to be fulfilled before the tech can be
3926 * researched. */
3927
3928 if (p->removed) {
3929 /* The Freeciv data structures currently records that a tech is removed
3930 * by setting req1 and req2 to "Never". */
3931 a->require[AR_ONE] = A_NEVER;
3932 a->require[AR_TWO] = A_NEVER;
3933 } else {
3934 /* Unpack req1 and req2 from the research_reqs requirement vector. */
3937 }
3938
3939 /* Any remaining requirements are a part of the research_reqs requirement
3940 * vector. */
3942 /* slice of the vector starting at index i */
3943 &(const struct requirement_vector) {
3944 .p = p->research_reqs.p + i,
3945 .size = p->research_reqs.size - i,
3946 /* .size_alloc shouldn't matter */
3947 });
3948
3949 /* The packet's research_reqs should contain req1, req2 and the
3950 * requirements of the tech's research_reqs. */
3951 fc_assert((a->research_reqs.size
3952 + ((a->require[AR_ONE]
3953 && (advance_number(a->require[AR_ONE]) != A_NONE)) ?
3954 1 : 0)
3955 + ((a->require[AR_TWO]
3956 && (advance_number(a->require[AR_TWO]) != A_NONE)) ?
3957 1 : 0))
3959
3961
3962 a->flags = p->flags;
3963 a->cost = p->cost;
3964 a->num_reqs = p->num_reqs;
3966
3968}
3969
3970/************************************************************************/
3974{
3976
3977 fc_assert_ret_msg(NULL != ptclass, "Bad tech_class %d.", p->id);
3978
3979 names_set(&ptclass->name, NULL, p->name, p->rule_name);
3980 ptclass->cost_pct = p->cost_pct;
3981}
3982
3983/************************************************************************/
3987{
3988 const char *flagname;
3989 const char *helptxt;
3990
3991 fc_assert_ret_msg(p->id >= TECH_USER_1 && p->id <= TECH_USER_LAST, "Bad user flag %d.", p->id);
3992
3993 if (p->name[0] == '\0') {
3994 flagname = NULL;
3995 } else {
3996 flagname = p->name;
3997 }
3998
3999 if (p->helptxt[0] == '\0') {
4000 helptxt = NULL;
4001 } else {
4002 helptxt = p->helptxt;
4003 }
4004
4005 set_user_tech_flag_name(p->id, flagname, helptxt);
4006}
4007
4008/************************************************************************/
4012{
4013 struct impr_type *b = improvement_by_number(p->id);
4014
4015 fc_assert_ret_msg(NULL != b, "Bad improvement %d.", p->id);
4016
4017 b->genus = p->genus;
4018 names_set(&b->name, NULL, p->name, p->rule_name);
4024 b->build_cost = p->build_cost;
4025 b->upkeep = p->upkeep;
4026 b->sabotage = p->sabotage;
4027 b->flags = p->flags;
4032
4033#ifdef FREECIV_DEBUG
4034 if (p->id == improvement_count() - 1) {
4036 log_debug("Improvement: %s...", improvement_rule_name(bdbg));
4037 log_debug(" build_cost %3d", bdbg->build_cost);
4038 log_debug(" upkeep %2d", bdbg->upkeep);
4039 log_debug(" sabotage %3d", bdbg->sabotage);
4040 if (NULL != bdbg->helptext) {
4041 strvec_iterate(bdbg->helptext, text) {
4042 log_debug(" helptext %s", text);
4044 }
4046 }
4047#endif /* FREECIV_DEBUG */
4048
4050}
4051
4052/************************************************************************/
4056{
4057 const char *flagname;
4058 const char *helptxt;
4059
4061 "Bad user flag %d.", p->id);
4062
4063 if (p->name[0] == '\0') {
4064 flagname = NULL;
4065 } else {
4066 flagname = p->name;
4067 }
4068
4069 if (p->helptxt[0] == '\0') {
4070 helptxt = NULL;
4071 } else {
4072 helptxt = p->helptxt;
4073 }
4074
4075 set_user_impr_flag_name(p->id, flagname, helptxt);
4076}
4077
4078/************************************************************************/
4082{
4083 struct multiplier *pmul = multiplier_by_number(p->id);
4084
4085 fc_assert_ret_msg(NULL != pmul, "Bad multiplier %d.", p->id);
4086
4087 pmul->start = p->start;
4088 pmul->stop = p->stop;
4089 pmul->step = p->step;
4090 pmul->def = p->def;
4091 pmul->offset = p->offset;
4092 pmul->factor = p->factor;
4093 pmul->minimum_turns = p->minimum_turns;
4094
4095 names_set(&pmul->name, NULL, p->name, p->rule_name);
4096 requirement_vector_copy(&pmul->reqs, &p->reqs);
4098}
4099
4100/************************************************************************/
4104{
4105 struct government *gov = government_by_number(p->id);
4106
4107 fc_assert_ret_msg(NULL != gov, "Bad government %d.", p->id);
4108
4109 gov->item_number = p->id;
4110
4111 requirement_vector_copy(&gov->reqs, &p->reqs);
4112 names_set(&gov->name, NULL, p->name, p->rule_name);
4115 sz_strlcpy(gov->sound_str, p->sound_str);
4116 sz_strlcpy(gov->sound_alt, p->sound_alt);
4118
4120
4122}
4123
4124/************************************************************************/
4128 (const struct packet_ruleset_government_ruler_title *packet)
4129{
4130 struct government *gov = government_by_number(packet->gov);
4131
4132 fc_assert_ret_msg(NULL != gov, "Bad government %d.", packet->gov);
4133
4135 packet->male_title,
4136 packet->female_title);
4137}
4138
4139/************************************************************************/
4143{
4144 int j;
4145 struct terrain *pterrain = terrain_by_number(p->id);
4146
4147 fc_assert_ret_msg(NULL != pterrain, "Bad terrain %d.", p->id);
4148
4149 pterrain->tclass = p->tclass;
4150 pterrain->native_to = p->native_to;
4151 names_set(&pterrain->name, NULL, p->name, p->rule_name);
4152 sz_strlcpy(pterrain->graphic_str, p->graphic_str);
4153 sz_strlcpy(pterrain->graphic_alt, p->graphic_alt);
4154 sz_strlcpy(pterrain->graphic_alt2, p->graphic_alt2);
4155 pterrain->movement_cost = p->movement_cost;
4156 pterrain->defense_bonus = p->defense_bonus;
4157
4159 pterrain->output[o] = p->output[o];
4161
4162 if (pterrain->resources != NULL) {
4163 free(pterrain->resources);
4164 }
4165 pterrain->resources = fc_calloc(p->num_resources + 1,
4166 sizeof(*pterrain->resources));
4167 if (pterrain->resource_freq != NULL) {
4168 free(pterrain->resource_freq);
4169 }
4170 pterrain->resource_freq = fc_calloc(p->num_resources + 1,
4171 sizeof(*pterrain->resource_freq));
4172 for (j = 0; j < p->num_resources; j++) {
4173 pterrain->resources[j] = extra_by_number(p->resources[j]);
4174 if (!pterrain->resources[j]) {
4175 log_error("handle_ruleset_terrain() "
4176 "Mismatched resource %d for terrain \"%s\".",
4177 p->resources[j], terrain_rule_name(pterrain));
4178 }
4179 pterrain->resource_freq[j] = p->resource_freq[j];
4180 }
4181 pterrain->resources[p->num_resources] = NULL;
4182 pterrain->resource_freq[p->num_resources] = 0;
4183
4187
4188 pterrain->base_time = p->base_time;
4189 pterrain->road_time = p->road_time;
4191 pterrain->cultivate_time = p->cultivate_time;
4193 pterrain->plant_time = p->plant_time;
4195 pterrain->irrigation_time = p->irrigation_time;
4197 pterrain->mining_time = p->mining_time;
4198 if (p->animal < 0) {
4199 pterrain->animal = NULL;
4200 } else {
4201 pterrain->animal = utype_by_number(p->animal);
4202 }
4204 pterrain->transform_time = p->transform_time;
4205 pterrain->placing_time = p->placing_time;
4206 pterrain->pillage_time = p->pillage_time;
4207
4208 for (j = 0; j < p->extra_count; j++) {
4209 pterrain->extra_removal_times[j] = p->extra_removal_times[j];
4210 }
4211
4212 pterrain->flags = p->flags;
4213
4214 fc_assert_ret(pterrain->rgb == NULL);
4215 pterrain->rgb = rgbcolor_new(p->color_red, p->color_green, p->color_blue);
4216
4218
4220}
4221
4222/************************************************************************/
4226{
4227 const char *flagname;
4228 const char *helptxt;
4229
4230 fc_assert_ret_msg(p->id >= TER_USER_1 && p->id <= TER_USER_LAST, "Bad user flag %d.", p->id);
4231
4232 if (p->name[0] == '\0') {
4233 flagname = NULL;
4234 } else {
4235 flagname = p->name;
4236 }
4237
4238 if (p->helptxt[0] == '\0') {
4239 helptxt = NULL;
4240 } else {
4241 helptxt = p->helptxt;
4242 }
4243
4245}
4246
4247/************************************************************************/
4251{
4252 struct resource_type *presource;
4253
4254 if (p->id < 0 || p->id > MAX_EXTRA_TYPES) {
4255 log_error("Bad resource %d.", p->id);
4256 return;
4257 }
4258
4259 presource = resource_type_init(extra_by_number(p->id));
4260
4262 presource->output[o] = p->output[o];
4264}
4265
4266/************************************************************************/
4270{
4271 struct extra_type *pextra = extra_by_number(p->id);
4272 int i;
4273 bool cbase;
4274 bool croad;
4275 bool cres;
4276
4277 fc_assert_ret_msg(NULL != pextra, "Bad extra %d.", p->id);
4278
4279 names_set(&pextra->name, NULL, p->name, p->rule_name);
4280
4281 pextra->category = p->category;
4282
4283 pextra->causes = 0;
4284 for (i = 0; i < EC_COUNT; i++) {
4285 if (BV_ISSET(p->causes, i)) {
4286 pextra->causes |= (1 << i);
4287 }
4288 }
4289
4290 pextra->rmcauses = 0;
4291 for (i = 0; i < ERM_COUNT; i++) {
4292 if (BV_ISSET(p->rmcauses, i)) {
4293 pextra->rmcauses |= (1 << i);
4294 }
4295 }
4296
4297 if (pextra->causes == 0) {
4299 } else {
4300 for (i = 0; i < EC_COUNT; i++) {
4301 if (is_extra_caused_by(pextra, i)) {
4302 extra_to_caused_by_list(pextra, i);
4303 }
4304 }
4305 }
4306
4307 cbase = is_extra_caused_by(pextra, EC_BASE);
4308 croad = is_extra_caused_by(pextra, EC_ROAD);
4310 if (cbase) {
4311 /* Index is one less than size of list when this base is already added. */
4313 }
4314 if (croad) {
4315 /* Index is one less than size of list when this road is already added. */
4317 }
4318 if (!cbase && !croad && !cres) {
4321 }
4322
4323 for (i = 0; i < ERM_COUNT; i++) {
4324 if (is_extra_removed_by(pextra, i)) {
4325 extra_to_removed_by_list(pextra, i);
4326 }
4327 }
4328
4330 sz_strlcpy(pextra->act_gfx_alt, p->act_gfx_alt);
4332 sz_strlcpy(pextra->rmact_gfx, p->rmact_gfx);
4335 sz_strlcpy(pextra->graphic_str, p->graphic_str);
4336 sz_strlcpy(pextra->graphic_alt, p->graphic_alt);
4337
4338 requirement_vector_copy(&pextra->reqs, &p->reqs);
4339 requirement_vector_copy(&pextra->rmreqs, &p->rmreqs);
4340
4343
4346
4347 pextra->visibility_req = p->visibility_req;
4348 pextra->buildable = p->buildable;
4349 pextra->generated = p->generated;
4350 pextra->build_time = p->build_time;
4352 pextra->removal_time = p->removal_time;
4354 pextra->infracost = p->infracost;
4355 pextra->defense_bonus = p->defense_bonus;
4356
4357 if (pextra->defense_bonus != 0) {
4358 if (extra_has_flag(pextra, EF_NATURAL_DEFENSE)) {
4360 } else {
4362 }
4363 }
4364
4366
4367 pextra->eus = p->eus;
4368 if (pextra->eus == EUS_HIDDEN) {
4370 }
4371
4372 pextra->native_to = p->native_to;
4373
4374 pextra->flags = p->flags;
4375 if (pextra->no_aggr_near_city >= 0) {
4377 }
4378 if (extra_has_flag(pextra, EF_CAUSE_ZOC)) {
4380 }
4381
4382 pextra->hidden_by = p->hidden_by;
4383 pextra->bridged_over = p->bridged_over;
4384 pextra->conflicts = p->conflicts;
4385
4387
4389}
4390
4391/************************************************************************/
4395{
4396 const char *flagname;
4397 const char *helptxt;
4398
4400 "Bad user flag %d.", p->id);
4401
4402 if (p->name[0] == '\0') {
4403 flagname = NULL;
4404 } else {
4405 flagname = p->name;
4406 }
4407
4408 if (p->helptxt[0] == '\0') {
4409 helptxt = NULL;
4410 } else {
4411 helptxt = p->helptxt;
4412 }
4413
4414 set_user_extra_flag_name(p->id, flagname, helptxt);
4415}
4416
4417/************************************************************************/
4421{
4422 struct base_type *pbase = base_by_number(p->id);
4423
4424 fc_assert_ret_msg(NULL != pbase, "Bad base %d.", p->id);
4425
4426 pbase->gui_type = p->gui_type;
4427 pbase->border_sq = p->border_sq;
4428 pbase->vision_main_sq = p->vision_main_sq;
4429 pbase->vision_invis_sq = p->vision_invis_sq;
4430 pbase->vision_subs_sq = p->vision_subs_sq;
4431
4435 }
4436}
4437
4438/************************************************************************/
4442{
4443 struct road_type *proad = road_by_number(p->id);
4444
4445 fc_assert_ret_msg(NULL != proad, "Bad road %d.", p->id);
4446
4447 proad->gui_type = p->gui_type;
4448
4449 requirement_vector_copy(&proad->first_reqs, &p->first_reqs);
4450
4451 proad->move_cost = p->move_cost;
4452 proad->move_mode = p->move_mode;
4453
4455 proad->tile_incr_const[o] = p->tile_incr_const[o];
4456 proad->tile_incr[o] = p->tile_incr[o];
4457 proad->tile_bonus[o] = p->tile_bonus[o];
4459
4460 proad->compat = p->compat;
4461 proad->integrates = p->integrates;
4462 proad->flags = p->flags;
4463}
4464
4465/************************************************************************/
4469{
4470 struct goods_type *pgood = goods_by_number(p->id);
4471
4472 fc_assert_ret_msg(NULL != pgood, "Bad goods %d.", p->id);
4473
4474 names_set(&pgood->name, NULL, p->name, p->rule_name);
4475
4476 requirement_vector_copy(&pgood->reqs, &p->reqs);
4477
4478 pgood->from_pct = p->from_pct;
4479 pgood->to_pct = p->to_pct;
4480 pgood->onetime_pct = p->onetime_pct;
4481 pgood->select_priority = p->select_priority;
4482 pgood->replace_priority = p->replace_priority;
4483 pgood->flags = p->flags;
4484
4485 PACKET_STRVEC_EXTRACT(pgood->helptext, p->helptext);
4486}
4487
4488/************************************************************************/
4492{
4493 struct action *act;
4494
4495 if (!action_id_exists(p->id)) {
4496 /* Action id out of range */
4497 log_error("handle_ruleset_action() the action id %d is out of range.",
4498 p->id);
4499
4500 return;
4501 }
4502
4503 act = action_by_number(p->id);
4504
4505 sz_strlcpy(act->ui_name, p->ui_name);
4506 act->quiet = p->quiet;
4507
4508 act->result = p->result;
4509 act->sub_results = p->sub_results;
4511
4512 act->actor_kind = p->act_kind;
4513 act->target_kind = p->tgt_kind;
4514 act->sub_target_kind = p->sub_tgt_kind;
4515
4516 act->min_distance = p->min_distance;
4517 act->max_distance = p->max_distance;
4518 act->blocked_by = p->blocked_by;
4519}
4520
4521/************************************************************************/
4524void
4526{
4527 struct action_enabler *enabler;
4528
4530 /* Non existing action */
4531 log_error("handle_ruleset_action_enabler() the action %d "
4532 "doesn't exist.",
4533 p->enabled_action);
4534
4535 return;
4536 }
4537
4539
4540 enabler->action = p->enabled_action;
4541
4542 requirement_vector_copy(&enabler->actor_reqs, &p->actor_reqs);
4543 requirement_vector_copy(&enabler->target_reqs, &p->target_reqs);
4544
4546}
4547
4548/************************************************************************/
4552{
4554 int i;
4555
4557
4558 auto_perf->cause = p->cause;
4559
4561
4562 for (i = 0; i < p->alternatives_count; i++) {
4563 auto_perf->alternatives[i] = p->alternatives[i];
4564 }
4565}
4566
4567/************************************************************************/
4571{
4573
4574 fc_assert_ret_msg(NULL != pdis, "Bad disaster %d.", p->id);
4575
4576 names_set(&pdis->name, NULL, p->name, p->rule_name);
4577
4578 requirement_vector_copy(&pdis->reqs, &p->reqs);
4579
4580 pdis->frequency = p->frequency;
4581
4582 pdis->effects = p->effects;
4583}
4584
4585/************************************************************************/
4589{
4591
4592 fc_assert_ret_msg(NULL != pach, "Bad achievement %d.", p->id);
4593
4594 names_set(&pach->name, NULL, p->name, p->rule_name);
4595
4596 pach->type = p->type;
4597 pach->unique = p->unique;
4598 pach->value = p->value;
4599}
4600
4601/************************************************************************/
4605{
4607
4608 if (pset != NULL) {
4609 pset->trade_pct = p->trade_pct;
4610 pset->cancelling = p->cancelling;
4611 pset->bonus_type = p->bonus_type;
4612 }
4613}
4614
4615/************************************************************************/
4619 (const struct packet_ruleset_terrain_control *p)
4620{
4621 /* Since terrain_control is the same as packet_ruleset_terrain_control
4622 * we can just copy the data directly. */
4623 terrain_control = *p;
4624 /* terrain_control.move_fragments likely changed */
4626}
4627
4628/************************************************************************/
4632 (const struct packet_ruleset_nation_sets *packet)
4633{
4634 int i;
4635
4636 for (i = 0; i < packet->nsets; i++) {
4637 struct nation_set *pset =
4638 nation_set_new(packet->names[i], packet->rule_names[i],
4639 packet->descriptions[i]);
4640
4641 if (pset == NULL) {
4642 break;
4643 } else {
4645 }
4646 }
4647}
4648
4649/************************************************************************/
4653 (const struct packet_ruleset_nation_groups *packet)
4654{
4655 int i;
4656
4657 for (i = 0; i < packet->ngroups; i++) {
4658 struct nation_group *pgroup;
4659
4660 pgroup = nation_group_new(packet->groups[i]);
4661
4662 if (pgroup != NULL) {
4664 pgroup->hidden = packet->hidden[i];
4665 } else {
4666 break;
4667 }
4668 }
4669}
4670
4671/************************************************************************/
4675{
4676 struct nation_type *pnation = nation_by_number(packet->id);
4677 int i;
4678
4679 fc_assert_ret_msg(NULL != pnation, "Bad nation %d.", packet->id);
4680
4681 if (packet->translation_domain[0] != '\0') {
4682 size_t len = strlen(packet->translation_domain) + 1;
4683 pnation->translation_domain = fc_malloc(len);
4685 } else {
4686 pnation->translation_domain = NULL;
4687 }
4688 names_set(&pnation->adjective, pnation->translation_domain,
4689 packet->adjective, packet->rule_name);
4690 name_set(&pnation->noun_plural, pnation->translation_domain, packet->noun_plural);
4691 sz_strlcpy(pnation->flag_graphic_str, packet->graphic_str);
4692 sz_strlcpy(pnation->flag_graphic_alt, packet->graphic_alt);
4693 pnation->style = style_by_number(packet->style);
4694 for (i = 0; i < packet->leader_count; i++) {
4695 (void) nation_leader_new(pnation, packet->leader_name[i],
4696 packet->leader_is_male[i]);
4697 }
4698
4699 /* set later by PACKET_NATION_AVAILABILITY */
4700 pnation->client.is_pickable = FALSE;
4701 pnation->is_playable = packet->is_playable;
4702 pnation->barb_type = packet->barbarian_type;
4703
4704 if ('\0' != packet->legend[0]) {
4705 pnation->legend = fc_strdup(nation_legend_translation(pnation, packet->legend));
4706 } else {
4707 pnation->legend = fc_strdup("");
4708 }
4709
4710 for (i = 0; i < packet->nsets; i++) {
4711 struct nation_set *pset = nation_set_by_number(packet->sets[i]);
4712
4713 if (NULL != pset) {
4714 nation_set_list_append(pnation->sets, pset);
4715 } else {
4716 log_error("handle_ruleset_nation() \"%s\" have unknown set %d.",
4717 nation_rule_name(pnation), packet->sets[i]);
4718 }
4719 }
4720
4721 for (i = 0; i < packet->ngroups; i++) {
4723
4724 if (NULL != pgroup) {
4726 } else {
4727 log_error("handle_ruleset_nation() \"%s\" have unknown group %d.",
4728 nation_rule_name(pnation), packet->groups[i]);
4729 }
4730 }
4731
4732 /* init_government may be NULL */
4734 for (i = 0; i < MAX_NUM_TECH_LIST; i++) {
4735 if (i < packet->init_techs_count) {
4736 pnation->init_techs[i] = packet->init_techs[i];
4737 } else {
4738 pnation->init_techs[i] = A_LAST;
4739 }
4740 }
4741 for (i = 0; i < MAX_NUM_UNIT_LIST; i++) {
4742 if (i < packet->init_units_count) {
4743 pnation->init_units[i] = utype_by_number(packet->init_units[i]);
4744 } else {
4745 /* TODO: should init_units be initialized in common/nation.c? */
4746 pnation->init_units[i] = utype_by_number(U_LAST);
4747 }
4748 }
4749 for (i = 0; i < MAX_NUM_BUILDING_LIST; i++) {
4750 if (i < packet->init_buildings_count) {
4751 pnation->init_buildings[i] = packet->init_buildings[i];
4752 } else {
4753 pnation->init_buildings[i] = B_LAST;
4754 }
4755 }
4756
4758}
4759
4760/************************************************************************/
4764void handle_nation_availability(int ncount, const bool *is_pickable,
4765 bool nationset_change)
4766{
4767 int i;
4768
4769 fc_assert_action(ncount == nation_count(),
4770 ncount = MIN(ncount, nation_count()));
4771
4772 for (i = 0; i < ncount; i++) {
4773 nation_by_number(i)->client.is_pickable = is_pickable[i];
4774 }
4775
4776 races_update_pickable(nationset_change);
4777}
4778
4779/************************************************************************/
4783{
4784 struct nation_style *pstyle = style_by_number(p->id);
4785
4786 fc_assert_ret_msg(NULL != pstyle, "Bad style %d.", p->id);
4787
4788 names_set(&pstyle->name, NULL, p->name, p->rule_name);
4789}
4790
4791/************************************************************************/
4795{
4796 struct clause_info *info = clause_info_get(p->type);
4797
4798 fc_assert_ret_msg(NULL != info, "Bad clause %d.", p->type);
4799
4800 info->enabled = p->enabled;
4801
4805}
4806
4807/************************************************************************/
4811{
4812 int id;
4813 struct citystyle *cs;
4814
4815 id = packet->style_id;
4817 "Bad citystyle %d.", id);
4818 cs = &city_styles[id];
4819
4820 requirement_vector_copy(&cs->reqs, &packet->reqs);
4821 names_set(&cs->name, NULL, packet->name, packet->rule_name);
4822 sz_strlcpy(cs->graphic, packet->graphic);
4823 sz_strlcpy(cs->graphic_alt, packet->graphic_alt);
4824 sz_strlcpy(cs->citizens_graphic, packet->citizens_graphic);
4825
4827}
4828
4829/************************************************************************/
4833{
4834 int id;
4835 struct music_style *pmus;
4836
4837 id = packet->id;
4839 "Bad music_style %d.", id);
4840
4842
4843 requirement_vector_copy(&pmus->reqs, &packet->reqs);
4844 sz_strlcpy(pmus->music_peaceful, packet->music_peaceful);
4845 sz_strlcpy(pmus->music_combat, packet->music_combat);
4846}
4847
4848/************************************************************************/
4852{
4853 int i;
4854
4855 /* Must set num_specialist_types before iterating over them. */
4857
4858 fc_assert_ret(packet->veteran_levels > 0);
4859
4861 game.veteran->levels = packet->veteran_levels;
4862
4863 for (i = 0; i < MAX_NUM_TECH_LIST; i++) {
4864 if (i < packet->global_init_techs_count) {
4866 } else {
4868 }
4869 }
4870 for (i = 0; i < MAX_NUM_BUILDING_LIST; i++) {
4871 if (i < packet->global_init_buildings_count) {
4873 } else {
4875 }
4876 }
4877
4878 for (i = 0; i < packet->veteran_levels; i++) {
4880 packet->power_fact[i], packet->move_bonus[i],
4881 packet->base_raise_chance[i],
4882 packet->work_raise_chance[i]);
4883 }
4884
4887 packet->background_green,
4888 packet->background_blue);
4889
4891}
4892
4893/************************************************************************/
4897{
4898 struct specialist *s = specialist_by_number(p->id);
4899
4900 fc_assert_ret_msg(NULL != s, "Bad specialist %d.", p->id);
4901
4902 names_set(&s->name, NULL, p->plural_name, p->rule_name);
4904
4909
4911}
4912
4913/************************************************************************/
4916void handle_city_name_suggestion_info(int unit_id, const char *name)
4917{
4918 struct unit *punit = player_unit_by_number(client_player(), unit_id);
4919
4920 if (!can_client_issue_orders()) {
4921 return;
4922 }
4923
4924 if (punit) {
4926 bool other_asking = FALSE;
4927
4929 if (other->client.asking_city_name) {
4931 }
4934
4935 if (!other_asking) {
4937 }
4938 } else {
4940 unit_id, tile_index(unit_tile(punit)),
4941 0, name);
4942 }
4943 }
4944}
4945
4946/************************************************************************/
4952void handle_unit_action_answer(int actor_id, int target_id, int cost,
4953 action_id action_type,
4954 int request_kind)
4955{
4956 struct city *pcity = game_city_by_number(target_id);
4957 struct unit *punit = game_unit_by_number(target_id);
4958 struct tile *ptile = index_to_tile(&(wld.map), target_id);
4959 struct unit *pactor = player_unit_by_number(client_player(), actor_id);
4960 struct action *paction = action_by_number(action_type);
4961
4962 if (ACTION_NONE != action_type
4963 && !action_id_exists(action_type)) {
4964 /* Non existing action */
4965 log_error("handle_unit_action_answer() the action %d doesn't exist.",
4966 action_type);
4967
4968 if (request_kind == REQEST_PLAYER_INITIATED) {
4972 }
4973
4974 return;
4975 }
4976
4977 if (!pactor) {
4978 log_debug("Bad actor %d.", actor_id);
4979
4980 if (request_kind == REQEST_PLAYER_INITIATED) {
4983 }
4984
4985 return;
4986 }
4987
4988 switch ((enum gen_action)action_type) {
4990 if (punit != nullptr && client.conn.playing
4992 if (request_kind == REQEST_PLAYER_INITIATED) {
4993 /* Focus on the unit so the player knows where it is */
4995
4997 } else {
4998 /* Not in use (yet). */
4999 log_error("Unimplemented: received background unit bribe cost.");
5000 }
5001 } else {
5002 log_debug("Bad target %d.", target_id);
5003 if (request_kind == REQEST_PLAYER_INITIATED) {
5007 }
5008 }
5009 break;
5011 if (ptile != nullptr && client.conn.playing
5013 if (request_kind == REQEST_PLAYER_INITIATED) {
5014 /* Focus on the unit so the player knows where it is */
5016
5018 } else {
5019 /* Not in use (yet). */
5020 log_error("Unimplemented: received background stack bribe cost.");
5021 }
5022 } else {
5023 log_debug("Bad target %d.", target_id);
5024 if (request_kind == REQEST_PLAYER_INITIATED) {
5028 }
5029 }
5030 break;
5033 if (pcity && client.conn.playing
5035 if (request_kind == REQEST_PLAYER_INITIATED) {
5036 /* Focus on the unit so the player knows where it is */
5038
5040 } else {
5041 /* Not in use (yet). */
5042 log_error("Unimplemented: received background city incite cost.");
5043 }
5044 } else {
5045 log_debug("Bad target %d.", target_id);
5046 if (request_kind == REQEST_PLAYER_INITIATED) {
5050 }
5051 }
5052 break;
5054 if (pcity && client.conn.playing
5056 /* TODO: The bundled clients will have to start showing the upgrade
5057 * price sent from the server before it can be allowed to rely on
5058 * things the player can't see. (Example: it becomes legal to upgrade
5059 * a unit in a foreign city.) */
5060
5061 /* Getting unit upgrade cost from the server is currently only used by
5062 * Freeciv-web. */
5063 log_error("Received upgrade unit price but can't forward it.");
5064 }
5065 break;
5066 case ACTION_NONE:
5067 log_debug("Server didn't respond to query.");
5068 if (request_kind == REQEST_PLAYER_INITIATED) {
5072 }
5073 break;
5074 default:
5075 log_error("handle_unit_action_answer() invalid action_type (%d).",
5076 action_type);
5077 if (request_kind == REQEST_PLAYER_INITIATED) {
5081 }
5082 break;
5083 };
5084}
5085
5086/************************************************************************/
5091{
5093
5095 if (action_prob_possible(act_probs[act_id])) {
5096 /* An attack. */
5097 if (attack_action == ACTION_NONE) {
5098 /* No previous attack action found. */
5099 attack_action = act_id;
5100 } else {
5101 /* More than one legal attack action found. */
5102 return ACTION_NONE;
5103 }
5104 }
5107 if (action_prob_possible(act_probs[act_id])) {
5108 /* An interesting non attack action has been found. */
5109 return ACTION_NONE;
5110 }
5112
5113 return attack_action;
5114}
5115
5116/**********************************************************************/
5121 const struct act_prob *act_probs,
5122 struct unit *target_unit,
5123 struct city *target_city,
5124 struct tile *target_tile)
5125{
5127
5129
5131
5132 if (auto_action != ACTION_NONE) {
5133 /* No interesting actions except a single attack action has been
5134 * found. The player wants it performed without questions. */
5135
5136 /* The order requests below doesn't send additional details. */
5138
5139 /* Give the order. */
5141 case ATK_TILE:
5142 case ATK_STACK:
5143 case ATK_EXTRAS:
5144 if (target_tile != NULL) {
5147 0, "");
5148 }
5149 break;
5150 case ATK_CITY:
5151 if (target_city != NULL) {
5154 0, "");
5155 }
5156 break;
5157 case ATK_UNIT:
5158 if (target_unit != NULL) {
5161 0, "");
5162 }
5163 break;
5164 case ATK_SELF:
5167 0, "");
5168 break;
5169 case ATK_COUNT:
5171 break;
5172 }
5173
5174 /* Clean up. */
5176 } else {
5177 /* This should be done in the foreground */
5179 }
5180}
5181
5182/************************************************************************/
5189{
5191
5192 struct tile *target_tile = index_to_tile(&(wld.map), packet->target_tile_id);
5193 struct extra_type *target_extra = packet->target_extra_id == EXTRA_NONE ?
5197
5198 const struct act_prob *act_probs = packet->action_probabilities;
5199
5200 int request_kind = packet->request_kind;
5201 bool valid = FALSE;
5202
5203 /* The dead can't act */
5205 /* At least one action must be possible */
5206 action_iterate(act) {
5207 if (action_prob_possible(act_probs[act])) {
5208 valid = TRUE;
5209 break;
5210 }
5212 }
5213
5214 switch (request_kind) {
5216 if (valid) {
5217 /* The player can select an action and should be informed. */
5218
5219 /* Show the client specific action dialog */
5223 act_probs);
5224 } else {
5225 /* Nothing to do. */
5229 }
5230 break;
5232 /* This was a background action selection dialog refresh. */
5233
5234 if (actor_unit != NULL
5236 /* The situation may have changed. */
5240 act_probs);
5241 }
5242 break;
5244 if (actor_unit != NULL) {
5247 }
5248 break;
5249 default:
5250 log_warn("Unknown request_kind %d in reply", request_kind);
5251 break;
5252 }
5253}
5254
5255/************************************************************************/
5258void handle_city_sabotage_list(int actor_id, int city_id,
5259 bv_imprs improvements,
5260 action_id act_id,
5261 int request_kind)
5262{
5263 struct city *pcity = game_city_by_number(city_id);
5264 struct unit *pactor = player_unit_by_number(client_player(), actor_id);
5265 struct action *paction = action_by_number(act_id);
5266
5267 if (!pactor) {
5268 log_debug("Bad diplomat %d.", actor_id);
5269
5270 if (request_kind == REQEST_PLAYER_INITIATED) {
5273 }
5274
5275 return;
5276 }
5277
5278 if (!pcity) {
5279 log_debug("Bad city %d.", city_id);
5280
5281 if (request_kind == REQEST_PLAYER_INITIATED) {
5285 }
5286
5287 return;
5288 }
5289
5291 improvement_iterate(pimprove) {
5293 BV_ISSET(improvements,
5294 improvement_index(pimprove)));
5296
5297 if (request_kind == REQEST_PLAYER_INITIATED) {
5298 /* Focus on the unit so the player knows where it is */
5300
5302 } else {
5303 /* Not in use (yet). */
5304 log_error("Unimplemented: received background city building list.");
5305 }
5306 } else {
5307 log_debug("Can't issue orders");
5308 if (request_kind == REQEST_PLAYER_INITIATED) {
5311 }
5312 }
5313}
5314
5315/************************************************************************/
5324
5325/************************************************************************/
5329{
5330 if (client_has_player()
5331 && packet->player_id == player_number(client_player())) {
5332 if (packet->winner) {
5333 start_menu_music("music_victory", NULL);
5334 } else {
5335 start_menu_music("music_defeat", NULL);
5336 }
5337 }
5339}
5340
5341/************************************************************************/
5345 (const struct packet_player_attribute_chunk *packet)
5346{
5347 if (!client_has_player()) {
5348 return;
5349 }
5350
5352
5353 if (packet->offset + packet->chunk_length == packet->total_length) {
5354 /* We successful received the last chunk. The attribute block is
5355 now complete. */
5357 }
5358}
5359
5360/************************************************************************/
5364{
5366
5370 client.last_processed_request_id_seen);
5372 request_id_of_currently_handled_packet);
5373
5374 log_debug("start processing packet %d",
5376}
5377
5378/************************************************************************/
5397
5398/************************************************************************/
5402 int packet_type, int size)
5403{
5404 fc_assert(pc == &client.conn);
5405 log_debug("incoming packet={type=%d, size=%d}", packet_type, size);
5406}
5407
5408/************************************************************************/
5412 int packet_type, int size,
5413 int request_id)
5414{
5415 fc_assert(pc == &client.conn);
5416 log_debug("outgoing packet={type=%d, size=%d, request_id=%d}",
5418
5420}
5421
5422/************************************************************************/
5426{
5427 log_debug("handle_freeze_client");
5428
5430}
5431
5432/************************************************************************/
5436{
5437 log_debug("handle_thaw_client");
5438
5441}
5442
5443/************************************************************************/
5447{
5449}
5450
5451/************************************************************************/
5455{
5456 log_verbose("server shutdown");
5457}
5458
5459/************************************************************************/
5463{
5464 recv_ruleset_effect(packet);
5465}
5466
5467/************************************************************************/
5473void handle_edit_object_created(int tag, int id)
5474{
5476}
5477
5478/************************************************************************/
5482{
5483 struct tile *ptile = index_to_tile(&(wld.map), packet->id);
5484 bool changed = FALSE;
5485
5486 /* Check. */
5487 if (NULL == ptile) {
5488 log_error("%s(): invalid tile index %d.", __FUNCTION__, packet->id);
5489 return;
5490 }
5491
5492 /* Handle. */
5493 if (packet->removal) {
5494 changed = map_startpos_remove(ptile);
5495 } else {
5496 if (NULL != map_startpos_get(ptile)) {
5497 changed = FALSE;
5498 } else {
5499 map_startpos_new(ptile);
5500 changed = TRUE;
5501 }
5502 }
5503
5504 /* Notify. */
5505 if (changed && can_client_change_view()) {
5507 if (packet->removal) {
5509 packet->id, TRUE);
5510 } else {
5511 editgui_notify_object_created(packet->tag, packet->id);
5512 }
5513 }
5514}
5515
5516/************************************************************************/
5520 packet)
5521{
5522 struct tile *ptile = index_to_tile(&(wld.map), packet->id);
5523 struct startpos *psp;
5524
5525 /* Check. */
5526 if (NULL == ptile) {
5527 log_error("%s(): invalid tile index %d.", __FUNCTION__, packet->id);
5528 return;
5529 }
5530
5531 psp = map_startpos_get(ptile);
5532 if (NULL == psp) {
5533 log_error("%s(): no start position at (%d, %d)",
5534 __FUNCTION__, TILE_XY(ptile));
5535 return;
5536 }
5537
5538 /* Handle. */
5539 if (startpos_unpack(psp, packet) && can_client_change_view()) {
5540 /* Notify. */
5543 FALSE);
5544 }
5545}
5546
5547/************************************************************************/
5551{
5552 game.client.fog_of_war = enabled;
5553
5554 menus_update();
5555}
5556
5557/************************************************************************/
5560void handle_vote_remove(int vote_no)
5561{
5564}
5565
5566/************************************************************************/
5569void handle_vote_update(int vote_no, int yes, int no, int abstain,
5570 int num_voters)
5571{
5572 struct voteinfo *vi;
5573
5575
5577 "Got packet_vote_update for non-existent vote %d!",
5578 vote_no);
5579
5580 vi->yes = yes;
5581 vi->no = no;
5582 vi->abstain = abstain;
5583 vi->num_voters = num_voters;
5584
5586}
5587
5588/************************************************************************/
5591void handle_vote_new(const struct packet_vote_new *packet)
5592{
5594 "Got a packet_vote_new for already existing "
5595 "vote %d!", packet->vote_no);
5596
5598 packet->user,
5599 packet->desc,
5600 packet->percent_required,
5601 packet->flags);
5603}
5604
5605/************************************************************************/
5609{
5610 struct voteinfo *vi;
5611
5613
5615 "Got packet_vote_resolve for non-existent vote %d!",
5616 vote_no);
5617
5618 vi->resolved = TRUE;
5619 vi->passed = passed;
5620
5622}
5623
5624/************************************************************************/
5627void handle_play_music(const char *tag)
5628{
5629 play_single_track(tag);
5630}
5631
5632/************************************************************************/
5635void handle_popup_image(const char *tag)
5636{
5637 popup_image(tag);
5638}
5639
5640/************************************************************************/
5643void handle_diplomacy_init_meeting(int counterpart, int initiated_from)
5644{
5645 client_init_meeting(counterpart, initiated_from);
5646}
5647
5648/************************************************************************/
5651void handle_diplomacy_accept_treaty(int counterpart, bool I_accepted,
5652 bool other_accepted)
5653{
5654 client_recv_accept_treaty(counterpart, I_accepted, other_accepted);
5655}
5656
5657/************************************************************************/
5660void handle_diplomacy_cancel_meeting(int counterpart, int initiated_from)
5661{
5662 client_recv_cancel_meeting(counterpart, initiated_from);
5663}
5664
5665/************************************************************************/
5668void handle_diplomacy_create_clause(int counterpart, int giver,
5669 enum clause_type type, int value)
5670{
5671 client_recv_create_clause(counterpart, giver, type, value);
5672}
5673
5674/************************************************************************/
5677void handle_diplomacy_remove_clause(int counterpart, int giver,
5678 enum clause_type type, int value)
5679{
5680 client_recv_remove_clause(counterpart, giver, type, value);
5681}
5682
5683/**********************************************************************/
5688{
5691
5692 names_set(&curr->name, NULL, packet->name, packet->rule_name);
5693 curr->checkpoint = packet->checkpoint;
5694 curr->type = packet->behaviour;
5695 curr->target = packet->type;
5696 curr->def = packet->def;
5697
5699 || curr->target != CTGT_CITY) {
5700 return;
5701 }
5702
5703 PACKET_STRVEC_EXTRACT(curr->helptext, packet->helptext);
5705}
5706
5707/**********************************************************************/
5711{
5712 int i;
5713 int counters_count;
5714 struct city *pcity = game_city_by_number(packet->city);
5715
5716 if (NULL == pcity) {
5717 return;
5718 }
5719
5721 if (counters_count != packet->count) {
5722 return;
5723 }
5724
5725 for (i = 0; i < counters_count; i++) {
5726 pcity->counter_values[i] = packet->counters[i];
5727 }
5728
5729 if (pcity->tile != NULL) {
5730 /* City's location known */
5732 }
5733
5735}
5736
5737/**********************************************************************/
5741{
5742}
struct achievement * achievement_by_number(int id)
struct action_auto_perf * action_auto_perf_slot_number(const int num)
Definition actions.c:5722
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5091
void actions_rs_pre_san_gen(void)
Definition actions.c:890
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:396
#define action_array_iterate(_act_array_, _act_id_)
Definition actions.h:257
#define action_id_requires_details(act_id)
Definition actions.h:434
#define action_array_iterate_end
Definition actions.h:269
#define action_iterate_end
Definition actions.h:214
#define action_iterate(_act_)
Definition actions.h:210
#define action_id_get_target_kind(act_id)
Definition actions.h:413
#define ACTION_NONE
Definition actions.h:55
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:1922
void editgui_refresh(void)
Definition editgui.c:1796
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:710
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:928
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:6002
const char * tileset_name_for_topology(int topology_id)
Definition options.c:6776
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:4851
void handle_player_diplstate(const struct packet_player_diplstate *packet)
Definition packhand.c:2801
static action_id auto_attack_act(const struct act_prob *act_probs)
Definition packhand.c:5090
void handle_ruleset_nation_sets(const struct packet_ruleset_nation_sets *packet)
Definition packhand.c:4632
void handle_ruleset_nation(const struct packet_ruleset_nation *packet)
Definition packhand.c:4674
void handle_city_name_suggestion_info(int unit_id, const char *name)
Definition packhand.c:4916
void handle_sync_serial_reply(int serial)
Definition packhand.c:5740
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:2771
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:4128
void handle_city_info(const struct packet_city_info *packet)
Definition packhand.c:658
void handle_end_turn(void)
Definition packhand.c:1498
static struct unit * unpackage_unit(const struct packet_unit_info *packet)
Definition packhand.c:264
char * caption
Definition packhand.c:129
enum event_type event
Definition packhand.c:128
void handle_conn_info(const struct packet_conn_info *pinfo)
Definition packhand.c:2902
void handle_vote_remove(int vote_no)
Definition packhand.c:5560
void handle_investigate_finished(const struct packet_investigate_finished *packet)
Definition packhand.c:2162
void handle_page_msg_part(const char *lines)
Definition packhand.c:1628
void handle_unit_combat_info(const struct packet_unit_combat_info *packet)
Definition packhand.c:576
void handle_ruleset_style(const struct packet_ruleset_style *p)
Definition packhand.c:4782
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:5569
static int last_turn
Definition packhand.c:137
void handle_ruleset_multiplier(const struct packet_ruleset_multiplier *p)
Definition packhand.c:4081
void handle_player_info(const struct packet_player_info *pinfo)
Definition packhand.c:2454
void handle_ruleset_extra(const struct packet_ruleset_extra *p)
Definition packhand.c:4269
void handle_ruleset_action_auto(const struct packet_ruleset_action_auto *p)
Definition packhand.c:4551
static struct @258 page_msg_report
void handle_map_info(const struct packet_map_info *packet)
Definition packhand.c:2242
void handle_ruleset_unit_bonus(const struct packet_ruleset_unit_bonus *p)
Definition packhand.c:3800
void handle_start_phase(int phase)
Definition packhand.c:1425
void start_revolution(void)
Definition packhand.c:2398
void handle_timeout_info(float seconds_to_phasedone, float last_turn_change_time)
Definition packhand.c:2368
void handle_ruleset_terrain_control(const struct packet_ruleset_terrain_control *p)
Definition packhand.c:4619
const action_id auto_attack_actions[]
Definition packhand.c:145
void handle_play_music(const char *tag)
Definition packhand.c:5627
static void update_continent_cache(const struct tile *ptile, Continent_id old_cont, Continent_id new_cont)
Definition packhand.c:3153
void handle_investigate_started(const struct packet_investigate_started *packet)
Definition packhand.c:2138
void handle_edit_object_created(int tag, int id)
Definition packhand.c:5473
int parts
Definition packhand.c:132
void handle_conn_ping(void)
Definition packhand.c:5446
static int unpack_tech_req(const enum tech_req r_num, const struct requirement_vector *reqs, struct advance *a, int i)
Definition packhand.c:3875
void handle_ruleset_tech_class(const struct packet_ruleset_tech_class *p)
Definition packhand.c:3973
void handle_diplomacy_init_meeting(int counterpart, int initiated_from)
Definition packhand.c:5643
void handle_ruleset_control(const struct packet_ruleset_control *packet)
Definition packhand.c:3533
void handle_end_phase(void)
Definition packhand.c:1414
void handle_ruleset_counter(const struct packet_ruleset_counter *packet)
Definition packhand.c:5687
void handle_server_info(const char *version_label, int major_version, int minor_version, int patch_version, int emerg_version)
Definition packhand.c:1581
void handle_ruleset_nation_groups(const struct packet_ruleset_nation_groups *packet)
Definition packhand.c:4653
void handle_ruleset_effect(const struct packet_ruleset_effect *packet)
Definition packhand.c:5462
void handle_new_year(int year, int fragments, int turn)
Definition packhand.c:1365
char * headline
Definition packhand.c:130
void handle_research_info(const struct packet_research_info *packet)
Definition packhand.c:2687
void handle_ruleset_goods(const struct packet_ruleset_goods *p)
Definition packhand.c:4468
void handle_unit_info(const struct packet_unit_info *packet)
Definition packhand.c:1654
void handle_ruleset_city(const struct packet_ruleset_city *packet)
Definition packhand.c:4810
void handle_ruleset_unit_class(const struct packet_ruleset_unit_class *p)
Definition packhand.c:3711
void handle_ruleset_government(const struct packet_ruleset_government *p)
Definition packhand.c:4103
void handle_ruleset_terrain_flag(const struct packet_ruleset_terrain_flag *p)
Definition packhand.c:4225
void handle_connect_msg(const char *message)
Definition packhand.c:1572
#define REQEST_BACKGROUND_REFRESH
Definition packhand.c:140
void handle_rulesets_ready(void)
Definition packhand.c:3657
void handle_tile_info(const struct packet_tile_info *packet)
Definition packhand.c:3241
void handle_ruleset_action(const struct packet_ruleset_action *p)
Definition packhand.c:4491
static void action_decision_handle(struct unit *punit)
Definition packhand.c:1670
void handle_achievement_info(int id, bool gained, bool first)
Definition packhand.c:3031
void handle_scenario_description(const char *description)
Definition packhand.c:3521
void play_sound_for_event(enum event_type type)
Definition packhand.c:1525
void handle_edit_startpos(const struct packet_edit_startpos *packet)
Definition packhand.c:5481
void handle_processing_finished(void)
Definition packhand.c:5381
void handle_diplomacy_cancel_meeting(int counterpart, int initiated_from)
Definition packhand.c:5660
void handle_city_short_info(const struct packet_city_short_info *packet)
Definition packhand.c:1166
void handle_edit_fogofwar_state(bool enabled)
Definition packhand.c:5550
void handle_popup_image(const char *tag)
Definition packhand.c:5635
void handle_diplomacy_create_clause(int counterpart, int giver, enum clause_type type, int value)
Definition packhand.c:5668
void handle_endgame_player(const struct packet_endgame_player *packet)
Definition packhand.c:5328
void handle_ruleset_resource(const struct packet_ruleset_resource *p)
Definition packhand.c:4250
void handle_unit_action_answer(int actor_id, int target_id, int cost, action_id action_type, int request_kind)
Definition packhand.c:4952
void handle_ruleset_tech(const struct packet_ruleset_tech *p)
Definition packhand.c:3904
void handle_team_name_info(int team_id, const char *team_name)
Definition packhand.c:561
void handle_thaw_client(void)
Definition packhand.c:5435
void handle_calendar_info(const struct packet_calendar_info *pcalendar)
Definition packhand.c:2360
void packhand_free(void)
Definition packhand.c:218
void set_government_choice(struct government *government)
Definition packhand.c:2385
void handle_city_rally_point(const struct packet_city_rally_point *packet)
Definition packhand.c:1015
void handle_ruleset_disaster(const struct packet_ruleset_disaster *p)
Definition packhand.c:4570
static bool handle_unit_packet_common(struct unit *packet_unit)
Definition packhand.c:1708
void handle_ruleset_unit_class_flag(const struct packet_ruleset_unit_class_flag *p)
Definition packhand.c:3845
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:3629
void handle_set_topology(int topology_id, int wrap_id)
Definition packhand.c:2219
void handle_ruleset_impr_flag(const struct packet_ruleset_impr_flag *p)
Definition packhand.c:4055
void handle_page_msg(const char *caption, const char *headline, enum event_type event, int len, int parts)
Definition packhand.c:1597
void handle_city_update_counters(const struct packet_city_update_counters *packet)
Definition packhand.c:5710
void handle_edit_startpos_full(const struct packet_edit_startpos_full *packet)
Definition packhand.c:5519
void handle_conn_ping_info(int connections, const int *conn_id, const float *ping_time)
Definition packhand.c:3008
void handle_diplomacy_remove_clause(int counterpart, int giver, enum clause_type type, int value)
Definition packhand.c:5677
static bool spaceship_autoplace(struct player *pplayer, struct player_spaceship *ship)
Definition packhand.c:3068
void handle_player_remove(int playerno)
Definition packhand.c:2409
void handle_processing_started(void)
Definition packhand.c:5363
void handle_begin_turn(void)
Definition packhand.c:1484
void handle_endgame_report(const struct packet_endgame_report *packet)
Definition packhand.c:5319
void handle_early_chat_msg(const struct packet_early_chat_msg *packet)
Definition packhand.c:1558
void handle_ruleset_clause(const struct packet_ruleset_clause *p)
Definition packhand.c:4794
void handle_ruleset_road(const struct packet_ruleset_road *p)
Definition packhand.c:4441
void handle_unit_actions(const struct packet_unit_actions *packet)
Definition packhand.c:5188
void handle_ruleset_music(const struct packet_ruleset_music *packet)
Definition packhand.c:4832
void handle_ruleset_base(const struct packet_ruleset_base *p)
Definition packhand.c:4420
void notify_about_incoming_packet(struct connection *pc, int packet_type, int size)
Definition packhand.c:5401
void handle_freeze_client(void)
Definition packhand.c:5425
void handle_city_remove(int city_id)
Definition packhand.c:476
void handle_chat_msg(const struct packet_chat_msg *packet)
Definition packhand.c:1538
static void city_packet_common(struct city *pcity, struct tile *pcenter, struct player *powner, struct tile_list *worked_tiles, bool is_new, bool popup, bool investigate)
Definition packhand.c:1029
static struct @257 invisible
void handle_trade_route_info(const struct packet_trade_route_info *packet)
Definition packhand.c:1131
void handle_player_attribute_chunk(const struct packet_player_attribute_chunk *packet)
Definition packhand.c:5345
void handle_vote_new(const struct packet_vote_new *packet)
Definition packhand.c:5591
static void packhand_init(void)
Definition packhand.c:239
void handle_scenario_info(const struct packet_scenario_info *packet)
Definition packhand.c:3500
void handle_ruleset_extra_flag(const struct packet_ruleset_extra_flag *p)
Definition packhand.c:4394
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:5411
#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:3986
void handle_nation_availability(int ncount, const bool *is_pickable, bool nationset_change)
Definition packhand.c:4764
void handle_spaceship_info(const struct packet_spaceship_info *p)
Definition packhand.c:3087
void handle_ruleset_specialist(const struct packet_ruleset_specialist *p)
Definition packhand.c:4896
void handle_unit_short_info(const struct packet_unit_short_info *packet)
Definition packhand.c:2169
void handle_diplomacy_accept_treaty(int counterpart, bool I_accepted, bool other_accepted)
Definition packhand.c:5651
void handle_ruleset_unit_flag(const struct packet_ruleset_unit_flag *p)
Definition packhand.c:3820
void handle_city_nationalities(const struct packet_city_nationalities *packet)
Definition packhand.c:995
void handle_server_shutdown(void)
Definition packhand.c:5454
void handle_ruleset_building(const struct packet_ruleset_building *p)
Definition packhand.c:4011
static int * continent_adjacency_count(Continent_id cont1, Continent_id cont2)
Definition packhand.c:3133
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:3729
void handle_ruleset_terrain(const struct packet_ruleset_terrain *p)
Definition packhand.c:4142
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:5120
#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:5258
void handle_ruleset_action_enabler(const struct packet_ruleset_action_enabler *p)
Definition packhand.c:4525
void handle_ruleset_achievement(const struct packet_ruleset_achievement *p)
Definition packhand.c:4588
void handle_game_info(const struct packet_game_info *pinfo)
Definition packhand.c:2284
struct player * placeholder
Definition packhand.c:120
void handle_vote_resolve(int vote_no, bool passed)
Definition packhand.c:5608
void handle_worker_task(const struct packet_worker_task *packet)
Definition packhand.c:1308
void handle_ruleset_description_part(const struct packet_ruleset_description_part *packet)
Definition packhand.c:3647
void handle_ruleset_trade(const struct packet_ruleset_trade *p)
Definition packhand.c:4604
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:140
int max_distance
Definition actions.h:123
bool quiet
Definition actions.h:130
enum action_sub_target_kind sub_target_kind
Definition actions.h:115
enum action_result result
Definition actions.h:110
char ui_name[MAX_LEN_NAME]
Definition actions.h:126
bv_action_sub_results sub_results
Definition actions.h:111
enum action_actor_kind actor_kind
Definition actions.h:113
bv_actions blocked_by
Definition actions.h:134
enum action_target_kind target_kind
Definition actions.h:114
int min_distance
Definition actions.h:123
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:474
enum combat_bonus_type type
Definition unittype.h:475
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_behaviour behaviour
enum counter_target type
struct strvec * helptext
char name[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
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:530
struct unit_class * uclass
Definition unittype.h:563
int pop_cost
Definition unittype.h:520
struct requirement_vector build_reqs
Definition unittype.h:527
int defense_strength
Definition unittype.h:523
bv_unit_classes cargo
Definition unittype.h:565
int firepower
Definition unittype.h:532
int paratroopers_range
Definition unittype.h:548
char graphic_alt[MAX_LEN_NAME]
Definition unittype.h:513
bool worker
Definition unittype.h:582
char sound_move_alt[MAX_LEN_NAME]
Definition unittype.h:516
int build_cost
Definition unittype.h:519
int convert_time
Definition unittype.h:538
int city_size
Definition unittype.h:557
struct veteran_system * veteran
Definition unittype.h:551
const struct unit_type * obsoleted_by
Definition unittype.h:536
int vision_radius_sq
Definition unittype.h:529
int move_rate
Definition unittype.h:524
bv_unit_classes targets
Definition unittype.h:568
enum vision_layer vlayer
Definition unittype.h:576
struct strvec * helptext
Definition unittype.h:578
struct unit_type::@90 adv
int bombard_rate
Definition unittype.h:554
char graphic_str[MAX_LEN_NAME]
Definition unittype.h:512
int city_slots
Definition unittype.h:559
char sound_move[MAX_LEN_NAME]
Definition unittype.h:515
char sound_fight_alt[MAX_LEN_NAME]
Definition unittype.h:518
struct name_translation name
Definition unittype.h:509
bv_unit_type_roles roles
Definition unittype.h:542
enum transp_def_type tp_defense
Definition unittype.h:561
int upkeep[O_LAST]
Definition unittype.h:545
char graphic_alt2[MAX_LEN_NAME]
Definition unittype.h:514
bv_unit_classes disembarks
Definition unittype.h:574
const struct unit_type * converted_to
Definition unittype.h:537
bv_unit_type_flags flags
Definition unittype.h:541
char sound_fight[MAX_LEN_NAME]
Definition unittype.h:517
bv_unit_classes embarks
Definition unittype.h:571
int attack_strength
Definition unittype.h:522
int happy_cost
Definition unittype.h:544
struct combat_bonus_list * bonuses
Definition unittype.h:533
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:115
#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:111
#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:3982
void tileset_setup_government(struct tileset *t, struct government *gov)
Definition tilespec.c:4592
void tileset_setup_specialist_type_default_set(struct tileset *t, Specialist_type_id id)
Definition tilespec.c:3067
void tileset_setup_tile_type(struct tileset *t, const struct terrain *pterrain)
Definition tilespec.c:4326
void tileset_player_init(struct tileset *t, struct player *pplayer)
Definition tilespec.c:7600
bool unit_drawn_with_city_outline(const struct unit *punit, bool check_focus)
Definition tilespec.c:5698
void tileset_setup_impr_type(struct tileset *t, struct impr_type *pimprove)
Definition tilespec.c:4016
void tileset_background_init(struct tileset *t)
Definition tilespec.c:7680
void tileset_setup_tech_type(struct tileset *t, struct advance *padvance)
Definition tilespec.c:4032
void tileset_setup_city_tiles(struct tileset *t, int style)
Definition tilespec.c:6644
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:4051
const char * tileset_basename(const struct tileset *t)
Definition tilespec.c:730
void finish_loading_sprites(struct tileset *t)
Definition tilespec.c:3788
const char * tileset_name_get(struct tileset *t)
Definition tilespec.c:7751
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:4607
void tileset_ruleset_reset(struct tileset *t)
Definition tilespec.c:7715
#define MAX_NUM_CITIZEN_SPRITES
Definition tilespec.h:199
#define NUM_WALL_TYPES
Definition tilespec.h:361
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:2447
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2518
bool unit_transport_unload(struct unit *pcargo)
Definition unit.c:2467
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Definition unit.c:1661
void unit_virtual_destroy(struct unit *punit)
Definition unit.c:1766
void unit_tile_set(struct unit *punit, struct tile *ptile)
Definition unit.c:1284
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2502
struct unit_list * unit_transport_cargo(const struct unit *ptrans)
Definition unit.c:2528
#define unit_tile(_pu)
Definition unit.h:404
@ 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:403
#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:2762
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:1575
const char * unit_rule_name(const struct unit *punit)
Definition unittype.c:1593
void set_unit_move_type(struct unit_class *puclass)
Definition unittype.c:2930
void set_unit_type_caches(struct unit_type *ptype)
Definition unittype.c:2821
struct unit_class * uclass_by_number(const Unit_Class_id id)
Definition unittype.c:2483
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:2691
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:921
void set_user_unit_class_flag_name(enum unit_class_flag_id id, const char *name, const char *helptxt)
Definition unittype.c:1818
struct veteran_system * veteran_system_new(int count)
Definition unittype.c:2660
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Definition unittype.c:377
void set_user_unit_type_flag_name(enum unit_type_flag_id id, const char *name, const char *helptxt)
Definition unittype.c:1882
#define UCF_LAST_USER_FLAG
Definition unittype.h:127
#define unit_class_iterate(_p)
Definition unittype.h:915
#define UTYF_LAST_USER_FLAG
Definition unittype.h:337
#define unit_type_iterate(_p)
Definition unittype.h:862
#define U_LAST
Definition unittype.h:40
#define unit_class_iterate_end
Definition unittype.h:922
#define unit_type_iterate_end
Definition unittype.h:869
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