Author: sveinung Date: Mon Apr 24 04:47:27 2017 New Revision: 35287 URL: http://svn.gna.org/viewcvs/freeciv?rev=35287&view=rev Log: Boolean server setting value access.
Add a function that gives access to the value of bool server settings to fc_interface. This can be used to implement a ServerSetting requirement type. It can also be used to check the value of Boolean server settings that aren't sent in PACKET_GAME_INFO. See hrm Feature #654153 Modified: trunk/client/client_main.c trunk/common/fc_interface.c trunk/common/fc_interface.h trunk/server/srv_main.c Modified: trunk/client/client_main.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/client_main.c?rev=35287&r1=35286&r2=35287&view=diff ============================================================================== --- trunk/client/client_main.c (original) +++ trunk/client/client_main.c Mon Apr 24 04:47:27 2017 @@ -1427,6 +1427,21 @@ return opt_type; } +/*************************************************************************** + Returns the value of the boolean server setting with the specified id. +***************************************************************************/ +static bool client_ss_val_bool_get(server_setting_id id) +{ + struct option *pset = optset_option_by_number(server_optset, id); + + if (pset) { + return option_bool_get(pset); + } else { + log_error("No server setting with the id %d exists.", id); + return FALSE; + } +} + /*************************************************************** Initialize client specific functions. ***************************************************************/ @@ -1437,6 +1452,7 @@ funcs->server_setting_by_name = client_ss_by_name; funcs->server_setting_name_get = client_ss_name_get; funcs->server_setting_type_get = client_ss_type_get; + funcs->server_setting_val_bool_get = client_ss_val_bool_get; funcs->create_extra = NULL; funcs->destroy_extra = NULL; funcs->player_tile_vision_get = client_map_is_known_and_seen; Modified: trunk/common/fc_interface.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/fc_interface.c?rev=35287&r1=35286&r2=35287&view=diff ============================================================================== --- trunk/common/fc_interface.c (original) +++ trunk/common/fc_interface.c Mon Apr 24 04:47:27 2017 @@ -59,6 +59,7 @@ fc_assert_exit(fc_funcs->server_setting_by_name); fc_assert_exit(fc_funcs->server_setting_name_get); fc_assert_exit(fc_funcs->server_setting_type_get); + fc_assert_exit(fc_funcs->server_setting_val_bool_get); fc_assert_exit(fc_funcs->player_tile_vision_get); fc_assert_exit(fc_funcs->player_tile_city_id_get); fc_assert_exit(fc_funcs->gui_color_free); Modified: trunk/common/fc_interface.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/fc_interface.h?rev=35287&r1=35286&r2=35287&view=diff ============================================================================== --- trunk/common/fc_interface.h (original) +++ trunk/common/fc_interface.h Mon Apr 24 04:47:27 2017 @@ -34,6 +34,7 @@ server_setting_id (*server_setting_by_name)(const char *name); const char *(*server_setting_name_get)(server_setting_id id); enum sset_type (*server_setting_type_get)(server_setting_id id); + bool (*server_setting_val_bool_get)(server_setting_id id); void (*create_extra)(struct tile *ptile, struct extra_type *pextra, struct player *pplayer); void (*destroy_extra)(struct tile *ptile, struct extra_type *pextra); Modified: trunk/server/srv_main.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/srv_main.c?rev=35287&r1=35286&r2=35287&view=diff ============================================================================== --- trunk/server/srv_main.c (original) +++ trunk/server/srv_main.c Mon Apr 24 04:47:27 2017 @@ -3309,6 +3309,21 @@ } } +/*************************************************************************** + Returns the value of the boolean server setting with the specified id. +***************************************************************************/ +static bool server_ss_val_bool_get(server_setting_id id) +{ + struct setting *pset = setting_by_number(id); + + if (pset) { + return setting_bool_get(pset); + } else { + log_error("No server setting with the id %d exists.", id); + return FALSE; + } +} + /*************************************************************** Initialize client specific functions. ***************************************************************/ @@ -3319,6 +3334,7 @@ funcs->server_setting_by_name = server_ss_by_name; funcs->server_setting_name_get = server_ss_name_get; funcs->server_setting_type_get = server_ss_type_get; + funcs->server_setting_val_bool_get = server_ss_val_bool_get; funcs->create_extra = create_extra; funcs->destroy_extra = destroy_extra; funcs->player_tile_vision_get = map_is_known_and_seen; _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits