Author: sveinung Date: Wed Jan 27 15:14:15 2016 New Revision: 31633 URL: http://svn.gna.org/viewcvs/freeciv?rev=31633&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: trunk/common/unittype.h trunk/data/alien/units.ruleset trunk/data/civ1/units.ruleset trunk/data/civ2/units.ruleset trunk/data/civ2civ3/units.ruleset trunk/data/classic/units.ruleset trunk/data/experimental/units.ruleset trunk/data/multiplayer/units.ruleset trunk/data/sandbox/units.ruleset trunk/data/stub/units.ruleset trunk/server/rssanity.c Modified: trunk/common/unittype.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/unittype.h?rev=31633&r1=31632&r2=31633&view=diff ============================================================================== --- trunk/common/unittype.h (original) +++ trunk/common/unittype.h Wed Jan 27 15:14:15 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: trunk/data/alien/units.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/alien/units.ruleset?rev=31633&r1=31632&r2=31633&view=diff ============================================================================== --- trunk/data/alien/units.ruleset (original) +++ trunk/data/alien/units.ruleset Wed Jan 27 15:14:15 2016 @@ -334,7 +334,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: trunk/data/civ1/units.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/civ1/units.ruleset?rev=31633&r1=31632&r2=31633&view=diff ============================================================================== --- trunk/data/civ1/units.ruleset (original) +++ trunk/data/civ1/units.ruleset Wed Jan 27 15:14:15 2016 @@ -250,7 +250,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: trunk/data/civ2/units.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2/units.ruleset?rev=31633&r1=31632&r2=31633&view=diff ============================================================================== --- trunk/data/civ2/units.ruleset (original) +++ trunk/data/civ2/units.ruleset Wed Jan 27 15:14:15 2016 @@ -262,7 +262,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: trunk/data/civ2civ3/units.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2civ3/units.ruleset?rev=31633&r1=31632&r2=31633&view=diff ============================================================================== --- trunk/data/civ2civ3/units.ruleset (original) +++ trunk/data/civ2civ3/units.ruleset Wed Jan 27 15:14:15 2016 @@ -374,7 +374,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: trunk/data/classic/units.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/classic/units.ruleset?rev=31633&r1=31632&r2=31633&view=diff ============================================================================== --- trunk/data/classic/units.ruleset (original) +++ trunk/data/classic/units.ruleset Wed Jan 27 15:14:15 2016 @@ -348,7 +348,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: trunk/data/experimental/units.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/experimental/units.ruleset?rev=31633&r1=31632&r2=31633&view=diff ============================================================================== --- trunk/data/experimental/units.ruleset (original) +++ trunk/data/experimental/units.ruleset Wed Jan 27 15:14:15 2016 @@ -362,7 +362,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: trunk/data/multiplayer/units.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/multiplayer/units.ruleset?rev=31633&r1=31632&r2=31633&view=diff ============================================================================== --- trunk/data/multiplayer/units.ruleset (original) +++ trunk/data/multiplayer/units.ruleset Wed Jan 27 15:14:15 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: trunk/data/sandbox/units.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/sandbox/units.ruleset?rev=31633&r1=31632&r2=31633&view=diff ============================================================================== --- trunk/data/sandbox/units.ruleset (original) +++ trunk/data/sandbox/units.ruleset Wed Jan 27 15:14:15 2016 @@ -375,7 +375,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: trunk/data/stub/units.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/stub/units.ruleset?rev=31633&r1=31632&r2=31633&view=diff ============================================================================== --- trunk/data/stub/units.ruleset (original) +++ trunk/data/stub/units.ruleset Wed Jan 27 15:14:15 2016 @@ -266,7 +266,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: trunk/server/rssanity.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/rssanity.c?rev=31633&r1=31632&r2=31633&view=diff ============================================================================== --- trunk/server/rssanity.c (original) +++ trunk/server/rssanity.c Wed Jan 27 15:14:15 2016 @@ -738,6 +738,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 Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits