Freeciv-3.1
Loading...
Searching...
No Matches
client_main.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 "fc_prehdrs.h"
19
20#ifdef FREECIV_MSWINDOWS
21#include <windows.h> /* LoadLibrary() */
22#endif
23
24#include <math.h>
25#include <signal.h>
26#include <stdarg.h>
27#include <stdio.h>
28#include <stdlib.h>
29#include <time.h>
30
31/* utility */
32#include "bitvector.h"
33#include "capstr.h"
34#include "dataio.h"
35#include "deprecations.h"
36#include "fcbacktrace.h"
37#include "fc_cmdline.h"
38#include "fciconv.h"
39#include "fcintl.h"
40#include "log.h"
41#include "mem.h"
42#include "rand.h"
43#include "registry.h"
44#include "support.h"
45#include "timing.h"
46
47/* common */
48#include "ai.h"
49#include "diptreaty.h"
50#include "fc_cmdhelp.h"
51#include "fc_interface.h"
52#include "game.h"
53#include "idex.h"
54#include "map.h"
55#include "mapimg.h"
56#include "netintf.h"
57#include "packets.h"
58#include "player.h"
59#include "research.h"
60#include "server_settings.h"
61#include "version.h"
62
63/* client/include */
64#include "chatline_g.h"
65#include "citydlg_g.h"
66#include "connectdlg_g.h"
67#include "dialogs_g.h"
68#include "diplodlg_g.h"
69#include "editgui_g.h"
70#include "graphics_g.h"
71#include "gui_main_g.h"
72#include "mapctrl_g.h"
73#include "mapview_g.h"
74#include "menu_g.h"
75#include "messagewin_g.h"
76#include "pages_g.h"
77#include "plrdlg_g.h"
78#include "repodlgs_g.h"
79#include "voteinfo_bar_g.h"
80
81/* client */
82#include "attribute.h"
83#include "audio.h"
84#include "cityrepdata.h"
85#include "climisc.h"
86#include "clinet.h"
87#include "connectdlg_common.h" /* client_kill_server() */
88#include "control.h"
89#include "editor.h"
90#include "global_worklist.h"
91#include "helpdata.h" /* boot_help_texts() */
92#include "mapview_common.h"
93#include "music.h"
94#include "options.h"
95#include "overview_common.h"
96#include "packhand.h"
97#include "tilespec.h"
98#include "themes_common.h"
99#include "update_queue.h"
100#include "voteinfo.h"
101#include "zoom.h"
102
103/* client/agents */
104#include "agents.h"
105#include "cma_core.h" /* kludge */
106
107/* client/luascript */
108#include "script_client.h"
109
110#include "client_main.h"
111
112
113static enum known_type mapimg_client_tile_known(const struct tile *ptile,
114 const struct player *pplayer,
115 bool knowledge);
116static struct terrain
117 *mapimg_client_tile_terrain(const struct tile *ptile,
118 const struct player *pplayer, bool knowledge);
119static struct player *mapimg_client_tile_owner(const struct tile *ptile,
120 const struct player *pplayer,
121 bool knowledge);
122static struct player *mapimg_client_tile_city(const struct tile *ptile,
123 const struct player *pplayer,
124 bool knowledge);
125static struct player *mapimg_client_tile_unit(const struct tile *ptile,
126 const struct player *pplayer,
127 bool knowledge);
128static int mapimg_client_plrcolor_count(void);
129static struct rgbcolor *mapimg_client_plrcolor_get(int i);
130
131static void fc_interface_init_client(void);
132
133char *logfile = NULL;
134char *scriptfile = NULL;
135char *savefile = NULL;
136char forced_tileset_name[512] = "\0";
137char sound_plugin_name[512] = "\0";
138char sound_set_name[512] = "\0";
139char music_set_name[512] = "\0";
140char server_host[512] = "\0";
141char user_name[512] = "\0";
143char metaserver[512] = "\0";
144int server_port = -1;
145bool auto_connect = FALSE; /* TRUE = skip "Connect to Freeciv Server" dialog */
146bool auto_spawn = FALSE; /* TRUE = skip main menu, start local server */
148
150
152
153/* TRUE if an end turn request is blocked by busy agents */
155
156/*
157 * TRUE between receiving PACKET_END_TURN and PACKET_BEGIN_TURN
158 */
159static bool server_busy = FALSE;
160
161#ifdef FREECIV_DEBUG
162bool hackless = FALSE;
163#endif
164
165static bool client_quitting = FALSE;
166
167/**********************************************************************/
171static char *put_conv(const char *src, size_t *length)
172{
173 char *out = internal_to_data_string_malloc(src);
174
175 if (out) {
176 *length = strlen(out);
177 return out;
178 } else {
179 *length = 0;
180 return NULL;
181 }
182}
183
184/**********************************************************************/
189static bool get_conv(char *dst, size_t ndst,
190 const char *src, size_t nsrc)
191{
192 char *out = data_to_internal_string_malloc(src);
193 bool ret = TRUE;
194 size_t len;
195
196 if (!out) {
197 dst[0] = '\0';
198 return FALSE;
199 }
200
201 len = strlen(out);
202 if (ndst > 0 && len >= ndst) {
203 ret = FALSE;
204 len = ndst - 1;
205 }
206
207 memcpy(dst, out, len);
208 dst[len] = '\0';
209 free(out);
210
211 return ret;
212}
213
214/**********************************************************************/
222
223/**********************************************************************/
227static void emergency_exit(void)
228{
230}
231
232/**********************************************************************/
235static void at_exit(void)
236{
242}
243
244/**********************************************************************/
266
267/**********************************************************************/
270static void client_game_free(void)
271{
273
275 mapimg_free();
280 control_free();
283 agents_free();
286 game_free();
287 /* update_queue_init() is correct at this point. The queue is reset to
288 a clean state which is also needed if the client is not connected to
289 the server! */
291
292 client.conn.playing = NULL;
294}
295
296/**********************************************************************/
300static void client_game_reset(void)
301{
303
306 control_free();
308 agents_free();
309
310 game_reset();
311 mapimg_reset();
312
314 agents_init();
315 control_init();
317}
318
319/**********************************************************************/
323{
325
326 if (forced_tileset_name[0] != '\0') {
328 log_error(_("Can't load requested tileset %s!"), forced_tileset_name);
329 client_exit(EXIT_FAILURE);
330 return EXIT_FAILURE;
331 }
332 } else {
334 }
335
336 editor_init();
337
338 return EXIT_SUCCESS;
339}
340
341/**********************************************************************/
344int client_main(int argc, char *argv[], bool postpone_tileset)
345{
346 int i;
347 enum log_level loglevel = LOG_NORMAL;
348 int ui_options = 0;
349 bool ui_separator = FALSE;
350 char *option = NULL;
351 int fatal_assertions = -1;
352 int aii;
353 int uret;
354
355 /* Load Windows post-crash debugger */
356#ifdef FREECIV_MSWINDOWS
357# ifndef FREECIV_NDEBUG
358 if (LoadLibrary("exchndl.dll") == NULL) {
359# ifdef FREECIV_DEBUG
360 fprintf(stderr, "exchndl.dll could not be loaded, no crash debugger\n");
361# endif /* FREECIV_DEBUG */
362 }
363# endif /* FREECIV_NDEBUG */
364#endif /* FREECIV_MSWINDOWS */
365
366 /* fc_interface_init_client() includes low level support like
367 * guaranteeing that fc_vsnprintf() will work after it,
368 * so this need to be early. */
370
371 i_am_client(); /* Tell to libfreeciv that we are client */
372
374
375 /* Ensure that all AIs are initialized to unused state
376 * Not using ai_type_iterate as it would stop at
377 * current ai type count, ai_type_get_count(), i.e., 0 */
378 for (aii = 0; aii < FREECIV_AI_MOD_LAST; aii++) {
379 struct ai_type *ai = get_ai_type(aii);
380
381 init_ai(ai);
382 }
383
384#ifdef ENABLE_NLS
385 (void) bindtextdomain("freeciv-nations", get_locale_dir());
386#endif
387
389 audio_init();
391#ifdef ENABLE_NLS
392 bind_textdomain_codeset("freeciv-nations", get_internal_encoding());
393#endif
394
395 i = 1;
396
398
399 while (i < argc) {
400 if (ui_separator) {
401 argv[1 + ui_options] = argv[i];
402 ui_options++;
403 } else if (is_option("--help", argv[i])) {
404 struct cmdhelp *help = cmdhelp_new(argv[0]);
405
406 cmdhelp_add(help, "A",
407 /* TRANS: "Announce" is exactly what user must type, do not translate. */
408 _("Announce PROTO"),
409 _("Announce game in LAN using protocol PROTO "
410 "(IPv4/IPv6/none)"));
411 cmdhelp_add(help, "a", "autoconnect",
412 _("Skip connect dialog"));
413#ifdef FREECIV_DEBUG
414 cmdhelp_add(help, "d",
415 /* TRANS: "debug" is exactly what user must type, do not translate. */
416 _("debug LEVEL"),
417 _("Set debug log level (one of f,e,w,n,v,d, or "
418 "d:file1,min,max:...)"));
419#else /* FREECIV_DEBUG */
420 cmdhelp_add(help, "d",
421 /* TRANS: "debug" is exactly what user must type, do not translate. */
422 _("debug LEVEL"),
423 _("Set debug log level (one of f,e,w,n,v)"));
424#endif /* FREECIV_DEBUG */
425#ifndef FREECIV_NDEBUG
426 cmdhelp_add(help, "F",
427 /* TRANS: "Fatal" is exactly what user must type, do not translate. */
428 _("Fatal [SIGNAL]"),
429 _("Raise a signal on failed assertion"));
430#endif /* FREECIV_NDEBUG */
431 cmdhelp_add(help, "f",
432 /* TRANS: "file" is exactly what user must type, do not translate. */
433 _("file FILE"),
434 _("Load saved game FILE"));
435 cmdhelp_add(help, "h", "help",
436 _("Print a summary of the options"));
437#ifdef FREECIV_DEBUG
438 cmdhelp_add(help, "H", "Hackless",
439 _("Do not request hack access to local, but not spawned, server"));
440#endif /* FREECIV_DEBUG */
441 cmdhelp_add(help, "l",
442 /* TRANS: "log" is exactly what user must type, do not translate. */
443 _("log FILE"),
444 _("Use FILE as logfile (spawned server also uses this)"));
445 cmdhelp_add(help, "M",
446 /* TRANS: "Meta" is exactly what user must type, do not translate. */
447 _("Meta HOST"),
448 _("Connect to the metaserver at HOST"));
449 cmdhelp_add(help, "n",
450 /* TRANS: "name" is exactly what user must type, do not translate. */
451 _("name NAME"),
452 _("Use NAME as username on server"));
453 cmdhelp_add(help, "p",
454 /* TRANS: "port" is exactly what user must type, do not translate. */
455 _("port PORT"),
456 _("Connect to server port PORT (usually with -a)"));
457 cmdhelp_add(help, "P",
458 /* TRANS: "Plugin" is exactly what user must type, do not translate. */
459 _("Plugin PLUGIN"),
460 _("Use PLUGIN for sound output %s"),
462 cmdhelp_add(help, "r",
463 /* TRANS: "read" is exactly what user must type, do not translate. */
464 _("read FILE"),
465 _("Read startup script FILE (for spawned server only)"));
466 cmdhelp_add(help, "s",
467 /* TRANS: "server" is exactly what user must type, do not translate. */
468 _("server HOST"),
469 _("Connect to the server at HOST (usually with -a)"));
470 cmdhelp_add(help, "S",
471 /* TRANS: "Sound" is exactly what user must type, do not translate. */
472 _("Sound FILE"),
473 _("Read sound tags from FILE"));
474 cmdhelp_add(help, "m",
475 /* TRANS: "music" is exactly what user must type, do not translate. */
476 _("music FILE"),
477 _("Read music tags from FILE"));
478 cmdhelp_add(help, "t",
479 /* TRANS: "tiles" is exactly what user must type, do not translate. */
480 _("tiles FILE"),
481 _("Use data file FILE.tilespec for tiles"));
482 cmdhelp_add(help, "v", "version",
483 _("Print the version number"));
484 cmdhelp_add(help, "w", "warnings",
485 _("Warn about deprecated modpack constructs"));
486
487 /* The function below prints a header and footer for the options.
488 * Furthermore, the options are sorted. */
489 cmdhelp_display(help, TRUE, TRUE, TRUE);
490 cmdhelp_destroy(help);
491
492 exit(EXIT_SUCCESS);
493 } else if (is_option("--version", argv[i])) {
494 fc_fprintf(stderr, "%s %s\n", freeciv_name_version(), client_string);
495 exit(EXIT_SUCCESS);
496#ifdef FREECIV_DEBUG
497 } else if (is_option("--Hackless", argv[i])) {
498 hackless = TRUE;
499#endif /* FREECIV_DEBUG */
500 } else if ((option = get_option_malloc("--log", argv, &i, argc, TRUE))) {
501 logfile = option;
502#ifndef FREECIV_NDEBUG
503 } else if (is_option("--Fatal", argv[i])) {
504 if (i + 1 >= argc || '-' == argv[i + 1][0]) {
505 fatal_assertions = SIGABRT;
506 } else if (str_to_int(argv[i + 1], &fatal_assertions)) {
507 i++;
508 } else {
509 fc_fprintf(stderr, _("Invalid signal number \"%s\".\n"),
510 argv[i + 1]);
511 fc_fprintf(stderr, _("Try using --help.\n"));
512 exit(EXIT_FAILURE);
513 }
514#endif /* FREECIV_NDEBUG */
515 } else if ((option = get_option_malloc("--read", argv, &i, argc, TRUE))) {
517 } else if ((option = get_option_malloc("--file", argv, &i, argc, TRUE))) {
520 } else if ((option = get_option_malloc("--name", argv, &i, argc, FALSE))) {
522 free(option);
523 } else if ((option = get_option_malloc("--Meta", argv, &i, argc, FALSE))) {
525 free(option);
526 } else if ((option = get_option_malloc("--Sound", argv, &i, argc, FALSE))) {
528 free(option);
529 } else if ((option = get_option_malloc("--music", argv, &i, argc, FALSE))) {
531 free(option);
532 } else if ((option = get_option_malloc("--Plugin", argv, &i, argc, FALSE))) {
534 free(option);
535 } else if ((option = get_option_malloc("--port", argv, &i, argc, FALSE))) {
536 if (!str_to_int(option, &server_port)) {
537 fc_fprintf(stderr,
538 _("Invalid port \"%s\" specified with --port option.\n"),
539 option);
540 fc_fprintf(stderr, _("Try using --help.\n"));
541 exit(EXIT_FAILURE);
542 }
543 free(option);
544 } else if ((option = get_option_malloc("--server", argv, &i, argc, FALSE))) {
546 free(option);
547 } else if (is_option("--autoconnect", argv[i])) {
549 } else if ((option = get_option_malloc("--debug", argv, &i, argc, FALSE))) {
550 if (!log_parse_level_str(option, &loglevel)) {
551 fc_fprintf(stderr,
552 _("Invalid debug level \"%s\" specified with --debug "
553 "option.\n"), option);
554 fc_fprintf(stderr, _("Try using --help.\n"));
555 exit(EXIT_FAILURE);
556 }
557 free(option);
558 } else if ((option = get_option_malloc("--tiles", argv, &i, argc, FALSE))) {
560 free(option);
561 } else if ((option = get_option_malloc("--Announce", argv, &i, argc, FALSE))) {
562 if (!fc_strcasecmp(option, "ipv4")) {
564 } else if (!fc_strcasecmp(option, "none")) {
566#ifdef FREECIV_IPV6_SUPPORT
567 } else if (!fc_strcasecmp(option, "ipv6")) {
569#endif /* IPv6 support */
570 } else {
571 fc_fprintf(stderr, _("Invalid announce protocol \"%s\".\n"), option);
572 exit(EXIT_FAILURE);
573 }
574 free(option);
575 } else if (is_option("--warnings", argv[i])) {
577 } else if (is_option("--", argv[i])) {
578 ui_separator = TRUE;
579 } else {
580 fc_fprintf(stderr, _("Unrecognized option: \"%s\"\n"), argv[i]);
581 exit(EXIT_FAILURE);
582 }
583 i++;
584 } /* of while */
585
586 if (auto_spawn && auto_connect) {
587 /* TRANS: don't translate option names */
588 fc_fprintf(stderr, _("-f/--file and -a/--autoconnect options are "
589 "incompatible\n"));
590 exit(EXIT_FAILURE);
591 }
592
593 /* Remove all options except those intended for the UI. */
594 argv[1 + ui_options] = NULL;
595 argc = 1 + ui_options;
596
597 /* disallow running as root -- too dangerous */
598 dont_run_as_root(argv[0], "freeciv_client");
599
600 log_init(logfile, loglevel, NULL, NULL, fatal_assertions);
602
603 /* after log_init: */
604
607 char buf[sizeof(gui_options.default_user_name)];
608
609 fc_snprintf(buf, sizeof(buf), "_%s", gui_options.default_user_name);
610 if (is_valid_username(buf)) {
612 } else {
615 "player%d", fc_rand(10000));
616 }
617 }
618
619 /* initialization */
620
621 game.all_connections = conn_list_new();
622 game.est_connections = conn_list_new();
623
624 ui_init();
628
630
631 /* register exit handler */
632 atexit(at_exit);
634
637 init_themes();
638
639 options_init();
640 options_load();
641
643
644 if (sound_set_name[0] == '\0') {
646 }
647 if (music_set_name[0] == '\0') {
649 }
650 if (sound_plugin_name[0] == '\0') {
652 }
653 if (server_host[0] == '\0') {
655 } else if (gui_options.use_prev_server) {
657 }
658 if (user_name[0] == '\0') {
660 }
661 if (metaserver[0] == '\0') {
662 /* FIXME: Find a cleaner way to achieve this. */
663 /* www.cazfi.net/freeciv/metaserver/ was default metaserver
664 * over one release when meta.freeciv.org was unavailable. */
665 const char *oldaddr = "http://www.cazfi.net/freeciv/metaserver/";
666
667 if (0 == strcmp(gui_options.default_metaserver, oldaddr)) {
668 log_normal(_("Updating old metaserver address \"%s\"."), oldaddr);
670 log_normal(_("Default metaserver has been set to value \"%s\"."),
672 }
674 sz_strlcpy(metaserver, FREECIV_META_URL);
675 } else {
677 }
678 }
679 if (server_port == -1) {
681 } else if (gui_options.use_prev_server) {
683 }
684
685 /* This seed is not saved anywhere; randoms in the client should
686 have cosmetic effects only (eg city name suggestions). --dwp */
687 fc_srand(time(NULL));
690
692 start_menu_music("music_menu", NULL);
693
694 if (!postpone_tileset) {
695 int tsret = default_tileset_select();
696
697 if (tsret != EXIT_SUCCESS) {
698 return tsret;
699 }
700 }
701
702 /* run gui-specific client */
703 uret = ui_main(argc, argv);
704
705 /* termination */
706 client_exit(uret);
707
708 /* not reached */
709 return EXIT_SUCCESS;
710}
711
712/**********************************************************************/
715static void log_option_save_msg(enum log_level lvl, const char *msg, ...)
716{
717 va_list args;
718
719 va_start(args, msg);
720 log_va_list(lvl, msg, args);
721 va_end(args);
722}
723
724/**********************************************************************/
728void client_exit(int return_value)
729{
730 if (client_state() >= C_S_PREPARING) {
733 }
734
737 }
738
740 if (unscaled_tileset != NULL) {
742 }
743 if (tileset != NULL) {
745 }
746
747 ui_exit();
748
749 /* Play the exit sound while audio system dependencies still up. */
751
753
754 editor_free();
755 options_free();
756 if (client_state() >= C_S_PREPARING) {
758 }
759
760 helpdata_done(); /* client_exit() unlinks help text list */
761 conn_list_destroy(game.all_connections);
762 conn_list_destroy(game.est_connections);
763
766
768 log_close();
770
771 exit(return_value);
772}
773
774/**********************************************************************/
777void client_packet_input(void *packet, int type)
778{
788 && PACKET_SERVER_INFO != type) {
789 log_error("Received packet %s (%d) before establishing connection!",
792 } else if (!client_handle_packet(type, packet)) {
793 log_error("Received unknown packet (type %d) from server!", type);
795 }
796}
797
798/**********************************************************************/
802{
804}
805
806/**********************************************************************/
810{
811 log_debug("send_turn_done() can_end_turn=%d",
812 can_end_turn());
813
814 if (!can_end_turn()) {
815 /*
816 * The turn done button is disabled but the user may have pressed
817 * the return key.
818 */
819
820 if (agents_busy()) {
822 }
823
824 return;
825 }
826
828
830
832
834}
835
836/**********************************************************************/
843
844/**********************************************************************/
848{
849 enum client_states oldstate = civclient_state;
850 struct player *pplayer = client_player();
851
852 if (auto_spawn) {
855 if (!client_start_server()) {
856 log_fatal(_("Failed to start local server; aborting."));
857 exit(EXIT_FAILURE);
858 }
859 }
860
861 if (auto_connect && newstate == C_S_DISCONNECTED) {
862 if (oldstate == C_S_DISCONNECTED) {
863 log_fatal(_("There was an error while auto connecting; aborting."));
864 exit(EXIT_FAILURE);
865 } else {
867 auto_connect = FALSE; /* Don't try this again. */
868 }
869 }
870
871 if (C_S_PREPARING == newstate
873 /* Reset the delta-state. */
875 }
876
877 if (oldstate == newstate) {
878 return;
879 }
880
881 if (oldstate == C_S_RUNNING && newstate != C_S_PREPARING) {
883
884 if (!is_client_quitting()) {
885 /* Back to menu */
886 start_menu_music("music_menu", NULL);
887 }
888 }
889
890 civclient_state = newstate;
891
892 switch (newstate) {
893 case C_S_INITIAL:
894 log_error("%d is not a valid client state to set.", C_S_INITIAL);
895 break;
896
897 case C_S_DISCONNECTED:
902
903 if (oldstate > C_S_DISCONNECTED) {
904 unit_focus_set(NULL);
906 editor_clear();
910 if (oldstate > C_S_PREPARING) {
912 }
913 }
914
915 set_client_page(PAGE_MAIN);
916 break;
917
918 case C_S_PREPARING:
923
924 if (oldstate < C_S_PREPARING) {
926 } else {
927 /* From an upper state means that we didn't quit the server,
928 * so a lot of informations are still in effect. */
931 }
932
933 unit_focus_set(NULL);
934
935 if (get_client_page() != PAGE_SCENARIO
936 && get_client_page() != PAGE_LOAD) {
937 set_client_page(PAGE_START);
938 }
939 break;
940
941 case C_S_RUNNING:
942 if (oldstate == C_S_PREPARING) {
944 stop_menu_music(); /* stop intro sound loop. */
945 }
946
949 create_event(NULL, E_GAME_START, ftc_client, _("Game started."));
950 if (pplayer) {
952 }
954 boot_help_texts(); /* reboot with player */
958 can_slide = TRUE;
959 set_client_page(PAGE_GAME);
960 /* Find something sensible to display instead of the intro gfx. */
965
967
968 update_info_label(); /* get initial population right */
971
974 }
976 break;
977
978 case C_S_OVER:
979 if (C_S_RUNNING == oldstate) {
980 /* Extra kludge for end-game handling of the CMA. */
981 if (pplayer && pplayer->cities) {
982 city_list_iterate(pplayer->cities, pcity) {
983 if (cma_is_city_under_agent(pcity, NULL)) {
984 cma_release_city(pcity);
985 }
987 }
991 unit_focus_set(NULL);
992 } else {
993 /* From C_S_PREPARING. */
996 if (pplayer) {
998 }
1000 boot_help_texts(); /* reboot */
1002 unit_focus_set(NULL);
1003 set_client_page(PAGE_GAME);
1005 }
1007
1011
1012 break;
1013 }
1014
1015 menus_init();
1018 if (can_client_change_view()) {
1020 }
1021
1022 /* If turn was going to change, that is now aborted. */
1024}
1025
1026/**********************************************************************/
1030{
1031 return civclient_state;
1032}
1033
1034/**********************************************************************/
1038{
1039 fc_assert_msg(pconn != NULL,
1040 "Trying to remove a non existing connection");
1041
1042 if (NULL != pconn->playing) {
1043 conn_list_remove(pconn->playing->connections, pconn);
1044 }
1045 conn_list_remove(game.all_connections, pconn);
1046 conn_list_remove(game.est_connections, pconn);
1047 fc_assert_ret(pconn != &client.conn);
1048 free(pconn);
1049}
1050
1051/**********************************************************************/
1056{
1058 "Connection list missing");
1059
1060 while (conn_list_size(game.all_connections) > 0) {
1061 struct connection *pconn = conn_list_get(game.all_connections, 0);
1063 }
1064}
1065
1066/**********************************************************************/
1073
1074/**********************************************************************/
1082
1083/**********************************************************************/
1087{
1089}
1090
1091/* Seconds_to_turndone is the number of seconds the server has told us
1092 * are left. The timer tells exactly how much time has passed since the
1093 * server gave us that data. */
1094static double seconds_to_turndone = 0.0;
1095static struct timer *turndone_timer;
1096
1097/* The timer tells how long since server informed us about starting
1098 * turn-change activities. */
1099static struct timer *between_turns = NULL;
1101
1102/* This value shows what value the timeout label is currently showing for
1103 * the seconds-to-turndone. */
1106
1107/**********************************************************************/
1113void set_seconds_to_turndone(double seconds)
1114{
1115 if (current_turn_timeout() > 0) {
1116 seconds_to_turndone = seconds;
1119
1120 /* Maybe we should do an update_timeout_label here, but it doesn't
1121 * seem to be necessary. */
1122 seconds_shown_to_turndone = ceil(seconds + 0.1);
1123 }
1124}
1125
1126/**********************************************************************/
1130{
1131 return waiting_turn_change;
1132}
1133
1134/**********************************************************************/
1145
1146/**********************************************************************/
1154
1155/**********************************************************************/
1160{
1161 if (current_turn_timeout() > 0) {
1163 } else {
1164 /* This shouldn't happen. */
1165 return FC_INFINITY;
1166 }
1167}
1168
1169/**********************************************************************/
1174{
1176}
1177
1178/**********************************************************************/
1184{
1185 double time_until_next_call = 1.0;
1186
1188
1189 {
1190 double autoconnect_time = try_to_autoconnect();
1191 time_until_next_call = MIN(time_until_next_call, autoconnect_time);
1192 }
1193
1194 if (C_S_RUNNING != client_state()) {
1195 return time_until_next_call;
1196 }
1197
1198 time_until_next_call = zoom_update(time_until_next_call);
1199
1200 {
1201 double blink_time = blink_turn_done_button();
1202
1203 time_until_next_call = MIN(time_until_next_call, blink_time);
1204 }
1205
1206 if (get_num_units_in_focus() > 0) {
1207 double blink_time = blink_active_unit();
1208
1209 time_until_next_call = MIN(time_until_next_call, blink_time);
1210 }
1211
1212 /* It is possible to have current_turn_timeout() > 0 but !turndone_timer,
1213 * in the first moments after the timeout is set. */
1214 if (current_turn_timeout() > 0 && turndone_timer != NULL) {
1216 int iseconds = ceil(seconds + 0.1); /* Turn should end right on 0. */
1217
1218 if (iseconds < seconds_shown_to_turndone) {
1219 seconds_shown_to_turndone = iseconds;
1221 }
1222
1223 time_until_next_call = MIN(time_until_next_call,
1224 seconds - floor(seconds) + 0.001);
1225 }
1226 if (waiting_turn_change) {
1228 int iseconds = ceil(seconds + 0.1); /* Turn should end right on 0. */
1229
1230 if (iseconds < game.tinfo.last_turn_change_time) {
1231 seconds_shown_to_new_turn = iseconds;
1233 }
1234 }
1235
1236 {
1237 static long counter = 0;
1238
1239 counter++;
1240
1241 if (gui_options.heartbeat_enabled && (counter % (20 * 10) == 0)) {
1243 }
1244 }
1245
1246 /* Make sure we wait at least 50 ms, otherwise we may not give any other
1247 * code time to run. */
1248 return MAX(time_until_next_call, 0.05);
1249}
1250
1251/**********************************************************************/
1255{
1256 return (NULL != client.conn.playing
1257 && !client_is_observer());
1258}
1259
1260/**********************************************************************/
1266{
1267 return (can_client_control()
1268 && C_S_RUNNING == client_state());
1269}
1270
1271/**********************************************************************/
1275bool can_meet_with_player(const struct player *pplayer)
1276{
1277 return (can_client_issue_orders()
1278 /* && NULL != client.conn.playing (above) */
1280}
1281
1282/**********************************************************************/
1286bool can_intel_with_player(const struct player *pplayer)
1287{
1288 return (client_is_observer()
1289 || (NULL != client.conn.playing
1290 && could_intel_with_player(client_player(), pplayer)));
1291}
1292
1293/**********************************************************************/
1297const char *title_for_player(const struct player *pplayer,
1298 char *buf, size_t buf_len)
1299{
1300 if (client_player() == pplayer || can_intel_with_player(pplayer)) {
1301 /* Knows the government to construct correct title */
1302 return ruler_title_for_player(pplayer, buf, buf_len);
1303 }
1304
1305 return default_title_for_player(pplayer, buf, buf_len);
1306}
1307
1308/**********************************************************************/
1314{
1315 return ((NULL != client.conn.playing || client_is_observer())
1316 && (C_S_RUNNING == client_state()
1317 || C_S_OVER == client_state()));
1318}
1319
1320/**********************************************************************/
1324void set_server_busy(bool busy)
1325{
1326 if (busy != server_busy) {
1327 /* server_busy value will change */
1328 server_busy = busy;
1329
1330 /* This may mean that we have to change from or to wait cursor */
1332 }
1333}
1334
1335/**********************************************************************/
1339{
1340 return server_busy;
1341}
1342
1343/**********************************************************************/
1347{
1348 return client.conn.playing == NULL && client.conn.observer;
1349}
1350
1351/**********************************************************************/
1355{
1356 if (client.conn.playing == NULL) {
1357 return -1;
1358 }
1360}
1361
1362/**********************************************************************/
1366{
1367 return client.conn.playing != NULL;
1368}
1369
1370/**********************************************************************/
1374bool client_map_is_known_and_seen(const struct tile *ptile,
1375 const struct player *pplayer,
1376 enum vision_layer vlayer)
1377{
1378 return dbv_isset(&pplayer->client.tile_vision[vlayer], tile_index(ptile));
1379}
1380
1381/**********************************************************************/
1384static int client_plr_tile_city_id_get(const struct tile *ptile,
1385 const struct player *pplayer)
1386{
1387 struct city *pcity = tile_city(ptile);
1388
1389 /* Can't look up what other players think. */
1390 fc_assert(pplayer == client_player());
1391
1392 return pcity ? pcity->id : IDENTITY_NUMBER_ZERO;
1393}
1394
1395/**********************************************************************/
1399{
1401
1402 if (pset) {
1403 return option_number(pset);
1404 } else {
1405 log_error("No server setting named %s exists.", name);
1406 return SERVER_SETTING_NONE;
1407 }
1408}
1409
1410/**********************************************************************/
1414{
1415 struct option *pset = optset_option_by_number(server_optset, id);
1416
1417 if (pset) {
1418 return option_name(pset);
1419 } else {
1420 log_error("No server setting with the id %d exists.", id);
1421 return NULL;
1422 }
1423}
1424
1425/**********************************************************************/
1428static enum sset_type client_ss_type_get(server_setting_id id)
1429{
1430 enum option_type opt_type;
1431 struct option *pset = optset_option_by_number(server_optset, id);
1432
1433 if (!pset) {
1434 log_error("No server setting with the id %d exists.", id);
1435 return sset_type_invalid();
1436 }
1437
1438 opt_type = option_type(pset);
1439
1440 /* The option type isn't client only. */
1441 fc_assert_ret_val_msg((opt_type != OT_FONT
1442 && opt_type != OT_COLOR
1443 && opt_type != OT_VIDEO_MODE),
1444 sset_type_invalid(),
1445 "%s is a client option type but not a server "
1446 "setting type",
1447 option_type_name(option_type(pset)));
1448
1449 /* The option type is valid. */
1450 fc_assert_ret_val(sset_type_is_valid((enum sset_type)opt_type),
1451 sset_type_invalid());
1452
1453 /* Each server setting type value equals the client option type value with
1454 * the same meaning. */
1455 FC_STATIC_ASSERT((enum sset_type)OT_BOOLEAN == SST_BOOL
1456 && (enum sset_type)OT_INTEGER == SST_INT
1457 && (enum sset_type)OT_STRING == SST_STRING
1458 && (enum sset_type)OT_ENUM == SST_ENUM
1459 && (enum sset_type)OT_BITWISE == SST_BITWISE
1460 && SST_COUNT == (enum sset_type)5,
1461 server_setting_type_not_equal_to_client_option_type);
1462
1463 /* Exploit the fact that each server setting type value corresponds to the
1464 * client option type value with the same meaning. */
1465 return (enum sset_type)opt_type;
1466}
1467
1468/**********************************************************************/
1472{
1473 struct option *pset = optset_option_by_number(server_optset, id);
1474
1475 if (pset) {
1476 return option_bool_get(pset);
1477 } else {
1478 log_error("No server setting with the id %d exists.", id);
1479 return FALSE;
1480 }
1481}
1482
1483/**********************************************************************/
1487{
1488 struct option *pset = optset_option_by_number(server_optset, id);
1489
1490 if (pset) {
1491 return option_int_get(pset);
1492 } else {
1493 log_error("No server setting with the id %d exists.", id);
1494 return 0;
1495 }
1496}
1497
1498/**********************************************************************/
1502{
1503 struct option *pset = optset_option_by_number(server_optset, id);
1504
1505 if (pset) {
1506 return option_bitwise_get(pset);
1507 } else {
1508 log_error("No server setting with the id %d exists.", id);
1509 return FALSE;
1510 }
1511}
1512
1513/**********************************************************************/
1517{
1519
1520 funcs->server_setting_by_name = client_ss_by_name;
1521 funcs->server_setting_name_get = client_ss_name_get;
1522 funcs->server_setting_type_get = client_ss_type_get;
1523 funcs->server_setting_val_bool_get = client_ss_val_bool_get;
1524 funcs->server_setting_val_int_get = client_ss_val_int_get;
1525 funcs->server_setting_val_bitwise_get = client_ss_val_bitwise_get;
1526 funcs->create_extra = NULL;
1527 funcs->destroy_extra = NULL;
1528 funcs->destroy_city = NULL;
1529 funcs->player_tile_vision_get = client_map_is_known_and_seen;
1530 funcs->player_tile_city_id_get = client_plr_tile_city_id_get;
1531 funcs->gui_color_free = color_free;
1532
1533 /* Keep this function call at the end. It checks if all required functions
1534 are defined. */
1536}
1537
1538/**********************************************************************/
1541static enum known_type mapimg_client_tile_known(const struct tile *ptile,
1542 const struct player *pplayer,
1543 bool knowledge)
1544{
1546 return TILE_KNOWN_SEEN;
1547 }
1548
1549 return tile_get_known(ptile, pplayer);
1550}
1551
1552/**********************************************************************/
1555static struct terrain *
1557 const struct player *pplayer, bool knowledge)
1558{
1559 return tile_terrain(ptile);
1560}
1561
1562/**********************************************************************/
1565static struct player *mapimg_client_tile_owner(const struct tile *ptile,
1566 const struct player *pplayer,
1567 bool knowledge)
1568{
1569 return tile_owner(ptile);
1570}
1571
1572/**********************************************************************/
1575static struct player *mapimg_client_tile_city(const struct tile *ptile,
1576 const struct player *pplayer,
1577 bool knowledge)
1578{
1579 struct city *pcity = tile_city(ptile);
1580
1581 if (!pcity) {
1582 return NULL;
1583 }
1584
1585 return city_owner(tile_city(ptile));
1586}
1587
1588/**********************************************************************/
1591static struct player *mapimg_client_tile_unit(const struct tile *ptile,
1592 const struct player *pplayer,
1593 bool knowledge)
1594{
1595 int unit_count = unit_list_size(ptile->units);
1596
1597 if (unit_count == 0) {
1598 return NULL;
1599 }
1600
1601 return unit_owner(unit_list_get(ptile->units, 0));
1602}
1603
1604/**********************************************************************/
1608{
1609 return player_count();
1610}
1611
1612/**********************************************************************/
1617{
1618 int count = 0;
1619
1620 if (0 > i || i > player_count()) {
1621 return NULL;
1622 }
1623
1624 players_iterate(pplayer) {
1625 if (count == i) {
1626 return pplayer->rgb;
1627 }
1628 count++;
1630
1631 return NULL;
1632}
1633
1634/**********************************************************************/
1638{
1639 return client_quitting;
1640}
1641
1642/**********************************************************************/
1646{
1648}
void agents_free(void)
Definition agents.c:346
void agents_disconnect(void)
Definition agents.c:400
void agents_game_start(void)
Definition agents.c:453
bool agents_busy(void)
Definition agents.c:799
void agents_init(void)
Definition agents.c:332
void init_ai(struct ai_type *ai)
Definition ai.c:264
struct ai_type * get_ai_type(int id)
Definition ai.c:254
void attribute_init(void)
Definition attribute.c:114
void attribute_free(void)
Definition attribute.c:123
void attribute_flush(void)
Definition attribute.c:327
void audio_shutdown(bool play_quit_tag)
Definition audio.c:629
const char * audio_get_all_plugin_names(void)
Definition audio.c:666
void audio_init(void)
Definition audio.c:187
void audio_real_init(const char *const soundset_name, const char *const musicset_name, const char *const preferred_plugin_name)
Definition audio.c:273
bool dbv_isset(const struct dbv *pdbv, int bit)
Definition bitvector.c:120
void init_our_capability(void)
Definition capstr.c:87
void fc_destroy_ow_mutex(void)
void fc_init_ow_mutex(void)
#define city_list_iterate(citylist, pcity)
Definition city.h:488
#define city_owner(_pcity_)
Definition city.h:543
#define city_list_iterate_end
Definition city.h:490
void init_city_report_game_data(void)
char music_set_name[512]
char forced_tileset_name[512]
void client_remove_all_cli_conn(void)
static struct player * mapimg_client_tile_city(const struct tile *ptile, const struct player *pplayer, bool knowledge)
bool is_client_quitting(void)
static enum client_states civclient_state
static server_setting_id client_ss_by_name(const char *name)
bool can_client_control(void)
void start_turn_change_wait(void)
static struct player * mapimg_client_tile_unit(const struct tile *ptile, const struct player *pplayer, bool knowledge)
bool client_is_global_observer(void)
static struct timer * turndone_timer
void client_remove_cli_conn(struct connection *pconn)
int get_seconds_to_new_turn(void)
static bool waiting_turn_change
int get_seconds_to_turndone(void)
static void charsets_init(void)
bool client_is_observer(void)
char metaserver[512]
char user_name[512]
static int client_plr_tile_city_id_get(const struct tile *ptile, const struct player *pplayer)
static struct rgbcolor * mapimg_client_plrcolor_get(int i)
bool can_meet_with_player(const struct player *pplayer)
void client_packet_input(void *packet, int type)
double real_timer_callback(void)
static void fc_interface_init_client(void)
static void at_exit(void)
bool client_map_is_known_and_seen(const struct tile *ptile, const struct player *pplayer, enum vision_layer vlayer)
bool waiting_for_end_turn
static char * put_conv(const char *src, size_t *length)
static enum sset_type client_ss_type_get(server_setting_id id)
char * logfile
void send_attribute_block_request(void)
static struct terrain * mapimg_client_tile_terrain(const struct tile *ptile, const struct player *pplayer, bool knowledge)
enum announce_type announce
int client_main(int argc, char *argv[], bool postpone_tileset)
char server_host[512]
bool can_intel_with_player(const struct player *pplayer)
int client_player_number(void)
static int mapimg_client_plrcolor_count(void)
static void client_game_free(void)
static enum known_type mapimg_client_tile_known(const struct tile *ptile, const struct player *pplayer, bool knowledge)
static bool client_quitting
void stop_turn_change_wait(void)
void set_server_busy(bool busy)
static bool client_ss_val_bool_get(server_setting_id id)
void user_ended_turn(void)
static bool get_conv(char *dst, size_t ndst, const char *src, size_t nsrc)
static int client_ss_val_int_get(server_setting_id id)
static void client_game_reset(void)
void send_turn_done(void)
struct civclient client
bool auto_connect
static unsigned int client_ss_val_bitwise_get(server_setting_id id)
static int seconds_shown_to_new_turn
enum client_states client_state(void)
bool is_waiting_turn_change(void)
char sound_plugin_name[512]
static void emergency_exit(void)
static double seconds_to_turndone
static void log_option_save_msg(enum log_level lvl, const char *msg,...)
bool auto_spawn
char * scriptfile
void set_seconds_to_turndone(double seconds)
static int seconds_shown_to_turndone
void send_report_request(enum report_type type)
static void client_game_init(void)
char sound_set_name[512]
bool can_client_issue_orders(void)
void start_quitting(void)
bool client_has_player(void)
bool is_server_busy(void)
static struct timer * between_turns
static struct player * mapimg_client_tile_owner(const struct tile *ptile, const struct player *pplayer, bool knowledge)
const char * title_for_player(const struct player *pplayer, char *buf, size_t buf_len)
void client_exit(int return_value)
char fc_password[MAX_LEN_PASSWORD]
int default_tileset_select(void)
void wait_till_request_got_processed(int request_id)
int server_port
static bool server_busy
static const char * client_ss_name_get(server_setting_id id)
void set_client_state(enum client_states newstate)
char * savefile
bool can_client_change_view(void)
#define client_player()
client_states
Definition client_main.h:43
@ C_S_PREPARING
Definition client_main.h:46
@ C_S_DISCONNECTED
Definition client_main.h:45
@ C_S_INITIAL
Definition client_main.h:44
@ C_S_RUNNING
Definition client_main.h:47
@ C_S_OVER
Definition client_main.h:48
const char *const gui_character_encoding
Definition gui_main.c:160
const bool gui_use_transliteration
Definition gui_main.c:161
void create_event(struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Definition climisc.c:1086
void center_on_something(void)
Definition climisc.c:424
void start_autoconnecting_to_server(void)
Definition clinet.c:547
double try_to_autoconnect(void)
Definition clinet.c:492
void input_from_server_till_request_got_processed(int fd, int expected_request_id)
Definition clinet.c:442
void disconnect_from_server(void)
Definition clinet.c:305
bool cma_is_city_under_agent(const struct city *pcity, struct cm_parameter *parameter)
Definition cma_core.c:551
void cma_release_city(struct city *pcity)
Definition cma_core.c:541
void client_kill_server(bool force)
bool client_start_server(void)
void conn_reset_delta_state(struct connection *pc)
Definition connection.c:670
#define MAX_LEN_PASSWORD
Definition connection.h:58
double blink_turn_done_button(void)
Definition control.c:925
void control_free(void)
Definition control.c:154
void unit_focus_set(struct unit *punit)
Definition control.c:507
struct unit_list * get_units_in_focus(void)
Definition control.c:177
void control_init(void)
Definition control.c:137
int get_num_units_in_focus(void)
Definition control.c:185
void unit_focus_update(void)
Definition control.c:790
void control_mouse_cursor(struct tile *ptile)
Definition control.c:1214
double blink_active_unit(void)
Definition control.c:893
void dio_set_get_conv_callback(DIO_GET_CONV_FUN fun)
Definition dataio_raw.c:131
void dio_set_put_conv_callback(DIO_PUT_CONV_FUN fun)
Definition dataio_raw.c:102
void deprecation_warnings_enable(void)
bool could_intel_with_player(const struct player *pplayer, const struct player *aplayer)
Definition diptreaty.c:81
bool could_meet_with_player(const struct player *pplayer, const struct player *aplayer)
Definition diptreaty.c:61
void editor_init(void)
Definition editor.c:193
void editor_clear(void)
Definition editor.c:246
void editor_free(void)
Definition editor.c:257
void cmdhelp_destroy(struct cmdhelp *pcmdhelp)
Definition fc_cmdhelp.c:70
void cmdhelp_display(struct cmdhelp *pcmdhelp, bool sort, bool gui_options, bool report_bugs)
Definition fc_cmdhelp.c:104
struct cmdhelp * cmdhelp_new(const char *cmdname)
Definition fc_cmdhelp.c:57
void cmdhelp_add(struct cmdhelp *pcmdhelp, const char *shortarg, const char *longarg, const char *helpstr,...)
Definition fc_cmdhelp.c:86
bool is_option(const char *option_name, char *option)
Definition fc_cmdline.c:112
char * get_option_malloc(const char *option_name, char **argv, int *i, int argc, bool gc)
Definition fc_cmdline.c:50
void cmdline_option_values_free(void)
Definition fc_cmdline.c:97
void i_am_client(void)
void libfreeciv_init(bool check_fc_interface)
void libfreeciv_free(void)
struct functions * fc_interface_funcs(void)
int server_setting_id
Definition fc_types.h:924
#define MAX_LEN_NAME
Definition fc_types.h:66
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:82
void backtrace_deinit(void)
Definition fcbacktrace.c:65
void backtrace_init(void)
Definition fcbacktrace.c:55
const char * get_internal_encoding(void)
Definition fciconv.c:182
static char void init_character_encodings(const char *my_internal_encoding, bool my_use_transliteration)
Definition fciconv.c:70
char * internal_to_data_string_malloc(const char *text)
void fc_fprintf(FILE *stream, const char *format,...) fc__attribute((__format__(__printf__
char * data_to_internal_string_malloc(const char *text)
const char * get_locale_dir(void)
Definition fcintl.c:111
#define bindtextdomain(Package, Directory)
Definition fcintl.h:82
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_client
void game_reset(void)
Definition game.c:475
struct civ_game game
Definition game.c:57
int current_turn_timeout(void)
Definition game.c:828
void game_init(bool keep_ruleset_value)
Definition game.c:429
void game_free(void)
Definition game.c:459
void global_worklists_build(void)
void global_worklists_unbuild(void)
const char * default_title_for_player(const struct player *pplayer, char *buf, size_t buf_len)
Definition government.c:425
const char * ruler_title_for_player(const struct player *pplayer, char *buf, size_t buf_len)
Definition government.c:390
void popdown_all_city_dialogs(void)
Definition citydlg.c:599
void color_free(struct color *color)
Definition colors.c:53
void popdown_races_dialog(void)
Definition dialogs.c:1238
void popdown_all_game_dialogs(void)
Definition dialogs.c:1523
void close_all_diplomacy_dialogs(void)
Definition diplodlg.c:1230
void editgui_popdown_all(void)
Definition editgui.c:1889
void editgui_tileset_changed(void)
Definition editgui.c:1861
int ui_main(int argc, char **argv)
Definition gui_main.c:1702
const char * client_string
Definition gui_main.c:104
void ui_exit(void)
Definition gui_main.c:1872
void ui_init(void)
Definition gui_main.c:1618
void update_timeout_label(void)
Definition mapview.c:101
void update_info_label(void)
Definition mapview.c:121
void update_unit_info_label(struct unit_list *punits)
Definition mapview.c:258
GType type
Definition repodlgs.c:1312
void voteinfo_gui_update(void)
static struct gui_funcs funcs
void conn_list_dialog_update(void)
void free_help_texts(void)
Definition helpdata.c:117
void boot_help_texts(void)
Definition helpdata.c:741
void helpdata_init(void)
Definition helpdata.c:87
void helpdata_done(void)
Definition helpdata.c:95
const char * name
Definition inputfile.c:127
void log_close(void)
Definition log.c:270
void log_init(const char *filename, enum log_level initial_level, log_callback_fn callback, log_prefix_fn prefix, int fatal_assertions)
Definition log.c:245
bool log_parse_level_str(const char *level_str, enum log_level *ret_level)
Definition log.c:86
#define fc_assert_msg(condition, message,...)
Definition log.h:181
#define fc_assert_ret(condition)
Definition log.h:191
#define fc_assert(condition)
Definition log.h:176
#define log_va_list(level, msg, args)
Definition log.h:128
#define fc_assert_ret_val(condition, val)
Definition log.h:194
#define log_fatal(message,...)
Definition log.h:100
#define log_debug(message,...)
Definition log.h:115
#define log_normal(message,...)
Definition log.h:107
log_level
Definition log.h:28
@ LOG_NORMAL
Definition log.h:32
#define log_error(message,...)
Definition log.h:103
#define FC_STATIC_ASSERT(cond, tag)
Definition log.h:235
#define fc_assert_ret_val_msg(condition, val, message,...)
Definition log.h:208
void update_turn_done_button_state(void)
bool can_end_turn(void)
void mapimg_free(void)
Definition mapimg.c:557
void mapimg_init(mapimg_tile_known_func mapimg_tile_known, mapimg_tile_terrain_func mapimg_tile_terrain, mapimg_tile_player_func mapimg_tile_owner, mapimg_tile_player_func mapimg_tile_city, mapimg_tile_player_func mapimg_tile_unit, mapimg_plrcolor_count_func mapimg_plrcolor_count, mapimg_plrcolor_get_func mapimg_plrcolor_get)
Definition mapimg.c:505
void mapimg_reset(void)
Definition mapimg.c:540
void update_map_canvas_visible(void)
void animations_init(void)
void link_marks_init(void)
void animations_free(void)
bool can_slide
void link_marks_free(void)
void menus_init(void)
void meswin_clear_older(int turn, int phase)
#define MESWIN_CLEAR_ALL
void start_menu_music(const char *const tag, char *const alt_tag)
Definition music.c:90
void stop_menu_music(void)
Definition music.c:100
void start_style_music(void)
Definition music.c:36
void stop_style_music(void)
Definition music.c:82
void fc_shutdown_network(void)
Definition netintf.c:217
announce_type
Definition net_types.h:53
@ ANNOUNCE_IPV6
Definition net_types.h:56
@ ANNOUNCE_IPV4
Definition net_types.h:55
@ ANNOUNCE_NONE
Definition net_types.h:54
void fc_init_network(void)
Definition netintf.c:198
#define ANNOUNCE_DEFAULT
Definition net_types.h:59
void fill_topo_ts_default(void)
Definition options.c:6555
const struct option_set * server_optset
Definition options.c:4009
void options_free(void)
Definition options.c:6271
int option_number(const struct option *poption)
Definition options.c:593
const char * option_name(const struct option *poption)
Definition options.c:603
int option_int_get(const struct option *poption)
Definition options.c:809
void options_init(void)
Definition options.c:6173
struct option * optset_option_by_number(const struct option_set *poptset, int id)
Definition options.c:395
bool option_bool_get(const struct option *poption)
Definition options.c:772
void server_options_init(void)
Definition options.c:4153
enum option_type option_type(const struct option *poption)
Definition options.c:633
void options_dialogs_update(void)
Definition options.c:5836
void server_options_free(void)
Definition options.c:4222
void options_load(void)
Definition options.c:5897
void options_save(option_save_log_callback log_cb)
Definition options.c:6053
struct client_options gui_options
Definition options.c:71
unsigned option_bitwise_get(const struct option *poption)
Definition options.c:1049
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:406
void options_dialogs_set(void)
Definition options.c:5864
#define DEFAULT_METASERVER_OPTION
Definition options.h:29
void refresh_overview_canvas(void)
void overview_free(void)
void packets_deinit(void)
Definition packets.c:900
report_type
Definition packets.h:73
const char * packet_name(enum packet_type type)
Definition packets_gen.c:49
int dsend_packet_player_phase_done(struct connection *pc, int turn)
int send_packet_client_heartbeat(struct connection *pc)
int send_packet_player_attribute_block(struct connection *pc)
int dsend_packet_report_req(struct connection *pc, enum report_type type)
@ PACKET_CONN_PING
@ PACKET_PROCESSING_STARTED
@ PACKET_PROCESSING_FINISHED
@ PACKET_AUTHENTICATION_REQ
@ PACKET_SERVER_JOIN_REPLY
@ PACKET_CONNECT_MSG
@ PACKET_EARLY_CHAT_MSG
@ PACKET_SERVER_SHUTDOWN
@ PACKET_SERVER_INFO
void packhand_free(void)
Definition packhand.c:215
int len
Definition packhand.c:125
bool client_handle_packet(enum packet_type type, const void *packet)
void set_client_page(enum client_pages page)
enum client_pages get_client_page(void)
bool is_valid_username(const char *name)
Definition player.c:1872
int player_count(void)
Definition player.c:808
int player_number(const struct player *pplayer)
Definition player.c:828
#define players_iterate_end
Definition player.h:535
#define players_iterate(_pplayer)
Definition player.h:530
void init_player_dlg_common(void)
void fc_srand(RANDOM_TYPE seed)
Definition rand.c:128
#define fc_rand(_size)
Definition rand.h:34
void registry_module_init(void)
Definition registry.c:30
void registry_module_close(void)
Definition registry.c:40
struct research * research_get(const struct player *pplayer)
Definition research.c:126
void research_update(struct research *presearch)
Definition research.c:499
static int fatal_assertions
Definition ruledit.cpp:58
bool script_client_init(void)
void script_client_free(void)
#define SERVER_SETTING_NONE
char * user_username(char *buf, size_t bufsz)
Definition shared.c:705
void dont_run_as_root(const char *argv0, const char *fallback)
Definition shared.c:1542
bool str_to_int(const char *str, int *pint)
Definition shared.c:512
#define MIN(x, y)
Definition shared.h:55
#define FC_INFINITY
Definition shared.h:36
#define MAX(x, y)
Definition shared.h:54
Definition ai.h:50
Definition city.h:309
int id
Definition city.h:315
struct conn_list * est_connections
Definition game.h:97
struct packet_game_info info
Definition game.h:89
struct civ_game::@30::@33 client
bool ruleset_ready
Definition game.h:116
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 connection conn
Definition client_main.h:96
int default_server_port
Definition options.h:109
char default_sound_set_name[512]
Definition options.h:116
bool use_prev_server
Definition options.h:110
char default_metaserver[512]
Definition options.h:112
char default_tileset_name[512]
Definition options.h:126
bool auto_center_each_turn
Definition options.h:151
char default_server_host[512]
Definition options.h:108
bool heartbeat_enabled
Definition options.h:111
bool save_options_on_exit
Definition options.h:121
char default_music_set_name[512]
Definition options.h:117
char default_sound_plugin_name[512]
Definition options.h:118
char default_user_name[512]
Definition options.h:107
bool established
Definition connection.h:145
struct player * playing
Definition connection.h:156
bool observer
Definition connection.h:152
struct city_list * cities
Definition player.h:281
struct dbv tile_vision[V_COUNT]
Definition player.h:359
struct player::@69::@72 client
struct conn_list * connections
Definition player.h:298
Definition tile.h:49
struct unit_list * units
Definition tile.h:57
Definition timing.c:81
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:189
int fc_at_quick_exit(void(*func)(void))
Definition support.c:1326
#define sz_strlcpy(dest, src)
Definition support.h:167
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
void init_themes(void)
enum known_type tile_get_known(const struct tile *ptile, const struct player *pplayer)
Definition tile.c:386
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:87
known_type
Definition tile.h:34
@ TILE_KNOWN_SEEN
Definition tile.h:37
#define tile_terrain(_tile)
Definition tile.h:109
#define tile_owner(_tile)
Definition tile.h:95
bool tilespec_try_read(const char *tileset_name, bool verbose, int topo_id, bool global_default)
Definition tilespec.c:1240
struct tileset * unscaled_tileset
Definition tilespec.c:545
void tileset_free(struct tileset *t)
Definition tilespec.c:1218
void timer_start(struct timer *t)
Definition timing.c:224
double timer_read_seconds(struct timer *t)
Definition timing.c:344
struct timer * timer_renew(struct timer *t, enum timer_timetype type, enum timer_use use)
Definition timing.c:176
@ TIMER_ACTIVE
Definition timing.h:45
@ TIMER_USER
Definition timing.h:41
#define unit_owner(_pu)
Definition unit.h:394
void role_unit_precalcs(void)
Definition unittype.c:2223
void update_queue_free(void)
void update_queue_init(void)
const char * freeciv_name_version(void)
Definition version.c:35
void voteinfo_queue_init(void)
Definition voteinfo.c:167
void voteinfo_queue_check_removed(void)
Definition voteinfo.c:72
void voteinfo_queue_free(void)
Definition voteinfo.c:179
bool zoom_update(double time_until_next_call)
Definition zoom.c:172