Author: sveinung
Date: Fri Sep 23 11:04:49 2016
New Revision: 33862

URL: http://svn.gna.org/viewcvs/freeciv?rev=33862&view=rev
Log:
universal_fulfills_requirement: support nations.

See patch #7716

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=33862&r1=33861&r2=33862&view=diff
==============================================================================
--- trunk/common/requirements.c (original)
+++ trunk/common/requirements.c Fri Sep 23 11:04:49 2016
@@ -3617,6 +3617,29 @@
 }
 
 /*************************************************************************
+  Find if a nation fulfills a requirement
+**************************************************************************/
+static enum item_found nation_found(const struct requirement *preq,
+                                    const struct universal *source)
+{
+  fc_assert(source->value.nation);
+
+  switch (preq->source.kind) {
+  case VUT_NATION:
+    return preq->source.value.nation == source->value.nation ? ITF_YES
+                                                             : ITF_NO;
+  case VUT_NATIONGROUP:
+    return nation_is_in_group(source->value.nation,
+                              preq->source.value.nationgroup) ? ITF_YES
+                                                              : ITF_NO;
+  default:
+    break;
+  }
+
+  return ITF_NOT_APPLICABLE;
+}
+
+/*************************************************************************
   Find if a government fulfills a requirement
 **************************************************************************/
 static enum item_found government_found(const struct requirement *preq,
@@ -3742,6 +3765,7 @@
 void universal_found_functions_init(void)
 {
   universal_found_function[VUT_GOVERNMENT] = &government_found;
+  universal_found_function[VUT_NATION] = &nation_found;
   universal_found_function[VUT_IMPROVEMENT] = &improvement_found;
   universal_found_function[VUT_UCLASS] = &unit_class_found;
   universal_found_function[VUT_UTYPE] = &unit_type_found;

Modified: trunk/common/requirements.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/requirements.h?rev=33862&r1=33861&r2=33862&view=diff
==============================================================================
--- trunk/common/requirements.h (original)
+++ trunk/common/requirements.h Fri Sep 23 11:04:49 2016
@@ -179,6 +179,9 @@
 #define requirement_fulfilled_by_government(_gov_, _rqs_)                  \
   universal_fulfills_requirement(FALSE, (_rqs_),                           \
       &(struct universal){.kind = VUT_GOVERNMENT, .value = {.govern = 
(_gov_)}})
+#define requirement_fulfilled_by_nation(_nat_, _rqs_)                      \
+  universal_fulfills_requirement(FALSE, (_rqs_),                           \
+      &(struct universal){.kind = VUT_NATION, .value = {.nation = (_nat_)}})
 #define requirement_fulfilled_by_improvement(_imp_, _rqs_)                 \
   universal_fulfills_requirement(FALSE, (_rqs_),                           \
     &(struct universal){.kind = VUT_IMPROVEMENT,                           \


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

Reply via email to