Author: cazfi
Date: Wed Mar 11 22:54:12 2015
New Revision: 28493

URL: http://svn.gna.org/viewcvs/freeciv?rev=28493&view=rev
Log:
Sanity check boolean effects

See patch #5918

Modified:
    branches/S2_6/server/rssanity.c

Modified: branches/S2_6/server/rssanity.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/rssanity.c?rev=28493&r1=28492&r2=28493&view=diff
==============================================================================
--- branches/S2_6/server/rssanity.c     (original)
+++ branches/S2_6/server/rssanity.c     Wed Mar 11 22:54:12 2015
@@ -440,6 +440,58 @@
   return TRUE;
 }
 
+
+/**************************************************************************
+  Check that boolean effect types have sensible effects.
+**************************************************************************/
+static bool sanity_check_boolean_effects(void)
+{
+  enum effect_type boolean_effects[] =
+    {
+      EFT_ANY_GOVERNMENT,
+      EFT_CAPITAL_CITY,
+      EFT_ENABLE_NUKE,
+      EFT_ENABLE_SPACE,
+      EFT_HAVE_EMBASSIES,
+      EFT_NO_ANARCHY,
+      EFT_NUKE_PROOF,
+      EFT_REVEAL_CITIES,
+      EFT_REVEAL_MAP,
+      EFT_SIZE_UNLIMIT,
+      EFT_SS_STRUCTURAL,
+      EFT_SS_COMPONENT,
+      EFT_NO_UNHAPPY,
+      EFT_RAPTURE_GROW,
+      EFT_HAS_SENATE,
+      EFT_INSPIRE_PARTISANS,
+      EFT_HAPPINESS_TO_GOLD,
+      EFT_FANATICS,
+      EFT_NO_DIPLOMACY,
+      EFT_IRRIG_POSSIBLE,
+      EFT_GOV_CENTER,
+      EFT_TRANSFORM_POSSIBLE,
+      EFT_MINING_POSSIBLE,
+      EFT_IRRIG_TF_POSSIBLE,
+      EFT_MINING_TF_POSSIBLE,
+      EFT_NOT_TECH_SOURCE,
+      EFT_VICTORY,
+      EFT_COUNT
+    };
+  int i;
+  bool ret = TRUE;
+
+  for (i = 0; boolean_effects[i] != EFT_COUNT; i++) {
+    if (effect_cumulative_min(boolean_effects[i], NULL) < 0
+        && effect_cumulative_max(boolean_effects[i], NULL) >= 0) {
+      ruleset_error(LOG_ERROR, "Boolean effect %s can get disabled, but it 
can't get "
+                    "enabled before that.", 
effect_type_name(boolean_effects[i]));
+      ret = FALSE;
+    }
+  }
+
+  return ret;
+}
+
 /**************************************************************************
   Some more sanity checking once all rulesets are loaded. These check
   for some cross-referencing which was impossible to do while only one
@@ -598,6 +650,10 @@
     ok = FALSE;
   }
 
+  if (!sanity_check_boolean_effects()) {
+    ok = FALSE;
+  }
+
   /* Others use requirement vectors */
 
   /* Disasters */


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

Reply via email to