Freeciv-3.1: /fast/freeciv/nightly/S3_1/common/fc_interface.c Source File

Freeciv-3.1

Loading...
Searching...
No Matches
fc_interface.c
Go to the documentation of this file.
1/****************************************************************************
2 Freeciv - Copyright (C) 2004 - The Freeciv Team
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/* utility */
19#include "astring.h"
20#include "fciconv.h"
21#include "netfile.h"
22#include "shared.h"
23
24/* common */
25#include "player.h"
26#include "tile.h"
27#include "vision.h"
28
29#include "fc_interface.h"
30
31/* Struct with functions pointers; the functions are defined in
32 ./client/client_main.c:init_client_functions(),
33 ./server/srv_main.c:init_server_functions(), and
34 ./tools/shared/tools_fc_interface.c(). */
35 struct functions fc_functions;
36
37/* The functions are accessed via this pointer. */
38 const struct functions *fc_funcs = NULL;
39/* After this is set to TRUE (in interface_init()), the functions are
40 available via fc_funcs. */
41 bool fc_funcs_defined = FALSE;
42
43/************************************************************************/
47 struct functions *fc_interface_funcs(void)
48{
49 fc_assert_exit(!fc_funcs_defined);
50
51 return &fc_functions;
52}
53
54/************************************************************************/
57 void i_am_server(void)
58{
59 am_i_server = TRUE;
60}
61
62/************************************************************************/
65 void i_am_client(void)
66{
67 am_i_server = FALSE;
68}
69
70/************************************************************************/
74 void libfreeciv_init(bool check_fc_interface)
75{
76 fc_astr_init();
77 fc_support_init();
78 init_nls();
79
80 if (check_fc_interface) {
81 fc_funcs = &fc_functions;
82
83 /* Test the existence of each required function here! */
84 fc_assert_exit(fc_funcs->server_setting_by_name);
85 fc_assert_exit(fc_funcs->server_setting_name_get);
86 fc_assert_exit(fc_funcs->server_setting_type_get);
87 fc_assert_exit(fc_funcs->server_setting_val_bool_get);
88 fc_assert_exit(fc_funcs->server_setting_val_int_get);
89 fc_assert_exit(fc_funcs->server_setting_val_bitwise_get);
90 fc_assert_exit(fc_funcs->player_tile_vision_get);
91 fc_assert_exit(fc_funcs->player_tile_city_id_get);
92 fc_assert_exit(fc_funcs->gui_color_free);
93
94 fc_funcs_defined = TRUE;
95
96 setup_real_activities_array();
97 }
98}
99
100/************************************************************************/
103 void libfreeciv_free(void)
104{
105 diplrel_mess_close();
106 free_data_dir_names();
107 free_multicast_group();
108 free_freeciv_storage_dir();
109 free_user_home_dir();
110 free_fileinfo_data();
111 netfile_free();
112 free_nls();
113 fc_iconv_close();
114 fc_support_free();
115 fc_astr_free();
116}
fc_astr_init
void fc_astr_init(void)
Definition astring.c:414
fc_astr_free
void fc_astr_free(void)
Definition astring.c:422
astring.h
i_am_server
void i_am_server(void)
Definition fc_interface.c:57
i_am_client
void i_am_client(void)
Definition fc_interface.c:65
fc_funcs
const struct functions * fc_funcs
Definition fc_interface.c:38
fc_functions
struct functions fc_functions
Definition fc_interface.c:35
libfreeciv_init
void libfreeciv_init(bool check_fc_interface)
Definition fc_interface.c:74
fc_funcs_defined
bool fc_funcs_defined
Definition fc_interface.c:41
libfreeciv_free
void libfreeciv_free(void)
Definition fc_interface.c:103
fc_interface_funcs
struct functions * fc_interface_funcs(void)
Definition fc_interface.c:47
fc_interface.h
am_i_server
bool am_i_server
Definition game.c:60
fc_iconv_close
void fc_iconv_close(void)
Definition fciconv.c:417
fciconv.h
fc_assert_exit
#define fc_assert_exit(condition)
Definition log.h:197
netfile_free
void netfile_free(void)
Definition netfile.c:327
netfile.h
diplrel_mess_close
void diplrel_mess_close(void)
Definition player.c:1772
player.h
free_user_home_dir
void free_user_home_dir(void)
Definition shared.c:659
init_nls
void init_nls(void)
Definition shared.c:1463
free_data_dir_names
void free_data_dir_names(void)
Definition shared.c:859
free_multicast_group
void free_multicast_group(void)
Definition shared.c:1693
free_fileinfo_data
void free_fileinfo_data(void)
Definition shared.c:1151
free_nls
void free_nls(void)
Definition shared.c:1522
free_freeciv_storage_dir
void free_freeciv_storage_dir(void)
Definition shared.c:690
shared.h
functions
Definition fc_interface.h:33
functions::player_tile_city_id_get
int(* player_tile_city_id_get)(const struct tile *ptile, const struct player *pplayer)
Definition fc_interface.h:52
functions::server_setting_val_int_get
int(* server_setting_val_int_get)(server_setting_id id)
Definition fc_interface.h:38
functions::player_tile_vision_get
bool(* player_tile_vision_get)(const struct tile *ptile, const struct player *pplayer, enum vision_layer vision)
Definition fc_interface.h:46
functions::server_setting_val_bool_get
bool(* server_setting_val_bool_get)(server_setting_id id)
Definition fc_interface.h:37
functions::server_setting_by_name
server_setting_id(* server_setting_by_name)(const char *name)
Definition fc_interface.h:34
functions::server_setting_val_bitwise_get
unsigned int(* server_setting_val_bitwise_get)(server_setting_id id)
Definition fc_interface.h:39
functions::server_setting_type_get
enum sset_type(* server_setting_type_get)(server_setting_id id)
Definition fc_interface.h:36
functions::gui_color_free
void(* gui_color_free)(struct color *pcolor)
Definition fc_interface.h:54
functions::server_setting_name_get
const char *(* server_setting_name_get)(server_setting_id id)
Definition fc_interface.h:35
fc_support_init
void fc_support_init(void)
Definition support.c:1338
fc_support_free
void fc_support_free(void)
Definition support.c:1356
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
tile.h
setup_real_activities_array
void setup_real_activities_array(void)
Definition unit.c:591
vision.h