Author: sveinung
Date: Tue Apr 18 07:24:45 2017
New Revision: 35259

URL: http://svn.gna.org/viewcvs/freeciv?rev=35259&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:
    branches/S3_0/common/requirements.c
    branches/S3_0/common/requirements.h

Modified: branches/S3_0/common/requirements.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/common/requirements.c?rev=35259&r1=35258&r2=35259&view=diff
==============================================================================
--- branches/S3_0/common/requirements.c (original)
+++ branches/S3_0/common/requirements.c Tue Apr 18 07:24:45 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: branches/S3_0/common/requirements.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/common/requirements.h?rev=35259&r1=35258&r2=35259&view=diff
==============================================================================
--- branches/S3_0/common/requirements.h (original)
+++ branches/S3_0/common/requirements.h Tue Apr 18 07:24:45 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