Author: sveinung
Date: Tue Mar 24 18:25:41 2015
New Revision: 28612

URL: http://svn.gna.org/viewcvs/freeciv?rev=28612&view=rev
Log:
Read nation group names before loading rules that may depend on them.

See bug #23401

Modified:
    branches/S2_6/server/ruleset.c

Modified: branches/S2_6/server/ruleset.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/ruleset.c?rev=28612&r1=28611&r2=28612&view=diff
==============================================================================
--- branches/S2_6/server/ruleset.c      (original)
+++ branches/S2_6/server/ruleset.c      Tue Mar 24 18:25:41 2015
@@ -3535,6 +3535,30 @@
 
   section_list_destroy(sec);
 
+  if (ok) {
+    sec = secfile_sections_by_name_prefix(file, NATION_GROUP_SECTION_PREFIX);
+    if (sec) {
+      section_list_iterate(sec, psection) {
+        struct nation_group *pgroup;
+        const char *name;
+
+        name = secfile_lookup_str(file, "%s.name", section_name(psection));
+        if (NULL == name) {
+          ruleset_error(LOG_ERROR, "Error: %s", secfile_error());
+          ok = FALSE;
+          break;
+        }
+        pgroup = nation_group_new(name);
+        if (pgroup == NULL) {
+          ok = FALSE;
+          break;
+        }
+      } section_list_iterate_end;
+      section_list_destroy(sec);
+      sec = NULL;
+    }
+  }
+
   return ok;
 }
 
@@ -3848,12 +3872,7 @@
         bool hidden;
 
         name = secfile_lookup_str(file, "%s.name", section_name(psection));
-        if (NULL == name) {
-          ruleset_error(LOG_ERROR, "Error: %s", secfile_error());
-          ok = FALSE;
-          break;
-        }
-        pgroup = nation_group_new(name);
+        pgroup = nation_group_by_rule_name(name);
         if (pgroup == NULL) {
           ok = FALSE;
           break;


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

Reply via email to