Author: jtn
Date: Mon Dec 21 10:11:25 2015
New Revision: 31130

URL: http://svn.gna.org/viewcvs/freeciv?rev=31130&view=rev
Log:
Check for duplicate flag names when loading rulesets.

See gna bug #24207.

Modified:
    trunk/server/ruleset.c

Modified: trunk/server/ruleset.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/ruleset.c?rev=31130&r1=31129&r2=31130&view=diff
==============================================================================
--- trunk/server/ruleset.c      (original)
+++ trunk/server/ruleset.c      Mon Dec 21 10:11:25 2015
@@ -1061,6 +1061,12 @@
        i++) {
     const char *helptxt = secfile_lookup_str_default(file, NULL, 
"control.flags%d.helptxt",
                                                      i);
+    if (tech_flag_id_by_name(flag, fc_strcasecmp) != tech_flag_id_invalid()) {
+      ruleset_error(LOG_ERROR, "\"%s\": Duplicate tech flag name '%s'",
+                    filename, flag);
+      ok = FALSE;
+      break;
+    }
     if (i > MAX_NUM_USER_TECH_FLAGS) {
       ruleset_error(LOG_ERROR, "\"%s\": Too many user tech flags!",
                     filename);
@@ -1306,6 +1312,13 @@
     const char *helptxt = secfile_lookup_str_default(file, NULL, 
"control.flags%d.helptxt",
                                                      i);
 
+    if (unit_type_flag_id_by_name(flag, fc_strcasecmp)
+        != unit_type_flag_id_invalid()) {
+      ruleset_error(LOG_ERROR, "\"%s\": Duplicate unit flag name '%s'",
+                    filename, flag);
+      ok = FALSE;
+      break;
+    }
     if (i > MAX_NUM_USER_UNIT_FLAGS) {
       ruleset_error(LOG_ERROR, "\"%s\": Too many user unit type flags!",
                     filename);
@@ -2184,6 +2197,13 @@
     const char *helptxt = secfile_lookup_str_default(file, NULL, 
"control.flags%d.helptxt",
                                                      i);
 
+    if (terrain_flag_id_by_name(flag, fc_strcasecmp)
+        != terrain_flag_id_invalid()) {
+      ruleset_error(LOG_ERROR, "\"%s\": Duplicate terrain flag name '%s'",
+                    filename, flag);
+      ok = FALSE;
+      break;
+    }
     if (i > MAX_NUM_USER_TER_FLAGS) {
       ruleset_error(LOG_ERROR, "\"%s\": Too many user terrain flags!",
                     filename);


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

Reply via email to