Freeciv-3.3
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 "modpack.h"
57#include "netintf.h"
58#include "packets.h"
59#include "player.h"
60#include "research.h"
61#include "server_settings.h"
62#include "version.h"
63
64/* client/include */
65#include "chatline_g.h"
66#include "citydlg_g.h"
67#include "connectdlg_g.h"
68#include "dialogs_g.h"
69#include "diplodlg_g.h"
70#include "editgui_g.h"
71#include "graphics_g.h"
72#include "gui_main_g.h"
73#include "mapctrl_g.h"
74#include "mapview_g.h"
75#include "menu_g.h"
76#include "messagewin_g.h"
77#include "pages_g.h"
78#include "plrdlg_g.h"
79#include "repodlgs_g.h"
80#include "voteinfo_bar_g.h"
81
82/* client */
83#include "attribute.h"
84#include "audio.h"
85#include "cityrepdata.h"
86#include "climisc.h"
87#include "clinet.h"
88#include "connectdlg_common.h" /* client_kill_server() */
89#include "control.h"
90#include "editor.h"
91#include "global_worklist.h"
92#include "helpdata.h" /* boot_help_texts() */
93#include "mapview_common.h"
94#include "music.h"
95#include "options.h"
96#include "overview_common.h"
97#include "packhand.h"
98#include "svgflag.h"
99#include "tilespec.h"
100#include "themes_common.h"
101#include "update_queue.h"
102#include "voteinfo.h"
103#include "zoom.h"
104
105/* client/agents */
106#include "agents.h"
107#include "cma_core.h" /* kludge */
108
109/* client/luascript */
110#include "script_client.h"
111
112#include "client_main.h"
113
114
115static enum known_type mapimg_client_tile_known(const struct tile *ptile,
116 const struct player *pplayer,
117 bool knowledge);
118static struct terrain
119 *mapimg_client_tile_terrain(const struct tile *ptile,
120 const struct player *pplayer, bool knowledge);
121static struct player *mapimg_client_tile_owner(const struct tile *ptile,
122 const struct player *pplayer,
123 bool knowledge);
124static struct player *mapimg_client_tile_city(const struct tile *ptile,
125 const struct player *pplayer,
126 bool knowledge);
127static struct player *mapimg_client_tile_unit(const struct tile *ptile,
128 const struct player *pplayer,
129 bool knowledge);
130static int mapimg_client_plrcolor_count(void);
131static struct rgbcolor *mapimg_client_plrcolor_get(int i);
132
133static void fc_interface_init_client(void);
134
135static void cache_tilesets(void);
136
137char *logfile = NULL;
140char forced_tileset_name[512] = "\0";
141char sound_plugin_name[512] = "\0";
142char sound_set_name[512] = "\0";
143char music_set_name[512] = "\0";
144char server_host[512] = "\0";
145char user_name[512] = "\0";
147char metaserver[512] = "\0";
148int server_port = -1;
149bool auto_connect = FALSE; /* TRUE = skip "Connect to Freeciv Server" dialog */
150bool auto_spawn = FALSE; /* TRUE = skip main menu, start local server */
152
154
156
157/* TRUE if an end turn request is blocked by busy agents */
159
160/*
161 * TRUE between receiving PACKET_END_TURN and PACKET_BEGIN_TURN
162 */
163static bool server_busy = FALSE;
164
165#ifdef FREECIV_DEBUG
166bool hackless = FALSE;
167#endif
168
169static bool client_quitting = FALSE;
170
171/**********************************************************************/
175static char *put_conv(const char *src, size_t *length)
176{
178
179 if (out) {
180 *length = strlen(out);
181 return out;
182 } else {
183 *length = 0;
184 return NULL;
185 }
186}
187
188/**********************************************************************/
193static bool get_conv(char *dst, size_t ndst,
194 const char *src, size_t nsrc)
195{
197 bool ret = TRUE;
198 size_t len;
199
200 if (!out) {
201 dst[0] = '\0';
202 return FALSE;
203 }
204
205 len = strlen(out);
206 if (ndst > 0 && len >= ndst) {
207 ret = FALSE;
208 len = ndst - 1;
209 }
210
211 memcpy(dst, out, len);
212 dst[len] = '\0';
213 free(out);
214
215 return ret;
216}
217
218/**********************************************************************/
226
227/**********************************************************************/
231static void emergency_exit(void)
232{
234}
235
236/**********************************************************************/
239static void at_exit(void)
240{
246}
247
248/**********************************************************************/
270
271/**********************************************************************/
274static void client_game_free(void)
275{
277
279 mapimg_free();
284 control_free();
287 agents_free();
290 game_free();
291 /* update_queue_init() is correct at this point. The queue is reset to
292 a clean state which is also needed if the client is not connected to
293 the server! */
295
298}
299
300/**********************************************************************/
304static void client_game_reset(void)
305{
307
310 control_free();
312 agents_free();
313
314 game_reset();
315 mapimg_reset();
316
318 agents_init();
319 control_init();
321}
322
323/**********************************************************************/
327{
329
330 if (forced_tileset_name[0] != '\0') {
332 log_error(_("Can't load requested tileset %s!"), forced_tileset_name);
334 return EXIT_FAILURE;
335 }
336 } else {
337 if (gui_options.default_tileset_name[0] == '\0') {
338 /* Use topology by default */
340 FALSE, -1, TRUE);
341 } else {
343 }
344 }
345
346 editor_init();
347
348 return EXIT_SUCCESS;
349}
350
351/**********************************************************************/
354int client_main(int argc, char *argv[], bool postpone_tileset)
355{
356 int i;
357 enum log_level loglevel = LOG_NORMAL;
358 int ui_options = 0;
359 bool ui_separator = FALSE;
360 char *option = NULL;
361 int fatal_assertions = -1;
362 int aii;
363 int uret;
364
365 /* Load Windows post-crash debugger */
366#ifdef FREECIV_MSWINDOWS
367# ifndef FREECIV_NDEBUG
368 if (LoadLibrary("exchndl.dll") == NULL) {
369# ifdef FREECIV_DEBUG
370 fprintf(stderr, "exchndl.dll could not be loaded, no crash debugger\n");
371# endif /* FREECIV_DEBUG */
372 }
373# endif /* FREECIV_NDEBUG */
374#endif /* FREECIV_MSWINDOWS */
375
376 /* fc_interface_init_client() includes low level support like
377 * guaranteeing that fc_vsnprintf() will work after it,
378 * so this need to be early. */
380
381 i_am_client(); /* Tell to libfreeciv that we are client */
382
384
385 /* Ensure that all AIs are initialized to unused state
386 * Not using ai_type_iterate as it would stop at
387 * current ai type count, ai_type_get_count(), i.e., 0 */
388 for (aii = 0; aii < FREECIV_AI_MOD_LAST; aii++) {
389 struct ai_type *ai = get_ai_type(aii);
390
391 init_ai(ai);
392 }
393
394#ifdef ENABLE_NLS
395 (void) bindtextdomain("freeciv-nations", get_locale_dir());
396#endif
397
399 audio_init();
401#ifdef ENABLE_NLS
403#endif
404
405 i = 1;
406
408
409 while (i < argc) {
410 if (ui_separator) {
411 argv[1 + ui_options] = argv[i];
412 ui_options++;
413 } else if (is_option("--help", argv[i])) {
414 struct cmdhelp *help = cmdhelp_new(argv[0]);
415
416 cmdhelp_add(help, "A",
417 /* TRANS: "Announce" is exactly what user must type, do not translate. */
418 _("Announce PROTO"),
419 _("Announce game in LAN using protocol PROTO "
420 "(IPv4/IPv6/none)"));
421 cmdhelp_add(help, "a", "autoconnect",
422 _("Skip connect dialog"));
423#ifdef FREECIV_DEBUG
424 cmdhelp_add(help, "d",
425 /* TRANS: "debug" is exactly what user must type, do not translate. */
426 _("debug LEVEL"),
427 _("Set debug log level (one of f,e,w,n,v,d, or "
428 "d:file1,min,max:...)"));
429#else /* FREECIV_DEBUG */
430 cmdhelp_add(help, "d",
431 /* TRANS: "debug" is exactly what user must type, do not translate. */
432 _("debug LEVEL"),
433 _("Set debug log level (one of f,e,w,n,v)"));
434#endif /* FREECIV_DEBUG */
435#ifndef FREECIV_NDEBUG
436 cmdhelp_add(help, "F",
437 /* TRANS: "Fatal" is exactly what user must type, do not translate. */
438 _("Fatal [SIGNAL]"),
439 _("Raise a signal on failed assertion"));
440#endif /* FREECIV_NDEBUG */
441 cmdhelp_add(help, "f",
442 /* TRANS: "file" is exactly what user must type, do not translate. */
443 _("file FILE"),
444 _("Load saved game FILE"));
445 cmdhelp_add(help, "h", "help",
446 _("Print a summary of the options"));
447#ifdef FREECIV_DEBUG
448 cmdhelp_add(help, "H", "Hackless",
449 _("Do not request hack access to local server"));
450#endif /* FREECIV_DEBUG */
451 cmdhelp_add(help, "l",
452 /* TRANS: "log" is exactly what user must type, do not translate. */
453 _("log FILE"),
454 _("Use FILE as logfile (spawned server also uses this)"));
455 cmdhelp_add(help, "M",
456 /* TRANS: "Meta" is exactly what user must type, do not translate. */
457 _("Meta HOST"),
458 _("Connect to the metaserver at HOST"));
459 cmdhelp_add(help, "n",
460 /* TRANS: "name" is exactly what user must type, do not translate. */
461 _("name NAME"),
462 _("Use NAME as username on server"));
463 cmdhelp_add(help, "p",
464 /* TRANS: "port" is exactly what user must type, do not translate. */
465 _("port PORT"),
466 _("Connect to server port PORT (usually with -a)"));
467 cmdhelp_add(help, "P",
468 /* TRANS: "Plugin" is exactly what user must type, do not translate. */
469 _("Plugin PLUGIN"),
470 _("Use PLUGIN for sound output %s"),
472 cmdhelp_add(help, "r",
473 /* TRANS: "read" is exactly what user must type, do not translate. */
474 _("read FILE"),
475 _("Read startup script FILE (for spawned server only)"));
476 cmdhelp_add(help, "s",
477 /* TRANS: "server" is exactly what user must type, do not translate. */
478 _("server HOST"),
479 _("Connect to the server at HOST (usually with -a)"));
480 cmdhelp_add(help, "S",
481 /* TRANS: "Sound" is exactly what user must type, do not translate. */
482 _("Sound FILE"),
483 _("Read sound tags from FILE"));
484 cmdhelp_add(help, "m",
485 /* TRANS: "music" is exactly what user must type, do not translate. */
486 _("music FILE"),
487 _("Read music tags from FILE"));
488 cmdhelp_add(help, "t",
489 /* TRANS: "tiles" is exactly what user must type, do not translate. */
490 _("tiles FILE"),
491 _("Use data file FILE.tilespec for tiles"));
492 cmdhelp_add(help, "v", "version",
493 _("Print the version number"));
494 cmdhelp_add(help, "w", "warnings",
495 _("Warn about deprecated modpack constructs"));
496
497 /* The function below prints a header and footer for the options.
498 * Furthermore, the options are sorted. */
499 cmdhelp_display(help, TRUE, TRUE, TRUE);
500 cmdhelp_destroy(help);
501
503 } else if (is_option("--version", argv[i])) {
506#ifdef FREECIV_DEBUG
507 } else if (is_option("--Hackless", argv[i])) {
508 hackless = TRUE;
509#endif /* FREECIV_DEBUG */
510 } else if ((option = get_option_malloc("--log", argv, &i, argc, TRUE))) {
511 logfile = option;
512#ifndef FREECIV_NDEBUG
513 } else if (is_option("--Fatal", argv[i])) {
514 if (i + 1 >= argc || '-' == argv[i + 1][0]) {
516 } else if (str_to_int(argv[i + 1], &fatal_assertions)) {
517 i++;
518 } else {
519 fc_fprintf(stderr, _("Invalid signal number \"%s\".\n"),
520 argv[i + 1]);
521 fc_fprintf(stderr, _("Try using --help.\n"));
523 }
524#endif /* FREECIV_NDEBUG */
525 } else if ((option = get_option_malloc("--read", argv, &i, argc, TRUE))) {
527 } else if ((option = get_option_malloc("--file", argv, &i, argc, TRUE))) {
530 } else if ((option = get_option_malloc("--name", argv, &i, argc, FALSE))) {
532 free(option);
533 } else if ((option = get_option_malloc("--Meta", argv, &i, argc, FALSE))) {
535 free(option);
536 } else if ((option = get_option_malloc("--Sound", argv, &i, argc, FALSE))) {
538 free(option);
539 } else if ((option = get_option_malloc("--music", argv, &i, argc, FALSE))) {
541 free(option);
542 } else if ((option = get_option_malloc("--Plugin", argv, &i, argc, FALSE))) {
544 free(option);
545 } else if ((option = get_option_malloc("--port", argv, &i, argc, FALSE))) {
546 if (!str_to_int(option, &server_port)) {
548 _("Invalid port \"%s\" specified with --port option.\n"),
549 option);
550 fc_fprintf(stderr, _("Try using --help.\n"));
552 }
553 free(option);
554 } else if ((option = get_option_malloc("--server", argv, &i, argc, FALSE))) {
556 free(option);
557 } else if (is_option("--autoconnect", argv[i])) {
559 } else if ((option = get_option_malloc("--debug", argv, &i, argc, FALSE))) {
560 if (!log_parse_level_str(option, &loglevel)) {
562 _("Invalid debug level \"%s\" specified with --debug "
563 "option.\n"), option);
564 fc_fprintf(stderr, _("Try using --help.\n"));
566 }
567 free(option);
568 } else if ((option = get_option_malloc("--tiles", argv, &i, argc, FALSE))) {
570 free(option);
571 } else if ((option = get_option_malloc("--Announce", argv, &i, argc, FALSE))) {
572 if (!fc_strcasecmp(option, "ipv4")) {
574 } else if (!fc_strcasecmp(option, "none")) {
576#ifdef FREECIV_IPV6_SUPPORT
577 } else if (!fc_strcasecmp(option, "ipv6")) {
579#endif /* IPv6 support */
580 } else {
581 fc_fprintf(stderr, _("Invalid announce protocol \"%s\".\n"), option);
583 }
584 free(option);
585 } else if (is_option("--warnings", argv[i])) {
587 } else if (is_option("--", argv[i])) {
589 } else {
590 fc_fprintf(stderr, _("Unrecognized option: \"%s\"\n"), argv[i]);
592 }
593 i++;
594 } /* of while */
595
596 if (auto_spawn && auto_connect) {
597 /* TRANS: don't translate option names */
598 fc_fprintf(stderr, _("-f/--file and -a/--autoconnect options are "
599 "incompatible\n"));
601 }
602
603 /* Remove all options except those intended for the UI. */
604 argv[1 + ui_options] = NULL;
605 argc = 1 + ui_options;
606
607 /* Disallow running as root -- too dangerous */
608 dont_run_as_root(argv[0], "freeciv_client");
609
612
613 /* After log_init: */
614
617 char buf[sizeof(gui_options.default_user_name)];
618
620 if (is_valid_username(buf)) {
622 } else {
625 "player%d", fc_rand(10000));
626 }
627 }
628
629 /* Initialization */
630
633
634 ui_init();
638
640
641 /* Register exit handler */
644
647 init_themes();
648
649 options_init();
650 options_load();
651
653
654 if (sound_set_name[0] == '\0') {
656 }
657 if (music_set_name[0] == '\0') {
659 }
660 if (sound_plugin_name[0] == '\0') {
662 }
663 if (server_host[0] == '\0') {
665 } else if (gui_options.use_prev_server) {
667 }
668 if (user_name[0] == '\0') {
670 }
671 if (metaserver[0] == '\0') {
674 } else {
676 }
677 }
678 if (server_port == -1) {
680 } else if (gui_options.use_prev_server) {
682 }
683
684 /* This seed is not saved anywhere; randoms in the client should
685 have cosmetic effects only (eg city name suggestions). --dwp */
689
692
694 start_menu_music("music_menu", NULL);
695
696 if (!postpone_tileset) {
698
699 if (tsret != EXIT_SUCCESS) {
700 return tsret;
701 }
702 }
703
704 /* Run gui-specific client */
705 uret = ui_main(argc, argv);
706
708
709 /* Termination */
711
712 /* Not reached */
713 return EXIT_SUCCESS;
714}
715
716/**********************************************************************/
719static void log_option_save_msg(enum log_level lvl, const char *msg, ...)
720{
721 va_list args;
722
723 va_start(args, msg);
724 log_va_list(lvl, msg, args);
725 va_end(args);
726}
727
728/**********************************************************************/
733{
734 if (client_state() >= C_S_PREPARING) {
737 }
738
741 }
742
744 if (unscaled_tileset != NULL) {
746 }
747 if (tileset != NULL) {
749 }
750
751 ui_exit();
752
753 /* Play the exit sound while audio system dependencies still up. */
755
757
758 editor_free();
759 options_free();
760 if (client_state() >= C_S_PREPARING) {
762 }
763
764 helpdata_done(); /* client_exit() unlinks help text list */
767
771
773 log_close();
775
777}
778
779/**********************************************************************/
782void client_packet_input(void *packet, int type)
783{
793 && PACKET_SERVER_INFO != type) {
794 log_error("Received packet %s (%d) before establishing connection!",
797 } else if (!client_handle_packet(type, packet)) {
798 log_error("Received unknown packet (type %d) from server!", type);
800 }
801}
802
803/**********************************************************************/
807{
809}
810
811/**********************************************************************/
815{
816 log_debug("send_turn_done() can_end_turn=%d",
817 can_end_turn());
818
819 if (!can_end_turn()) {
820 /*
821 * The turn done button is disabled but the user may have pressed
822 * the return key.
823 */
824
825 if (agents_busy()) {
827 }
828
829 return;
830 }
831
833
835
837
839}
840
841/**********************************************************************/
848
849/**********************************************************************/
853{
855 struct player *pplayer = client_player();
856
857 if (auto_spawn) {
860 if (!client_start_server()) {
861 log_fatal(_("Failed to start local server; aborting."));
863 }
864 }
865
867 if (oldstate == C_S_DISCONNECTED) {
868 log_fatal(_("There was an error while auto connecting; aborting."));
870 } else {
872 auto_connect = FALSE; /* Don't try this again. */
873 }
874 }
875
878 /* Reset the delta-state. */
880 }
881
882 if (oldstate == newstate) {
883 return;
884 }
885
888
889 if (!is_client_quitting()) {
890 /* Back to menu */
891 start_menu_music("music_menu", NULL);
892 }
893 }
894
896
897 switch (newstate) {
898 case C_S_INITIAL:
899 log_error("%d is not a valid client state to set.", C_S_INITIAL);
900 break;
901
902 case C_S_DISCONNECTED:
907
911 editor_clear();
915 if (oldstate > C_S_PREPARING) {
917 }
918 }
919
921 break;
922
923 case C_S_PREPARING:
928
929 if (oldstate < C_S_PREPARING) {
931 } else {
932 /* From an upper state means that we didn't quit the server,
933 * so a lot of informations are still in effect. */
936 }
937
939
941 && get_client_page() != PAGE_LOAD) {
943 }
944 break;
945
946 case C_S_RUNNING:
947 if (oldstate == C_S_PREPARING) {
949 stop_menu_music(); /* stop intro sound loop. */
950 }
951
954 create_event(NULL, E_GAME_START, ftc_client, _("Game started."));
955 if (pplayer) {
957 }
959 boot_help_texts(); /* reboot with player */
963 can_slide = TRUE;
965 /* Find something sensible to display instead of the intro gfx. */
970
972
973 update_info_label(); /* get initial population right */
976
979 }
981 break;
982
983 case C_S_OVER:
984 if (C_S_RUNNING == oldstate) {
985 /* Extra kludge for end-game handling of the CMA. */
986 if (pplayer && pplayer->cities) {
987 city_list_iterate(pplayer->cities, pcity) {
988 if (cma_is_city_under_agent(pcity, NULL)) {
989 cma_release_city(pcity);
990 }
992 }
997 } else {
998 /* From C_S_PREPARING. */
1001 if (pplayer) {
1002 research_update(research_get(pplayer));
1003 }
1005 boot_help_texts(); /* reboot */
1010 }
1012
1016
1017 break;
1018 }
1019
1020 menus_init();
1023 if (can_client_change_view()) {
1025 }
1026
1027 /* If turn was going to change, that is now aborted. */
1029}
1030
1031/**********************************************************************/
1035{
1036 return civclient_state;
1037}
1038
1039/**********************************************************************/
1043{
1045 "Trying to remove a non existing connection");
1046
1047 if (NULL != pconn->playing) {
1048 conn_list_remove(pconn->playing->connections, pconn);
1049 }
1053 free(pconn);
1054}
1055
1056/**********************************************************************/
1061{
1063 "Connection list missing");
1064
1065 while (conn_list_size(game.all_connections) > 0) {
1068 }
1069}
1070
1071/**********************************************************************/
1078
1079/**********************************************************************/
1087
1088/**********************************************************************/
1092{
1094}
1095
1096/* Seconds_to_turndone is the number of seconds the server has told us
1097 * are left. The timer tells exactly how much time has passed since the
1098 * server gave us that data. */
1099static double seconds_to_turndone = 0.0;
1100static struct timer *turndone_timer;
1101
1102/* The timer tells how long since server informed us about starting
1103 * turn-change activities. */
1104static struct timer *between_turns = NULL;
1106
1107/* This value shows what value the timeout label is currently showing for
1108 * the seconds-to-turndone. */
1111
1112/**********************************************************************/
1119{
1120 if (current_turn_timeout() > 0) {
1123 turndone_timer != NULL ? NULL : "turndone");
1125
1126 /* Maybe we should do an update_timeout_label here, but it doesn't
1127 * seem to be necessary. */
1129 }
1130}
1131
1132/**********************************************************************/
1136{
1137 return waiting_turn_change;
1138}
1139
1140/**********************************************************************/
1152
1153/**********************************************************************/
1161
1162/**********************************************************************/
1167{
1168 if (current_turn_timeout() > 0) {
1170 } else {
1171 /* This shouldn't happen. */
1172 return FC_INFINITY;
1173 }
1174}
1175
1176/**********************************************************************/
1181{
1183}
1184
1185/**********************************************************************/
1191{
1192 double time_until_next_call = 1.0;
1193
1195
1196 {
1199 }
1200
1201 if (C_S_RUNNING != client_state()) {
1202 return time_until_next_call;
1203 }
1204
1206
1207 {
1209
1211 }
1212
1213 if (get_num_units_in_focus() > 0) {
1214 double blink_time = blink_active_unit();
1215
1217 }
1218
1219 /* It is possible to have current_turn_timeout() > 0 but !turndone_timer,
1220 * in the first moments after the timeout is set. */
1221 if (current_turn_timeout() > 0 && turndone_timer != NULL) {
1223 int iseconds = ceil(seconds + 0.1); /* Turn should end right on 0. */
1224
1228 }
1229
1231 seconds - floor(seconds) + 0.001);
1232 }
1233 if (waiting_turn_change) {
1235 int iseconds = ceil(seconds + 0.1); /* Turn should end right on 0. */
1236
1240 }
1241 }
1242
1243 {
1244 static long counter = 0;
1245
1246 counter++;
1247
1248 if (gui_options.heartbeat_enabled && (counter % (20 * 10) == 0)) {
1250 }
1251 }
1252
1253 /* Make sure we wait at least 50 ms, otherwise we may not give any other
1254 * code time to run. */
1255 return MAX(time_until_next_call, 0.05);
1256}
1257
1258/**********************************************************************/
1262{
1263 return (NULL != client.conn.playing
1264 && !client_is_observer());
1265}
1266
1267/**********************************************************************/
1273{
1274 return (can_client_control()
1275 && C_S_RUNNING == client_state());
1276}
1277
1278/**********************************************************************/
1282bool can_meet_with_player(const struct player *pplayer)
1283{
1284 return (can_client_issue_orders()
1285 /* && NULL != client.conn.playing (above) */
1287}
1288
1289/**********************************************************************/
1293bool can_intel_with_player(const struct player *pplayer)
1294{
1295 return (client_is_observer()
1296 || (NULL != client.conn.playing
1297 && could_intel_with_player(client_player(), pplayer)));
1298}
1299
1300/**********************************************************************/
1304const char *title_for_player(const struct player *pplayer,
1305 char *buf, size_t buf_len)
1306{
1307 if (client_player() == pplayer || can_intel_with_player(pplayer)) {
1308 /* Knows the government to construct correct title */
1309 return ruler_title_for_player(pplayer, buf, buf_len);
1310 }
1311
1312 return default_title_for_player(pplayer, buf, buf_len);
1313}
1314
1315/**********************************************************************/
1321{
1322 return ((NULL != client.conn.playing || client_is_observer())
1323 && (C_S_RUNNING == client_state()
1324 || C_S_OVER == client_state()));
1325}
1326
1327/**********************************************************************/
1332{
1333 if (busy != server_busy) {
1334 /* server_busy value will change */
1335 server_busy = busy;
1336
1337 /* This may mean that we have to change from or to wait cursor */
1339 }
1340}
1341
1342/**********************************************************************/
1346{
1347 return server_busy;
1348}
1349
1350/**********************************************************************/
1354{
1355 return client.conn.playing == NULL && client.conn.observer;
1356}
1357
1358/**********************************************************************/
1362{
1363 if (client.conn.playing == NULL) {
1364 return -1;
1365 }
1367}
1368
1369/**********************************************************************/
1373{
1374 return client.conn.playing != NULL;
1375}
1376
1377/**********************************************************************/
1381bool client_map_is_known_and_seen(const struct tile *ptile,
1382 const struct player *pplayer,
1383 enum vision_layer vlayer)
1384{
1385 return dbv_isset(&pplayer->client.tile_vision[vlayer], tile_index(ptile));
1386}
1387
1388/**********************************************************************/
1391static int client_plr_tile_city_id_get(const struct tile *ptile,
1392 const struct player *pplayer)
1393{
1394 struct city *pcity = tile_city(ptile);
1395
1396 /* Can't look up what other players think. */
1397 fc_assert(pplayer == client_player());
1398
1399 return pcity ? pcity->id : IDENTITY_NUMBER_ZERO;
1400}
1401
1402/**********************************************************************/
1406{
1408
1409 if (pset) {
1410 return option_number(pset);
1411 } else {
1412 log_error("No server setting named %s exists.", name);
1413 return SERVER_SETTING_NONE;
1414 }
1415}
1416
1417/**********************************************************************/
1421{
1423
1424 if (pset) {
1425 return option_name(pset);
1426 } else {
1427 log_error("No server setting with the id %d exists.", id);
1428 return NULL;
1429 }
1430}
1431
1432/**********************************************************************/
1436{
1437 enum option_type opt_type;
1439
1440 if (!pset) {
1441 log_error("No server setting with the id %d exists.", id);
1442 return sset_type_invalid();
1443 }
1444
1446
1447 /* The option type isn't client only. */
1449 && opt_type != OT_COLOR
1450 && opt_type != OT_VIDEO_MODE),
1452 "%s is a client option type but not a server "
1453 "setting type",
1455
1456 /* The option type is valid. */
1459
1460 /* Each server setting type value equals the client option type value with
1461 * the same meaning. */
1463 && (enum sset_type)OT_INTEGER == SST_INT
1464 && (enum sset_type)OT_STRING == SST_STRING
1465 && (enum sset_type)OT_ENUM == SST_ENUM
1466 && (enum sset_type)OT_BITWISE == SST_BITWISE
1467 && SST_COUNT == (enum sset_type)5,
1469
1470 /* Exploit the fact that each server setting type value corresponds to the
1471 * client option type value with the same meaning. */
1472 return (enum sset_type)opt_type;
1473}
1474
1475/**********************************************************************/
1479{
1481
1482 if (pset) {
1483 return option_bool_get(pset);
1484 } else {
1485 log_error("No server setting with the id %d exists.", id);
1486 return FALSE;
1487 }
1488}
1489
1490/**********************************************************************/
1494{
1496
1497 if (pset) {
1498 return option_int_get(pset);
1499 } else {
1500 log_error("No server setting with the id %d exists.", id);
1501 return 0;
1502 }
1503}
1504
1505/**********************************************************************/
1509{
1511
1512 if (pset) {
1513 return option_bitwise_get(pset);
1514 } else {
1515 log_error("No server setting with the id %d exists.", id);
1516 return FALSE;
1517 }
1518}
1519
1520/**********************************************************************/
1524{
1526
1527 funcs->server_setting_by_name = client_ss_by_name;
1528 funcs->server_setting_name_get = client_ss_name_get;
1529 funcs->server_setting_type_get = client_ss_type_get;
1530 funcs->server_setting_val_bool_get = client_ss_val_bool_get;
1531 funcs->server_setting_val_int_get = client_ss_val_int_get;
1532 funcs->server_setting_val_bitwise_get = client_ss_val_bitwise_get;
1533 funcs->create_extra = NULL;
1534 funcs->destroy_extra = NULL;
1535 funcs->destroy_city = NULL;
1536 funcs->player_tile_vision_get = client_map_is_known_and_seen;
1537 funcs->player_tile_city_id_get = client_plr_tile_city_id_get;
1538 funcs->gui_color_free = color_free;
1539
1540 /* Keep this function call at the end. It checks if all required functions
1541 are defined. */
1543}
1544
1545/**********************************************************************/
1548static enum known_type mapimg_client_tile_known(const struct tile *ptile,
1549 const struct player *pplayer,
1550 bool knowledge)
1551{
1553 return TILE_KNOWN_SEEN;
1554 }
1555
1556 return tile_get_known(ptile, pplayer);
1557}
1558
1559/**********************************************************************/
1562static struct terrain *
1564 const struct player *pplayer, bool knowledge)
1565{
1566 return tile_terrain(ptile);
1567}
1568
1569/**********************************************************************/
1572static struct player *mapimg_client_tile_owner(const struct tile *ptile,
1573 const struct player *pplayer,
1574 bool knowledge)
1575{
1576 return tile_owner(ptile);
1577}
1578
1579/**********************************************************************/
1582static struct player *mapimg_client_tile_city(const struct tile *ptile,
1583 const struct player *pplayer,
1584 bool knowledge)
1585{
1586 struct city *pcity = tile_city(ptile);
1587
1588 if (!pcity) {
1589 return NULL;
1590 }
1591
1592 return city_owner(tile_city(ptile));
1593}
1594
1595/**********************************************************************/
1598static struct player *mapimg_client_tile_unit(const struct tile *ptile,
1599 const struct player *pplayer,
1600 bool knowledge)
1601{
1602 int unit_count = unit_list_size(ptile->units);
1603
1604 if (unit_count == 0) {
1605 return NULL;
1606 }
1607
1608 return unit_owner(unit_list_get(ptile->units, 0));
1609}
1610
1611/**********************************************************************/
1615{
1616 return player_count();
1617}
1618
1619/**********************************************************************/
1624{
1625 int count = 0;
1626
1627 if (0 > i || i > player_count()) {
1628 return NULL;
1629 }
1630
1631 players_iterate(pplayer) {
1632 if (count == i) {
1633 return pplayer->rgb;
1634 }
1635 count++;
1637
1638 return NULL;
1639}
1640
1641/**********************************************************************/
1645{
1646 return client_quitting;
1647}
1648
1649/**********************************************************************/
1653{
1655}
1656
1657/************************************************************************/
1660static void cache_tilesets(void)
1661{
1663
1665
1667 struct section_file *sf;
1668
1669 sf = secfile_load(pfile->fullname, FALSE);
1670
1671 if (sf != NULL) {
1673 secfile_destroy(sf);
1674 }
1676
1678}
void agents_free(void)
Definition agents.c:349
void agents_disconnect(void)
Definition agents.c:405
void agents_game_start(void)
Definition agents.c:458
bool agents_busy(void)
Definition agents.c:804
void agents_init(void)
Definition agents.c:335
void init_ai(struct ai_type *ai)
Definition ai.c:270
struct ai_type * get_ai_type(int id)
Definition ai.c:260
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:657
const char * audio_get_all_plugin_names(void)
Definition audio.c:694
void audio_init(void)
Definition audio.c:188
void audio_real_init(const char *const soundset_name, const char *const musicset_name, const char *const preferred_plugin_name)
Definition audio.c:274
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:508
#define city_owner(_pcity_)
Definition city.h:563
#define city_list_iterate_end
Definition city.h:510
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)
void fc__noreturn client_exit(int return_value)
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)
static void cache_tilesets(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)
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:161
const bool gui_use_transliteration
Definition gui_main.c:162
void create_event(struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Definition climisc.c:1082
void center_on_something(void)
Definition climisc.c:430
void start_autoconnecting_to_server(void)
Definition clinet.c:553
void disconnect_from_server(bool leaving_sound)
Definition clinet.c:306
double try_to_autoconnect(void)
Definition clinet.c:498
void input_from_server_till_request_got_processed(int fd, int expected_request_id)
Definition clinet.c:447
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
char * incite_cost
Definition comments.c:74
#define MAX_LEN_PASSWORD
Definition conn_types.h:31
report_type
Definition conn_types.h:49
void client_kill_server(bool force)
bool client_start_server(void)
void conn_reset_delta_state(struct connection *pc)
Definition connection.c:673
double blink_turn_done_button(void)
Definition control.c:907
void control_free(void)
Definition control.c:154
void unit_focus_set(struct unit *punit)
Definition control.c:501
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:771
void control_mouse_cursor(struct tile *ptile)
Definition control.c:1189
double blink_active_unit(void)
Definition control.c:874
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:84
bool could_meet_with_player(const struct player *pplayer, const struct player *aplayer)
Definition diptreaty.c:64
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:1050
#define MAX_LEN_NAME
Definition fc_types.h:66
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:92
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:491
struct civ_game game
Definition game.c:61
int current_turn_timeout(void)
Definition game.c:851
void game_init(bool keep_ruleset_value)
Definition game.c:443
void game_free(void)
Definition game.c:474
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:426
const char * ruler_title_for_player(const struct player *pplayer, char *buf, size_t buf_len)
Definition government.c:391
void popdown_all_city_dialogs(void)
Definition citydlg.c:607
void color_free(struct color *color)
Definition colors.c:53
void popdown_races_dialog(void)
Definition dialogs.c:1230
void popdown_all_game_dialogs(void)
Definition dialogs.c:1514
void close_all_diplomacy_dialogs(void)
Definition diplodlg.c:1258
void editgui_popdown_all(void)
Definition editgui.c:1890
void editgui_tileset_changed(void)
Definition editgui.c:1862
int ui_main(int argc, char **argv)
Definition gui_main.c:1910
const char * client_string
Definition gui_main.c:105
void ui_exit(void)
Definition gui_main.c:2089
void ui_init(void)
Definition gui_main.c:1778
void update_timeout_label(void)
Definition mapview.c:118
void update_info_label(void)
Definition mapview.c:138
void update_unit_info_label(struct unit_list *punits)
Definition mapview.c:275
GType type
Definition repodlgs.c:1313
void voteinfo_gui_update(void)
static struct gui_funcs funcs
void conn_list_dialog_update(void)
void free_help_texts(void)
Definition helpdata.c:125
void boot_help_texts(void)
Definition helpdata.c:710
void helpdata_init(void)
Definition helpdata.c:95
void helpdata_done(void)
Definition helpdata.c:103
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
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:558
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:506
void mapimg_reset(void)
Definition mapimg.c:541
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 modpacks_free(void)
Definition modpack.c:62
void modpacks_init(void)
Definition modpack.c:50
struct fileinfo_list * get_modpacks_list(void)
Definition modpack.c:127
const char * modpack_cache_tileset(struct section_file *sf)
Definition modpack.c:262
void start_menu_music(const char *const tag, char *const alt_tag)
Definition music.c:98
void stop_menu_music(void)
Definition music.c:108
void start_style_music(void)
Definition music.c:44
void stop_style_music(void)
Definition music.c:90
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:6863
const char * tileset_name_for_topology(int topology_id)
Definition options.c:6777
const struct option_set * server_optset
Definition options.c:4281
void options_free(void)
Definition options.c:6579
int option_number(const struct option *poption)
Definition options.c:653
const char * option_name(const struct option *poption)
Definition options.c:663
int option_int_get(const struct option *poption)
Definition options.c:869
void options_init(void)
Definition options.c:6481
struct option * optset_option_by_number(const struct option_set *poptset, int id)
Definition options.c:455
bool option_bool_get(const struct option *poption)
Definition options.c:832
void server_options_init(void)
Definition options.c:4425
enum option_type option_type(const struct option *poption)
Definition options.c:693
void options_dialogs_update(void)
Definition options.c:6098
void server_options_free(void)
Definition options.c:4494
void options_load(void)
Definition options.c:6159
void options_save(option_save_log_callback log_cb)
Definition options.c:6341
struct client_options gui_options
Definition options.c:71
unsigned option_bitwise_get(const struct option *poption)
Definition options.c:1109
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:466
void options_dialogs_set(void)
Definition options.c:6126
#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
const char * packet_name(enum packet_type type)
Definition packets_gen.c:47
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:218
int len
Definition packhand.c:127
bool client_handle_packet(enum packet_type type, const void *packet)
bool is_valid_username(const char *name)
Definition player.c:1914
int player_count(void)
Definition player.c:817
int player_number(const struct player *pplayer)
Definition player.c:837
#define players_iterate_end
Definition player.h:539
#define players_iterate(_pplayer)
Definition player.h:534
void init_player_dlg_common(void)
void fc_srand(RANDOM_TYPE seed)
Definition rand.c:161
#define fc_rand(_size)
Definition rand.h:56
struct section_file * secfile_load(const char *filename, bool allow_duplicates)
Definition registry.c:51
void registry_module_init(void)
Definition registry.c:31
void registry_module_close(void)
Definition registry.c:41
void secfile_destroy(struct section_file *secfile)
struct research * research_get(const struct player *pplayer)
Definition research.c:128
void research_update(struct research *presearch)
Definition research.c:501
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:704
void dont_run_as_root(const char *argv0, const char *fallback)
Definition shared.c:1539
bool str_to_int(const char *str, int *pint)
Definition shared.c:515
#define MIN(x, y)
Definition shared.h:55
#define FC_INFINITY
Definition shared.h:36
#define MAX(x, y)
Definition shared.h:54
#define fileinfo_list_iterate(list, pnode)
Definition shared.h:182
#define fileinfo_list_iterate_end
Definition shared.h:184
Definition ai.h:50
Definition city.h:320
int id
Definition city.h:326
struct conn_list * est_connections
Definition game.h:97
struct packet_game_info info
Definition game.h:89
bool ruleset_ready
Definition game.h:117
struct conn_list * all_connections
Definition game.h:96
bool ruleset_init
Definition game.h:116
struct packet_timeout_info tinfo
Definition game.h:91
struct civ_game::@31::@34 client
struct connection conn
Definition client_main.h:96
int default_server_port
Definition options.h:110
char default_sound_set_name[512]
Definition options.h:119
bool use_prev_server
Definition options.h:111
char default_metaserver[512]
Definition options.h:114
char default_tileset_name[512]
Definition options.h:130
bool auto_center_each_turn
Definition options.h:159
int default_topology
Definition options.h:123
char default_server_host[512]
Definition options.h:109
bool heartbeat_enabled
Definition options.h:112
bool save_options_on_exit
Definition options.h:125
char default_music_set_name[512]
Definition options.h:120
char default_sound_plugin_name[512]
Definition options.h:121
char default_user_name[512]
Definition options.h:108
bool established
Definition connection.h:140
struct player * playing
Definition connection.h:151
bool observer
Definition connection.h:147
struct city_list * cities
Definition player.h:281
struct dbv tile_vision[V_COUNT]
Definition player.h:359
struct player::@70::@73 client
Definition tile.h:50
struct unit_list * units
Definition tile.h:58
Definition timing.c:81
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:186
int fc_at_quick_exit(void(*func)(void))
Definition support.c:1317
#define sz_strlcpy(dest, src)
Definition support.h:189
#define fc__noreturn
Definition support.h:125
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
void free_svg_flag_API(void)
Definition svgflag.c:109
void init_themes(void)
enum known_type tile_get_known(const struct tile *ptile, const struct player *pplayer)
Definition tile.c:392
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:89
known_type
Definition tile.h:35
@ TILE_KNOWN_SEEN
Definition tile.h:38
#define tile_terrain(_tile)
Definition tile.h:111
#define tile_owner(_tile)
Definition tile.h:97
bool tilespec_try_read(const char *tileset_name, bool verbose, int topo_id, bool global_default)
Definition tilespec.c:1335
struct tileset * unscaled_tileset
Definition tilespec.c:569
int index_ts_topology(int idx)
Definition tilespec.c:1086
void tileset_free(struct tileset *t)
Definition tilespec.c:1290
void timer_start(struct timer *t)
Definition timing.c:264
double timer_read_seconds(struct timer *t)
Definition timing.c:384
struct timer * timer_renew(struct timer *t, enum timer_timetype type, enum timer_use use, const char *name)
Definition timing.c:180
@ TIMER_ACTIVE
Definition timing.h:46
@ TIMER_USER
Definition timing.h:42
#define unit_owner(_pu)
Definition unit.h:396
void role_unit_precalcs(void)
Definition unittype.c:2175
void update_queue_free(void)
void set_client_page(enum client_pages page)
void update_queue_init(void)
enum client_pages get_client_page(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:176