Author: jtn
Date: Mon Apr  6 10:48:56 2015
New Revision: 28727

URL: http://svn.gna.org/viewcvs/freeciv?rev=28727&view=rev
Log:
Allow effect_cumulative_min/max() to check unit type/class flags.

See gna patch #5981.

Modified:
    branches/S2_5/common/effects.c

Modified: branches/S2_5/common/effects.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/common/effects.c?rev=28727&r1=28726&r2=28727&view=diff
==============================================================================
--- branches/S2_5/common/effects.c      (original)
+++ branches/S2_5/common/effects.c      Mon Apr  6 10:48:56 2015
@@ -294,8 +294,11 @@
 }
 
 /****************************************************************************
-  Get the maximum effect value in this ruleset for the unit type.
-  Universal can be NULL to get overall max
+  Get the maximum effect value in this ruleset for the unit type for_unit
+  (that is, the sum of all positive effects clauses that apply specifically
+  to this type of unit -- this can be an overestimate in the case of
+  mutually exclusive effects).
+  for_unit can be NULL to get max effect value ignoring requirements.
 ****************************************************************************/
 int effect_cumulative_max(enum effect_type type, struct unit_type *for_unit)
 {
@@ -323,8 +326,20 @@
               } else {
                 failed |= (!preq->negated);
               }
+            } else if (preq->source.kind == VUT_UTFLAG) {
+              if (utype_has_flag(for_unit, preq->source.value.unitflag)) {
+                failed |= preq->negated;
+              } else {
+                failed |= (!preq->negated);
+              }
             } else if (preq->source.kind == VUT_UCLASS) {
               if (preq->source.value.uclass == pclass) {
+                failed |= preq->negated;
+              } else {
+                failed |= (!preq->negated);
+              }
+            } else if (preq->source.kind == VUT_UCFLAG) {
+              if (uclass_has_flag(pclass, preq->source.value.unitclassflag)) {
                 failed |= preq->negated;
               } else {
                 failed |= (!preq->negated);
@@ -338,8 +353,20 @@
               } else {
                 failed |= preq->negated;
               }
+            } else if (preq->source.kind == VUT_UTFLAG) {
+              if (utype_has_flag(for_unit, preq->source.value.unitflag)) {
+                failed |= (!preq->negated);
+              } else {
+                failed |= preq->negated;
+              }
             } else if (preq->source.kind == VUT_UCLASS) {
               if (preq->source.value.uclass == pclass) {
+                failed |= (!preq->negated);
+              } else {
+                failed |= preq->negated;
+              }
+            } else if (preq->source.kind == VUT_UCFLAG) {
+              if (uclass_has_flag(pclass, preq->source.value.unitclassflag)) {
                 failed |= (!preq->negated);
               } else {
                 failed |= preq->negated;
@@ -359,8 +386,11 @@
 }
 
 /****************************************************************************
-  Get the minimum effect value in this ruleset for the unit type.
-  Universal can be NULL for the overall minimum
+  Get the minimum effect value in this ruleset for the unit type for_unit
+  (that is, the sum of all negative effects clauses that apply specifically
+  to this type of unit -- this can be an overestimate in the case of
+  mutually exclusive effects).
+  for_unit can be NULL to get min effect value ignoring requirements.
 ****************************************************************************/
 int effect_cumulative_min(enum effect_type type, struct unit_type *for_unit)
 {
@@ -388,8 +418,20 @@
               } else {
                 failed |= (!preq->negated);
               }
+            } else if (preq->source.kind == VUT_UTFLAG) {
+              if (utype_has_flag(for_unit, preq->source.value.unitflag)) {
+                failed |= preq->negated;
+              } else {
+                failed |= (!preq->negated);
+              }
             } else if (preq->source.kind == VUT_UCLASS) {
               if (preq->source.value.uclass == pclass) {
+                failed |= preq->negated;
+              } else {
+                failed |= (!preq->negated);
+              }
+            } else if (preq->source.kind == VUT_UCFLAG) {
+              if (uclass_has_flag(pclass, preq->source.value.unitclassflag)) {
                 failed |= preq->negated;
               } else {
                 failed |= (!preq->negated);
@@ -403,8 +445,20 @@
               } else {
                 failed |= preq->negated;
               }
+            } else if (preq->source.kind == VUT_UTFLAG) {
+              if (utype_has_flag(for_unit, preq->source.value.unitflag)) {
+                failed |= (!preq->negated);
+              } else {
+                failed |= preq->negated;
+              }
             } else if (preq->source.kind == VUT_UCLASS) {
               if (preq->source.value.uclass == pclass) {
+                failed |= (!preq->negated);
+              } else {
+                failed |= preq->negated;
+              }
+            } else if (preq->source.kind == VUT_UCFLAG) {
+              if (uclass_has_flag(pclass, preq->source.value.unitclassflag)) {
                 failed |= (!preq->negated);
               } else {
                 failed |= preq->negated;


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

Reply via email to