Author: cazfi
Date: Sat May  7 08:47:12 2016
New Revision: 32613

URL: http://svn.gna.org/viewcvs/freeciv?rev=32613&view=rev
Log:
Added list of roads providing movement bonus to the unit class caches.

See patch #7176

Modified:
    branches/S2_6/common/map.c
    branches/S2_6/common/unittype.c
    branches/S2_6/common/unittype.h

Modified: branches/S2_6/common/map.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/map.c?rev=32613&r1=32612&r2=32613&view=diff
==============================================================================
--- branches/S2_6/common/map.c  (original)
+++ branches/S2_6/common/map.c  Sat May  7 08:47:12 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: branches/S2_6/common/unittype.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/unittype.c?rev=32613&r1=32612&r2=32613&view=diff
==============================================================================
--- branches/S2_6/common/unittype.c     (original)
+++ branches/S2_6/common/unittype.c     Sat May  7 08:47:12 2016
@@ -1568,6 +1568,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;
   }
@@ -1588,6 +1589,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);
@@ -1750,15 +1755,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: branches/S2_6/common/unittype.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/unittype.h?rev=32613&r1=32612&r2=32613&view=diff
==============================================================================
--- branches/S2_6/common/unittype.h     (original)
+++ branches/S2_6/common/unittype.h     Sat May  7 08:47:12 2016
@@ -139,6 +139,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

Reply via email to