Author: cazfi Date: Mon Jul 7 02:02:43 2014 New Revision: 25409 URL: http://svn.gna.org/viewcvs/freeciv?rev=25409&view=rev Log: Obsoleted "NoBonus" road move mode. Such roads should have move_cost set to -1 instead, and mode to what ever mode should be used in determining move restrictions.
See patch #4877 Modified: trunk/ai/threaded/taicity.c trunk/client/helpdata.c trunk/common/map.c trunk/common/movement.c trunk/common/road.c trunk/common/road.h trunk/data/alien/terrain.ruleset trunk/data/civ1/terrain.ruleset trunk/data/civ2/terrain.ruleset trunk/data/civ2civ3/terrain.ruleset trunk/data/classic/terrain.ruleset trunk/data/experimental/terrain.ruleset trunk/data/multiplayer/terrain.ruleset trunk/data/stub/terrain.ruleset trunk/server/advisors/autosettlers.c Modified: trunk/ai/threaded/taicity.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/ai/threaded/taicity.c?rev=25409&r1=25408&r2=25409&view=diff ============================================================================== --- trunk/ai/threaded/taicity.c (original) +++ trunk/ai/threaded/taicity.c Mon Jul 7 02:02:43 2014 @@ -117,7 +117,7 @@ road_type_iterate(pold) { if (tile_has_road(ptile, pold)) { - if (pold->move_mode != RMM_NO_BONUS + if (road_provides_move_bonus(pold) && pold->move_cost < old_move_cost) { old_move_cost = pold->move_cost; } Modified: trunk/client/helpdata.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/helpdata.c?rev=25409&r1=25408&r2=25409&view=diff ============================================================================== --- trunk/client/helpdata.c (original) +++ trunk/client/helpdata.c Mon Jul 7 02:02:43 2014 @@ -3651,7 +3651,7 @@ } } - if (proad != NULL && proad->move_mode != RMM_NO_BONUS) { + if (proad != NULL && road_provides_move_bonus(proad)) { if (proad->move_cost == 0) { CATLSTR(buf, bufsz, _("* Allows infinite movement.\n")); } else { Modified: trunk/common/map.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/map.c?rev=25409&r1=25408&r2=25409&view=diff ============================================================================== --- trunk/common/map.c (original) +++ trunk/common/map.c Mon Jul 7 02:02:43 2014 @@ -741,7 +741,7 @@ && (!pclass || is_native_extra_to_uclass(road_extra_get(proad), pclass))) { road_type_list_iterate(proad->integrators, iroad) { - if (iroad->move_mode != RMM_NO_BONUS + if (road_provides_move_bonus(iroad) && cost > iroad->move_cost && tile_has_road(t2, iroad) && (!pclass @@ -772,9 +772,6 @@ case RMM_FAST_ALWAYS: cost = iroad->move_cost; break; - case RMM_NO_BONUS: - fc_assert(proad->move_mode != RMM_NO_BONUS); - break; } } } road_type_list_iterate_end; Modified: trunk/common/movement.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/movement.c?rev=25409&r1=25408&r2=25409&view=diff ============================================================================== --- trunk/common/movement.c (original) +++ trunk/common/movement.c Mon Jul 7 02:02:43 2014 @@ -347,7 +347,6 @@ } switch (iroad->move_mode) { case RMM_FAST_ALWAYS: - case RMM_NO_BONUS: /* Road connects source and destination, so we're fine. */ return TRUE; case RMM_CARDINAL: Modified: trunk/common/road.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/road.c?rev=25409&r1=25408&r2=25409&view=diff ============================================================================== --- trunk/common/road.c (original) +++ trunk/common/road.c Mon Jul 7 02:02:43 2014 @@ -547,3 +547,11 @@ return proad->move_mode == RMM_CARDINAL || proad->move_mode == RMM_RELAXED; } + +/**************************************************************************** + Does road type provide move bonus +****************************************************************************/ +bool road_provides_move_bonus(const struct road_type *proad) +{ + return proad->move_cost >= 0; +} Modified: trunk/common/road.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/road.h?rev=25409&r1=25408&r2=25409&view=diff ============================================================================== --- trunk/common/road.h (original) +++ trunk/common/road.h Mon Jul 7 02:02:43 2014 @@ -33,14 +33,12 @@ /* Used in the network protocol. */ #define SPECENUM_NAME road_move_mode -#define SPECENUM_VALUE0 RMM_NO_BONUS -#define SPECENUM_VALUE0NAME "NoBonus" -#define SPECENUM_VALUE1 RMM_CARDINAL -#define SPECENUM_VALUE1NAME "Cardinal" -#define SPECENUM_VALUE2 RMM_RELAXED -#define SPECENUM_VALUE2NAME "Relaxed" -#define SPECENUM_VALUE3 RMM_FAST_ALWAYS -#define SPECENUM_VALUE3NAME "FastAlways" +#define SPECENUM_VALUE0 RMM_CARDINAL +#define SPECENUM_VALUE0NAME "Cardinal" +#define SPECENUM_VALUE1 RMM_RELAXED +#define SPECENUM_VALUE1NAME "Relaxed" +#define SPECENUM_VALUE2 RMM_FAST_ALWAYS +#define SPECENUM_VALUE2NAME "FastAlways" #include "specenum_gen.h" struct road_type; @@ -132,6 +130,8 @@ bool is_cardinal_only_road(const struct extra_type *pextra); +bool road_provides_move_bonus(const struct road_type *proad); + /* Sorting */ int compare_road_move_cost(const struct road_type *const *p, const struct road_type *const *q); Modified: trunk/data/alien/terrain.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/alien/terrain.ruleset?rev=25409&r1=25408&r2=25409&view=diff ============================================================================== --- trunk/data/alien/terrain.ruleset (original) +++ trunk/data/alien/terrain.ruleset Mon Jul 7 02:02:43 2014 @@ -952,8 +952,8 @@ ; move_cost = how much movement it takes to travel ; via this road (in fractional move points, as ; defined by move_fragments) +; -1 means that road provides no speed bonus. ; move_mode = how movement costs are applied -; - "NoBonus" = Road gives no movement bonuses (move_cost ignored) ; - "Cardinal" = Road cost applies only on cardinal moves ; - "Relaxed" = Road cost is normal for cardinal, double for diagonal moves ; - "FastAlways" = Road cost applies always between two tiles with the roads Modified: trunk/data/civ1/terrain.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/civ1/terrain.ruleset?rev=25409&r1=25408&r2=25409&view=diff ============================================================================== --- trunk/data/civ1/terrain.ruleset (original) +++ trunk/data/civ1/terrain.ruleset Mon Jul 7 02:02:43 2014 @@ -946,8 +946,8 @@ ; move_cost = how much movement it takes to travel ; via this road (in fractional move points, as ; defined by move_fragments) +; -1 means that road provides no speed bonus. ; move_mode = how movement costs are applied -; - "NoBonus" = Road gives no movement bonuses (move_cost ignored) ; - "Cardinal" = Road cost applies only on cardinal moves ; - "Relaxed" = Road cost is normal for cardinal, double for diagonal moves ; - "FastAlways" = Road cost applies always between two tiles with the roads Modified: trunk/data/civ2/terrain.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2/terrain.ruleset?rev=25409&r1=25408&r2=25409&view=diff ============================================================================== --- trunk/data/civ2/terrain.ruleset (original) +++ trunk/data/civ2/terrain.ruleset Mon Jul 7 02:02:43 2014 @@ -1104,8 +1104,8 @@ ; move_cost = how much movement it takes to travel ; via this road (in fractional move points, as ; defined by move_fragments) +; -1 means that road provides no speed bonus. ; move_mode = how movement costs are applied -; - "NoBonus" = Road gives no movement bonuses (move_cost ignored) ; - "Cardinal" = Road cost applies only on cardinal moves ; - "Relaxed" = Road cost is normal for cardinal, double for diagonal moves ; - "FastAlways" = Road cost applies always between two tiles with the roads Modified: trunk/data/civ2civ3/terrain.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2civ3/terrain.ruleset?rev=25409&r1=25408&r2=25409&view=diff ============================================================================== --- trunk/data/civ2civ3/terrain.ruleset (original) +++ trunk/data/civ2civ3/terrain.ruleset Mon Jul 7 02:02:43 2014 @@ -1377,8 +1377,8 @@ ; move_cost = how much movement it takes to travel ; via this road (in fractional move points, as ; defined by move_fragments) +; -1 means that road provides no speed bonus. ; move_mode = how movement costs are applied -; - "NoBonus" = Road gives no movement bonuses (move_cost ignored) ; - "Cardinal" = Road cost applies only on cardinal moves ; - "Relaxed" = Road cost is normal for cardinal, double for diagonal moves ; - "FastAlways" = Road cost applies always between two tiles with the roads Modified: trunk/data/classic/terrain.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/classic/terrain.ruleset?rev=25409&r1=25408&r2=25409&view=diff ============================================================================== --- trunk/data/classic/terrain.ruleset (original) +++ trunk/data/classic/terrain.ruleset Mon Jul 7 02:02:43 2014 @@ -1368,9 +1368,9 @@ ; README.effects for help on requirements) ; move_cost = how much movement it takes to travel ; via this road (in fractional move points, as -; defined by move_fragments) +; defined by move_fragments). +; -1 means that road provides no speed bonus. ; move_mode = how movement costs are applied -; - "NoBonus" = Road gives no movement bonuses (move_cost ignored) ; - "Cardinal" = Road cost applies only on cardinal moves ; - "Relaxed" = Road cost is normal for cardinal, double for diagonal moves ; - "FastAlways" = Road cost applies always between two tiles with the roads Modified: trunk/data/experimental/terrain.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/experimental/terrain.ruleset?rev=25409&r1=25408&r2=25409&view=diff ============================================================================== --- trunk/data/experimental/terrain.ruleset (original) +++ trunk/data/experimental/terrain.ruleset Mon Jul 7 02:02:43 2014 @@ -1367,8 +1367,8 @@ ; move_cost = how much movement it takes to travel ; via this road (in fractional move points, as ; defined by move_fragments) +; -1 means that road provides no speed bonus. ; move_mode = how movement costs are applied -; - "NoBonus" = Road gives no movement bonuses (move_cost ignored) ; - "Cardinal" = Road cost applies only on cardinal moves ; - "Relaxed" = Road cost is normal for cardinal, double for diagonal moves ; - "FastAlways" = Road cost applies always between two tiles with the roads Modified: trunk/data/multiplayer/terrain.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/multiplayer/terrain.ruleset?rev=25409&r1=25408&r2=25409&view=diff ============================================================================== --- trunk/data/multiplayer/terrain.ruleset (original) +++ trunk/data/multiplayer/terrain.ruleset Mon Jul 7 02:02:43 2014 @@ -1343,8 +1343,8 @@ ; move_cost = how much movement it takes to travel ; via this road (in fractional move points, as ; defined by move_fragments) +; -1 means that road provides no speed bonus. ; move_mode = how movement costs are applied -; - "NoBonus" = Road gives no movement bonuses (move_cost ignored) ; - "Cardinal" = Road cost applies only on cardinal moves ; - "Relaxed" = Road cost is normal for cardinal, double for diagonal moves ; - "FastAlways" = Road cost applies always between two tiles with the roads Modified: trunk/data/stub/terrain.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/stub/terrain.ruleset?rev=25409&r1=25408&r2=25409&view=diff ============================================================================== --- trunk/data/stub/terrain.ruleset (original) +++ trunk/data/stub/terrain.ruleset Mon Jul 7 02:02:43 2014 @@ -422,8 +422,8 @@ ; move_cost = how much movement it takes to to travel ; via this road (in fractional move points, as ; defined by move_fragments) +; -1 means that road provides no speed bonus. ; move_mode = how movement costs are applied -; - "NoBonus" = Road gives no movement bonuses (move_cost ignored) ; - "Cardinal" = Road cost applies only on cardinal moves ; - "Relaxed" = Road cost is normal for cardinal, double for diagonal moves ; - "FastAlways" = Road cost applies always between two tiles with the roads Modified: trunk/server/advisors/autosettlers.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/advisors/autosettlers.c?rev=25409&r1=25408&r2=25409&view=diff ============================================================================== --- trunk/server/advisors/autosettlers.c (original) +++ trunk/server/advisors/autosettlers.c Mon Jul 7 02:02:43 2014 @@ -454,39 +454,44 @@ if (base_value >= 0) { int extra; - int mc_multiplier = 1; - int mc_divisor = 1; - int old_move_cost = tile_terrain(ptile)->movement_cost * SINGLE_MOVE; - - road_type_iterate(pold) { - if (tile_has_road(ptile, pold)) { - /* This ignores the fact that new road may be native to units that - * old road is not. */ - if (pold->move_cost < old_move_cost) { - old_move_cost = pold->move_cost; - } - } - } road_type_iterate_end; time = pos.turn + get_turns_for_activity_at(punit, ACTIVITY_GEN_ROAD, ptile, target); - if (proad->move_cost < old_move_cost) { - if (proad->move_cost >= 3) { - mc_divisor = proad->move_cost / 3; - } else { - if (proad->move_cost == 0) { - mc_multiplier = 2; + if (road_provides_move_bonus(proad)) { + int mc_multiplier = 1; + int mc_divisor = 1; + int old_move_cost = tile_terrain(ptile)->movement_cost * SINGLE_MOVE; + + road_type_iterate(pold) { + if (tile_has_road(ptile, pold)) { + /* This ignores the fact that new road may be native to units that + * old road is not. */ + if (pold->move_cost < old_move_cost) { + old_move_cost = pold->move_cost; + } + } + } road_type_iterate_end; + + if (proad->move_cost < old_move_cost) { + if (proad->move_cost >= 3) { + mc_divisor = proad->move_cost / 3; } else { - mc_multiplier = 1 - proad->move_cost; + if (proad->move_cost == 0) { + mc_multiplier = 2; + } else { + mc_multiplier = 1 - proad->move_cost; + } + mc_multiplier += old_move_cost; } - mc_multiplier += old_move_cost; } + + extra = adv_settlers_road_bonus(ptile, proad) * mc_multiplier / mc_divisor; + } else { + extra = 0; } - - extra = adv_settlers_road_bonus(ptile, proad) * mc_multiplier / mc_divisor; if (can_unit_do_activity_targeted_at(punit, ACTIVITY_GEN_ROAD, target, ptile)) { _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits