Author: cazfi Date: Sat May 7 08:47:07 2016 New Revision: 32612 URL: http://svn.gna.org/viewcvs/freeciv?rev=32612&view=rev Log: Added list of roads providing movement bonus to the unit class caches.
See patch #7176 Modified: trunk/common/map.c trunk/common/unittype.c trunk/common/unittype.h Modified: trunk/common/map.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/map.c?rev=32612&r1=32611&r2=32612&view=diff ============================================================================== --- trunk/common/map.c (original) +++ trunk/common/map.c Sat May 7 08:47:07 2016 @@ -807,7 +807,7 @@ cost = tile_terrain(t2)->movement_cost * SINGLE_MOVE; ri = restrict_infra(pplayer, t1, t2); - extra_type_by_cause_iterate(EC_ROAD, pextra) { + extra_type_list_iterate(pclass->cache.bonus_roads, pextra) { struct road_type *proad = extra_road_get(pextra); /* We check the destination tile first, as that's @@ -815,18 +815,14 @@ * If can avoid inner loop about integrating roads * completely if the destination road has too high cost. */ - if (road_provides_move_bonus(proad) - && cost > proad->move_cost + if (cost > proad->move_cost && (!ri || road_has_flag(proad, RF_UNRESTRICTED_INFRA)) - && tile_has_extra(t2, pextra) - && (!pclass - || is_native_extra_to_uclass(pextra, pclass))) { + && tile_has_extra(t2, pextra)) { extra_type_list_iterate(proad->integrators, iextra) { /* We have no unrestricted infra related check here, * destination road is the one that counts. */ if (tile_has_extra(t1, iextra) - && (!pclass - || is_native_extra_to_uclass(iextra, pclass))) { + && is_native_extra_to_uclass(iextra, pclass)) { if (proad->move_mode == RMM_FAST_ALWAYS) { cost = proad->move_cost; } else { @@ -866,7 +862,7 @@ } } extra_type_list_iterate_end; } - } extra_type_by_cause_iterate_end; + } extra_type_list_iterate_end; /* UTYF_IGTER units have a maximum move cost per step. */ if (utype_has_flag(punittype, UTYF_IGTER) && MOVE_COST_IGTER < cost) { Modified: trunk/common/unittype.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/unittype.c?rev=32612&r1=32611&r2=32612&view=diff ============================================================================== --- trunk/common/unittype.c (original) +++ trunk/common/unittype.c Sat May 7 08:47:07 2016 @@ -1725,6 +1725,7 @@ unit_classes[i].item_number = i; unit_classes[i].cache.refuel_bases = NULL; unit_classes[i].cache.native_tile_extras = NULL; + unit_classes[i].cache.bonus_roads = NULL; unit_classes[i].cache.subset_movers = NULL; unit_classes[i].helptext = NULL; } @@ -1745,6 +1746,10 @@ if (unit_classes[i].cache.native_tile_extras != NULL) { extra_type_list_destroy(unit_classes[i].cache.native_tile_extras); unit_classes[i].cache.native_tile_extras = NULL; + } + if (unit_classes[i].cache.bonus_roads != NULL) { + extra_type_list_destroy(unit_classes[i].cache.bonus_roads); + unit_classes[i].cache.bonus_roads = NULL; } if (unit_classes[i].cache.subset_movers != NULL) { unit_class_list_destroy(unit_classes[i].cache.subset_movers); @@ -1907,15 +1912,21 @@ { pclass->cache.refuel_bases = extra_type_list_new(); pclass->cache.native_tile_extras = extra_type_list_new(); + pclass->cache.bonus_roads = extra_type_list_new(); pclass->cache.subset_movers = unit_class_list_new(); extra_type_iterate(pextra) { if (is_native_extra_to_uclass(pextra, pclass)) { + struct road_type *proad = extra_road_get(pextra); + if (extra_has_flag(pextra, EF_REFUEL)) { extra_type_list_append(pclass->cache.refuel_bases, pextra); } if (extra_has_flag(pextra, EF_NATIVE_TILE)) { extra_type_list_append(pclass->cache.native_tile_extras, pextra); + } + if (proad != NULL && road_provides_move_bonus(proad)) { + extra_type_list_append(pclass->cache.bonus_roads, pextra); } } } extra_type_iterate_end; Modified: trunk/common/unittype.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/unittype.h?rev=32612&r1=32611&r2=32612&view=diff ============================================================================== --- trunk/common/unittype.h (original) +++ trunk/common/unittype.h Sat May 7 08:47:07 2016 @@ -151,6 +151,7 @@ struct { struct extra_type_list *refuel_bases; struct extra_type_list *native_tile_extras; + struct extra_type_list *bonus_roads; struct unit_class_list *subset_movers; } cache; }; _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits