Author: sveinung Date: Fri Sep 23 11:04:27 2016 New Revision: 33861 URL: http://svn.gna.org/viewcvs/freeciv?rev=33861&view=rev Log: Freeciv-web: ruleset action distance compat.
An unlimited max action distance is stored as the text "unlimited". The largest non unlimited max distance an action can have is stored as a number. The max size of that number was MAP_DISTANCE_MAX. MAP_DISTANCE_MAX is the largest possible distance between two tiles. But that value is, because of different max map sizes, smaller in Freeciv-web than in regular Freeciv. This made it possible to create a ruleset that would be rejected in Freeciv-web because of a too larger action max distance. Define the action distance numbers without a direct reference to MAP_DISTANCE_MAX. Add a static assertion to make sure that MAP_DISTANCE_MAX still can be as a regular distance. This makes Freeciv and Freeciv-web rulesets compatible (when it comes to action distance). See patch #7715 Modified: trunk/common/actions.c trunk/common/actions.h trunk/server/rssanity.c Modified: trunk/common/actions.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.c?rev=33861&r1=33860&r2=33861&view=diff ============================================================================== --- trunk/common/actions.c (original) +++ trunk/common/actions.c Fri Sep 23 11:04:27 2016 @@ -87,6 +87,10 @@ action_prob_not_relevant(const struct act_prob probability); static inline bool action_prob_not_impl(const struct act_prob probability); + +/* Make sure that an action distance can target the whole map. */ +FC_STATIC_ASSERT(MAP_DISTANCE_MAX <= ACTION_DISTANCE_LAST_NON_SIGNAL, + action_range_can_not_cover_the_whole_map); /************************************************************************** Initialize the actions and the action enablers. Modified: trunk/common/actions.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.h?rev=33861&r1=33860&r2=33861&view=diff ============================================================================== --- trunk/common/actions.h (original) +++ trunk/common/actions.h Fri Sep 23 11:04:27 2016 @@ -131,8 +131,16 @@ #define SPECENUM_COUNT ACT_REQ_COUNT #include "specenum_gen.h" +/* The last action distance value that is interpreted as an actual + * distance rather than as a signal value. + * + * It is specified literally rather than referring to MAP_DISTANCE_MAX + * because Freeciv-web's MAP_DISTANCE_MAX differs from the regular Freeciv + * server's MAP_DISTANCE_MAX. A static assertion in actions.c makes sure + * that it can cover the whole map. */ +#define ACTION_DISTANCE_LAST_NON_SIGNAL 128016 /* No action max distance to target limit. */ -#define ACTION_DISTANCE_UNLIMITED (MAP_DISTANCE_MAX + 1) +#define ACTION_DISTANCE_UNLIMITED (ACTION_DISTANCE_LAST_NON_SIGNAL + 1) /* No action max distance can be bigger than this. */ #define ACTION_DISTANCE_MAX ACTION_DISTANCE_UNLIMITED Modified: trunk/server/rssanity.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/rssanity.c?rev=33861&r1=33860&r2=33861&view=diff ============================================================================== --- trunk/server/rssanity.c (original) +++ trunk/server/rssanity.c Fri Sep 23 11:04:27 2016 @@ -908,11 +908,11 @@ ok = FALSE; } - if (paction->min_distance > MAP_DISTANCE_MAX) { + if (paction->min_distance > ACTION_DISTANCE_LAST_NON_SIGNAL) { ruleset_error(LOG_ERROR, "Action %s: min distance (%d) larger than " "any distance on a map can be (%d).", action_get_rule_name(act), paction->min_distance, - MAP_DISTANCE_MAX); + ACTION_DISTANCE_LAST_NON_SIGNAL); ok = FALSE; } _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits