Author: sveinung
Date: Sun Mar 12 13:30:49 2017
New Revision: 35101

URL: http://svn.gna.org/viewcvs/freeciv?rev=35101&view=rev
Log:
Define tristate "and" near tristate.

Rename the function tri_and() to fc_tristate_and() and define it where the
enum fc_tristate is defined.

See hrm Feature #644166

Modified:
    branches/S3_0/common/actions.c
    branches/S3_0/common/metaknowledge.c
    branches/S3_0/common/metaknowledge.h
    branches/S3_0/utility/shared.c
    branches/S3_0/utility/shared.h

Modified: branches/S3_0/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/common/actions.c?rev=35101&r1=35100&r2=35101&view=diff
==============================================================================
--- branches/S3_0/common/actions.c      (original)
+++ branches/S3_0/common/actions.c      Sun Mar 12 13:30:49 2017
@@ -2559,18 +2559,20 @@
   result = TRI_NO;
   action_enabler_list_iterate(action_enablers_for_action(wanted_action),
                               enabler) {
-    current = tri_and(mke_eval_reqs(actor_player, actor_player,
-                                    target_player, actor_city,
-                                    actor_building, actor_tile,
-                                    actor_unit, actor_output,
-                                    actor_specialist,
-                                    &enabler->actor_reqs, RPT_CERTAIN),
-                      mke_eval_reqs(actor_player, target_player,
-                                    actor_player, target_city,
-                                    target_building, target_tile,
-                                    target_unit, target_output,
-                                    target_specialist,
-                                    &enabler->target_reqs, RPT_CERTAIN));
+    current = fc_tristate_and(mke_eval_reqs(actor_player, actor_player,
+                                            target_player, actor_city,
+                                            actor_building, actor_tile,
+                                            actor_unit, actor_output,
+                                            actor_specialist,
+                                            &enabler->actor_reqs,
+                                            RPT_CERTAIN),
+                              mke_eval_reqs(actor_player, target_player,
+                                            actor_player, target_city,
+                                            target_building, target_tile,
+                                            target_unit, target_output,
+                                            target_specialist,
+                                            &enabler->target_reqs,
+                                            RPT_CERTAIN));
     if (current == TRI_YES) {
       return TRI_YES;
     } else if (current == TRI_MAYBE) {
@@ -2842,16 +2844,18 @@
 
   chance = ACTPROB_NOT_IMPLEMENTED;
 
-  known = tri_and(known,
-                  action_enabled_local(wanted_action,
-                                       actor_player, actor_city,
-                                       actor_building, actor_tile,
-                                       actor_unit,
-                                       actor_output, actor_specialist,
-                                       target_player, target_city,
-                                       target_building, target_tile,
-                                       target_unit,
-                                       target_output, target_specialist));
+  known = fc_tristate_and(known,
+                          action_enabled_local(wanted_action,
+                                               actor_player, actor_city,
+                                               actor_building, actor_tile,
+                                               actor_unit,
+                                               actor_output,
+                                               actor_specialist,
+                                               target_player, target_city,
+                                               target_building, target_tile,
+                                               target_unit,
+                                               target_output,
+                                               target_specialist));
 
   switch (wanted_action) {
   case ACTION_SPY_POISON:
@@ -2885,16 +2889,18 @@
     break;
   case ACTION_SPY_STEAL_TECH:
     /* Do the victim have anything worth taking? */
-    known = tri_and(known,
-                    tech_can_be_stolen(actor_player, target_player));
+    known = fc_tristate_and(known,
+                            tech_can_be_stolen(actor_player,
+                                               target_player));
 
     /* TODO: Calculate actual chance */
 
     break;
   case ACTION_SPY_TARGETED_STEAL_TECH:
     /* Do the victim have anything worth taking? */
-    known = tri_and(known,
-                    tech_can_be_stolen(actor_player, target_player));
+    known = fc_tristate_and(known,
+                            tech_can_be_stolen(actor_player,
+                                               target_player));
 
     /* TODO: Calculate actual chance */
 

Modified: branches/S3_0/common/metaknowledge.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/common/metaknowledge.c?rev=35101&r1=35100&r2=35101&view=diff
==============================================================================
--- branches/S3_0/common/metaknowledge.c        (original)
+++ branches/S3_0/common/metaknowledge.c        Sun Mar 12 13:30:49 2017
@@ -22,23 +22,6 @@
 #include "metaknowledge.h"
 #include "tile.h"
 #include "traderoutes.h"
-
-/**************************************************************************
-  An AND function for fc_tristate.
-**************************************************************************/
-enum fc_tristate tri_and(enum fc_tristate one,
-                         enum fc_tristate two)
-{
-  if (TRI_NO == one || TRI_NO == two) {
-    return TRI_NO;
-  }
-
-  if (TRI_MAYBE == one || TRI_MAYBE == two) {
-    return TRI_MAYBE;
-  }
-
-  return TRI_YES;
-}
 
 /**************************************************************************
   Returns TRUE iff the target_tile it self and all tiles cardinally

Modified: branches/S3_0/common/metaknowledge.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/common/metaknowledge.h?rev=35101&r1=35100&r2=35101&view=diff
==============================================================================
--- branches/S3_0/common/metaknowledge.h        (original)
+++ branches/S3_0/common/metaknowledge.h        Sun Mar 12 13:30:49 2017
@@ -20,9 +20,6 @@
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
-
-enum fc_tristate tri_and(enum fc_tristate one,
-                         enum fc_tristate two);
 
 enum fc_tristate
 mke_eval_req(const struct player *pow_player,

Modified: branches/S3_0/utility/shared.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/utility/shared.c?rev=35101&r1=35100&r2=35101&view=diff
==============================================================================
--- branches/S3_0/utility/shared.c      (original)
+++ branches/S3_0/utility/shared.c      Sun Mar 12 13:30:49 2017
@@ -117,6 +117,22 @@
                                    const struct fileinfo *const *ppb);
 
 static char *expand_dir(char *tok_in, bool ok_to_free);
+
+/***************************************************************************
+  An AND function for fc_tristate.
+***************************************************************************/
+enum fc_tristate fc_tristate_and(enum fc_tristate one, enum fc_tristate two)
+{
+  if (TRI_NO == one || TRI_NO == two) {
+    return TRI_NO;
+  }
+
+  if (TRI_MAYBE == one || TRI_MAYBE == two) {
+    return TRI_MAYBE;
+  }
+
+  return TRI_YES;
+}
 
 /***************************************************************
   Returns a statically allocated string containing a nicely-formatted

Modified: branches/S3_0/utility/shared.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/utility/shared.h?rev=35101&r1=35100&r2=35101&view=diff
==============================================================================
--- branches/S3_0/utility/shared.h      (original)
+++ branches/S3_0/utility/shared.h      Sun Mar 12 13:30:49 2017
@@ -45,6 +45,9 @@
 
 enum fc_tristate { TRI_NO, TRI_YES, TRI_MAYBE };
 #define BOOL_TO_TRISTATE(tri) ((tri) ? TRI_YES : TRI_NO)
+
+enum fc_tristate fc_tristate_and(enum fc_tristate one,
+                                 enum fc_tristate two);
 
 #ifndef MAX
 #define MAX(x,y) (((x)>(y))?(x):(y))


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

Reply via email to