Author: sveinung
Date: Sun Aug 21 11:57:25 2016
New Revision: 33663

URL: http://svn.gna.org/viewcvs/freeciv?rev=33663&view=rev
Log:
Fix airlifting over huge distances legality.

Airlifting from any city to any city should be allowed according to the old
rules. When "Airlift Unit" became action enabler controlled it got
MAP_MAX_LINEAR_SIZE as its maximum distance. It was assumed to cover the
whole map. The assumption was wrong. A map can be non wrapping. It can also
forbid some diagonal movement.

See bug #24997

Modified:
    trunk/common/actions.c
    trunk/common/map.h
    trunk/server/rssanity.c

Modified: trunk/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.c?rev=33663&r1=33662&r2=33663&view=diff
==============================================================================
--- trunk/common/actions.c      (original)
+++ trunk/common/actions.c      Sun Aug 21 11:57:25 2016
@@ -231,7 +231,7 @@
   actions[ACTION_AIRLIFT] =
       action_new(ACTION_AIRLIFT, ATK_CITY,
                  FALSE, FALSE, TRUE,
-                 1, MAP_MAX_LINEAR_SIZE);
+                 1, MAP_DISTANCE_MAX);
   actions[ACTION_ATTACK] =
       action_new(ACTION_ATTACK,
                  /* FIXME: Target is actually City and, depending on the

Modified: trunk/common/map.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/map.h?rev=33663&r1=33662&r2=33663&view=diff
==============================================================================
--- trunk/common/map.h  (original)
+++ trunk/common/map.h  Sun Aug 21 11:57:25 2016
@@ -591,6 +591,11 @@
 #define MAP_MAX_LINEAR_SIZE      (MAP_MAX_SIZE * 1000 / MAP_MIN_LINEAR_SIZE)
 #define MAP_MIN_LINEAR_SIZE      16
 
+/* The distance between two points at a map shouldn't be larger than this.
+Adds MAP_MIN_LINEAR_SIZE because hex topologies forbids certain diagonal
+moves. Includes MAP_MAX_LINEAR_SIZE because a map can be non wrapping. */
+#define MAP_DISTANCE_MAX (MAP_MAX_LINEAR_SIZE + MAP_MIN_LINEAR_SIZE)
+
 #define MAP_ORIGINAL_TOPO        TF_WRAPX
 #ifdef FREECIV_WEB
 /* Freeciv-web doesn't support isometric maps yet. */

Modified: trunk/server/rssanity.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/rssanity.c?rev=33663&r1=33662&r2=33663&view=diff
==============================================================================
--- trunk/server/rssanity.c     (original)
+++ trunk/server/rssanity.c     Sun Aug 21 11:57:25 2016
@@ -908,7 +908,7 @@
       ok = FALSE;
     }
 
-    if (paction->max_distance > MAP_MAX_LINEAR_SIZE) {
+    if (paction->max_distance > MAP_DISTANCE_MAX) {
       ruleset_error(LOG_ERROR, "Action %s: max distance is %d. "
                     "A map can't be that big.",
                     action_get_rule_name(act), paction->max_distance);


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

Reply via email to