Author: jtn
Date: Mon Dec 21 10:49:22 2015
New Revision: 31135

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

See gna bug #24207.

Modified:
    branches/S2_5/server/ruleset.c

Modified: branches/S2_5/server/ruleset.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/ruleset.c?rev=31135&r1=31134&r2=31135&view=diff
==============================================================================
--- branches/S2_5/server/ruleset.c      (original)
+++ branches/S2_5/server/ruleset.c      Mon Dec 21 10:49:22 2015
@@ -1142,6 +1142,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);
@@ -1378,6 +1384,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);
@@ -2387,6 +2400,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