Freeciv-3.4
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 "accessarea.h"
32#include "achievements.h"
33#include "actions.h"
34#include "capstr.h"
35#include "citizens.h"
36#include "counters.h"
37#include "events.h"
38#include "extras.h"
39#include "game.h"
40#include "government.h"
41#include "idex.h"
42#include "map.h"
43#include "name_translation.h"
44#include "movement.h"
45#include "multipliers.h"
46#include "nation.h"
47#include "packets.h"
48#include "player.h"
49#include "research.h"
50#include "rgbcolor.h"
51#include "road.h"
52#include "spaceship.h"
53#include "specialist.h"
54#include "style.h"
55#include "tiledef.h"
56#include "traderoutes.h"
57#include "unit.h"
58#include "unitlist.h"
59#include "worklist.h"
60
61/* client/include */
62#include "chatline_g.h"
63#include "citydlg_g.h"
64#include "cityrep_g.h"
65#include "connectdlg_g.h"
66#include "dialogs_g.h"
67#include "editgui_g.h"
68#include "gui_main_g.h"
69#include "inteldlg_g.h"
70#include "mapctrl_g.h" /* popup_newcity_dialog() */
71#include "mapview_g.h"
72#include "menu_g.h"
73#include "messagewin_g.h"
74#include "pages_g.h"
75#include "plrdlg_g.h"
76#include "ratesdlg_g.h"
77#include "repodlgs_g.h"
78#include "spaceshipdlg_g.h"
79#include "voteinfo_bar_g.h"
80#include "wldlg_g.h"
81
82/* client */
83#include "agents.h"
84#include "attribute.h"
85#include "audio.h"
86#include "client_main.h"
87#include "climap.h"
88#include "climisc.h"
89#include "clitreaty.h"
90#include "connectdlg_common.h"
91#include "control.h"
92#include "editor.h"
93#include "goto.h" /* client_goto_init() */
94#include "helpdata.h" /* boot_help_texts() */
95#include "mapview_common.h"
96#include "music.h"
97#include "options.h"
98#include "overview_common.h"
99#include "tilespec.h"
100#include "update_queue.h"
101#include "voteinfo.h"
102
103/* client/luascript */
104#include "script_client.h"
105
106#include "packhand.h"
107
108/* Define this macro to get additional debug output about the transport
109 * status of the units. */
110#undef DEBUG_TRANSPORT
111
112static void city_packet_common(struct city *pcity, struct tile *pcenter,
113 struct player *powner,
114 struct tile_list *worked_tiles,
115 bool is_new, bool popup, bool investigate);
116static bool handle_unit_packet_common(struct unit *packet_unit);
117
118
119/* The dumbest of cities, placeholders for unknown and unseen cities. */
120static struct {
121 struct city_list *cities;
123} invisible = {
124 .cities = nullptr,
125 .placeholder = nullptr
127
128static struct {
129 int len;
131 char *caption;
132 char *headline;
133 char *lines;
134 int parts;
135} page_msg_report = { .parts = 0 };
136
137extern const char forced_tileset_name[];
138
139static int last_turn = 0;
140
141/* Refresh the action selection dialog */
142#define REQEST_BACKGROUND_REFRESH (1)
143/* Get possible actions for fast auto attack. */
144#define REQEST_BACKGROUND_FAST_AUTO_ATTACK (2)
145
146/* A unit will auto attack with the following actions. */
162
163/* A unit will not auto attack if any of these actions are legal. */
211 /* Actually an attack but it needs a target to be specified. */
213 /* End the action list. */
215};
216
217/************************************************************************/
221{
222 if (invisible.cities != nullptr) {
227
229 invisible.cities = nullptr;
230 }
231
232 if (invisible.placeholder != nullptr) {
233 free(invisible.placeholder);
234 invisible.placeholder = nullptr;
235 }
236}
237
238/************************************************************************/
241static void packhand_init(void)
242{
244
245 invisible.cities = city_list_new();
246
247 /* Can't use player_new() here, as it will register the player. */
248 invisible.placeholder = fc_calloc(1, sizeof(*invisible.placeholder));
249 memset(invisible.placeholder, 0, sizeof(*invisible.placeholder));
250 /* Set some values to prevent bugs ... */
251 sz_strlcpy(invisible.placeholder->name, ANON_PLAYER_NAME);
252 sz_strlcpy(invisible.placeholder->username, _(ANON_USER_NAME));
253 invisible.placeholder->unassigned_user = TRUE;
254 sz_strlcpy(invisible.placeholder->ranked_username, ANON_USER_NAME);
255 invisible.placeholder->unassigned_ranked = TRUE;
256}
257
258/************************************************************************/
266static struct unit *unpackage_unit(const struct packet_unit_info *packet)
267{
269 nullptr,
270 utype_by_number(packet->type),
271 packet->veteran);
272
273 /* Owner, veteran, and type fields are already filled in by
274 * unit_virtual_create() */
276 punit->id = packet->id;
278 punit->facing = packet->facing;
279 punit->homecity = packet->homecity;
281 punit->upkeep[o] = packet->upkeep[o];
283 punit->moves_left = packet->movesleft;
284 punit->hp = packet->hp;
285 punit->activity = packet->activity;
287
288 if (packet->activity_tgt == EXTRA_NONE) {
289 punit->activity_target = nullptr;
290 } else {
292 }
293
296
297 if (packet->changed_from_tgt == EXTRA_NONE) {
298 punit->changed_from_target = nullptr;
299 } else {
301 }
302
304 punit->fuel = packet->fuel;
306 punit->paradropped = packet->paradropped;
307 punit->done_moving = packet->done_moving;
308 punit->stay = packet->stay;
309 punit->birth_turn = packet->birth_turn;
311
312 /* Transporter / transporting information. */
313 punit->client.occupied = packet->occupied;
314 if (packet->transported) {
316 } else {
318 }
319 if (packet->carrying >= 0) {
321 } else {
322 punit->carrying = nullptr;
323 }
324
325 punit->battlegroup = packet->battlegroup;
326 punit->has_orders = packet->has_orders;
327 punit->orders.length = packet->orders_length;
328 punit->orders.index = packet->orders_index;
329 punit->orders.repeat = packet->orders_repeat;
331 if (punit->has_orders) {
332 int i;
333
334 for (i = 0; i < packet->orders_length; i++) {
335 /* Just an assert. The client doesn't use the action data. */
337 || action_id_exists(packet->orders[i].action));
338 }
340 = fc_malloc(punit->orders.length * sizeof(*punit->orders.list));
341 memcpy(punit->orders.list, packet->orders,
342 punit->orders.length * sizeof(*punit->orders.list));
343 }
344
348
350
351 return punit;
352}
353
354/************************************************************************/
364static struct unit *
366{
367 struct unit *punit;
368 struct player *owner;
369
370 if (packet->owner == OWNER_NONE) {
371 owner = nullptr;
372 } else {
373 owner = player_by_number(packet->owner);
374 }
375
377 utype_by_number(packet->type),
378 0);
379
380 /* Owner and type fields are already filled in by unit_virtual_create() */
381 punit->id = packet->id;
383 punit->facing = packet->facing;
384 punit->nationality = nullptr;
385 punit->veteran = packet->veteran;
386 punit->hp = packet->hp;
387 punit->activity = packet->activity;
388
389 if (packet->activity_tgt == EXTRA_NONE) {
390 punit->activity_target = nullptr;
391 } else {
393 }
394
395 /* Transporter / transporting information. */
396 punit->client.occupied = packet->occupied;
397 if (packet->transported) {
399 } else {
401 }
402
403 return punit;
404}
405
406/************************************************************************/
410void handle_server_join_reply(bool you_can_join, const char *message,
411 const char *capability,
412 const char *challenge_file, int conn_id)
413{
414 const char *s_capability = client.conn.capability;
415
416 conn_set_capability(&client.conn, capability);
418
419 if (you_can_join) {
421
422 log_verbose("join game accept:%s", message);
424 client.conn.id = conn_id;
425
428
432 }
433
435#ifdef EMERGENCY_VERSION
436 client_info.emerg_version = EMERGENCY_VERSION;
437#else
438 client_info.emerg_version = 0;
439#endif
441 sizeof(client_info.distribution));
443
444 /* We could always use hack, verify we're local */
445#ifdef FREECIV_DEBUG
446 if (!hackless)
447#endif /* FREECIV_DEBUG */
448 {
449 send_client_wants_hack(challenge_file);
450 }
451
453 } else {
455 _("You were rejected from the game: %s"), message);
456 client.conn.id = -1; /* not in range of conn_info id */
457
458 if (auto_connect) {
459 log_normal(_("You were rejected from the game: %s"), message);
460 }
462
464 }
466 return;
467 }
468 output_window_printf(ftc_client, _("Client capability string: %s"),
470 output_window_printf(ftc_client, _("Server capability string: %s"),
472}
473
474/************************************************************************/
478void handle_city_remove(int city_id)
479{
480 struct city *pcity = game_city_by_number(city_id);
482
483 fc_assert_ret_msg(pcity != nullptr, "Bad city %d.", city_id);
484
486
490
491 /* Update menus if the focus unit is on the tile. */
492 if (need_menus_update) {
493 menus_update();
494 }
495}
496
497/************************************************************************/
501void handle_unit_remove(int unit_id)
502{
503 struct unit *punit = game_unit_by_number(unit_id);
504 struct unit_list *cargos;
505 struct player *powner;
507
508 if (!punit) {
509 log_error("Server wants us to remove unit id %d, "
510 "but we don't know about this unit!",
511 unit_id);
512 return;
513 }
514
515 /* Close the action selection dialog if the actor unit is lost. */
518 /* Open another action selection dialog if there are other actors in the
519 * current selection that want a decision. */
521 }
522
524 powner = unit_owner(punit);
525
526 /* Unload cargo if this is a transporter. */
528 if (unit_list_size(cargos) > 0) {
532 }
533
534 /* Unload unit if it is transported. */
537 }
539
543
544 if (!client_has_player() || powner == client_player()) {
547 }
549 }
550}
551
552/************************************************************************/
559
560/************************************************************************/
563void handle_team_name_info(int team_id, const char *team_name)
564{
565 struct team_slot *tslot = team_slot_by_number(team_id);
566
567 fc_assert_ret(tslot != nullptr);
568
571}
572
573/************************************************************************/
580{
581 bool show_combat = FALSE;
584
585 if (punit0 && punit1) {
587 packet->attacker_hp, packet->defender_hp,
588 packet->make_att_veteran, packet->make_def_veteran);
595 } else {
597 }
599 }
600
601 if (show_combat) {
602 int hp0 = packet->attacker_hp, hp1 = packet->defender_hp;
603
605 unit_type_get(punit0)->sound_fight_alt,
606 nullptr);
608 unit_type_get(punit1)->sound_fight_alt,
609 nullptr);
610
613 } else {
614 punit0->hp = hp0;
615 punit1->hp = hp1;
616
617 set_units_in_combat(nullptr, nullptr);
620 }
621 }
622 if (packet->make_att_veteran && punit0) {
623 punit0->veteran++;
625 }
626 if (packet->make_def_veteran && punit1) {
627 punit1->veteran++;
629 }
630 }
631}
632
633/************************************************************************/
640 struct impr_type *pimprove,
641 bool have_impr)
642{
643 if (have_impr) {
644 if (pcity->built[improvement_index(pimprove)].turn <= I_NEVER) {
645 city_add_improvement(pcity, pimprove);
646 return TRUE;
647 }
648 } else {
649 if (pcity->built[improvement_index(pimprove)].turn > I_NEVER) {
651 return TRUE;
652 }
653 }
654 return FALSE;
655}
656
657/************************************************************************/
661void handle_city_info(const struct packet_city_info *packet)
662{
663 struct universal product;
664 int i;
665 bool popup;
666 bool city_is_new = FALSE;
671 bool name_changed = FALSE;
674 bool production_changed = FALSE;
676 struct unit_list *pfocus_units = get_units_in_focus();
677 struct city *pcity = game_city_by_number(packet->id);
678 struct tile_list *worked_tiles = nullptr;
679 struct tile *pcenter = index_to_tile(&(wld.map), packet->tile);
680 struct tile *ptile = nullptr;
681 struct player *powner = player_by_number(packet->owner);
682
683 fc_assert_ret_msg(powner != nullptr, "Bad player number %d.", packet->owner);
684 fc_assert_ret_msg(pcenter != nullptr, "Invalid tile index %d.", packet->tile);
685
687 log_error("handle_city_info() bad production_kind %d.",
688 packet->production_kind);
689 product.kind = VUT_NONE;
690 } else {
692 packet->production_value);
693 if (!universals_n_is_valid(product.kind)) {
694 log_error("handle_city_info() "
695 "production_kind %d with bad production_value %d.",
696 packet->production_kind, packet->production_value);
697 product.kind = VUT_NONE;
698 }
699 }
700
701 if (pcity != nullptr) {
702 ptile = city_tile(pcity);
703
704 if (ptile == nullptr) {
705 /* Invisible worked city */
708
709 pcity->tile = pcenter;
710 ptile = pcenter;
711 pcity->owner = powner;
712 } else if (city_owner(pcity) != powner) {
713 /* Remember what were the worked tiles. The server won't
714 * send them to us again. */
716 ptile, pworked, _index, _x, _y) {
717 if (pcity == tile_worked(pworked)) {
718 if (worked_tiles == nullptr) {
719 worked_tiles = tile_list_new();
720 }
721 tile_list_append(worked_tiles, pworked);
722 }
725 pcity = nullptr;
727 }
728 }
729
730 if (pcity == nullptr) {
732 pcity = create_city_virtual(powner, pcenter, packet->name);
733 pcity->id = packet->id;
736 } else if (pcity->id != packet->id) {
737 log_error("handle_city_info() city id %d != id %d.",
738 pcity->id, packet->id);
739 return;
740 } else if (ptile != pcenter) {
741 log_error("handle_city_info() city tile (%d, %d) != (%d, %d).",
742 TILE_XY(ptile), TILE_XY(pcenter));
743 return;
744 } else {
746
747 while (trade_route_list_size(pcity->routes) > packet->trade_route_count) {
748 struct trade_route *proute = trade_route_list_get(pcity->routes, -1);
749
753 }
754
755 /* Descriptions should probably be updated if the
756 * city name, production or time-to-grow changes.
757 * Note that if either the food stock or surplus
758 * have changed, the time-to-grow is likely to
759 * have changed as well. */
762 && (!are_universals_equal(&pcity->production, &product)
763 || pcity->surplus[O_SHIELD] != packet->surplus[O_SHIELD]
764 || pcity->shield_stock != packet->shield_stock))
766 && (pcity->food_stock != packet->food_stock
767 || pcity->surplus[O_FOOD] != packet->surplus[O_FOOD]))
769
770 city_name_set(pcity, packet->name);
771 }
772
773 pcity->original = player_by_number(packet->original);
774
775 /* Check data */
777 for (i = 0; i < FEELING_LAST; i++) {
778 pcity->feel[CITIZEN_HAPPY][i] = packet->ppl_happy[i];
779 pcity->feel[CITIZEN_CONTENT][i] = packet->ppl_content[i];
780 pcity->feel[CITIZEN_UNHAPPY][i] = packet->ppl_unhappy[i];
781 pcity->feel[CITIZEN_ANGRY][i] = packet->ppl_angry[i];
782 }
783 for (i = 0; i < CITIZEN_LAST; i++) {
785 }
787 pcity->specialists[sp] = packet->specialists[sp];
789 city_size_add(pcity, pcity->specialists[sp]);
790 }
792
793 if (city_size_get(pcity) != packet->size) {
794 log_error("handle_city_info() "
795 "%d citizens not equal %d city size in \"%s\".",
797 city_size_set(pcity, packet->size);
798 }
799
800 pcity->history = packet->history;
801 pcity->client.culture = packet->culture;
802 pcity->client.buy_cost = packet->buy_cost;
803
804 pcity->city_radius_sq = packet->city_radius_sq;
805
806 pcity->city_options = packet->city_options;
807 pcity->wlcb = packet->wl_cb;
808
809 pcity->acquire_t = packet->acquire_type;
810
811 if (pcity->surplus[O_SCIENCE] != packet->surplus[O_SCIENCE]
812 || pcity->surplus[O_SCIENCE] != packet->surplus[O_SCIENCE]
813 || pcity->waste[O_SCIENCE] != packet->waste[O_SCIENCE]
814 || (pcity->unhappy_penalty[O_SCIENCE]
815 != packet->unhappy_penalty[O_SCIENCE])
816 || pcity->prod[O_SCIENCE] != packet->prod[O_SCIENCE]
817 || pcity->citizen_base[O_SCIENCE] != packet->citizen_base[O_SCIENCE]
818 || pcity->usage[O_SCIENCE] != packet->usage[O_SCIENCE]) {
820 }
821
822 pcity->food_stock = packet->food_stock;
823 if (pcity->shield_stock != packet->shield_stock) {
825 pcity->shield_stock = packet->shield_stock;
826 }
827 pcity->pollution = packet->pollution;
828 pcity->illness_trade = packet->illness_trade;
829
830 if (!are_universals_equal(&pcity->production, &product)) {
831 production_changed = TRUE;
832 }
833 /* Need to consider shield stock/surplus for unit dialog as used build
834 * slots may change, affecting number of "in-progress" units. */
835 if ((city_is_new && VUT_UTYPE == product.kind)
836 || (production_changed && (VUT_UTYPE == pcity->production.kind
837 || VUT_UTYPE == product.kind))
838 || pcity->surplus[O_SHIELD] != packet->surplus[O_SHIELD]
841 }
842 pcity->production = product;
843
845 pcity->surplus[o] = packet->surplus[o];
846 pcity->waste[o] = packet->waste[o];
847 pcity->unhappy_penalty[o] = packet->unhappy_penalty[o];
848 pcity->prod[o] = packet->prod[o];
849 pcity->citizen_base[o] = packet->citizen_base[o];
850 pcity->usage[o] = packet->usage[o];
852
853#ifdef DONE_BY_create_city_virtual
854 if (city_is_new) {
855 worklist_init(&pcity->worklist);
856
857 for (i = 0; i < ARRAY_SIZE(pcity->built); i++) {
858 pcity->built[i].turn = I_NEVER;
859 }
860 }
861#endif /* DONE_BY_create_city_virtual */
862
863 worklist_copy(&pcity->worklist, &packet->worklist);
864
865 pcity->airlift = packet->airlift;
866 pcity->did_buy = packet->did_buy;
867 pcity->did_sell = packet->did_sell;
868 pcity->was_happy = packet->was_happy;
869 pcity->had_famine = packet->had_famine;
870
871 pcity->anarchy = packet->anarchy;
872 pcity->rapture = packet->rapture;
873
874 pcity->turn_founded = packet->turn_founded;
875 pcity->turn_last_built = packet->turn_last_built;
876
878 log_error("handle_city_info() bad changed_from_kind %d.",
879 packet->changed_from_kind);
880 product.kind = VUT_NONE;
881 } else {
883 packet->changed_from_value);
884 if (!universals_n_is_valid(product.kind)) {
885 log_error("handle_city_info() bad changed_from_value %d.",
886 packet->changed_from_value);
887 product.kind = VUT_NONE;
888 }
889 }
891
892 pcity->before_change_shields = packet->before_change_shields;
893 pcity->disbanded_shields = packet->disbanded_shields;
894 pcity->caravan_shields = packet->caravan_shields;
895 pcity->last_turns_shield_surplus = packet->last_turns_shield_surplus;
896
897 improvement_iterate(pimprove) {
898 bool have = BV_ISSET(packet->improvements, improvement_index(pimprove));
899
900 if (have && !city_is_new
901 && pcity->built[improvement_index(pimprove)].turn <= I_NEVER) {
902 audio_play_sound(pimprove->soundtag, pimprove->soundtag_alt,
903 pimprove->soundtag_alt2);
904 }
908
909 /* We should be able to see units in the city. But for a diplomat
910 * investigating an enemy city we can't. In that case we don't update
911 * the occupied flag at all: it's already been set earlier and we'll
912 * get an update if it changes. */
915 = (unit_list_size(pcity->tile->units) > 0);
916 }
917
918 pcity->client.walls = packet->walls;
919 if (pcity->client.walls > NUM_WALL_TYPES) {
920 pcity->client.walls = NUM_WALL_TYPES;
921 }
922 pcity->style = packet->style;
923 pcity->capital = packet->capital;
924 if (packet->capital == CAPITAL_PRIMARY) {
925 powner->primary_capital_id = pcity->id;
926 } else if (powner->primary_capital_id == pcity->id) {
927 powner->primary_capital_id = 0;
928 }
929 pcity->client.city_image = packet->city_image;
930 pcity->steal = packet->steal;
931
932 pcity->client.happy = city_happy(pcity);
933 pcity->client.unhappy = city_unhappy(pcity);
934
936 && powner == client.conn.playing
938 || packet->diplomat_investigate;
939
940 city_packet_common(pcity, pcenter, powner, worked_tiles,
942
945 } else {
947 }
948
949 /* Update the description if necessary. */
952 }
953
954 /* Update focus unit info label if necessary. */
955 if (name_changed) {
957 if (pfocus_unit->homecity == pcity->id) {
959 break;
960 }
962 }
963
964 /* Update the science dialog if necessary. */
967 }
968
969 /* Update the units dialog if necessary. */
972 }
973
974 /* Update the economy dialog if necessary. */
977 }
978
979 /* Update the panel text (including civ population). */
981
982 /* Update caravan dialog */
983 if ((production_changed || shield_stock_changed)
988 city_tile(pcity)->index,
991 }
992
997 }
998}
999
1000/************************************************************************/
1004{
1005 struct city *pcity = game_city_by_number(packet->id);
1006
1007 /* The nationality of the citizens. */
1008 if (pcity != nullptr && game.info.citizen_nationality) {
1009 int i;
1010
1012 for (i = 0; i < packet->nationalities_count; i++) {
1014 packet->nation_citizens[i]);
1015 }
1017 }
1018}
1019
1020/************************************************************************/
1024{
1025 struct city *pcity = game_city_by_number(packet->id);
1026
1027 if (pcity != nullptr) {
1029 }
1030}
1031
1032/************************************************************************/
1037static void city_packet_common(struct city *pcity, struct tile *pcenter,
1038 struct player *powner,
1039 struct tile_list *worked_tiles,
1040 bool is_new, bool popup, bool investigate)
1041{
1042 if (worked_tiles != nullptr) {
1043 /* We need to transfer the worked infos because the server will assume
1044 * those infos are kept in our side and won't send to us again. */
1045 tile_list_iterate(worked_tiles, pwork) {
1048 tile_list_destroy(worked_tiles);
1049 }
1050
1051 if (is_new) {
1052 tile_set_worked(pcenter, pcity); /* is_free_worked() */
1053 city_list_prepend(powner->cities, pcity);
1054
1055 if (client_is_global_observer() || powner == client_player()) {
1057 }
1058
1060 unit_list_iterate(pp->units, punit) {
1061 if (punit->homecity == pcity->id) {
1062 unit_list_prepend(pcity->units_supported, punit);
1063 }
1066
1067 pcity->client.first_citizen_index = fc_rand(MAX_NUM_CITIZEN_SPRITES);
1068 } else {
1069 if (client_is_global_observer() || powner == client_player()) {
1071 }
1072 }
1073
1074 if (can_client_change_view()) {
1076 }
1077
1078 if (city_workers_display == pcity) {
1079 city_workers_display = nullptr;
1080 }
1081
1082 if (investigate) {
1083 /* Commit the collected supported and present units. */
1084 if (pcity->client.collecting_info_units_supported != nullptr) {
1085 /* We got units, let's move the unit lists. */
1086 fc_assert(pcity->client.collecting_info_units_present != nullptr);
1087
1088 unit_list_destroy(pcity->client.info_units_present);
1089 pcity->client.info_units_present =
1090 pcity->client.collecting_info_units_present;
1091 pcity->client.collecting_info_units_present = nullptr;
1092
1093 unit_list_destroy(pcity->client.info_units_supported);
1094 pcity->client.info_units_supported =
1095 pcity->client.collecting_info_units_supported;
1096 pcity->client.collecting_info_units_supported = nullptr;
1097 } else {
1098 /* We didn't get any unit, let's clear the unit lists. */
1099 fc_assert(pcity->client.collecting_info_units_present == nullptr);
1100
1101 unit_list_clear(pcity->client.info_units_supported);
1102 unit_list_clear(pcity->client.info_units_present);
1103 }
1104 }
1105
1106 if (popup
1107 && client.conn.playing != nullptr
1110 menus_update();
1111 if (!city_dialog_is_open(pcity)) {
1113 }
1114 }
1115
1116 if (!is_new
1119 }
1120
1121 /* update menus if the focus unit is on the tile. */
1123 menus_update();
1124 }
1125
1126 if (is_new) {
1127 log_debug("(%d,%d) creating city %d, %s %s", TILE_XY(pcenter),
1130 }
1131
1133}
1134
1135/************************************************************************/
1140{
1141 struct city *pcity = game_city_by_number(packet->city);
1142 struct trade_route *proute;
1143 bool city_changed = FALSE;
1144
1145 if (pcity == nullptr) {
1146 return;
1147 }
1148
1149 proute = trade_route_list_get(pcity->routes, packet->index);
1150 if (proute == nullptr) {
1151 fc_assert(trade_route_list_size(pcity->routes) == packet->index);
1152
1153 proute = fc_malloc(sizeof(struct trade_route));
1156 }
1157
1158 proute->partner = packet->partner;
1159 proute->value = packet->value;
1160 proute->dir = packet->direction;
1161 proute->goods = goods_by_number(packet->goods);
1162
1166 }
1167}
1168
1169/************************************************************************/
1175{
1177 bool city_is_new = FALSE;
1178 bool name_changed = FALSE;
1180 struct city *pcity = game_city_by_number(packet->id);
1181 struct tile *pcenter = index_to_tile(&(wld.map), packet->tile);
1182 struct tile *ptile = nullptr;
1183 struct tile_list *worked_tiles = nullptr;
1184 struct player *powner = player_by_number(packet->owner);
1185 struct player *original = player_by_number(packet->original);
1186 int radius_sq = game.info.init_city_radius_sq;
1187
1188 fc_assert_ret_msg(powner != nullptr, "Bad player number %d.", packet->owner);
1189 fc_assert_ret_msg(pcenter != nullptr, "Invalid tile index %d.", packet->tile);
1190
1191 if (pcity != nullptr) {
1192 ptile = city_tile(pcity);
1193
1194 if (ptile == nullptr) {
1195 /* Invisible worked city */
1197 city_is_new = TRUE;
1198
1199 pcity->tile = pcenter;
1200 pcity->owner = powner;
1201 pcity->original = original;
1202
1204 if (wtile->worked == pcity) {
1206
1209 }
1210 }
1212 } else if (city_owner(pcity) != powner) {
1213 /* Remember what were the worked tiles. The server won't
1214 * send to us again. */
1216 pworked, _index, _x, _y) {
1217 if (pcity == tile_worked(pworked)) {
1218 if (worked_tiles == nullptr) {
1219 worked_tiles = tile_list_new();
1220 }
1221 tile_list_append(worked_tiles, pworked);
1222 }
1224 radius_sq = city_map_radius_sq_get(pcity);
1226 pcity = nullptr;
1228 }
1229 }
1230
1231 if (pcity == nullptr) {
1232 city_is_new = TRUE;
1233 pcity = create_city_virtual(powner, pcenter, packet->name);
1234 pcity->id = packet->id;
1235 pcity->original = original;
1236 city_map_radius_sq_set(pcity, radius_sq);
1238 } else if (pcity->id != packet->id) {
1239 log_error("handle_city_short_info() city id %d != id %d.",
1240 pcity->id, packet->id);
1241 return;
1242 } else if (city_tile(pcity) != pcenter) {
1243 log_error("handle_city_short_info() city tile (%d, %d) != (%d, %d).",
1245 return;
1246 } else {
1247 name_changed = (fc_strncmp(packet->name, pcity->name, MAX_LEN_CITYNAME));
1248
1249 /* Check if city descriptions should be updated */
1252 }
1253
1254 city_name_set(pcity, packet->name);
1255
1256 memset(pcity->feel, 0, sizeof(pcity->feel));
1257 memset(pcity->specialists, 0, sizeof(pcity->specialists));
1258 }
1259
1260 pcity->specialists[DEFAULT_SPECIALIST] = packet->size;
1261 city_size_set(pcity, packet->size);
1262
1263 /* We can't actually see the internals of the city, but the server tells
1264 * us this much. */
1265 if (pcity->client.occupied != packet->occupied) {
1266 pcity->client.occupied = packet->occupied;
1269 }
1270 }
1271 pcity->client.walls = packet->walls;
1272 if (pcity->client.walls > NUM_WALL_TYPES) {
1273 pcity->client.walls = NUM_WALL_TYPES;
1274 }
1275 pcity->style = packet->style;
1276 pcity->capital = packet->capital;
1277 if (packet->capital == CAPITAL_PRIMARY) {
1278 powner->primary_capital_id = pcity->id;
1279 } else if (powner->primary_capital_id == pcity->id) {
1280 powner->primary_capital_id = 0;
1281 }
1282 pcity->client.city_image = packet->city_image;
1283
1284 pcity->client.happy = packet->happy;
1285 pcity->client.unhappy = packet->unhappy;
1286
1287 pcity->rapture = 0;
1288 pcity->anarchy = 0;
1289
1290 improvement_iterate(pimprove) {
1291 /* Don't update the non-visible improvements, they could hide the
1292 * previously seen information about the city (diplomat investigation).
1293 */
1294 if (is_improvement_visible(pimprove)) {
1295 bool have = BV_ISSET(packet->improvements,
1296 improvement_index(pimprove));
1298 }
1300
1301 city_packet_common(pcity, pcenter, powner, worked_tiles,
1303
1306 } else {
1308 }
1309
1310 /* Update the description if necessary. */
1311 if (update_descriptions) {
1313 }
1314}
1315
1316/************************************************************************/
1319void handle_worker_task(const struct packet_worker_task *packet)
1320{
1321 struct city *pcity = game_city_by_number(packet->city_id);
1322 struct worker_task *ptask = nullptr;
1323
1324 if (pcity == nullptr
1325 || (pcity->owner != client.conn.playing
1327 return;
1328 }
1329
1331 if (tile_index(ptask_old->ptile) == packet->tile_id) {
1332 ptask = ptask_old;
1333 break;
1334 }
1336
1337 if (ptask == nullptr) {
1338 if (packet->activity == ACTIVITY_LAST) {
1339 return;
1340 } else {
1341 ptask = fc_malloc(sizeof(struct worker_task));
1342 worker_task_list_append(pcity->task_reqs, ptask);
1343 }
1344 } else {
1345 if (packet->activity == ACTIVITY_LAST) {
1346 worker_task_list_remove(pcity->task_reqs, ptask);
1347 free(ptask);
1348 ptask = nullptr;
1349 }
1350 }
1351
1352 if (ptask != nullptr) {
1353 ptask->ptile = index_to_tile(&(wld.map), packet->tile_id);
1354 ptask->act = packet->activity;
1355 if (packet->tgt >= 0) {
1356 ptask->tgt = extra_by_number(packet->tgt);
1357 } else {
1358 ptask->tgt = nullptr;
1359 }
1360 ptask->want = packet->want;
1361 }
1362
1363 if (ptask && !worker_task_is_sane(ptask)) {
1364 log_debug("Bad worker task");
1365 worker_task_list_remove(pcity->task_reqs, ptask);
1366 free(ptask);
1367 ptask = nullptr;
1368 return;
1369 }
1370
1372}
1373
1374/************************************************************************/
1377void handle_new_year(int year, int fragments, int turn)
1378{
1379 game.info.year = year;
1380 game.info.fragment_count = fragments;
1381 /*
1382 * The turn was increased in handle_end_turn()
1383 */
1384 fc_assert(game.info.turn == turn);
1386
1389
1391 menus_update();
1392
1394
1395#if 0
1396 /* This information shouldn't be needed, but if it is this is the only
1397 * way we can get it. */
1398 if (client.conn.playing != nullptr) {
1402 }
1403#endif
1404
1407
1410 _("Start of turn %d"), game.info.turn);
1411 }
1412
1414
1415 if (last_turn != turn) {
1416 start_turn();
1417 last_turn = turn;
1418 }
1419}
1420
1421/************************************************************************/
1427{
1428 /* Messagewindow will contain events happened since our own phase ended,
1429 * so player of the first phase and last phase are in equal situation. */
1431}
1432
1433/************************************************************************/
1437void handle_start_phase(int phase)
1438{
1440 /* We are on detached state, let ignore this packet. */
1441 return;
1442 }
1443
1444 if (phase < 0
1446 && phase >= player_count())
1448 && phase >= team_count())) {
1449 log_error("handle_start_phase() illegal phase %d.", phase);
1450 return;
1451 }
1452
1454
1455 game.info.phase = phase;
1456
1457 /* Possibly replace wait cursor with something else */
1458 if (phase == 0) {
1459 /* TODO: Have server set as busy also if switching phase
1460 * is taking long in a alternating phases mode. */
1462 }
1463
1464 if (client.conn.playing != nullptr
1465 && is_player_phase(client.conn.playing, phase)) {
1468
1470
1474 }
1475
1477
1481
1485
1487 }
1488
1490}
1491
1492/************************************************************************/
1497{
1498 log_debug("handle_begin_turn()");
1499
1500 /* Server is still considered busy until it handles also the beginning
1501 * of the first phase. */
1502
1504}
1505
1506/************************************************************************/
1511{
1512 log_debug("handle_end_turn()");
1513
1514 /* Make sure wait cursor is in use */
1516
1518
1519 /*
1520 * The local idea of the game.info.turn is increased here since the
1521 * client will get unit updates (reset of move points for example)
1522 * between handle_end_turn() and handle_new_year(). These
1523 * unit updates will look like they did take place in the old turn
1524 * which is incorrect. If we get the authoritative information about
1525 * the game.info.turn in handle_new_year() we will check it.
1526 */
1527 game.info.turn++;
1528
1529 log_verbose(_("Beginning turn %d"), game.info.turn);
1530
1532}
1533
1534/************************************************************************/
1538{
1539 const char *sound_tag = get_event_tag(type);
1540
1541 if (sound_tag) {
1542 audio_play_sound(sound_tag, nullptr, nullptr);
1543 }
1544}
1545
1546/************************************************************************/
1550void handle_chat_msg(const struct packet_chat_msg *packet)
1551{
1552 handle_event(packet->message,
1553 index_to_tile(&(wld.map), packet->tile),
1554 packet->event,
1555 packet->turn,
1556 packet->phase,
1557 packet->conn_id);
1558}
1559
1560/************************************************************************/
1571{
1572 handle_event(packet->message,
1573 index_to_tile(&(wld.map), packet->tile),
1574 packet->event,
1575 packet->turn,
1576 packet->phase,
1577 packet->conn_id);
1578}
1579
1580/************************************************************************/
1585{
1586 popup_connect_msg(_("Welcome"), message);
1587}
1588
1589/************************************************************************/
1593void handle_server_info(const char *version_label, int major_version,
1594 int minor_version, int patch_version, int emerg_version)
1595{
1596 if (emerg_version > 0) {
1597 log_verbose("Server has version %d.%d.%d.%d%s",
1598 major_version, minor_version, patch_version, emerg_version,
1599 version_label);
1600 } else {
1601 log_verbose("Server has version %d.%d.%d%s",
1602 major_version, minor_version, patch_version, version_label);
1603 }
1604}
1605
1606/************************************************************************/
1609void handle_page_msg(const char *caption, const char *headline,
1610 enum event_type event, int len, int parts)
1611{
1612 if (!client_has_player()
1614 || event != E_BROADCAST_REPORT) {
1615 if (page_msg_report.parts > 0) {
1616 /* Previous one was never finished */
1617 free(page_msg_report.caption);
1618 free(page_msg_report.headline);
1619 free(page_msg_report.lines);
1620 }
1621 page_msg_report.len = len;
1622 page_msg_report.event = event;
1625 page_msg_report.parts = parts;
1626 page_msg_report.lines = fc_malloc(len + 1);
1627 page_msg_report.lines[0] = '\0';
1628
1629 if (parts == 0) {
1630 /* Empty report - handle as if last part was just received. */
1631 page_msg_report.parts = 1;
1633 }
1634 }
1635}
1636
1637/************************************************************************/
1641{
1642 if (page_msg_report.lines != nullptr) {
1643 /* We have already decided to show the message at the time we got
1644 * the header packet. */
1646 page_msg_report.parts--;
1647
1648 if (page_msg_report.parts == 0) {
1649 /* This is the final part */
1651 page_msg_report.headline,
1652 page_msg_report.lines);
1654
1655 free(page_msg_report.caption);
1656 free(page_msg_report.headline);
1657 free(page_msg_report.lines);
1658 page_msg_report.lines = nullptr;
1659 }
1660 }
1661}
1662
1663/************************************************************************/
1666void handle_unit_info(const struct packet_unit_info *packet)
1667{
1668 struct unit *punit;
1669
1670 punit = unpackage_unit(packet);
1674 }
1675}
1676
1677/**********************************************************************/
1683{
1686 if (utype_can_do_action(unit_type_get(punit), act_id)) {
1687 /* An auto action like auto attack could be legal. Check for those
1688 * at once so they won't have to wait for player focus. */
1690 punit->id,
1693 EXTRA_NONE,
1695 return;
1696 }
1698 }
1699
1700 /* This should be done in the foreground */
1702}
1703
1704/************************************************************************/
1721{
1722 struct city *pcity;
1723 struct unit *punit;
1724 bool need_menus_update = FALSE;
1727 bool repaint_unit = FALSE;
1728 bool repaint_city = FALSE; /* Regards unit's homecity */
1729 struct tile *old_tile = nullptr;
1730 bool check_focus = FALSE; /* Conservative focus change */
1731 bool moved = FALSE;
1732 bool ret = FALSE;
1734 struct player *plr = client_player();
1735
1736 if (owner == nullptr) {
1737 punit = nullptr;
1738 } else {
1740 }
1741
1742 if (punit == nullptr && game_unit_by_number(packet_unit->id)) {
1743 /* This means unit has changed owner. We deal with this here
1744 * by simply deleting the old one and creating a new one. */
1746 }
1747
1748 if (punit != nullptr) {
1749 /* In some situations, the size of repaint units require can change;
1750 * in particular, city-builder units sometimes get a potential-city
1751 * outline, but to speed up redraws we don't repaint this whole area
1752 * unnecessarily. We need to ensure that when the footprint shrinks,
1753 * old bits aren't left behind on the canvas.
1754 * If the current (old) status of the unit is such that it gets a large
1755 * repaint, as a special case, queue a large repaint immediately, to
1756 * schedule the correct amount/location to be redrawn; but rely on the
1757 * repaint being deferred until the unit is updated, so that what's
1758 * drawn reflects the new status (e.g., no city outline). */
1761 }
1762
1763 ret = TRUE;
1764 punit->activity_count = packet_unit->activity_count;
1766 if (punit->ssa_controller != packet_unit->ssa_controller) {
1767 punit->ssa_controller = packet_unit->ssa_controller;
1769 /* AI is set: May change focus */
1770 /* AI is cleared: Keep focus */
1771 if (packet_unit->ssa_controller != SSA_NONE
1772 && unit_is_in_focus(punit)) {
1773 check_focus = TRUE;
1774 }
1775 }
1776
1777 if (punit->facing != packet_unit->facing) {
1778 punit->facing = packet_unit->facing;
1780 }
1781
1782 if (punit->activity != packet_unit->activity
1783 || punit->activity_target == packet_unit->activity_target
1784 || punit->client.transported_by != packet_unit->client.transported_by
1785 || punit->client.occupied != packet_unit->client.occupied
1786 || punit->has_orders != packet_unit->has_orders
1787 || punit->orders.repeat != packet_unit->orders.repeat
1788 || punit->orders.vigilant != packet_unit->orders.vigilant
1789 || punit->orders.index != packet_unit->orders.index) {
1790
1791 /*** Change in activity or activity's target. ***/
1792
1793 /* May change focus if focus unit gets a new activity.
1794 * But if new activity is Idle, it means user specifically selected
1795 * the unit */
1797 && (packet_unit->activity != ACTIVITY_IDLE
1798 || packet_unit->has_orders)) {
1799 check_focus = TRUE;
1800 }
1801
1803
1804 /* Wakeup Focus */
1806 && plr != nullptr
1807 && is_human(plr)
1808 && owner == plr
1810 && packet_unit->activity == ACTIVITY_IDLE
1812 && is_player_phase(plr, game.info.phase)) {
1813 /* Many wakeup units per tile are handled */
1815 check_focus = FALSE; /* and keep it */
1816 }
1817
1818 punit->activity = packet_unit->activity;
1819 punit->activity_target = packet_unit->activity_target;
1820
1822 != packet_unit->client.transported_by) {
1823 if (packet_unit->client.transported_by == -1) {
1824 /* The unit was unloaded from its transport. The check for a new
1825 * transport is done below. */
1827 }
1828
1829 punit->client.transported_by = packet_unit->client.transported_by;
1830 }
1831
1832 if (punit->client.occupied != packet_unit->client.occupied) {
1834 /* Special case: (un)loading a unit in a transporter on the same
1835 * tile as the focus unit may (dis)allow the focus unit to be
1836 * loaded. Thus the orders->(un)load menu item needs updating. */
1838 }
1839 punit->client.occupied = packet_unit->client.occupied;
1840 }
1841
1842 punit->has_orders = packet_unit->has_orders;
1843 punit->orders.length = packet_unit->orders.length;
1844 punit->orders.index = packet_unit->orders.index;
1845 punit->orders.repeat = packet_unit->orders.repeat;
1846 punit->orders.vigilant = packet_unit->orders.vigilant;
1847
1848 /* We cheat by just stealing the packet unit's list. */
1849 if (punit->orders.list) {
1851 }
1852 punit->orders.list = packet_unit->orders.list;
1853 packet_unit->orders.list = nullptr;
1854
1855 if (plr == nullptr || owner == plr) {
1857 }
1858 } /*** End of Change in activity or activity's target. ***/
1859
1860 /* These two lines force the menus to be updated as appropriate when
1861 * the focus unit changes. */
1862 if (unit_is_in_focus(punit)) {
1864 }
1865
1866 if (punit->homecity != packet_unit->homecity) {
1867 /* change homecity */
1868 struct city *hcity;
1869
1871 unit_list_remove(hcity->units_supported, punit);
1873 }
1874
1875 punit->homecity = packet_unit->homecity;
1877 unit_list_prepend(hcity->units_supported, punit);
1879 }
1880
1881 /* This can change total upkeep figures */
1883 }
1884
1885 if (punit->hp != packet_unit->hp) {
1886 /* hp changed */
1887 punit->hp = packet_unit->hp;
1889 }
1890
1892 /* Unit type has changed (been upgraded) */
1893 struct city *ccity = tile_city(unit_tile(punit));
1894
1898 if (ccity != nullptr && (ccity->id != punit->homecity)) {
1900 }
1901 if (unit_is_in_focus(punit)) {
1902 /* Update the orders menu -- the unit might have new abilities */
1904 }
1906 }
1907
1908 /* May change focus if an attempted move or attack exhausted unit */
1909 if (punit->moves_left != packet_unit->moves_left
1910 && unit_is_in_focus(punit)) {
1911 check_focus = TRUE;
1912 }
1913
1915 /*** Change position ***/
1916 struct city *ccity = tile_city(unit_tile(punit));
1917
1919 moved = TRUE;
1920
1921 /* Show where the unit is going. */
1923
1924 if (ccity != nullptr) {
1926 /* Unit moved out of a city - update the occupied status. */
1927 bool new_occupied
1928 = (unit_list_size(ccity->tile->units) > 0);
1929
1930 if (ccity->client.occupied != new_occupied) {
1931 ccity->client.occupied = new_occupied;
1935 }
1936 }
1937 }
1938
1939 if (ccity->id == punit->homecity) {
1941 } else {
1943 }
1944 }
1945
1946 if ((ccity = tile_city(unit_tile(punit)))) {
1948 /* Unit moved into a city - obviously it's occupied. */
1949 if (!ccity->client.occupied) {
1950 ccity->client.occupied = TRUE;
1954 }
1955 }
1956 }
1957
1958 if (ccity->id == punit->homecity) {
1960 } else {
1962 }
1963 }
1964
1965 } /*** End of Change position. ***/
1966
1967 if (repaint_city || repaint_unit) {
1968 /* We repaint the city if the unit itself needs repainting or if
1969 * there is a special city-only redrawing to be done. */
1972 }
1974 && tile_city(unit_tile(punit)) != pcity) {
1975 /* Refresh the city we're occupying too. */
1977 }
1978 }
1979
1981 != packet_unit->upkeep[O_GOLD]);
1982 /* unit upkeep information */
1984 punit->upkeep[o] = packet_unit->upkeep[o];
1986
1987 punit->nationality = packet_unit->nationality;
1988 punit->veteran = packet_unit->veteran;
1989 punit->moves_left = packet_unit->moves_left;
1990 punit->fuel = packet_unit->fuel;
1991 punit->goto_tile = packet_unit->goto_tile;
1992 punit->paradropped = packet_unit->paradropped;
1993 punit->stay = packet_unit->stay;
1994 if (punit->done_moving != packet_unit->done_moving) {
1995 punit->done_moving = packet_unit->done_moving;
1996 check_focus = TRUE;
1997 }
1998 punit->carrying = packet_unit->carrying;
1999
2000 /* This won't change punit; it enqueues the call for later handling. */
2003
2004 if ((punit->action_decision_want != packet_unit->action_decision_want
2006 != packet_unit->action_decision_tile))
2008 /* The unit wants the player to decide. */
2010 /* Pop up an action selection dialog if the unit has focus or give
2011 * the unit higher priority in the focus queue if not. */
2012 punit->action_decision_tile = packet_unit->action_decision_tile;
2014 check_focus = TRUE;
2015 } else {
2016 /* Refresh already open action selection dialog. */
2020 tile_index(
2021 packet_unit->action_decision_tile),
2024 }
2025 }
2026 punit->action_decision_want = packet_unit->action_decision_want;
2027 punit->action_decision_tile = packet_unit->action_decision_tile;
2028 } else {
2029 /*** Create new unit ***/
2032
2033 if (owner != nullptr) {
2034 unit_list_prepend(owner->units, punit);
2035 }
2037
2039
2041 unit_list_prepend(pcity->units_supported, punit);
2042 }
2043
2044 log_debug("New %s %s id %d (%d %d) hc %d %s",
2048 (pcity ? city_name_get(pcity) : "(unknown)"));
2049
2052
2053 /* Check if we should link cargo units.
2054 * (This might be necessary if the cargo info was sent to us before
2055 * this transporter.) */
2056 if (punit->client.occupied) {
2058 if (aunit->client.transported_by == punit->id) {
2059 fc_assert(aunit->transporter == nullptr);
2060
2062 }
2064 }
2065
2066 if ((pcity = tile_city(unit_tile(punit)))) {
2067 /* The unit is in a city - obviously it's occupied. */
2069 }
2070
2072 /* The unit wants the player to decide. */
2074 check_focus = TRUE;
2075 }
2076
2078 } /*** End of Create new unit ***/
2079
2080 fc_assert_ret_val(punit != nullptr, ret);
2081
2082 /* Check if we have to load the unit on a transporter. */
2083 if (punit->client.transported_by != -1) {
2084 struct unit *ptrans
2085 = game_unit_by_number(packet_unit->client.transported_by);
2086
2087 /* Load unit only if transporter is known by the client.
2088 * (If not, cargo will be loaded later when the transporter info is
2089 * sent to the client.) */
2091 /* First, we have to unload the unit from its old transporter. */
2094
2095#ifdef DEBUG_TRANSPORT
2096 log_debug("load %s (ID: %d) onto %s (ID: %d)",
2099 } else if (ptrans && ptrans == unit_transport_get(punit)) {
2100 log_debug("%s (ID: %d) is loaded onto %s (ID: %d)",
2103 } else {
2104 log_debug("%s (ID: %d) is not loaded", unit_name_translation(punit),
2105 punit->id);
2106#endif /* DEBUG_TRANSPORT */
2107
2108 }
2109 }
2110
2115 /* Update (an possible active) unit select dialog. */
2117 }
2118
2119 if (repaint_unit) {
2121 }
2122
2123 if ((check_focus || get_num_units_in_focus() == 0)
2124 && plr != nullptr
2125 && is_human(plr)
2126 && is_player_phase(plr, game.info.phase)) {
2128 }
2129
2130 if (need_menus_update) {
2131 menus_update();
2132 }
2133
2134 if (!client_has_player() || owner == plr) {
2137 }
2140 }
2141 }
2142
2143 return ret;
2144}
2145
2146/************************************************************************/
2153{
2154 struct city *pcity = game_city_by_number(packet->city_id);
2155
2156 if (!pcity) {
2157 log_error("Investigate city: unknown city id %d!",
2158 packet->city_id);
2159 return;
2160 }
2161
2162 /* Start collecting supported and present units. */
2163
2164 /* Ensure we are not already in an investigate cycle. */
2165 fc_assert(pcity->client.collecting_info_units_supported == nullptr);
2166 fc_assert(pcity->client.collecting_info_units_present == nullptr);
2167
2168 pcity->client.collecting_info_units_supported
2170 pcity->client.collecting_info_units_present
2172}
2173
2174/************************************************************************/
2178{
2179}
2180
2181/************************************************************************/
2185{
2186 struct city *pcity;
2187 struct unit *punit;
2188
2189 /* Special case for a diplomat/spy investigating a city: The investigator
2190 * needs to know the supported and present units of a city, whether or not
2191 * they are fogged. So, we send a list of them all before sending the city
2192 * info. */
2194 || packet->packet_use == UNIT_INFO_CITY_PRESENT) {
2195
2197 if (!pcity) {
2198 log_error("Investigate city: unknown city id %d!",
2199 packet->info_city_id);
2200 return;
2201 }
2202
2203 /* Append a unit struct to the proper list. */
2204 punit = unpackage_short_unit(packet);
2205 if (punit != nullptr) {
2206 if (packet->packet_use == UNIT_INFO_CITY_SUPPORTED) {
2207 fc_assert(pcity->client.collecting_info_units_supported != nullptr);
2208 unit_list_append(pcity->client.collecting_info_units_supported, punit);
2209 } else {
2211 fc_assert(pcity->client.collecting_info_units_present != nullptr);
2212 unit_list_append(pcity->client.collecting_info_units_present, punit);
2213 }
2214 }
2215
2216 /* Done with special case. */
2217 return;
2218 }
2219
2220 if (player_by_number(packet->owner) == client.conn.playing) {
2221 log_error("handle_unit_short_info() for own unit.");
2222 }
2223
2224 punit = unpackage_short_unit(packet);
2225 if (punit != nullptr && handle_unit_packet_common(punit)) {
2228 }
2229}
2230
2231/************************************************************************/
2234void handle_set_topology(int topology_id, int wrap_id)
2235{
2236 wld.map.topology_id = topology_id;
2237 wld.map.wrap_id = wrap_id;
2238
2239 if (forced_tileset_name[0] == '\0'
2240 && (tileset_map_topo_compatible(topology_id, tileset, nullptr)
2243 const char *ts_to_load;
2244
2246
2247 if (ts_to_load != nullptr && ts_to_load[0] != '\0'
2250 }
2251 }
2252}
2253
2254/************************************************************************/
2258void handle_map_info(const struct packet_map_info *packet)
2259{
2260 int ts_topo;
2261
2262 if (!map_is_empty()) {
2263 map_free(&(wld.map), FALSE);
2265 }
2266
2267 wld.map.xsize = packet->xsize;
2268 wld.map.ysize = packet->ysize;
2269
2273
2277 _("Map topology (%s) and tileset (%s) incompatible."),
2279 }
2280
2281 wld.map.topology_id = packet->topology_id;
2282 wld.map.wrap_id = packet->wrap_id;
2283
2288 mapdeco_init();
2289
2291
2293
2294 packhand_init();
2295}
2296
2297/************************************************************************/
2301{
2302 bool boot_help;
2304 bool toggle_edit_ui = FALSE;
2305
2306 if (game.info.aifill != pinfo->aifill) {
2308 }
2309 if (game.info.skill_level != pinfo->skill_level) {
2311 }
2312
2313 if (game.info.is_edit_mode != pinfo->is_edit_mode) {
2315
2317 /* Clears the current goto command. */
2319
2320 if (pinfo->is_edit_mode) {
2322 /* Gui didn't handle this */
2324 _("This scenario may have manually set properties the editor "
2325 "cannot handle."));
2327 _("They won't be saved when scenario is saved from the editor."));
2328 }
2329 }
2330 }
2331
2332 game.info = *pinfo;
2333
2334 /* check the values! */
2335#define VALIDATE(_count, _maximum, _string) \
2336 if (game.info._count > _maximum) { \
2337 log_error("handle_game_info(): Too many " _string "; using %d of %d", \
2338 _maximum, game.info._count); \
2339 game.info._count = _maximum; \
2340 }
2341
2342 VALIDATE(granary_num_inis, MAX_GRANARY_INIS, "granary entries");
2343#undef VALIDATE
2344
2349
2351 && game.info.victory_conditions != pinfo->victory_conditions);
2352 if (boot_help) {
2353 boot_help_texts(); /* Reboot, after setting game.spacerace */
2354 }
2356 menus_update();
2360 }
2361
2362 if (can_client_change_view()) {
2364 }
2365
2366 if (toggle_edit_ui) {
2368 }
2369
2371}
2372
2373/************************************************************************/
2380
2381/************************************************************************/
2384void handle_timeout_info(float seconds_to_phasedone, float last_turn_change_time)
2385{
2386 if (current_turn_timeout() != 0 && seconds_to_phasedone >= 0) {
2387 /* If this packet is received in the middle of a turn, this value
2388 * represents the number of seconds from now to the end of the turn
2389 * (not from the start of the turn). So we need to restart our
2390 * timer. */
2391 set_seconds_to_turndone(seconds_to_phasedone);
2392 }
2393
2394 game.tinfo.last_turn_change_time = last_turn_change_time;
2395}
2396
2397/************************************************************************/
2410
2411/************************************************************************/
2420
2421/************************************************************************/
2426void handle_player_remove(int playerno)
2427{
2428 struct player_slot *pslot;
2429 struct player *pplayer;
2430 int plr_nbr;
2431
2432 pslot = player_slot_by_number(playerno);
2433
2434 if (pslot == nullptr || !player_slot_is_used(pslot)) {
2435 /* Ok, just ignore. */
2436 return;
2437 }
2438
2439 pplayer = player_slot_get_player(pslot);
2440
2441 if (can_client_change_view()) {
2442 close_intel_dialog(pplayer);
2443 }
2444
2445 /* Update the connection information. */
2446 if (client_player() == pplayer) {
2447 client.conn.playing = nullptr;
2448 }
2450 pconn->playing = nullptr;
2452 conn_list_clear(pplayer->connections);
2453
2454 /* Save player number before player is freed */
2455 plr_nbr = player_number(pplayer);
2456
2457 player_destroy(pplayer);
2458
2461
2464}
2465
2466/************************************************************************/
2472{
2473 bool is_new_nation = FALSE;
2474 bool turn_done_changed = FALSE;
2475 bool new_player = FALSE;
2476 int i;
2477 struct player *pplayer, *my_player;
2478 struct nation_type *pnation;
2479 struct government *pgov, *ptarget_gov;
2480 struct player_slot *pslot;
2481 struct team_slot *tslot;
2482 bool gov_change;
2483
2484 /* Player. */
2485 pslot = player_slot_by_number(pinfo->playerno);
2486
2487 fc_assert(pslot != nullptr);
2488
2490 pplayer = player_new(pslot);
2491
2492 if ((pplayer->rgb == nullptr) != !pinfo->color_valid
2493 || (pinfo->color_valid
2494 && (pplayer->rgb->r != pinfo->color_red
2495 || pplayer->rgb->g != pinfo->color_green
2496 || pplayer->rgb->b != pinfo->color_blue))) {
2497 struct rgbcolor *prgbcolor;
2498
2499 if (pinfo->color_valid) {
2500 prgbcolor = rgbcolor_new(pinfo->color_red,
2501 pinfo->color_green,
2502 pinfo->color_blue);
2503
2504 fc_assert_ret(prgbcolor != nullptr);
2505 } else {
2506 prgbcolor = nullptr;
2507 }
2508
2509 player_set_color(pplayer, prgbcolor);
2510 tileset_player_init(tileset, pplayer);
2511
2513
2514 /* Queue a map update -- may need to redraw borders, etc. */
2516 }
2517 pplayer->client.color_changeable = pinfo->color_changeable;
2518
2519 if (new_player) {
2520 /* Initialise client side player data (tile vision). At the moment
2521 * redundant as the values are initialised with 0 due to fc_calloc(). */
2522 client_player_init(pplayer);
2523 }
2524
2525 /* Team. */
2527
2528 fc_assert(tslot != nullptr);
2529
2530 /* Should never fail when slot given is not nullptr */
2531 team_add_player(pplayer, team_new(tslot));
2532
2533 pnation = nation_by_number(pinfo->nation);
2534 pgov = government_by_number(pinfo->government);
2535 ptarget_gov = government_by_number(pinfo->target_government);
2536
2537 /* Now update the player information. */
2538 sz_strlcpy(pplayer->name, pinfo->name);
2539 sz_strlcpy(pplayer->username, pinfo->username);
2540 pplayer->unassigned_user = pinfo->unassigned_user;
2541
2542 is_new_nation = player_set_nation(pplayer, pnation);
2543 pplayer->is_male = pinfo->is_male;
2544 pplayer->score.game = pinfo->score;
2545 pplayer->was_created = pinfo->was_created;
2546
2547 pplayer->autoselect_weight = pinfo->autoselect_weight;
2548 pplayer->economic.gold = pinfo->gold;
2549 pplayer->economic.tax = pinfo->tax;
2550 pplayer->economic.science = pinfo->science;
2551 pplayer->economic.luxury = pinfo->luxury;
2552 pplayer->client.tech_upkeep = pinfo->tech_upkeep;
2553 gov_change = (!new_player && pgov != pplayer->government
2554 && pplayer->government != nullptr);
2555 pplayer->government = pgov;
2556 pplayer->target_government = ptarget_gov;
2557 pplayer->real_embassy = pinfo->real_embassy;
2558 pplayer->gives_shared_vision = pinfo->gives_shared_vision;
2559 pplayer->gives_shared_tiles = pinfo->gives_shared_tiles;
2560 pplayer->style = style_by_number(pinfo->style);
2561
2562 if (pplayer == client.conn.playing) {
2563 bool music_change = FALSE;
2564
2565 if (pplayer->music_style != pinfo->music_style) {
2566 pplayer->music_style = pinfo->music_style;
2568 }
2569 if (pplayer->client.mood != pinfo->mood) {
2570 pplayer->client.mood = pinfo->mood;
2572 }
2573
2574 if (music_change) {
2576 }
2577
2578 if (gov_change) {
2579 audio_play_sound(pgov->sound_str, pgov->sound_alt, pgov->sound_alt2);
2580 }
2581 }
2582
2583 pplayer->history = pinfo->history;
2584 pplayer->client.culture = pinfo->culture;
2585
2586 if (pplayer->economic.infra_points != pinfo->infrapoints) {
2587 pplayer->economic.infra_points = pinfo->infrapoints;
2589 }
2590
2591 /* Don't use player_iterate or player_slot_count here, because we ignore
2592 * the real number of players and we want to read all the datas. */
2593 fc_assert(ARRAY_SIZE(pplayer->ai_common.love) >= ARRAY_SIZE(pinfo->love));
2594 for (i = 0; i < ARRAY_SIZE(pinfo->love); i++) {
2595 pplayer->ai_common.love[i] = pinfo->love[i];
2596 }
2597
2599
2600 pplayer->is_connected = pinfo->is_connected;
2601
2602 for (i = 0; i < B_LAST; i++) {
2603 pplayer->wonders[i] = pinfo->wonders[i];
2604 }
2605
2606 /* Set AI.control. */
2607 if (is_ai(pplayer) != BV_ISSET(pinfo->flags, PLRF_AI)) {
2608 BV_SET_VAL(pplayer->flags, PLRF_AI, BV_ISSET(pinfo->flags, PLRF_AI));
2609 if (pplayer == my_player) {
2610 if (is_ai(my_player)) {
2611 output_window_append(ftc_client, _("AI mode is now ON."));
2612 if (!gui_options.ai_manual_turn_done && !pplayer->phase_done) {
2613 /* End turn immediately */
2615 }
2616 } else {
2617 output_window_append(ftc_client, _("AI mode is now OFF."));
2618 }
2619 }
2620 }
2621
2622 pplayer->flags = pinfo->flags;
2623
2624 pplayer->ai_common.science_cost = pinfo->science_cost;
2625
2626 turn_done_changed = (pplayer->phase_done != pinfo->phase_done
2627 || (BV_ISSET(pplayer->flags, PLRF_AI) !=
2628 BV_ISSET(pinfo->flags, PLRF_AI)));
2629 pplayer->phase_done = pinfo->phase_done;
2630
2631 pplayer->is_ready = pinfo->is_ready;
2632 pplayer->nturns_idle = pinfo->nturns_idle;
2633 pplayer->is_alive = pinfo->is_alive;
2634 pplayer->turns_alive = pinfo->turns_alive;
2635 pplayer->ai_common.barbarian_type = pinfo->barbarian_type;
2636 pplayer->revolution_finishes = pinfo->revolution_finishes;
2637 pplayer->ai_common.skill_level = pinfo->ai_skill_level;
2638
2639 fc_assert(pinfo->multip_count == multiplier_count());
2640 game.control.num_multipliers = pinfo->multip_count;
2641 multipliers_iterate(pmul) {
2642 int idx = multiplier_index(pmul);
2643
2644 pplayer->multipliers[idx].value = pinfo->multiplier[idx];
2645 pplayer->multipliers[idx].target = pinfo->multiplier_target[idx];
2646 pplayer->multipliers[idx].changed = pinfo->multiplier_changed[idx];
2648
2649 /* if the server requests that the client reset, then information about
2650 * connections to this player are lost. If this is the case, insert the
2651 * correct conn back into the player->connections list */
2652 if (conn_list_size(pplayer->connections) == 0) {
2654 if (pplayer == pconn->playing) {
2655 /* insert the controller into first position */
2656 if (pconn->observer) {
2658 } else {
2660 }
2661 }
2663 }
2664
2665
2666 /* The player information is now fully set. Update the GUI. */
2667
2668 if (pplayer == my_player && can_client_change_view()) {
2669 if (turn_done_changed) {
2671 }
2678 menus_update();
2679 }
2680
2682
2685
2686 if (is_new_nation) {
2688
2689 /* When changing nation during a running game, some refreshing is needed.
2690 * This may not be the only one! */
2692 }
2693
2694 if (can_client_change_view()) {
2695 /* Just about any changes above require an update to the intelligence
2696 * dialog. */
2697 update_intel_dialog(pplayer);
2698 }
2699
2702 FALSE);
2703}
2704
2705/************************************************************************/
2709{
2710 struct research *presearch;
2711 bool tech_changed = FALSE;
2712 bool poptechup = FALSE;
2714 int gained_techs_num = 0, i;
2716
2717#ifdef FREECIV_DEBUG
2718 log_verbose("Research nb %d inventions: %s",
2719 packet->id,
2720 packet->inventions);
2721#endif /* FREECIV_DEBUG */
2722
2723 presearch = research_by_number(packet->id);
2724
2725 fc_assert_ret(presearch != nullptr);
2726
2727 poptechup = (presearch->researching != packet->researching
2728 || presearch->tech_goal != packet->tech_goal);
2729 presearch->techs_researched = packet->techs_researched;
2730 if (presearch->future_tech == 0 && packet->future_tech > 0) {
2732 }
2733 presearch->future_tech = packet->future_tech;
2734 presearch->researching = packet->researching;
2735 presearch->client.researching_cost = packet->researching_cost;
2736 presearch->bulbs_researched = packet->bulbs_researched;
2737 presearch->tech_goal = packet->tech_goal;
2738 presearch->client.total_bulbs_prod = packet->total_bulbs_prod;
2739
2741 newstate = packet->inventions[advi] - '0';
2743
2744 if (newstate != oldstate) {
2745 if (TECH_KNOWN == newstate) {
2747 if (A_NONE != advi) {
2749 }
2750 } else if (TECH_KNOWN == oldstate) {
2752 }
2753 }
2755
2757
2758 if (C_S_RUNNING == client_state()) {
2760 if (poptechup && is_human(client_player())) {
2762 }
2764 if (tech_changed) {
2765 /* Some ways a new or lost tech can affect menus:
2766 * - If tech is needed for certain governments, the government
2767 * switching menus need updating.
2768 * - If we just learned/lost bridge building and focus is on a
2769 * worker on a river, the road menu item needs updating. */
2770 menus_update();
2771
2772 script_client_signal_emit("new_tech");
2773
2774 /* If we got a new tech the tech tree news an update. */
2776 }
2777 for (i = 0; i < gained_techs_num; i++) {
2779 }
2780 }
2781 if (editor_is_active()) {
2785 FALSE);
2787 }
2788 }
2789}
2790
2791/************************************************************************/
2795{
2797
2798 if (presearch == nullptr) {
2799 log_error("Received unknown research for clearing: %d.", id);
2800 return;
2801 }
2802
2803 /* Do we need to set other fields? */
2804 presearch->researching = A_UNKNOWN;
2805 presearch->future_tech = 0;
2806 presearch->tech_goal = A_UNKNOWN;
2807
2811
2812 if (editor_is_active()) {
2816 FALSE);
2818 }
2819}
2820
2821/************************************************************************/
2825{
2826 struct player *plr1 = player_by_number(packet->plr1);
2827 struct player *plr2 = player_by_number(packet->plr2);
2828 struct player *my_player = client_player();
2829 struct player_diplstate *ds = player_diplstate_get(plr1, plr2);
2831
2832 fc_assert_ret(ds != nullptr);
2833
2834 if (client_has_player() && my_player == plr2) {
2835 if (ds->type != packet->type) {
2837 }
2838
2839 /* Check if we detect change to armistice with us. If so,
2840 * ready all units for movement out of the territory in
2841 * question; otherwise they will be disbanded. */
2843 && DS_ARMISTICE == packet->type) {
2846 || tile_owner(unit_tile(punit)) != plr1) {
2847 continue;
2848 }
2851 }
2852 if (punit->activity != ACTIVITY_IDLE) {
2854 }
2856 }
2857 }
2858
2859 ds->type = packet->type;
2860 ds->turns_left = packet->turns_left;
2861 ds->has_reason_to_cancel = packet->has_reason_to_cancel;
2862 ds->contact_turns_left = packet->contact_turns_left;
2863
2866 }
2867
2870 /* An action selection dialog is open and our diplomatic state just
2871 * changed. Find out if the relationship that changed was to a
2872 * potential target. */
2873 struct tile *tgt_tile = nullptr;
2874
2875 /* Is a refresh needed because of a unit target? */
2877 struct unit *tgt_unit;
2878
2880
2881 if (tgt_unit != nullptr && tgt_unit->owner == plr1) {
2882 /* An update is needed because of this unit target. */
2884
2885 fc_assert(tgt_tile != nullptr);
2886 }
2887 }
2888
2889 /* Is a refresh needed because of a city target? */
2891 struct city *tgt_city;
2892
2894
2895 if (tgt_city != nullptr && tgt_city->owner == plr1) {
2896 /* An update is needed because of this city target.
2897 * Overwrites any target tile from a unit. */
2899
2900 fc_assert(tgt_tile != nullptr);
2901 }
2902 }
2903
2904 if (tgt_tile
2905 || ((tgt_tile = index_to_tile(&(wld.map),
2907 && tile_owner(tgt_tile) == plr1)) {
2908 /* The diplomatic relationship to the target in an open action
2909 * selection dialog have changed. This probably changes
2910 * the set of available actions. */
2914 tgt_tile->index,
2917 }
2918 }
2919}
2920
2921/************************************************************************/
2928{
2929 struct connection *pconn = conn_by_number(pinfo->id);
2931
2932 log_debug("conn_info id%d used%d est%d plr%d obs%d acc%d",
2933 pinfo->id, pinfo->used, pinfo->established, pinfo->player_num,
2934 pinfo->observer, (int) pinfo->access_level);
2935 log_debug("conn_info \"%s\" \"%s\" \"%s\"",
2936 pinfo->username, pinfo->addr, pinfo->capability);
2937
2938 if (!pinfo->used) {
2939 /* Forget the connection */
2940 if (!pconn) {
2941 log_verbose("Server removed unknown connection %d", pinfo->id);
2942 return;
2943 }
2945 pconn = nullptr;
2946 } else {
2947 struct player_slot *pslot = player_slot_by_number(pinfo->player_num);
2948 struct player *pplayer = nullptr;
2949
2950 if (pslot != nullptr) {
2951 pplayer = player_slot_get_player(pslot);
2952 }
2953
2954 if (!pconn) {
2955 log_verbose("Server reports new connection %d %s",
2956 pinfo->id, pinfo->username);
2957
2958 pconn = fc_calloc(1, sizeof(struct connection));
2959 pconn->buffer = nullptr;
2960 pconn->send_buffer = nullptr;
2961 pconn->ping_time = -1.0;
2962 if (pplayer) {
2964 }
2967 } else {
2968 log_packet("Server reports updated connection %d %s",
2969 pinfo->id, pinfo->username);
2970 if (pplayer != pconn->playing) {
2971 if (pconn->playing != nullptr) {
2972 conn_list_remove(pconn->playing->connections, pconn);
2973 }
2974 if (pplayer) {
2976 }
2977 }
2978 }
2979
2980 pconn->id = pinfo->id;
2981 pconn->established = pinfo->established;
2982 pconn->observer = pinfo->observer;
2983 pconn->access_level = pinfo->access_level;
2984 pconn->playing = pplayer;
2985
2986 sz_strlcpy(pconn->username, pinfo->username);
2987 sz_strlcpy(pconn->addr, pinfo->addr);
2988 sz_strlcpy(pconn->capability, pinfo->capability);
2989
2990 if (pinfo->id == client.conn.id) {
2991 /* NB: In this case, pconn is not a duplication of client.conn.
2992 *
2993 * pconn->addr is our address that the server knows whereas
2994 * client.conn.addr is the address to the server. Also,
2995 * pconn->capability stores our capabilites known at server side
2996 * whereas client.conn.capability represents the capabilities of the
2997 * server. */
2998 if (client.conn.playing != pplayer
2999 || client.conn.observer != pinfo->observer) {
3000 /* Our connection state changed, let prepare the changes and reset
3001 * the game. */
3003 }
3004
3005 /* Copy our current state into the static structure (our connection
3006 * to the server). */
3007 client.conn.established = pinfo->established;
3008 client.conn.observer = pinfo->observer;
3009 client.conn.access_level = pinfo->access_level;
3010 client.conn.playing = pplayer;
3011 sz_strlcpy(client.conn.username, pinfo->username);
3012 }
3013 }
3014
3017
3018 if (pinfo->used && pinfo->id == client.conn.id) {
3019 /* For updating the sensitivity of the "Edit Mode" menu item,
3020 * among other things. */
3021 menus_update();
3022 }
3023
3026 }
3027}
3028
3029/************************************************************************/
3033void handle_conn_ping_info(int connections, const int *conn_id,
3034 const float *ping_time)
3035{
3036 int i;
3037
3038 for (i = 0; i < connections; i++) {
3039 struct connection *pconn = conn_by_number(conn_id[i]);
3040
3041 if (!pconn) {
3042 continue;
3043 }
3044
3045 pconn->ping_time = ping_time[i];
3046 log_debug("conn-id=%d, ping=%fs", pconn->id, pconn->ping_time);
3047 }
3048 /* The old_ping_time data is ignored. */
3049
3051}
3052
3053/************************************************************************/
3056void handle_achievement_info(int id, bool gained, bool first)
3057{
3058 struct achievement *pach;
3059
3061 log_error("Received illegal achievement info %d", id);
3062 return;
3063 }
3064
3066
3067 if (gained) {
3068 BV_SET(pach->achievers, player_index(client_player()));
3069 } else {
3070 BV_CLR(pach->achievers, player_index(client_player()));
3071 }
3072
3073 if (first) {
3074 pach->first = client_player();
3075 }
3076}
3077
3078/************************************************************************/
3093static bool spaceship_autoplace(struct player *pplayer,
3094 struct player_spaceship *ship)
3095{
3098
3099 if (next_spaceship_component(pplayer, ship, &place)) {
3101
3102 return TRUE;
3103 }
3104 }
3105
3106 return FALSE;
3107}
3108
3109/************************************************************************/
3113{
3114 struct player_spaceship *ship;
3115 struct player *pplayer = player_by_number(p->player_num);
3116
3117 fc_assert_ret_msg(pplayer != nullptr, "Invalid player number %d.",
3118 p->player_num);
3119
3120 ship = &pplayer->spaceship;
3121 ship->state = p->sship_state;
3122 ship->structurals = p->structurals;
3123 ship->components = p->components;
3124 ship->modules = p->modules;
3125 ship->fuel = p->fuel;
3126 ship->propulsion = p->propulsion;
3127 ship->habitation = p->habitation;
3128 ship->life_support = p->life_support;
3129 ship->solar_panels = p->solar_panels;
3130 ship->launch_year = p->launch_year;
3131 ship->population = p->population;
3132 ship->mass = p->mass;
3133 ship->support_rate = p->support_rate;
3134 ship->energy_rate = p->energy_rate;
3135 ship->success_rate = p->success_rate;
3136 ship->travel_time = p->travel_time;
3137 ship->structure = p->structure;
3138
3139 if (pplayer != client_player()) {
3140 refresh_spaceship_dialog(pplayer);
3141 menus_update();
3142 return;
3143 }
3144
3145 if (!spaceship_autoplace(pplayer, ship)) {
3146 /* We refresh the dialog when the packet did *not* cause placing
3147 * of new part. That's because those cases where part is placed, are
3148 * followed by exactly one case where there's no more parts to place -
3149 * we want to refresh the dialog only when that last packet comes. */
3150 refresh_spaceship_dialog(pplayer);
3151 }
3152}
3153
3154/**********************************************************************/
3160{
3161 if (cont1 == cont2) {
3162 return nullptr;
3163 } else if (cont1 >= 0 && cont2 <= 0) {
3164 return &wld.map.client.adj_matrix[cont1][-cont2];
3165 } else if (cont1 <= 0 && cont2 >= 0) {
3166 return &wld.map.client.adj_matrix[cont2][-cont1];
3167 }
3168 return nullptr;
3169}
3170
3171/**********************************************************************/
3178static inline void update_continent_cache(const struct tile *ptile,
3181{
3182 /* Update known continents */
3184 int cont;
3185
3186 /* Expand sizes array */
3188 (new_cont + 1) * sizeof(*wld.map.continent_sizes));
3189
3190 /* Expand adjacency matrix */
3192 (new_cont + 1) * sizeof(*wld.map.client.adj_matrix));
3193
3194 /* Initialize new spots */
3195 for (cont = wld.map.num_continents + 1; cont <= new_cont; cont++) {
3196 wld.map.continent_sizes[cont] = 0;
3198 sizeof(*wld.map.client.adj_matrix[cont]));
3199 }
3200
3202 } else if (new_cont < -wld.map.num_oceans) {
3203 int cont, ocean;
3204
3205 /* Expand sizes array */
3207 (-new_cont + 1) * sizeof(*wld.map.ocean_sizes));
3208
3209 /* Initialize new spots */
3210 for (ocean = wld.map.num_oceans + 1; ocean <= -new_cont; ocean++) {
3211 wld.map.ocean_sizes[ocean] = 0;
3212 }
3213
3214 /* Expand adjacency matrix */
3215 for (cont = 0; cont <= wld.map.num_continents; cont++) {
3217 wld.map.client.adj_matrix[cont],
3218 (-new_cont + 1) * sizeof(*wld.map.client.adj_matrix[cont])
3219 );
3220
3221 for (ocean = wld.map.num_oceans + 1; ocean <= -new_cont; ocean++) {
3222 wld.map.client.adj_matrix[cont][ocean] = 0;
3223 }
3224 }
3225
3227 }
3228
3229 /* Decrement old continent/ocean size */
3230 if (old_cont > 0) {
3232 } else if (old_cont < 0) {
3234 }
3235
3236 /* Increment new continent/ocean size */
3237 if (new_cont > 0) {
3239 } else if (new_cont < 0) {
3241 }
3242
3243 /* Update tile adjacency counts */
3244 adjc_iterate(&(wld.map), ptile, adj_tile) {
3246 int *padjc_count;
3247
3248 /* Decrement old adjacency */
3250 if (padjc_count) {
3251 fc_assert(*padjc_count > 0);
3252 (*padjc_count)--;
3253 }
3254
3255 /* Increment new adjacency */
3257 if (padjc_count) {
3258 (*padjc_count)++;
3259 }
3261}
3262
3263/************************************************************************/
3266void handle_tile_info(const struct packet_tile_info *packet)
3267{
3268 enum known_type new_known;
3269 enum known_type old_known;
3270 bool known_changed = FALSE;
3271 bool tile_changed = FALSE;
3272 struct player *powner = player_by_number(packet->owner);
3273 struct player *eowner = player_by_number(packet->extras_owner);
3274 struct extra_type *presource = nullptr;
3275 struct terrain *pterrain = terrain_by_number(packet->terrain);
3276 struct tile *ptile = index_to_tile(&(wld.map), packet->tile);
3277
3278 fc_assert_ret_msg(ptile != nullptr, "Invalid tile index %d.", packet->tile);
3279
3281
3282 if (packet->resource != MAX_EXTRA_TYPES) {
3283 presource = extra_by_number(packet->resource);
3284 }
3285
3286 if (tile_terrain(ptile) == nullptr || pterrain != tile_terrain(ptile)) {
3288 switch (old_known) {
3289 case TILE_UNKNOWN:
3290 tile_set_terrain(ptile, pterrain);
3291 break;
3292 case TILE_KNOWN_UNSEEN:
3293 case TILE_KNOWN_SEEN:
3294 if (pterrain != nullptr || TILE_UNKNOWN == packet->known) {
3295 tile_set_terrain(ptile, pterrain);
3296 } else {
3298 log_error("handle_tile_info() unknown terrain (%d, %d).",
3299 TILE_XY(ptile));
3300 }
3301 break;
3302 };
3303 }
3304
3305 if (!BV_ARE_EQUAL(ptile->extras, packet->extras)) {
3306 ptile->extras = packet->extras;
3308 }
3309
3310 tile_changed = tile_changed || (tile_resource(ptile) != presource);
3311
3312 /* Always called after setting terrain */
3313 tile_set_resource(ptile, presource);
3314
3315 if (tile_owner(ptile) != powner) {
3316 tile_set_owner(ptile, powner, nullptr);
3318 }
3319 if (extra_owner(ptile) != eowner) {
3320 ptile->extras_owner = eowner;
3322 }
3323
3324 ptile->altitude = packet->altitude;
3325
3326 if (packet->placing < 0) {
3327 if (ptile->placing != nullptr) {
3329 ptile->placing = nullptr;
3330 ptile->infra_turns = 0;
3331 }
3332 } else {
3333 struct extra_type *old = ptile->placing;
3334
3335 ptile->placing = extra_by_number(packet->placing);
3336 if (ptile->placing != old
3337 || ptile->infra_turns != packet->place_turn - game.info.turn) {
3339 }
3340 ptile->infra_turns = packet->place_turn - game.info.turn;
3341 }
3342
3343 if (tile_worked(ptile) == nullptr
3344 || tile_worked(ptile)->id != packet->worked) {
3345 if (IDENTITY_NUMBER_ZERO != packet->worked) {
3346 struct city *pwork = game_city_by_number(packet->worked);
3347
3348 if (pwork == nullptr) {
3349 char named[MAX_LEN_CITYNAME];
3350
3351 /* New unseen ("invisible") city, or before city_info */
3352 fc_snprintf(named, sizeof(named), "%06u", packet->worked);
3353
3354 pwork = create_city_virtual(invisible.placeholder, nullptr, named);
3355 pwork->id = packet->worked;
3357
3359
3360 log_debug("(%d,%d) invisible city %d, %s",
3361 TILE_XY(ptile), pwork->id, city_name_get(pwork));
3362 } else if (city_tile(pwork) == nullptr) {
3363 /* Old unseen ("invisible") city, or before city_info */
3364 if (powner != nullptr && city_owner(pwork) != powner) {
3365 /* Update placeholder with current owner */
3366 pwork->owner = powner;
3367 pwork->original = nullptr;
3368 }
3369 } else {
3370 /* We have a real (not invisible) city record for this ID, but
3371 * perhaps our info about that city is out of date. */
3372 int dist_sq = sq_map_distance(city_tile(pwork), ptile);
3373
3375 /* This is probably enemy city which has grown in diameter since we
3376 * last saw it. We need city_radius_sq to be at least big enough so
3377 * that all workers fit in, so set it so. */
3379 }
3380 /* This might be a known city that is open in a dialog.
3381 * (And this might be our only prompt to refresh the worked tiles
3382 * display in its city map, if a worker rearrangement does not
3383 * change anything else about the city such as output.) */
3384 {
3385 struct city *oldwork = tile_worked(ptile);
3386
3387 if (oldwork && city_tile(oldwork) != nullptr) {
3388 /* Refresh previous city too if it's real and different */
3390 }
3391 /* Refresh new city working tile (which we already know is real) */
3393 }
3394 }
3395
3396 /* This marks tile worked by (possibly invisible) city. Other
3397 * parts of the code have to handle invisible cities correctly
3398 * (ptile->worked->tile == nullptr) */
3399 tile_set_worked(ptile, pwork);
3400 } else {
3401 /* Tile is no longer being worked by a city.
3402 * (Again, this might be our only prompt to refresh the worked tiles
3403 * display for the previous working city.) */
3404 if (tile_worked(ptile) && city_tile(tile_worked(ptile)) != nullptr) {
3406 }
3407 tile_set_worked(ptile, nullptr);
3408 }
3409
3411 }
3412
3413 if (old_known != packet->known) {
3415 }
3416
3417 if (client.conn.playing != nullptr) {
3422
3423 switch (packet->known) {
3424 case TILE_KNOWN_SEEN:
3429 break;
3430 case TILE_KNOWN_UNSEEN:
3432 break;
3433 case TILE_UNKNOWN:
3434 break;
3435 default:
3436 log_error("handle_tile_info() invalid known (%d).", packet->known);
3437 break;
3438 };
3439 }
3441
3442 if (packet->spec_sprite[0] != '\0') {
3443 if (!ptile->spec_sprite
3444 || strcmp(ptile->spec_sprite, packet->spec_sprite) != 0) {
3445 if (ptile->spec_sprite) {
3446 free(ptile->spec_sprite);
3447 }
3448 ptile->spec_sprite = fc_strdup(packet->spec_sprite);
3450 }
3451 } else {
3452 if (ptile->spec_sprite) {
3453 free(ptile->spec_sprite);
3454 ptile->spec_sprite = nullptr;
3456 }
3457 }
3458
3460 /* This is an error. So first we log the error,
3461 * then make an assertion. */
3462 unit_list_iterate(ptile->units, punit) {
3463 log_error("%p %d %s at (%d,%d) %s", punit, punit->id,
3467 fc_assert_msg(0 == unit_list_size(ptile->units), "Ghost units seen");
3468 /* Repairing... */
3469 unit_list_clear(ptile->units);
3470 }
3471
3472 if (ptile->continent != packet->continent) {
3473 update_continent_cache(ptile, ptile->continent, packet->continent);
3474 }
3475 ptile->continent = packet->continent;
3476
3477 if (packet->label[0] == '\0') {
3478 if (ptile->label != nullptr) {
3479 FC_FREE(ptile->label);
3480 ptile->label = nullptr;
3482 }
3483 } else if (ptile->label == nullptr || strcmp(packet->label, ptile->label)) {
3484 tile_set_label(ptile, packet->label);
3486 }
3487
3488 if (known_changed || tile_changed) {
3489 /*
3490 * A tile can only change if it was known before and is still
3491 * known. In the other cases the tile is new or removed.
3492 */
3494 agents_tile_new(ptile);
3495 } else if (known_changed && TILE_KNOWN_UNSEEN == new_known) {
3496 agents_tile_remove(ptile);
3497 } else {
3498 agents_tile_changed(ptile);
3499 }
3501 }
3502
3503 /* refresh tiles */
3504 if (can_client_change_view()) {
3505 /* the tile itself (including the necessary parts of adjacent tiles) */
3506 if (tile_changed || old_known != new_known) {
3508 }
3509 }
3510
3511 /* update menus if the focus unit is on the tile. */
3512 if (tile_changed) {
3513 if (get_focus_unit_on_tile(ptile)) {
3514 menus_update();
3515 }
3516 }
3517
3518 /* FIXME: we really ought to call refresh_city_dialog() for any city
3519 * whose radii include this tile, to update the city map display.
3520 * But that would be expensive. We deal with the (common) special
3521 * case of changes in worked tiles above. */
3522}
3523
3524/************************************************************************/
3544
3545/************************************************************************/
3548void handle_scenario_description(const char *description)
3549{
3551
3553}
3554
3555/************************************************************************/
3561{
3562 /* The ruleset is going to load new nations. So close
3563 * the nation selection dialog if it is open. */
3565
3571 game.control = *packet;
3572
3573 /* check the values! */
3574#define VALIDATE(_count, _maximum, _string) \
3575 if (game.control._count > _maximum) { \
3576 log_error("handle_ruleset_control(): Too many " _string \
3577 "; using %d of %d", _maximum, game.control._count); \
3578 game.control._count = _maximum; \
3579 }
3580
3581 VALIDATE(num_unit_classes, UCL_LAST, "unit classes");
3582 VALIDATE(num_unit_types, U_LAST, "unit types");
3583 VALIDATE(num_impr_types, B_LAST, "improvements");
3584 VALIDATE(num_tech_types, A_LAST, "advances");
3585 VALIDATE(num_base_types, MAX_EXTRA_TYPES, "bases");
3586 VALIDATE(num_road_types, MAX_EXTRA_TYPES, "roads");
3587 VALIDATE(num_resource_types, MAX_EXTRA_TYPES, "resources");
3588 VALIDATE(num_disaster_types, MAX_DISASTER_TYPES, "disasters");
3589 VALIDATE(num_achievement_types, MAX_ACHIEVEMENT_TYPES, "achievements");
3590 VALIDATE(num_counters, MAX_COUNTERS, "counters");
3591
3592 /* game.control.government_count, game.control.nation_count and
3593 * game.control.num_city_styles are allocated dynamically, and do
3594 * not need a size check. See the allocation below. */
3595
3597
3598 VALIDATE(num_specialist_types, SP_MAX, "specialists");
3599#undef VALIDATE
3600
3606
3607 if (game.control.desc_length > 0) {
3609 game.ruleset_description[0] = '\0';
3610 }
3611
3612 if (packet->preferred_tileset[0] != '\0') {
3613 /* There is tileset suggestion */
3615 /* It's not currently in use */
3618 } else {
3620 }
3621 }
3622 }
3623
3624 if (packet->preferred_soundset[0] != '\0') {
3625 /* There is soundset suggestion */
3627 /* It's not currently in use */
3630 } else {
3632 }
3633 }
3634 }
3635
3636 if (packet->preferred_musicset[0] != '\0') {
3637 /* There is musicset suggestion */
3639 /* It's not currently in use */
3642 } else {
3644 }
3645 }
3646 }
3647
3649
3651}
3652
3653/************************************************************************/
3657{
3658 int len;
3659
3660 if (game.ruleset_summary != nullptr) {
3662 }
3663
3664 len = strlen(packet->text);
3665
3667
3668 fc_strlcpy(game.ruleset_summary, packet->text, len + 1);
3669}
3670
3671/************************************************************************/
3680
3681/************************************************************************/
3685{
3686 /* Setup extra hiders caches */
3687 extra_type_iterate(pextra) {
3688 pextra->hiders = extra_type_list_new();
3690 if (BV_ISSET(pextra->hidden_by, extra_index(phider))) {
3691 extra_type_list_append(pextra->hiders, phider);
3692 }
3694 pextra->bridged = extra_type_list_new();
3696 if (BV_ISSET(pextra->bridged_over, extra_index(pbridged))) {
3697 extra_type_list_append(pextra->bridged, pbridged);
3698 }
3701
3706
3707 /* Setup improvement feature caches */
3709
3710 /* Setup road integrators caches */
3712
3713 /* Pre calculate action related data. */
3715
3716 /* Setup unit unknown move cost caches */
3718 ptype->unknown_move_cost = utype_unknown_move_cost(ptype);
3722
3723 /* Cache what city production can receive help from caravans. */
3725
3726 /* Adjust editor for changed ruleset. */
3728
3729 /* We are not going to crop any more sprites from big sprites, free them. */
3731
3733}
3734
3735/************************************************************************/
3739{
3740 struct unit_class *c = uclass_by_number(p->id);
3741
3742 fc_assert_ret_msg(c != nullptr, "Bad unit_class %d.", p->id);
3743
3744 names_set(&c->name, nullptr, p->name, p->rule_name);
3745 c->min_speed = p->min_speed;
3746 c->hp_loss_pct = p->hp_loss_pct;
3748 c->flags = p->flags;
3749
3751}
3752
3753/************************************************************************/
3757{
3758 int i;
3759 struct unit_type *u = utype_by_number(p->id);
3760
3761 fc_assert_ret_msg(u != nullptr, "Bad unit_type %d.", p->id);
3762
3763 names_set(&u->name, nullptr, p->name, p->rule_name);
3771
3773 u->build_cost = p->build_cost;
3774 u->pop_cost = p->pop_cost;
3778 u->move_rate = p->move_rate;
3782 u->hp = p->hp;
3783 u->firepower = p->firepower;
3786 u->convert_time = p->convert_time;
3787 u->fuel = p->fuel;
3788 u->flags = p->flags;
3789 u->roles = p->roles;
3790 u->happy_cost = p->happy_cost;
3792 u->upkeep[o] = p->upkeep[o];
3795 u->bombard_rate = p->bombard_rate;
3796 u->city_size = p->city_size;
3797 u->city_slots = p->city_slots;
3798 u->tp_defense = p->tp_defense;
3799 u->cargo = p->cargo;
3800 u->targets = p->targets;
3801 u->embarks = p->embarks;
3802 u->disembarks = p->disembarks;
3803 u->vlayer = p->vlayer;
3804
3805 if (p->veteran_levels == 0) {
3806 u->veteran = nullptr;
3807 } else {
3809
3810 for (i = 0; i < p->veteran_levels; i++) {
3812 p->power_fact[i], p->move_bonus[i],
3813 p->base_raise_chance[i],
3814 p->work_raise_chance[i]);
3815 }
3816 }
3817
3819
3820 u->adv.worker = p->worker;
3821
3823}
3824
3825/************************************************************************/
3829{
3830 struct unit_type *u = utype_by_number(p->unit);
3831 struct combat_bonus *bonus;
3832
3833 fc_assert_ret_msg(u != nullptr, "Bad unit_type %d.", p->unit);
3834
3835 bonus = malloc(sizeof(*bonus));
3836
3837 bonus->flag = p->flag;
3838 bonus->type = p->type;
3839 bonus->value = p->value;
3840 bonus->quiet = p->quiet;
3841
3843}
3844
3845/************************************************************************/
3849{
3850 const char *flagname;
3851 const char *helptxt;
3852
3854 "Bad user flag %d.", p->id);
3855
3856 if (p->name[0] == '\0') {
3857 flagname = nullptr;
3858 } else {
3859 flagname = p->name;
3860 }
3861
3862 if (p->helptxt[0] == '\0') {
3863 helptxt = nullptr;
3864 } else {
3865 helptxt = p->helptxt;
3866 }
3867
3869}
3870
3871/************************************************************************/
3875 const struct packet_ruleset_unit_class_flag *p)
3876{
3877 const char *flagname;
3878 const char *helptxt;
3879
3881 "Bad user flag %d.", p->id);
3882
3883 if (p->name[0] == '\0') {
3884 flagname = nullptr;
3885 } else {
3886 flagname = p->name;
3887 }
3888
3889 if (p->helptxt[0] == '\0') {
3890 helptxt = nullptr;
3891 } else {
3892 helptxt = p->helptxt;
3893 }
3894
3896}
3897
3898/************************************************************************/
3904static int unpack_tech_req(const enum tech_req r_num,
3905 const struct requirement_vector *reqs,
3906 struct advance *a,
3907 int i)
3908{
3911 /* Extract the tech req so the old code can reason about it. */
3912
3913 /* This IS a traditional tech req... right? */
3916
3917 /* Put it in the advance structure. */
3918 a->require[r_num] = requirement_vector_get(reqs, i)->source.value.advance;
3919
3920 /* Move on in the requirement vector. */
3921 i++;
3922 } else {
3923 /* No tech req. */
3925 }
3926
3927 return i;
3928}
3929
3930/************************************************************************/
3934{
3935 int i;
3936 struct advance *a = advance_by_number(p->id);
3937
3938 fc_assert_ret_msg(a != nullptr, "Bad advance %d.", p->id);
3939
3940 names_set(&a->name, nullptr, p->name, p->rule_name);
3943
3944 i = 0;
3945
3948
3949 if (p->tclass >= 0) {
3951 } else {
3952 a->tclass = nullptr;
3953 }
3954
3955 /* The tech requirements req1 and req2 are send inside research_reqs
3956 * since they too are required to be fulfilled before the tech can be
3957 * researched. */
3958
3959 if (p->removed) {
3960 /* The Freeciv data structures currently records that a tech is removed
3961 * by setting req1 and req2 to "Never". */
3962 a->require[AR_ONE] = A_NEVER;
3963 a->require[AR_TWO] = A_NEVER;
3964 } else {
3965 /* Unpack req1 and req2 from the research_reqs requirement vector. */
3968 }
3969
3970 /* Any remaining requirements are a part of the research_reqs requirement
3971 * vector. */
3973 /* slice of the vector starting at index i */
3974 &(const struct requirement_vector) {
3975 .p = p->research_reqs.p + i,
3976 .size = p->research_reqs.size - i,
3977 /* .size_alloc shouldn't matter */
3978 });
3979
3980 /* The packet's research_reqs should contain req1, req2 and the
3981 * requirements of the tech's research_reqs. */
3982 fc_assert((a->research_reqs.size
3983 + ((a->require[AR_ONE]
3984 && (advance_number(a->require[AR_ONE]) != A_NONE)) ?
3985 1 : 0)
3986 + ((a->require[AR_TWO]
3987 && (advance_number(a->require[AR_TWO]) != A_NONE)) ?
3988 1 : 0))
3990
3992
3993 a->flags = p->flags;
3994 a->cost = p->cost;
3995 a->num_reqs = p->num_reqs;
3997
3999}
4000
4001/************************************************************************/
4005{
4007
4008 fc_assert_ret_msg(ptclass != nullptr, "Bad tech_class %d.", p->id);
4009
4010 names_set(&ptclass->name, nullptr, p->name, p->rule_name);
4011 ptclass->cost_pct = p->cost_pct;
4012}
4013
4014/************************************************************************/
4018{
4019 const char *flagname;
4020 const char *helptxt;
4021
4023 "Bad user flag %d.", p->id);
4024
4025 if (p->name[0] == '\0') {
4026 flagname = nullptr;
4027 } else {
4028 flagname = p->name;
4029 }
4030
4031 if (p->helptxt[0] == '\0') {
4032 helptxt = nullptr;
4033 } else {
4034 helptxt = p->helptxt;
4035 }
4036
4037 set_user_tech_flag_name(p->id, flagname, helptxt);
4038}
4039
4040/************************************************************************/
4044{
4045 struct impr_type *b = improvement_by_number(p->id);
4046
4047 fc_assert_ret_msg(b != nullptr, "Bad improvement %d.", p->id);
4048
4049 b->genus = p->genus;
4050 names_set(&b->name, nullptr, p->name, p->rule_name);
4056 b->build_cost = p->build_cost;
4057 b->upkeep = p->upkeep;
4058 b->sabotage = p->sabotage;
4059 b->flags = p->flags;
4064
4065#ifdef FREECIV_DEBUG
4066 if (p->id == improvement_count() - 1) {
4068 log_debug("Improvement: %s...", improvement_rule_name(bdbg));
4069 log_debug(" build_cost %3d", bdbg->build_cost);
4070 log_debug(" upkeep %2d", bdbg->upkeep);
4071 log_debug(" sabotage %3d", bdbg->sabotage);
4072 if (bdbg->helptext != nullptr) {
4073 strvec_iterate(bdbg->helptext, text) {
4074 log_debug(" helptext %s", text);
4076 }
4078 }
4079#endif /* FREECIV_DEBUG */
4080
4082}
4083
4084/************************************************************************/
4088{
4089 const char *flagname;
4090 const char *helptxt;
4091
4093 "Bad user flag %d.", p->id);
4094
4095 if (p->name[0] == '\0') {
4096 flagname = nullptr;
4097 } else {
4098 flagname = p->name;
4099 }
4100
4101 if (p->helptxt[0] == '\0') {
4102 helptxt = nullptr;
4103 } else {
4104 helptxt = p->helptxt;
4105 }
4106
4107 set_user_impr_flag_name(p->id, flagname, helptxt);
4108}
4109
4110/************************************************************************/
4114{
4115 struct multiplier *pmul = multiplier_by_number(p->id);
4116
4117 fc_assert_ret_msg(pmul != nullptr, "Bad multiplier %d.", p->id);
4118
4119 pmul->start = p->start;
4120 pmul->stop = p->stop;
4121 pmul->step = p->step;
4122 pmul->def = p->def;
4123 pmul->offset = p->offset;
4124 pmul->factor = p->factor;
4125 pmul->minimum_turns = p->minimum_turns;
4126
4127 names_set(&pmul->name, nullptr, p->name, p->rule_name);
4128 requirement_vector_copy(&pmul->reqs, &p->reqs);
4130}
4131
4132/************************************************************************/
4136{
4137 struct government *gov = government_by_number(p->id);
4138
4139 fc_assert_ret_msg(gov != nullptr, "Bad government %d.", p->id);
4140
4141 gov->item_number = p->id;
4142
4143 requirement_vector_copy(&gov->reqs, &p->reqs);
4144 names_set(&gov->name, nullptr, p->name, p->rule_name);
4147 sz_strlcpy(gov->sound_str, p->sound_str);
4148 sz_strlcpy(gov->sound_alt, p->sound_alt);
4150 gov->flags = p->flags;
4151
4153
4155}
4156
4157/************************************************************************/
4161 (const struct packet_ruleset_government_ruler_title *packet)
4162{
4163 struct government *gov = government_by_number(packet->gov);
4164
4165 fc_assert_ret_msg(gov != nullptr, "Bad government %d.", packet->gov);
4166
4168 packet->male_title,
4169 packet->female_title);
4170}
4171
4172/************************************************************************/
4176{
4177 const char *flagname;
4178 const char *helptxt;
4179
4181 "Bad user flag %d.", p->id);
4182
4183 if (p->name[0] == '\0') {
4184 flagname = nullptr;
4185 } else {
4186 flagname = p->name;
4187 }
4188
4189 if (p->helptxt[0] == '\0') {
4190 helptxt = nullptr;
4191 } else {
4192 helptxt = p->helptxt;
4193 }
4194
4195 set_user_gov_flag_name(p->id, flagname, helptxt);
4196}
4197
4198/************************************************************************/
4202{
4203 int j;
4204 struct terrain *pterrain = terrain_by_number(p->id);
4205
4206 fc_assert_ret_msg(pterrain != nullptr, "Bad terrain %d.", p->id);
4207
4208 pterrain->tclass = p->tclass;
4209 pterrain->native_to = p->native_to;
4210 names_set(&pterrain->name, nullptr, p->name, p->rule_name);
4211 sz_strlcpy(pterrain->graphic_str, p->graphic_str);
4212 sz_strlcpy(pterrain->graphic_alt, p->graphic_alt);
4213 sz_strlcpy(pterrain->graphic_alt2, p->graphic_alt2);
4214 pterrain->movement_cost = p->movement_cost;
4215 pterrain->defense_bonus = p->defense_bonus;
4216
4218 pterrain->output[o] = p->output[o];
4220
4221 if (pterrain->resources != nullptr) {
4222 free(pterrain->resources);
4223 }
4224 pterrain->resources = fc_calloc(p->num_resources + 1,
4225 sizeof(*pterrain->resources));
4226 if (pterrain->resource_freq != nullptr) {
4227 free(pterrain->resource_freq);
4228 }
4229 pterrain->resource_freq = fc_calloc(p->num_resources + 1,
4230 sizeof(*pterrain->resource_freq));
4231 for (j = 0; j < p->num_resources; j++) {
4232 pterrain->resources[j] = extra_by_number(p->resources[j]);
4233 if (!pterrain->resources[j]) {
4234 log_error("handle_ruleset_terrain() "
4235 "Mismatched resource %d for terrain \"%s\".",
4236 p->resources[j], terrain_rule_name(pterrain));
4237 }
4238 pterrain->resource_freq[j] = p->resource_freq[j];
4239 }
4240 pterrain->resources[p->num_resources] = nullptr;
4241 pterrain->resource_freq[p->num_resources] = 0;
4242
4246
4247 pterrain->base_time = p->base_time;
4248 pterrain->road_time = p->road_time;
4250 pterrain->cultivate_time = p->cultivate_time;
4252 pterrain->plant_time = p->plant_time;
4254 pterrain->irrigation_time = p->irrigation_time;
4256 pterrain->mining_time = p->mining_time;
4257
4258 pterrain->num_animals = p->num_animals;
4259 if (p->num_animals == 0) {
4260 pterrain->animals = nullptr;
4261 } else {
4262 pterrain->animals = fc_calloc(p->num_animals,
4263 sizeof(*pterrain->animals));
4264 for (j = 0; j < p->num_animals; j++) {
4265 pterrain->animals[j] = utype_by_number(p->animals[j]);
4266 }
4267 }
4268
4270 pterrain->transform_time = p->transform_time;
4271 pterrain->placing_time = p->placing_time;
4272 pterrain->pillage_time = p->pillage_time;
4273
4274 for (j = 0; j < p->extra_count; j++) {
4275 pterrain->extra_removal_times[j] = p->extra_removal_times[j];
4276 }
4277
4278 pterrain->flags = p->flags;
4279
4280 fc_assert_ret(pterrain->rgb == nullptr);
4281
4282 pterrain->rgb = rgbcolor_new(p->color_red, p->color_green, p->color_blue);
4283
4285
4287}
4288
4289/************************************************************************/
4293{
4294 const char *flagname;
4295 const char *helptxt;
4296
4298 "Bad user flag %d.", p->id);
4299
4300 if (p->name[0] == '\0') {
4301 flagname = nullptr;
4302 } else {
4303 flagname = p->name;
4304 }
4305
4306 if (p->helptxt[0] == '\0') {
4307 helptxt = nullptr;
4308 } else {
4309 helptxt = p->helptxt;
4310 }
4311
4313}
4314
4315/************************************************************************/
4319{
4320 struct resource_type *presource;
4321
4322 if (p->id < 0 || p->id > MAX_EXTRA_TYPES) {
4323 log_error("Bad resource %d.", p->id);
4324 return;
4325 }
4326
4327 presource = resource_type_init(extra_by_number(p->id));
4328
4330 presource->output[o] = p->output[o];
4332}
4333
4334/************************************************************************/
4338{
4339 struct extra_type *pextra = extra_by_number(p->id);
4340 int i;
4341 bool cbase;
4342 bool croad;
4343 bool cres;
4344
4345 fc_assert_ret_msg(pextra != nullptr, "Bad extra %d.", p->id);
4346
4347 names_set(&pextra->name, nullptr, p->name, p->rule_name);
4348
4349 pextra->category = p->category;
4350
4351 pextra->causes = 0;
4352 for (i = 0; i < EC_COUNT; i++) {
4353 if (BV_ISSET(p->causes, i)) {
4354 pextra->causes |= (1 << i);
4355 }
4356 }
4357
4358 pextra->rmcauses = 0;
4359 for (i = 0; i < ERM_COUNT; i++) {
4360 if (BV_ISSET(p->rmcauses, i)) {
4361 pextra->rmcauses |= (1 << i);
4362 }
4363 }
4364
4365 if (pextra->causes == 0) {
4367 } else {
4368 for (i = 0; i < EC_COUNT; i++) {
4369 if (is_extra_caused_by(pextra, i)) {
4370 extra_to_caused_by_list(pextra, i);
4371 }
4372 }
4373 }
4374
4375 cbase = is_extra_caused_by(pextra, EC_BASE);
4376 croad = is_extra_caused_by(pextra, EC_ROAD);
4378 if (cbase) {
4379 /* Index is one less than size of list when this base is already added. */
4381 }
4382 if (croad) {
4383 /* Index is one less than size of list when this road is already added. */
4385 }
4386 if (!cbase && !croad && !cres) {
4389 }
4390
4391 for (i = 0; i < ERM_COUNT; i++) {
4392 if (is_extra_removed_by(pextra, i)) {
4393 extra_to_removed_by_list(pextra, i);
4394 }
4395 }
4396
4398 sz_strlcpy(pextra->act_gfx_alt, p->act_gfx_alt);
4400 sz_strlcpy(pextra->rmact_gfx, p->rmact_gfx);
4403 sz_strlcpy(pextra->graphic_str, p->graphic_str);
4404 sz_strlcpy(pextra->graphic_alt, p->graphic_alt);
4405
4406 requirement_vector_copy(&pextra->reqs, &p->reqs);
4407 requirement_vector_copy(&pextra->rmreqs, &p->rmreqs);
4408
4411
4414
4415 pextra->visibility_req = p->visibility_req;
4416 pextra->buildable = p->buildable;
4417 pextra->generated = p->generated;
4418 pextra->build_time = p->build_time;
4420 pextra->removal_time = p->removal_time;
4422 pextra->infracost = p->infracost;
4423 pextra->defense_bonus = p->defense_bonus;
4424
4425 if (pextra->defense_bonus != 0) {
4426 if (extra_has_flag(pextra, EF_NATURAL_DEFENSE)) {
4428 } else {
4430 }
4431 }
4432
4434
4435 pextra->eus = p->eus;
4436 if (pextra->eus == EUS_HIDDEN) {
4438 }
4439
4440 pextra->native_to = p->native_to;
4441
4442 pextra->flags = p->flags;
4443 if (pextra->no_aggr_near_city >= 0) {
4445 }
4446 if (extra_has_flag(pextra, EF_CAUSE_ZOC)) {
4448 }
4449
4450 pextra->hidden_by = p->hidden_by;
4451 pextra->bridged_over = p->bridged_over;
4452 pextra->conflicts = p->conflicts;
4453
4455
4457}
4458
4459/************************************************************************/
4463{
4464 const char *flagname;
4465 const char *helptxt;
4466
4468 "Bad user flag %d.", p->id);
4469
4470 if (p->name[0] == '\0') {
4471 flagname = nullptr;
4472 } else {
4473 flagname = p->name;
4474 }
4475
4476 if (p->helptxt[0] == '\0') {
4477 helptxt = nullptr;
4478 } else {
4479 helptxt = p->helptxt;
4480 }
4481
4482 set_user_extra_flag_name(p->id, flagname, helptxt);
4483}
4484
4485/************************************************************************/
4489{
4490 struct base_type *pbase = base_by_number(p->id);
4491
4492 fc_assert_ret_msg(pbase != nullptr, "Bad base %d.", p->id);
4493
4494 pbase->gui_type = p->gui_type;
4495 pbase->border_sq = p->border_sq;
4496 pbase->vision_main_sq = p->vision_main_sq;
4497 pbase->vision_invis_sq = p->vision_invis_sq;
4498 pbase->vision_subs_sq = p->vision_subs_sq;
4499
4503 }
4504}
4505
4506/************************************************************************/
4510{
4511 struct road_type *proad = road_by_number(p->id);
4512
4513 fc_assert_ret_msg(proad != nullptr, "Bad road %d.", p->id);
4514
4515 proad->gui_type = p->gui_type;
4516
4517 requirement_vector_copy(&proad->first_reqs, &p->first_reqs);
4518
4519 proad->move_cost = p->move_cost;
4520 proad->move_mode = p->move_mode;
4521
4523 proad->tile_incr_const[o] = p->tile_incr_const[o];
4524 proad->tile_incr[o] = p->tile_incr[o];
4525 proad->tile_bonus[o] = p->tile_bonus[o];
4527
4528 proad->compat = p->compat;
4529 proad->integrates = p->integrates;
4530 proad->flags = p->flags;
4531}
4532
4533/************************************************************************/
4537{
4538 struct tiledef *td = tiledef_by_number(p->id);
4539
4540 fc_assert_ret_msg(td != nullptr, "Bad tiledef %d.", p->id);
4541
4542 names_set(&td->name, nullptr, p->name, p->rule_name);
4543
4544 extra_type_iterate(pextra) {
4545 if (BV_ISSET(p->extras, extra_index(pextra))) {
4546 extra_type_list_append(td->extras, pextra);
4547 }
4549}
4550
4551/************************************************************************/
4555{
4556 struct goods_type *pgood = goods_by_number(p->id);
4557
4558 fc_assert_ret_msg(pgood != nullptr, "Bad goods %d.", p->id);
4559
4560 names_set(&pgood->name, nullptr, p->name, p->rule_name);
4561
4562 requirement_vector_copy(&pgood->reqs, &p->reqs);
4563
4564 pgood->from_pct = p->from_pct;
4565 pgood->to_pct = p->to_pct;
4566 pgood->onetime_pct = p->onetime_pct;
4567 pgood->select_priority = p->select_priority;
4568 pgood->replace_priority = p->replace_priority;
4569 pgood->flags = p->flags;
4570
4571 PACKET_STRVEC_EXTRACT(pgood->helptext, p->helptext);
4572}
4573
4574/************************************************************************/
4578{
4579 struct action *act;
4580
4581 if (!action_id_exists(p->id)) {
4582 /* Action id out of range */
4583 log_error("handle_ruleset_action() the action id %d is out of range.",
4584 p->id);
4585
4586 return;
4587 }
4588
4589 act = action_by_number(p->id);
4590
4591 sz_strlcpy(act->ui_name, p->ui_name);
4592 act->quiet = p->quiet;
4593
4594 act->result = p->result;
4595 act->sub_results = p->sub_results;
4597
4598 act->actor_kind = p->act_kind;
4599 act->target_kind = p->tgt_kind;
4600 act->sub_target_kind = p->sub_tgt_kind;
4601
4602 act->min_distance = p->min_distance;
4603 act->max_distance = p->max_distance;
4604 act->blocked_by = p->blocked_by;
4605}
4606
4607/************************************************************************/
4610void
4612{
4613 struct action_enabler *enabler;
4614
4616 /* Non existing action */
4617 log_error("handle_ruleset_action_enabler() the action %d "
4618 "doesn't exist.",
4619 p->enabled_action);
4620
4621 return;
4622 }
4623
4625
4626 enabler->action = p->enabled_action;
4627
4628 requirement_vector_copy(&enabler->actor_reqs, &p->actor_reqs);
4629 requirement_vector_copy(&enabler->target_reqs, &p->target_reqs);
4630
4632}
4633
4634/************************************************************************/
4638{
4640 int i;
4641
4643
4644 auto_perf->cause = p->cause;
4645
4647
4648 for (i = 0; i < p->alternatives_count; i++) {
4649 auto_perf->alternatives[i] = p->alternatives[i];
4650 }
4651}
4652
4653/************************************************************************/
4657{
4659
4660 fc_assert_ret_msg(pdis != nullptr, "Bad disaster %d.", p->id);
4661
4662 names_set(&pdis->name, nullptr, p->name, p->rule_name);
4663
4664 requirement_vector_copy(&pdis->reqs, &p->reqs);
4665
4666 pdis->frequency = p->frequency;
4667
4668 pdis->effects = p->effects;
4669}
4670
4671/************************************************************************/
4675{
4677
4678 fc_assert_ret_msg(pach != nullptr, "Bad achievement %d.", p->id);
4679
4680 names_set(&pach->name, nullptr, p->name, p->rule_name);
4681
4682 pach->type = p->type;
4683 pach->unique = p->unique;
4684 pach->value = p->value;
4685}
4686
4687/************************************************************************/
4691{
4693
4694 if (pset != nullptr) {
4695 pset->trade_pct = p->trade_pct;
4696 pset->cancelling = p->cancelling;
4697 pset->bonus_type = p->bonus_type;
4698 }
4699}
4700
4701/************************************************************************/
4705 (const struct packet_ruleset_terrain_control *p)
4706{
4707 struct unit_type *access_unit = nullptr;
4708
4709 /* Since terrain_control is the same as packet_ruleset_terrain_control
4710 * we can just copy the data directly. */
4711 terrain_control = *p;
4712 /* terrain_control.move_fragments likely changed */
4714
4715 if (p->access_unit >= 0) {
4716 access_unit = utype_by_number(p->access_unit);
4717 }
4719 access_info_init(access_unit);
4720}
4721
4722/************************************************************************/
4726 (const struct packet_ruleset_nation_sets *packet)
4727{
4728 int i;
4729
4730 for (i = 0; i < packet->nsets; i++) {
4731 struct nation_set *pset =
4732 nation_set_new(packet->names[i], packet->rule_names[i],
4733 packet->descriptions[i]);
4734
4735 if (pset == nullptr) {
4736 break;
4737 } else {
4739 }
4740 }
4741}
4742
4743/************************************************************************/
4747 (const struct packet_ruleset_nation_groups *packet)
4748{
4749 int i;
4750
4751 for (i = 0; i < packet->ngroups; i++) {
4752 struct nation_group *pgroup;
4753
4754 pgroup = nation_group_new(packet->groups[i]);
4755
4756 if (pgroup != nullptr) {
4758 pgroup->hidden = packet->hidden[i];
4759 } else {
4760 break;
4761 }
4762 }
4763}
4764
4765/************************************************************************/
4769{
4770 struct nation_type *pnation = nation_by_number(packet->id);
4771 int i;
4772
4773 fc_assert_ret_msg(pnation != nullptr, "Bad nation %d.", packet->id);
4774
4775 if (packet->translation_domain[0] != '\0') {
4776 size_t len = strlen(packet->translation_domain) + 1;
4777 pnation->translation_domain = fc_malloc(len);
4779 } else {
4780 pnation->translation_domain = nullptr;
4781 }
4782 names_set(&pnation->adjective, pnation->translation_domain,
4783 packet->adjective, packet->rule_name);
4784 name_set(&pnation->noun_plural, pnation->translation_domain, packet->noun_plural);
4785 sz_strlcpy(pnation->flag_graphic_str, packet->graphic_str);
4786 sz_strlcpy(pnation->flag_graphic_alt, packet->graphic_alt);
4787 pnation->style = style_by_number(packet->style);
4788 for (i = 0; i < packet->leader_count; i++) {
4789 (void) nation_leader_new(pnation, packet->leader_name[i],
4790 packet->leader_is_male[i]);
4791 }
4792
4793 /* set later by PACKET_NATION_AVAILABILITY */
4794 pnation->client.is_pickable = FALSE;
4795 pnation->is_playable = packet->is_playable;
4796 pnation->barb_type = packet->barbarian_type;
4797
4798 if ('\0' != packet->legend[0]) {
4799 pnation->legend = fc_strdup(nation_legend_translation(pnation, packet->legend));
4800 } else {
4801 pnation->legend = fc_strdup("");
4802 }
4803
4804 for (i = 0; i < packet->nsets; i++) {
4805 struct nation_set *pset = nation_set_by_number(packet->sets[i]);
4806
4807 if (pset != nullptr) {
4808 nation_set_list_append(pnation->sets, pset);
4809 } else {
4810 log_error("handle_ruleset_nation() \"%s\" have unknown set %d.",
4811 nation_rule_name(pnation), packet->sets[i]);
4812 }
4813 }
4814
4815 for (i = 0; i < packet->ngroups; i++) {
4817
4818 if (pgroup != nullptr) {
4820 } else {
4821 log_error("handle_ruleset_nation() \"%s\" have unknown group %d.",
4822 nation_rule_name(pnation), packet->groups[i]);
4823 }
4824 }
4825
4826 /* init_government may be nullptr */
4828 for (i = 0; i < MAX_NUM_TECH_LIST; i++) {
4829 if (i < packet->init_techs_count) {
4830 pnation->init_techs[i] = packet->init_techs[i];
4831 } else {
4832 pnation->init_techs[i] = A_LAST;
4833 }
4834 }
4835 for (i = 0; i < MAX_NUM_UNIT_LIST; i++) {
4836 if (i < packet->init_units_count) {
4837 pnation->init_units[i] = utype_by_number(packet->init_units[i]);
4838 } else {
4839 /* TODO: should init_units be initialized in common/nation.c? */
4840 pnation->init_units[i] = utype_by_number(U_LAST);
4841 }
4842 }
4843 for (i = 0; i < MAX_NUM_BUILDING_LIST; i++) {
4844 if (i < packet->init_buildings_count) {
4845 pnation->init_buildings[i] = packet->init_buildings[i];
4846 } else {
4847 pnation->init_buildings[i] = B_LAST;
4848 }
4849 }
4850
4852}
4853
4854/************************************************************************/
4858void handle_nation_availability(int ncount, const bool *is_pickable,
4859 bool nationset_change)
4860{
4861 int i;
4862
4863 fc_assert_action(ncount == nation_count(),
4864 ncount = MIN(ncount, nation_count()));
4865
4866 for (i = 0; i < ncount; i++) {
4867 nation_by_number(i)->client.is_pickable = is_pickable[i];
4868 }
4869
4870 races_update_pickable(nationset_change);
4871}
4872
4873/************************************************************************/
4877{
4878 struct nation_style *pstyle = style_by_number(p->id);
4879
4880 fc_assert_ret_msg(pstyle != nullptr, "Bad style %d.", p->id);
4881
4882 names_set(&pstyle->name, nullptr, p->name, p->rule_name);
4883}
4884
4885/************************************************************************/
4889{
4890 struct clause_info *info = clause_info_get(p->type);
4891
4892 fc_assert_ret_msg(info != nullptr, "Bad clause %d.", p->type);
4893
4894 info->enabled = p->enabled;
4895
4899}
4900
4901/************************************************************************/
4905{
4906 int id;
4907 struct citystyle *cs;
4908
4909 id = packet->style_id;
4910
4912 "Bad citystyle %d.", id);
4913
4914 cs = &city_styles[id];
4915
4916 requirement_vector_copy(&cs->reqs, &packet->reqs);
4917 names_set(&cs->name, nullptr, packet->name, packet->rule_name);
4918 sz_strlcpy(cs->graphic, packet->graphic);
4919 sz_strlcpy(cs->graphic_alt, packet->graphic_alt);
4920 sz_strlcpy(cs->citizens_graphic, packet->citizens_graphic);
4921
4923}
4924
4925/************************************************************************/
4929{
4930 int id;
4931 struct music_style *pmus;
4932
4933 id = packet->id;
4935 "Bad music_style %d.", id);
4936
4938
4939 requirement_vector_copy(&pmus->reqs, &packet->reqs);
4940 sz_strlcpy(pmus->music_peaceful, packet->music_peaceful);
4941 sz_strlcpy(pmus->music_combat, packet->music_combat);
4942}
4943
4944/************************************************************************/
4948{
4949 int i;
4950
4951 /* Must set num_specialist_types before iterating over them. */
4953
4954 fc_assert_ret(packet->veteran_levels > 0);
4955
4957 game.veteran->levels = packet->veteran_levels;
4958
4959 for (i = 0; i < MAX_NUM_TECH_LIST; i++) {
4960 if (i < packet->global_init_techs_count) {
4962 } else {
4964 }
4965 }
4966 for (i = 0; i < MAX_NUM_BUILDING_LIST; i++) {
4967 if (i < packet->global_init_buildings_count) {
4969 } else {
4971 }
4972 }
4973
4974 for (i = 0; i < packet->veteran_levels; i++) {
4976 packet->power_fact[i], packet->move_bonus[i],
4977 packet->base_raise_chance[i],
4978 packet->work_raise_chance[i]);
4979 }
4980
4981 fc_assert(game.plr_bg_color == nullptr);
4982
4984 packet->background_green,
4985 packet->background_blue);
4986
4988}
4989
4990/************************************************************************/
4994{
4995 struct specialist *s = specialist_by_number(p->id);
4996
4997 fc_assert_ret_msg(s != nullptr, "Bad specialist %d.", p->id);
4998
4999 names_set(&s->name, nullptr, p->plural_name, p->rule_name);
5000 name_set(&s->abbreviation, nullptr, p->short_name);
5001
5006
5008}
5009
5010/************************************************************************/
5013void handle_city_name_suggestion_info(int unit_id, const char *name)
5014{
5015 struct unit *punit = player_unit_by_number(client_player(), unit_id);
5016
5017 if (!can_client_issue_orders()) {
5018 return;
5019 }
5020
5021 if (punit) {
5023 bool other_asking = FALSE;
5024
5026 if (other->client.asking_city_name) {
5028 }
5031
5032 if (!other_asking) {
5034 }
5035 } else {
5037 unit_id, tile_index(unit_tile(punit)),
5038 0, name);
5039 }
5040 }
5041}
5042
5043/************************************************************************/
5049void handle_unit_action_answer(int actor_id, int target_id, int cost,
5050 action_id action_type,
5051 int request_kind)
5052{
5053 struct city *pcity = game_city_by_number(target_id);
5054 struct unit *punit = game_unit_by_number(target_id);
5055 struct tile *ptile = index_to_tile(&(wld.map), target_id);
5056 struct unit *pactor = player_unit_by_number(client_player(), actor_id);
5057 struct action *paction = action_by_number(action_type);
5058
5059 if (ACTION_NONE != action_type
5060 && !action_id_exists(action_type)) {
5061 /* Non existing action */
5062 log_error("handle_unit_action_answer() the action %d doesn't exist.",
5063 action_type);
5064
5065 if (request_kind == REQEST_PLAYER_INITIATED) {
5069 }
5070
5071 return;
5072 }
5073
5074 if (!pactor) {
5075 log_debug("Bad actor %d.", actor_id);
5076
5077 if (request_kind == REQEST_PLAYER_INITIATED) {
5080 }
5081
5082 return;
5083 }
5084
5085 switch ((enum gen_action)action_type) {
5087 if (punit != nullptr && client.conn.playing
5089 if (request_kind == REQEST_PLAYER_INITIATED) {
5090 /* Focus on the unit so the player knows where it is */
5092
5094 } else {
5095 /* Not in use (yet). */
5096 log_error("Unimplemented: received background unit bribe cost.");
5097 }
5098 } else {
5099 log_debug("Bad target %d.", target_id);
5100 if (request_kind == REQEST_PLAYER_INITIATED) {
5104 }
5105 }
5106 break;
5108 if (ptile != nullptr && client.conn.playing
5110 if (request_kind == REQEST_PLAYER_INITIATED) {
5111 /* Focus on the unit so the player knows where it is */
5113
5115 } else {
5116 /* Not in use (yet). */
5117 log_error("Unimplemented: received background stack bribe cost.");
5118 }
5119 } else {
5120 log_debug("Bad target %d.", target_id);
5121 if (request_kind == REQEST_PLAYER_INITIATED) {
5125 }
5126 }
5127 break;
5130 if (pcity && client.conn.playing
5132 if (request_kind == REQEST_PLAYER_INITIATED) {
5133 /* Focus on the unit so the player knows where it is */
5135
5137 } else {
5138 /* Not in use (yet). */
5139 log_error("Unimplemented: received background city incite cost.");
5140 }
5141 } else {
5142 log_debug("Bad target %d.", target_id);
5143 if (request_kind == REQEST_PLAYER_INITIATED) {
5147 }
5148 }
5149 break;
5151 if (pcity && client.conn.playing
5153 /* TODO: The bundled clients will have to start showing the upgrade
5154 * price sent from the server before it can be allowed to rely on
5155 * things the player can't see. (Example: it becomes legal to upgrade
5156 * a unit in a foreign city.) */
5157
5158 /* Getting unit upgrade cost from the server is currently only used by
5159 * Freeciv-web. */
5160 log_error("Received upgrade unit price but can't forward it.");
5161 }
5162 break;
5163 case ACTION_NONE:
5164 log_debug("Server didn't respond to query.");
5165 if (request_kind == REQEST_PLAYER_INITIATED) {
5169 }
5170 break;
5171 default:
5172 log_error("handle_unit_action_answer() invalid action_type (%d).",
5173 action_type);
5174 if (request_kind == REQEST_PLAYER_INITIATED) {
5178 }
5179 break;
5180 };
5181}
5182
5183/************************************************************************/
5188{
5190
5192 if (action_prob_possible(act_probs[act_id])) {
5193 /* An attack. */
5194 if (attack_action == ACTION_NONE) {
5195 /* No previous attack action found. */
5196 attack_action = act_id;
5197 } else {
5198 /* More than one legal attack action found. */
5199 return ACTION_NONE;
5200 }
5201 }
5204 if (action_prob_possible(act_probs[act_id])) {
5205 /* An interesting non attack action has been found. */
5206 return ACTION_NONE;
5207 }
5209
5210 return attack_action;
5211}
5212
5213/**********************************************************************/
5218 const struct act_prob *act_probs,
5219 struct unit *target_unit,
5220 struct city *target_city,
5221 struct tile *target_tile)
5222{
5224
5225 fc_assert_ret(actor_unit != nullptr);
5226
5228
5229 if (auto_action != ACTION_NONE) {
5230 /* No interesting actions except a single attack action has been
5231 * found. The player wants it performed without questions. */
5232
5233 /* The order requests below doesn't send additional details. */
5235
5236 /* Give the order. */
5238 case ATK_TILE:
5239 case ATK_STACK:
5240 case ATK_EXTRAS:
5241 if (target_tile != nullptr) {
5244 0, "");
5245 }
5246 break;
5247 case ATK_CITY:
5248 if (target_city != nullptr) {
5251 0, "");
5252 }
5253 break;
5254 case ATK_UNIT:
5255 if (target_unit != nullptr) {
5258 0, "");
5259 }
5260 break;
5261 case ATK_SELF:
5264 0, "");
5265 break;
5266 case ATK_COUNT:
5268 break;
5269 }
5270
5271 /* Clean up. */
5273 } else {
5274 /* This should be done in the foreground */
5276 }
5277}
5278
5279/************************************************************************/
5286{
5288
5289 struct tile *target_tile = index_to_tile(&(wld.map), packet->target_tile_id);
5294
5295 const struct act_prob *act_probs = packet->action_probabilities;
5296
5297 int request_kind = packet->request_kind;
5298 bool valid = FALSE;
5299
5300 /* The dead can't act */
5302 /* At least one action must be possible */
5303 action_iterate(act) {
5304 if (action_prob_possible(act_probs[act])) {
5305 valid = TRUE;
5306 break;
5307 }
5309 }
5310
5311 switch (request_kind) {
5313 if (valid) {
5314 /* The player can select an action and should be informed. */
5315
5316 /* Show the client specific action dialog */
5320 act_probs);
5321 } else {
5322 /* Nothing to do. */
5326 }
5327 break;
5329 /* This was a background action selection dialog refresh. */
5330
5331 if (actor_unit != nullptr
5333 /* The situation may have changed. */
5337 act_probs);
5338 }
5339 break;
5341 if (actor_unit != nullptr) {
5344 }
5345 break;
5346 default:
5347 log_warn("Unknown request_kind %d in reply", request_kind);
5348 break;
5349 }
5350}
5351
5352/************************************************************************/
5355void handle_city_sabotage_list(int actor_id, int city_id,
5356 bv_imprs improvements,
5357 action_id act_id,
5358 int request_kind)
5359{
5360 struct city *pcity = game_city_by_number(city_id);
5361 struct unit *pactor = player_unit_by_number(client_player(), actor_id);
5362 struct action *paction = action_by_number(act_id);
5363
5364 if (!pactor) {
5365 log_debug("Bad diplomat %d.", actor_id);
5366
5367 if (request_kind == REQEST_PLAYER_INITIATED) {
5370 }
5371
5372 return;
5373 }
5374
5375 if (!pcity) {
5376 log_debug("Bad city %d.", city_id);
5377
5378 if (request_kind == REQEST_PLAYER_INITIATED) {
5382 }
5383
5384 return;
5385 }
5386
5388 improvement_iterate(pimprove) {
5390 BV_ISSET(improvements,
5391 improvement_index(pimprove)));
5393
5394 if (request_kind == REQEST_PLAYER_INITIATED) {
5395 /* Focus on the unit so the player knows where it is */
5397
5399 } else {
5400 /* Not in use (yet). */
5401 log_error("Unimplemented: received background city building list.");
5402 }
5403 } else {
5404 log_debug("Can't issue orders");
5405 if (request_kind == REQEST_PLAYER_INITIATED) {
5408 }
5409 }
5410}
5411
5412/************************************************************************/
5421
5422/************************************************************************/
5426{
5427 if (client_has_player()
5428 && packet->player_id == player_number(client_player())) {
5429 if (packet->winner) {
5430 start_menu_music("music_victory", nullptr);
5431 } else {
5432 start_menu_music("music_defeat", nullptr);
5433 }
5434 }
5436}
5437
5438/************************************************************************/
5442 (const struct packet_player_attribute_chunk *packet)
5443{
5444 if (!client_has_player()) {
5445 return;
5446 }
5447
5449
5450 if (packet->offset + packet->chunk_length == packet->total_length) {
5451 /* We successful received the last chunk. The attribute block is
5452 now complete. */
5454 }
5455}
5456
5457/************************************************************************/
5461{
5463
5467 client.last_processed_request_id_seen);
5469 request_id_of_currently_handled_packet);
5470
5471 log_debug("start processing packet %d",
5473}
5474
5475/************************************************************************/
5494
5495/************************************************************************/
5499 int packet_type, int size)
5500{
5501 fc_assert(pc == &client.conn);
5502 log_debug("incoming packet={type=%d, size=%d}", packet_type, size);
5503}
5504
5505/************************************************************************/
5509 int packet_type, int size,
5510 int request_id)
5511{
5512 fc_assert(pc == &client.conn);
5513 log_debug("outgoing packet={type=%d, size=%d, request_id=%d}",
5515
5517}
5518
5519/************************************************************************/
5523{
5524 log_debug("handle_freeze_client");
5525
5527}
5528
5529/************************************************************************/
5533{
5534 log_debug("handle_thaw_client");
5535
5538}
5539
5540/************************************************************************/
5544{
5546}
5547
5548/************************************************************************/
5552{
5553 log_verbose("server shutdown");
5554}
5555
5556/************************************************************************/
5560{
5561 recv_ruleset_effect(packet);
5562}
5563
5564/************************************************************************/
5570void handle_edit_object_created(int tag, int id)
5571{
5573}
5574
5575/************************************************************************/
5579{
5580 struct tile *ptile = index_to_tile(&(wld.map), packet->id);
5581 bool changed = FALSE;
5582
5583 /* Check. */
5584 if (ptile == nullptr) {
5585 log_error("%s(): invalid tile index %d.", __FUNCTION__, packet->id);
5586 return;
5587 }
5588
5589 /* Handle. */
5590 if (packet->removal) {
5591 changed = map_startpos_remove(ptile);
5592 } else {
5593 if (map_startpos_get(ptile) != nullptr) {
5594 changed = FALSE;
5595 } else {
5596 map_startpos_new(ptile);
5597 changed = TRUE;
5598 }
5599 }
5600
5601 /* Notify. */
5602 if (changed && can_client_change_view()) {
5604 if (packet->removal) {
5606 packet->id, TRUE);
5607 } else {
5608 editgui_notify_object_created(packet->tag, packet->id);
5609 }
5610 }
5611}
5612
5613/************************************************************************/
5617 packet)
5618{
5619 struct tile *ptile = index_to_tile(&(wld.map), packet->id);
5620 struct startpos *psp;
5621
5622 /* Check. */
5623 if (ptile == nullptr) {
5624 log_error("%s(): invalid tile index %d.", __FUNCTION__, packet->id);
5625 return;
5626 }
5627
5628 psp = map_startpos_get(ptile);
5629 if (psp == nullptr) {
5630 log_error("%s(): no start position at (%d, %d)",
5631 __FUNCTION__, TILE_XY(ptile));
5632 return;
5633 }
5634
5635 /* Handle. */
5636 if (startpos_unpack(psp, packet) && can_client_change_view()) {
5637 /* Notify. */
5640 FALSE);
5641 }
5642}
5643
5644/************************************************************************/
5648{
5649 game.client.fog_of_war = enabled;
5650
5651 menus_update();
5652}
5653
5654/************************************************************************/
5657void handle_vote_remove(int vote_no)
5658{
5661}
5662
5663/************************************************************************/
5666void handle_vote_update(int vote_no, int yes, int no, int abstain,
5667 int num_voters)
5668{
5669 struct voteinfo *vi;
5670
5672
5673 fc_assert_ret_msg(vi != nullptr,
5674 "Got packet_vote_update for non-existent vote %d!",
5675 vote_no);
5676
5677 vi->yes = yes;
5678 vi->no = no;
5679 vi->abstain = abstain;
5680 vi->num_voters = num_voters;
5681
5683}
5684
5685/************************************************************************/
5688void handle_vote_new(const struct packet_vote_new *packet)
5689{
5690 fc_assert_ret_msg(voteinfo_queue_find(packet->vote_no) == nullptr,
5691 "Got a packet_vote_new for already existing "
5692 "vote %d!", packet->vote_no);
5693
5695 packet->user,
5696 packet->desc,
5697 packet->percent_required,
5698 packet->flags);
5700}
5701
5702/************************************************************************/
5706{
5707 struct voteinfo *vi;
5708
5710
5711 fc_assert_ret_msg(vi != nullptr,
5712 "Got packet_vote_resolve for non-existent vote %d!",
5713 vote_no);
5714
5715 vi->resolved = TRUE;
5716 vi->passed = passed;
5717
5719}
5720
5721/************************************************************************/
5724void handle_play_music(const char *tag)
5725{
5726 play_single_track(tag);
5727}
5728
5729/************************************************************************/
5732void handle_popup_image(const char *tag)
5733{
5734 popup_image(tag);
5735}
5736
5737/************************************************************************/
5740void handle_diplomacy_init_meeting(int counterpart, int initiated_from)
5741{
5742 client_init_meeting(counterpart, initiated_from);
5743}
5744
5745/************************************************************************/
5748void handle_diplomacy_accept_treaty(int counterpart, bool I_accepted,
5749 bool other_accepted)
5750{
5751 client_recv_accept_treaty(counterpart, I_accepted, other_accepted);
5752}
5753
5754/************************************************************************/
5757void handle_diplomacy_cancel_meeting(int counterpart, int initiated_from)
5758{
5759 client_recv_cancel_meeting(counterpart, initiated_from);
5760}
5761
5762/************************************************************************/
5765void handle_diplomacy_create_clause(int counterpart, int giver,
5766 enum clause_type type, int value)
5767{
5768 client_recv_create_clause(counterpart, giver, type, value);
5769}
5770
5771/************************************************************************/
5774void handle_diplomacy_remove_clause(int counterpart, int giver,
5775 enum clause_type type, int value)
5776{
5777 client_recv_remove_clause(counterpart, giver, type, value);
5778}
5779
5780/**********************************************************************/
5785{
5788
5789 names_set(&curr->name, nullptr, packet->name, packet->rule_name);
5790 curr->checkpoint = packet->checkpoint;
5791 curr->type = packet->behavior;
5792 curr->target = packet->type;
5793 curr->def = packet->def;
5794
5796 || curr->target != CTGT_CITY) {
5797 return;
5798 }
5799
5800 PACKET_STRVEC_EXTRACT(curr->helptext, packet->helptext);
5802}
5803
5804/**********************************************************************/
5808{
5809 int i;
5810 int counters_count;
5811 struct city *pcity = game_city_by_number(packet->city);
5812
5813 if (pcity == nullptr) {
5814 return;
5815 }
5816
5818 if (counters_count != packet->count) {
5819 return;
5820 }
5821
5822 for (i = 0; i < counters_count; i++) {
5823 pcity->counter_values[i] = packet->counters[i];
5824 }
5825
5826 if (pcity->tile != nullptr) {
5827 /* City's location known */
5829 }
5830
5832}
5833
5834/**********************************************************************/
5838{
5839 options_sync_reply(serial);
5840}
5841
5842/**********************************************************************/
5845void handle_access_area(const struct packet_access_area *packet)
5846{
5847 struct player *plr = player_by_number(packet->player);
5848 struct aarea_list *alist;
5849 struct access_area *aarea;
5850
5851 if (plr == nullptr) {
5852 log_warn("handle_access_area() received illegal player");
5853 return;
5854 }
5855
5856 if (packet->index == 0) {
5857 /* First access area packet. Clear old set. */
5858
5859 /* Make sure no city refers to the old set. */
5861 pcity->aarea = nullptr;
5863
5865
5868 } else {
5870 }
5871
5872 aarea = fc_malloc(sizeof(struct access_area));
5873
5874 aarea->cities = city_list_new();
5875 aarea->index = packet->index;
5876 aarea->capital = packet->capital;
5877 aarea->tiledefs = packet->tiledefs;
5878
5879 aarea_list_append(alist, aarea);
5880}
5881
5882/**********************************************************************/
5886{
5887 struct city *pcity = game_city_by_number(packet->city);
5888 struct player *plr;
5889 struct aarea_list *alist;
5890
5891 if (pcity == nullptr) {
5892 log_warn("handle_city_access_area() received illegal city");
5893 return;
5894 }
5895
5896 plr = city_owner(pcity);
5897
5898 /* Currently we support only packets about our own cities. */
5899 fc_assert(plr == client_player());
5900
5902 aarea_list_iterate(alist, aarea) {
5903 if (aarea->index == packet->aarea) {
5904 fc_assert(pcity->aarea == nullptr);
5905
5906 pcity->aarea = aarea;
5907 city_list_append(aarea->cities, pcity);
5908 break;
5909 }
5911}
void area_list_for_player_set(struct player *pplayer, struct aarea_list *alist)
Definition accessarea.c:112
void access_info_init(const struct unit_type *aunit)
Definition accessarea.c:39
struct aarea_list * area_list_for_player(struct player *pplayer)
Definition accessarea.c:103
void access_info_close(void)
Definition accessarea.c:55
void area_list_clear_plr(struct player *pplayer)
Definition accessarea.c:94
#define aarea_list_iterate_end
Definition accessarea.h:31
#define aarea_list_iterate(aarealist, parea)
Definition accessarea.h:29
struct achievement * achievement_by_number(int id)
struct action_auto_perf * action_auto_perf_slot_number(const int num)
Definition actions.c:5956
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:5317
void actions_rs_pre_san_gen(void)
Definition actions.c:899
void action_enabler_add(struct action_enabler *enabler)
Definition actions.c:1547
struct action_enabler * action_enabler_new(void)
Definition actions.c:1496
bool action_id_exists(const action_id act_id)
Definition actions.c:1089
static struct action * action_by_number(action_id act_id)
Definition actions.h:400
#define action_array_iterate(_act_array_, _act_id_)
Definition actions.h:261
#define action_id_requires_details(act_id)
Definition actions.h:438
#define action_array_iterate_end
Definition actions.h:273
#define action_iterate_end
Definition actions.h:218
#define action_iterate(_act_)
Definition actions.h:214
#define action_id_get_target_kind(act_id)
Definition actions.h:417
#define ACTION_NONE
Definition actions.h:59
void agents_unit_changed(struct unit *punit)
Definition agents.c:512
void agents_city_remove(struct city *pcity)
Definition agents.c:641
void agents_thaw_hint(void)
Definition agents.c:441
void agents_tile_remove(struct tile *ptile)
Definition agents.c:668
void agents_city_new(struct city *pcity)
Definition agents.c:615
void agents_start_turn(void)
Definition agents.c:475
void agents_tile_changed(struct tile *ptile)
Definition agents.c:692
void agents_unit_new(struct unit *punit)
Definition agents.c:537
void agents_unit_remove(struct unit *punit)
Definition agents.c:563
void agents_processing_started(void)
Definition agents.c:414
void agents_tile_new(struct tile *ptile)
Definition agents.c:716
void agents_processing_finished(void)
Definition agents.c:423
void agents_new_turn(void)
Definition agents.c:484
void agents_city_changed(struct city *pcity)
Definition agents.c:589
void agents_game_joined(void)
Definition agents.c:450
void agents_freeze_hint(void)
Definition agents.c:432
void agents_before_new_turn(void)
Definition agents.c:467
void attribute_restore(void)
Definition attribute.c:361
void audio_restart(const char *soundset_name, const char *musicset_name)
Definition audio.c:378
void audio_play_sound(const char *const tag, const char *const alt_tag, const char *const alt_tag2)
Definition audio.c:531
void base_type_init(struct extra_type *pextra, int idx)
Definition base.c:122
struct extra_type * base_extra_get(const struct base_type *pbase)
Definition base.c:106
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:163
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:1201
void city_styles_alloc(int num)
Definition city.c:3508
const char * city_name_get(const struct city *pcity)
Definition city.c:1157
void city_production_caravan_shields_init(void)
Definition city.c:1835
void city_remove_improvement(struct city *pcity, const struct impr_type *pimprove)
Definition city.c:3483
void city_size_add(struct city *pcity, int add)
Definition city.c:1220
void free_city_map_index(void)
Definition city.c:609
bool city_unhappy(const struct city *pcity)
Definition city.c:1683
struct city * create_city_virtual(struct player *pplayer, struct tile *ptile, const char *name)
Definition city.c:3542
bool city_happy(const struct city *pcity)
Definition city.c:1671
void city_size_set(struct city *pcity, citizens size)
Definition city.c:1236
void city_add_improvement(struct city *pcity, const struct impr_type *pimprove)
Definition city.c:3469
int city_map_radius_sq_get(const struct city *pcity)
Definition city.c:137
void destroy_city_virtual(struct city *pcity)
Definition city.c:3632
void city_rally_point_receive(const struct packet_city_rally_point *packet, struct city *pcity)
Definition city.c:3762
static const struct city struct citystyle * city_styles
Definition city.c:84
#define city_list_iterate(citylist, pcity)
Definition city.h:508
#define city_tile(_pcity_)
Definition city.h:565
static citizens city_size_get(const struct city *pcity)
Definition city.h:570
#define city_tile_iterate_skip_free_worked(_nmap, _radius_sq, _city_tile, _tile, _index, _x, _y)
Definition city.h:212
@ CITIZEN_LAST
Definition city.h:270
@ CITIZEN_ANGRY
Definition city.h:269
@ CITIZEN_HAPPY
Definition city.h:266
@ CITIZEN_CONTENT
Definition city.h:267
@ CITIZEN_UNHAPPY
Definition city.h:268
#define output_type_iterate(output)
Definition city.h:853
#define city_owner(_pcity_)
Definition city.h:564
#define city_tile_iterate_skip_free_worked_end
Definition city.h:220
#define city_list_iterate_end
Definition city.h:510
#define I_NEVER
Definition city.h:245
@ FEELING_FINAL
Definition city.h:282
@ FEELING_LAST
Definition city.h:283
#define output_type_iterate_end
Definition city.h:859
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:1098
void client_player_init(struct player *pplayer)
Definition climisc.c:1378
void client_remove_city(struct city *pcity)
Definition climisc.c:134
void client_player_maps_reset(void)
Definition climisc.c:1389
void client_remove_unit(struct unit *punit)
Definition climisc.c:72
void unit_focus_set_status(struct player *pplayer)
Definition climisc.c:1368
void handle_event(const char *featured_text, struct tile *ptile, enum event_type event, int turn, int phase, int conn_id)
Definition climisc.c:973
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:77
void send_client_wants_hack(const char *filename)
int get_next_request_id(int old_request_id)
Definition connection.c:532
void conn_set_capability(struct connection *pconn, const char *capability)
Definition connection.c:663
struct connection * conn_by_number(int id)
Definition connection.c:423
#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:2814
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:1063
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:1122
void set_units_in_combat(struct unit *pattacker, struct unit *pdefender)
Definition control.c:1044
void clear_hover_state(void)
Definition control.c:328
void unit_focus_set(struct unit *punit)
Definition control.c:518
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:1742
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:1092
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:801
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:1941
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1104
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:72
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:76
struct unit struct city struct unit * target_unit
Definition dialogs_g.h:55
popup_action_selection
Definition dialogs_g.h:54
struct unit * actor_unit
Definition dialogs_g.h:54
const char * caption
Definition dialogs_g.h:36
const char const char * headline
Definition dialogs_g.h:37
popup_notify_dialog
Definition dialogs_g.h:36
struct unit struct city struct unit struct tile * target_tile
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 * punit
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 struct unit struct city * pcity
Definition dialogs_g.h:77
struct unit struct city * target_city
Definition dialogs_g.h:55
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile struct extra_type * target_extra
Definition dialogs_g.h:56
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:82
const char * get_event_tag(enum event_type event)
Definition events.c:277
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:74
#define MAX_NUM_BUILDING_LIST
Definition fc_types.h:46
int Tech_type_id
Definition fc_types.h:238
#define EC_NATURAL_DEFENSIVE
Definition fc_types.h:811
#define EC_SPECIAL
Definition fc_types.h:809
int action_id
Definition fc_types.h:250
#define SP_MAX
Definition fc_types.h:269
#define EC_NONE
Definition fc_types.h:808
#define EC_NOT_AGGRESSIVE
Definition fc_types.h:812
#define EC_DEFENSIVE
Definition fc_types.h:810
#define IF_LAST_USER_FLAG
Definition fc_types.h:492
#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:128
#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:103
@ O_FOOD
Definition fc_types.h:103
@ O_SCIENCE
Definition fc_types.h:103
@ O_GOLD
Definition fc_types.h:103
#define MAX_LEN_CITYNAME
Definition fc_types.h:69
signed short Continent_id
Definition fc_types.h:233
#define MAX_COUNTERS
Definition fc_types.h:108
#define UCL_LAST
Definition fc_types.h:276
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:94
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_client
struct civ_game game
Definition game.c:62
void game_ruleset_init(void)
Definition game.c:517
bool is_player_phase(const struct player *pplayer, int phase)
Definition game.c:716
int current_turn_timeout(void)
Definition game.c:858
void game_ruleset_free(void)
Definition game.c:568
struct world wld
Definition game.c:63
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:322
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:115
void governments_alloc(int num)
Definition government.c:525
Government_type_id government_number(const struct government *pgovern)
Definition government.c:92
void set_user_gov_flag_name(enum gov_flag_id id, const char *name, const char *helptxt)
Definition government.c:614
#define GOVF_LAST_USER_FLAG
Definition government.h:28
int action_selection_target_extra(void)
int action_selection_target_tile(void)
int action_selection_actor_unit(void)
void popup_bribe_stack_dialog(struct unit *actor, struct tile *ptile, int cost, const struct action *paction)
void action_selection_close(void)
int action_selection_target_city(void)
void action_selection_refresh(struct unit *actor_unit, struct city *target_city, struct unit *target_unit, struct tile *target_tile, struct extra_type *target_extra, const struct act_prob *act_probs)
int action_selection_target_unit(void)
void popup_incite_dialog(struct unit *actor, struct city *pcity, int cost, const struct action *paction)
bool city_dialog_is_open(struct city *pcity)
Definition citydlg.c:587
void popdown_all_city_dialogs(void)
Definition citydlg.c:607
void refresh_unit_city_dialogs(struct unit *punit)
Definition citydlg.c:546
struct city * owner
Definition citydlg.c:226
void server_connect(void)
Definition connectdlg.c:60
void close_connection_dialog(void)
Definition connectdlg.c:52
void races_update_pickable(bool nationset_change)
Definition dialogs.c:731
void show_tech_gained_dialog(Tech_type_id tech)
Definition dialogs.c:1524
void popdown_races_dialog(void)
Definition dialogs.c:1230
void popup_connect_msg(const char *headline, const char *message)
Definition dialogs.c:239
bool handmade_scenario_warning(void)
Definition dialogs.c:1573
void races_toggles_set_sensitive(void)
Definition dialogs.c:1245
void popup_combat_info(int attacker_unit_id, int defender_unit_id, int attacker_hp, int defender_hp, bool make_att_veteran, bool make_def_veteran)
Definition dialogs.c:1583
void popup_image(const char *tag)
Definition dialogs.c:1636
void editgui_notify_object_created(int tag, int id)
Definition editgui.c:1924
void editgui_refresh(void)
Definition editgui.c:1798
static GtkWidget * source
Definition gotodlg.c:58
enum gui_type get_gui_type(void)
Definition gui_main.c:2046
void update_infra_dialog(void)
Definition infradlg.c:138
void close_intel_dialog(struct player *p)
Definition inteldlg.c:223
void update_intel_dialog(struct player *p)
Definition inteldlg.c:462
void popup_newcity_dialog(struct unit *punit, const char *suggestname)
Definition mapctrl.c:197
void update_info_label(void)
Definition mapview.c:138
void start_turn(void)
Definition mapview.c:805
void update_unit_info_label(struct unit_list *punits)
Definition mapview.c:275
void update_city_descriptions(void)
Definition mapview.c:488
void update_start_page(void)
Definition pages.c:1675
void science_report_dialog_popup(bool raise)
Definition repodlgs.c:716
void endgame_report_dialog_start(const struct packet_endgame_report *packet)
Definition repodlgs.c:1983
GType type
Definition repodlgs.c:1313
void science_report_dialog_redraw(void)
Definition repodlgs.c:761
void popup_musicset_suggestion_dialog(void)
void popup_soundset_suggestion_dialog(void)
void refresh_spaceship_dialog(struct player *pplayer)
void popup_tileset_suggestion_dialog(void)
Definition tileset_dlg.c:58
void voteinfo_gui_update(void)
void conn_list_dialog_update(void)
void boot_help_texts(void)
Definition helpdata.c:768
void idex_register_unit(struct world *iworld, struct unit *punit)
Definition idex.c:82
void idex_unregister_city(struct world *iworld, struct city *pcity)
Definition idex.c:97
void idex_register_city(struct world *iworld, struct city *pcity)
Definition idex.c:67
struct impr_type * improvement_by_number(const Impr_type_id id)
const char * improvement_rule_name(const struct impr_type *pimprove)
bool is_improvement_visible(const struct impr_type *pimprove)
Impr_type_id improvement_index(const struct impr_type *pimprove)
void improvement_feature_cache_init(void)
Definition improvement.c:92
void set_user_impr_flag_name(enum impr_flag_id id, const char *name, const char *helptxt)
Impr_type_id improvement_count(void)
#define improvement_iterate_end
#define improvement_iterate(_p)
#define B_LAST
Definition improvement.h:42
const char * name
Definition inputfile.c:127
#define fc_assert_msg(condition, message,...)
Definition log.h:182
#define fc_assert_ret(condition)
Definition log.h:192
#define log_packet
Definition log.h:138
#define log_warn(message,...)
Definition log.h:106
#define log_verbose(message,...)
Definition log.h:110
#define fc_assert(condition)
Definition log.h:177
#define fc_assert_ret_msg(condition, message,...)
Definition log.h:206
#define fc_assert_ret_val(condition, val)
Definition log.h:195
#define fc_assert_action(condition, action)
Definition log.h:188
#define log_debug(message,...)
Definition log.h:116
#define log_normal(message,...)
Definition log.h:108
@ LOG_NORMAL
Definition log.h:33
#define log_error(message,...)
Definition log.h:104
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
struct startpos * map_startpos_get(const struct tile *ptile)
Definition map.c:2047
int startpos_number(const struct startpos *psp)
Definition map.c:1785
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:2030
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:2063
bool same_pos(const struct tile *tile1, const struct tile *tile2)
Definition map.c:1085
bool startpos_unpack(struct startpos *psp, const struct packet_edit_startpos_full *packet)
Definition map.c:1884
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:439
#define adjc_iterate(nmap, center_tile, itr_tile)
Definition map.h:434
#define whole_map_iterate(_map, _tile)
Definition map.h:582
#define whole_map_iterate_end
Definition map.h:591
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:978
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:937
Nation_type_id nation_count(void)
Definition nation.c:503
struct nation_group * nation_group_new(const char *name)
Definition nation.c:953
struct nation_type * nation_of_unit(const struct unit *punit)
Definition nation.c:461
struct nation_set * nation_set_new(const char *set_name, const char *set_rule_name, const char *set_description)
Definition nation.c:714
struct nation_type * nation_by_number(const Nation_type_id nation)
Definition nation.c:472
int nation_set_index(const struct nation_set *pset)
Definition nation.c:698
struct nation_type * nation_of_city(const struct city *pcity)
Definition nation.c:453
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:999
struct nation_leader * nation_leader_new(struct nation_type *pnation, const char *name, bool is_male)
Definition nation.c:241
void nations_alloc(int num)
Definition nation.c:620
const char * nation_legend_translation(const struct nation_type *pnation, const char *legend)
Definition nation.c:303
void resend_desired_settable_options(void)
Definition options.c:6103
const char * tileset_name_for_topology(int topology_id)
Definition options.c:6910
void options_sync_reply(int serial)
Definition options.c:6458
struct client_options gui_options
Definition options.c:71
void calculate_overview_dimensions(void)
void generic_handle_player_attribute_chunk(struct player *pplayer, const struct packet_player_attribute_chunk *chunk)
Definition packets.c:697
#define PACKET_STRVEC_EXTRACT(dest, src)
Definition packets.h:193
#define REQEST_PLAYER_INITIATED
Definition packets.h:63
@ UNIT_INFO_CITY_PRESENT
Definition packets.h:69
@ UNIT_INFO_CITY_SUPPORTED
Definition packets.h:68
void handle_access_area(const struct packet_access_area *packet)
Definition packhand.c:5845
void handle_ruleset_game(const struct packet_ruleset_game *packet)
Definition packhand.c:4947
void handle_player_diplstate(const struct packet_player_diplstate *packet)
Definition packhand.c:2824
static action_id auto_attack_act(const struct act_prob *act_probs)
Definition packhand.c:5187
void handle_ruleset_nation_sets(const struct packet_ruleset_nation_sets *packet)
Definition packhand.c:4726
void handle_ruleset_nation(const struct packet_ruleset_nation *packet)
Definition packhand.c:4768
void handle_city_name_suggestion_info(int unit_id, const char *name)
Definition packhand.c:5013
void handle_sync_serial_reply(int serial)
Definition packhand.c:5837
static struct unit * unpackage_short_unit(const struct packet_unit_short_info *packet)
Definition packhand.c:365
void handle_nuke_tile_info(int tile)
Definition packhand.c:555
void handle_unknown_research(int id)
Definition packhand.c:2794
const action_id auto_attack_blockers[]
Definition packhand.c:164
void handle_ruleset_government_ruler_title(const struct packet_ruleset_government_ruler_title *packet)
Definition packhand.c:4161
void handle_city_info(const struct packet_city_info *packet)
Definition packhand.c:661
void handle_end_turn(void)
Definition packhand.c:1510
static struct unit * unpackage_unit(const struct packet_unit_info *packet)
Definition packhand.c:266
char * caption
Definition packhand.c:131
enum event_type event
Definition packhand.c:130
void handle_conn_info(const struct packet_conn_info *pinfo)
Definition packhand.c:2927
void handle_vote_remove(int vote_no)
Definition packhand.c:5657
void handle_investigate_finished(const struct packet_investigate_finished *packet)
Definition packhand.c:2177
void handle_page_msg_part(const char *lines)
Definition packhand.c:1640
void handle_unit_combat_info(const struct packet_unit_combat_info *packet)
Definition packhand.c:579
void handle_ruleset_style(const struct packet_ruleset_style *p)
Definition packhand.c:4876
void handle_unit_remove(int unit_id)
Definition packhand.c:501
void handle_vote_update(int vote_no, int yes, int no, int abstain, int num_voters)
Definition packhand.c:5666
static int last_turn
Definition packhand.c:139
void handle_city_access_area(const struct packet_city_access_area *packet)
Definition packhand.c:5885
void handle_ruleset_multiplier(const struct packet_ruleset_multiplier *p)
Definition packhand.c:4113
void handle_player_info(const struct packet_player_info *pinfo)
Definition packhand.c:2471
void handle_ruleset_extra(const struct packet_ruleset_extra *p)
Definition packhand.c:4337
void handle_ruleset_action_auto(const struct packet_ruleset_action_auto *p)
Definition packhand.c:4637
void handle_map_info(const struct packet_map_info *packet)
Definition packhand.c:2258
void handle_ruleset_unit_bonus(const struct packet_ruleset_unit_bonus *p)
Definition packhand.c:3828
void handle_start_phase(int phase)
Definition packhand.c:1437
void start_revolution(void)
Definition packhand.c:2415
void handle_timeout_info(float seconds_to_phasedone, float last_turn_change_time)
Definition packhand.c:2384
void handle_ruleset_terrain_control(const struct packet_ruleset_terrain_control *p)
Definition packhand.c:4705
const action_id auto_attack_actions[]
Definition packhand.c:147
void handle_play_music(const char *tag)
Definition packhand.c:5724
static void update_continent_cache(const struct tile *ptile, Continent_id old_cont, Continent_id new_cont)
Definition packhand.c:3178
void handle_investigate_started(const struct packet_investigate_started *packet)
Definition packhand.c:2152
void handle_edit_object_created(int tag, int id)
Definition packhand.c:5570
int parts
Definition packhand.c:134
void handle_conn_ping(void)
Definition packhand.c:5543
static int unpack_tech_req(const enum tech_req r_num, const struct requirement_vector *reqs, struct advance *a, int i)
Definition packhand.c:3904
void handle_ruleset_tech_class(const struct packet_ruleset_tech_class *p)
Definition packhand.c:4004
void handle_diplomacy_init_meeting(int counterpart, int initiated_from)
Definition packhand.c:5740
void handle_ruleset_control(const struct packet_ruleset_control *packet)
Definition packhand.c:3560
void handle_end_phase(void)
Definition packhand.c:1426
void handle_ruleset_gov_flag(const struct packet_ruleset_gov_flag *p)
Definition packhand.c:4175
void handle_ruleset_counter(const struct packet_ruleset_counter *packet)
Definition packhand.c:5784
void handle_server_info(const char *version_label, int major_version, int minor_version, int patch_version, int emerg_version)
Definition packhand.c:1593
void handle_ruleset_nation_groups(const struct packet_ruleset_nation_groups *packet)
Definition packhand.c:4747
void handle_ruleset_effect(const struct packet_ruleset_effect *packet)
Definition packhand.c:5559
void handle_new_year(int year, int fragments, int turn)
Definition packhand.c:1377
char * headline
Definition packhand.c:132
void handle_research_info(const struct packet_research_info *packet)
Definition packhand.c:2708
void handle_ruleset_goods(const struct packet_ruleset_goods *p)
Definition packhand.c:4554
void handle_unit_info(const struct packet_unit_info *packet)
Definition packhand.c:1666
void handle_ruleset_city(const struct packet_ruleset_city *packet)
Definition packhand.c:4904
void handle_ruleset_unit_class(const struct packet_ruleset_unit_class *p)
Definition packhand.c:3738
void handle_ruleset_government(const struct packet_ruleset_government *p)
Definition packhand.c:4135
void handle_ruleset_terrain_flag(const struct packet_ruleset_terrain_flag *p)
Definition packhand.c:4292
void handle_connect_msg(const char *message)
Definition packhand.c:1584
#define REQEST_BACKGROUND_REFRESH
Definition packhand.c:142
void handle_rulesets_ready(void)
Definition packhand.c:3684
void handle_tile_info(const struct packet_tile_info *packet)
Definition packhand.c:3266
void handle_ruleset_tiledef(const struct packet_ruleset_tiledef *p)
Definition packhand.c:4536
void handle_ruleset_action(const struct packet_ruleset_action *p)
Definition packhand.c:4577
static void action_decision_handle(struct unit *punit)
Definition packhand.c:1682
void handle_achievement_info(int id, bool gained, bool first)
Definition packhand.c:3056
void handle_scenario_description(const char *description)
Definition packhand.c:3548
void play_sound_for_event(enum event_type type)
Definition packhand.c:1537
void handle_edit_startpos(const struct packet_edit_startpos *packet)
Definition packhand.c:5578
void handle_processing_finished(void)
Definition packhand.c:5478
void handle_diplomacy_cancel_meeting(int counterpart, int initiated_from)
Definition packhand.c:5757
void handle_city_short_info(const struct packet_city_short_info *packet)
Definition packhand.c:1174
void handle_edit_fogofwar_state(bool enabled)
Definition packhand.c:5647
void handle_popup_image(const char *tag)
Definition packhand.c:5732
void handle_diplomacy_create_clause(int counterpart, int giver, enum clause_type type, int value)
Definition packhand.c:5765
void handle_endgame_player(const struct packet_endgame_player *packet)
Definition packhand.c:5425
void handle_ruleset_resource(const struct packet_ruleset_resource *p)
Definition packhand.c:4318
void handle_unit_action_answer(int actor_id, int target_id, int cost, action_id action_type, int request_kind)
Definition packhand.c:5049
void handle_ruleset_tech(const struct packet_ruleset_tech *p)
Definition packhand.c:3933
void handle_team_name_info(int team_id, const char *team_name)
Definition packhand.c:563
void handle_thaw_client(void)
Definition packhand.c:5532
void handle_calendar_info(const struct packet_calendar_info *pcalendar)
Definition packhand.c:2376
void packhand_free(void)
Definition packhand.c:220
void set_government_choice(struct government *government)
Definition packhand.c:2401
void handle_city_rally_point(const struct packet_city_rally_point *packet)
Definition packhand.c:1023
void handle_ruleset_disaster(const struct packet_ruleset_disaster *p)
Definition packhand.c:4656
static bool handle_unit_packet_common(struct unit *packet_unit)
Definition packhand.c:1720
void handle_ruleset_unit_class_flag(const struct packet_ruleset_unit_class_flag *p)
Definition packhand.c:3874
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:410
void handle_ruleset_summary(const struct packet_ruleset_summary *packet)
Definition packhand.c:3656
void handle_set_topology(int topology_id, int wrap_id)
Definition packhand.c:2234
void handle_ruleset_impr_flag(const struct packet_ruleset_impr_flag *p)
Definition packhand.c:4087
void handle_page_msg(const char *caption, const char *headline, enum event_type event, int len, int parts)
Definition packhand.c:1609
static struct @255 invisible
void handle_city_update_counters(const struct packet_city_update_counters *packet)
Definition packhand.c:5807
void handle_edit_startpos_full(const struct packet_edit_startpos_full *packet)
Definition packhand.c:5616
void handle_conn_ping_info(int connections, const int *conn_id, const float *ping_time)
Definition packhand.c:3033
void handle_diplomacy_remove_clause(int counterpart, int giver, enum clause_type type, int value)
Definition packhand.c:5774
static bool spaceship_autoplace(struct player *pplayer, struct player_spaceship *ship)
Definition packhand.c:3093
void handle_player_remove(int playerno)
Definition packhand.c:2426
void handle_processing_started(void)
Definition packhand.c:5460
void handle_begin_turn(void)
Definition packhand.c:1496
void handle_endgame_report(const struct packet_endgame_report *packet)
Definition packhand.c:5416
void handle_early_chat_msg(const struct packet_early_chat_msg *packet)
Definition packhand.c:1570
void handle_ruleset_clause(const struct packet_ruleset_clause *p)
Definition packhand.c:4888
void handle_ruleset_road(const struct packet_ruleset_road *p)
Definition packhand.c:4509
void handle_unit_actions(const struct packet_unit_actions *packet)
Definition packhand.c:5285
void handle_ruleset_music(const struct packet_ruleset_music *packet)
Definition packhand.c:4928
void handle_ruleset_base(const struct packet_ruleset_base *p)
Definition packhand.c:4488
void notify_about_incoming_packet(struct connection *pc, int packet_type, int size)
Definition packhand.c:5498
void handle_freeze_client(void)
Definition packhand.c:5522
void handle_city_remove(int city_id)
Definition packhand.c:478
void handle_chat_msg(const struct packet_chat_msg *packet)
Definition packhand.c:1550
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:1037
void handle_trade_route_info(const struct packet_trade_route_info *packet)
Definition packhand.c:1139
void handle_player_attribute_chunk(const struct packet_player_attribute_chunk *packet)
Definition packhand.c:5442
void handle_vote_new(const struct packet_vote_new *packet)
Definition packhand.c:5688
static void packhand_init(void)
Definition packhand.c:241
void handle_scenario_info(const struct packet_scenario_info *packet)
Definition packhand.c:3527
void handle_ruleset_extra_flag(const struct packet_ruleset_extra_flag *p)
Definition packhand.c:4462
char * lines
Definition packhand.c:133
void notify_about_outgoing_packet(struct connection *pc, int packet_type, int size, int request_id)
Definition packhand.c:5508
#define VALIDATE(_count, _maximum, _string)
const char forced_tileset_name[]
struct city_list * cities
Definition packhand.c:121
void handle_ruleset_tech_flag(const struct packet_ruleset_tech_flag *p)
Definition packhand.c:4017
static struct @256 page_msg_report
void handle_nation_availability(int ncount, const bool *is_pickable, bool nationset_change)
Definition packhand.c:4858
void handle_spaceship_info(const struct packet_spaceship_info *p)
Definition packhand.c:3112
void handle_ruleset_specialist(const struct packet_ruleset_specialist *p)
Definition packhand.c:4993
void handle_unit_short_info(const struct packet_unit_short_info *packet)
Definition packhand.c:2184
void handle_diplomacy_accept_treaty(int counterpart, bool I_accepted, bool other_accepted)
Definition packhand.c:5748
void handle_ruleset_unit_flag(const struct packet_ruleset_unit_flag *p)
Definition packhand.c:3848
void handle_city_nationalities(const struct packet_city_nationalities *packet)
Definition packhand.c:1003
void handle_server_shutdown(void)
Definition packhand.c:5551
void handle_ruleset_building(const struct packet_ruleset_building *p)
Definition packhand.c:4043
static int * continent_adjacency_count(Continent_id cont1, Continent_id cont2)
Definition packhand.c:3158
static bool update_improvement_from_packet(struct city *pcity, struct impr_type *pimprove, bool have_impr)
Definition packhand.c:639
void handle_ruleset_unit(const struct packet_ruleset_unit *p)
Definition packhand.c:3756
void handle_ruleset_terrain(const struct packet_ruleset_terrain *p)
Definition packhand.c:4201
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:5217
#define REQEST_BACKGROUND_FAST_AUTO_ATTACK
Definition packhand.c:144
void handle_city_sabotage_list(int actor_id, int city_id, bv_imprs improvements, action_id act_id, int request_kind)
Definition packhand.c:5355
void handle_ruleset_action_enabler(const struct packet_ruleset_action_enabler *p)
Definition packhand.c:4611
void handle_ruleset_achievement(const struct packet_ruleset_achievement *p)
Definition packhand.c:4674
void handle_game_info(const struct packet_game_info *pinfo)
Definition packhand.c:2300
struct player * placeholder
Definition packhand.c:122
void handle_vote_resolve(int vote_no, bool passed)
Definition packhand.c:5705
void handle_worker_task(const struct packet_worker_task *packet)
Definition packhand.c:1319
void handle_ruleset_description_part(const struct packet_ruleset_description_part *packet)
Definition packhand.c:3674
void handle_ruleset_trade(const struct packet_ruleset_trade *p)
Definition packhand.c:4690
int len
Definition packhand.c:129
bool player_slot_is_used(const struct player_slot *pslot)
Definition player.c:441
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
Definition player.c:1217
struct player * player_new(struct player_slot *pslot)
Definition player.c:484
struct player * player_by_number(const int player_id)
Definition player.c:837
int player_count(void)
Definition player.c:806
struct player_slot * player_slot_by_number(int player_id)
Definition player.c:454
int player_number(const struct player *pplayer)
Definition player.c:826
const char * player_name(const struct player *pplayer)
Definition player.c:885
void player_set_color(struct player *pplayer, const struct rgbcolor *prgbcolor)
Definition player.c:639
int player_index(const struct player *pplayer)
Definition player.c:818
bool player_set_nation(struct player *pplayer, struct nation_type *pnation)
Definition player.c:849
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Definition player.c:325
bool can_player_see_units_in_city(const struct player *pplayer, const struct city *pcity)
Definition player.c:1124
struct player * player_slot_get_player(const struct player_slot *pslot)
Definition player.c:432
bool can_player_see_city_internals(const struct player *pplayer, const struct city *pcity)
Definition player.c:1140
void player_destroy(struct player *pplayer)
Definition player.c:747
#define players_iterate_end
Definition player.h:552
#define players_iterate(_pplayer)
Definition player.h:547
#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:640
struct research * research_by_number(int number)
Definition research.c:119
struct research * research_get(const struct player *pplayer)
Definition research.c:130
void research_update(struct research *presearch)
Definition research.c:504
#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:70
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:110
bool is_normal_specialist_id(Specialist_type_id sp)
Definition specialist.c:196
#define specialist_type_iterate_end
Definition specialist.h:85
#define specialist_type_iterate(sp)
Definition specialist.h:79
#define DEFAULT_SPECIALIST
Definition specialist.h:43
size_t size
Definition specvec.h:72
#define strvec_iterate(psv, str)
#define strvec_iterate_end
bv_tiledefs tiledefs
Definition fc_types.h:1107
struct city_list * cities
Definition fc_types.h:1105
struct player * first
bool actor_consuming_always
Definition actions.h:144
int max_distance
Definition actions.h:127
bool quiet
Definition actions.h:134
enum action_sub_target_kind sub_target_kind
Definition actions.h:119
enum action_result result
Definition actions.h:114
char ui_name[MAX_LEN_NAME]
Definition actions.h:130
bv_action_sub_results sub_results
Definition actions.h:115
enum action_actor_kind actor_kind
Definition actions.h:117
bv_actions blocked_by
Definition actions.h:138
enum action_target_kind target_kind
Definition actions.h:118
int min_distance
Definition actions.h:127
struct requirement_vector research_reqs
Definition tech.h:134
struct tech_class * tclass
Definition tech.h:127
double cost
Definition tech.h:147
struct advance * require[AR_SIZE]
Definition tech.h:129
struct name_translation name
Definition tech.h:123
struct strvec * helptext
Definition tech.h:137
bv_tech_flags flags
Definition tech.h:136
int num_reqs
Definition tech.h:153
char graphic_str[MAX_LEN_NAME]
Definition tech.h:125
char graphic_alt[MAX_LEN_NAME]
Definition tech.h:126
Definition city.h:318
int id
Definition city.h:324
struct civ_game::@32::@35 client
bool fog_of_war
Definition game.h:121
struct rgbcolor * plr_bg_color
Definition game.h:103
struct packet_scenario_description scenario_desc
Definition game.h:88
struct packet_ruleset_control control
Definition game.h:83
char * ruleset_summary
Definition game.h:84
struct conn_list * est_connections
Definition game.h:97
int global_init_techs[MAX_NUM_TECH_LIST]
Definition game.h:110
struct packet_game_info info
Definition game.h:89
bool ruleset_ready
Definition game.h:119
int global_init_buildings[MAX_NUM_BUILDING_LIST]
Definition game.h:111
struct packet_scenario_info scenario
Definition game.h:87
char * ruleset_description
Definition game.h:85
struct conn_list * all_connections
Definition game.h:96
struct civ_game::@31 rgame
bool ruleset_init
Definition game.h:118
struct packet_timeout_info tinfo
Definition game.h:91
struct veteran_system * veteran
Definition game.h:101
struct packet_calendar_info calendar
Definition game.h:90
struct government * default_government
Definition game.h:93
struct government * government_during_revolution
Definition game.h:94
int xsize
Definition map_types.h:79
int ysize
Definition map_types.h:79
int north_latitude
Definition map_types.h:80
Continent_id num_continents
Definition map_types.h:83
struct civ_map::@44::@47 client
int south_latitude
Definition map_types.h:81
bool altitude_info
Definition map_types.h:74
int topology_id
Definition map_types.h:72
int wrap_id
Definition map_types.h:73
int * continent_sizes
Definition map_types.h:92
int * ocean_sizes
Definition map_types.h:93
Continent_id num_oceans
Definition map_types.h:84
int ** adj_matrix
Definition map_types.h:153
struct connection conn
Definition client_main.h:96
struct requirement_vector receiver_reqs
Definition diptreaty.h:61
struct requirement_vector giver_reqs
Definition diptreaty.h:60
struct requirement_vector either_reqs
Definition diptreaty.h:62
bool enabled
Definition diptreaty.h:59
bool sound_bell_at_new_turn
Definition options.h:151
bool autoaccept_tileset_suggestion
Definition options.h:184
bool autoaccept_musicset_suggestion
Definition options.h:186
bool draw_city_names
Definition options.h:197
bool draw_city_productions
Definition options.h:199
bool popup_new_cities
Definition options.h:168
bool draw_city_trade_routes
Definition options.h:201
bool wakeup_focus
Definition options.h:160
bool autoaccept_soundset_suggestion
Definition options.h:185
bool ask_city_name
Definition options.h:167
bool draw_city_growth
Definition options.h:198
bool ai_manual_turn_done
Definition options.h:155
int smooth_combat_step_msec
Definition options.h:154
bool draw_full_citybar
Definition options.h:217
bool auto_center_on_combat
Definition options.h:158
bool popup_attack_actions
Definition options.h:170
enum unit_type_flag_id flag
Definition unittype.h:472
enum combat_bonus_type type
Definition unittype.h:473
bool established
Definition connection.h:140
struct player * playing
Definition connection.h:151
int request_id_of_currently_handled_packet
Definition connection.h:193
enum cmdlevel access_level
Definition connection.h:177
bool observer
Definition connection.h:147
char username[MAX_LEN_NAME]
Definition connection.h:164
struct connection::@61::@66 client
char capability[MAX_LEN_CAPSTR]
Definition connection.h:171
int last_processed_request_id_seen
Definition connection.h:190
double ping_time
Definition connection.h:161
bv_unit_classes native_to
Definition extras.h:130
char rmact_gfx[MAX_LEN_NAME]
Definition extras.h:102
bv_extras conflicts
Definition extras.h:133
uint8_t rmcauses
Definition extras.h:95
char act_gfx_alt[MAX_LEN_NAME]
Definition extras.h:100
struct requirement_vector appearance_reqs
Definition extras.h:108
struct strvec * helptext
Definition extras.h:149
bv_extra_flags flags
Definition extras.h:132
char rmact_gfx_alt[MAX_LEN_NAME]
Definition extras.h:103
uint16_t causes
Definition extras.h:94
bv_extras bridged_over
Definition extras.h:135
int removal_time
Definition extras.h:120
char rmact_gfx_alt2[MAX_LEN_NAME]
Definition extras.h:104
int build_time_factor
Definition extras.h:119
struct requirement_vector disappearance_reqs
Definition extras.h:109
bool generated
Definition extras.h:117
int special_idx
Definition extras.h:153
struct extra_type::@26 data
struct requirement_vector rmreqs
Definition extras.h:107
Tech_type_id visibility_req
Definition extras.h:139
enum extra_category category
Definition extras.h:93
char graphic_alt[MAX_LEN_NAME]
Definition extras.h:98
char activity_gfx[MAX_LEN_NAME]
Definition extras.h:99
int disappearance_chance
Definition extras.h:126
int removal_time_factor
Definition extras.h:121
char act_gfx_alt2[MAX_LEN_NAME]
Definition extras.h:101
struct requirement_vector reqs
Definition extras.h:106
bool buildable
Definition extras.h:116
enum extra_unit_seen_type eus
Definition extras.h:128
int defense_bonus
Definition extras.h:124
int appearance_chance
Definition extras.h:125
char graphic_str[MAX_LEN_NAME]
Definition extras.h:97
int build_time
Definition extras.h:118
int infracost
Definition extras.h:122
int no_aggr_near_city
Definition extras.h:137
bv_extras hidden_by
Definition extras.h:134
struct name_translation name
Definition extras.h:90
struct strvec * helptext
Definition government.h:68
struct requirement_vector reqs
Definition government.h:64
char graphic_alt[MAX_LEN_NAME]
Definition government.h:60
Government_type_id item_number
Definition government.h:55
char sound_alt2[MAX_LEN_NAME]
Definition government.h:63
struct name_translation name
Definition government.h:56
char sound_str[MAX_LEN_NAME]
Definition government.h:61
char graphic_str[MAX_LEN_NAME]
Definition government.h:59
bv_gov_flags flags
Definition government.h:67
char sound_alt[MAX_LEN_NAME]
Definition government.h:62
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:126
bool is_pickable
Definition nation.h:163
struct unit_type * init_units[MAX_NUM_UNIT_LIST]
Definition nation.h:127
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
bv_tiledefs tiledefs
enum event_type event
char message[MAX_LEN_MSG]
int last_turns_shield_surplus
int prod[O_LAST]
int ppl_content[FEELING_LAST]
bv_city_options city_options
int waste[O_LAST]
enum capital_type capital
enum city_acquire_type acquire_type
int unhappy_penalty[O_LAST]
enum city_wl_cancel_behavior wl_cb
bv_imprs improvements
struct worklist worklist
int citizen_base[O_LAST]
int specialists[SP_MAX]
int ppl_unhappy[FEELING_LAST]
int usage[O_LAST]
int surplus[O_LAST]
char name[MAX_LEN_CITYNAME]
int ppl_angry[FEELING_LAST]
int ppl_happy[FEELING_LAST]
int nation_id[MAX_CITY_NATIONALITIES]
int nation_citizens[MAX_CITY_NATIONALITIES]
char name[MAX_LEN_CITYNAME]
enum capital_type capital
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]
char name[MAX_LEN_NAME]
enum achievement_type type
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
char ui_name[MAX_LEN_NAME]
enum action_sub_target_kind sub_tgt_kind
enum action_actor_kind act_kind
bv_action_sub_results sub_results
enum action_target_kind tgt_kind
enum action_result result
enum base_gui_type gui_type
char graphic_alt2[MAX_LEN_NAME]
char name[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
char graphic_alt[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
struct requirement_vector reqs
struct requirement_vector obs_reqs
char soundtag_alt2[MAX_LEN_NAME]
enum impr_genus_id genus
char soundtag[MAX_LEN_NAME]
char soundtag_alt[MAX_LEN_NAME]
struct strvec * helptext
char rule_name[MAX_LEN_NAME]
char graphic[MAX_LEN_NAME]
char citizens_graphic[MAX_LEN_NAME]
char graphic_alt[MAX_LEN_NAME]
struct requirement_vector reqs
char name[MAX_LEN_NAME]
struct requirement_vector giver_reqs
enum clause_type type
struct requirement_vector receiver_reqs
struct requirement_vector either_reqs
char preferred_musicset[MAX_LEN_NAME]
char preferred_tileset[MAX_LEN_NAME]
char preferred_soundset[MAX_LEN_NAME]
enum counter_target type
char name[MAX_LEN_NAME]
struct strvec * helptext
char rule_name[MAX_LEN_NAME]
enum counter_behavior behavior
char text[MAX_LEN_CONTENT]
char name[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
struct requirement_vector reqs
bv_disaster_effects effects
char helptxt[MAX_LEN_PACKET]
char name[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
struct strvec * helptext
bv_unit_classes native_to
char graphic_alt[MAX_LEN_NAME]
char rmact_gfx[MAX_LEN_NAME]
struct requirement_vector appearance_reqs
char act_gfx_alt[MAX_LEN_NAME]
char act_gfx_alt2[MAX_LEN_NAME]
struct requirement_vector disappearance_reqs
bv_extra_flags flags
char rmact_gfx_alt[MAX_LEN_NAME]
struct requirement_vector rmreqs
enum extra_unit_seen_type eus
char activity_gfx[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
char name[MAX_LEN_NAME]
struct requirement_vector reqs
char rmact_gfx_alt2[MAX_LEN_NAME]
int base_raise_chance[MAX_VET_LEVELS]
int work_raise_chance[MAX_VET_LEVELS]
int move_bonus[MAX_VET_LEVELS]
int power_fact[MAX_VET_LEVELS]
char veteran_name[MAX_VET_LEVELS][MAX_LEN_NAME]
int global_init_techs[MAX_NUM_TECH_LIST]
Impr_type_id global_init_buildings[MAX_NUM_BUILDING_LIST]
struct requirement_vector reqs
bv_goods_flags flags
char rule_name[MAX_LEN_NAME]
char name[MAX_LEN_NAME]
struct strvec * helptext
char helptxt[MAX_LEN_PACKET]
char name[MAX_LEN_NAME]
char sound_alt2[MAX_LEN_NAME]
char sound_str[MAX_LEN_NAME]
struct requirement_vector reqs
char graphic_alt[MAX_LEN_NAME]
Government_type_id id
char graphic_str[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
char sound_alt[MAX_LEN_NAME]
char name[MAX_LEN_NAME]
char helptxt[MAX_LEN_PACKET]
char name[MAX_LEN_NAME]
struct requirement_vector reqs
char name[MAX_LEN_NAME]
Multiplier_type_id id
char rule_name[MAX_LEN_NAME]
struct requirement_vector reqs
char music_peaceful[MAX_LEN_NAME]
char music_combat[MAX_LEN_NAME]
bool hidden[MAX_NUM_NATION_GROUPS]
char groups[MAX_NUM_NATION_GROUPS][MAX_LEN_NAME]
char names[MAX_NUM_NATION_SETS][MAX_LEN_NAME]
char rule_names[MAX_NUM_NATION_SETS][MAX_LEN_NAME]
char descriptions[MAX_NUM_NATION_SETS][MAX_LEN_MSG]
char graphic_alt[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
bool leader_is_male[MAX_NUM_LEADERS]
int sets[MAX_NUM_NATION_SETS]
Impr_type_id init_buildings[MAX_NUM_BUILDING_LIST]
char adjective[MAX_LEN_NAME]
char translation_domain[MAX_LEN_NAME]
char leader_name[MAX_NUM_LEADERS][MAX_LEN_NAME]
int init_techs[MAX_NUM_TECH_LIST]
Unit_type_id init_units[MAX_NUM_UNIT_LIST]
char legend[MAX_LEN_MSG]
int groups[MAX_NUM_NATION_GROUPS]
Government_type_id init_government_id
enum barbarian_type barbarian_type
char noun_plural[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
bv_road_flags flags
enum road_gui_type gui_type
bv_max_extras integrates
int tile_incr_const[O_LAST]
enum road_compat compat
int tile_incr[O_LAST]
enum road_move_mode move_mode
int tile_bonus[O_LAST]
struct requirement_vector first_reqs
char plural_name[MAX_LEN_NAME]
struct requirement_vector reqs
Specialist_type_id id
char rule_name[MAX_LEN_NAME]
char short_name[MAX_LEN_NAME]
char graphic_alt[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
char name[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
char text[MAX_LEN_CONTENT]
char rule_name[MAX_LEN_NAME]
char name[MAX_LEN_NAME]
char name[MAX_LEN_NAME]
char helptxt[MAX_LEN_PACKET]
struct strvec * helptext
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 requirement_vector research_reqs
char name[MAX_LEN_NAME]
char helptxt[MAX_LEN_PACKET]
Terrain_type_id transform_result
char name[MAX_LEN_NAME]
int animals[MAX_NUM_ANIMALS]
int resource_freq[MAX_EXTRA_TYPES]
bv_terrain_flags flags
Resource_type_id resources[MAX_EXTRA_TYPES]
char graphic_alt[MAX_LEN_NAME]
bv_unit_classes native_to
int road_output_incr_pct[O_LAST]
char graphic_alt2[MAX_LEN_NAME]
Terrain_type_id cultivate_result
int extra_removal_times[MAX_EXTRA_TYPES]
Terrain_type_id plant_result
char rule_name[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
struct strvec * helptext
char rule_name[MAX_LEN_NAME]
char 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]
bv_unit_class_flags flags
char rule_name[MAX_LEN_NAME]
char name[MAX_LEN_NAME]
char helptxt[MAX_LEN_PACKET]
char name[MAX_LEN_NAME]
enum vision_layer vlayer
enum transp_def_type tp_defense
char rule_name[MAX_LEN_NAME]
int base_raise_chance[MAX_VET_LEVELS]
int move_bonus[MAX_VET_LEVELS]
int work_raise_chance[MAX_VET_LEVELS]
char sound_move[MAX_LEN_NAME]
bv_unit_classes disembarks
bv_unit_classes cargo
bv_unit_type_flags flags
char sound_fight_alt[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
bv_unit_classes targets
struct requirement_vector build_reqs
int power_fact[MAX_VET_LEVELS]
char veteran_name[MAX_VET_LEVELS][MAX_LEN_NAME]
bv_unit_classes embarks
char sound_fight[MAX_LEN_NAME]
char sound_move_alt[MAX_LEN_NAME]
struct strvec * helptext
char graphic_alt2[MAX_LEN_NAME]
char graphic_alt[MAX_LEN_NAME]
char name[MAX_LEN_NAME]
bv_unit_type_roles roles
char description[MAX_LEN_CONTENT]
char authors[MAX_LEN_PACKET/3]
bv_spaceship_structure structure
Resource_type_id resource
enum known_type known
Continent_id continent
char spec_sprite[MAX_LEN_NAME]
Terrain_type_id terrain
char label[MAX_LEN_MAP_LABEL]
enum route_direction direction
struct act_prob action_probabilities[MAX_NUM_ACTIONS]
enum action_decision action_decision_want
enum unit_activity activity
struct unit_order orders[MAX_LEN_ROUTE]
Unit_type_id type
enum unit_activity changed_from
enum direction8 facing
int upkeep[O_LAST]
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:157
char graphic_alt2[MAX_LEN_NAME]
Definition terrain.h:82
bv_terrain_flags flags
Definition terrain.h:153
int * resource_freq
Definition terrain.h:98
bv_unit_classes native_to
Definition terrain.h:151
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
int num_animals
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:155
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
const struct unit_type ** animals
Definition terrain.h:131
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:93
int action
Definition unit.h:101
int transport_capacity
Definition unittype.h:530
struct unit_class * uclass
Definition unittype.h:563
int pop_cost
Definition unittype.h:518
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:511
bool worker
Definition unittype.h:582
char sound_move_alt[MAX_LEN_NAME]
Definition unittype.h:514
int build_cost
Definition unittype.h:517
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:510
int city_slots
Definition unittype.h:559
char sound_move[MAX_LEN_NAME]
Definition unittype.h:513
char sound_fight_alt[MAX_LEN_NAME]
Definition unittype.h:516
struct name_translation name
Definition unittype.h:507
bv_unit_type_roles roles
Definition unittype.h: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:512
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:515
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
struct specialist * spec_type
Definition unittype.h:520
Definition unit.h:139
int length
Definition unit.h:197
int upkeep[O_LAST]
Definition unit.h:149
bool has_orders
Definition unit.h:195
bool occupied
Definition unit.h:221
enum action_decision action_decision_want
Definition unit.h:204
int battlegroup
Definition unit.h:193
enum unit_activity activity
Definition unit.h:158
int moves_left
Definition unit.h:151
int id
Definition unit.h:146
struct unit::@83 orders
bool moved
Definition unit.h:175
int index
Definition unit.h:197
bool vigilant
Definition unit.h:199
int hp
Definition unit.h:152
int fuel
Definition unit.h:154
struct extra_type * changed_from_target
Definition unit.h:172
int current_form_turn
Definition unit.h:210
bool stay
Definition unit.h:207
bool colored
Definition unit.h:224
enum direction8 facing
Definition unit.h:143
bool asking_city_name
Definition unit.h:227
struct tile * tile
Definition unit.h:141
struct unit::@84::@86 client
struct extra_type * activity_target
Definition unit.h:166
int activity_count
Definition unit.h:164
struct unit_order * list
Definition unit.h:200
enum unit_activity changed_from
Definition unit.h:170
struct player * nationality
Definition unit.h:145
int transported_by
Definition unit.h:218
bool repeat
Definition unit.h:198
int homecity
Definition unit.h:147
bool paradropped
Definition unit.h:176
bool done_moving
Definition unit.h:183
int birth_turn
Definition unit.h:209
struct goods_type * carrying
Definition unit.h:188
struct tile * goto_tile
Definition unit.h:156
struct tile * action_decision_tile
Definition unit.h:205
const struct unit_type * utype
Definition unit.h:140
int veteran
Definition unit.h:153
int changed_from_count
Definition unit.h:171
struct player * owner
Definition unit.h:144
enum unit_focus_status focus_status
Definition unit.h:216
enum server_side_agent ssa_controller
Definition unit.h:174
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:84
void styles_alloc(int count)
Definition style.c:36
struct music_style * music_style_by_number(int id)
Definition style.c:165
void music_styles_alloc(int count)
Definition style.c:129
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 nullptr
Definition support.h:55
#define fc_strncmp(_s1_, _s2_, _len_)
Definition support.h:160
int team_count(void)
Definition team.c:367
struct team_slot * team_slot_by_number(int team_id)
Definition team.c:173
bool team_add_player(struct player *pplayer, struct team *pteam)
Definition team.c:452
struct team * team_new(struct team_slot *tslot)
Definition team.c:309
void team_slot_set_defined_name(struct team_slot *tslot, const char *team_name)
Definition team.c:282
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:110
void set_user_tech_flag_name(enum tech_flag_id id, const char *name, const char *helptxt)
Definition tech.c:409
struct tech_class * tech_class_by_number(const int idx)
Definition tech.c:335
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:100
#define A_FUTURE
Definition tech.h:46
#define A_NEVER
Definition tech.h:51
#define advance_index_iterate_end
Definition tech.h:246
tech_req
Definition tech.h:107
@ AR_TWO
Definition tech.h:109
@ AR_ROOT
Definition tech.h:110
@ AR_ONE
Definition tech.h:108
static Tech_type_id advance_count(void)
Definition tech.h:167
#define TECH_USER_LAST
Definition tech.h:103
#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:242
Terrain_type_id terrain_count(void)
Definition terrain.c:119
struct terrain * terrain_by_number(const Terrain_type_id type)
Definition terrain.c:157
const char * terrain_rule_name(const struct terrain *pterrain)
Definition terrain.c:249
struct resource_type * resource_type_init(struct extra_type *pextra)
Definition terrain.c:275
void set_user_terrain_flag_name(enum terrain_flag_id id, const char *name, const char *helptxt)
Definition terrain.c:791
#define MAX_NUM_TERRAINS
Definition terrain.h:69
void tile_set_terrain(struct tile *ptile, struct terrain *pterrain)
Definition tile.c:125
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:1098
void tile_set_resource(struct tile *ptile, struct extra_type *presource)
Definition tile.c:350
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:107
#define tile_index(_pt_)
Definition tile.h:89
#define tile_worked(_tile)
Definition tile.h:119
#define tile_resource(_tile)
Definition tile.h:103
known_type
Definition tile.h:35
@ TILE_KNOWN_UNSEEN
Definition tile.h:37
@ TILE_UNKNOWN
Definition tile.h:36
@ TILE_KNOWN_SEEN
Definition tile.h:38
#define tile_list_iterate(tile_list, ptile)
Definition tile.h:74
#define tile_terrain(_tile)
Definition tile.h:115
#define TILE_XY(ptile)
Definition tile.h:43
#define tile_list_iterate_end
Definition tile.h:76
#define tile_continent(_tile)
Definition tile.h:93
#define tile_owner(_tile)
Definition tile.h:97
struct tiledef * tiledef_by_number(int id)
Definition tiledef.c:84
void tileset_setup_unit_type(struct tileset *t, struct unit_type *ut)
Definition tilespec.c:3999
void tileset_setup_government(struct tileset *t, struct government *gov)
Definition tilespec.c:4608
void tileset_setup_specialist_type_default_set(struct tileset *t, Specialist_type_id id)
Definition tilespec.c:3088
void tileset_setup_tile_type(struct tileset *t, const struct terrain *pterrain)
Definition tilespec.c:4342
void tileset_player_init(struct tileset *t, struct player *pplayer)
Definition tilespec.c:7634
bool unit_drawn_with_city_outline(const struct unit *punit, bool check_focus)
Definition tilespec.c:5718
void tileset_setup_impr_type(struct tileset *t, struct impr_type *pimprove)
Definition tilespec.c:4033
void tileset_background_init(struct tileset *t)
Definition tilespec.c:7714
void tileset_setup_tech_type(struct tileset *t, struct advance *padvance)
Definition tilespec.c:4049
void tileset_setup_city_tiles(struct tileset *t, int style)
Definition tilespec.c:6670
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:4068
const char * tileset_basename(const struct tileset *t)
Definition tilespec.c:730
void finish_loading_sprites(struct tileset *t)
Definition tilespec.c:3809
const char * tileset_name_get(struct tileset *t)
Definition tilespec.c:7785
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:4623
void tileset_ruleset_reset(struct tileset *t)
Definition tilespec.c:7749
#define MAX_NUM_CITIZEN_SPRITES
Definition tilespec.h:200
#define NUM_WALL_TYPES
Definition tilespec.h:362
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:2461
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2525
bool unit_transport_unload(struct unit *pcargo)
Definition unit.c:2478
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Definition unit.c:1682
void unit_virtual_destroy(struct unit *punit)
Definition unit.c:1786
void unit_tile_set(struct unit *punit, struct tile *ptile)
Definition unit.c:1308
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2511
struct unit_list * unit_transport_cargo(const struct unit *ptrans)
Definition unit.c:2533
#define unit_tile(_pu)
Definition unit.h:407
@ FOCUS_AVAIL
Definition unit.h:53
@ FOCUS_WAIT
Definition unit.h:53
@ ORDER_PERFORM_ACTION
Definition unit.h:47
#define unit_owner(_pu)
Definition unit.h:406
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
void set_unit_class_caches(struct unit_class *pclass)
Definition unittype.c:2793
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:126
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c:1595
const char * unit_rule_name(const struct unit *punit)
Definition unittype.c:1613
void set_unit_move_type(struct unit_class *puclass)
Definition unittype.c:2961
void set_unit_type_caches(struct unit_type *ptype)
Definition unittype.c:2852
struct unit_class * uclass_by_number(const Unit_Class_id id)
Definition unittype.c:2511
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:2722
struct unit_type * utype_by_number(const Unit_type_id id)
Definition unittype.c:114
void unit_type_action_cache_set(struct unit_type *ptype)
Definition unittype.c:940
void set_user_unit_class_flag_name(enum unit_class_flag_id id, const char *name, const char *helptxt)
Definition unittype.c:1839
struct veteran_system * veteran_system_new(int count)
Definition unittype.c:2691
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Definition unittype.c:396
void set_user_unit_type_flag_name(enum unit_type_flag_id id, const char *name, const char *helptxt)
Definition unittype.c:1903
#define UCF_LAST_USER_FLAG
Definition unittype.h:127
#define unit_class_iterate(_p)
Definition unittype.h:918
#define UTYF_LAST_USER_FLAG
Definition unittype.h:335
#define unit_type_iterate(_p)
Definition unittype.h:865
#define U_LAST
Definition unittype.h:40
#define unit_class_iterate_end
Definition unittype.h:925
#define unit_type_iterate_end
Definition unittype.h:872
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 FREECIV_DISTRIBUTOR
Definition version_gen.h:26
#define EMERGENCY_VERSION
Definition version_gen.h:9
#define vision_layer_iterate(v)
Definition vision.h:76
#define vision_layer_iterate_end
Definition vision.h:79
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