Author: sveinung Date: Sun Aug 21 12:11:55 2016 New Revision: 33665 URL: http://svn.gna.org/viewcvs/freeciv?rev=33665&view=rev Log: Support unlimited action max distance.
Allow a ruleset to specify that the entire map is a valid target of an action rather than having to define a max_distance value large enough to cover the biggest possible maps. This way the action will be able to cover the entire map after the next time the map size increases. Unlimited max distance is represented by the string "unlimited" in the ruleset format and by the new special value ACTION_DISTANCE_UNLIMITED internally. See patch #7635 Modified: trunk/common/actions.c trunk/common/actions.h trunk/common/game.h trunk/data/alien/game.ruleset trunk/data/civ1/game.ruleset trunk/data/civ2/game.ruleset trunk/data/civ2civ3/game.ruleset trunk/data/classic/game.ruleset trunk/data/experimental/game.ruleset trunk/data/multiplayer/game.ruleset trunk/data/sandbox/game.ruleset trunk/data/stub/game.ruleset trunk/data/webperimental/game.ruleset trunk/fc_version trunk/server/rssanity.c trunk/server/ruleset.c trunk/tools/ruleutil/rulesave.c Modified: trunk/common/actions.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.c?rev=33665&r1=33664&r2=33665&view=diff ============================================================================== --- trunk/common/actions.c (original) +++ trunk/common/actions.c Sun Aug 21 12:11:55 2016 @@ -227,11 +227,11 @@ actions[ACTION_PARADROP] = action_new(ACTION_PARADROP, ATK_TILE, FALSE, FALSE, TRUE, - 1, MAP_DISTANCE_MAX); + 1, ACTION_DISTANCE_MAX); actions[ACTION_AIRLIFT] = action_new(ACTION_AIRLIFT, ATK_CITY, FALSE, FALSE, TRUE, - 1, MAP_DISTANCE_MAX); + 1, ACTION_DISTANCE_MAX); actions[ACTION_ATTACK] = action_new(ACTION_ATTACK, /* FIXME: Target is actually City and, depending on the @@ -475,7 +475,8 @@ fc_assert_ret_val(action, FALSE); return (distance >= action->min_distance - && distance <= action->max_distance); + && (distance <= action->max_distance + || action->max_distance == ACTION_DISTANCE_UNLIMITED)); } /************************************************************************** Modified: trunk/common/actions.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.h?rev=33665&r1=33664&r2=33665&view=diff ============================================================================== --- trunk/common/actions.h (original) +++ trunk/common/actions.h Sun Aug 21 12:11:55 2016 @@ -131,6 +131,11 @@ #define SPECENUM_COUNT ACT_REQ_COUNT #include "specenum_gen.h" +/* No action max distance to target limit. */ +#define ACTION_DISTANCE_UNLIMITED (MAP_DISTANCE_MAX + 1) +/* No action max distance can be bigger than this. */ +#define ACTION_DISTANCE_MAX ACTION_DISTANCE_UNLIMITED + struct action { enum gen_action id; Modified: trunk/common/game.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/game.h?rev=33665&r1=33664&r2=33665&view=diff ============================================================================== --- trunk/common/game.h (original) +++ trunk/common/game.h Sun Aug 21 12:11:55 2016 @@ -797,6 +797,8 @@ #define RS_DEFAULT_POISON_EMPTIES_FOOD_STOCK FALSE #define RS_DEFAULT_BOMBARD_MAX_RANGE 1 +#define RS_ACTION_NO_MAX_DISTANCE "unlimited" + #ifdef __cplusplus } #endif /* __cplusplus */ Modified: trunk/data/alien/game.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/alien/game.ruleset?rev=33665&r1=33664&r2=33665&view=diff ============================================================================== --- trunk/data/alien/game.ruleset (original) +++ trunk/data/alien/game.ruleset Sun Aug 21 12:11:55 2016 @@ -215,7 +215,11 @@ ; will empty the food stock. poison_empties_food_stock = FALSE -; How far away targets of "Bombard" is allowed to be. +; The maximum distance from the actor unit to the target of the "Bombard" +; action. The value 1 means that the targets must be on a tile adjacent to +; the actor unit. The special value "unlimited" lifts the maximum distance +; restriction. The maximum distance can't be smaller than the minimum +; distance. bombard_max_range = 1 ; What each action should be called when showing them to the player. Modified: trunk/data/civ1/game.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/civ1/game.ruleset?rev=33665&r1=33664&r2=33665&view=diff ============================================================================== --- trunk/data/civ1/game.ruleset (original) +++ trunk/data/civ1/game.ruleset Sun Aug 21 12:11:55 2016 @@ -190,7 +190,11 @@ ; will empty the food stock. poison_empties_food_stock = FALSE -; How far away targets of "Bombard" is allowed to be. +; The maximum distance from the actor unit to the target of the "Bombard" +; action. The value 1 means that the targets must be on a tile adjacent to +; the actor unit. The special value "unlimited" lifts the maximum distance +; restriction. The maximum distance can't be smaller than the minimum +; distance. bombard_max_range = 1 ; What each action should be called when showing them to the player. Modified: trunk/data/civ2/game.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2/game.ruleset?rev=33665&r1=33664&r2=33665&view=diff ============================================================================== --- trunk/data/civ2/game.ruleset (original) +++ trunk/data/civ2/game.ruleset Sun Aug 21 12:11:55 2016 @@ -207,7 +207,11 @@ ; will empty the food stock. poison_empties_food_stock = FALSE -; How far away targets of "Bombard" is allowed to be. +; The maximum distance from the actor unit to the target of the "Bombard" +; action. The value 1 means that the targets must be on a tile adjacent to +; the actor unit. The special value "unlimited" lifts the maximum distance +; restriction. The maximum distance can't be smaller than the minimum +; distance. bombard_max_range = 1 ; What each action should be called when showing them to the player. Modified: trunk/data/civ2civ3/game.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2civ3/game.ruleset?rev=33665&r1=33664&r2=33665&view=diff ============================================================================== --- trunk/data/civ2civ3/game.ruleset (original) +++ trunk/data/civ2civ3/game.ruleset Sun Aug 21 12:11:55 2016 @@ -216,7 +216,11 @@ ; will empty the food stock. poison_empties_food_stock = FALSE -; How far away targets of "Bombard" is allowed to be. +; The maximum distance from the actor unit to the target of the "Bombard" +; action. The value 1 means that the targets must be on a tile adjacent to +; the actor unit. The special value "unlimited" lifts the maximum distance +; restriction. The maximum distance can't be smaller than the minimum +; distance. bombard_max_range = 1 ; What each action should be called when showing them to the player. Modified: trunk/data/classic/game.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/classic/game.ruleset?rev=33665&r1=33664&r2=33665&view=diff ============================================================================== --- trunk/data/classic/game.ruleset (original) +++ trunk/data/classic/game.ruleset Sun Aug 21 12:11:55 2016 @@ -211,7 +211,11 @@ ; will empty the food stock. poison_empties_food_stock = FALSE -; How far away targets of "Bombard" is allowed to be. +; The maximum distance from the actor unit to the target of the "Bombard" +; action. The value 1 means that the targets must be on a tile adjacent to +; the actor unit. The special value "unlimited" lifts the maximum distance +; restriction. The maximum distance can't be smaller than the minimum +; distance. bombard_max_range = 1 ; What each action should be called when showing them to the player. Modified: trunk/data/experimental/game.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/experimental/game.ruleset?rev=33665&r1=33664&r2=33665&view=diff ============================================================================== --- trunk/data/experimental/game.ruleset (original) +++ trunk/data/experimental/game.ruleset Sun Aug 21 12:11:55 2016 @@ -214,7 +214,11 @@ ; will empty the food stock. poison_empties_food_stock = FALSE -; How far away targets of "Bombard" is allowed to be. +; The maximum distance from the actor unit to the target of the "Bombard" +; action. The value 1 means that the targets must be on a tile adjacent to +; the actor unit. The special value "unlimited" lifts the maximum distance +; restriction. The maximum distance can't be smaller than the minimum +; distance. bombard_max_range = 1 ; What each action should be called when showing them to the player. Modified: trunk/data/multiplayer/game.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/multiplayer/game.ruleset?rev=33665&r1=33664&r2=33665&view=diff ============================================================================== --- trunk/data/multiplayer/game.ruleset (original) +++ trunk/data/multiplayer/game.ruleset Sun Aug 21 12:11:55 2016 @@ -214,7 +214,11 @@ ; will empty the food stock. poison_empties_food_stock = FALSE -; How far away targets of "Bombard" is allowed to be. +; The maximum distance from the actor unit to the target of the "Bombard" +; action. The value 1 means that the targets must be on a tile adjacent to +; the actor unit. The special value "unlimited" lifts the maximum distance +; restriction. The maximum distance can't be smaller than the minimum +; distance. bombard_max_range = 1 ; What each action should be called when showing them to the player. Modified: trunk/data/sandbox/game.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/sandbox/game.ruleset?rev=33665&r1=33664&r2=33665&view=diff ============================================================================== --- trunk/data/sandbox/game.ruleset (original) +++ trunk/data/sandbox/game.ruleset Sun Aug 21 12:11:55 2016 @@ -213,7 +213,11 @@ ; will empty the food stock. poison_empties_food_stock = FALSE -; How far away targets of "Bombard" is allowed to be. +; The maximum distance from the actor unit to the target of the "Bombard" +; action. The value 1 means that the targets must be on a tile adjacent to +; the actor unit. The special value "unlimited" lifts the maximum distance +; restriction. The maximum distance can't be smaller than the minimum +; distance. bombard_max_range = 1 ; What each action should be called when showing them to the player. Modified: trunk/data/stub/game.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/stub/game.ruleset?rev=33665&r1=33664&r2=33665&view=diff ============================================================================== --- trunk/data/stub/game.ruleset (original) +++ trunk/data/stub/game.ruleset Sun Aug 21 12:11:55 2016 @@ -202,7 +202,11 @@ ; will empty the food stock. ;poison_empties_food_stock = FALSE -; How far away targets of "Bombard" is allowed to be. +; The maximum distance from the actor unit to the target of the "Bombard" +; action. The value 1 means that the targets must be on a tile adjacent to +; the actor unit. The special value "unlimited" lifts the maximum distance +; restriction. The maximum distance can't be smaller than the minimum +; distance. bombard_max_range = 1 ; What each action should be called when showing them to the player. Modified: trunk/data/webperimental/game.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/webperimental/game.ruleset?rev=33665&r1=33664&r2=33665&view=diff ============================================================================== --- trunk/data/webperimental/game.ruleset (original) +++ trunk/data/webperimental/game.ruleset Sun Aug 21 12:11:55 2016 @@ -264,7 +264,11 @@ ; will empty the food stock. poison_empties_food_stock = FALSE -; How far away targets of "Bombard" is allowed to be. +; The maximum distance from the actor unit to the target of the "Bombard" +; action. The value 1 means that the targets must be on a tile adjacent to +; the actor unit. The special value "unlimited" lifts the maximum distance +; restriction. The maximum distance can't be smaller than the minimum +; distance. bombard_max_range = 3 ; What each action should be called when showing them to the player. Modified: trunk/fc_version URL: http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=33665&r1=33664&r2=33665&view=diff ============================================================================== --- trunk/fc_version (original) +++ trunk/fc_version Sun Aug 21 12:11:55 2016 @@ -56,7 +56,7 @@ # - Avoid adding a new mandatory capability to the development branch for # as long as possible. We want to maintain network compatibility with # the stable branch for as long as possible. -NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2016.Aug.20" +NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2016.Aug.21" NETWORK_CAPSTRING_OPTIONAL="" FREECIV_DISTRIBUTOR="" Modified: trunk/server/rssanity.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/rssanity.c?rev=33665&r1=33664&r2=33665&view=diff ============================================================================== --- trunk/server/rssanity.c (original) +++ trunk/server/rssanity.c Sun Aug 21 12:11:55 2016 @@ -908,7 +908,7 @@ ok = FALSE; } - if (paction->max_distance > MAP_DISTANCE_MAX) { + if (paction->max_distance > ACTION_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); Modified: trunk/server/ruleset.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/ruleset.c?rev=33665&r1=33664&r2=33665&view=diff ============================================================================== --- trunk/server/ruleset.c (original) +++ trunk/server/ruleset.c Sun Aug 21 12:11:55 2016 @@ -5860,9 +5860,42 @@ /* Allow setting max distance for bombardment before generalized * actions. */ - action_by_number(ACTION_BOMBARD)->max_distance - = secfile_lookup_int_default(file, RS_DEFAULT_BOMBARD_MAX_RANGE, - "actions.bombard_max_range"); + { + struct entry *pentry; + int max_range; + + pentry = secfile_entry_lookup(file, "actions.bombard_max_range"); + + if (!pentry) { + max_range = RS_DEFAULT_BOMBARD_MAX_RANGE; + } else { + switch (entry_type(pentry)) { + case ENTRY_INT: + if (entry_int_get(pentry, &max_range)) { + break; + } + /* Fall through to error handling. */ + case ENTRY_STR: + { + const char *custom; + + if (entry_str_get(pentry, &custom) + && !fc_strcasecmp(custom, RS_ACTION_NO_MAX_DISTANCE)) { + max_range = ACTION_DISTANCE_UNLIMITED; + break; + } + } + /* Fall through to error handling. */ + default: + ruleset_error(LOG_ERROR, "Bad actions.bombard_max_range"); + ok = FALSE; + max_range = RS_DEFAULT_BOMBARD_MAX_RANGE; + break; + } + } + + action_by_number(ACTION_BOMBARD)->max_distance = max_range; + } text = secfile_lookup_str_default(file, /* TRANS: _Poison City (3% chance of success). */ Modified: trunk/tools/ruleutil/rulesave.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruleutil/rulesave.c?rev=33665&r1=33664&r2=33665&view=diff ============================================================================== --- trunk/tools/ruleutil/rulesave.c (original) +++ trunk/tools/ruleutil/rulesave.c Sun Aug 21 12:11:55 2016 @@ -940,9 +940,15 @@ RS_DEFAULT_POISON_EMPTIES_FOOD_STOCK, "actions.poison_empties_food_stock", NULL); - save_default_int(sfile, action_by_number(ACTION_BOMBARD)->max_distance, - RS_DEFAULT_BOMBARD_MAX_RANGE, - "actions.bombard_max_range", NULL); + if (action_by_number(ACTION_BOMBARD)->max_distance + == ACTION_DISTANCE_UNLIMITED) { + secfile_insert_str(sfile, RS_ACTION_NO_MAX_DISTANCE, + "actions.bombard_max_range"); + } else { + save_default_int(sfile, action_by_number(ACTION_BOMBARD)->max_distance, + RS_DEFAULT_BOMBARD_MAX_RANGE, + "actions.bombard_max_range", NULL); + } secfile_insert_str(sfile, action_by_number(ACTION_SPY_POISON)->ui_name, _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits