Author: sveinung
Date: Tue Apr 18 07:16:51 2017
New Revision: 35255

URL: http://svn.gna.org/viewcvs/freeciv?rev=35255&view=rev
Log:
Universal is relevant to a requirement checker.

Introduce universal_is_relevant_to_requirement(). It uses the requirements
module's universal_found functions to see if a universal is relevant to a
requirement.

See hrm Feature #651673

Modified:
    trunk/common/requirements.c
    trunk/common/requirements.h

Modified: trunk/common/requirements.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/requirements.c?rev=35255&r1=35254&r2=35255&view=diff
==============================================================================
--- trunk/common/requirements.c (original)
+++ trunk/common/requirements.c Tue Apr 18 07:16:51 2017
@@ -3740,6 +3740,27 @@
 }
 
 /*************************************************************************
+  Returns TRUE iff the specified universal is relevant to fulfilling the
+  specified requirement.
+**************************************************************************/
+bool universal_is_relevant_to_requirement(const struct requirement *req,
+                                          const struct universal *source)
+{
+  fc_assert(universal_found_function[source->kind]);
+
+  switch ((*universal_found_function[source->kind])(req, source)) {
+  case ITF_NOT_APPLICABLE:
+    return FALSE;
+  case ITF_NO:
+  case ITF_YES:
+    return TRUE;
+  }
+
+  log_error("Unhandled item_found value");
+  return FALSE;
+}
+
+/*************************************************************************
   Find if a nation fulfills a requirement
 **************************************************************************/
 static enum item_found nation_found(const struct requirement *preq,

Modified: trunk/common/requirements.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/requirements.h?rev=35255&r1=35254&r2=35255&view=diff
==============================================================================
--- trunk/common/requirements.h (original)
+++ trunk/common/requirements.h Tue Apr 18 07:16:51 2017
@@ -165,6 +165,8 @@
 bool universal_fulfills_requirement(bool check_necessary,
                                     const struct requirement_vector *reqs,
                                     const struct universal *source);
+bool universal_is_relevant_to_requirement(const struct requirement *req,
+                                          const struct universal *source);
 
 #define universals_iterate(_univ_) \
   {                                \


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

Reply via email to