Freeciv-3.1
Loading...
Searching...
No Matches
packhand.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#include <string.h>
19
20/* utility */
21#include "bitvector.h"
22#include "capability.h"
23#include "fcintl.h"
24#include "log.h"
25#include "mem.h"
26#include "rand.h"
27#include "string_vector.h"
28#include "support.h"
29
30/* common */
31#include "achievements.h"
32#include "actions.h"
33#include "capstr.h"
34#include "citizens.h"
35#include "events.h"
36#include "extras.h"
37#include "game.h"
38#include "government.h"
39#include "idex.h"
40#include "map.h"
41#include "name_translation.h"
42#include "movement.h"
43#include "multipliers.h"
44#include "nation.h"
45#include "packets.h"
46#include "player.h"
47#include "research.h"
48#include "rgbcolor.h"
49#include "road.h"
50#include "spaceship.h"
51#include "specialist.h"
52#include "style.h"
53#include "traderoutes.h"
54#include "unit.h"
55#include "unitlist.h"
56#include "worklist.h"
57
58/* client/include */
59#include "chatline_g.h"
60#include "citydlg_g.h"
61#include "cityrep_g.h"
62#include "connectdlg_g.h"
63#include "dialogs_g.h"
64#include "editgui_g.h"
65#include "gui_main_g.h"
66#include "inteldlg_g.h"
67#include "mapctrl_g.h" /* popup_newcity_dialog() */
68#include "mapview_g.h"
69#include "menu_g.h"
70#include "messagewin_g.h"
71#include "pages_g.h"
72#include "plrdlg_g.h"
73#include "ratesdlg_g.h"
74#include "repodlgs_g.h"
75#include "spaceshipdlg_g.h"
76#include "voteinfo_bar_g.h"
77#include "wldlg_g.h"
78
79/* client */
80#include "agents.h"
81#include "attribute.h"
82#include "audio.h"
83#include "client_main.h"
84#include "climap.h"
85#include "climisc.h"
86#include "connectdlg_common.h"
87#include "control.h"
88#include "editor.h"
89#include "goto.h" /* client_goto_init() */
90#include "helpdata.h" /* boot_help_texts() */
91#include "mapview_common.h"
92#include "music.h"
93#include "options.h"
94#include "overview_common.h"
95#include "tilespec.h"
96#include "update_queue.h"
97#include "voteinfo.h"
98
99/* client/luascript */
100#include "script_client.h"
101
102#include "packhand.h"
103
104/* Define this macro to get additional debug output about the transport
105 * status of the units. */
106#undef DEBUG_TRANSPORT
107
108static void city_packet_common(struct city *pcity, struct tile *pcenter,
109 struct player *powner,
110 struct tile_list *worked_tiles,
111 bool is_new, bool popup, bool investigate);
112static bool handle_unit_packet_common(struct unit *packet_unit);
113
114
115/* The dumbest of cities, placeholders for unknown and unseen cities. */
116static struct {
117 struct city_list *cities;
119} invisible = {
120 .cities = NULL,
121 .placeholder = NULL
123
124static struct {
125 int len;
126 enum event_type event;
127 char *caption;
128 char *headline;
129 char *lines;
130 int parts;
131} page_msg_report = { .parts = 0 };
132
133extern const char forced_tileset_name[];
134
135static int last_turn = 0;
136
137/* Refresh the action selection dialog */
138#define REQEST_BACKGROUND_REFRESH (1)
139/* Get possible actions for fast auto attack. */
140#define REQEST_BACKGROUND_FAST_AUTO_ATTACK (2)
141
142/* A unit will auto attack with the following actions. */
144 ACTION_CAPTURE_UNITS,
145 ACTION_BOMBARD, ACTION_BOMBARD2, ACTION_BOMBARD3,
146 ACTION_NUKE, ACTION_NUKE_CITY, ACTION_NUKE_UNITS,
147 ACTION_ATTACK, ACTION_SUICIDE_ATTACK,
148 ACTION_CONQUER_CITY, ACTION_CONQUER_CITY2,
149 ACTION_CONQUER_CITY3, ACTION_CONQUER_CITY4,
150 ACTION_STRIKE_PRODUCTION,
151 ACTION_CONQUER_EXTRAS, ACTION_CONQUER_EXTRAS2,
152 ACTION_CONQUER_EXTRAS3, ACTION_CONQUER_EXTRAS4,
153 /* End the action list. */
155};
156
157/* A unit will not auto attack if any of these actions are legal. */
159 ACTION_ESTABLISH_EMBASSY, ACTION_ESTABLISH_EMBASSY_STAY,
160 ACTION_SPY_INVESTIGATE_CITY, ACTION_INV_CITY_SPEND,
161 ACTION_SPY_POISON, ACTION_SPY_POISON_ESC,
162 ACTION_SPY_STEAL_GOLD, ACTION_SPY_STEAL_GOLD_ESC,
163 ACTION_SPY_SPREAD_PLAGUE,
164 ACTION_SPY_SABOTAGE_CITY, ACTION_SPY_SABOTAGE_CITY_ESC,
165 ACTION_SPY_TARGETED_SABOTAGE_CITY,
166 ACTION_SPY_TARGETED_SABOTAGE_CITY_ESC,
167 ACTION_SPY_SABOTAGE_CITY_PRODUCTION,
168 ACTION_SPY_SABOTAGE_CITY_PRODUCTION_ESC,
169 ACTION_SPY_STEAL_TECH, ACTION_SPY_STEAL_TECH_ESC,
170 ACTION_SPY_TARGETED_STEAL_TECH,
171 ACTION_SPY_TARGETED_STEAL_TECH_ESC,
172 ACTION_SPY_INCITE_CITY, ACTION_SPY_INCITE_CITY_ESC,
173 ACTION_TRADE_ROUTE, ACTION_MARKETPLACE,
174 ACTION_HELP_WONDER,
175 ACTION_SPY_BRIBE_UNIT,
176 ACTION_SPY_SABOTAGE_UNIT, ACTION_SPY_SABOTAGE_UNIT_ESC,
177 ACTION_SPY_ATTACK,
178 ACTION_FOUND_CITY,
179 ACTION_JOIN_CITY,
180 ACTION_STEAL_MAPS, ACTION_STEAL_MAPS_ESC,
181 ACTION_SPY_NUKE, ACTION_SPY_NUKE_ESC,
182 ACTION_DESTROY_CITY,
183 ACTION_EXPEL_UNIT,
184 ACTION_DISBAND_UNIT_RECOVER,
185 ACTION_HOME_CITY,
186 ACTION_HOMELESS,
187 ACTION_UPGRADE_UNIT,
188 ACTION_PARADROP, ACTION_PARADROP_CONQUER, ACTION_PARADROP_FRIGHTEN,
189 ACTION_PARADROP_FRIGHTEN_CONQUER, ACTION_PARADROP_ENTER,
190 ACTION_PARADROP_ENTER_CONQUER,
191 ACTION_AIRLIFT,
192 ACTION_HEAL_UNIT, ACTION_HEAL_UNIT2,
193 ACTION_TRANSFORM_TERRAIN,
194 ACTION_CULTIVATE,
195 ACTION_PLANT,
196 ACTION_PILLAGE,
197 ACTION_CLEAN_POLLUTION,
198 ACTION_CLEAN_FALLOUT,
199 ACTION_ROAD,
200 ACTION_BASE,
201 ACTION_MINE,
202 ACTION_IRRIGATE,
203 ACTION_HUT_ENTER, ACTION_HUT_ENTER2, ACTION_HUT_ENTER3, ACTION_HUT_ENTER4,
204 ACTION_HUT_FRIGHTEN, ACTION_HUT_FRIGHTEN2,
205 ACTION_HUT_FRIGHTEN3, ACTION_HUT_FRIGHTEN4,
206 /* Actually an attack but it needs a target to be specified. */
207 ACTION_STRIKE_BUILDING,
208 /* End the action list. */
210};
211
212/************************************************************************/
216{
217 if (NULL != invisible.cities) {
218 city_list_iterate(invisible.cities, pcity) {
219 idex_unregister_city(&wld, pcity);
222
223 city_list_destroy(invisible.cities);
224 invisible.cities = NULL;
225 }
226
227 if (NULL != invisible.placeholder) {
228 free(invisible.placeholder);
229 invisible.placeholder = NULL;
230 }
231}
232
233/************************************************************************/
236static void packhand_init(void)
237{
239
240 invisible.cities = city_list_new();
241
242 /* Can't use player_new() here, as it will register the player. */
243 invisible.placeholder = fc_calloc(1, sizeof(*invisible.placeholder));
244 memset(invisible.placeholder, 0, sizeof(*invisible.placeholder));
245 /* Set some values to prevent bugs ... */
246 sz_strlcpy(invisible.placeholder->name, ANON_PLAYER_NAME);
247 sz_strlcpy(invisible.placeholder->username, _(ANON_USER_NAME));
248 invisible.placeholder->unassigned_user = TRUE;
249 sz_strlcpy(invisible.placeholder->ranked_username, ANON_USER_NAME);
250 invisible.placeholder->unassigned_ranked = TRUE;
251}
252
253/************************************************************************/
261static struct unit *unpackage_unit(const struct packet_unit_info *packet)
262{
264 NULL,
265 utype_by_number(packet->type),
266 packet->veteran);
267
268 /* Owner, veteran, and type fields are already filled in by
269 * unit_virtual_create() */
270 if (!has_capability("ids32", client.conn.capability)) {
271 punit->id = packet->id16;
272 punit->homecity = packet->homecity16;
273 if (packet->transported) {
275 } else {
277 }
278 } else {
279 punit->id = packet->id32;
280 punit->homecity = packet->homecity32;
281 if (packet->transported) {
283 } else {
285 }
286 }
287
290 punit->facing = packet->facing;
292 punit->upkeep[o] = packet->upkeep[o];
294 punit->moves_left = packet->movesleft;
295 punit->hp = packet->hp;
296 punit->activity = packet->activity;
298
299 if (packet->activity_tgt == EXTRA_NONE) {
300 punit->activity_target = NULL;
301 } else {
303 }
304
307
308 if (packet->changed_from_tgt == EXTRA_NONE) {
310 } else {
312 }
313
315 punit->fuel = packet->fuel;
317 punit->paradropped = packet->paradropped;
318 punit->done_moving = packet->done_moving;
319 punit->stay = packet->stay;
320
321 /* Transporter / transporting information. */
322 punit->client.occupied = packet->occupied;
323 if (packet->carrying >= 0) {
325 } else {
326 punit->carrying = NULL;
327 }
328
329 punit->battlegroup = packet->battlegroup;
330 punit->has_orders = packet->has_orders;
331 punit->orders.length = packet->orders_length;
332 punit->orders.index = packet->orders_index;
333 punit->orders.repeat = packet->orders_repeat;
335 if (punit->has_orders) {
336 int i;
337
338 for (i = 0; i < packet->orders_length; i++) {
339 /* Just an assert. The client doesn't use the action data. */
341 || action_id_exists(packet->orders[i].action));
342 }
344 = fc_malloc(punit->orders.length * sizeof(*punit->orders.list));
345 memcpy(punit->orders.list, packet->orders,
346 punit->orders.length * sizeof(*punit->orders.list));
347 }
348
352
354
355 return punit;
356}
357
358/************************************************************************/
368static struct unit *
370{
372 NULL,
373 utype_by_number(packet->type),
374 0);
375
376 /* Owner and type fields are already filled in by unit_virtual_create() */
377 if (!has_capability("ids32", client.conn.capability)) {
378 punit->id = packet->id16;
379 if (packet->transported) {
381 } else {
383 }
384 } else {
385 punit->id = packet->id32;
386 if (packet->transported) {
388 } else {
390 }
391 }
392
394 punit->facing = packet->facing;
395 punit->nationality = NULL;
396 punit->veteran = packet->veteran;
397 punit->hp = packet->hp;
398 punit->activity = packet->activity;
399
400 if (packet->activity_tgt == EXTRA_NONE) {
401 punit->activity_target = NULL;
402 } else {
404 }
405
406 /* Transporter / transporting information. */
407 punit->client.occupied = packet->occupied;
408
409 return punit;
410}
411
412/************************************************************************/
416void handle_server_join_reply(bool you_can_join, const char *message,
417 const char *capability,
418 const char *challenge_file, int conn_id)
419{
420 const char *s_capability = client.conn.capability;
421
422 conn_set_capability(&client.conn, capability);
424
425 if (you_can_join) {
426 struct packet_client_info client_info;
427
428 log_verbose("join game accept:%s", message);
430 client.conn.id = conn_id;
431
434
435 if (get_client_page() == PAGE_MAIN
436 || get_client_page() == PAGE_NETWORK) {
437 set_client_page(PAGE_START);
438 }
439
440 client_info.gui = get_gui_type();
441#ifdef EMERGENCY_VERSION
442 client_info.emerg_version = EMERGENCY_VERSION;
443#else
444 client_info.emerg_version = 0;
445#endif
446 strncpy(client_info.distribution, FREECIV_DISTRIBUTOR,
447 sizeof(client_info.distribution));
448 send_packet_client_info(&client.conn, &client_info);
449
450 /* we could always use hack, verify we're local */
451#ifdef FREECIV_DEBUG
452 if (!hackless || is_server_running())
453#endif /* FREECIV_DEBUG */
454 {
455 send_client_wants_hack(challenge_file);
456 }
457
459 } else {
461 _("You were rejected from the game: %s"), message);
462 client.conn.id = -1; /* not in range of conn_info id */
463
464 if (auto_connect) {
465 log_normal(_("You were rejected from the game: %s"), message);
466 }
468
469 set_client_page(PAGE_MAIN);
470 }
471 if (strcmp(s_capability, our_capability) == 0) {
472 return;
473 }
474 output_window_printf(ftc_client, _("Client capability string: %s"),
476 output_window_printf(ftc_client, _("Server capability string: %s"),
477 s_capability);
478}
479
480/************************************************************************/
484void handle_city_remove(int city_id16, int city_id32)
485{
486 struct city *pcity;
487 bool need_menus_update;
488
489 if (!has_capability("ids32", client.conn.capability)) {
490 city_id32 = city_id16;
491 }
492
493 pcity = game_city_by_number(city_id32);
494
495 fc_assert_ret_msg(NULL != pcity, "Bad city %d.", city_id32);
496
497 need_menus_update = (NULL != get_focus_unit_on_tile(city_tile(pcity)));
498
499 agents_city_remove(pcity);
501 client_remove_city(pcity);
502
503 /* Update menus if the focus unit is on the tile. */
504 if (need_menus_update) {
505 menus_update();
506 }
507}
508
509/************************************************************************/
513void handle_unit_remove(int unit_id16, int unit_id32)
514{
515 struct unit *punit;
516 struct unit_list *cargos;
517 struct player *powner;
518 bool need_economy_report_update;
519
520 if (!has_capability("ids32", client.conn.capability)) {
521 unit_id32 = unit_id16;
522 }
523
524 punit = game_unit_by_number(unit_id32);
525
526 if (punit == NULL) {
527 log_error("Server wants us to remove unit id %d, "
528 "but we don't know about this unit!",
529 unit_id32);
530 return;
531 }
532
533 /* Close diplomat dialog if the diplomat is lost */
536 /* Open another action selection dialog if there are other actors in the
537 * current selection that want a decision. */
539 }
540
541 need_economy_report_update = (0 < punit->upkeep[O_GOLD]);
542 powner = unit_owner(punit);
543
544 /* Unload cargo if this is a transporter. */
545 cargos = unit_transport_cargo(punit);
546 if (unit_list_size(cargos) > 0) {
547 unit_list_iterate(cargos, pcargo) {
548 unit_transport_unload(pcargo);
550 }
551
552 /* Unload unit if it is transported. */
555 }
557
561
562 if (!client_has_player() || powner == client_player()) {
563 if (need_economy_report_update) {
565 }
567 }
568}
569
570/************************************************************************/
577
578/************************************************************************/
581void handle_team_name_info(int team_id, const char *team_name)
582{
583 struct team_slot *tslot = team_slot_by_number(team_id);
584
585 fc_assert_ret(NULL != tslot);
586 team_slot_set_defined_name(tslot, team_name);
588}
589
590/************************************************************************/
597{
598 bool show_combat = FALSE;
599 struct unit *punit0;
600 struct unit *punit1;
601 int attacker_unit_id;
602 int defender_unit_id;
603
604 if (!has_capability("ids32", client.conn.capability)) {
605 attacker_unit_id = packet->attacker_unit_id16;
606 defender_unit_id = packet->defender_unit_id16;
607 } else {
608 attacker_unit_id = packet->attacker_unit_id32;
609 defender_unit_id = packet->defender_unit_id32;
610 }
611
612 punit0 = game_unit_by_number(attacker_unit_id);
613 punit1 = game_unit_by_number(defender_unit_id);
614
615 if (punit0 && punit1) {
616 popup_combat_info(attacker_unit_id, defender_unit_id,
617 packet->attacker_hp, packet->defender_hp,
618 packet->make_att_veteran, packet->make_def_veteran);
620 && tile_visible_mapcanvas(unit_tile(punit1))) {
621 show_combat = TRUE;
623 if (unit_owner(punit0) == client.conn.playing) {
625 } else {
627 }
628 show_combat = TRUE;
629 }
630
631 if (show_combat) {
632 int hp0 = packet->attacker_hp, hp1 = packet->defender_hp;
633
634 audio_play_sound(unit_type_get(punit0)->sound_fight,
635 unit_type_get(punit0)->sound_fight_alt);
636 audio_play_sound(unit_type_get(punit1)->sound_fight,
637 unit_type_get(punit1)->sound_fight_alt);
638
640 decrease_unit_hp_smooth(punit0, hp0, punit1, hp1);
641 } else {
642 punit0->hp = hp0;
643 punit1->hp = hp1;
644
645 set_units_in_combat(NULL, NULL);
646 refresh_unit_mapcanvas(punit0, unit_tile(punit0), TRUE, FALSE);
647 refresh_unit_mapcanvas(punit1, unit_tile(punit1), TRUE, FALSE);
648 }
649 }
650 if (packet->make_att_veteran && punit0) {
651 punit0->veteran++;
652 refresh_unit_mapcanvas(punit0, unit_tile(punit0), TRUE, FALSE);
653 }
654 if (packet->make_def_veteran && punit1) {
655 punit1->veteran++;
656 refresh_unit_mapcanvas(punit1, unit_tile(punit1), TRUE, FALSE);
657 }
658 }
659}
660
661/************************************************************************/
667static bool update_improvement_from_packet(struct city *pcity,
668 struct impr_type *pimprove,
669 bool have_impr)
670{
671 if (have_impr) {
672 if (pcity->built[improvement_index(pimprove)].turn <= I_NEVER) {
673 city_add_improvement(pcity, pimprove);
674 return TRUE;
675 }
676 } else {
677 if (pcity->built[improvement_index(pimprove)].turn > I_NEVER) {
678 city_remove_improvement(pcity, pimprove);
679 return TRUE;
680 }
681 }
682 return FALSE;
683}
684
685/************************************************************************/
689void handle_city_info(const struct packet_city_info *packet)
690{
691 struct universal product;
692 int i;
693 bool popup;
694 bool city_is_new = FALSE;
695 bool city_has_changed_owner = FALSE;
696 bool need_science_dialog_update = FALSE;
697 bool need_units_dialog_update = FALSE;
698 bool need_economy_dialog_update = FALSE;
699 bool name_changed = FALSE;
700 bool update_descriptions = FALSE;
701 bool shield_stock_changed = FALSE;
702 bool production_changed = FALSE;
703 bool trade_routes_changed = FALSE;
704 struct unit_list *pfocus_units = get_units_in_focus();
705 struct city *pcity;
706 struct tile_list *worked_tiles = NULL;
707 struct tile *pcenter = index_to_tile(&(wld.map), packet->tile);
708 struct tile *ptile = NULL;
709 struct player *powner = player_by_number(packet->owner);
710 int city_id;
711
712 if (!has_capability("ids32", client.conn.capability)) {
713 city_id = packet->id16;
714 } else {
715 city_id = packet->id32;
716 }
717
718 pcity = game_city_by_number(city_id);
719
720 fc_assert_ret_msg(NULL != powner, "Bad player number %d.", packet->owner);
721 fc_assert_ret_msg(NULL != pcenter, "Invalid tile index %d.", packet->tile);
722
723 if (!universals_n_is_valid(packet->production_kind)) {
724 log_error("handle_city_info() bad production_kind %d.",
725 packet->production_kind);
726 product.kind = VUT_NONE;
727 } else {
728 product = universal_by_number(packet->production_kind,
729 packet->production_value);
730 if (!universals_n_is_valid(product.kind)) {
731 log_error("handle_city_info() "
732 "production_kind %d with bad production_value %d.",
733 packet->production_kind, packet->production_value);
734 product.kind = VUT_NONE;
735 }
736 }
737
738 if (NULL != pcity) {
739 ptile = city_tile(pcity);
740
741 if (NULL == ptile) {
742 /* Invisible worked city */
743 city_list_remove(invisible.cities, pcity);
744 city_is_new = TRUE;
745
746 pcity->tile = pcenter;
747 ptile = pcenter;
748 pcity->owner = powner;
749 } else if (city_owner(pcity) != powner) {
750 /* Remember what were the worked tiles. The server won't
751 * send them to us again. */
753 ptile, pworked, _index, _x, _y) {
754 if (pcity == tile_worked(pworked)) {
755 if (NULL == worked_tiles) {
756 worked_tiles = tile_list_new();
757 }
758 tile_list_append(worked_tiles, pworked);
759 }
761 client_remove_city(pcity);
762 pcity = NULL;
763 city_has_changed_owner = TRUE;
764 }
765 }
766
767 if (NULL == pcity) {
768 city_is_new = TRUE;
769 pcity = create_city_virtual(powner, pcenter, packet->name);
770 pcity->id = city_id;
771 idex_register_city(&wld, pcity);
772 update_descriptions = TRUE;
773 } else if (pcity->id != city_id) {
774 log_error("handle_city_info() city id %d != id %d.",
775 pcity->id, city_id);
776 return;
777 } else if (ptile != pcenter) {
778 log_error("handle_city_info() city tile (%d, %d) != (%d, %d).",
779 TILE_XY(ptile), TILE_XY(pcenter));
780 return;
781 } else {
782 name_changed = (0 != strncmp(packet->name, pcity->name,
784
785 while (trade_route_list_size(pcity->routes) > packet->trade_route_count) {
786 struct trade_route *proute = trade_route_list_get(pcity->routes, -1);
787
788 trade_route_list_remove(pcity->routes, proute);
789 FC_FREE(proute);
790 trade_routes_changed = TRUE;
791 }
792
793 /* Descriptions should probably be updated if the
794 * city name, production or time-to-grow changes.
795 * Note that if either the food stock or surplus
796 * have changed, the time-to-grow is likely to
797 * have changed as well. */
798 update_descriptions = (gui_options.draw_city_names && name_changed)
800 && (!are_universals_equal(&pcity->production, &product)
801 || pcity->surplus[O_SHIELD] != packet->surplus[O_SHIELD]
802 || pcity->shield_stock != packet->shield_stock))
804 && (pcity->food_stock != packet->food_stock
805 || pcity->surplus[O_FOOD] != packet->surplus[O_FOOD]))
806 || (gui_options.draw_city_trade_routes && trade_routes_changed);
807
808 city_name_set(pcity, packet->name);
809 }
810
811 if (has_capability("city-original", client.conn.capability)) {
812 pcity->original = player_by_number(packet->original);
813 } else {
814 pcity->original = NULL;
815 }
816
817 /* Check data */
818 city_size_set(pcity, 0);
819 for (i = 0; i < FEELING_LAST; i++) {
820 pcity->feel[CITIZEN_HAPPY][i] = packet->ppl_happy[i];
821 pcity->feel[CITIZEN_CONTENT][i] = packet->ppl_content[i];
822 pcity->feel[CITIZEN_UNHAPPY][i] = packet->ppl_unhappy[i];
823 pcity->feel[CITIZEN_ANGRY][i] = packet->ppl_angry[i];
824 }
825 for (i = 0; i < CITIZEN_LAST; i++) {
826 city_size_add(pcity, pcity->feel[i][FEELING_FINAL]);
827 }
829 pcity->specialists[sp] = packet->specialists[sp];
830 city_size_add(pcity, pcity->specialists[sp]);
832
833 if (city_size_get(pcity) != packet->size) {
834 log_error("handle_city_info() "
835 "%d citizens not equal %d city size in \"%s\".",
836 city_size_get(pcity), packet->size, city_name_get(pcity));
837 city_size_set(pcity, packet->size);
838 }
839
840 pcity->history = packet->history;
841 pcity->client.culture = packet->culture;
842 pcity->client.buy_cost = packet->buy_cost;
843
844 pcity->city_radius_sq = packet->city_radius_sq;
845
846 pcity->city_options = packet->city_options;
847
848 if (pcity->surplus[O_SCIENCE] != packet->surplus[O_SCIENCE]
849 || pcity->surplus[O_SCIENCE] != packet->surplus[O_SCIENCE]
850 || pcity->waste[O_SCIENCE] != packet->waste[O_SCIENCE]
851 || (pcity->unhappy_penalty[O_SCIENCE]
852 != packet->unhappy_penalty[O_SCIENCE])
853 || pcity->prod[O_SCIENCE] != packet->prod[O_SCIENCE]
854 || pcity->citizen_base[O_SCIENCE] != packet->citizen_base[O_SCIENCE]
855 || pcity->usage[O_SCIENCE] != packet->usage[O_SCIENCE]) {
856 need_science_dialog_update = TRUE;
857 }
858
859 pcity->food_stock=packet->food_stock;
860 if (pcity->shield_stock != packet->shield_stock) {
861 shield_stock_changed = TRUE;
862 pcity->shield_stock = packet->shield_stock;
863 }
864 pcity->pollution = packet->pollution;
865 pcity->illness_trade = packet->illness_trade;
866
867 if (!are_universals_equal(&pcity->production, &product)) {
868 production_changed = TRUE;
869 }
870 /* Need to consider shield stock/surplus for unit dialog as used build
871 * slots may change, affecting number of "in-progress" units. */
872 if ((city_is_new && VUT_UTYPE == product.kind)
873 || (production_changed && (VUT_UTYPE == pcity->production.kind
874 || VUT_UTYPE == product.kind))
875 || pcity->surplus[O_SHIELD] != packet->surplus[O_SHIELD]
876 || shield_stock_changed) {
877 need_units_dialog_update = TRUE;
878 }
879 pcity->production = product;
880
882 pcity->surplus[o] = packet->surplus[o];
883 pcity->waste[o] = packet->waste[o];
884 pcity->unhappy_penalty[o] = packet->unhappy_penalty[o];
885 pcity->prod[o] = packet->prod[o];
886 pcity->citizen_base[o] = packet->citizen_base[o];
887 pcity->usage[o] = packet->usage[o];
889
890#ifdef DONE_BY_create_city_virtual
891 if (city_is_new) {
892 worklist_init(&pcity->worklist);
893
894 for (i = 0; i < ARRAY_SIZE(pcity->built); i++) {
895 pcity->built[i].turn = I_NEVER;
896 }
897 }
898#endif /* DONE_BY_create_city_virtual */
899
900 worklist_copy(&pcity->worklist, &packet->worklist);
901
902 pcity->airlift = packet->airlift;
903 pcity->did_buy=packet->did_buy;
904 pcity->did_sell=packet->did_sell;
905 pcity->was_happy=packet->was_happy;
906
907 pcity->turn_founded = packet->turn_founded;
908 pcity->turn_last_built = packet->turn_last_built;
909
910 if (!universals_n_is_valid(packet->changed_from_kind)) {
911 log_error("handle_city_info() bad changed_from_kind %d.",
912 packet->changed_from_kind);
913 product.kind = VUT_NONE;
914 } else {
915 product = universal_by_number(packet->changed_from_kind,
916 packet->changed_from_value);
917 if (!universals_n_is_valid(product.kind)) {
918 log_error("handle_city_info() bad changed_from_value %d.",
919 packet->changed_from_value);
920 product.kind = VUT_NONE;
921 }
922 }
923 pcity->changed_from = product;
924
927 pcity->caravan_shields=packet->caravan_shields;
929
930 improvement_iterate(pimprove) {
931 bool have = BV_ISSET(packet->improvements, improvement_index(pimprove));
932
933 if (have && !city_is_new
934 && pcity->built[improvement_index(pimprove)].turn <= I_NEVER) {
935 audio_play_sound(pimprove->soundtag, pimprove->soundtag_alt);
936 }
937 need_economy_dialog_update |=
938 update_improvement_from_packet(pcity, pimprove, have);
940
941 /* We should be able to see units in the city. But for a diplomat
942 * investigating an enemy city we can't. In that case we don't update
943 * the occupied flag at all: it's already been set earlier and we'll
944 * get an update if it changes. */
946 pcity->client.occupied
947 = (unit_list_size(pcity->tile->units) > 0);
948 }
949
950 pcity->client.walls = packet->walls;
951 if (pcity->client.walls > NUM_WALL_TYPES) {
952 pcity->client.walls = NUM_WALL_TYPES;
953 }
954 pcity->style = packet->style;
955 pcity->capital = packet->capital;
956 if (packet->capital == CAPITAL_PRIMARY) {
957 powner->primary_capital_id = pcity->id;
958 } else if (powner->primary_capital_id == pcity->id) {
959 powner->primary_capital_id = 0;
960 }
961 pcity->client.city_image = packet->city_image;
962 pcity->steal = packet->steal;
963
964 pcity->client.happy = city_happy(pcity);
965 pcity->client.unhappy = city_unhappy(pcity);
966
967 popup = (city_is_new && can_client_change_view()
968 && powner == client.conn.playing
970 || packet->diplomat_investigate;
971
972 city_packet_common(pcity, pcenter, powner, worked_tiles,
973 city_is_new, popup, packet->diplomat_investigate);
974
975 if (city_is_new && !city_has_changed_owner) {
976 agents_city_new(pcity);
977 } else {
978 agents_city_changed(pcity);
979 }
980
981 /* Update the description if necessary. */
982 if (update_descriptions) {
984 }
985
986 /* Update focus unit info label if necessary. */
987 if (name_changed) {
988 unit_list_iterate(pfocus_units, pfocus_unit) {
989 if (pfocus_unit->homecity == pcity->id) {
990 update_unit_info_label(pfocus_units);
991 break;
992 }
994 }
995
996 /* Update the science dialog if necessary. */
997 if (need_science_dialog_update) {
999 }
1000
1001 /* Update the units dialog if necessary. */
1002 if (need_units_dialog_update) {
1004 }
1005
1006 /* Update the economy dialog if necessary. */
1007 if (need_economy_dialog_update) {
1009 }
1010
1011 /* Update the panel text (including civ population). */
1013
1014 /* Update caravan dialog */
1015 if ((production_changed || shield_stock_changed)
1016 && action_selection_target_city() == pcity->id) {
1017 int acid = action_selection_actor_unit();
1018 int tgtid = action_selection_target_unit();
1019
1021 acid, acid,
1022 tgtid, tgtid,
1023 city_tile(pcity)->index,
1026 }
1027
1029 && (trade_routes_changed
1030 || (city_is_new && 0 < city_num_trade_routes(pcity)))) {
1032 }
1033}
1034
1035/************************************************************************/
1040void handle_web_city_info_addition(int id16, int id32, int granary_size,
1041 int granary_turns)
1042{
1043}
1044
1045/************************************************************************/
1049{
1050 struct city *pcity;
1051
1052 if (!has_capability("ids32", client.conn.capability)) {
1053 pcity = game_city_by_number(packet->id16);
1054 } else {
1055 pcity = game_city_by_number(packet->id32);
1056 }
1057
1058 /* The nationality of the citizens. */
1059 if (pcity != NULL && game.info.citizen_nationality) {
1060 int i;
1061
1062 citizens_init(pcity);
1063 for (i = 0; i < packet->nationalities_count; i++) {
1065 packet->nation_citizens[i]);
1066 }
1067 fc_assert(citizens_count(pcity) == city_size_get(pcity));
1068 }
1069}
1070
1071/************************************************************************/
1075{
1076 struct city *pcity;
1077
1078 if (!has_capability("ids32", client.conn.capability)) {
1079 pcity = game_city_by_number(packet->city_id16);
1080 } else {
1081 pcity = game_city_by_number(packet->city_id32);
1082 }
1083
1084 if (pcity != NULL) {
1085 city_rally_point_receive(packet, pcity);
1086 }
1087}
1088
1089/************************************************************************/
1094static void city_packet_common(struct city *pcity, struct tile *pcenter,
1095 struct player *powner,
1096 struct tile_list *worked_tiles,
1097 bool is_new, bool popup, bool investigate)
1098{
1099 if (NULL != worked_tiles) {
1100 /* We need to transfer the worked infos because the server will assume
1101 * those infos are kept in our side and won't send to us again. */
1102 tile_list_iterate(worked_tiles, pwork) {
1103 tile_set_worked(pwork, pcity);
1105 tile_list_destroy(worked_tiles);
1106 }
1107
1108 if (is_new) {
1109 tile_set_worked(pcenter, pcity); /* is_free_worked() */
1110 city_list_prepend(powner->cities, pcity);
1111
1112 if (client_is_global_observer() || powner == client_player()) {
1114 }
1115
1116 players_iterate(pp) {
1117 unit_list_iterate(pp->units, punit) {
1118 if (punit->homecity == pcity->id) {
1119 unit_list_prepend(pcity->units_supported, punit);
1120 }
1123
1125 } else {
1126 if (client_is_global_observer() || powner == client_player()) {
1128 }
1129 }
1130
1131 if (can_client_change_view()) {
1132 refresh_city_mapcanvas(pcity, pcenter, FALSE, FALSE);
1133 }
1134
1135 if (city_workers_display == pcity) {
1136 city_workers_display = NULL;
1137 }
1138
1139 if (investigate) {
1140 /* Commit the collected supported and present units. */
1141 if (pcity->client.collecting_info_units_supported != NULL) {
1142 /* We got units, let's move the unit lists. */
1144
1145 unit_list_destroy(pcity->client.info_units_present);
1146 pcity->client.info_units_present =
1149
1150 unit_list_destroy(pcity->client.info_units_supported);
1154 } else {
1155 /* We didn't get any unit, let's clear the unit lists. */
1157
1158 unit_list_clear(pcity->client.info_units_supported);
1159 unit_list_clear(pcity->client.info_units_present);
1160 }
1161 }
1162
1163 if (popup
1164 && NULL != client.conn.playing
1167 menus_update();
1168 if (!city_dialog_is_open(pcity)) {
1169 popup_city_dialog(pcity);
1170 }
1171 }
1172
1173 if (!is_new
1174 && (popup || can_player_see_city_internals(client.conn.playing, pcity))) {
1175 refresh_city_dialog(pcity);
1176 }
1177
1178 /* update menus if the focus unit is on the tile. */
1179 if (get_focus_unit_on_tile(pcenter)) {
1180 menus_update();
1181 }
1182
1183 if (is_new) {
1184 log_debug("(%d,%d) creating city %d, %s %s", TILE_XY(pcenter),
1185 pcity->id, nation_rule_name(nation_of_city(pcity)),
1186 city_name_get(pcity));
1187 }
1188
1190}
1191
1192/************************************************************************/
1197{
1198 struct city *pcity;
1199 struct trade_route *proute;
1200 bool city_changed = FALSE;
1201 int partner;
1202
1203 if (!has_capability("ids32", client.conn.capability)) {
1204 pcity = game_city_by_number(packet->city16);
1205 partner = packet->partner16;
1206 } else {
1207 pcity = game_city_by_number(packet->city32);
1208 partner = packet->partner32;
1209 }
1210
1211 if (pcity == NULL) {
1212 return;
1213 }
1214
1215 proute = trade_route_list_get(pcity->routes, packet->index);
1216 if (proute == NULL) {
1217 fc_assert(trade_route_list_size(pcity->routes) == packet->index);
1218
1219 proute = fc_malloc(sizeof(struct trade_route));
1220 trade_route_list_append(pcity->routes, proute);
1222 }
1223
1224 proute->partner = partner;
1225 proute->value = packet->value;
1226 proute->dir = packet->direction;
1227 proute->goods = goods_by_number(packet->goods);
1228
1232 }
1233}
1234
1235/************************************************************************/
1241{
1242 bool city_has_changed_owner = FALSE;
1243 bool city_is_new = FALSE;
1244 bool name_changed = FALSE;
1245 bool update_descriptions = FALSE;
1246 struct city *pcity;
1247 struct tile *pcenter = index_to_tile(&(wld.map), packet->tile);
1248 struct tile *ptile = NULL;
1249 struct tile_list *worked_tiles = NULL;
1250 struct player *powner = player_by_number(packet->owner);
1251 int radius_sq = game.info.init_city_radius_sq;
1252 int city_id;
1253
1254 if (!has_capability("ids32", client.conn.capability)) {
1255 city_id = packet->id16;
1256 } else {
1257 city_id = packet->id32;
1258 }
1259
1260 pcity = game_city_by_number(city_id);
1261
1262 fc_assert_ret_msg(NULL != powner, "Bad player number %d.", packet->owner);
1263 fc_assert_ret_msg(NULL != pcenter, "Invalid tile index %d.", packet->tile);
1264
1265 if (NULL != pcity) {
1266 ptile = city_tile(pcity);
1267
1268 if (NULL == ptile) {
1269 /* Invisible worked city */
1270 city_list_remove(invisible.cities, pcity);
1271 city_is_new = TRUE;
1272
1273 pcity->tile = pcenter;
1274 pcity->owner = powner;
1275 pcity->original = NULL;
1276
1277 whole_map_iterate(&(wld.map), wtile) {
1278 if (wtile->worked == pcity) {
1279 int dist_sq = sq_map_distance(pcenter, wtile);
1280
1281 if (dist_sq > city_map_radius_sq_get(pcity)) {
1282 city_map_radius_sq_set(pcity, dist_sq);
1283 }
1284 }
1286 } else if (city_owner(pcity) != powner) {
1287 /* Remember what were the worked tiles. The server won't
1288 * send to us again. */
1290 pworked, _index, _x, _y) {
1291 if (pcity == tile_worked(pworked)) {
1292 if (NULL == worked_tiles) {
1293 worked_tiles = tile_list_new();
1294 }
1295 tile_list_append(worked_tiles, pworked);
1296 }
1298 radius_sq = city_map_radius_sq_get(pcity);
1299 client_remove_city(pcity);
1300 pcity = NULL;
1301 city_has_changed_owner = TRUE;
1302 }
1303 }
1304
1305 if (NULL == pcity) {
1306 city_is_new = TRUE;
1307 pcity = create_city_virtual(powner, pcenter, packet->name);
1308 pcity->id = city_id;
1309 city_map_radius_sq_set(pcity, radius_sq);
1310 idex_register_city(&wld, pcity);
1311 } else if (pcity->id != city_id) {
1312 log_error("handle_city_short_info() city id %d != id %d.",
1313 pcity->id, city_id);
1314 return;
1315 } else if (city_tile(pcity) != pcenter) {
1316 log_error("handle_city_short_info() city tile (%d, %d) != (%d, %d).",
1317 TILE_XY(city_tile(pcity)), TILE_XY(pcenter));
1318 return;
1319 } else {
1320 name_changed = (0 != strncmp(packet->name, pcity->name,
1322
1323 /* Check if city descriptions should be updated */
1324 if (gui_options.draw_city_names && name_changed) {
1325 update_descriptions = TRUE;
1326 }
1327
1328 city_name_set(pcity, packet->name);
1329
1330 memset(pcity->feel, 0, sizeof(pcity->feel));
1331 memset(pcity->specialists, 0, sizeof(pcity->specialists));
1332 }
1333
1334 pcity->specialists[DEFAULT_SPECIALIST] = packet->size;
1335 city_size_set(pcity, packet->size);
1336
1337 /* We can't actually see the internals of the city, but the server tells
1338 * us this much. */
1339 if (pcity->client.occupied != packet->occupied) {
1340 pcity->client.occupied = packet->occupied;
1342 update_descriptions = TRUE;
1343 }
1344 }
1345 pcity->client.walls = packet->walls;
1346 if (pcity->client.walls > NUM_WALL_TYPES) {
1347 pcity->client.walls = NUM_WALL_TYPES;
1348 }
1349 pcity->style = packet->style;
1350 pcity->capital = packet->capital;
1351 if (packet->capital == CAPITAL_PRIMARY) {
1352 powner->primary_capital_id = pcity->id;
1353 } else if (powner->primary_capital_id == pcity->id) {
1354 powner->primary_capital_id = 0;
1355 }
1356 pcity->client.city_image = packet->city_image;
1357
1358 pcity->client.happy = packet->happy;
1359 pcity->client.unhappy = packet->unhappy;
1360
1361 improvement_iterate(pimprove) {
1362 /* Don't update the non-visible improvements, they could hide the
1363 * previously seen information about the city (diplomat investigation).
1364 */
1365 if (is_improvement_visible(pimprove)) {
1366 bool have = BV_ISSET(packet->improvements,
1367 improvement_index(pimprove));
1368 update_improvement_from_packet(pcity, pimprove, have);
1369 }
1371
1372 city_packet_common(pcity, pcenter, powner, worked_tiles,
1373 city_is_new, FALSE, FALSE);
1374
1375 if (city_is_new && !city_has_changed_owner) {
1376 agents_city_new(pcity);
1377 } else {
1378 agents_city_changed(pcity);
1379 }
1380
1381 /* Update the description if necessary. */
1382 if (update_descriptions) {
1384 }
1385}
1386
1387/************************************************************************/
1390void handle_worker_task(const struct packet_worker_task *packet)
1391{
1392 struct city *pcity;
1393 struct worker_task *ptask = NULL;
1394
1395 if (!has_capability("ids32", client.conn.capability)) {
1396 pcity = game_city_by_number(packet->city_id16);
1397 } else {
1398 pcity = game_city_by_number(packet->city_id32);
1399 }
1400
1401 if (pcity == NULL
1402 || (pcity->owner != client.conn.playing && !client_is_global_observer())) {
1403 return;
1404 }
1405
1406 worker_task_list_iterate(pcity->task_reqs, ptask_old) {
1407 if (tile_index(ptask_old->ptile) == packet->tile_id) {
1408 ptask = ptask_old;
1409 break;
1410 }
1412
1413 if (ptask == NULL) {
1414 if (packet->activity == ACTIVITY_LAST) {
1415 return;
1416 } else {
1417 ptask = fc_malloc(sizeof(struct worker_task));
1418 worker_task_list_append(pcity->task_reqs, ptask);
1419 }
1420 } else {
1421 if (packet->activity == ACTIVITY_LAST) {
1422 worker_task_list_remove(pcity->task_reqs, ptask);
1423 free(ptask);
1424 ptask = NULL;
1425 }
1426 }
1427
1428 if (ptask != NULL) {
1429 ptask->ptile = index_to_tile(&(wld.map), packet->tile_id);
1430 ptask->act = packet->activity;
1431 if (packet->tgt >= 0) {
1432 ptask->tgt = extra_by_number(packet->tgt);
1433 } else {
1434 ptask->tgt = NULL;
1435 }
1436 ptask->want = packet->want;
1437 }
1438
1439 if (ptask && !worker_task_is_sane(ptask)) {
1440 log_debug("Bad worker task");
1441 worker_task_list_remove(pcity->task_reqs, ptask);
1442 free(ptask);
1443 ptask = NULL;
1444 return;
1445 }
1446
1447 refresh_city_dialog(pcity);
1448}
1449
1450/************************************************************************/
1453void handle_new_year(int year, int fragments, int turn)
1454{
1455 game.info.year = year;
1456 game.info.fragment_count = fragments;
1457 /*
1458 * The turn was increased in handle_end_turn()
1459 */
1460 fc_assert(game.info.turn == turn);
1462
1465
1467 menus_update();
1468
1470
1471#if 0
1472 /* This information shouldn't be needed, but if it is this is the only
1473 * way we can get it. */
1474 if (NULL != client.conn.playing) {
1475 turn_gold_difference =
1476 client.conn.playing->economic.gold - last_turn_gold_amount;
1477 last_turn_gold_amount = client.conn.playing->economic.gold;
1478 }
1479#endif
1480
1483
1485 create_event(NULL, E_TURN_BELL, ftc_client,
1486 _("Start of turn %d"), game.info.turn);
1487 }
1488
1490
1491 if (last_turn != turn) {
1492 start_turn();
1493 last_turn = turn;
1494 }
1495}
1496
1497/************************************************************************/
1503{
1504 /* Messagewindow will contain events happened since our own phase ended,
1505 * so player of the first phase and last phase are in equal situation. */
1507}
1508
1509/************************************************************************/
1513void handle_start_phase(int phase)
1514{
1516 /* We are on detached state, let ignore this packet. */
1517 return;
1518 }
1519
1520 if (phase < 0
1521 || (game.info.phase_mode == PMT_PLAYERS_ALTERNATE
1522 && phase >= player_count())
1523 || (game.info.phase_mode == PMT_TEAMS_ALTERNATE
1524 && phase >= team_count())) {
1525 log_error("handle_start_phase() illegal phase %d.", phase);
1526 return;
1527 }
1528
1530
1531 game.info.phase = phase;
1532
1533 /* Possibly replace wait cursor with something else */
1534 if (phase == 0) {
1535 /* TODO: Have server set as busy also if switching phase
1536 * is taking long in a alternating phases mode. */
1538 }
1539
1540 if (NULL != client.conn.playing
1541 && is_player_phase(client.conn.playing, phase)) {
1544
1546
1550 }
1551
1553
1555 pcity->client.colored = FALSE;
1557
1561
1563 }
1564
1566}
1567
1568/************************************************************************/
1573{
1574 log_debug("handle_begin_turn()");
1575
1576 /* Server is still considered busy until it handles also the beginning
1577 * of the first phase. */
1578
1580}
1581
1582/************************************************************************/
1587{
1588 log_debug("handle_end_turn()");
1589
1590 /* Make sure wait cursor is in use */
1592
1594
1595 /*
1596 * The local idea of the game.info.turn is increased here since the
1597 * client will get unit updates (reset of move points for example)
1598 * between handle_end_turn() and handle_new_year(). These
1599 * unit updates will look like they did take place in the old turn
1600 * which is incorrect. If we get the authoritative information about
1601 * the game.info.turn in handle_new_year() we will check it.
1602 */
1603 game.info.turn++;
1604
1605 log_verbose(_("Beginning turn %d"), game.info.turn);
1606
1608}
1609
1610/************************************************************************/
1613void play_sound_for_event(enum event_type type)
1614{
1615 const char *sound_tag = get_event_tag(type);
1616
1617 if (sound_tag) {
1618 audio_play_sound(sound_tag, NULL);
1619 }
1620}
1621
1622/************************************************************************/
1626void handle_chat_msg(const struct packet_chat_msg *packet)
1627{
1628 handle_event(packet->message,
1629 index_to_tile(&(wld.map), packet->tile),
1630 packet->event,
1631 packet->turn,
1632 packet->phase,
1633 packet->conn_id);
1634}
1635
1636/************************************************************************/
1647{
1648 handle_event(packet->message,
1649 index_to_tile(&(wld.map), packet->tile),
1650 packet->event,
1651 packet->turn,
1652 packet->phase,
1653 packet->conn_id);
1654}
1655
1656/************************************************************************/
1661{
1662 popup_connect_msg(_("Welcome"), message);
1663}
1664
1665/************************************************************************/
1669void handle_server_info(const char *version_label, int major_version,
1670 int minor_version, int patch_version, int emerg_version)
1671{
1672 if (emerg_version > 0) {
1673 log_verbose("Server has version %d.%d.%d.%d%s",
1674 major_version, minor_version, patch_version, emerg_version,
1675 version_label);
1676 } else {
1677 log_verbose("Server has version %d.%d.%d%s",
1678 major_version, minor_version, patch_version, version_label);
1679 }
1680}
1681
1682/************************************************************************/
1685void handle_page_msg(const char *caption, const char *headline,
1686 enum event_type event, int len, int parts)
1687{
1688 if (!client_has_player()
1690 || event != E_BROADCAST_REPORT) {
1691 if (page_msg_report.parts > 0) {
1692 /* Previous one was never finished */
1693 free(page_msg_report.caption);
1694 free(page_msg_report.headline);
1695 free(page_msg_report.lines);
1696 }
1697 page_msg_report.len = len;
1698 page_msg_report.event = event;
1701 page_msg_report.parts = parts;
1702 page_msg_report.lines = fc_malloc(len + 1);
1703 page_msg_report.lines[0] = '\0';
1704
1705 if (parts == 0) {
1706 /* Empty report - handle as if last part was just received. */
1707 page_msg_report.parts = 1;
1709 }
1710 }
1711}
1712
1713/************************************************************************/
1717{
1718 if (page_msg_report.lines != NULL) {
1719 /* We have already decided to show the message at the time we got
1720 * the header packet. */
1722 page_msg_report.parts--;
1723
1724 if (page_msg_report.parts == 0) {
1725 /* This is the final part */
1727 page_msg_report.headline,
1728 page_msg_report.lines);
1730
1731 free(page_msg_report.caption);
1732 free(page_msg_report.headline);
1733 free(page_msg_report.lines);
1734 page_msg_report.lines = NULL;
1735 }
1736 }
1737}
1738
1739/************************************************************************/
1742void handle_unit_info(const struct packet_unit_info *packet)
1743{
1744 struct unit *punit;
1745
1746 punit = unpackage_unit(packet);
1750 }
1751}
1752
1753/**********************************************************************/
1759{
1762 if (utype_can_do_action(unit_type_get(punit), act_id)) {
1763 /* An auto action like auto attack could be legal. Check for those
1764 * at once so they won't have to wait for player focus. */
1766 punit->id, punit->id,
1769 EXTRA_NONE,
1771 return;
1772 }
1774 }
1775
1776 /* This should be done in the foreground */
1778}
1779
1780/************************************************************************/
1796static bool handle_unit_packet_common(struct unit *packet_unit)
1797{
1798 struct city *pcity;
1799 struct unit *punit;
1800 bool need_menus_update = FALSE;
1801 bool need_economy_report_update = FALSE;
1802 bool need_units_report_update = FALSE;
1803 bool repaint_unit = FALSE;
1804 bool repaint_city = FALSE; /* regards unit's homecity */
1805 struct tile *old_tile = NULL;
1806 bool check_focus = FALSE; /* conservative focus change */
1807 bool moved = FALSE;
1808 bool ret = FALSE;
1809
1810 punit = player_unit_by_number(unit_owner(packet_unit), packet_unit->id);
1811 if (!punit && game_unit_by_number(packet_unit->id)) {
1812 /* This means unit has changed owner. We deal with this here
1813 * by simply deleting the old one and creating a new one. */
1814 handle_unit_remove(packet_unit->id, packet_unit->id);
1815 }
1816
1817 if (punit) {
1818 /* In some situations, the size of repaint units require can change;
1819 * in particular, city-builder units sometimes get a potential-city
1820 * outline, but to speed up redraws we don't repaint this whole area
1821 * unnecessarily. We need to ensure that when the footprint shrinks,
1822 * old bits aren't left behind on the canvas.
1823 * If the current (old) status of the unit is such that it gets a large
1824 * repaint, as a special case, queue a large repaint immediately, to
1825 * schedule the correct amount/location to be redrawn; but rely on the
1826 * repaint being deferred until the unit is updated, so that what's
1827 * drawn reflects the new status (e.g., no city outline). */
1830 }
1831
1832 ret = TRUE;
1833 punit->activity_count = packet_unit->activity_count;
1835 if (punit->ssa_controller != packet_unit->ssa_controller) {
1836 punit->ssa_controller = packet_unit->ssa_controller;
1837 repaint_unit = TRUE;
1838 /* AI is set: may change focus */
1839 /* AI is cleared: keep focus */
1840 if (packet_unit->ssa_controller != SSA_NONE
1841 && unit_is_in_focus(punit)) {
1842 check_focus = TRUE;
1843 }
1844 }
1845
1846 if (punit->facing != packet_unit->facing) {
1847 punit->facing = packet_unit->facing;
1848 repaint_unit = TRUE;
1849 }
1850
1851 if (punit->activity != packet_unit->activity
1852 || punit->activity_target == packet_unit->activity_target
1853 || punit->client.transported_by != packet_unit->client.transported_by
1854 || punit->client.occupied != packet_unit->client.occupied
1855 || punit->has_orders != packet_unit->has_orders
1856 || punit->orders.repeat != packet_unit->orders.repeat
1857 || punit->orders.vigilant != packet_unit->orders.vigilant
1858 || punit->orders.index != packet_unit->orders.index) {
1859
1860 /*** Change in activity or activity's target. ***/
1861
1862 /* May change focus if focus unit gets a new activity.
1863 * But if new activity is Idle, it means user specifically selected
1864 * the unit */
1866 && (packet_unit->activity != ACTIVITY_IDLE
1867 || packet_unit->has_orders)) {
1868 check_focus = TRUE;
1869 }
1870
1871 repaint_unit = TRUE;
1872
1873 /* Wakeup Focus */
1875 && NULL != client.conn.playing
1878 && punit->activity == ACTIVITY_SENTRY
1879 && packet_unit->activity == ACTIVITY_IDLE
1882 /* many wakeup units per tile are handled */
1884 check_focus = FALSE; /* and keep it */
1885 }
1886
1887 punit->activity = packet_unit->activity;
1888 punit->activity_target = packet_unit->activity_target;
1889
1891 != packet_unit->client.transported_by) {
1892 if (packet_unit->client.transported_by == -1) {
1893 /* The unit was unloaded from its transport. The check for a new
1894 * transport is done below. */
1896 }
1897
1899 }
1900
1901 if (punit->client.occupied != packet_unit->client.occupied) {
1902 if (get_focus_unit_on_tile(unit_tile(packet_unit))) {
1903 /* Special case: (un)loading a unit in a transporter on the same
1904 *tile as the focus unit may (dis)allow the focus unit to be
1905 * loaded. Thus the orders->(un)load menu item needs updating. */
1906 need_menus_update = TRUE;
1907 }
1908 punit->client.occupied = packet_unit->client.occupied;
1909 }
1910
1911 punit->has_orders = packet_unit->has_orders;
1912 punit->orders.length = packet_unit->orders.length;
1913 punit->orders.index = packet_unit->orders.index;
1914 punit->orders.repeat = packet_unit->orders.repeat;
1915 punit->orders.vigilant = packet_unit->orders.vigilant;
1916
1917 /* We cheat by just stealing the packet unit's list. */
1918 if (punit->orders.list) {
1919 free(punit->orders.list);
1920 }
1921 punit->orders.list = packet_unit->orders.list;
1922 packet_unit->orders.list = NULL;
1923
1924 if (NULL == client.conn.playing
1927 }
1928 } /*** End of Change in activity or activity's target. ***/
1929
1930 /* These two lines force the menus to be updated as appropriate when
1931 * the focus unit changes. */
1932 if (unit_is_in_focus(punit)) {
1933 need_menus_update = TRUE;
1934 }
1935
1936 if (punit->homecity != packet_unit->homecity) {
1937 /* change homecity */
1938 struct city *hcity;
1939
1940 if ((hcity = game_city_by_number(punit->homecity))) {
1941 unit_list_remove(hcity->units_supported, punit);
1942 refresh_city_dialog(hcity);
1943 }
1944
1945 punit->homecity = packet_unit->homecity;
1946 if ((hcity = game_city_by_number(punit->homecity))) {
1947 unit_list_prepend(hcity->units_supported, punit);
1948 repaint_city = TRUE;
1949 }
1950
1951 /* This can change total upkeep figures */
1952 need_units_report_update = TRUE;
1953 }
1954
1955 if (punit->hp != packet_unit->hp) {
1956 /* hp changed */
1957 punit->hp = packet_unit->hp;
1958 repaint_unit = TRUE;
1959 }
1960
1961 if (punit->utype != unit_type_get(packet_unit)) {
1962 /* Unit type has changed (been upgraded) */
1963 struct city *ccity = tile_city(unit_tile(punit));
1964
1965 punit->utype = unit_type_get(packet_unit);
1966 repaint_unit = TRUE;
1967 repaint_city = TRUE;
1968 if (ccity != NULL && (ccity->id != punit->homecity)) {
1969 refresh_city_dialog(ccity);
1970 }
1971 if (unit_is_in_focus(punit)) {
1972 /* Update the orders menu -- the unit might have new abilities */
1973 need_menus_update = TRUE;
1974 }
1975 need_units_report_update = TRUE;
1976 }
1977
1978 /* May change focus if an attempted move or attack exhausted unit */
1979 if (punit->moves_left != packet_unit->moves_left
1980 && unit_is_in_focus(punit)) {
1981 check_focus = TRUE;
1982 }
1983
1984 if (!same_pos(unit_tile(punit), unit_tile(packet_unit))) {
1985 /*** Change position ***/
1986 struct city *ccity = tile_city(unit_tile(punit));
1987
1988 old_tile = unit_tile(punit);
1989 moved = TRUE;
1990
1991 /* Show where the unit is going. */
1992 do_move_unit(punit, packet_unit);
1993
1994 if (ccity != NULL) {
1996 /* Unit moved out of a city - update the occupied status. */
1997 bool new_occupied =
1998 (unit_list_size(ccity->tile->units) > 0);
1999
2000 if (ccity->client.occupied != new_occupied) {
2001 ccity->client.occupied = new_occupied;
2002 refresh_city_mapcanvas(ccity, ccity->tile, FALSE, FALSE);
2005 }
2006 }
2007 }
2008
2009 if (ccity->id == punit->homecity) {
2010 repaint_city = TRUE;
2011 } else {
2012 refresh_city_dialog(ccity);
2013 }
2014 }
2015
2016 if ((ccity = tile_city(unit_tile(punit)))) {
2018 /* Unit moved into a city - obviously it's occupied. */
2019 if (!ccity->client.occupied) {
2020 ccity->client.occupied = TRUE;
2021 refresh_city_mapcanvas(ccity, ccity->tile, FALSE, FALSE);
2024 }
2025 }
2026 }
2027
2028 if (ccity->id == punit->homecity) {
2029 repaint_city = TRUE;
2030 } else {
2031 refresh_city_dialog(ccity);
2032 }
2033 }
2034
2035 } /*** End of Change position. ***/
2036
2037 if (repaint_city || repaint_unit) {
2038 /* We repaint the city if the unit itself needs repainting or if
2039 * there is a special city-only redrawing to be done. */
2040 if ((pcity = game_city_by_number(punit->homecity))) {
2041 refresh_city_dialog(pcity);
2042 }
2043 if (repaint_unit && tile_city(unit_tile(punit))
2044 && tile_city(unit_tile(punit)) != pcity) {
2045 /* Refresh the city we're occupying too. */
2047 }
2048 }
2049
2050 need_economy_report_update = (punit->upkeep[O_GOLD]
2051 != packet_unit->upkeep[O_GOLD]);
2052 /* unit upkeep information */
2054 punit->upkeep[o] = packet_unit->upkeep[o];
2056
2057 punit->nationality = packet_unit->nationality;
2058 punit->veteran = packet_unit->veteran;
2059 punit->moves_left = packet_unit->moves_left;
2060 punit->fuel = packet_unit->fuel;
2061 punit->goto_tile = packet_unit->goto_tile;
2062 punit->paradropped = packet_unit->paradropped;
2063 punit->stay = packet_unit->stay;
2064 if (punit->done_moving != packet_unit->done_moving) {
2065 punit->done_moving = packet_unit->done_moving;
2066 check_focus = TRUE;
2067 }
2068 punit->carrying = packet_unit->carrying;
2069
2070 /* This won't change punit; it enqueues the call for later handling. */
2073
2074 if ((punit->action_decision_want != packet_unit->action_decision_want
2076 != packet_unit->action_decision_tile))
2077 && should_ask_server_for_actions(packet_unit)) {
2078 /* The unit wants the player to decide. */
2080 /* Pop up an action selection dialog if the unit has focus or give
2081 * the unit higher priority in the focus queue if not. */
2084 check_focus = TRUE;
2085 } else {
2086 /* Refresh already open action selection dialog. */
2087 int acid = action_selection_actor_unit();
2088 int tgtid = action_selection_target_unit();
2089
2091 acid, acid,
2092 tgtid, tgtid,
2093 tile_index(
2094 packet_unit->action_decision_tile),
2097 }
2098 }
2101 } else {
2102 /*** Create new unit ***/
2103 punit = packet_unit;
2105
2106 unit_list_prepend(unit_owner(punit)->units, punit);
2107 unit_list_prepend(unit_tile(punit)->units, punit);
2108
2110
2111 if ((pcity = game_city_by_number(punit->homecity))) {
2112 unit_list_prepend(pcity->units_supported, punit);
2113 }
2114
2115 log_debug("New %s %s id %d (%d %d) hc %d %s",
2119 (pcity ? city_name_get(pcity) : "(unknown)"));
2120
2121 repaint_unit = !unit_transported(punit);
2123
2124 /* Check if we should link cargo units.
2125 * (This might be necessary if the cargo info was sent to us before
2126 * this transporter.) */
2127 if (punit->client.occupied) {
2128 unit_list_iterate(unit_tile(punit)->units, aunit) {
2129 if (aunit->client.transported_by == punit->id) {
2130 fc_assert(aunit->transporter == NULL);
2132 }
2134 }
2135
2136 if ((pcity = tile_city(unit_tile(punit)))) {
2137 /* The unit is in a city - obviously it's occupied. */
2138 pcity->client.occupied = TRUE;
2139 }
2140
2142 /* The unit wants the player to decide. */
2144 check_focus = TRUE;
2145 }
2146
2147 need_units_report_update = TRUE;
2148 } /*** End of Create new unit ***/
2149
2150 fc_assert_ret_val(punit != NULL, ret);
2151
2152 /* Check if we have to load the unit on a transporter. */
2153 if (punit->client.transported_by != -1) {
2154 struct unit *ptrans
2156
2157 /* Load unit only if transporter is known by the client.
2158 * (If not, cargo will be loaded later when the transporter info is
2159 * sent to the client.) */
2160 if (ptrans && ptrans != unit_transport_get(punit)) {
2161 /* First, we have to unload the unit from its old transporter. */
2163 unit_transport_load(punit, ptrans, TRUE);
2164#ifdef DEBUG_TRANSPORT
2165 log_debug("load %s (ID: %d) onto %s (ID: %d)",
2167 unit_name_translation(ptrans), ptrans->id);
2168 } else if (ptrans && ptrans == unit_transport_get(punit)) {
2169 log_debug("%s (ID: %d) is loaded onto %s (ID: %d)",
2171 unit_name_translation(ptrans), ptrans->id);
2172 } else {
2173 log_debug("%s (ID: %d) is not loaded", unit_name_translation(punit),
2174 punit->id);
2175#endif /* DEBUG_TRANSPORT */
2176 }
2177 }
2178
2181 || (moved && get_focus_unit_on_tile(old_tile))) {
2183 /* Update (an possible active) unit select dialog. */
2185 }
2186
2187 if (repaint_unit) {
2189 }
2190
2191 if ((check_focus || get_num_units_in_focus() == 0)
2192 && NULL != client.conn.playing
2196 }
2197
2198 if (need_menus_update) {
2199 menus_update();
2200 }
2201
2203 if (need_economy_report_update) {
2205 }
2206 if (need_units_report_update) {
2208 }
2209 }
2210
2211 return ret;
2212}
2213
2214/************************************************************************/
2220void handle_investigate_started(int unit_id16, int unit_id32,
2221 int city_id16, int city_id32)
2222{
2223 struct city *pcity;
2224
2225 if (!has_capability("ids32", client.conn.capability)) {
2226 city_id32 = city_id16;
2227 /* Unit id not used by this function. */
2228 }
2229
2230 pcity = game_city_by_number(city_id32);
2231
2232 if (pcity == NULL) {
2233 log_error("Investigate city: unknown city id %d!",
2234 city_id32);
2235 return;
2236 }
2237
2238 /* Start collecting supported and present units. */
2239
2240 /* Ensure we are not already in an investigate cycle. */
2244 unit_list_new_full(unit_virtual_destroy);
2246 unit_list_new_full(unit_virtual_destroy);
2247}
2248
2249/************************************************************************/
2252void handle_investigate_finished(int unit_id16, int unit_id32,
2253 int city_id16, int city_id32)
2254{
2255}
2256
2257/************************************************************************/
2261{
2262 struct city *pcity;
2263 struct unit *punit;
2264 int info_city_id;
2265
2266 if (!has_capability("ids32", client.conn.capability)) {
2267 info_city_id = packet->info_city_id16;
2268 } else {
2269 info_city_id = packet->info_city_id32;
2270 }
2271
2272 /* Special case for a diplomat/spy investigating a city: The investigator
2273 * needs to know the supported and present units of a city, whether or not
2274 * they are fogged. So, we send a list of them all before sending the city
2275 * info. */
2277 || packet->packet_use == UNIT_INFO_CITY_PRESENT) {
2278 static int last_serial_num = 0;
2279
2280 pcity = game_city_by_number(info_city_id);
2281 if (!pcity) {
2282 log_error("Investigate city: unknown city id %d!",
2283 info_city_id);
2284 return;
2285 }
2286
2287 if (!has_capability("obsinv", client.conn.capability)) {
2288 /* New serial number: start collecting supported and present units. */
2289 if (last_serial_num
2291 last_serial_num =
2293 /* Ensure we are not already in an investigate cycle. */
2297 unit_list_new_full(unit_virtual_destroy);
2299 unit_list_new_full(unit_virtual_destroy);
2300 }
2301 }
2302
2303 /* Append a unit struct to the proper list. */
2304 punit = unpackage_short_unit(packet);
2305 if (packet->packet_use == UNIT_INFO_CITY_SUPPORTED) {
2306 if (pcity->client.collecting_info_units_supported != NULL) {
2307 unit_list_append(pcity->client.collecting_info_units_supported, punit);
2308 } else {
2309 /* pcity->client.collecting_info_units_supported should not be NULL,
2310 * but older servers never started the sequence for observers. */
2312 && client_is_observer()),
2313 "Supported units list NULL");
2314 }
2315 } else {
2317 if (pcity->client.collecting_info_units_present != NULL) {
2318 unit_list_append(pcity->client.collecting_info_units_present, punit);
2319 } else {
2320 /* pcity->client.collecting_info_units_present should not be NULL,
2321 * but older servers never started the sequence for observers. */
2323 && client_is_observer()),
2324 "Present units list NULL");
2325 }
2326 }
2327
2328 /* Done with special case. */
2329 return;
2330 }
2331
2332 if (player_by_number(packet->owner) == client.conn.playing) {
2333 log_error("handle_unit_short_info() for own unit.");
2334 }
2335
2336 punit = unpackage_short_unit(packet);
2340 }
2341}
2342
2343/************************************************************************/
2346void handle_set_topology(int topology_id)
2347{
2348 wld.map.topology_id = topology_id;
2349
2350 if (forced_tileset_name[0] == '\0'
2351 && (tileset_map_topo_compatible(topology_id, tileset, NULL)
2354 const char *ts_to_load;
2355
2356 ts_to_load = tileset_name_for_topology(topology_id);
2357
2358 if (ts_to_load != NULL && ts_to_load[0] != '\0' && strcmp(tileset_basename(tileset), ts_to_load)) {
2360 }
2361 }
2362}
2363
2364/************************************************************************/
2368void handle_map_info(int xsize, int ysize, int topology_id)
2369{
2370 int ts_topo;
2371
2372 if (!map_is_empty()) {
2373 map_free(&(wld.map));
2375 }
2376
2377 wld.map.xsize = xsize;
2378 wld.map.ysize = ysize;
2379
2380 if (tileset_map_topo_compatible(topology_id, tileset, &ts_topo) == TOPO_INCOMP_HARD) {
2382 _("Map topology (%s) and tileset (%s) incompatible."),
2383 describe_topology(topology_id), describe_topology(ts_topo));
2384 }
2385
2386 wld.map.topology_id = topology_id;
2387
2392 mapdeco_init();
2393
2395
2397
2398 packhand_init();
2399}
2400
2401/************************************************************************/
2404void handle_game_info(const struct packet_game_info *pinfo)
2405{
2406 bool boot_help;
2407 bool update_aifill_button = FALSE, update_ai_skill_level = FALSE;
2408 bool toggle_edit_ui = FALSE;
2409
2410 if (game.info.aifill != pinfo->aifill) {
2411 update_aifill_button = TRUE;
2412 }
2413 if (game.info.skill_level != pinfo->skill_level) {
2414 update_ai_skill_level = TRUE;
2415 }
2416
2417 if (game.info.is_edit_mode != pinfo->is_edit_mode) {
2418 toggle_edit_ui = TRUE;
2419
2421 /* Clears the current goto command. */
2423
2424 if (pinfo->is_edit_mode) {
2426 /* Gui didn't handle this */
2428 _("This scenario may have manually set properties the editor "
2429 "cannot handle."));
2431 _("They won't be saved when scenario is saved from the editor."));
2432 }
2433 }
2434 }
2435
2436 game.info = *pinfo;
2437
2438 /* check the values! */
2439#define VALIDATE(_count, _maximum, _string) \
2440 if (game.info._count > _maximum) { \
2441 log_error("handle_game_info(): Too many " _string "; using %d of %d", \
2442 _maximum, game.info._count); \
2443 game.info._count = _maximum; \
2444 }
2445
2446 VALIDATE(granary_num_inis, MAX_GRANARY_INIS, "granary entries");
2447#undef VALIDATE
2448
2453
2454 boot_help = (can_client_change_view()
2456 if (boot_help) {
2457 boot_help_texts(); /* reboot, after setting game.spacerace */
2458 }
2460 menus_update();
2462 if (update_aifill_button || update_ai_skill_level) {
2464 }
2465
2466 if (can_client_change_view()) {
2468 }
2469
2470 if (toggle_edit_ui) {
2472 }
2473
2475}
2476
2477/************************************************************************/
2480void handle_calendar_info(const struct packet_calendar_info *pcalendar)
2481{
2482 game.calendar = *pcalendar;
2483}
2484
2485/************************************************************************/
2488void handle_timeout_info(float seconds_to_phasedone, float last_turn_change_time)
2489{
2490 if (current_turn_timeout() != 0 && seconds_to_phasedone >= 0) {
2491 /* If this packet is received in the middle of a turn, this value
2492 * represents the number of seconds from now to the end of the turn
2493 * (not from the start of the turn). So we need to restart our
2494 * timer. */
2495 set_seconds_to_turndone(seconds_to_phasedone);
2496 }
2497
2498 game.tinfo.last_turn_change_time = last_turn_change_time;
2499}
2500
2501/************************************************************************/
2513
2514/************************************************************************/
2523
2524/************************************************************************/
2529void handle_player_remove(int playerno)
2530{
2531 struct player_slot *pslot;
2532 struct player *pplayer;
2533 int plr_nbr;
2534
2535 pslot = player_slot_by_number(playerno);
2536
2537 if (NULL == pslot || !player_slot_is_used(pslot)) {
2538 /* Ok, just ignore. */
2539 return;
2540 }
2541
2542 pplayer = player_slot_get_player(pslot);
2543
2544 if (can_client_change_view()) {
2545 close_intel_dialog(pplayer);
2546 }
2547
2548 /* Update the connection information. */
2549 if (client_player() == pplayer) {
2550 client.conn.playing = NULL;
2551 }
2552 conn_list_iterate(pplayer->connections, pconn) {
2553 pconn->playing = NULL;
2555 conn_list_clear(pplayer->connections);
2556
2557 /* Save player number before player is freed */
2558 plr_nbr = player_number(pplayer);
2559
2560 player_destroy(pplayer);
2561
2564
2567}
2568
2569/************************************************************************/
2575{
2576 bool is_new_nation = FALSE;
2577 bool turn_done_changed = FALSE;
2578 bool new_player = FALSE;
2579 int i;
2580 struct player *pplayer, *my_player;
2581 struct nation_type *pnation;
2582 struct government *pgov, *ptarget_gov;
2583 struct player_slot *pslot;
2584 struct team_slot *tslot;
2585
2586 /* Player. */
2587 pslot = player_slot_by_number(pinfo->playerno);
2588 fc_assert(NULL != pslot);
2589 new_player = !player_slot_is_used(pslot);
2590 pplayer = player_new(pslot);
2591
2592 if ((pplayer->rgb == NULL) != !pinfo->color_valid
2593 || (pinfo->color_valid
2594 && (pplayer->rgb->r != pinfo->color_red
2595 || pplayer->rgb->g != pinfo->color_green
2596 || pplayer->rgb->b != pinfo->color_blue))) {
2597 struct rgbcolor *prgbcolor;
2598
2599 if (pinfo->color_valid) {
2600 prgbcolor = rgbcolor_new(pinfo->color_red,
2601 pinfo->color_green,
2602 pinfo->color_blue);
2603 fc_assert_ret(prgbcolor != NULL);
2604 } else {
2605 prgbcolor = NULL;
2606 }
2607
2608 player_set_color(pplayer, prgbcolor);
2609 tileset_player_init(tileset, pplayer);
2610
2611 rgbcolor_destroy(prgbcolor);
2612
2613 /* Queue a map update -- may need to redraw borders, etc. */
2615 }
2616 pplayer->client.color_changeable = pinfo->color_changeable;
2617
2618 if (new_player) {
2619 /* Initialise client side player data (tile vision). At the moment
2620 * redundant as the values are initialised with 0 due to fc_calloc(). */
2621 client_player_init(pplayer);
2622 }
2623
2624 /* Team. */
2625 tslot = team_slot_by_number(pinfo->team);
2626 fc_assert(NULL != tslot);
2627
2628 /* Should never fail when slot given is not NULL */
2629 team_add_player(pplayer, team_new(tslot));
2630
2631 pnation = nation_by_number(pinfo->nation);
2632 pgov = government_by_number(pinfo->government);
2633 ptarget_gov = government_by_number(pinfo->target_government);
2634
2635 /* Now update the player information. */
2636 sz_strlcpy(pplayer->name, pinfo->name);
2637 sz_strlcpy(pplayer->username, pinfo->username);
2638 pplayer->unassigned_user = pinfo->unassigned_user;
2639
2640 is_new_nation = player_set_nation(pplayer, pnation);
2641 pplayer->is_male = pinfo->is_male;
2642 pplayer->score.game = pinfo->score;
2643 pplayer->was_created = pinfo->was_created;
2644
2645 pplayer->economic.gold = pinfo->gold;
2646 pplayer->economic.tax = pinfo->tax;
2647 pplayer->economic.science = pinfo->science;
2648 pplayer->economic.luxury = pinfo->luxury;
2649 if (has_capability("tu32", client.conn.capability)) {
2650 pplayer->client.tech_upkeep = pinfo->tech_upkeep_32;
2651 } else {
2652 pplayer->client.tech_upkeep = pinfo->tech_upkeep_16;
2653 }
2654 pplayer->government = pgov;
2655 pplayer->target_government = ptarget_gov;
2656 /* Don't use player_iterate here, because we ignore the real number
2657 * of players and we want to read all the datas. */
2658 BV_CLR_ALL(pplayer->real_embassy);
2659 fc_assert(8 * sizeof(pplayer->real_embassy)
2660 >= ARRAY_SIZE(pinfo->real_embassy));
2661 for (i = 0; i < ARRAY_SIZE(pinfo->real_embassy); i++) {
2662 if (pinfo->real_embassy[i]) {
2663 BV_SET(pplayer->real_embassy, i);
2664 }
2665 }
2666 pplayer->gives_shared_vision = pinfo->gives_shared_vision;
2667 pplayer->style = style_by_number(pinfo->style);
2668
2669 if (pplayer == client.conn.playing) {
2670 bool music_change = FALSE;
2671
2672 if (pplayer->music_style != pinfo->music_style) {
2673 pplayer->music_style = pinfo->music_style;
2674 music_change = TRUE;
2675 }
2676 if (pplayer->client.mood != pinfo->mood) {
2677 pplayer->client.mood = pinfo->mood;
2678 music_change = TRUE;
2679 }
2680
2681 if (music_change) {
2683 }
2684 }
2685
2686 pplayer->history = pinfo->history;
2687 pplayer->client.culture = pinfo->culture;
2688
2689 if (pplayer->economic.infra_points != pinfo->infrapoints) {
2690 pplayer->economic.infra_points = pinfo->infrapoints;
2692 }
2693
2694 /* Don't use player_iterate or player_slot_count here, because we ignore
2695 * the real number of players and we want to read all the datas. */
2696 fc_assert(ARRAY_SIZE(pplayer->ai_common.love) >= ARRAY_SIZE(pinfo->love));
2697 for (i = 0; i < ARRAY_SIZE(pinfo->love); i++) {
2698 pplayer->ai_common.love[i] = pinfo->love[i];
2699 }
2700
2701 my_player = client_player();
2702
2703 pplayer->is_connected = pinfo->is_connected;
2704
2705 for (i = 0; i < B_LAST; i++) {
2706 pplayer->wonders[i] = pinfo->wonders[i];
2707 }
2708
2709 /* Set AI.control. */
2710 if (is_ai(pplayer) != BV_ISSET(pinfo->flags, PLRF_AI)) {
2711 BV_SET_VAL(pplayer->flags, PLRF_AI, BV_ISSET(pinfo->flags, PLRF_AI));
2712 if (pplayer == my_player) {
2713 if (is_ai(my_player)) {
2714 output_window_append(ftc_client, _("AI mode is now ON."));
2715 if (!gui_options.ai_manual_turn_done && !pplayer->phase_done) {
2716 /* End turn immediately */
2718 }
2719 } else {
2720 output_window_append(ftc_client, _("AI mode is now OFF."));
2721 }
2722 }
2723 }
2724
2725 pplayer->flags = pinfo->flags;
2726
2727 pplayer->ai_common.science_cost = pinfo->science_cost;
2728
2729 turn_done_changed = (pplayer->phase_done != pinfo->phase_done
2730 || (BV_ISSET(pplayer->flags, PLRF_AI) !=
2731 BV_ISSET(pinfo->flags, PLRF_AI)));
2732 pplayer->phase_done = pinfo->phase_done;
2733
2734 pplayer->is_ready = pinfo->is_ready;
2735 pplayer->nturns_idle = pinfo->nturns_idle;
2736 pplayer->is_alive = pinfo->is_alive;
2737 pplayer->turns_alive = pinfo->turns_alive;
2738 pplayer->ai_common.barbarian_type = pinfo->barbarian_type;
2739 pplayer->revolution_finishes = pinfo->revolution_finishes;
2740 pplayer->ai_common.skill_level = pinfo->ai_skill_level;
2741
2744 multipliers_iterate(pmul) {
2745 int idx = multiplier_index(pmul);
2746
2747 pplayer->multipliers[idx].value = pinfo->multiplier[idx];
2748 pplayer->multipliers[idx].target = pinfo->multiplier_target[idx];
2749 pplayer->multipliers[idx].changed = pinfo->multiplier_changed[idx];
2751
2752 /* if the server requests that the client reset, then information about
2753 * connections to this player are lost. If this is the case, insert the
2754 * correct conn back into the player->connections list */
2755 if (conn_list_size(pplayer->connections) == 0) {
2757 if (pplayer == pconn->playing) {
2758 /* insert the controller into first position */
2759 if (pconn->observer) {
2760 conn_list_append(pplayer->connections, pconn);
2761 } else {
2762 conn_list_prepend(pplayer->connections, pconn);
2763 }
2764 }
2766 }
2767
2768
2769 /* The player information is now fully set. Update the GUI. */
2770
2771 if (pplayer == my_player && can_client_change_view()) {
2772 if (turn_done_changed) {
2774 }
2781 menus_update();
2782 }
2783
2785
2788
2789 if (is_new_nation) {
2791
2792 /* When changing nation during a running game, some refreshing is needed.
2793 * This may not be the only one! */
2795 }
2796
2797 if (can_client_change_view()) {
2798 /* Just about any changes above require an update to the intelligence
2799 * dialog. */
2800 update_intel_dialog(pplayer);
2801 }
2802
2805 FALSE);
2806}
2807
2808/************************************************************************/
2813void handle_web_player_info_addition(int playerno, int expected_income)
2814{
2815}
2816
2817/************************************************************************/
2821{
2822 struct research *presearch;
2823 bool tech_changed = FALSE;
2824 bool poptechup = FALSE;
2825 Tech_type_id gained_techs[advance_count()];
2826 int gained_techs_num = 0, i;
2827 enum tech_state newstate, oldstate;
2828
2829#ifdef FREECIV_DEBUG
2830 log_verbose("Research nb %d inventions: %s",
2831 packet->id,
2832 packet->inventions);
2833#endif
2834 presearch = research_by_number(packet->id);
2835 fc_assert_ret(NULL != presearch);
2836
2837 poptechup = (presearch->researching != packet->researching
2838 || presearch->tech_goal != packet->tech_goal);
2839 presearch->techs_researched = packet->techs_researched;
2840 if (presearch->future_tech == 0 && packet->future_tech > 0) {
2841 gained_techs[gained_techs_num++] = A_FUTURE;
2842 }
2843 presearch->future_tech = packet->future_tech;
2844 presearch->researching = packet->researching;
2845 presearch->client.researching_cost = packet->researching_cost;
2846 presearch->bulbs_researched = packet->bulbs_researched;
2847 presearch->tech_goal = packet->tech_goal;
2848 presearch->client.total_bulbs_prod = packet->total_bulbs_prod;
2849
2851 newstate = packet->inventions[advi] - '0';
2852 oldstate = research_invention_set(presearch, advi, newstate);
2853
2854 if (newstate != oldstate) {
2855 if (TECH_KNOWN == newstate) {
2856 tech_changed = TRUE;
2857 if (A_NONE != advi) {
2858 gained_techs[gained_techs_num++] = advi;
2859 }
2860 } else if (TECH_KNOWN == oldstate) {
2861 tech_changed = TRUE;
2862 }
2863 }
2865
2866 research_update(presearch);
2867
2868 if (C_S_RUNNING == client_state()) {
2869 if (presearch == research_get(client_player())) {
2870 if (poptechup && is_human(client_player())) {
2872 }
2874 if (tech_changed) {
2875 /* Some ways a new or lost tech can affect menus:
2876 * - If tech is needed for certain governments, the government
2877 * switching menus need updating.
2878 * - If we just learned/lost bridge building and focus is on a
2879 * worker on a river, the road menu item needs updating. */
2880 menus_update();
2881
2882 script_client_signal_emit("new_tech");
2883
2884 /* If we got a new tech the tech tree news an update. */
2886 }
2887 for (i = 0; i < gained_techs_num; i++) {
2888 show_tech_gained_dialog(gained_techs[i]);
2889 }
2890 }
2891 if (editor_is_active()) {
2893 research_players_iterate(presearch, pplayer) {
2895 FALSE);
2897 }
2898 }
2899}
2900
2901/************************************************************************/
2905{
2906 struct research *presearch = research_by_number(id);
2907
2908 if (presearch == NULL) {
2909 log_error("Received unknown research for clearing: %d.", id);
2910 return;
2911 }
2912
2913 /* Do we need to set other fields? */
2914 presearch->researching = A_UNKNOWN;
2915 presearch->future_tech = 0;
2916 presearch->tech_goal = A_UNKNOWN;
2917
2919 research_invention_set(presearch, advi, TECH_UNKNOWN);
2921
2922 if (editor_is_active()) {
2924 research_players_iterate(presearch, pplayer) {
2926 FALSE);
2928 }
2929}
2930
2931/************************************************************************/
2935{
2936 struct player *plr1 = player_by_number(packet->plr1);
2937 struct player *plr2 = player_by_number(packet->plr2);
2938 struct player *my_player = client_player();
2939 struct player_diplstate *ds = player_diplstate_get(plr1, plr2);
2940 bool need_players_dialog_update = FALSE;
2941
2942 fc_assert_ret(ds != NULL);
2943
2944 if (client_has_player() && my_player == plr2) {
2945 if (ds->type != packet->type) {
2946 need_players_dialog_update = TRUE;
2947 }
2948
2949 /* Check if we detect change to armistice with us. If so,
2950 * ready all units for movement out of the territory in
2951 * question; otherwise they will be disbanded. */
2952 if (DS_ARMISTICE != player_diplstate_get(plr1, my_player)->type
2953 && DS_ARMISTICE == packet->type) {
2954 unit_list_iterate(my_player->units, punit) {
2956 || tile_owner(unit_tile(punit)) != plr1) {
2957 continue;
2958 }
2961 }
2962 if (punit->activity != ACTIVITY_IDLE) {
2963 request_new_unit_activity(punit, ACTIVITY_IDLE);
2964 }
2966 }
2967 }
2968
2969 ds->type = packet->type;
2970 ds->turns_left = packet->turns_left;
2973
2974 if (need_players_dialog_update) {
2976 }
2977
2978 if (need_players_dialog_update
2980 /* An action selection dialog is open and our diplomatic state just
2981 * changed. Find out if the relationship that changed was to a
2982 * potential target. */
2983 struct tile *tgt_tile = NULL;
2984
2985 /* Is a refresh needed because of a unit target? */
2987 struct unit *tgt_unit;
2988
2990
2991 if (tgt_unit != NULL && tgt_unit->owner == plr1) {
2992 /* An update is needed because of this unit target. */
2993 tgt_tile = unit_tile(tgt_unit);
2994 fc_assert(tgt_tile != NULL);
2995 }
2996 }
2997
2998 /* Is a refresh needed because of a city target? */
3000 struct city *tgt_city;
3001
3003
3004 if (tgt_city != NULL && tgt_city->owner == plr1) {
3005 /* An update is needed because of this city target.
3006 * Overwrites any target tile from a unit. */
3007 tgt_tile = city_tile(tgt_city);
3008 fc_assert(tgt_tile != NULL);
3009 }
3010 }
3011
3012 if (tgt_tile
3013 || ((tgt_tile = index_to_tile(&(wld.map),
3015 && tile_owner(tgt_tile) == plr1)) {
3016 /* The diplomatic relationship to the target in an open action
3017 * selection dialog have changed. This probably changes
3018 * the set of available actions. */
3019 int acid = action_selection_actor_unit();
3020 int tgtid = action_selection_target_unit();
3021
3023 acid, acid,
3024 tgtid, tgtid,
3025 tgt_tile->index,
3028 }
3029 }
3030}
3031
3032/************************************************************************/
3038void handle_conn_info(const struct packet_conn_info *pinfo)
3039{
3040 struct connection *pconn = conn_by_number(pinfo->id);
3041 bool preparing_client_state = FALSE;
3042
3043 log_debug("conn_info id%d used%d est%d plr%d obs%d acc%d",
3044 pinfo->id, pinfo->used, pinfo->established, pinfo->player_num,
3045 pinfo->observer, (int) pinfo->access_level);
3046 log_debug("conn_info \"%s\" \"%s\" \"%s\"",
3047 pinfo->username, pinfo->addr, pinfo->capability);
3048
3049 if (!pinfo->used) {
3050 /* Forget the connection */
3051 if (!pconn) {
3052 log_verbose("Server removed unknown connection %d", pinfo->id);
3053 return;
3054 }
3056 pconn = NULL;
3057 } else {
3058 struct player_slot *pslot = player_slot_by_number(pinfo->player_num);
3059 struct player *pplayer = NULL;
3060
3061 if (NULL != pslot) {
3062 pplayer = player_slot_get_player(pslot);
3063 }
3064
3065 if (!pconn) {
3066 log_verbose("Server reports new connection %d %s",
3067 pinfo->id, pinfo->username);
3068
3069 pconn = fc_calloc(1, sizeof(struct connection));
3070 pconn->buffer = NULL;
3071 pconn->send_buffer = NULL;
3072 pconn->ping_time = -1.0;
3073 if (pplayer) {
3074 conn_list_append(pplayer->connections, pconn);
3075 }
3076 conn_list_append(game.all_connections, pconn);
3077 conn_list_append(game.est_connections, pconn);
3078 } else {
3079 log_packet("Server reports updated connection %d %s",
3080 pinfo->id, pinfo->username);
3081 if (pplayer != pconn->playing) {
3082 if (NULL != pconn->playing) {
3083 conn_list_remove(pconn->playing->connections, pconn);
3084 }
3085 if (pplayer) {
3086 conn_list_append(pplayer->connections, pconn);
3087 }
3088 }
3089 }
3090
3091 pconn->id = pinfo->id;
3092 pconn->established = pinfo->established;
3093 pconn->observer = pinfo->observer;
3094 pconn->access_level = pinfo->access_level;
3095 pconn->playing = pplayer;
3096
3097 sz_strlcpy(pconn->username, pinfo->username);
3098 sz_strlcpy(pconn->addr, pinfo->addr);
3099 sz_strlcpy(pconn->capability, pinfo->capability);
3100
3101 if (pinfo->id == client.conn.id) {
3102 /* NB: In this case, pconn is not a duplication of client.conn.
3103 *
3104 * pconn->addr is our address that the server knows whereas
3105 * client.conn.addr is the address to the server. Also,
3106 * pconn->capability stores our capabilites known at server side
3107 * whereas client.conn.capability represents the capabilities of the
3108 * server. */
3109 if (client.conn.playing != pplayer
3110 || client.conn.observer != pinfo->observer) {
3111 /* Our connection state changed, let prepare the changes and reset
3112 * the game. */
3113 preparing_client_state = TRUE;
3114 }
3115
3116 /* Copy our current state into the static structure (our connection
3117 * to the server). */
3119 client.conn.observer = pinfo->observer;
3121 client.conn.playing = pplayer;
3123 }
3124 }
3125
3128
3129 if (pinfo->used && pinfo->id == client.conn.id) {
3130 /* For updating the sensitivity of the "Edit Mode" menu item,
3131 * among other things. */
3132 menus_update();
3133 }
3134
3135 if (preparing_client_state) {
3137 }
3138}
3139
3140/************************************************************************/
3144void handle_conn_ping_info(int connections, const int *conn_id,
3145 const float *ping_time)
3146{
3147 int i;
3148
3149 for (i = 0; i < connections; i++) {
3150 struct connection *pconn = conn_by_number(conn_id[i]);
3151
3152 if (!pconn) {
3153 continue;
3154 }
3155
3156 pconn->ping_time = ping_time[i];
3157 log_debug("conn-id=%d, ping=%fs", pconn->id, pconn->ping_time);
3158 }
3159 /* The old_ping_time data is ignored. */
3160
3162}
3163
3164/************************************************************************/
3167void handle_achievement_info(int id, bool gained, bool first)
3168{
3169 struct achievement *pach;
3170
3171 if (id < 0 || id >= game.control.num_achievement_types) {
3172 log_error("Received illegal achievement info %d", id);
3173 return;
3174 }
3175
3176 pach = achievement_by_number(id);
3177
3178 if (gained) {
3180 } else {
3182 }
3183
3184 if (first) {
3185 pach->first = client_player();
3186 }
3187}
3188
3189/************************************************************************/
3204static bool spaceship_autoplace(struct player *pplayer,
3205 struct player_spaceship *ship)
3206{
3208 struct spaceship_component place;
3209
3210 if (next_spaceship_component(pplayer, ship, &place)) {
3212
3213 return TRUE;
3214 }
3215 }
3216
3217 return FALSE;
3218}
3219
3220/************************************************************************/
3224{
3225 struct player_spaceship *ship;
3226 struct player *pplayer = player_by_number(p->player_num);
3227
3228 fc_assert_ret_msg(NULL != pplayer, "Invalid player number %d.",
3229 p->player_num);
3230
3231 ship = &pplayer->spaceship;
3232 ship->state = p->sship_state;
3233 ship->structurals = p->structurals;
3234 ship->components = p->components;
3235 ship->modules = p->modules;
3236 ship->fuel = p->fuel;
3237 ship->propulsion = p->propulsion;
3238 ship->habitation = p->habitation;
3239 ship->life_support = p->life_support;
3240 ship->solar_panels = p->solar_panels;
3241 ship->launch_year = p->launch_year;
3242 ship->population = p->population;
3243 ship->mass = p->mass;
3244 ship->support_rate = p->support_rate;
3245 ship->energy_rate = p->energy_rate;
3246 ship->success_rate = p->success_rate;
3247 ship->travel_time = p->travel_time;
3248 ship->structure = p->structure;
3249
3250 if (pplayer != client_player()) {
3251 refresh_spaceship_dialog(pplayer);
3252 menus_update();
3253 return;
3254 }
3255
3256 if (!spaceship_autoplace(pplayer, ship)) {
3257 /* We refresh the dialog when the packet did *not* cause placing
3258 * of new part. That's because those cases where part is placed, are
3259 * followed by exactly one case where there's no more parts to place -
3260 * we want to refresh the dialog only when that last packet comes. */
3261 refresh_spaceship_dialog(pplayer);
3262 }
3263}
3264
3265/************************************************************************/
3268void handle_tile_info(const struct packet_tile_info *packet)
3269{
3270 enum known_type new_known;
3271 enum known_type old_known;
3272 bool known_changed = FALSE;
3273 bool tile_changed = FALSE;
3274 struct player *powner = player_by_number(packet->owner);
3275 struct player *eowner = player_by_number(packet->extras_owner);
3276 struct extra_type *presource = NULL;
3277 struct terrain *pterrain = terrain_by_number(packet->terrain);
3278 struct tile *ptile = index_to_tile(&(wld.map), packet->tile);
3279 int worked;
3280
3281 fc_assert_ret_msg(NULL != ptile, "Invalid tile index %d.", packet->tile);
3282 old_known = client_tile_get_known(ptile);
3283
3284 if (packet->resource != MAX_EXTRA_TYPES) {
3285 presource = extra_by_number(packet->resource);
3286 }
3287
3288 if (NULL == tile_terrain(ptile) || pterrain != tile_terrain(ptile)) {
3289 tile_changed = TRUE;
3290 switch (old_known) {
3291 case TILE_UNKNOWN:
3292 tile_set_terrain(ptile, pterrain);
3293 break;
3294 case TILE_KNOWN_UNSEEN:
3295 case TILE_KNOWN_SEEN:
3296 if (NULL != pterrain || TILE_UNKNOWN == packet->known) {
3297 tile_set_terrain(ptile, pterrain);
3298 } else {
3299 tile_changed = FALSE;
3300 log_error("handle_tile_info() unknown terrain (%d, %d).",
3301 TILE_XY(ptile));
3302 }
3303 break;
3304 };
3305 }
3306
3307 if (!BV_ARE_EQUAL(ptile->extras, packet->extras)) {
3308 ptile->extras = packet->extras;
3309 tile_changed = TRUE;
3310 }
3311
3312 tile_changed = tile_changed || (tile_resource(ptile) != presource);
3313
3314 /* Always called after setting terrain */
3315 tile_set_resource(ptile, presource);
3316
3317 if (tile_owner(ptile) != powner) {
3318 tile_set_owner(ptile, powner, NULL);
3319 tile_changed = TRUE;
3320 }
3321 if (extra_owner(ptile) != eowner) {
3322 ptile->extras_owner = eowner;
3323 tile_changed = TRUE;
3324 }
3325
3326 if (packet->placing < 0) {
3327 if (ptile->placing != NULL) {
3328 tile_changed = TRUE;
3329 ptile->placing = NULL;
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) {
3338 tile_changed = TRUE;
3339 }
3340 ptile->infra_turns = packet->place_turn - game.info.turn;
3341 }
3342
3343 if (!has_capability("ids32", client.conn.capability)) {
3344 worked = packet->worked16;
3345 } else {
3346 worked = packet->worked32;
3347 }
3348
3349 if (NULL == tile_worked(ptile)
3350 || tile_worked(ptile)->id != worked) {
3351 if (IDENTITY_NUMBER_ZERO != worked) {
3352 struct city *pwork = game_city_by_number(worked);
3353
3354 if (NULL == pwork) {
3355 char named[MAX_LEN_CITYNAME];
3356
3357 /* New unseen ("invisible") city, or before city_info */
3358 fc_snprintf(named, sizeof(named), "%06u", worked);
3359
3360 pwork = create_city_virtual(invisible.placeholder, NULL, named);
3361 pwork->id = worked;
3362 idex_register_city(&wld, pwork);
3363
3364 city_list_prepend(invisible.cities, pwork);
3365
3366 log_debug("(%d,%d) invisible city %d, %s",
3367 TILE_XY(ptile), pwork->id, city_name_get(pwork));
3368 } else if (NULL == city_tile(pwork)) {
3369 /* Old unseen ("invisible") city, or before city_info */
3370 if (NULL != powner && city_owner(pwork) != powner) {
3371 /* Update placeholder with current owner */
3372 pwork->owner = powner;
3373 pwork->original = NULL;
3374 }
3375 } else {
3376 /* We have a real (not invisible) city record for this ID, but
3377 * perhaps our info about that city is out of date. */
3378 int dist_sq = sq_map_distance(city_tile(pwork), ptile);
3379
3380 if (dist_sq > city_map_radius_sq_get(pwork)) {
3381 /* This is probably enemy city which has grown in diameter since we
3382 * last saw it. We need city_radius_sq to be at least big enough so
3383 * that all workers fit in, so set it so. */
3384 city_map_radius_sq_set(pwork, dist_sq);
3385 }
3386 /* This might be a known city that is open in a dialog.
3387 * (And this might be our only prompt to refresh the worked tiles
3388 * display in its city map, if a worker rearrangement does not
3389 * change anything else about the city such as output.) */
3390 {
3391 struct city *oldwork = tile_worked(ptile);
3392 if (oldwork && NULL != city_tile(oldwork)) {
3393 /* Refresh previous city too if it's real and different */
3394 refresh_city_dialog(oldwork);
3395 }
3396 /* Refresh new city working tile (which we already know is real) */
3397 refresh_city_dialog(pwork);
3398 }
3399 }
3400
3401 /* This marks tile worked by (possibly invisible) city. Other
3402 * parts of the code have to handle invisible cities correctly
3403 * (ptile->worked->tile == NULL) */
3404 tile_set_worked(ptile, pwork);
3405 } else {
3406 /* Tile is no longer being worked by a city.
3407 * (Again, this might be our only prompt to refresh the worked tiles
3408 * display for the previous working city.) */
3409 if (tile_worked(ptile) && NULL != city_tile(tile_worked(ptile))) {
3411 }
3412 tile_set_worked(ptile, NULL);
3413 }
3414
3415 tile_changed = TRUE;
3416 }
3417
3418 if (old_known != packet->known) {
3419 known_changed = TRUE;
3420 }
3421
3422 if (NULL != client.conn.playing) {
3427
3428 switch (packet->known) {
3429 case TILE_KNOWN_SEEN:
3434 break;
3435 case TILE_KNOWN_UNSEEN:
3437 break;
3438 case TILE_UNKNOWN:
3439 break;
3440 default:
3441 log_error("handle_tile_info() invalid known (%d).", packet->known);
3442 break;
3443 };
3444 }
3445 new_known = client_tile_get_known(ptile);
3446
3447 if (packet->spec_sprite[0] != '\0') {
3448 if (!ptile->spec_sprite
3449 || strcmp(ptile->spec_sprite, packet->spec_sprite) != 0) {
3450 if (ptile->spec_sprite) {
3451 free(ptile->spec_sprite);
3452 }
3453 ptile->spec_sprite = fc_strdup(packet->spec_sprite);
3454 tile_changed = TRUE;
3455 }
3456 } else {
3457 if (ptile->spec_sprite) {
3458 free(ptile->spec_sprite);
3459 ptile->spec_sprite = NULL;
3460 tile_changed = TRUE;
3461 }
3462 }
3463
3464 if (TILE_KNOWN_SEEN == old_known && TILE_KNOWN_SEEN != new_known) {
3465 /* This is an error. So first we log the error,
3466 * then make an assertion. */
3467 unit_list_iterate(ptile->units, punit) {
3468 log_error("%p %d %s at (%d,%d) %s", punit, punit->id,
3472 fc_assert_msg(0 == unit_list_size(ptile->units), "Ghost units seen");
3473 /* Repairing... */
3474 unit_list_clear(ptile->units);
3475 }
3476
3477 ptile->continent = packet->continent;
3479
3480 if (packet->label[0] == '\0') {
3481 if (ptile->label != NULL) {
3482 FC_FREE(ptile->label);
3483 ptile->label = NULL;
3484 tile_changed = TRUE;
3485 }
3486 } else if (ptile->label == NULL || strcmp(packet->label, ptile->label)) {
3487 tile_set_label(ptile, packet->label);
3488 tile_changed = TRUE;
3489 }
3490
3491 if (known_changed || tile_changed) {
3492 /*
3493 * A tile can only change if it was known before and is still
3494 * known. In the other cases the tile is new or removed.
3495 */
3496 if (known_changed && TILE_KNOWN_SEEN == new_known) {
3497 agents_tile_new(ptile);
3498 } else if (known_changed && TILE_KNOWN_UNSEEN == new_known) {
3499 agents_tile_remove(ptile);
3500 } else {
3501 agents_tile_changed(ptile);
3502 }
3504 }
3505
3506 /* refresh tiles */
3507 if (can_client_change_view()) {
3508 /* the tile itself (including the necessary parts of adjacent tiles) */
3509 if (tile_changed || old_known != new_known) {
3511 }
3512 }
3513
3514 /* update menus if the focus unit is on the tile. */
3515 if (tile_changed) {
3516 if (get_focus_unit_on_tile(ptile)) {
3517 menus_update();
3518 }
3519 }
3520
3521 /* FIXME: we really ought to call refresh_city_dialog() for any city
3522 * whose radii include this tile, to update the city map display.
3523 * But that would be expensive. We deal with the (common) special
3524 * case of changes in worked tiles above. */
3525}
3526
3527/************************************************************************/
3547
3548/************************************************************************/
3551void handle_scenario_description(const char *description)
3552{
3554
3556}
3557
3558/************************************************************************/
3564{
3565 /* The ruleset is going to load new nations. So close
3566 * the nation selection dialog if it is open. */
3568
3574 game.control = *packet;
3575
3576 /* check the values! */
3577#define VALIDATE(_count, _maximum, _string) \
3578 if (game.control._count > _maximum) { \
3579 log_error("handle_ruleset_control(): Too many " _string \
3580 "; using %d of %d", _maximum, game.control._count); \
3581 game.control._count = _maximum; \
3582 }
3583
3584 VALIDATE(num_unit_classes, UCL_LAST, "unit classes");
3585 VALIDATE(num_unit_types, U_LAST, "unit types");
3586 VALIDATE(num_impr_types, B_LAST, "improvements");
3587 VALIDATE(num_tech_types, A_LAST, "advances");
3588 VALIDATE(num_base_types, MAX_EXTRA_TYPES, "bases");
3589 VALIDATE(num_road_types, MAX_EXTRA_TYPES, "roads");
3590 VALIDATE(num_resource_types, MAX_RESOURCE_TYPES, "resources");
3591 VALIDATE(num_disaster_types, MAX_DISASTER_TYPES, "disasters");
3592 VALIDATE(num_achievement_types, MAX_ACHIEVEMENT_TYPES, "achievements");
3593
3594 /* game.control.government_count, game.control.nation_count and
3595 * game.control.styles_count are allocated dynamically, and do
3596 * not need a size check. See the allocation below. */
3597
3599
3600 VALIDATE(num_specialist_types, SP_MAX, "specialists");
3601#undef VALIDATE
3602
3608
3609 if (!has_capability("rsdesc32", client.conn.capability)) {
3611 }
3612
3613 if (game.control.desc_length32 > 0) {
3615 game.ruleset_description[0] = '\0';
3616 }
3617
3618 if (packet->preferred_tileset[0] != '\0') {
3619 /* There is tileset suggestion */
3620 if (strcmp(packet->preferred_tileset, tileset_basename(tileset))) {
3621 /* It's not currently in use */
3624 } else {
3626 }
3627 }
3628 }
3629
3630 if (packet->preferred_soundset[0] != '\0') {
3631 /* There is soundset suggestion */
3632 if (strcmp(packet->preferred_soundset, sound_set_name)) {
3633 /* It's not currently in use */
3636 } else {
3638 }
3639 }
3640 }
3641
3642 if (packet->preferred_musicset[0] != '\0') {
3643 /* There is musicset suggestion */
3644 if (strcmp(packet->preferred_musicset, music_set_name)) {
3645 /* It's not currently in use */
3648 } else {
3650 }
3651 }
3652 }
3653
3655
3657}
3658
3659/************************************************************************/
3663{
3664 int len;
3665
3666 if (game.ruleset_summary != NULL) {
3667 free(game.ruleset_summary);
3668 }
3669
3670 len = strlen(packet->text);
3671
3673
3674 fc_strlcpy(game.ruleset_summary, packet->text, len + 1);
3675}
3676
3677/************************************************************************/
3686
3687/************************************************************************/
3691{
3692 /* Setup extra hiders caches */
3693 extra_type_iterate(pextra) {
3694 pextra->hiders = extra_type_list_new();
3695 extra_type_iterate(phider) {
3696 if (BV_ISSET(pextra->hidden_by, extra_index(phider))) {
3697 extra_type_list_append(pextra->hiders, phider);
3698 }
3700 pextra->bridged = extra_type_list_new();
3701 extra_type_iterate(pbridged) {
3702 if (BV_ISSET(pextra->bridged_over, extra_index(pbridged))) {
3703 extra_type_list_append(pextra->bridged, pbridged);
3704 }
3707
3708 unit_class_iterate(pclass) {
3709 set_unit_class_caches(pclass);
3710 set_unit_move_type(pclass);
3712
3713 /* Setup improvement feature caches */
3715
3716 /* Setup road integrators caches */
3718
3719 /* Pre calculate action related data. */
3721
3722 /* Setup unit unknown move cost caches */
3723 unit_type_iterate(ptype) {
3724 ptype->unknown_move_cost = utype_unknown_move_cost(ptype);
3725 set_unit_type_caches(ptype);
3728
3729 /* Cache what city production can receive help from caravans. */
3731
3732 /* Adjust editor for changed ruleset. */
3734
3735 /* We are not going to crop any more sprites from big sprites, free them. */
3737
3739}
3740
3741/************************************************************************/
3745{
3746 struct unit_class *c = uclass_by_number(p->id);
3747
3748 fc_assert_ret_msg(NULL != c, "Bad unit_class %d.", p->id);
3749
3750 names_set(&c->name, NULL, p->name, p->rule_name);
3751 c->min_speed = p->min_speed;
3752 c->hp_loss_pct = p->hp_loss_pct;
3754 c->flags = p->flags;
3755
3757}
3758
3759/************************************************************************/
3763{
3764 int i;
3765 struct unit_type *u = utype_by_number(p->id);
3766
3767 fc_assert_ret_msg(NULL != u, "Bad unit_type %d.", p->id);
3768
3769 names_set(&u->name, NULL, p->name, p->rule_name);
3776
3778 u->build_cost = p->build_cost;
3779 u->pop_cost = p->pop_cost;
3782 u->move_rate = p->move_rate;
3784 for (i = 0; i < p->build_reqs_count; i++) {
3785 requirement_vector_append(&u->build_reqs, p->build_reqs[i]);
3786 }
3789 u->hp = p->hp;
3790 u->firepower = p->firepower;
3793 u->convert_time = p->convert_time;
3794 u->fuel = p->fuel;
3795 u->flags = p->flags;
3796 u->roles = p->roles;
3797 u->happy_cost = p->happy_cost;
3799 u->upkeep[o] = p->upkeep[o];
3802 u->bombard_rate = p->bombard_rate;
3803 u->city_size = p->city_size;
3804 u->city_slots = p->city_slots;
3805 u->tp_defense = p->tp_defense;
3806 u->cargo = p->cargo;
3807 u->targets = p->targets;
3808 u->embarks = p->embarks;
3809 u->disembarks = p->disembarks;
3810 u->vlayer = p->vlayer;
3811
3812 if (p->veteran_levels == 0) {
3813 u->veteran = NULL;
3814 } else {
3816
3817 for (i = 0; i < p->veteran_levels; i++) {
3819 p->power_fact[i], p->move_bonus[i],
3820 p->base_raise_chance[i],
3821 p->work_raise_chance[i]);
3822 }
3823 }
3824
3826
3827 u->adv.worker = p->worker;
3828
3830}
3831
3832/************************************************************************/
3837void handle_web_ruleset_unit_addition(int id, bv_actions utype_actions)
3838{
3839}
3840
3841/************************************************************************/
3845{
3846 struct unit_type *u = utype_by_number(p->unit);
3847 struct combat_bonus *bonus;
3848
3849 fc_assert_ret_msg(NULL != u, "Bad unit_type %d.", p->unit);
3850
3851 bonus = malloc(sizeof(*bonus));
3852
3853 bonus->flag = p->flag;
3854 bonus->type = p->type;
3855 bonus->value = p->value;
3856 bonus->quiet = p->quiet;
3857
3858 combat_bonus_list_append(u->bonuses, bonus);
3859}
3860
3861/************************************************************************/
3865{
3866 const char *flagname;
3867 const char *helptxt;
3868
3869 fc_assert_ret_msg(p->id >= UTYF_USER_FLAG_1 && p->id <= UTYF_LAST_USER_FLAG, "Bad user flag %d.", p->id);
3870
3871 if (p->name[0] == '\0') {
3872 flagname = NULL;
3873 } else {
3874 flagname = p->name;
3875 }
3876
3877 if (p->helptxt[0] == '\0') {
3878 helptxt = NULL;
3879 } else {
3880 helptxt = p->helptxt;
3881 }
3882
3883 set_user_unit_type_flag_name(p->id, flagname, helptxt);
3884}
3885
3886/************************************************************************/
3890 const struct packet_ruleset_unit_class_flag *p)
3891{
3892 const char *flagname;
3893 const char *helptxt;
3894
3895 fc_assert_ret_msg(p->id >= UCF_USER_FLAG_1 && p->id <= UCF_LAST_USER_FLAG,
3896 "Bad user flag %d.", p->id);
3897
3898 if (p->name[0] == '\0') {
3899 flagname = NULL;
3900 } else {
3901 flagname = p->name;
3902 }
3903
3904 if (p->helptxt[0] == '\0') {
3905 helptxt = NULL;
3906 } else {
3907 helptxt = p->helptxt;
3908 }
3909
3910 set_user_unit_class_flag_name(p->id, flagname, helptxt);
3911}
3912
3913/************************************************************************/
3921static int unpack_tech_req(const enum tech_req r_num,
3922 const int reqs_size,
3923 const struct requirement *reqs,
3924 struct advance *a,
3925 int i)
3926{
3927 if (i < reqs_size
3928 && reqs[i].source.kind == VUT_ADVANCE) {
3929 /* Extract the tech req so the old code can reason about it. */
3930
3931 /* This IS a traditional tech req... right? */
3932 fc_assert(reqs[i].present);
3933 fc_assert(reqs[i].range == REQ_RANGE_PLAYER);
3934
3935 /* Put it in the advance structure. */
3936 a->require[r_num] = reqs[i].source.value.advance;
3937
3938 /* Move on in the requirement vector. */
3939 i++;
3940 } else {
3941 /* No tech req. */
3942 a->require[r_num] = advance_by_number(A_NONE);
3943 }
3944
3945 return i;
3946}
3947
3948/************************************************************************/
3952{
3953 int i;
3954 struct advance *a = advance_by_number(p->id);
3955
3956 fc_assert_ret_msg(NULL != a, "Bad advance %d.", p->id);
3957
3958 names_set(&a->name, NULL, p->name, p->rule_name);
3961
3962 i = 0;
3963
3965 if (p->tclass >= 0) {
3967 } else {
3968 a->tclass = NULL;
3969 }
3970
3971 /* The tech requirements req1 and req2 are send inside research_reqs
3972 * since they too are required to be fulfilled before the tech can be
3973 * researched. */
3974
3975 if (p->removed) {
3976 /* The Freeciv data structures currently records that a tech is removed
3977 * by setting req1 and req2 to "Never". */
3978 a->require[AR_ONE] = A_NEVER;
3979 a->require[AR_TWO] = A_NEVER;
3980 } else {
3981 /* Unpack req1 and req2 from the research_reqs requirement vector. */
3984 }
3985
3986 /* Any remaining requirements are a part of the research_reqs requirement
3987 * vector. */
3988 for (; i < p->research_reqs_count; i++) {
3989 requirement_vector_append(&a->research_reqs, p->research_reqs[i]);
3990 }
3991
3992 /* The packet's research_reqs should contain req1, req2 and the
3993 * requirements of the tech's research_reqs. */
3994 fc_assert((a->research_reqs.size
3995 + ((a->require[AR_ONE]
3996 && (advance_number(a->require[AR_ONE]) != A_NONE)) ?
3997 1 : 0)
3998 + ((a->require[AR_TWO]
3999 && (advance_number(a->require[AR_TWO]) != A_NONE)) ?
4000 1 : 0))
4001 == p->research_reqs_count);
4002
4004
4005 a->flags = p->flags;
4006 a->cost = p->cost;
4007 a->num_reqs = p->num_reqs;
4009
4011}
4012
4013/************************************************************************/
4017{
4018 struct tech_class *ptclass = tech_class_by_number(p->id);
4019
4020 fc_assert_ret_msg(NULL != ptclass, "Bad tech_class %d.", p->id);
4021
4022 names_set(&ptclass->name, NULL, p->name, p->rule_name);
4023 ptclass->cost_pct = p->cost_pct;
4024}
4025
4026/************************************************************************/
4030{
4031 const char *flagname;
4032 const char *helptxt;
4033
4034 fc_assert_ret_msg(p->id >= TECH_USER_1 && p->id <= TECH_USER_LAST, "Bad user flag %d.", p->id);
4035
4036 if (p->name[0] == '\0') {
4037 flagname = NULL;
4038 } else {
4039 flagname = p->name;
4040 }
4041
4042 if (p->helptxt[0] == '\0') {
4043 helptxt = NULL;
4044 } else {
4045 helptxt = p->helptxt;
4046 }
4047
4048 set_user_tech_flag_name(p->id, flagname, helptxt);
4049}
4050
4051/************************************************************************/
4055{
4056 int i;
4057 struct impr_type *b = improvement_by_number(p->id);
4058
4059 fc_assert_ret_msg(NULL != b, "Bad improvement %d.", p->id);
4060
4061 b->genus = p->genus;
4062 names_set(&b->name, NULL, p->name, p->rule_name);
4065 for (i = 0; i < p->reqs_count; i++) {
4066 requirement_vector_append(&b->reqs, p->reqs[i]);
4067 }
4068 fc_assert(b->reqs.size == p->reqs_count);
4069 for (i = 0; i < p->obs_count; i++) {
4070 requirement_vector_append(&b->obsolete_by, p->obs_reqs[i]);
4071 }
4072 fc_assert(b->obsolete_by.size == p->obs_count);
4073 b->build_cost = p->build_cost;
4074 b->upkeep = p->upkeep;
4075 b->sabotage = p->sabotage;
4076 b->flags = p->flags;
4080
4081#ifdef FREECIV_DEBUG
4082 if (p->id == improvement_count() - 1) {
4083 improvement_iterate(bdbg) {
4084 log_debug("Improvement: %s...", improvement_rule_name(bdbg));
4085 log_debug(" build_cost %3d", bdbg->build_cost);
4086 log_debug(" upkeep %2d", bdbg->upkeep);
4087 log_debug(" sabotage %3d", bdbg->sabotage);
4088 if (NULL != bdbg->helptext) {
4089 strvec_iterate(bdbg->helptext, text) {
4090 log_debug(" helptext %s", text);
4092 }
4094 }
4095#endif /* FREECIV_DEBUG */
4096
4098}
4099
4100/************************************************************************/
4104{
4105 struct multiplier *pmul = multiplier_by_number(p->id);
4106 int j;
4107
4108 fc_assert_ret_msg(NULL != pmul, "Bad multiplier %d.", p->id);
4109
4110 pmul->start = p->start;
4111 pmul->stop = p->stop;
4112 pmul->step = p->step;
4113 pmul->def = p->def;
4114 pmul->offset = p->offset;
4115 pmul->factor = p->factor;
4116 pmul->minimum_turns = p->minimum_turns;
4117
4118 names_set(&pmul->name, NULL, p->name, p->rule_name);
4119
4120 for (j = 0; j < p->reqs_count; j++) {
4121 requirement_vector_append(&pmul->reqs, p->reqs[j]);
4122 }
4123 fc_assert(pmul->reqs.size == p->reqs_count);
4124
4126}
4127
4128/************************************************************************/
4132{
4133 int j;
4134 struct government *gov = government_by_number(p->id);
4135
4136 fc_assert_ret_msg(NULL != gov, "Bad government %d.", p->id);
4137
4138 gov->item_number = p->id;
4139
4140 for (j = 0; j < p->reqs_count; j++) {
4141 requirement_vector_append(&gov->reqs, p->reqs[j]);
4142 }
4143 fc_assert(gov->reqs.size == p->reqs_count);
4144
4145 names_set(&gov->name, NULL, p->name, p->rule_name);
4148
4150
4152}
4153
4154/************************************************************************/
4158 (const struct packet_ruleset_government_ruler_title *packet)
4159{
4160 struct government *gov = government_by_number(packet->gov);
4161
4162 fc_assert_ret_msg(NULL != gov, "Bad government %d.", packet->gov);
4163
4165 packet->male_title,
4166 packet->female_title);
4167}
4168
4169/************************************************************************/
4173{
4174 int j;
4175 struct terrain *pterrain = terrain_by_number(p->id);
4176
4177 fc_assert_ret_msg(NULL != pterrain, "Bad terrain %d.", p->id);
4178
4179 pterrain->tclass = p->tclass;
4180 pterrain->native_to = p->native_to;
4181 names_set(&pterrain->name, NULL, p->name, p->rule_name);
4182 sz_strlcpy(pterrain->graphic_str, p->graphic_str);
4183 sz_strlcpy(pterrain->graphic_alt, p->graphic_alt);
4184 pterrain->movement_cost = p->movement_cost;
4185 pterrain->defense_bonus = p->defense_bonus;
4186
4188 pterrain->output[o] = p->output[o];
4190
4191 if (pterrain->resources != NULL) {
4192 free(pterrain->resources);
4193 }
4194 pterrain->resources = fc_calloc(p->num_resources + 1,
4195 sizeof(*pterrain->resources));
4196 for (j = 0; j < p->num_resources; j++) {
4197 pterrain->resources[j] = extra_by_number(p->resources[j]);
4198 if (!pterrain->resources[j]) {
4199 log_error("handle_ruleset_terrain() "
4200 "Mismatched resource %d for terrain \"%s\".",
4201 p->resources[j], terrain_rule_name(pterrain));
4202 }
4203 }
4204 pterrain->resources[p->num_resources] = NULL;
4205
4207 pterrain->road_output_incr_pct[o] = p->road_output_incr_pct[o];
4209
4210 pterrain->base_time = p->base_time;
4211 pterrain->road_time = p->road_time;
4213 pterrain->cultivate_time = p->cultivate_time;
4215 pterrain->plant_time = p->plant_time;
4217 pterrain->irrigation_time = p->irrigation_time;
4219 pterrain->mining_time = p->mining_time;
4220 if (p->animal < 0) {
4221 pterrain->animal = NULL;
4222 } else {
4223 pterrain->animal = utype_by_number(p->animal);
4224 }
4226 pterrain->transform_time = p->transform_time;
4227 pterrain->placing_time = p->placing_time;
4228 pterrain->pillage_time = p->pillage_time;
4231
4232 pterrain->flags = p->flags;
4233
4234 fc_assert_ret(pterrain->rgb == NULL);
4235 pterrain->rgb = rgbcolor_new(p->color_red, p->color_green, p->color_blue);
4236
4238
4240}
4241
4242/************************************************************************/
4246{
4247 const char *flagname;
4248 const char *helptxt;
4249
4250 fc_assert_ret_msg(p->id >= TER_USER_1 && p->id <= TER_USER_LAST, "Bad user flag %d.", p->id);
4251
4252 if (p->name[0] == '\0') {
4253 flagname = NULL;
4254 } else {
4255 flagname = p->name;
4256 }
4257
4258 if (p->helptxt[0] == '\0') {
4259 helptxt = NULL;
4260 } else {
4261 helptxt = p->helptxt;
4262 }
4263
4264 set_user_terrain_flag_name(p->id, flagname, helptxt);
4265}
4266
4267/************************************************************************/
4271{
4272 struct resource_type *presource;
4273
4274 if (p->id < 0 || p->id > MAX_EXTRA_TYPES) {
4275 log_error("Bad resource %d.", p->id);
4276 return;
4277 }
4278
4279 presource = resource_type_init(extra_by_number(p->id));
4280
4282 presource->output[o] = p->output[o];
4284}
4285
4286/************************************************************************/
4290{
4291 struct extra_type *pextra = extra_by_number(p->id);
4292 int i;
4293 bool cbase;
4294 bool croad;
4295 bool cres;
4296
4297 fc_assert_ret_msg(NULL != pextra, "Bad extra %d.", p->id);
4298
4299 names_set(&pextra->name, NULL, p->name, p->rule_name);
4300
4301 pextra->category = p->category;
4302
4303 pextra->causes = 0;
4304 for (i = 0; i < EC_COUNT; i++) {
4305 if (BV_ISSET(p->causes, i)) {
4306 pextra->causes |= (1 << i);
4307 }
4308 }
4309
4310 pextra->rmcauses = 0;
4311 for (i = 0; i < ERM_COUNT; i++) {
4312 if (BV_ISSET(p->rmcauses, i)) {
4313 pextra->rmcauses |= (1 << i);
4314 }
4315 }
4316
4317 if (pextra->causes == 0) {
4319 } else {
4320 for (i = 0; i < EC_COUNT; i++) {
4321 if (is_extra_caused_by(pextra, i)) {
4322 extra_to_caused_by_list(pextra, i);
4323 }
4324 }
4325 }
4326
4327 cbase = is_extra_caused_by(pextra, EC_BASE);
4328 croad = is_extra_caused_by(pextra, EC_ROAD);
4329 cres = is_extra_caused_by(pextra, EC_RESOURCE);
4330 if (cbase) {
4331 /* Index is one less than size of list when this base is already added. */
4332 base_type_init(pextra, extra_type_list_size(extra_type_list_by_cause(EC_BASE)) - 1);
4333 }
4334 if (croad) {
4335 /* Index is one less than size of list when this road is already added. */
4336 road_type_init(pextra, extra_type_list_size(extra_type_list_by_cause(EC_ROAD)) - 1);
4337 }
4338 if (!cbase && !croad && !cres) {
4339 pextra->data.special_idx = extra_type_list_size(extra_type_list_by_cause(EC_SPECIAL));
4341 }
4342
4343 for (i = 0; i < ERM_COUNT; i++) {
4344 if (is_extra_removed_by(pextra, i)) {
4345 extra_to_removed_by_list(pextra, i);
4346 }
4347 }
4348
4350 sz_strlcpy(pextra->act_gfx_alt, p->act_gfx_alt);
4352 sz_strlcpy(pextra->rmact_gfx, p->rmact_gfx);
4354 sz_strlcpy(pextra->graphic_str, p->graphic_str);
4355 sz_strlcpy(pextra->graphic_alt, p->graphic_alt);
4356
4357 for (i = 0; i < p->reqs_count; i++) {
4358 requirement_vector_append(&pextra->reqs, p->reqs[i]);
4359 }
4360 fc_assert(pextra->reqs.size == p->reqs_count);
4361
4362 for (i = 0; i < p->rmreqs_count; i++) {
4363 requirement_vector_append(&pextra->rmreqs, p->rmreqs[i]);
4364 }
4365 fc_assert(pextra->rmreqs.size == p->rmreqs_count);
4366
4368 for (i = 0; i < p->appearance_reqs_count; i++) {
4369 requirement_vector_append(&pextra->appearance_reqs, p->appearance_reqs[i]);
4370 }
4372
4374 for (i = 0; i < p->disappearance_reqs_count; i++) {
4375 requirement_vector_append(&pextra->disappearance_reqs, p->disappearance_reqs[i]);
4376 }
4378
4379 pextra->visibility_req = p->visibility_req;
4380 pextra->buildable = p->buildable;
4381 pextra->generated = p->generated;
4382 pextra->build_time = p->build_time;
4384 pextra->removal_time = p->removal_time;
4386 pextra->infracost = p->infracost;
4387 pextra->defense_bonus = p->defense_bonus;
4388
4389 if (pextra->defense_bonus != 0) {
4390 if (extra_has_flag(pextra, EF_NATURAL_DEFENSE)) {
4392 } else {
4394 }
4395 }
4396
4397 pextra->eus = p->eus;
4398 if (pextra->eus == EUS_HIDDEN) {
4399 extra_type_list_append(extra_type_list_of_unit_hiders(), pextra);
4400 }
4401
4402 pextra->native_to = p->native_to;
4403
4404 pextra->flags = p->flags;
4405 if (extra_has_flag(pextra, EF_NOT_AGGRESSIVE)) {
4407 }
4408
4409 pextra->hidden_by = p->hidden_by;
4410 pextra->bridged_over = p->bridged_over;
4411 pextra->conflicts = p->conflicts;
4412
4414
4416}
4417
4418/************************************************************************/
4422{
4423 const char *flagname;
4424 const char *helptxt;
4425
4426 fc_assert_ret_msg(p->id >= EF_USER_FLAG_1 && p->id <= EF_LAST_USER_FLAG,
4427 "Bad user flag %d.", p->id);
4428
4429 if (p->name[0] == '\0') {
4430 flagname = NULL;
4431 } else {
4432 flagname = p->name;
4433 }
4434
4435 if (p->helptxt[0] == '\0') {
4436 helptxt = NULL;
4437 } else {
4438 helptxt = p->helptxt;
4439 }
4440
4441 set_user_extra_flag_name(p->id, flagname, helptxt);
4442}
4443
4444/************************************************************************/
4448{
4449 struct base_type *pbase = base_by_number(p->id);
4450
4451 fc_assert_ret_msg(NULL != pbase, "Bad base %d.", p->id);
4452
4453 pbase->gui_type = p->gui_type;
4454 pbase->border_sq = p->border_sq;
4455 pbase->vision_main_sq = p->vision_main_sq;
4456 pbase->vision_invis_sq = p->vision_invis_sq;
4457 pbase->vision_subs_sq = p->vision_subs_sq;
4458
4459 if (territory_claiming_base(pbase)) {
4460 extra_type_list_append(extra_type_list_of_terr_claimers(),
4461 base_extra_get(pbase));
4462 }
4463}
4464
4465/************************************************************************/
4469{
4470 int i;
4471 struct road_type *proad = road_by_number(p->id);
4472
4473 fc_assert_ret_msg(NULL != proad, "Bad road %d.", p->id);
4474
4475 proad->gui_type = p->gui_type;
4476
4477 for (i = 0; i < p->first_reqs_count; i++) {
4478 requirement_vector_append(&proad->first_reqs, p->first_reqs[i]);
4479 }
4480 fc_assert(proad->first_reqs.size == p->first_reqs_count);
4481
4482 proad->move_cost = p->move_cost;
4483 proad->move_mode = p->move_mode;
4484
4486 proad->tile_incr_const[o] = p->tile_incr_const[o];
4487 proad->tile_incr[o] = p->tile_incr[o];
4488 proad->tile_bonus[o] = p->tile_bonus[o];
4490
4491 proad->compat = p->compat;
4492 proad->integrates = p->integrates;
4493 proad->flags = p->flags;
4494}
4495
4496/************************************************************************/
4500{
4501 struct goods_type *pgood = goods_by_number(p->id);
4502 int i;
4503
4504 fc_assert_ret_msg(NULL != pgood, "Bad goods %d.", p->id);
4505
4506 names_set(&pgood->name, NULL, p->name, p->rule_name);
4507
4508 for (i = 0; i < p->reqs_count; i++) {
4509 requirement_vector_append(&pgood->reqs, p->reqs[i]);
4510 }
4511 fc_assert(pgood->reqs.size == p->reqs_count);
4512
4513 pgood->from_pct = p->from_pct;
4514 pgood->to_pct = p->to_pct;
4515 pgood->onetime_pct = p->onetime_pct;
4516 pgood->flags = p->flags;
4517
4519}
4520
4521/************************************************************************/
4525{
4526 struct action *act;
4527
4528 if (!action_id_exists(p->id)) {
4529 /* Action id out of range */
4530 log_error("handle_ruleset_action() the action id %d is out of range.",
4531 p->id);
4532
4533 return;
4534 }
4535
4536 act = action_by_number(p->id);
4537
4538 sz_strlcpy(act->ui_name, p->ui_name);
4539 act->quiet = p->quiet;
4540
4541 act->result = p->result;
4542 act->sub_results = p->sub_results;
4544
4545 act->actor_kind = p->act_kind;
4546 act->target_kind = p->tgt_kind;
4547 act->sub_target_kind = p->sub_tgt_kind;
4548
4549 act->min_distance = p->min_distance;
4550 act->max_distance = p->max_distance;
4551 act->blocked_by = p->blocked_by;
4552}
4553
4554/************************************************************************/
4557void
4559{
4560 struct action_enabler *enabler;
4561 int i;
4562
4564 /* Non existing action */
4565 log_error("handle_ruleset_action_enabler() the action %d "
4566 "doesn't exist.",
4567 p->enabled_action);
4568
4569 return;
4570 }
4571
4572 enabler = action_enabler_new();
4573
4574 enabler->action = p->enabled_action;
4575
4576 for (i = 0; i < p->actor_reqs_count; i++) {
4577 requirement_vector_append(&enabler->actor_reqs, p->actor_reqs[i]);
4578 }
4579 fc_assert(enabler->actor_reqs.size == p->actor_reqs_count);
4580
4581 for (i = 0; i < p->target_reqs_count; i++) {
4582 requirement_vector_append(&enabler->target_reqs, p->target_reqs[i]);
4583 }
4584 fc_assert(enabler->target_reqs.size == p->target_reqs_count);
4585
4586 action_enabler_add(enabler);
4587}
4588
4589/************************************************************************/
4593{
4594 struct action_auto_perf *auto_perf;
4595 int i;
4596
4597 auto_perf = action_auto_perf_slot_number(p->id);
4598
4599 auto_perf->cause = p->cause;
4600
4601 for (i = 0; i < p->reqs_count; i++) {
4602 requirement_vector_append(&auto_perf->reqs, p->reqs[i]);
4603 }
4604 fc_assert(auto_perf->reqs.size == p->reqs_count);
4605
4606 for (i = 0; i < p->alternatives_count; i++) {
4607 auto_perf->alternatives[i] = p->alternatives[i];
4608 }
4609}
4610
4611/************************************************************************/
4615{
4616 struct disaster_type *pdis = disaster_by_number(p->id);
4617 int i;
4618
4619 fc_assert_ret_msg(NULL != pdis, "Bad disaster %d.", p->id);
4620
4621 names_set(&pdis->name, NULL, p->name, p->rule_name);
4622
4623 for (i = 0; i < p->reqs_count; i++) {
4624 requirement_vector_append(&pdis->reqs, p->reqs[i]);
4625 }
4626 fc_assert(pdis->reqs.size == p->reqs_count);
4627
4628 pdis->frequency = p->frequency;
4629
4630 pdis->effects = p->effects;
4631}
4632
4633/************************************************************************/
4637{
4638 struct achievement *pach = achievement_by_number(p->id);
4639
4640 fc_assert_ret_msg(NULL != pach, "Bad achievement %d.", p->id);
4641
4642 names_set(&pach->name, NULL, p->name, p->rule_name);
4643
4644 pach->type = p->type;
4645 pach->unique = p->unique;
4646 pach->value = p->value;
4647}
4648
4649/************************************************************************/
4653{
4655
4656 if (pset != NULL) {
4657 pset->trade_pct = p->trade_pct;
4658 pset->cancelling = p->cancelling;
4659 pset->bonus_type = p->bonus_type;
4660 }
4661}
4662
4663/************************************************************************/
4667 (const struct packet_ruleset_terrain_control *p)
4668{
4669 /* Since terrain_control is the same as packet_ruleset_terrain_control
4670 * we can just copy the data directly. */
4671 terrain_control = *p;
4672 /* terrain_control.move_fragments likely changed */
4674}
4675
4676/************************************************************************/
4680 (const struct packet_ruleset_nation_sets *packet)
4681{
4682 int i;
4683
4684 for (i = 0; i < packet->nsets; i++) {
4685 struct nation_set *pset =
4686 nation_set_new(packet->names[i], packet->rule_names[i],
4687 packet->descriptions[i]);
4688
4689 if (pset == NULL) {
4690 break;
4691 } else {
4692 fc_assert(i == nation_set_index(pset));
4693 }
4694 }
4695}
4696
4697/************************************************************************/
4701 (const struct packet_ruleset_nation_groups *packet)
4702{
4703 int i;
4704
4705 for (i = 0; i < packet->ngroups; i++) {
4706 struct nation_group *pgroup;
4707
4708 pgroup = nation_group_new(packet->groups[i]);
4709
4710 if (pgroup != NULL) {
4711 fc_assert(i == nation_group_index(pgroup));
4712 pgroup->hidden = packet->hidden[i];
4713 } else {
4714 break;
4715 }
4716 }
4717}
4718
4719/************************************************************************/
4723{
4724 struct nation_type *pnation = nation_by_number(packet->id);
4725 int i;
4726
4727 fc_assert_ret_msg(NULL != pnation, "Bad nation %d.", packet->id);
4728
4729 if (packet->translation_domain[0] != '\0') {
4730 size_t len = strlen(packet->translation_domain) + 1;
4731 pnation->translation_domain = fc_malloc(len);
4733 } else {
4734 pnation->translation_domain = NULL;
4735 }
4736 names_set(&pnation->adjective, pnation->translation_domain,
4737 packet->adjective, packet->rule_name);
4738 name_set(&pnation->noun_plural, pnation->translation_domain, packet->noun_plural);
4739 sz_strlcpy(pnation->flag_graphic_str, packet->graphic_str);
4740 sz_strlcpy(pnation->flag_graphic_alt, packet->graphic_alt);
4741 pnation->style = style_by_number(packet->style);
4742 for (i = 0; i < packet->leader_count; i++) {
4743 (void) nation_leader_new(pnation, packet->leader_name[i],
4744 packet->leader_is_male[i]);
4745 }
4746
4747 /* set later by PACKET_NATION_AVAILABILITY */
4748 pnation->client.is_pickable = FALSE;
4749 pnation->is_playable = packet->is_playable;
4750 pnation->barb_type = packet->barbarian_type;
4751
4752 if ('\0' != packet->legend[0]) {
4753 pnation->legend = fc_strdup(nation_legend_translation(pnation, packet->legend));
4754 } else {
4755 pnation->legend = fc_strdup("");
4756 }
4757
4758 for (i = 0; i < packet->nsets; i++) {
4759 struct nation_set *pset = nation_set_by_number(packet->sets[i]);
4760
4761 if (NULL != pset) {
4762 nation_set_list_append(pnation->sets, pset);
4763 } else {
4764 log_error("handle_ruleset_nation() \"%s\" have unknown set %d.",
4765 nation_rule_name(pnation), packet->sets[i]);
4766 }
4767 }
4768
4769 for (i = 0; i < packet->ngroups; i++) {
4770 struct nation_group *pgroup = nation_group_by_number(packet->groups[i]);
4771
4772 if (NULL != pgroup) {
4773 nation_group_list_append(pnation->groups, pgroup);
4774 } else {
4775 log_error("handle_ruleset_nation() \"%s\" have unknown group %d.",
4776 nation_rule_name(pnation), packet->groups[i]);
4777 }
4778 }
4779
4780 /* init_government may be NULL */
4782 for (i = 0; i < MAX_NUM_TECH_LIST; i++) {
4783 if (i < packet->init_techs_count) {
4784 pnation->init_techs[i] = packet->init_techs[i];
4785 } else {
4786 pnation->init_techs[i] = A_LAST;
4787 }
4788 }
4789 for (i = 0; i < MAX_NUM_UNIT_LIST; i++) {
4790 if (i < packet->init_units_count) {
4791 pnation->init_units[i] = utype_by_number(packet->init_units[i]);
4792 } else {
4793 /* TODO: should init_units be initialized in common/nation.c? */
4794 pnation->init_units[i] = utype_by_number(U_LAST);
4795 }
4796 }
4797 for (i = 0; i < MAX_NUM_BUILDING_LIST; i++) {
4798 if (i < packet->init_buildings_count) {
4799 pnation->init_buildings[i] = packet->init_buildings[i];
4800 } else {
4801 pnation->init_buildings[i] = B_LAST;
4802 }
4803 }
4804
4806}
4807
4808/************************************************************************/
4812void handle_nation_availability(int ncount, const bool *is_pickable,
4813 bool nationset_change)
4814{
4815 int i;
4816
4817 fc_assert_action(ncount == nation_count(),
4818 ncount = MIN(ncount, nation_count()));
4819
4820 for (i = 0; i < ncount; i++) {
4821 nation_by_number(i)->client.is_pickable = is_pickable[i];
4822 }
4823
4824 races_update_pickable(nationset_change);
4825}
4826
4827/************************************************************************/
4831{
4832 struct nation_style *pstyle = style_by_number(p->id);
4833
4834 fc_assert_ret_msg(NULL != pstyle, "Bad style %d.", p->id);
4835
4836 names_set(&pstyle->name, NULL, p->name, p->rule_name);
4837}
4838
4839/************************************************************************/
4843{
4844 struct clause_info *info = clause_info_get(p->type);
4845 int i;
4846
4847 fc_assert_ret_msg(NULL != info, "Bad clause %d.", p->type);
4848
4849 info->enabled = p->enabled;
4850
4851 for (i = 0; i < p->giver_reqs_count; i++) {
4852 requirement_vector_append(&info->giver_reqs, p->giver_reqs[i]);
4853 }
4854 fc_assert(info->giver_reqs.size == p->giver_reqs_count);
4855
4856 for (i = 0; i < p->receiver_reqs_count; i++) {
4857 requirement_vector_append(&info->receiver_reqs, p->receiver_reqs[i]);
4858 }
4860}
4861
4862/************************************************************************/
4866{
4867 int id, j;
4868 struct citystyle *cs;
4869
4870 id = packet->style_id;
4872 "Bad citystyle %d.", id);
4873 cs = &city_styles[id];
4874
4875 for (j = 0; j < packet->reqs_count; j++) {
4876 requirement_vector_append(&cs->reqs, packet->reqs[j]);
4877 }
4878 fc_assert(cs->reqs.size == packet->reqs_count);
4879
4880 names_set(&cs->name, NULL, packet->name, packet->rule_name);
4881 sz_strlcpy(cs->graphic, packet->graphic);
4882 sz_strlcpy(cs->graphic_alt, packet->graphic_alt);
4884
4886}
4887
4888/************************************************************************/
4892{
4893 int id, j;
4894 struct music_style *pmus;
4895
4896 id = packet->id;
4898 "Bad music_style %d.", id);
4899
4900 pmus = music_style_by_number(id);
4901
4902 for (j = 0; j < packet->reqs_count; j++) {
4903 requirement_vector_append(&pmus->reqs, packet->reqs[j]);
4904 }
4905 fc_assert(pmus->reqs.size == packet->reqs_count);
4906
4908 sz_strlcpy(pmus->music_combat, packet->music_combat);
4909}
4910
4911/************************************************************************/
4915{
4916 int i;
4917
4918 /* Must set num_specialist_types before iterating over them. */
4920
4921 fc_assert_ret(packet->veteran_levels > 0);
4922
4924 game.veteran->levels = packet->veteran_levels;
4925
4926 for (i = 0; i < MAX_NUM_TECH_LIST; i++) {
4927 if (i < packet->global_init_techs_count) {
4929 } else {
4931 }
4932 }
4933 for (i = 0; i < MAX_NUM_BUILDING_LIST; i++) {
4934 if (i < packet->global_init_buildings_count) {
4936 } else {
4938 }
4939 }
4940
4941 for (i = 0; i < packet->veteran_levels; i++) {
4943 packet->power_fact[i], packet->move_bonus[i],
4944 packet->base_raise_chance[i],
4945 packet->work_raise_chance[i]);
4946 }
4947
4948 fc_assert(game.plr_bg_color == NULL);
4950 packet->background_green,
4951 packet->background_blue);
4952
4954}
4955
4956/************************************************************************/
4960{
4961 int j;
4962 struct specialist *s = specialist_by_number(p->id);
4963
4964 fc_assert_ret_msg(NULL != s, "Bad specialist %d.", p->id);
4965
4966 names_set(&s->name, NULL, p->plural_name, p->rule_name);
4967 name_set(&s->abbreviation, NULL, p->short_name);
4968
4971
4972 for (j = 0; j < p->reqs_count; j++) {
4973 requirement_vector_append(&s->reqs, p->reqs[j]);
4974 }
4975 fc_assert(s->reqs.size == p->reqs_count);
4976
4978
4980}
4981
4982/************************************************************************/
4985void handle_city_name_suggestion_info(int unit_id16, int unit_id32,
4986 const char *name)
4987{
4988 struct unit *punit;
4989
4990 if (!has_capability("ids32", client.conn.capability)) {
4991 unit_id32 = unit_id16;
4992 }
4993
4995
4996 if (!can_client_issue_orders()) {
4997 return;
4998 }
4999
5000 if (punit) {
5002 bool other_asking = FALSE;
5003
5004 unit_list_iterate(unit_tile(punit)->units, other) {
5005 if (other->client.asking_city_name) {
5006 other_asking = TRUE;
5007 }
5010
5011 if (!other_asking) {
5013 }
5014 } else {
5015 request_do_action(ACTION_FOUND_CITY,
5016 unit_id32, tile_index(unit_tile(punit)),
5017 0, name);
5018 }
5019 }
5020}
5021
5022/************************************************************************/
5029{
5030 struct city *pcity = game_city_by_number(packet->target_id);
5031 struct unit *punit = game_unit_by_number(packet->target_id);
5032 struct unit *pactor;
5033 struct action *paction = action_by_number(packet->action_type);
5034 int actor_id;
5035
5036 if (!has_capability("ids32", client.conn.capability)) {
5037 actor_id = packet->actor_id16;
5038 } else {
5039 actor_id = packet->actor_id32;
5040 }
5041
5042 pactor = player_unit_by_number(client_player(), actor_id);
5043
5044 if (ACTION_NONE != packet->action_type
5045 && !action_id_exists(packet->action_type)) {
5046 /* Non existing action */
5047 log_error("handle_unit_action_answer() the action %d doesn't exist.",
5048 packet->action_type);
5049
5050 if (packet->request_kind == REQEST_PLAYER_INITIATED) {
5054 }
5055
5056 return;
5057 }
5058
5059 if (!pactor) {
5060 log_debug("Bad actor %d.", actor_id);
5061
5062 if (packet->request_kind == REQEST_PLAYER_INITIATED) {
5065 }
5066
5067 return;
5068 }
5069
5070 switch ((enum gen_action)packet->action_type) {
5071 case ACTION_SPY_BRIBE_UNIT:
5072 if (punit && client.conn.playing
5074 if (packet->request_kind == REQEST_PLAYER_INITIATED) {
5075 /* Focus on the unit so the player knows where it is */
5076 unit_focus_set(pactor);
5077
5078 popup_bribe_dialog(pactor, punit, packet->cost, paction);
5079 } else {
5080 /* Not in use (yet). */
5081 log_error("Unimplemented: received background unit bribe cost.");
5082 }
5083 } else {
5084 log_debug("Bad target %d.", packet->target_id);
5085 if (packet->request_kind == REQEST_PLAYER_INITIATED) {
5089 }
5090 }
5091 break;
5092 case ACTION_SPY_INCITE_CITY:
5093 case ACTION_SPY_INCITE_CITY_ESC:
5094 if (pcity && client.conn.playing
5096 if (packet->request_kind == REQEST_PLAYER_INITIATED) {
5097 /* Focus on the unit so the player knows where it is */
5098 unit_focus_set(pactor);
5099
5100 popup_incite_dialog(pactor, pcity, packet->cost, paction);
5101 } else {
5102 /* Not in use (yet). */
5103 log_error("Unimplemented: received background city incite cost.");
5104 }
5105 } else {
5106 log_debug("Bad target %d.", packet->target_id);
5107 if (packet->request_kind == REQEST_PLAYER_INITIATED) {
5111 }
5112 }
5113 break;
5114 case ACTION_UPGRADE_UNIT:
5115 if (pcity && client.conn.playing
5117 /* TODO: The bundled clients will have to start showing the upgrade
5118 * price sent from the server before it can be allowed to rely on
5119 * things the player can't see. (Example: it becomes legal to upgrade
5120 * a unit in a foreign city.) */
5121
5122 /* Getting unit upgrade cost from the server is currently only used by
5123 * Freeciv-web. */
5124 log_error("Received upgrade unit price but can't forward it.");
5125 }
5126 break;
5127 case ACTION_NONE:
5128 log_debug("Server didn't respond to query.");
5129 if (packet->request_kind == REQEST_PLAYER_INITIATED) {
5133 }
5134 break;
5135 default:
5136 log_error("handle_unit_action_answer() invalid action_type (%d).",
5137 packet->action_type);
5138 if (packet->request_kind == REQEST_PLAYER_INITIATED) {
5142 }
5143 break;
5144 };
5145}
5146
5147/************************************************************************/
5151static action_id auto_attack_act(const struct act_prob *act_probs)
5152{
5153 action_id attack_action = ACTION_NONE;
5154
5156 if (action_prob_possible(act_probs[act_id])) {
5157 /* An attack. */
5158 if (attack_action == ACTION_NONE) {
5159 /* No previous attack action found. */
5160 attack_action = act_id;
5161 } else {
5162 /* More than one legal attack action found. */
5163 return ACTION_NONE;
5164 }
5165 }
5168 if (action_prob_possible(act_probs[act_id])) {
5169 /* An interesting non attack action has been found. */
5170 return ACTION_NONE;
5171 }
5173
5174 return attack_action;
5175}
5176
5177/**********************************************************************/
5182 const struct act_prob *act_probs,
5183 struct unit *target_unit,
5184 struct city *target_city,
5185 struct tile *target_tile)
5186{
5187 action_id auto_action;
5188
5189 fc_assert_ret(actor_unit != NULL);
5190
5191 auto_action = auto_attack_act(act_probs);
5192
5193 if (auto_action != ACTION_NONE) {
5194 /* No interesting actions except a single attack action has been
5195 * found. The player wants it performed without questions. */
5196
5197 /* The order requests below doesn't send additional details. */
5199
5200 /* Give the order. */
5201 switch (action_id_get_target_kind(auto_action)) {
5202 case ATK_TILE:
5203 case ATK_UNITS:
5204 case ATK_EXTRAS:
5205 if (target_tile != NULL) {
5206 request_do_action(auto_action,
5208 0, "");
5209 }
5210 break;
5211 case ATK_CITY:
5212 if (target_city != NULL) {
5213 request_do_action(auto_action,
5215 0, "");
5216 }
5217 break;
5218 case ATK_UNIT:
5219 if (target_unit != NULL) {
5220 request_do_action(auto_action,
5222 0, "");
5223 }
5224 break;
5225 case ATK_SELF:
5226 request_do_action(auto_action,
5228 0, "");
5229 break;
5230 case ATK_COUNT:
5231 fc_assert(action_id_get_target_kind(auto_action) != ATK_COUNT);
5232 break;
5233 }
5234
5235 /* Clean up. */
5237 } else {
5238 /* This should be done in the foreground */
5240 }
5241}
5242
5243/************************************************************************/
5250{
5251 struct unit *actor_unit;
5252 struct tile *target_tile = index_to_tile(&(wld.map), packet->target_tile_id);
5253 struct extra_type *target_extra = packet->target_extra_id == EXTRA_NONE ?
5254 NULL : extra_by_number(packet->target_extra_id);
5255 struct city *target_city;
5256 struct unit *target_unit;
5257 int actor_unit_id;
5258
5259 const struct act_prob *act_probs = packet->action_probabilities;
5260
5261 int request_kind = packet->request_kind;
5262 bool valid = FALSE;
5263
5264 if (!has_capability("ids32", client.conn.capability)) {
5268 } else {
5272 }
5273
5275
5276 /* The dead can't act */
5278 /* At least one action must be possible */
5279 action_iterate(act) {
5280 if (action_prob_possible(act_probs[act])) {
5281 valid = TRUE;
5282 break;
5283 }
5285 }
5286
5287 switch (request_kind) {
5289 if (valid) {
5290 /* The player can select an action and should be informed. */
5291
5292 /* Show the client specific action dialog */
5296 act_probs);
5297 } else {
5298 /* Nothing to do. */
5302 }
5303 break;
5305 /* This was a background action selection dialog refresh. */
5306
5307 if (actor_unit != NULL
5309 /* The situation may have changed. */
5313 act_probs);
5314 }
5315 break;
5317 if (actor_unit != NULL) {
5320 }
5321 break;
5322 default:
5323 log_warn("Unknown request_kind %d in reply", request_kind);
5324 break;
5325 }
5326}
5327
5328/************************************************************************/
5332{
5333 struct city *pcity;
5334 struct unit *pactor;
5335 struct action *paction = action_by_number(packet->act_id);
5336 int actor_id;
5337 int city_id;
5338
5339 if (!has_capability("ids32", client.conn.capability)) {
5340 actor_id = packet->actor_id16;
5341 city_id = packet->city_id16;
5342 } else {
5343 actor_id = packet->actor_id32;
5344 city_id = packet->city_id32;
5345 }
5346
5347 pactor = player_unit_by_number(client_player(), actor_id);
5348 pcity = game_city_by_number(city_id);
5349
5350 if (pactor == NULL) {
5351 log_debug("Bad diplomat %d.", actor_id);
5352
5353 if (packet->request_kind == REQEST_PLAYER_INITIATED) {
5356 }
5357
5358 return;
5359 }
5360
5361 if (!pcity) {
5362 log_debug("Bad city %d.", city_id);
5363
5364 if (packet->request_kind == REQEST_PLAYER_INITIATED) {
5368 }
5369
5370 return;
5371 }
5372
5374 improvement_iterate(pimprove) {
5375 update_improvement_from_packet(pcity, pimprove,
5376 BV_ISSET(packet->improvements,
5377 improvement_index(pimprove)));
5379
5380 if (packet->request_kind == REQEST_PLAYER_INITIATED) {
5381 /* Focus on the unit so the player knows where it is */
5382 unit_focus_set(pactor);
5383
5384 popup_sabotage_dialog(pactor, pcity, paction);
5385 } else {
5386 /* Not in use (yet). */
5387 log_error("Unimplemented: received background city building list.");
5388 }
5389 } else {
5390 log_debug("Can't issue orders");
5391 if (packet->request_kind == REQEST_PLAYER_INITIATED) {
5394 }
5395 }
5396}
5397
5398/************************************************************************/
5407
5408/************************************************************************/
5412{
5413 if (client_has_player()
5414 && packet->player_id == player_number(client_player())) {
5415 if (packet->winner) {
5416 start_menu_music("music_victory", NULL);
5417 } else {
5418 start_menu_music("music_defeat", NULL);
5419 }
5420 }
5422}
5423
5424/************************************************************************/
5428 (const struct packet_player_attribute_chunk *packet)
5429{
5430 if (!client_has_player()) {
5431 return;
5432 }
5433
5435
5436 if (packet->offset + packet->chunk_length == packet->total_length) {
5437 /* We successful received the last chunk. The attribute block is
5438 now complete. */
5440 }
5441}
5442
5443/************************************************************************/
5447{
5449
5453 client.last_processed_request_id_seen);
5455 request_id_of_currently_handled_packet);
5456
5457 log_debug("start processing packet %d",
5459}
5460
5461/************************************************************************/
5480
5481/************************************************************************/
5485 int packet_type, int size)
5486{
5487 fc_assert(pc == &client.conn);
5488 log_debug("incoming packet={type=%d, size=%d}", packet_type, size);
5489}
5490
5491/************************************************************************/
5495 int packet_type, int size,
5496 int request_id)
5497{
5498 fc_assert(pc == &client.conn);
5499 log_debug("outgoing packet={type=%d, size=%d, request_id=%d}",
5500 packet_type, size, request_id);
5501
5502 fc_assert(request_id);
5503}
5504
5505/************************************************************************/
5509{
5510 log_debug("handle_freeze_client");
5511
5513}
5514
5515/************************************************************************/
5519{
5520 log_debug("handle_thaw_client");
5521
5524}
5525
5526/************************************************************************/
5530{
5532}
5533
5534/************************************************************************/
5538{
5539 log_verbose("server shutdown");
5540}
5541
5542/************************************************************************/
5546{
5547 recv_ruleset_effect(packet);
5548}
5549
5550/************************************************************************/
5556void handle_edit_object_created(int tag, int id)
5557{
5559}
5560
5561/************************************************************************/
5565{
5566 struct tile *ptile = index_to_tile(&(wld.map), packet->id);
5567 bool changed = FALSE;
5568
5569 /* Check. */
5570 if (NULL == ptile) {
5571 log_error("%s(): invalid tile index %d.", __FUNCTION__, packet->id);
5572 return;
5573 }
5574
5575 /* Handle. */
5576 if (packet->removal) {
5577 changed = map_startpos_remove(ptile);
5578 } else {
5579 if (NULL != map_startpos_get(ptile)) {
5580 changed = FALSE;
5581 } else {
5582 map_startpos_new(ptile);
5583 changed = TRUE;
5584 }
5585 }
5586
5587 /* Notify. */
5588 if (changed && can_client_change_view()) {
5590 if (packet->removal) {
5592 packet->id, TRUE);
5593 } else {
5594 editgui_notify_object_created(packet->tag, packet->id);
5595 }
5596 }
5597}
5598
5599/************************************************************************/
5603 packet)
5604{
5605 struct tile *ptile = index_to_tile(&(wld.map), packet->id);
5606 struct startpos *psp;
5607
5608 /* Check. */
5609 if (NULL == ptile) {
5610 log_error("%s(): invalid tile index %d.", __FUNCTION__, packet->id);
5611 return;
5612 }
5613
5614 psp = map_startpos_get(ptile);
5615 if (NULL == psp) {
5616 log_error("%s(): no start position at (%d, %d)",
5617 __FUNCTION__, TILE_XY(ptile));
5618 return;
5619 }
5620
5621 /* Handle. */
5622 if (startpos_unpack(psp, packet) && can_client_change_view()) {
5623 /* Notify. */
5626 FALSE);
5627 }
5628}
5629
5630/************************************************************************/
5633void handle_vote_remove(int vote_no)
5634{
5637}
5638
5639/************************************************************************/
5642void handle_vote_update(int vote_no, int yes, int no, int abstain,
5643 int num_voters)
5644{
5645 struct voteinfo *vi;
5646
5648
5649 fc_assert_ret_msg(NULL != vi,
5650 "Got packet_vote_update for non-existent vote %d!",
5651 vote_no);
5652
5653 vi->yes = yes;
5654 vi->no = no;
5655 vi->abstain = abstain;
5656 vi->num_voters = num_voters;
5657
5659}
5660
5661/************************************************************************/
5664void handle_vote_new(const struct packet_vote_new *packet)
5665{
5667 "Got a packet_vote_new for already existing "
5668 "vote %d!", packet->vote_no);
5669
5671 packet->user,
5672 packet->desc,
5673 packet->percent_required,
5674 packet->flags);
5676}
5677
5678/************************************************************************/
5682{
5683 struct voteinfo *vi;
5684
5686
5687 fc_assert_ret_msg(NULL != vi,
5688 "Got packet_vote_resolve for non-existent vote %d!",
5689 vote_no);
5690
5691 vi->resolved = TRUE;
5692 vi->passed = passed;
5693
5695}
5696
5697/************************************************************************/
5700void handle_play_music(const char *tag)
5701{
5702 play_single_track(tag);
5703}
struct achievement * achievement_by_number(int id)
struct action_auto_perf * action_auto_perf_slot_number(const int num)
Definition actions.c:7349
bool action_prob_possible(const struct act_prob probability)
Definition actions.c:6703
void actions_rs_pre_san_gen(void)
Definition actions.c:1520
void action_enabler_add(struct action_enabler *enabler)
Definition actions.c:2442
struct action_enabler * action_enabler_new(void)
Definition actions.c:2396
bool action_id_exists(const action_id act_id)
Definition actions.c:1697
static struct action * action_by_number(action_id act_id)
Definition actions.h:640
#define action_id_requires_details(act_id)
Definition actions.h:678
#define action_array_iterate(_act_list_, _act_id_)
Definition actions.h:506
#define action_array_iterate_end
Definition actions.h:518
#define action_iterate_end
Definition actions.h:474
#define action_iterate(_act_)
Definition actions.h:469
#define action_id_get_target_kind(act_id)
Definition actions.h:657
#define ACTION_NONE
Definition actions.h:295
void agents_unit_changed(struct unit *punit)
Definition agents.c:507
void agents_city_remove(struct city *pcity)
Definition agents.c:636
void agents_thaw_hint(void)
Definition agents.c:436
void agents_tile_remove(struct tile *ptile)
Definition agents.c:663
void agents_city_new(struct city *pcity)
Definition agents.c:610
void agents_start_turn(void)
Definition agents.c:470
void agents_tile_changed(struct tile *ptile)
Definition agents.c:687
void agents_unit_new(struct unit *punit)
Definition agents.c:532
void agents_unit_remove(struct unit *punit)
Definition agents.c:558
void agents_processing_started(void)
Definition agents.c:409
void agents_tile_new(struct tile *ptile)
Definition agents.c:711
void agents_processing_finished(void)
Definition agents.c:418
void agents_new_turn(void)
Definition agents.c:479
void agents_city_changed(struct city *pcity)
Definition agents.c:584
void agents_game_joined(void)
Definition agents.c:445
void agents_freeze_hint(void)
Definition agents.c:427
void agents_before_new_turn(void)
Definition agents.c:462
void attribute_restore(void)
Definition attribute.c:354
void audio_restart(const char *soundset_name, const char *musicset_name)
Definition audio.c:369
void audio_play_sound(const char *const tag, const char *const alt_tag)
Definition audio.c:521
void base_type_init(struct extra_type *pextra, int idx)
Definition base.c:117
struct extra_type * base_extra_get(const struct base_type *pbase)
Definition base.c:101
struct base_type * base_by_number(const Base_type_id id)
Definition base.c:76
bool territory_claiming_base(const struct base_type *pbase)
Definition base.c:158
void dbv_set(struct dbv *pdbv, int bit)
Definition bitvector.c:144
void dbv_clr(struct dbv *pdbv, int bit)
Definition bitvector.c:167
#define BV_SET_VAL(bv, bit, val)
Definition bitvector.h:91
#define BV_CLR_ALL(bv)
Definition bitvector.h:95
#define BV_SET(bv, bit)
Definition bitvector.h:81
#define BV_ARE_EQUAL(vec1, vec2)
Definition bitvector.h:113
#define BV_ISSET(bv, bit)
Definition bitvector.h:78
#define BV_CLR(bv, bit)
Definition bitvector.h:86
bool has_capability(const char *cap, const char *capstr)
Definition capability.c:77
const char *const our_capability
Definition capstr.c:32
void output_window_append(const struct ft_color color, const char *featured_text)
void output_window_printf(const struct ft_color color, const char *format,...)
void citizens_nation_set(struct city *pcity, const struct player_slot *pslot, citizens count)
Definition citizens.c:145
citizens citizens_count(const struct city *pcity)
Definition citizens.c:162
void citizens_init(struct city *pcity)
Definition citizens.c:32
void city_map_radius_sq_set(struct city *pcity, int radius_sq)
Definition city.c:143
void city_name_set(struct city *pcity, const char *new_name)
Definition city.c:1123
struct citystyle * city_styles
Definition city.c:79
void city_styles_alloc(int num)
Definition city.c:3309
const char * city_name_get(const struct city *pcity)
Definition city.c:1115
void city_production_caravan_shields_init(void)
Definition city.c:1751
void city_remove_improvement(struct city *pcity, const struct impr_type *pimprove)
Definition city.c:3284
void city_size_add(struct city *pcity, int add)
Definition city.c:1142
void free_city_map_index(void)
Definition city.c:604
bool city_unhappy(const struct city *pcity)
Definition city.c:1599
struct city * create_city_virtual(struct player *pplayer, struct tile *ptile, const char *name)
Definition city.c:3343
bool city_happy(const struct city *pcity)
Definition city.c:1587
void city_size_set(struct city *pcity, citizens size)
Definition city.c:1158
void city_add_improvement(struct city *pcity, const struct impr_type *pimprove)
Definition city.c:3270
int city_map_radius_sq_get(const struct city *pcity)
Definition city.c:132
void destroy_city_virtual(struct city *pcity)
Definition city.c:3419
void city_rally_point_receive(const struct packet_city_rally_point *packet, struct city *pcity)
Definition city.c:3540
#define city_list_iterate(citylist, pcity)
Definition city.h:488
#define city_tile(_pcity_)
Definition city.h:544
static citizens city_size_get(const struct city *pcity)
Definition city.h:549
#define city_tile_iterate_skip_free_worked(_nmap, _radius_sq, _city_tile, _tile, _index, _x, _y)
Definition city.h:206
@ CITIZEN_LAST
Definition city.h:264
@ CITIZEN_ANGRY
Definition city.h:263
@ CITIZEN_HAPPY
Definition city.h:260
@ CITIZEN_CONTENT
Definition city.h:261
@ CITIZEN_UNHAPPY
Definition city.h:262
#define output_type_iterate(output)
Definition city.h:821
#define city_owner(_pcity_)
Definition city.h:543
#define city_tile_iterate_skip_free_worked_end
Definition city.h:214
#define city_list_iterate_end
Definition city.h:490
#define I_NEVER
Definition city.h:239
@ FEELING_FINAL
Definition city.h:276
@ FEELING_LAST
Definition city.h:277
#define output_type_iterate_end
Definition city.h:827
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:1086
void client_player_init(struct player *pplayer)
Definition climisc.c:1366
void client_remove_city(struct city *pcity)
Definition climisc.c:134
void client_player_maps_reset(void)
Definition climisc.c:1377
void client_remove_unit(struct unit *punit)
Definition climisc.c:72
void unit_focus_set_status(struct player *pplayer)
Definition climisc.c:1356
void handle_event(const char *featured_text, struct tile *ptile, enum event_type event, int turn, int phase, int conn_id)
Definition climisc.c:961
static void city_changed(int city_id)
Definition cma_core.c:448
void send_client_wants_hack(const char *filename)
bool is_server_running(void)
int get_next_request_id(int old_request_id)
Definition connection.c:529
void conn_set_capability(struct connection *pconn, const char *capability)
Definition connection.c:658
struct connection * conn_by_number(int id)
Definition connection.c:420
#define conn_list_iterate(connlist, pconn)
Definition connection.h:113
#define conn_list_iterate_end
Definition connection.h:115
void do_move_unit(struct unit *punit, struct unit *target_unit)
Definition control.c:2689
bool unit_is_in_focus(const struct unit *punit)
Definition control.c:389
void action_selection_no_longer_in_progress(const int old_actor_id)
Definition control.c:1050
struct unit * get_focus_unit_on_tile(const struct tile *ptile)
Definition control.c:397
void action_decision_request(struct unit *actor_unit)
Definition control.c:1109
void set_units_in_combat(struct unit *pattacker, struct unit *pdefender)
Definition control.c:1031
void clear_hover_state(void)
Definition control.c:328
void unit_focus_set(struct unit *punit)
Definition control.c:507
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:1701
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:1079
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:790
void auto_center_on_focus_unit(void)
Definition control.c:435
void request_new_unit_activity(struct unit *punit, enum unit_activity act)
Definition control.c:1854
void action_selection_next_in_focus(const int old_actor_id)
Definition control.c:1091
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
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id popup_bribe_dialog
Definition dialogs_g.h:72
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 * target_city
Definition dialogs_g.h:55
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:273
struct disaster_type * disaster_by_number(Disaster_type_id id)
Definition disaster.c:87
editgui_notify_object_changed
Definition editgui_g.h:27
int int id
Definition editgui_g.h:28
bool editor_is_active(void)
Definition editor.c:347
void editor_ruleset_changed(void)
Definition editor.c:181
@ OBJTYPE_PLAYER
Definition editor.h:30
@ OBJTYPE_UNIT
Definition editor.h:28
@ OBJTYPE_STARTPOS
Definition editor.h:27
@ OBJTYPE_GAME
Definition editor.h:31
@ OBJTYPE_CITY
Definition editor.h:29
@ OBJTYPE_TILE
Definition editor.h:26
void recv_ruleset_effect(const struct packet_ruleset_effect *packet)
Definition effects.c:534
struct @21::@22 reqs
enum event_type event
Definition events.c:81
const char * get_event_tag(enum event_type event)
Definition events.c:274
struct player * extra_owner(const struct tile *ptile)
Definition extras.c:1068
void set_user_extra_flag_name(enum extra_flag_id id, const char *name, const char *helptxt)
Definition extras.c:882
bool extra_has_flag(const struct extra_type *pextra, enum extra_flag_id flag)
Definition extras.c:810
struct extra_type_list * extra_type_list_by_cause(enum extra_cause cause)
Definition extras.c:241
void extra_to_caused_by_list(struct extra_type *pextra, enum extra_cause cause)
Definition extras.c:296
struct extra_type * extra_by_number(int id)
Definition extras.c:175
void extra_to_removed_by_list(struct extra_type *pextra, enum extra_rmcause rmcause)
Definition extras.c:316
struct extra_type_list * extra_type_list_of_terr_claimers(void)
Definition extras.c:259
bool is_extra_removed_by(const struct extra_type *pextra, enum extra_rmcause rmcause)
Definition extras.c:327
struct extra_type_list * extra_type_list_of_unit_hiders(void)
Definition extras.c:251
#define extra_type_iterate(_p)
Definition extras.h:291
#define extra_type_iterate_end
Definition extras.h:297
#define is_extra_caused_by(e, c)
Definition extras.h:196
#define extra_index(_e_)
Definition extras.h:177
#define EXTRA_NONE
Definition extras.h:82
#define EF_LAST_USER_FLAG
Definition extras.h:79
#define MAX_DISASTER_TYPES
Definition fc_types.h:52
#define MAX_GRANARY_INIS
Definition fc_types.h:72
#define MAX_NUM_BUILDING_LIST
Definition fc_types.h:46
int Tech_type_id
Definition fc_types.h:347
#define EC_NATURAL_DEFENSIVE
Definition fc_types.h:970
#define EC_SPECIAL
Definition fc_types.h:968
int action_id
Definition fc_types.h:359
#define SP_MAX
Definition fc_types.h:379
#define EC_NONE
Definition fc_types.h:967
#define EC_NOT_AGGRESSIVE
Definition fc_types.h:971
#define EC_DEFENSIVE
Definition fc_types.h:969
#define MAX_NUM_UNIT_LIST
Definition fc_types.h:45
#define MAX_EXTRA_TYPES
Definition fc_types.h:50
#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:91
@ O_FOOD
Definition fc_types.h:91
@ O_SCIENCE
Definition fc_types.h:91
@ O_GOLD
Definition fc_types.h:91
#define MAX_LEN_CITYNAME
Definition fc_types.h:67
#define UCL_LAST
Definition fc_types.h:387
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:82
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_client
struct civ_game game
Definition game.c:57
void game_ruleset_init(void)
Definition game.c:499
bool is_player_phase(const struct player *pplayer, int phase)
Definition game.c:687
int current_turn_timeout(void)
Definition game.c:828
void game_ruleset_free(void)
Definition game.c:544
struct world wld
Definition game.c:58
struct unit * game_unit_by_number(int id)
Definition game.c:111
struct city * game_city_by_number(int id)
Definition game.c:102
void init_client_goto(void)
Definition goto.c:152
struct ruler_title * government_ruler_title_new(struct government *pgovern, const struct nation_type *pnation, const char *ruler_male_title, const char *ruler_female_title)
Definition government.c:324
struct government * government_by_number(const Government_type_id gov)
Definition government.c:102
struct government * government_of_player(const struct player *pplayer)
Definition government.c:113
void governments_alloc(int num)
Definition government.c:528
Government_type_id government_number(const struct government *pgovern)
Definition government.c:90
int action_selection_target_extra(void)
static int actor_unit_id
int action_selection_target_tile(void)
int action_selection_actor_unit(void)
void action_selection_close(void)
int action_selection_target_city(void)
void action_selection_refresh(struct unit *actor_unit, struct city *target_city, struct unit *target_unit, struct tile *target_tile, struct extra_type *target_extra, const struct act_prob *act_probs)
void popup_sabotage_dialog(struct unit *actor, struct city *pcity, const struct action *paction)
int action_selection_target_unit(void)
void popup_incite_dialog(struct unit *actor, struct city *pcity, int cost, const struct action *paction)
bool city_dialog_is_open(struct city *pcity)
Definition citydlg.c:579
void popdown_all_city_dialogs(void)
Definition citydlg.c:599
void refresh_unit_city_dialogs(struct unit *punit)
Definition citydlg.c:538
void server_connect(void)
Definition connectdlg.c:58
void close_connection_dialog(void)
Definition connectdlg.c:50
void races_update_pickable(bool nationset_change)
Definition dialogs.c:737
void show_tech_gained_dialog(Tech_type_id tech)
Definition dialogs.c:1533
void popdown_races_dialog(void)
Definition dialogs.c:1238
void popup_connect_msg(const char *headline, const char *message)
Definition dialogs.c:243
bool handmade_scenario_warning(void)
Definition dialogs.c:1582
void races_toggles_set_sensitive(void)
Definition dialogs.c:1253
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:1592
void editgui_notify_object_created(int tag, int id)
Definition editgui.c:1921
void editgui_refresh(void)
Definition editgui.c:1795
static GtkWidget * source
Definition gotodlg.c:58
enum gui_type get_gui_type(void)
Definition gui_main.c:1883
void update_infra_dialog(void)
Definition infradlg.c:24
void close_intel_dialog(struct player *p)
Definition inteldlg.c:222
void update_intel_dialog(struct player *p)
Definition inteldlg.c:460
void popup_newcity_dialog(struct unit *punit, const char *suggestname)
Definition mapctrl.c:194
void update_info_label(void)
Definition mapview.c:121
void start_turn(void)
Definition mapview.c:787
void update_unit_info_label(struct unit_list *punits)
Definition mapview.c:258
void update_city_descriptions(void)
Definition mapview.c:470
void update_start_page(void)
Definition pages.c:1672
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:1980
GType type
Definition repodlgs.c:1312
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:57
void voteinfo_gui_update(void)
void conn_list_dialog_update(void)
void boot_help_texts(void)
Definition helpdata.c:799
void idex_register_unit(struct world *iworld, struct unit *punit)
Definition idex.c:81
void idex_unregister_city(struct world *iworld, struct city *pcity)
Definition idex.c:96
void idex_register_city(struct world *iworld, struct city *pcity)
Definition idex.c:66
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:90
Impr_type_id improvement_count(void)
#define improvement_iterate_end
#define improvement_iterate(_p)
#define B_LAST
Definition improvement.h:42
const char * name
Definition inputfile.c:127
#define fc_assert_msg(condition, message,...)
Definition log.h:181
#define fc_assert_ret(condition)
Definition log.h:191
#define log_packet
Definition log.h:137
#define log_warn(message,...)
Definition log.h:105
#define log_verbose(message,...)
Definition log.h:109
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_ret_msg(condition, message,...)
Definition log.h:205
#define fc_assert_ret_val(condition, val)
Definition log.h:194
#define fc_assert_action(condition, action)
Definition log.h:187
#define log_debug(message,...)
Definition log.h:115
#define log_normal(message,...)
Definition log.h:107
@ LOG_NORMAL
Definition log.h:32
#define log_error(message,...)
Definition log.h:103
struct startpos * map_startpos_get(const struct tile *ptile)
Definition map.c:1686
int startpos_number(const struct startpos *psp)
Definition map.c:1436
void map_free(struct civ_map *fmap)
Definition map.c:528
int sq_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:639
struct startpos * map_startpos_new(struct tile *ptile)
Definition map.c:1669
void map_init_topology(struct civ_map *nmap)
Definition map.c:301
void main_map_allocate(void)
Definition map.c:517
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Definition map.c:454
bool map_startpos_remove(struct tile *ptile)
Definition map.c:1702
bool same_pos(const struct tile *tile1, const struct tile *tile2)
Definition map.c:938
bool startpos_unpack(struct startpos *psp, const struct packet_edit_startpos_full *packet)
Definition map.c:1529
struct terrain_misc terrain_control
Definition map.c:69
bool map_is_empty(void)
Definition map.c:149
#define whole_map_iterate(_map, _tile)
Definition map.h:539
#define whole_map_iterate_end
Definition map.h:548
void upgrade_canvas_clipboard(void)
void update_turn_done_button_state(void)
struct city * city_workers_display
void put_nuke_mushroom_pixmaps(struct tile *ptile)
void update_map_canvas_visible(void)
bool tile_visible_mapcanvas(struct tile *ptile)
enum topo_comp_lvl tileset_map_topo_compatible(int topology_id, struct tileset *tset, int *tset_topo)
void refresh_city_mapcanvas(struct city *pcity, struct tile *ptile, bool full_refresh, bool write_to_screen)
void mapdeco_init(void)
void center_tile_mapcanvas(const struct tile *ptile)
void link_marks_decrease_turn_counters(void)
void update_city_description(struct city *pcity)
const char * describe_topology(int topo)
void refresh_tile_mapcanvas(struct tile *ptile, bool full_refresh, bool write_to_screen)
void refresh_unit_mapcanvas(struct unit *punit, struct tile *ptile, bool full_refresh, bool write_to_screen)
void decrease_unit_hp_smooth(struct unit *punit0, int hp0, struct unit *punit1, int hp1)
@ TOPO_INCOMP_HARD
#define fc_calloc(n, esz)
Definition mem.h:38
#define FC_FREE(ptr)
Definition mem.h:41
#define fc_strdup(str)
Definition mem.h:43
#define fc_malloc(sz)
Definition mem.h:34
void menus_update(void)
void meswin_clear_older(int turn, int phase)
int utype_unknown_move_cost(const struct unit_type *utype)
Definition movement.c:105
void init_move_fragments(void)
Definition movement.c:917
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:108
void start_menu_music(const char *const tag, char *const alt_tag)
Definition music.c:90
void start_style_music(void)
Definition music.c:36
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:137
int nation_group_index(const struct nation_group *pgroup)
Definition nation.c:942
Nation_type_id nation_count(void)
Definition nation.c:506
struct nation_group * nation_group_new(const char *name)
Definition nation.c:959
struct nation_type * nation_of_unit(const struct unit *punit)
Definition nation.c:462
struct nation_set * nation_set_new(const char *set_name, const char *set_rule_name, const char *set_description)
Definition nation.c:715
struct nation_type * nation_by_number(const Nation_type_id nation)
Definition nation.c:474
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:761
struct nation_group * nation_group_by_number(int id)
Definition nation.c:1003
struct nation_leader * nation_leader_new(struct nation_type *pnation, const char *name, bool is_male)
Definition nation.c:238
void nations_alloc(int num)
Definition nation.c:621
const char * nation_legend_translation(const struct nation_type *pnation, const char *legend)
Definition nation.c:298
void resend_desired_settable_options(void)
Definition options.c:5742
const char * tileset_name_for_topology(int topology_id)
Definition options.c:6469
struct client_options gui_options
Definition options.c:71
void calculate_overview_dimensions(void)
void generic_handle_player_attribute_chunk(struct player *pplayer, const struct packet_player_attribute_chunk *chunk)
Definition packets.c:690
#define PACKET_STRVEC_EXTRACT(strvec, str)
Definition packets.h:211
#define REQEST_PLAYER_INITIATED
Definition packets.h:70
@ UNIT_INFO_CITY_PRESENT
Definition packets.h:84
@ UNIT_INFO_CITY_SUPPORTED
Definition packets.h:83
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_player_change_government(struct connection *pc, Government_type_id government)
int dsend_packet_unit_get_actions(struct connection *pc, int actor_unit_id16, int actor_unit_id32, int target_unit_id16, int target_unit_id32, int target_tile_id, int target_extra_id, int request_kind)
int send_packet_client_info(struct connection *pc, const struct packet_client_info *packet)
packet_type
void handle_ruleset_game(const struct packet_ruleset_game *packet)
Definition packhand.c:4914
void handle_player_diplstate(const struct packet_player_diplstate *packet)
Definition packhand.c:2934
static action_id auto_attack_act(const struct act_prob *act_probs)
Definition packhand.c:5151
void handle_ruleset_nation_sets(const struct packet_ruleset_nation_sets *packet)
Definition packhand.c:4680
void handle_ruleset_nation(const struct packet_ruleset_nation *packet)
Definition packhand.c:4722
static struct unit * unpackage_short_unit(const struct packet_unit_short_info *packet)
Definition packhand.c:369
void handle_nuke_tile_info(int tile)
Definition packhand.c:573
void handle_unknown_research(int id)
Definition packhand.c:2904
void handle_city_sabotage_list(const struct packet_city_sabotage_list *packet)
Definition packhand.c:5331
const action_id auto_attack_blockers[]
Definition packhand.c:158
void handle_ruleset_government_ruler_title(const struct packet_ruleset_government_ruler_title *packet)
Definition packhand.c:4158
void handle_city_info(const struct packet_city_info *packet)
Definition packhand.c:689
void handle_end_turn(void)
Definition packhand.c:1586
static struct unit * unpackage_unit(const struct packet_unit_info *packet)
Definition packhand.c:261
char * caption
Definition packhand.c:127
enum event_type event
Definition packhand.c:126
void handle_conn_info(const struct packet_conn_info *pinfo)
Definition packhand.c:3038
void handle_vote_remove(int vote_no)
Definition packhand.c:5633
void handle_page_msg_part(const char *lines)
Definition packhand.c:1716
void handle_unit_combat_info(const struct packet_unit_combat_info *packet)
Definition packhand.c:596
void handle_ruleset_style(const struct packet_ruleset_style *p)
Definition packhand.c:4830
void handle_vote_update(int vote_no, int yes, int no, int abstain, int num_voters)
Definition packhand.c:5642
static int last_turn
Definition packhand.c:135
void handle_unit_remove(int unit_id16, int unit_id32)
Definition packhand.c:513
void handle_ruleset_multiplier(const struct packet_ruleset_multiplier *p)
Definition packhand.c:4103
void handle_player_info(const struct packet_player_info *pinfo)
Definition packhand.c:2574
void handle_ruleset_extra(const struct packet_ruleset_extra *p)
Definition packhand.c:4289
void handle_ruleset_action_auto(const struct packet_ruleset_action_auto *p)
Definition packhand.c:4592
static struct @243 invisible
void handle_web_player_info_addition(int playerno, int expected_income)
Definition packhand.c:2813
void handle_ruleset_unit_bonus(const struct packet_ruleset_unit_bonus *p)
Definition packhand.c:3844
void handle_start_phase(int phase)
Definition packhand.c:1513
void start_revolution(void)
Definition packhand.c:2518
void handle_timeout_info(float seconds_to_phasedone, float last_turn_change_time)
Definition packhand.c:2488
void handle_ruleset_terrain_control(const struct packet_ruleset_terrain_control *p)
Definition packhand.c:4667
const action_id auto_attack_actions[]
Definition packhand.c:143
void handle_play_music(const char *tag)
Definition packhand.c:5700
void handle_edit_object_created(int tag, int id)
Definition packhand.c:5556
int parts
Definition packhand.c:130
void handle_conn_ping(void)
Definition packhand.c:5529
void handle_ruleset_tech_class(const struct packet_ruleset_tech_class *p)
Definition packhand.c:4016
void handle_ruleset_control(const struct packet_ruleset_control *packet)
Definition packhand.c:3563
void handle_end_phase(void)
Definition packhand.c:1502
void handle_server_info(const char *version_label, int major_version, int minor_version, int patch_version, int emerg_version)
Definition packhand.c:1669
void handle_ruleset_nation_groups(const struct packet_ruleset_nation_groups *packet)
Definition packhand.c:4701
void handle_ruleset_effect(const struct packet_ruleset_effect *packet)
Definition packhand.c:5545
void handle_new_year(int year, int fragments, int turn)
Definition packhand.c:1453
char * headline
Definition packhand.c:128
void handle_research_info(const struct packet_research_info *packet)
Definition packhand.c:2820
void handle_ruleset_goods(const struct packet_ruleset_goods *p)
Definition packhand.c:4499
void handle_unit_info(const struct packet_unit_info *packet)
Definition packhand.c:1742
void handle_ruleset_city(const struct packet_ruleset_city *packet)
Definition packhand.c:4865
void handle_ruleset_unit_class(const struct packet_ruleset_unit_class *p)
Definition packhand.c:3744
void handle_ruleset_government(const struct packet_ruleset_government *p)
Definition packhand.c:4131
void handle_ruleset_terrain_flag(const struct packet_ruleset_terrain_flag *p)
Definition packhand.c:4245
void handle_connect_msg(const char *message)
Definition packhand.c:1660
#define REQEST_BACKGROUND_REFRESH
Definition packhand.c:138
void handle_rulesets_ready(void)
Definition packhand.c:3690
void handle_tile_info(const struct packet_tile_info *packet)
Definition packhand.c:3268
void handle_ruleset_action(const struct packet_ruleset_action *p)
Definition packhand.c:4524
static void action_decision_handle(struct unit *punit)
Definition packhand.c:1758
void handle_achievement_info(int id, bool gained, bool first)
Definition packhand.c:3167
void handle_scenario_description(const char *description)
Definition packhand.c:3551
void play_sound_for_event(enum event_type type)
Definition packhand.c:1613
void handle_edit_startpos(const struct packet_edit_startpos *packet)
Definition packhand.c:5564
void handle_processing_finished(void)
Definition packhand.c:5464
void handle_city_remove(int city_id16, int city_id32)
Definition packhand.c:484
static int unpack_tech_req(const enum tech_req r_num, const int reqs_size, const struct requirement *reqs, struct advance *a, int i)
Definition packhand.c:3921
void handle_city_name_suggestion_info(int unit_id16, int unit_id32, const char *name)
Definition packhand.c:4985
void handle_city_short_info(const struct packet_city_short_info *packet)
Definition packhand.c:1240
void handle_endgame_player(const struct packet_endgame_player *packet)
Definition packhand.c:5411
void handle_ruleset_resource(const struct packet_ruleset_resource *p)
Definition packhand.c:4270
void handle_web_ruleset_unit_addition(int id, bv_actions utype_actions)
Definition packhand.c:3837
void handle_ruleset_tech(const struct packet_ruleset_tech *p)
Definition packhand.c:3951
void handle_team_name_info(int team_id, const char *team_name)
Definition packhand.c:581
void handle_thaw_client(void)
Definition packhand.c:5518
void handle_calendar_info(const struct packet_calendar_info *pcalendar)
Definition packhand.c:2480
void packhand_free(void)
Definition packhand.c:215
void set_government_choice(struct government *government)
Definition packhand.c:2505
void handle_unit_action_answer(const struct packet_unit_action_answer *packet)
Definition packhand.c:5028
void handle_city_rally_point(const struct packet_city_rally_point *packet)
Definition packhand.c:1074
void handle_ruleset_disaster(const struct packet_ruleset_disaster *p)
Definition packhand.c:4614
static bool handle_unit_packet_common(struct unit *packet_unit)
Definition packhand.c:1796
void handle_ruleset_unit_class_flag(const struct packet_ruleset_unit_class_flag *p)
Definition packhand.c:3889
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:416
void handle_ruleset_summary(const struct packet_ruleset_summary *packet)
Definition packhand.c:3662
void handle_page_msg(const char *caption, const char *headline, enum event_type event, int len, int parts)
Definition packhand.c:1685
void handle_edit_startpos_full(const struct packet_edit_startpos_full *packet)
Definition packhand.c:5602
void handle_conn_ping_info(int connections, const int *conn_id, const float *ping_time)
Definition packhand.c:3144
static bool spaceship_autoplace(struct player *pplayer, struct player_spaceship *ship)
Definition packhand.c:3204
void handle_player_remove(int playerno)
Definition packhand.c:2529
void handle_processing_started(void)
Definition packhand.c:5446
void handle_begin_turn(void)
Definition packhand.c:1572
void handle_endgame_report(const struct packet_endgame_report *packet)
Definition packhand.c:5402
void handle_early_chat_msg(const struct packet_early_chat_msg *packet)
Definition packhand.c:1646
void handle_ruleset_clause(const struct packet_ruleset_clause *p)
Definition packhand.c:4842
void handle_ruleset_road(const struct packet_ruleset_road *p)
Definition packhand.c:4468
void handle_web_city_info_addition(int id16, int id32, int granary_size, int granary_turns)
Definition packhand.c:1040
void handle_unit_actions(const struct packet_unit_actions *packet)
Definition packhand.c:5249
void handle_ruleset_music(const struct packet_ruleset_music *packet)
Definition packhand.c:4891
void handle_ruleset_base(const struct packet_ruleset_base *p)
Definition packhand.c:4447
void notify_about_incoming_packet(struct connection *pc, int packet_type, int size)
Definition packhand.c:5484
void handle_freeze_client(void)
Definition packhand.c:5508
void handle_chat_msg(const struct packet_chat_msg *packet)
Definition packhand.c:1626
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:1094
void handle_trade_route_info(const struct packet_trade_route_info *packet)
Definition packhand.c:1196
void handle_player_attribute_chunk(const struct packet_player_attribute_chunk *packet)
Definition packhand.c:5428
void handle_vote_new(const struct packet_vote_new *packet)
Definition packhand.c:5664
void handle_set_topology(int topology_id)
Definition packhand.c:2346
static void packhand_init(void)
Definition packhand.c:236
void handle_scenario_info(const struct packet_scenario_info *packet)
Definition packhand.c:3530
void handle_ruleset_extra_flag(const struct packet_ruleset_extra_flag *p)
Definition packhand.c:4421
char * lines
Definition packhand.c:129
void notify_about_outgoing_packet(struct connection *pc, int packet_type, int size, int request_id)
Definition packhand.c:5494
#define VALIDATE(_count, _maximum, _string)
const char forced_tileset_name[]
struct city_list * cities
Definition packhand.c:117
void handle_ruleset_tech_flag(const struct packet_ruleset_tech_flag *p)
Definition packhand.c:4029
void handle_nation_availability(int ncount, const bool *is_pickable, bool nationset_change)
Definition packhand.c:4812
void handle_spaceship_info(const struct packet_spaceship_info *p)
Definition packhand.c:3223
void handle_investigate_finished(int unit_id16, int unit_id32, int city_id16, int city_id32)
Definition packhand.c:2252
void handle_ruleset_specialist(const struct packet_ruleset_specialist *p)
Definition packhand.c:4959
void handle_unit_short_info(const struct packet_unit_short_info *packet)
Definition packhand.c:2260
void handle_ruleset_unit_flag(const struct packet_ruleset_unit_flag *p)
Definition packhand.c:3864
void handle_city_nationalities(const struct packet_city_nationalities *packet)
Definition packhand.c:1048
void handle_server_shutdown(void)
Definition packhand.c:5537
void handle_ruleset_building(const struct packet_ruleset_building *p)
Definition packhand.c:4054
void handle_map_info(int xsize, int ysize, int topology_id)
Definition packhand.c:2368
static bool update_improvement_from_packet(struct city *pcity, struct impr_type *pimprove, bool have_impr)
Definition packhand.c:667
void handle_ruleset_unit(const struct packet_ruleset_unit *p)
Definition packhand.c:3762
void handle_ruleset_terrain(const struct packet_ruleset_terrain *p)
Definition packhand.c:4172
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:5181
#define REQEST_BACKGROUND_FAST_AUTO_ATTACK
Definition packhand.c:140
void handle_ruleset_action_enabler(const struct packet_ruleset_action_enabler *p)
Definition packhand.c:4558
void handle_ruleset_achievement(const struct packet_ruleset_achievement *p)
Definition packhand.c:4636
void handle_game_info(const struct packet_game_info *pinfo)
Definition packhand.c:2404
struct player * placeholder
Definition packhand.c:118
void handle_vote_resolve(int vote_no, bool passed)
Definition packhand.c:5681
static struct @244 page_msg_report
void handle_worker_task(const struct packet_worker_task *packet)
Definition packhand.c:1390
void handle_ruleset_description_part(const struct packet_ruleset_description_part *packet)
Definition packhand.c:3680
void handle_ruleset_trade(const struct packet_ruleset_trade *p)
Definition packhand.c:4652
void handle_investigate_started(int unit_id16, int unit_id32, int city_id16, int city_id32)
Definition packhand.c:2220
int len
Definition packhand.c:125
void set_client_page(enum client_pages page)
enum client_pages get_client_page(void)
bool player_slot_is_used(const struct player_slot *pslot)
Definition player.c:441
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
Definition player.c:1205
struct player * player_new(struct player_slot *pslot)
Definition player.c:486
struct player * player_by_number(const int player_id)
Definition player.c:840
int player_count(void)
Definition player.c:808
struct player_slot * player_slot_by_number(int player_id)
Definition player.c:456
int player_number(const struct player *pplayer)
Definition player.c:828
const char * player_name(const struct player *pplayer)
Definition player.c:886
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:820
bool player_set_nation(struct player *pplayer, struct nation_type *pnation)
Definition player.c:852
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Definition player.c:317
bool can_player_see_units_in_city(const struct player *pplayer, const struct city *pcity)
Definition player.c:1113
struct player * player_slot_get_player(const struct player_slot *pslot)
Definition player.c:430
bool can_player_see_city_internals(const struct player *pplayer, const struct city *pcity)
Definition player.c:1129
void player_destroy(struct player *pplayer)
Definition player.c:747
#define players_iterate_end
Definition player.h:535
#define players_iterate(_pplayer)
Definition player.h:530
#define ANON_USER_NAME
Definition player.h:48
#define is_ai(plr)
Definition player.h:234
#define ANON_PLAYER_NAME
Definition player.h:43
#define is_human(plr)
Definition player.h:233
void players_dialog_update(void)
#define fc_rand(_size)
Definition rand.h:34
void multipliers_dialog_update(void)
const struct packet_endgame_player *packet void science_report_dialog_update(void)
void economy_report_dialog_update(void)
void units_report_dialog_update(void)
endgame_report_dialog_player
Definition repodlgs_g.h:33
struct universal universal_by_number(const enum universals_n kind, const int value)
bool are_universals_equal(const struct universal *psource1, const struct universal *psource2)
enum tech_state research_invention_set(struct research *presearch, Tech_type_id tech, enum tech_state value)
Definition research.c:634
struct research * research_by_number(int number)
Definition research.c:116
struct research * research_get(const struct player *pplayer)
Definition research.c:126
void research_update(struct research *presearch)
Definition research.c:499
#define research_players_iterate(_presearch, _pplayer)
Definition research.h:168
#define research_players_iterate_end
Definition research.h:172
void rgbcolor_destroy(struct rgbcolor *prgbcolor)
Definition rgbcolor.c:74
struct rgbcolor * rgbcolor_new(int r, int g, int b)
Definition rgbcolor.c:34
void road_integrators_cache_init(void)
Definition road.c:111
struct road_type * road_by_number(Road_type_id id)
Definition road.c:58
void road_type_init(struct extra_type *pextra, int idx)
Definition road.c:93
void script_client_signal_emit(const char *signal_name,...)
static struct connection connections[MAX_NUM_CONNECTIONS]
Definition sernet.c:94
#define ARRAY_SIZE(x)
Definition shared.h:85
#define MIN(x, y)
Definition shared.h:55
#define MAX(x, y)
Definition shared.h:54
bool next_spaceship_component(struct player *pplayer, struct player_spaceship *ship, struct spaceship_component *fill)
Definition spaceship.c:130
struct specialist * specialist_by_number(const Specialist_type_id id)
Definition specialist.c:100
#define specialist_type_iterate_end
Definition specialist.h:79
#define specialist_type_iterate(sp)
Definition specialist.h:73
#define DEFAULT_SPECIALIST
Definition specialist.h:43
size_t size
Definition specvec.h:72
#define strvec_iterate(psv, str)
#define strvec_iterate_end
enum achievement_type type
struct player * first
bv_player achievers
struct name_translation name
struct requirement_vector reqs
Definition actions.h:576
enum action_auto_perf_cause cause
Definition actions.h:572
action_id alternatives[MAX_NUM_ACTIONS]
Definition actions.h:580
action_id action
Definition actions.h:441
struct requirement_vector actor_reqs
Definition actions.h:442
struct requirement_vector target_reqs
Definition actions.h:443
bool actor_consuming_always
Definition actions.h:414
int max_distance
Definition actions.h:397
bool quiet
Definition actions.h:404
enum action_sub_target_kind sub_target_kind
Definition actions.h:389
enum action_result result
Definition actions.h:384
char ui_name[MAX_LEN_NAME]
Definition actions.h:400
bv_action_sub_results sub_results
Definition actions.h:385
enum action_actor_kind actor_kind
Definition actions.h:387
bv_actions blocked_by
Definition actions.h:408
enum action_target_kind target_kind
Definition actions.h:388
int min_distance
Definition actions.h:397
struct requirement_vector research_reqs
Definition tech.h:137
struct tech_class * tclass
Definition tech.h:130
double cost
Definition tech.h:150
struct advance * require[AR_SIZE]
Definition tech.h:132
struct name_translation name
Definition tech.h:126
struct strvec * helptext
Definition tech.h:140
bv_tech_flags flags
Definition tech.h:139
int num_reqs
Definition tech.h:156
char graphic_str[MAX_LEN_NAME]
Definition tech.h:128
char graphic_alt[MAX_LEN_NAME]
Definition tech.h:129
int border_sq
Definition base.h:44
int vision_main_sq
Definition base.h:45
enum base_gui_type gui_type
Definition base.h:43
int vision_invis_sq
Definition base.h:46
int vision_subs_sq
Definition base.h:47
int turn
Definition city.h:238
Definition city.h:309
struct worker_task_list * task_reqs
Definition city.h:395
int turn_last_built
Definition city.h:373
int surplus[O_LAST]
Definition city.h:343
int food_stock
Definition city.h:354
struct built_status built[B_LAST]
Definition city.h:380
struct player * original
Definition city.h:313
int history
Definition city.h:393
int pollution
Definition city.h:356
bool did_sell
Definition city.h:367
int id
Definition city.h:315
int last_turns_shield_surplus
Definition city.h:378
enum capital_type capital
Definition city.h:317
int disbanded_shields
Definition city.h:377
int waste[O_LAST]
Definition city.h:344
struct unit_list * info_units_present
Definition city.h:457
bv_city_options city_options
Definition city.h:389
int city_radius_sq
Definition city.h:362
bool was_happy
Definition city.h:368
struct player * owner
Definition city.h:312
int turn_founded
Definition city.h:372
int airlift
Definition city.h:365
int citizen_base[O_LAST]
Definition city.h:347
int caravan_shields
Definition city.h:376
bool did_buy
Definition city.h:366
struct unit_list * info_units_supported
Definition city.h:456
char * name
Definition city.h:310
struct trade_route_list * routes
Definition city.h:332
bool occupied
Definition city.h:443
int usage[O_LAST]
Definition city.h:348
struct worklist worklist
Definition city.h:387
struct universal production
Definition city.h:382
int walls
Definition city.h:444
bool happy
Definition city.h:445
struct unit_list * collecting_info_units_supported
Definition city.h:460
int steal
Definition city.h:397
int unhappy_penalty[O_LAST]
Definition city.h:345
unsigned char first_citizen_index
Definition city.h:466
int before_change_shields
Definition city.h:375
int culture
Definition city.h:448
int style
Definition city.h:316
struct unit_list * collecting_info_units_present
Definition city.h:461
int buy_cost
Definition city.h:449
citizens feel[CITIZEN_LAST][FEELING_LAST]
Definition city.h:321
citizens specialists[SP_MAX]
Definition city.h:324
struct tile * tile
Definition city.h:311
int shield_stock
Definition city.h:355
int prod[O_LAST]
Definition city.h:346
int city_image
Definition city.h:447
struct universal changed_from
Definition city.h:385
bool unhappy
Definition city.h:446
struct unit_list * units_supported
Definition city.h:391
int illness_trade
Definition city.h:357
struct city::@17::@20 client
struct requirement_vector reqs
Definition city.h:476
char citizens_graphic[MAX_LEN_NAME]
Definition city.h:475
char graphic_alt[MAX_LEN_NAME]
Definition city.h:474
struct name_translation name
Definition city.h:472
char graphic[MAX_LEN_NAME]
Definition city.h:473
struct civ_game::@29 rgame
struct rgbcolor * plr_bg_color
Definition game.h:102
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:107
struct packet_game_info info
Definition game.h:89
struct civ_game::@30::@33 client
bool ruleset_ready
Definition game.h:116
int global_init_buildings[MAX_NUM_BUILDING_LIST]
Definition game.h:108
struct packet_scenario_info scenario
Definition game.h:87
char * ruleset_description
Definition game.h:85
struct conn_list * all_connections
Definition game.h:96
bool ruleset_init
Definition game.h:115
struct packet_timeout_info tinfo
Definition game.h:91
struct veteran_system * veteran
Definition game.h:100
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:77
int ysize
Definition map_types.h:77
int num_continents
Definition map_types.h:78
int topology_id
Definition map_types.h:72
struct connection conn
Definition client_main.h:96
struct requirement_vector receiver_reqs
Definition diptreaty.h:57
struct requirement_vector giver_reqs
Definition diptreaty.h:56
bool enabled
Definition diptreaty.h:55
bool sound_bell_at_new_turn
Definition options.h:143
bool autoaccept_tileset_suggestion
Definition options.h:176
bool autoaccept_musicset_suggestion
Definition options.h:178
bool draw_city_names
Definition options.h:188
bool draw_city_productions
Definition options.h:190
bool popup_new_cities
Definition options.h:160
bool draw_city_trade_routes
Definition options.h:192
bool wakeup_focus
Definition options.h:152
bool autoaccept_soundset_suggestion
Definition options.h:177
bool ask_city_name
Definition options.h:159
bool draw_city_growth
Definition options.h:189
bool ai_manual_turn_done
Definition options.h:147
int smooth_combat_step_msec
Definition options.h:146
bool draw_full_citybar
Definition options.h:208
bool auto_center_on_combat
Definition options.h:150
bool popup_attack_actions
Definition options.h:162
enum unit_type_flag_id flag
Definition unittype.h:448
enum combat_bonus_type type
Definition unittype.h:449
bool established
Definition connection.h:145
struct player * playing
Definition connection.h:156
struct connection::@57::@62 client
int request_id_of_currently_handled_packet
Definition connection.h:198
enum cmdlevel access_level
Definition connection.h:182
bool observer
Definition connection.h:152
char username[MAX_LEN_NAME]
Definition connection.h:169
struct socket_packet_buffer * send_buffer
Definition connection.h:159
char capability[MAX_LEN_CAPSTR]
Definition connection.h:176
int last_processed_request_id_seen
Definition connection.h:195
char addr[MAX_LEN_ADDR]
Definition connection.h:170
double ping_time
Definition connection.h:166
struct socket_packet_buffer * buffer
Definition connection.h:158
struct name_translation name
Definition disaster.h:48
struct requirement_vector reqs
Definition disaster.h:50
bv_disaster_effects effects
Definition disaster.h:56
bv_unit_classes native_to
Definition extras.h:126
char rmact_gfx[MAX_LEN_NAME]
Definition extras.h:99
bv_extras conflicts
Definition extras.h:129
uint8_t rmcauses
Definition extras.h:92
char act_gfx_alt[MAX_LEN_NAME]
Definition extras.h:97
struct requirement_vector appearance_reqs
Definition extras.h:104
struct strvec * helptext
Definition extras.h:143
bv_extra_flags flags
Definition extras.h:128
char rmact_gfx_alt[MAX_LEN_NAME]
Definition extras.h:100
uint16_t causes
Definition extras.h:91
bv_extras bridged_over
Definition extras.h:131
int removal_time
Definition extras.h:116
int build_time_factor
Definition extras.h:115
struct requirement_vector disappearance_reqs
Definition extras.h:105
bool generated
Definition extras.h:113
int special_idx
Definition extras.h:147
struct requirement_vector rmreqs
Definition extras.h:103
struct extra_type::@24 data
Tech_type_id visibility_req
Definition extras.h:133
enum extra_category category
Definition extras.h:90
char graphic_alt[MAX_LEN_NAME]
Definition extras.h:95
char activity_gfx[MAX_LEN_NAME]
Definition extras.h:96
int disappearance_chance
Definition extras.h:122
int removal_time_factor
Definition extras.h:117
char act_gfx_alt2[MAX_LEN_NAME]
Definition extras.h:98
struct requirement_vector reqs
Definition extras.h:102
bool buildable
Definition extras.h:112
enum extra_unit_seen_type eus
Definition extras.h:124
int defense_bonus
Definition extras.h:120
int appearance_chance
Definition extras.h:121
char graphic_str[MAX_LEN_NAME]
Definition extras.h:94
int build_time
Definition extras.h:114
int infracost
Definition extras.h:118
bv_extras hidden_by
Definition extras.h:130
struct name_translation name
Definition extras.h:87
struct requirement_vector reqs
bv_goods_flags flags
struct strvec * helptext
struct name_translation name
struct strvec * helptext
Definition government.h:62
struct requirement_vector reqs
Definition government.h:59
char graphic_alt[MAX_LEN_NAME]
Definition government.h:58
Government_type_id item_number
Definition government.h:53
struct name_translation name
Definition government.h:54
char graphic_str[MAX_LEN_NAME]
Definition government.h:57
int build_cost
Definition improvement.h:77
char graphic_str[MAX_LEN_NAME]
Definition improvement.h:73
enum impr_genus_id genus
Definition improvement.h:80
char graphic_alt[MAX_LEN_NAME]
Definition improvement.h:74
struct requirement_vector obsolete_by
Definition improvement.h:76
char soundtag_alt[MAX_LEN_NAME]
Definition improvement.h:84
struct requirement_vector reqs
Definition improvement.h:75
struct strvec * helptext
Definition improvement.h:82
struct name_translation name
Definition improvement.h:70
bv_impr_flags flags
Definition improvement.h:81
char soundtag[MAX_LEN_NAME]
Definition improvement.h:83
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
struct requirement_vector reqs
Definition style.h:33
char music_peaceful[MAX_LEN_NAME]
Definition style.h:31
char music_combat[MAX_LEN_NAME]
Definition style.h:32
bool hidden
Definition nation.h:168
struct name_translation name
Definition style.h:24
int init_buildings[MAX_NUM_BUILDING_LIST]
Definition nation.h:122
struct nation_group_list * groups
Definition nation.h:115
struct name_translation noun_plural
Definition nation.h:101
struct nation_set_list * sets
Definition nation.h:112
char flag_graphic_str[MAX_LEN_NAME]
Definition nation.h:102
struct name_translation adjective
Definition nation.h:100
struct nation_type::@50::@53 client
char flag_graphic_alt[MAX_LEN_NAME]
Definition nation.h:103
struct government * init_government
Definition nation.h:123
bool is_pickable
Definition nation.h:160
struct unit_type * init_units[MAX_NUM_UNIT_LIST]
Definition nation.h:124
char * legend
Definition nation.h:106
enum barbarian_type barb_type
Definition nation.h:109
char * translation_domain
Definition nation.h:99
struct nation_style * style
Definition nation.h:105
int init_techs[MAX_NUM_TECH_LIST]
Definition nation.h:121
bool is_playable
Definition nation.h:108
char message[MAX_LEN_MSG]
enum event_type event
int last_turns_shield_surplus
int usage[O_LAST]
int ppl_content[FEELING_LAST]
bv_city_options city_options
enum capital_type capital
int surplus[O_LAST]
int ppl_unhappy[FEELING_LAST]
int citizen_base[O_LAST]
int specialists[SP_MAX]
int ppl_angry[FEELING_LAST]
bv_imprs improvements
struct worklist worklist
char name[MAX_LEN_CITYNAME]
int ppl_happy[FEELING_LAST]
int prod[O_LAST]
int unhappy_penalty[O_LAST]
int waste[O_LAST]
int nation_id[MAX_CITY_NATIONALITIES]
int nation_citizens[MAX_CITY_NATIONALITIES]
enum capital_type capital
char name[MAX_LEN_CITYNAME]
char distribution[MAX_LEN_NAME]
enum gui_type gui
char capability[MAX_LEN_CAPSTR]
char addr[MAX_LEN_ADDR]
char username[MAX_LEN_NAME]
enum cmdlevel access_level
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
enum ai_level ai_skill_level
int multiplier[MAX_NUM_MULTIPLIERS]
char username[MAX_LEN_NAME]
bv_plr_flags flags
enum mood_type mood
bv_player gives_shared_vision
int love[MAX_NUM_PLAYER_SLOTS]
Government_type_id target_government
int multiplier_target[MAX_NUM_MULTIPLIERS]
bool real_embassy[MAX_NUM_PLAYER_SLOTS]
int multiplier_changed[MAX_NUM_MULTIPLIERS]
Nation_type_id nation
enum barbarian_type barbarian_type
char name[MAX_LEN_NAME]
Government_type_id government
int wonders[B_LAST]
char inventions[A_LAST+1]
char rule_name[MAX_LEN_NAME]
enum achievement_type type
char name[MAX_LEN_NAME]
action_id alternatives[MAX_NUM_ACTIONS]
struct requirement reqs[MAX_NUM_REQS]
enum action_auto_perf_cause cause
struct requirement actor_reqs[MAX_NUM_REQS]
struct requirement target_reqs[MAX_NUM_REQS]
enum action_sub_target_kind sub_tgt_kind
enum action_actor_kind act_kind
bv_action_sub_results sub_results
char ui_name[MAX_LEN_NAME]
enum action_target_kind tgt_kind
enum action_result result
enum base_gui_type gui_type
char helptext[MAX_LEN_PACKET]
struct requirement obs_reqs[MAX_NUM_REQS]
char soundtag_alt[MAX_LEN_NAME]
struct requirement reqs[MAX_NUM_REQS]
enum impr_genus_id genus
char name[MAX_LEN_NAME]
char soundtag[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
char graphic_alt[MAX_LEN_NAME]
char citizens_graphic[MAX_LEN_NAME]
char name[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
char graphic_alt[MAX_LEN_NAME]
char graphic[MAX_LEN_NAME]
struct requirement reqs[MAX_NUM_REQS]
enum clause_type type
struct requirement receiver_reqs[MAX_NUM_REQS]
struct requirement giver_reqs[MAX_NUM_REQS]
char preferred_soundset[MAX_LEN_NAME]
char preferred_tileset[MAX_LEN_NAME]
char preferred_musicset[MAX_LEN_NAME]
char text[MAX_LEN_CONTENT]
char rule_name[MAX_LEN_NAME]
struct requirement reqs[MAX_NUM_REQS]
bv_disaster_effects effects
char name[MAX_LEN_NAME]
char helptxt[MAX_LEN_PACKET]
char name[MAX_LEN_NAME]
bv_unit_classes native_to
struct requirement reqs[MAX_NUM_REQS]
char graphic_alt[MAX_LEN_NAME]
char act_gfx_alt2[MAX_LEN_NAME]
struct requirement disappearance_reqs[MAX_NUM_REQS]
bv_extra_flags flags
char act_gfx_alt[MAX_LEN_NAME]
char activity_gfx[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
enum extra_unit_seen_type eus
struct requirement appearance_reqs[MAX_NUM_REQS]
char name[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
char rmact_gfx_alt[MAX_LEN_NAME]
char rmact_gfx[MAX_LEN_NAME]
struct requirement rmreqs[MAX_NUM_REQS]
char helptext[MAX_LEN_PACKET]
int work_raise_chance[MAX_VET_LEVELS]
int base_raise_chance[MAX_VET_LEVELS]
int global_init_techs[MAX_NUM_TECH_LIST]
int move_bonus[MAX_VET_LEVELS]
char veteran_name[MAX_VET_LEVELS][MAX_LEN_NAME]
Impr_type_id global_init_buildings[MAX_NUM_BUILDING_LIST]
int power_fact[MAX_VET_LEVELS]
char helptext[MAX_LEN_PACKET]
bv_goods_flags flags
char name[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
struct requirement reqs[MAX_NUM_REQS]
char graphic_alt[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
char name[MAX_LEN_NAME]
Government_type_id id
char graphic_str[MAX_LEN_NAME]
struct requirement reqs[MAX_NUM_REQS]
char helptext[MAX_LEN_PACKET]
char name[MAX_LEN_NAME]
Multiplier_type_id id
struct requirement reqs[MAX_NUM_REQS]
char rule_name[MAX_LEN_NAME]
char helptext[MAX_LEN_PACKET]
char music_combat[MAX_LEN_NAME]
struct requirement reqs[MAX_NUM_REQS]
char music_peaceful[MAX_LEN_NAME]
char groups[MAX_NUM_NATION_GROUPS][MAX_LEN_NAME]
bool hidden[MAX_NUM_NATION_GROUPS]
char rule_names[MAX_NUM_NATION_SETS][MAX_LEN_NAME]
char names[MAX_NUM_NATION_SETS][MAX_LEN_NAME]
char descriptions[MAX_NUM_NATION_SETS][MAX_LEN_MSG]
int init_techs[MAX_NUM_TECH_LIST]
char leader_name[MAX_NUM_LEADERS][MAX_LEN_NAME]
char noun_plural[MAX_LEN_NAME]
char adjective[MAX_LEN_NAME]
Impr_type_id init_buildings[MAX_NUM_BUILDING_LIST]
Unit_type_id init_units[MAX_NUM_UNIT_LIST]
bool leader_is_male[MAX_NUM_LEADERS]
char translation_domain[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
Government_type_id init_government_id
int groups[MAX_NUM_NATION_GROUPS]
enum barbarian_type barbarian_type
int sets[MAX_NUM_NATION_SETS]
char graphic_alt[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
char legend[MAX_LEN_MSG]
bv_road_flags flags
int tile_incr_const[O_LAST]
enum road_gui_type gui_type
bv_max_extras integrates
enum road_compat compat
enum road_move_mode move_mode
int tile_bonus[O_LAST]
int tile_incr[O_LAST]
struct requirement first_reqs[MAX_NUM_REQS]
char rule_name[MAX_LEN_NAME]
char graphic_alt[MAX_LEN_NAME]
struct requirement reqs[MAX_NUM_REQS]
Specialist_type_id id
char helptext[MAX_LEN_PACKET]
char short_name[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
char plural_name[MAX_LEN_NAME]
char name[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
char text[MAX_LEN_CONTENT]
char name[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
char name[MAX_LEN_NAME]
char helptxt[MAX_LEN_PACKET]
char name[MAX_LEN_NAME]
struct requirement research_reqs[MAX_NUM_REQS]
char graphic_str[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
char graphic_alt[MAX_LEN_NAME]
bv_tech_flags flags
char helptext[MAX_LEN_PACKET]
char name[MAX_LEN_NAME]
char helptxt[MAX_LEN_PACKET]
Terrain_type_id transform_result
char helptext[MAX_LEN_PACKET]
bv_terrain_flags flags
Resource_type_id resources[MAX_RESOURCE_TYPES]
char graphic_str[MAX_LEN_NAME]
bv_unit_classes native_to
Terrain_type_id cultivate_result
Terrain_type_id plant_result
char name[MAX_LEN_NAME]
int road_output_incr_pct[O_LAST]
char graphic_alt[MAX_LEN_NAME]
char rule_name[MAX_LEN_NAME]
enum trade_route_illegal_cancelling cancelling
enum trade_route_bonus_type bonus_type
enum combat_bonus_type type
enum unit_type_flag_id flag
char helptxt[MAX_LEN_PACKET]
char rule_name[MAX_LEN_NAME]
bv_unit_class_flags flags
char name[MAX_LEN_NAME]
char helptext[MAX_LEN_PACKET]
char name[MAX_LEN_NAME]
char helptxt[MAX_LEN_PACKET]
char graphic_alt[MAX_LEN_NAME]
enum vision_layer vlayer
enum transp_def_type tp_defense
char rule_name[MAX_LEN_NAME]
int power_fact[MAX_VET_LEVELS]
char name[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
char sound_fight_alt[MAX_LEN_NAME]
bv_unit_classes disembarks
bv_unit_classes cargo
bv_unit_type_flags flags
char sound_move_alt[MAX_LEN_NAME]
bv_unit_classes targets
struct requirement build_reqs[MAX_NUM_REQS]
int base_raise_chance[MAX_VET_LEVELS]
int work_raise_chance[MAX_VET_LEVELS]
char sound_fight[MAX_LEN_NAME]
bv_unit_classes embarks
char veteran_name[MAX_VET_LEVELS][MAX_LEN_NAME]
char sound_move[MAX_LEN_NAME]
char helptext[MAX_LEN_PACKET]
bv_unit_type_roles roles
int move_bonus[MAX_VET_LEVELS]
char description[MAX_LEN_CONTENT]
char authors[MAX_LEN_PACKET/3]
bv_spaceship_structure structure
Resource_type_id resource
enum known_type known
char label[MAX_LEN_MAP_LABEL]
Continent_id continent
Terrain_type_id terrain
char spec_sprite[MAX_LEN_NAME]
enum route_direction direction
struct act_prob action_probabilities[MAX_NUM_ACTIONS]
int upkeep[O_LAST]
enum action_decision action_decision_want
struct unit_order orders[MAX_LEN_ROUTE]
enum unit_activity activity
Unit_type_id type
enum unit_activity changed_from
enum direction8 facing
enum server_side_agent ssa_controller
enum direction8 facing
char user[MAX_LEN_NAME]
enum unit_activity activity
enum ai_level skill_level
Definition player.h:122
enum barbarian_type barbarian_type
Definition player.h:128
int science_cost
Definition player.h:125
int love[MAX_NUM_PLAYER_SLOTS]
Definition player.h:130
char contact_turns_left
Definition player.h:206
enum diplstate_type type
Definition player.h:201
char has_reason_to_cancel
Definition player.h:205
int infra_points
Definition player.h:74
bv_spaceship_structure structure
Definition spaceship.h:100
double success_rate
Definition spaceship.h:115
double support_rate
Definition spaceship.h:113
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:301
struct government * target_government
Definition player.h:259
char username[MAX_LEN_NAME]
Definition player.h:252
bool is_connected
Definition player.h:296
int revolution_finishes
Definition player.h:273
struct player::@69::@72 client
int nturns_idle
Definition player.h:265
struct government * government
Definition player.h:258
struct dbv tile_known
Definition player.h:306
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:299
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:310
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
bool is_ready
Definition player.h:262
int history
Definition player.h:312
struct rgbcolor * rgb
Definition player.h:308
bool unassigned_user
Definition player.h:253
Tech_type_id researching
Definition research.h:52
int future_tech
Definition research.h:42
Tech_type_id tech_goal
Definition research.h:85
struct research::@75::@77 client
int techs_researched
Definition research.h:42
int total_bulbs_prod
Definition research.h:99
int researching_cost
Definition research.h:98
int bulbs_researched
Definition research.h:53
int output[O_LAST]
Definition terrain.h:49
int g
Definition rgbcolor.h:34
int b
Definition rgbcolor.h:34
int r
Definition rgbcolor.h:34
enum road_gui_type gui_type
Definition road.h:84
struct requirement_vector first_reqs
Definition road.h:86
enum road_move_mode move_mode
Definition road.h:79
int tile_bonus[O_LAST]
Definition road.h:82
int tile_incr_const[O_LAST]
Definition road.h:80
int tile_incr[O_LAST]
Definition road.h:81
bv_road_flags flags
Definition road.h:89
int move_cost
Definition road.h:78
enum road_compat compat
Definition road.h:83
bv_max_extras integrates
Definition road.h:88
enum spaceship_place_type type
Definition spaceship.h:133
struct requirement_vector reqs
Definition specialist.h:38
char graphic_alt[MAX_LEN_NAME]
Definition specialist.h:36
struct strvec * helptext
Definition specialist.h:40
char graphic_str[MAX_LEN_NAME]
Definition specialist.h:35
struct name_translation name
Definition specialist.h:31
struct name_translation abbreviation
Definition specialist.h:32
Definition map.c:41
struct name_translation name
Definition tech.h:119
int cost_pct
Definition tech.h:121
struct terrain * cultivate_result
Definition terrain.h:203
int placing_time
Definition terrain.h:215
struct extra_type ** resources
Definition terrain.h:197
struct strvec * helptext
Definition terrain.h:249
bv_terrain_flags flags
Definition terrain.h:245
bv_unit_classes native_to
Definition terrain.h:243
int road_time
Definition terrain.h:201
struct name_translation name
Definition terrain.h:178
int plant_time
Definition terrain.h:207
struct terrain * plant_result
Definition terrain.h:206
int irrigation_food_incr
Definition terrain.h:209
int clean_fallout_time
Definition terrain.h:220
int defense_bonus
Definition terrain.h:193
int cultivate_time
Definition terrain.h:204
int movement_cost
Definition terrain.h:192
const struct unit_type * animal
Definition terrain.h:223
int pillage_time
Definition terrain.h:221
int output[O_LAST]
Definition terrain.h:195
int transform_time
Definition terrain.h:218
char graphic_alt[MAX_LEN_NAME]
Definition terrain.h:182
int mining_time
Definition terrain.h:213
struct rgbcolor * rgb
Definition terrain.h:247
int clean_pollution_time
Definition terrain.h:219
char graphic_str[MAX_LEN_NAME]
Definition terrain.h:181
enum terrain_class tclass
Definition terrain.h:190
int road_output_incr_pct[O_LAST]
Definition terrain.h:199
struct terrain * transform_result
Definition terrain.h:217
int irrigation_time
Definition terrain.h:210
int base_time
Definition terrain.h:200
int mining_shield_incr
Definition terrain.h:212
Definition tile.h:49
char * spec_sprite
Definition tile.h:65
char * label
Definition tile.h:64
int index
Definition tile.h:50
bv_extras extras
Definition tile.h:54
struct unit_list * units
Definition tile.h:57
struct player * extras_owner
Definition tile.h:62
int infra_turns
Definition tile.h:61
struct extra_type * placing
Definition tile.h:60
struct city * worked
Definition tile.h:58
Continent_id continent
Definition tile.h:53
enum trade_route_bonus_type bonus_type
Definition traderoutes.h:78
enum trade_route_illegal_cancelling cancelling
Definition traderoutes.h:77
enum route_direction dir
Definition traderoutes.h:86
struct goods_type * goods
Definition traderoutes.h:87
int hp_loss_pct
Definition unittype.h:142
int non_native_def_pct
Definition unittype.h:143
int min_speed
Definition unittype.h:141
struct name_translation name
Definition unittype.h:138
struct strvec * helptext
Definition unittype.h:146
bv_unit_class_flags flags
Definition unittype.h:144
enum unit_orders order
Definition unit.h:93
int action
Definition unit.h:100
int transport_capacity
Definition unittype.h:504
struct unit_type::@87 adv
struct unit_class * uclass
Definition unittype.h:537
int pop_cost
Definition unittype.h:493
struct requirement_vector build_reqs
Definition unittype.h:501
int defense_strength
Definition unittype.h:496
bv_unit_classes cargo
Definition unittype.h:539
int firepower
Definition unittype.h:506
int paratroopers_range
Definition unittype.h:522
char graphic_alt[MAX_LEN_NAME]
Definition unittype.h:487
bool worker
Definition unittype.h:556
char sound_move_alt[MAX_LEN_NAME]
Definition unittype.h:489
int build_cost
Definition unittype.h:492
int convert_time
Definition unittype.h:512
int city_size
Definition unittype.h:531
struct veteran_system * veteran
Definition unittype.h:525
const struct unit_type * obsoleted_by
Definition unittype.h:510
int vision_radius_sq
Definition unittype.h:503
int move_rate
Definition unittype.h:497
bv_unit_classes targets
Definition unittype.h:542
enum vision_layer vlayer
Definition unittype.h:550
struct advance * require_advance
Definition unittype.h:500
struct strvec * helptext
Definition unittype.h:552
int bombard_rate
Definition unittype.h:528
char graphic_str[MAX_LEN_NAME]
Definition unittype.h:486
int city_slots
Definition unittype.h:533
char sound_move[MAX_LEN_NAME]
Definition unittype.h:488
char sound_fight_alt[MAX_LEN_NAME]
Definition unittype.h:491
struct name_translation name
Definition unittype.h:483
bv_unit_type_roles roles
Definition unittype.h:516
enum transp_def_type tp_defense
Definition unittype.h:535
int upkeep[O_LAST]
Definition unittype.h:519
bv_unit_classes disembarks
Definition unittype.h:548
const struct unit_type * converted_to
Definition unittype.h:511
bv_unit_type_flags flags
Definition unittype.h:515
char sound_fight[MAX_LEN_NAME]
Definition unittype.h:490
bv_unit_classes embarks
Definition unittype.h:545
int attack_strength
Definition unittype.h:495
int happy_cost
Definition unittype.h:518
struct combat_bonus_list * bonuses
Definition unittype.h:507
Definition unit.h:138
int length
Definition unit.h:195
int upkeep[O_LAST]
Definition unit.h:148
bool has_orders
Definition unit.h:193
bool occupied
Definition unit.h:216
enum action_decision action_decision_want
Definition unit.h:202
int battlegroup
Definition unit.h:191
enum unit_activity activity
Definition unit.h:157
int moves_left
Definition unit.h:150
int id
Definition unit.h:145
bool moved
Definition unit.h:173
int index
Definition unit.h:195
bool vigilant
Definition unit.h:197
int hp
Definition unit.h:151
struct unit::@80::@82 client
struct unit::@79 orders
int fuel
Definition unit.h:153
struct extra_type * changed_from_target
Definition unit.h:170
bool stay
Definition unit.h:205
bool colored
Definition unit.h:219
enum direction8 facing
Definition unit.h:142
bool asking_city_name
Definition unit.h:222
struct extra_type * activity_target
Definition unit.h:164
int activity_count
Definition unit.h:162
struct unit_order * list
Definition unit.h:198
enum unit_activity changed_from
Definition unit.h:168
struct player * nationality
Definition unit.h:144
int transported_by
Definition unit.h:213
bool repeat
Definition unit.h:196
int homecity
Definition unit.h:146
bool paradropped
Definition unit.h:174
bool done_moving
Definition unit.h:181
struct goods_type * carrying
Definition unit.h:186
struct tile * goto_tile
Definition unit.h:155
struct tile * action_decision_tile
Definition unit.h:203
const struct unit_type * utype
Definition unit.h:139
int veteran
Definition unit.h:152
int changed_from_count
Definition unit.h:169
struct player * owner
Definition unit.h:143
enum unit_focus_status focus_status
Definition unit.h:211
enum server_side_agent ssa_controller
Definition unit.h:172
enum universals_n kind
Definition fc_types.h:758
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
bool resolved
Definition voteinfo.h:40
int vote_no
Definition voteinfo.h:31
int no
Definition voteinfo.h:37
enum unit_activity act
Definition workertask.h:23
struct tile * ptile
Definition workertask.h:22
struct extra_type * tgt
Definition workertask.h:24
struct civ_map map
struct nation_style * style_by_number(int id)
Definition style.c:88
void styles_alloc(int count)
Definition style.c:36
struct music_style * music_style_by_number(int id)
Definition style.c:171
void music_styles_alloc(int count)
Definition style.c:133
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
size_t fc_strlcpy(char *dest, const char *src, size_t n)
Definition support.c:787
size_t fc_strlcat(char *dest, const char *src, size_t n)
Definition support.c:832
#define sz_strlcpy(dest, src)
Definition support.h:167
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
int team_count(void)
Definition team.c:375
struct team_slot * team_slot_by_number(int team_id)
Definition team.c:175
bool team_add_player(struct player *pplayer, struct team *pteam)
Definition team.c:467
struct team * team_new(struct team_slot *tslot)
Definition team.c:317
void team_slot_set_defined_name(struct team_slot *tslot, const char *team_name)
Definition team.c:288
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:107
void set_user_tech_flag_name(enum tech_flag_id id, const char *name, const char *helptxt)
Definition tech.c:394
struct tech_class * tech_class_by_number(const int idx)
Definition tech.c:320
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
#define A_FUTURE
Definition tech.h:46
#define A_NEVER
Definition tech.h:51
#define advance_index_iterate_end
Definition tech.h:248
tech_req
Definition tech.h:110
@ AR_TWO
Definition tech.h:112
@ AR_ROOT
Definition tech.h:113
@ AR_ONE
Definition tech.h:111
static Tech_type_id advance_count(void)
Definition tech.h:170
#define A_NONE
Definition tech.h:43
#define A_UNKNOWN
Definition tech.h:49
#define A_LAST
Definition tech.h:45
#define advance_index_iterate(_start, _index)
Definition tech.h:244
Terrain_type_id terrain_count(void)
Definition terrain.c:106
struct terrain * terrain_by_number(const Terrain_type_id type)
Definition terrain.c:144
const char * terrain_rule_name(const struct terrain *pterrain)
Definition terrain.c:235
struct resource_type * resource_type_init(struct extra_type *pextra)
Definition terrain.c:260
void set_user_terrain_flag_name(enum terrain_flag_id id, const char *name, const char *helptxt)
Definition terrain.c:776
#define MAX_RESOURCE_TYPES
Definition terrain.h:67
#define MAX_NUM_TERRAINS
Definition terrain.h:64
void tile_set_terrain(struct tile *ptile, struct terrain *pterrain)
Definition tile.c:124
void tile_set_owner(struct tile *ptile, struct player *pplayer, struct tile *claimer)
Definition tile.c:69
bool tile_set_label(struct tile *ptile, const char *label)
Definition tile.c:1080
void tile_set_resource(struct tile *ptile, struct extra_type *presource)
Definition tile.c:343
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
void tile_set_worked(struct tile *ptile, struct city *pcity)
Definition tile.c:106
#define tile_index(_pt_)
Definition tile.h:87
#define tile_worked(_tile)
Definition tile.h:117
#define tile_resource(_tile)
Definition tile.h:101
known_type
Definition tile.h:34
@ TILE_KNOWN_UNSEEN
Definition tile.h:36
@ TILE_UNKNOWN
Definition tile.h:35
@ TILE_KNOWN_SEEN
Definition tile.h:37
#define tile_list_iterate(tile_list, ptile)
Definition tile.h:72
#define tile_terrain(_tile)
Definition tile.h:113
#define TILE_XY(ptile)
Definition tile.h:42
#define tile_list_iterate_end
Definition tile.h:74
#define tile_owner(_tile)
Definition tile.h:95
void tileset_setup_unit_type(struct tileset *t, struct unit_type *ut)
Definition tilespec.c:3576
void tileset_setup_government(struct tileset *t, struct government *gov)
Definition tilespec.c:4179
void tileset_setup_specialist_type(struct tileset *t, Specialist_type_id id)
Definition tilespec.c:2760
void tileset_setup_tile_type(struct tileset *t, const struct terrain *pterrain)
Definition tilespec.c:3914
void tileset_player_init(struct tileset *t, struct player *pplayer)
Definition tilespec.c:7069
bool unit_drawn_with_city_outline(const struct unit *punit, bool check_focus)
Definition tilespec.c:5267
void tileset_setup_impr_type(struct tileset *t, struct impr_type *pimprove)
Definition tilespec.c:3606
void tileset_background_init(struct tileset *t)
Definition tilespec.c:7149
void tileset_setup_tech_type(struct tileset *t, struct advance *padvance)
Definition tilespec.c:3621
void tileset_setup_city_tiles(struct tileset *t, int style)
Definition tilespec.c:6209
void tilespec_reread_frozen_refresh(const char *tname)
Definition tilespec.c:1484
void tileset_setup_extra(struct tileset *t, struct extra_type *pextra)
Definition tilespec.c:3640
const char * tileset_basename(const struct tileset *t)
Definition tilespec.c:667
void finish_loading_sprites(struct tileset *t)
Definition tilespec.c:3432
const char * tileset_name_get(struct tileset *t)
Definition tilespec.c:7212
void tileset_error(enum log_level level, const char *tset_name, const char *format,...)
Definition tilespec.c:587
bool tilespec_reread(const char *new_tileset_name, bool game_fully_initialized, float scale)
Definition tilespec.c:1299
void tileset_setup_nation_flag(struct tileset *t, struct nation_type *nation)
Definition tilespec.c:4194
void tileset_ruleset_reset(struct tileset *t)
Definition tilespec.c:7184
#define MAX_NUM_CITIZEN_SPRITES
Definition tilespec.h:196
#define NUM_WALL_TYPES
Definition tilespec.h:356
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:2362
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2433
bool unit_transport_unload(struct unit *pcargo)
Definition unit.c:2382
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Definition unit.c:1625
void unit_virtual_destroy(struct unit *punit)
Definition unit.c:1721
void unit_tile_set(struct unit *punit, struct tile *ptile)
Definition unit.c:1289
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2417
struct unit_list * unit_transport_cargo(const struct unit *ptrans)
Definition unit.c:2443
#define unit_tile(_pu)
Definition unit.h:395
@ 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:394
#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:2772
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c:1621
const char * unit_rule_name(const struct unit *punit)
Definition unittype.c:1639
void set_unit_move_type(struct unit_class *puclass)
Definition unittype.c:2940
void set_unit_type_caches(struct unit_type *ptype)
Definition unittype.c:2831
struct unit_class * uclass_by_number(const Unit_Class_id id)
Definition unittype.c:2525
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:2733
struct unit_type * utype_by_number(const Unit_type_id id)
Definition unittype.c:112
void unit_type_action_cache_set(struct unit_type *ptype)
Definition unittype.c:967
void set_user_unit_class_flag_name(enum unit_class_flag_id id, const char *name, const char *helptxt)
Definition unittype.c:1864
struct veteran_system * veteran_system_new(int count)
Definition unittype.c:2702
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Definition unittype.c:443
void set_user_unit_type_flag_name(enum unit_type_flag_id id, const char *name, const char *helptxt)
Definition unittype.c:1928
#define UCF_LAST_USER_FLAG
Definition unittype.h:112
#define unit_class_iterate(_p)
Definition unittype.h:879
#define UTYF_LAST_USER_FLAG
Definition unittype.h:315
#define unit_type_iterate(_p)
Definition unittype.h:841
#define U_LAST
Definition unittype.h:40
#define unit_class_iterate_end
Definition unittype.h:886
#define unit_type_iterate_end
Definition unittype.h:848
void update_queue_processing_finished(int request_id)
void update_queue_processing_started(int request_id)
void unit_select_dialog_update(void)
#define vision_layer_iterate(v)
Definition vision.h: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