server_settings: assert that fc_funcs exists.
[freeciv.git] / common / server_settings.c
blob48d7a5ddd975bfd77c2482de086d21a43002c1b5
1 /***********************************************************************
2 Freeciv - Copyright (C) 2017 - Freeciv Development 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.
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 ***********************************************************************/
14 #ifdef HAVE_CONFIG_H
15 #include <fc_config.h>
16 #endif
18 /* common */
19 #include "fc_interface.h"
21 #include "server_settings.h"
23 /***************************************************************************
24 Returns the server setting with the specified name.
25 ***************************************************************************/
26 server_setting_id server_setting_by_name(const char *name)
28 fc_assert_ret_val(fc_funcs, SERVER_SETTING_NONE);
29 fc_assert_ret_val(fc_funcs->server_setting_by_name, SERVER_SETTING_NONE);
31 return fc_funcs->server_setting_by_name(name);
34 /***************************************************************************
35 Returns the name of the server setting with the specified id.
36 ***************************************************************************/
37 const char *server_setting_name_get(server_setting_id id)
39 fc_assert_ret_val(fc_funcs, NULL);
40 fc_assert_ret_val(fc_funcs->server_setting_name_get, NULL);
42 return fc_funcs->server_setting_name_get(id);
45 /***************************************************************************
46 Returns the type of the server setting with the specified id.
47 ***************************************************************************/
48 enum sset_type server_setting_type_get(server_setting_id id)
50 fc_assert_ret_val(fc_funcs, sset_type_invalid());
51 fc_assert_ret_val(fc_funcs->server_setting_type_get, sset_type_invalid());
53 return fc_funcs->server_setting_type_get(id);
56 /***************************************************************************
57 Returns TRUE iff a server setting with the specified id exists.
58 ***************************************************************************/
59 bool server_setting_exists(server_setting_id id)
61 return sset_type_is_valid(server_setting_type_get(id));
64 /***************************************************************************
65 Returns the value of the server setting with the specified id.
66 ***************************************************************************/
67 bool server_setting_value_bool_get(server_setting_id id)
69 fc_assert_ret_val(fc_funcs, FALSE);
70 fc_assert_ret_val(fc_funcs->server_setting_val_bool_get, FALSE);
71 fc_assert_ret_val(server_setting_type_get(id) == SST_BOOL, FALSE);
73 return fc_funcs->server_setting_val_bool_get(id);