Author: cazfi
Date: Tue Dec 22 03:31:41 2015
New Revision: 31144

URL: http://svn.gna.org/viewcvs/freeciv?rev=31144&view=rev
Log:
Automatically make resource extras to conflict each other.

See patch #6702

Modified:
    trunk/server/rssanity.c
    trunk/server/rssanity.h
    trunk/server/ruleset.c
    trunk/tools/ruledit/tab_misc.cpp

Modified: trunk/server/rssanity.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/rssanity.c?rev=31144&r1=31143&r2=31144&view=diff
==============================================================================
--- trunk/server/rssanity.c     (original)
+++ trunk/server/rssanity.c     Tue Dec 22 03:31:41 2015
@@ -988,3 +988,29 @@
 
   return ok;
 }
+
+/**************************************************************************
+  Apply some automatic defaults to already loaded rulesets.
+
+  Returns TRUE iff everything ok.
+**************************************************************************/
+bool autoadjust_ruleset_data(void)
+{
+  bool ok = TRUE;
+  
+  extra_type_by_cause_iterate(EC_RESOURCE, pextra) {
+    extra_type_by_cause_iterate(EC_RESOURCE, pextra2) {
+      if (pextra != pextra2) {
+        int idx = extra_index(pextra2);
+
+        if (!BV_ISSET(pextra->conflicts, idx)) {
+          log_debug("Autoconflicting resource %s with %s",
+                    extra_rule_name(pextra), extra_rule_name(pextra2));
+          BV_SET(pextra->conflicts, extra_index(pextra2));
+        }
+      }
+    } extra_type_by_cause_iterate_end;
+  } extra_type_by_cause_iterate_end;
+
+  return ok;
+}

Modified: trunk/server/rssanity.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/rssanity.h?rev=31144&r1=31143&r2=31144&view=diff
==============================================================================
--- trunk/server/rssanity.h     (original)
+++ trunk/server/rssanity.h     Tue Dec 22 03:31:41 2015
@@ -17,6 +17,7 @@
 extern "C" {
 #endif /* __cplusplus */
 
+bool autoadjust_ruleset_data(void);
 bool sanity_check_ruleset_data(void);
 
 #ifdef __cplusplus

Modified: trunk/server/ruleset.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/ruleset.c?rev=31144&r1=31143&r2=31144&view=diff
==============================================================================
--- trunk/server/ruleset.c      (original)
+++ trunk/server/ruleset.c      Tue Dec 22 03:31:41 2015
@@ -7364,7 +7364,8 @@
     role_unit_precalcs();
     road_integrators_cache_init();
 
-    ok = sanity_check_ruleset_data();
+    ok = autoadjust_ruleset_data()
+      && sanity_check_ruleset_data();
   }
 
   if (ok) {

Modified: trunk/tools/ruledit/tab_misc.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruledit/tab_misc.cpp?rev=31144&r1=31143&r2=31144&view=diff
==============================================================================
--- trunk/tools/ruledit/tab_misc.cpp    (original)
+++ trunk/tools/ruledit/tab_misc.cpp    Tue Dec 22 03:31:41 2015
@@ -188,7 +188,7 @@
   strncpy(game.control.version, version->text().toUtf8().data(),
           sizeof(game.control.version));
 
-  if (!sanity_check_ruleset_data()) {
+  if (!autoadjust_ruleset_data() || !sanity_check_ruleset_data()) {
     QMessageBox *box = new QMessageBox();
 
     box->setText("Current data fails sanity checks. Save anyway?");


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

Reply via email to