Author: cazfi
Date: Sun Apr 10 11:21:33 2016
New Revision: 32335

URL: http://svn.gna.org/viewcvs/freeciv?rev=32335&view=rev
Log:
Free ruleset choices list server has generated for local clients.

See bug #24564

Modified:
    trunk/server/gamehand.c
    trunk/server/gamehand.h
    trunk/server/srv_main.c

Modified: trunk/server/gamehand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/gamehand.c?rev=32335&r1=32334&r2=32335&view=diff
==============================================================================
--- trunk/server/gamehand.c     (original)
+++ trunk/server/gamehand.c     Sun Apr 10 11:21:33 2016
@@ -78,6 +78,8 @@
 #define SPECPQ_DATA_TYPE struct team_placement_state *
 #define SPECPQ_PRIORITY_TYPE long
 #include "specpq.h"
+
+static struct strvec *ruleset_choices = NULL;
 
 /****************************************************************************
   Get role_id for given role character
@@ -1062,23 +1064,32 @@
 static void send_ruleset_choices(struct connection *pc)
 {
   struct packet_ruleset_choices packet;
-  static struct strvec *rulesets = NULL;
   size_t i;
 
-  if (!rulesets) {
+  if (ruleset_choices == NULL) {
     /* This is only read once per server invocation.  Add a new ruleset
      * and you have to restart the server. */
-    rulesets = fileinfolist(get_data_dirs(), RULESET_SUFFIX);
-  }
-
-  packet.ruleset_count = MIN(MAX_NUM_RULESETS, strvec_size(rulesets));
+    ruleset_choices = fileinfolist(get_data_dirs(), RULESET_SUFFIX);
+  }
+
+  packet.ruleset_count = MIN(MAX_NUM_RULESETS, strvec_size(ruleset_choices));
   for (i = 0; i < packet.ruleset_count; i++) {
-    sz_strlcpy(packet.rulesets[i], strvec_get(rulesets, i));
+    sz_strlcpy(packet.rulesets[i], strvec_get(ruleset_choices, i));
   }
 
   send_packet_ruleset_choices(pc, &packet);
 }
 
+/************************************************************************** 
+  Free list of ruleset choices.
+**************************************************************************/
+void ruleset_choices_free(void)
+{
+  if (ruleset_choices != NULL) {
+    free(ruleset_choices);
+    ruleset_choices = NULL;
+  }
+}
 
 /**************************************************************************** 
   Opens a file specified by the packet and compares the packet values with

Modified: trunk/server/gamehand.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/gamehand.h?rev=32335&r1=32334&r2=32335&view=diff
==============================================================================
--- trunk/server/gamehand.h     (original)
+++ trunk/server/gamehand.h     Sun Apr 10 11:21:33 2016
@@ -32,4 +32,6 @@
 
 const char *new_challenge_filename(struct connection *pc);
 
+void ruleset_choices_free(void);
+
 #endif  /* FC__GAMEHAND_H */

Modified: trunk/server/srv_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/srv_main.c?rev=32335&r1=32334&r2=32335&view=diff
==============================================================================
--- trunk/server/srv_main.c     (original)
+++ trunk/server/srv_main.c     Sun Apr 10 11:21:33 2016
@@ -1609,6 +1609,7 @@
   generator_free();
   close_connections_and_socket();
   rulesets_deinit();
+  ruleset_choices_free();
   timing_log_free();
   registry_module_close();
   fc_destroy_mutex(&game.server.mutexes.city_list);


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to