Author: sveinung
Date: Sun Mar 12 13:33:37 2017
New Revision: 35103

URL: http://svn.gna.org/viewcvs/freeciv?rev=35103&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/S2_6/common/actions.c
    branches/S2_6/common/metaknowledge.c
    branches/S2_6/common/metaknowledge.h
    branches/S2_6/utility/shared.c
    branches/S2_6/utility/shared.h

Modified: branches/S2_6/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/actions.c?rev=35103&r1=35102&r2=35103&view=diff
==============================================================================
--- branches/S2_6/common/actions.c      (original)
+++ branches/S2_6/common/actions.c      Sun Mar 12 13:33:37 2017
@@ -984,18 +984,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) {
@@ -1286,16 +1288,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/S2_6/common/metaknowledge.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/metaknowledge.c?rev=35103&r1=35102&r2=35103&view=diff
==============================================================================
--- branches/S2_6/common/metaknowledge.c        (original)
+++ branches/S2_6/common/metaknowledge.c        Sun Mar 12 13:33:37 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/S2_6/common/metaknowledge.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/metaknowledge.h?rev=35103&r1=35102&r2=35103&view=diff
==============================================================================
--- branches/S2_6/common/metaknowledge.h        (original)
+++ branches/S2_6/common/metaknowledge.h        Sun Mar 12 13:33:37 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/S2_6/utility/shared.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/utility/shared.c?rev=35103&r1=35102&r2=35103&view=diff
==============================================================================
--- branches/S2_6/utility/shared.c      (original)
+++ branches/S2_6/utility/shared.c      Sun Mar 12 13:33:37 2017
@@ -116,6 +116,22 @@
 static int compare_file_mtime_ptrs(const struct fileinfo *const *ppa,
                                    const struct fileinfo *const *ppb);
 
+
+/***************************************************************************
+  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;
+}
 
 /***************************************************************
   Take a string containing multiple lines and create a copy where

Modified: branches/S2_6/utility/shared.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/utility/shared.h?rev=35103&r1=35102&r2=35103&view=diff
==============================================================================
--- branches/S2_6/utility/shared.h      (original)
+++ branches/S2_6/utility/shared.h      Sun Mar 12 13:33:37 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