Author: sveinung
Date: Fri Aug 21 12:26:12 2015
New Revision: 29622

URL: http://svn.gna.org/viewcvs/freeciv?rev=29622&view=rev
Log:
A local DiplRel requirement belongs in actor_reqs

Don't allow a ruleset to break the assumptions made about where a local
DiplRel is located. Be strict from the introduction of action enablers.

See patch #6262

Modified:
    trunk/doc/README.actions
    trunk/server/rssanity.c

Modified: trunk/doc/README.actions
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/doc/README.actions?rev=29622&r1=29621&r2=29622&view=diff
==============================================================================
--- trunk/doc/README.actions    (original)
+++ trunk/doc/README.actions    Fri Aug 21 12:26:12 2015
@@ -76,6 +76,27 @@
 the target cities civilization (and therefore knowledge about its techs) can
 be added.
 
+Requirement vector rules
+========================
+An action enabler has two requirement vectors that must be true at the same
+time. This creates some corner cases you won't find with single requirement
+vectors. The rules below tries to deal with them.
+
+A "DiplRel" requirement with the range "Local" should always be put in the
+actor requirements.
+ * A local DiplRel requirement can always be expressed as an actor
+   requirement.
+ * Only having to care about local DiplRel requirements in the actor
+   requirements allows the Freeciv code responsible for reasoning about
+   action enablers to be simpler and faster.
+ * If player A having a diplomatic relationship to player B implies that
+   player B has the same relationship to player A the relationship is
+   symmetric. Examples: "Is foreign" and "War"
+ * Symmetric local DiplReal requirements can be moved directly from the
+   target requirement vector to the actor requirement vector.
+ * Asymmetric local DiplReal requirements must test for the same thing in
+   the opposite direction. Example: "Hosts embassy" -> "Has embassy"
+
 Actions and Lua
 ===============
 Right before an action is executed, but after it is known to be legal, a

Modified: trunk/server/rssanity.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/rssanity.c?rev=29622&r1=29621&r2=29622&view=diff
==============================================================================
--- trunk/server/rssanity.c     (original)
+++ trunk/server/rssanity.c     Fri Aug 21 12:26:12 2015
@@ -811,6 +811,23 @@
                       "requirements!", action_get_rule_name(act));
         ok = FALSE;
       }
+
+      requirement_vector_iterate(&(enabler->target_reqs), preq) {
+        if (preq->source.kind == VUT_DIPLREL
+            && preq->range == REQ_RANGE_LOCAL) {
+          /* A Local DiplRel requirement can be expressed as a requirement
+           * in actor_reqs. Demand that it is there. This avoids breaking
+           * code that reasons about actions. */
+          ruleset_error(LOG_ERROR,
+                        "Action enabler for %s has a local DiplRel "
+                        "requirement %s in target_reqs! Please read the "
+                        "section \"Requirement vector rules\" in "
+                        "doc/README.actions",
+                        action_get_rule_name(act),
+                        req_to_fstring(preq));
+          ok = FALSE;
+        }
+      } requirement_vector_iterate_end;
     } action_enabler_list_iterate_end;
   } action_iterate_end;
 


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

Reply via email to