Author: sveinung
Date: Sun Feb 28 01:37:12 2016
New Revision: 32102

URL: http://svn.gna.org/viewcvs/freeciv?rev=32102&view=rev
Log:
Fix 2.6 ruleset upgrade for goods.

See bug #24457

Modified:
    trunk/server/ruleset.c

Modified: trunk/server/ruleset.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/ruleset.c?rev=32102&r1=32101&r2=32102&view=diff
==============================================================================
--- trunk/server/ruleset.c      (original)
+++ trunk/server/ruleset.c      Sun Feb 28 01:37:12 2016
@@ -1043,37 +1043,43 @@
 
   section_list_destroy(sec);
 
-  if (ok) {
-    sec = secfile_sections_by_name_prefix(file, GOODS_SECTION_PREFIX);
-
-    nval = (NULL != sec ? section_list_size(sec) : 0);
-    if (nval > MAX_GOODS_TYPES) {
-      int num = nval; /* No "size_t" to printf */
-
-      ruleset_error(LOG_ERROR, "\"%s\": Too many goods types (%d, max %d)",
-                    filename, num, MAX_GOODS_TYPES);
-      section_list_destroy(sec);
-      ok = FALSE;
-    } else if (nval < 1) {
-      ruleset_error(LOG_ERROR, "\"%s\": At least one goods type needed",
-                    filename);
-      section_list_destroy(sec);
-      ok = FALSE;
-    } else {
-      game.control.num_goods_types = nval;
-    }
-
+  if (compat->ver_game < 10) {
+    rscompat_goods_3_0();
+  } else {
     if (ok) {
-      goods_type_iterate(pgood) {
-        const char *sec_name = section_name(section_list_get(sec, 
goods_index(pgood)));
-
-        if (!ruleset_load_names(&pgood->name, NULL, file, sec_name)) {
-          ruleset_error(LOG_ERROR, "\"%s\": Cannot load goods names",
-                        filename);
-          ok = FALSE;
-          break;
-        }
-      } goods_type_iterate_end;
+      sec = secfile_sections_by_name_prefix(file, GOODS_SECTION_PREFIX);
+
+      nval = (NULL != sec ? section_list_size(sec) : 0);
+      if (nval > MAX_GOODS_TYPES) {
+        int num = nval; /* No "size_t" to printf */
+
+        ruleset_error(LOG_ERROR,
+                      "\"%s\": Too many goods types (%d, max %d)",
+                      filename, num, MAX_GOODS_TYPES);
+        section_list_destroy(sec);
+        ok = FALSE;
+      } else if (nval < 1) {
+        ruleset_error(LOG_ERROR, "\"%s\": At least one goods type needed",
+                      filename);
+        section_list_destroy(sec);
+        ok = FALSE;
+      } else {
+        game.control.num_goods_types = nval;
+      }
+
+      if (ok) {
+        goods_type_iterate(pgood) {
+          const char *sec_name
+              = section_name(section_list_get(sec, goods_index(pgood)));
+
+          if (!ruleset_load_names(&pgood->name, NULL, file, sec_name)) {
+            ruleset_error(LOG_ERROR, "\"%s\": Cannot load goods names",
+                          filename);
+            ok = FALSE;
+            break;
+          }
+        } goods_type_iterate_end;
+      }
     }
   }
 
@@ -6271,25 +6277,21 @@
     }
   }
 
-  if (compat->ver_game < 10) {
-    rscompat_goods_3_0();
-  } else {
-    if (ok) {
-      sec = secfile_sections_by_name_prefix(file, GOODS_SECTION_PREFIX);
-
-      goods_type_iterate(pgood) {
-        int id = goods_index(pgood);
-        const char *sec_name = section_name(section_list_get(sec, id));
-        struct requirement_vector *reqs;
-
-        reqs = lookup_req_list(file, compat, sec_name, "reqs", 
goods_rule_name(pgood));
-        if (reqs == NULL) {
-          ok = FALSE;
-          break;
-        }
-        requirement_vector_copy(&pgood->reqs, reqs);
-      } goods_type_iterate_end;
-    }
+  if (ok) {
+    sec = secfile_sections_by_name_prefix(file, GOODS_SECTION_PREFIX);
+
+    goods_type_iterate(pgood) {
+      int id = goods_index(pgood);
+      const char *sec_name = section_name(section_list_get(sec, id));
+      struct requirement_vector *reqs;
+
+      reqs = lookup_req_list(file, compat, sec_name, "reqs", 
goods_rule_name(pgood));
+      if (reqs == NULL) {
+        ok = FALSE;
+        break;
+      }
+      requirement_vector_copy(&pgood->reqs, reqs);
+    } goods_type_iterate_end;
   }
 
   /* secfile_check_unused() is not here, but only after also settings section


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

Reply via email to