Author: jtn
Date: Thu Dec 17 03:34:14 2015
New Revision: 31036

URL: http://svn.gna.org/viewcvs/freeciv?rev=31036&view=rev
Log:
Get rid of broken and slow code attempting to enforce that different
nations don't share leader names; this accidentally hadn't been enforced
since S2_3 (r18279), and has no known major harmful effects.

See gna bug #23791.

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=31036&r1=31035&r2=31036&view=diff
==============================================================================
--- branches/S2_6/server/ruleset.c      (original)
+++ branches/S2_6/server/ruleset.c      Thu Dec 17 03:34:14 2015
@@ -3508,13 +3508,11 @@
 }
 
 /****************************************************************************
-  This checks if nations[pos] leader names are not already defined in any
-  previous nation, or twice in its own leader name table.
-  If not return NULL, if yes return pointer to name which is repeated
-  and id of a conflicting nation as second parameter.
+  Check for duplicate leader names in nation.
+  If no duplicates return NULL; if yes return pointer to name which is
+  repeated.
 ****************************************************************************/
-static const char *check_leader_names(struct nation_type *pnation,
-                                      struct nation_type **ppconflict_nation)
+static const char *check_leader_names(struct nation_type *pnation)
 {
   nation_leader_list_iterate(nation_leaders(pnation), pleader) {
     const char *name = nation_leader_name(pleader);
@@ -3523,31 +3521,10 @@
       if (prev_leader == pleader) {
         break;
       } else if (0 == fc_strcasecmp(name, nation_leader_name(prev_leader))) {
-        *ppconflict_nation = pnation;
         return name;
       }
     } nation_leader_list_iterate_end;
   } nation_leader_list_iterate_end;
-
-  nations_iterate(prev_nation) {
-    if (prev_nation == pnation) {
-      break;
-    }
-
-    nation_leader_list_iterate(nation_leaders(prev_nation), pleader) {
-      const char *name = nation_leader_name(pleader);
-
-      nation_leader_list_iterate(nation_leaders(prev_nation), prev_leader) {
-        if (prev_leader == pleader) {
-          break;
-        } else if (0 == fc_strcasecmp(name,
-                                      nation_leader_name(prev_leader))) {
-          *ppconflict_nation = prev_nation;
-          return name;
-        }
-      } nation_leader_list_iterate_end;
-    } nation_leader_list_iterate_end;
-  } nations_iterate_end;
   return NULL;
 }
 
@@ -4189,22 +4166,13 @@
         break;
       }
 
-      /* Check if leader name is not already defined */
-      if ((bad_leader = check_leader_names(pnation, &pconflict))) {
-        if (pnation == pconflict) {
-          ruleset_error(LOG_ERROR,
-                        "Nation %s: leader \"%s\" defined more than once.",
-                        nation_rule_name(pnation), bad_leader);
-          ok = FALSE;
-          break;
-        } else {
-          ruleset_error(LOG_ERROR,
-                        "Nations %s and %s share the same leader \"%s\".",
-                        nation_rule_name(pnation), nation_rule_name(pconflict),
-                        bad_leader);
-          ok = FALSE;
-          break;
-        }
+      /* Check if leader name is not already defined in this nation. */
+      if ((bad_leader = check_leader_names(pnation))) {
+        ruleset_error(LOG_ERROR,
+                      "Nation %s: leader \"%s\" defined more than once.",
+                      nation_rule_name(pnation), bad_leader);
+        ok = FALSE;
+        break;
       }
 
       /* Nation player color preference, if any */


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

Reply via email to