Author: sveinung
Date: Mon Apr 24 04:48:18 2017
New Revision: 35288

URL: http://svn.gna.org/viewcvs/freeciv?rev=35288&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:
    branches/S3_0/client/client_main.c
    branches/S3_0/common/fc_interface.c
    branches/S3_0/common/fc_interface.h
    branches/S3_0/server/srv_main.c

Modified: branches/S3_0/client/client_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/client/client_main.c?rev=35288&r1=35287&r2=35288&view=diff
==============================================================================
--- branches/S3_0/client/client_main.c  (original)
+++ branches/S3_0/client/client_main.c  Mon Apr 24 04:48:18 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: branches/S3_0/common/fc_interface.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/common/fc_interface.c?rev=35288&r1=35287&r2=35288&view=diff
==============================================================================
--- branches/S3_0/common/fc_interface.c (original)
+++ branches/S3_0/common/fc_interface.c Mon Apr 24 04:48:18 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: branches/S3_0/common/fc_interface.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/common/fc_interface.h?rev=35288&r1=35287&r2=35288&view=diff
==============================================================================
--- branches/S3_0/common/fc_interface.h (original)
+++ branches/S3_0/common/fc_interface.h Mon Apr 24 04:48:18 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: branches/S3_0/server/srv_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/server/srv_main.c?rev=35288&r1=35287&r2=35288&view=diff
==============================================================================
--- branches/S3_0/server/srv_main.c     (original)
+++ branches/S3_0/server/srv_main.c     Mon Apr 24 04:48:18 2017
@@ -3308,6 +3308,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.
 ***************************************************************/
@@ -3318,6 +3333,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

Reply via email to