Author: cazfi
Date: Thu Nov 26 15:19:48 2015
New Revision: 30794

URL: http://svn.gna.org/viewcvs/freeciv?rev=30794&view=rev
Log:
Explicitly check at ruleset loading time check that bases and roads have 
association to an extra,
to produce sensible error message when things fail.

See patch #6629

Modified:
    trunk/server/ruleset.c

Modified: trunk/server/ruleset.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/ruleset.c?rev=30794&r1=30793&r2=30794&view=diff
==============================================================================
--- trunk/server/ruleset.c      (original)
+++ trunk/server/ruleset.c      Thu Nov 26 15:19:48 2015
@@ -2350,15 +2350,23 @@
     for (idx = 0; idx < nval; idx++) {
       const char *sec_name = section_name(section_list_get(sec, idx));
       const char *base_name = secfile_lookup_str(file, "%s.extra", sec_name);
-      struct extra_type *pextra = extra_type_by_rule_name(base_name);
-
-      if (pextra != NULL) {
-        base_type_init(pextra, idx);
-        section_strlcpy(&base_sections[idx * MAX_SECTION_LABEL], sec_name);
+
+      if (base_name != NULL) {
+        struct extra_type *pextra = extra_type_by_rule_name(base_name);
+
+        if (pextra != NULL) {
+          base_type_init(pextra, idx);
+          section_strlcpy(&base_sections[idx * MAX_SECTION_LABEL], sec_name);
+        } else {
+          ruleset_error(LOG_ERROR,
+                        "No extra definition matching base definition \"%s\"",
+                        base_name);
+          ok = FALSE;
+        }
       } else {
         ruleset_error(LOG_ERROR,
-                      "No extra definition matching base definition \"%s\"",
-                      base_name);
+                      "Base section \"%s\" does not associate base with any 
extra",
+                      sec_name);
         ok = FALSE;
       }
     }
@@ -2394,15 +2402,23 @@
     for (idx = 0; idx < nval; idx++) {
       const char *sec_name = section_name(section_list_get(sec, idx));
       const char *road_name = secfile_lookup_str(file, "%s.extra", sec_name);
-      struct extra_type *pextra = extra_type_by_rule_name(road_name);
-
-      if (pextra != NULL) {
-        road_type_init(pextra, idx);
-        section_strlcpy(&road_sections[idx * MAX_SECTION_LABEL], sec_name);
+
+      if (road_name != NULL) {
+        struct extra_type *pextra = extra_type_by_rule_name(road_name);
+
+        if (pextra != NULL) {
+          road_type_init(pextra, idx);
+          section_strlcpy(&road_sections[idx * MAX_SECTION_LABEL], sec_name);
+        } else {
+          ruleset_error(LOG_ERROR,
+                        "No extra definition matching road definition \"%s\"",
+                        road_name);
+          ok = FALSE;
+        }
       } else {
         ruleset_error(LOG_ERROR,
-                      "No extra definition matching road definition \"%s\"",
-                      road_name);
+                      "Road section \"%s\" does not associate road with any 
extra",
+                      sec_name);
         ok = FALSE;
       }
     }


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

Reply via email to