Author: sveinung
Date: Wed Jan 27 15:20:12 2016
New Revision: 31635

URL: http://svn.gna.org/viewcvs/freeciv?rev=31635&view=rev
Log:
Max paratroopers_range is 255.

The network protocol transfers paratroopers_range in an UINT8. This limits
its value to 255.

Add a sanity warning that paratroopers_range is in range. Document the
maximum value in ruleset comments.

See patch #6833

Modified:
    branches/S2_5/common/unittype.h
    branches/S2_5/data/alien/units.ruleset
    branches/S2_5/data/civ1/units.ruleset
    branches/S2_5/data/civ2/units.ruleset
    branches/S2_5/data/civ2civ3/units.ruleset
    branches/S2_5/data/classic/units.ruleset
    branches/S2_5/data/experimental/units.ruleset
    branches/S2_5/data/multiplayer/units.ruleset
    branches/S2_5/server/rssanity.c

Modified: branches/S2_5/common/unittype.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/common/unittype.h?rev=31635&r1=31634&r2=31635&view=diff
==============================================================================
--- branches/S2_5/common/unittype.h     (original)
+++ branches/S2_5/common/unittype.h     Wed Jan 27 15:20:12 2016
@@ -79,6 +79,12 @@
 /* keep this last */
 #define SPECENUM_COUNT UCF_COUNT
 #include "specenum_gen.h"
+
+/* The largest distance a ruleset can allow a unit to paradrop.
+ * Remember to make sure that the field type of PACKET_RULESET_UNIT's
+ * paratroopers_range field can transfer the new maximum if you increase
+ * it. */
+#define UNIT_MAX_PARADROP_RANGE 255
 
 /* Used in the network protocol. */
 BV_DEFINE(bv_unit_classes, UCL_LAST);

Modified: branches/S2_5/data/alien/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/data/alien/units.ruleset?rev=31635&r1=31634&r2=31635&view=diff
==============================================================================
--- branches/S2_5/data/alien/units.ruleset      (original)
+++ branches/S2_5/data/alien/units.ruleset      Wed Jan 27 15:20:12 2016
@@ -315,7 +315,8 @@
 ;
 ; Following flag strings require extra fields:
 ;  "Paratroopers"
-;   paratroopers_range = the maximal range the unit can be paradropped to
+;   paratroopers_range  = the maximal range the unit can be paradropped to.
+;                         Max range is 255.
 ;   paratroopers_mr_req = the move rate which is required at least for
 ;                         paradropping (whole movement points)
 ;   paratroopers_mr_sub = the move rate which is subtracted after paradropping

Modified: branches/S2_5/data/civ1/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/data/civ1/units.ruleset?rev=31635&r1=31634&r2=31635&view=diff
==============================================================================
--- branches/S2_5/data/civ1/units.ruleset       (original)
+++ branches/S2_5/data/civ1/units.ruleset       Wed Jan 27 15:20:12 2016
@@ -239,7 +239,8 @@
 ;
 ; Following flag strings require extra fields:  (but do not appear in Civ1)
 ;  "Paratroopers"
-;   paratroopers_range = the maximal range the unit can be paradropped to
+;   paratroopers_range  = the maximal range the unit can be paradropped to.
+;                         Max range is 255.
 ;   paratroopers_mr_req = the move rate which is required at least for
 ;                         paradropping (whole movement points)
 ;   paratroopers_mr_sub = the move rate which is subtracted after paradropping

Modified: branches/S2_5/data/civ2/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/data/civ2/units.ruleset?rev=31635&r1=31634&r2=31635&view=diff
==============================================================================
--- branches/S2_5/data/civ2/units.ruleset       (original)
+++ branches/S2_5/data/civ2/units.ruleset       Wed Jan 27 15:20:12 2016
@@ -252,7 +252,8 @@
 ;
 ; Following flag strings require extra fields:
 ;  "Paratroopers"
-;   paratroopers_range = the maximal range the unit can be paradropped to
+;   paratroopers_range  = the maximal range the unit can be paradropped to.
+;                         Max range is 255.
 ;   paratroopers_mr_req = the move rate which is required at least for
 ;                         paradropping (whole movement points)
 ;   paratroopers_mr_sub = the move rate which is subtracted after paradropping

Modified: branches/S2_5/data/civ2civ3/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/data/civ2civ3/units.ruleset?rev=31635&r1=31634&r2=31635&view=diff
==============================================================================
--- branches/S2_5/data/civ2civ3/units.ruleset   (original)
+++ branches/S2_5/data/civ2civ3/units.ruleset   Wed Jan 27 15:20:12 2016
@@ -356,7 +356,8 @@
 ;
 ; Following flag strings require extra fields:
 ;  "Paratroopers"
-;   paratroopers_range = the maximal range the unit can be paradropped to
+;   paratroopers_range  = the maximal range the unit can be paradropped to.
+;                         Max range is 255.
 ;   paratroopers_mr_req = the move rate which is required at least for
 ;                         paradropping (whole movement points)
 ;   paratroopers_mr_sub = the move rate which is subtracted after paradropping

Modified: branches/S2_5/data/classic/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/data/classic/units.ruleset?rev=31635&r1=31634&r2=31635&view=diff
==============================================================================
--- branches/S2_5/data/classic/units.ruleset    (original)
+++ branches/S2_5/data/classic/units.ruleset    Wed Jan 27 15:20:12 2016
@@ -333,7 +333,8 @@
 ;
 ; Following flag strings require extra fields:
 ;  "Paratroopers"
-;   paratroopers_range = the maximal range the unit can be paradropped to
+;   paratroopers_range  = the maximal range the unit can be paradropped to.
+;                         Max range is 255.
 ;   paratroopers_mr_req = the move rate which is required at least for
 ;                         paradropping (whole movement points)
 ;   paratroopers_mr_sub = the move rate which is subtracted after paradropping

Modified: branches/S2_5/data/experimental/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/data/experimental/units.ruleset?rev=31635&r1=31634&r2=31635&view=diff
==============================================================================
--- branches/S2_5/data/experimental/units.ruleset       (original)
+++ branches/S2_5/data/experimental/units.ruleset       Wed Jan 27 15:20:12 2016
@@ -347,7 +347,8 @@
 ;
 ; Following flag strings require extra fields:
 ;  "Paratroopers"
-;   paratroopers_range = the maximal range the unit can be paradropped to
+;   paratroopers_range  = the maximal range the unit can be paradropped to.
+;                         Max range is 255.
 ;   paratroopers_mr_req = the move rate which is required at least for
 ;                         paradropping (whole movement points)
 ;   paratroopers_mr_sub = the move rate which is subtracted after paradropping

Modified: branches/S2_5/data/multiplayer/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/data/multiplayer/units.ruleset?rev=31635&r1=31634&r2=31635&view=diff
==============================================================================
--- branches/S2_5/data/multiplayer/units.ruleset        (original)
+++ branches/S2_5/data/multiplayer/units.ruleset        Wed Jan 27 15:20:12 2016
@@ -333,7 +333,8 @@
 ;
 ; Following flag strings require extra fields:
 ;  "Paratroopers"
-;   paratroopers_range = the maximal range the unit can be paradropped to
+;   paratroopers_range  = the maximal range the unit can be paradropped to.
+;                         Max range is 255.
 ;   paratroopers_mr_req = the move rate which is required at least for
 ;                         paradropping (whole movement points)
 ;   paratroopers_mr_sub = the move rate which is subtracted after paradropping

Modified: branches/S2_5/server/rssanity.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/rssanity.c?rev=31635&r1=31634&r2=31635&view=diff
==============================================================================
--- branches/S2_5/server/rssanity.c     (original)
+++ branches/S2_5/server/rssanity.c     Wed Jan 27 15:20:12 2016
@@ -631,6 +631,19 @@
     }
   } unit_type_iterate_end;
 
+  /* Check that unit type fields are in range. */
+  unit_type_iterate(putype) {
+    if (putype->paratroopers_range < 0
+        || putype->paratroopers_range > UNIT_MAX_PARADROP_RANGE) {
+      /* Paradrop range is limited by the network protocol. */
+      ruleset_error(LOG_ERROR,
+                    "The paratroopers_range of the unit type '%s' is %d. "
+                    "That is out of range. Max range is %d.",
+                    utype_rule_name(putype),
+                    putype->paratroopers_range, UNIT_MAX_PARADROP_RANGE);
+    }
+  } unit_type_iterate_end;
+
   /* Check requirement sets against conflicting requirements.
    * Effects use requirement lists */
   if (!iterate_effect_cache(effect_list_sanity_cb)) {


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

Reply via email to