Author: sveinung
Date: Wed Jan 27 15:17:45 2016
New Revision: 31634
URL: http://svn.gna.org/viewcvs/freeciv?rev=31634&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 check that paratroopers_range is in range. Document the
maximum value in ruleset comments.
See patch #6833
Modified:
branches/S2_6/common/unittype.h
branches/S2_6/data/alien/units.ruleset
branches/S2_6/data/civ1/units.ruleset
branches/S2_6/data/civ2/units.ruleset
branches/S2_6/data/civ2civ3/units.ruleset
branches/S2_6/data/classic/units.ruleset
branches/S2_6/data/experimental/units.ruleset
branches/S2_6/data/multiplayer/units.ruleset
branches/S2_6/data/stub/units.ruleset
branches/S2_6/server/rssanity.c
Modified: branches/S2_6/common/unittype.h
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/unittype.h?rev=31634&r1=31633&r2=31634&view=diff
==============================================================================
--- branches/S2_6/common/unittype.h (original)
+++ branches/S2_6/common/unittype.h Wed Jan 27 15:17:45 2016
@@ -36,6 +36,12 @@
* to hold full number of unit types.
* Used in the network protocol. */
#define U_LAST MAX_NUM_ITEMS
+
+/* 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. */
#define SPECENUM_NAME unit_class_flag_id
Modified: branches/S2_6/data/alien/units.ruleset
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/alien/units.ruleset?rev=31634&r1=31633&r2=31634&view=diff
==============================================================================
--- branches/S2_6/data/alien/units.ruleset (original)
+++ branches/S2_6/data/alien/units.ruleset Wed Jan 27 15:17:45 2016
@@ -326,7 +326,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_6/data/civ1/units.ruleset
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/civ1/units.ruleset?rev=31634&r1=31633&r2=31634&view=diff
==============================================================================
--- branches/S2_6/data/civ1/units.ruleset (original)
+++ branches/S2_6/data/civ1/units.ruleset Wed Jan 27 15:17:45 2016
@@ -245,7 +245,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_6/data/civ2/units.ruleset
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/civ2/units.ruleset?rev=31634&r1=31633&r2=31634&view=diff
==============================================================================
--- branches/S2_6/data/civ2/units.ruleset (original)
+++ branches/S2_6/data/civ2/units.ruleset Wed Jan 27 15:17:45 2016
@@ -257,7 +257,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_6/data/civ2civ3/units.ruleset
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/civ2civ3/units.ruleset?rev=31634&r1=31633&r2=31634&view=diff
==============================================================================
--- branches/S2_6/data/civ2civ3/units.ruleset (original)
+++ branches/S2_6/data/civ2civ3/units.ruleset Wed Jan 27 15:17:45 2016
@@ -365,7 +365,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_6/data/classic/units.ruleset
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/classic/units.ruleset?rev=31634&r1=31633&r2=31634&view=diff
==============================================================================
--- branches/S2_6/data/classic/units.ruleset (original)
+++ branches/S2_6/data/classic/units.ruleset Wed Jan 27 15:17:45 2016
@@ -342,7 +342,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_6/data/experimental/units.ruleset
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/experimental/units.ruleset?rev=31634&r1=31633&r2=31634&view=diff
==============================================================================
--- branches/S2_6/data/experimental/units.ruleset (original)
+++ branches/S2_6/data/experimental/units.ruleset Wed Jan 27 15:17:45 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_6/data/multiplayer/units.ruleset
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/multiplayer/units.ruleset?rev=31634&r1=31633&r2=31634&view=diff
==============================================================================
--- branches/S2_6/data/multiplayer/units.ruleset (original)
+++ branches/S2_6/data/multiplayer/units.ruleset Wed Jan 27 15:17:45 2016
@@ -341,7 +341,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_6/data/stub/units.ruleset
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/stub/units.ruleset?rev=31634&r1=31633&r2=31634&view=diff
==============================================================================
--- branches/S2_6/data/stub/units.ruleset (original)
+++ branches/S2_6/data/stub/units.ruleset Wed Jan 27 15:17:45 2016
@@ -264,7 +264,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_6/server/rssanity.c
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/rssanity.c?rev=31634&r1=31633&r2=31634&view=diff
==============================================================================
--- branches/S2_6/server/rssanity.c (original)
+++ branches/S2_6/server/rssanity.c Wed Jan 27 15:17:45 2016
@@ -702,6 +702,20 @@
}
} 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);
+ ok = FALSE;
+ }
+ } unit_type_iterate_end;
+
/* Check requirement sets against conflicting requirements.
* Effects use requirement lists */
if (!iterate_effect_cache(effect_list_sanity_cb, NULL)) {
_______________________________________________
Freeciv-commits mailing list
[email protected]
https://mail.gna.org/listinfo/freeciv-commits