Author: cazfi
Date: Mon Sep  7 21:41:13 2015
New Revision: 29808

URL: http://svn.gna.org/viewcvs/freeciv?rev=29808&view=rev
Log:
Turned road->integrators from road_list in to an extra_list to cut conversions
from road to extra when actually accessing it.

See patch #6315

Modified:
    branches/S2_6/client/tilespec.c
    branches/S2_6/common/map.c
    branches/S2_6/common/movement.c
    branches/S2_6/common/road.c
    branches/S2_6/common/road.h
    branches/S2_6/server/rssanity.c

Modified: branches/S2_6/client/tilespec.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/tilespec.c?rev=29808&r1=29807&r2=29808&view=diff
==============================================================================
--- branches/S2_6/client/tilespec.c     (original)
+++ branches/S2_6/client/tilespec.c     Mon Sep  7 21:41:13 2015
@@ -3995,12 +3995,12 @@
     if (!is_cardinal_only_road(pextra)
         || is_cardinal_tileset_dir(t, dir)) {
       road_near[dir] = FALSE;
-      road_type_list_iterate(proad->integrators, iroad) {
-        if (BV_ISSET(textras_near[dir], extra_index(road_extra_get(iroad)))) {
+      extra_type_list_iterate(proad->integrators, iextra) {
+        if (BV_ISSET(textras_near[dir], extra_index(iextra))) {
           road_near[dir] = TRUE;
           break;
         }
-      } road_type_list_iterate_end;
+      } extra_type_list_iterate_end;
       if (cl) {
         land_near[dir] = (tterrain_near[dir] != T_UNKNOWN
                           && terrain_type_terrain_class(tterrain_near[dir]) != 
TC_OCEAN);

Modified: branches/S2_6/common/map.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/map.c?rev=29808&r1=29807&r2=29808&view=diff
==============================================================================
--- branches/S2_6/common/map.c  (original)
+++ branches/S2_6/common/map.c  Mon Sep  7 21:41:13 2015
@@ -734,9 +734,7 @@
         && tile_has_extra(t2, pextra)
         && (!pclass
             || is_native_extra_to_uclass(pextra, pclass))) {
-      road_type_list_iterate(proad->integrators, iroad) {
-        struct extra_type *iextra = road_extra_get(iroad);
-
+      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)
@@ -770,7 +768,7 @@
             break;
           }
         }
-      } road_type_list_iterate_end;
+      } extra_type_list_iterate_end;
     }
   } extra_type_by_cause_iterate_end;
 

Modified: branches/S2_6/common/movement.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/movement.c?rev=29808&r1=29807&r2=29808&view=diff
==============================================================================
--- branches/S2_6/common/movement.c     (original)
+++ branches/S2_6/common/movement.c     Mon Sep  7 21:41:13 2015
@@ -357,11 +357,11 @@
     }
 
     proad = extra_road_get(pextra);
-    road_type_list_iterate(proad->integrators, iroad) {
-      if (!tile_has_road(src_tile, iroad)) {
+    extra_type_list_iterate(proad->integrators, iextra) {
+      if (!tile_has_extra(src_tile, iextra)) {
         continue;
       }
-      switch (iroad->move_mode) {
+      switch (extra_road_get(iextra)->move_mode) {
       case RMM_FAST_ALWAYS:
         /* Road connects source and destination, so we're fine. */
         return TRUE;
@@ -377,15 +377,15 @@
           return TRUE;
         }
         cardinal_between_iterate(src_tile, dst_tile, between) {
-          if (tile_has_road(between, iroad)
-              || tile_has_road(between, proad)) {
+          if (tile_has_extra(between, iextra)
+              || tile_has_extra(between, pextra)) {
             /* We have a link for the connection. */
             return TRUE;
           }
         } cardinal_between_iterate_end;
         break;
       }
-    } road_type_list_iterate_end;
+    } extra_type_list_iterate_end;
   } extra_type_list_iterate_end;
 
   return FALSE;

Modified: branches/S2_6/common/road.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/road.c?rev=29808&r1=29807&r2=29808&view=diff
==============================================================================
--- branches/S2_6/common/road.c (original)
+++ branches/S2_6/common/road.c Mon Sep  7 21:41:13 2015
@@ -87,10 +87,11 @@
   This function is passed to road_type_list_sort() to sort a list of roads
   in ascending move_cost (faster roads first).
 ****************************************************************************/
-int compare_road_move_cost(const struct road_type *const *p,
-                           const struct road_type *const *q)
-{
-  const struct road_type *proad = *p, *qroad = *q;
+int compare_road_move_cost(const struct extra_type *const *p,
+                           const struct extra_type *const *q)
+{
+  const struct road_type *proad = extra_road_get(*p);
+  const struct road_type *qroad = extra_road_get(*q);
 
   if (proad->move_cost > qroad->move_cost) {
     return -1; /* q is faster */
@@ -126,16 +127,16 @@
 void road_integrators_cache_init(void)
 {
   road_type_iterate(proad) {
-    proad->integrators = road_type_list_new();
+    proad->integrators = extra_type_list_new();
     /* Roads always integrate with themselves. */
-    road_type_list_append(proad->integrators, proad);
+    extra_type_list_append(proad->integrators, road_extra_get(proad));
     road_type_iterate(oroad) {
       if (BV_ISSET(proad->integrates, road_index(oroad))) {
-        road_type_list_append(proad->integrators, oroad);
+        extra_type_list_append(proad->integrators, road_extra_get(oroad));
       }
     } road_type_iterate_end;
-    road_type_list_unique(proad->integrators);
-    road_type_list_sort(proad->integrators, &compare_road_move_cost);
+    extra_type_list_unique(proad->integrators);
+    extra_type_list_sort(proad->integrators, &compare_road_move_cost);
   } road_type_iterate_end;
 }
 
@@ -148,7 +149,7 @@
     requirement_vector_free(&proad->first_reqs);
 
     if (proad->integrators != NULL) {
-      road_type_list_destroy(proad->integrators);
+      extra_type_list_destroy(proad->integrators);
       proad->integrators = NULL;
     }
   } road_type_iterate_end;
@@ -310,9 +311,9 @@
   if (requirement_vector_size(&proad->first_reqs) > 0) {
     bool beginning = TRUE;
 
-    road_type_list_iterate(proad->integrators, iroad) {
+    extra_type_list_iterate(proad->integrators, iroad) {
       adjc_iterate(ptile, adjc_tile) {
-        if (tile_has_road(adjc_tile, iroad)) {
+        if (tile_has_extra(adjc_tile, iroad)) {
           beginning = FALSE;
           break;
         }
@@ -321,7 +322,7 @@
       if (!beginning) {
         break;
       }
-    } road_type_list_iterate_end;
+    } extra_type_list_iterate_end;
 
     if (beginning) {
       if (!are_reqs_active(pplayer, tile_owner(ptile), NULL, NULL, ptile,

Modified: branches/S2_6/common/road.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/road.h?rev=29808&r1=29807&r2=29808&view=diff
==============================================================================
--- branches/S2_6/common/road.h (original)
+++ branches/S2_6/common/road.h Mon Sep  7 21:41:13 2015
@@ -73,7 +73,7 @@
 
   /* Same information as in integrates, but iterating through this list is much
    * faster than through all road types to check for compatible roads. */
-  struct road_type_list *integrators;
+  struct extra_type_list *integrators;
 
   struct extra_type *self;
 };
@@ -132,8 +132,8 @@
 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);
+int compare_road_move_cost(const struct extra_type *const *p,
+                           const struct extra_type *const *q);
 
 /* Initialization and iteration */
 void road_type_init(struct extra_type *pextra, int idx);

Modified: branches/S2_6/server/rssanity.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/rssanity.c?rev=29808&r1=29807&r2=29808&view=diff
==============================================================================
--- branches/S2_6/server/rssanity.c     (original)
+++ branches/S2_6/server/rssanity.c     Mon Sep  7 21:41:13 2015
@@ -753,7 +753,9 @@
 
   /* Roads */
   road_type_iterate(proad) {
-    road_type_list_iterate(proad->integrators, iroad) {
+    extra_type_list_iterate(proad->integrators, iextra) {
+      struct road_type *iroad = extra_road_get(iextra);
+
       if (road_index(proad) != road_index(iroad)
           && !BV_ISSET(iroad->integrates, road_index(proad))) {
         ruleset_error(LOG_ERROR,
@@ -761,7 +763,7 @@
                       road_name_translation(proad),
                       road_name_translation(iroad));
       }
-    } road_type_list_iterate_end;
+    } extra_type_list_iterate_end;
   } road_type_iterate_end;
 
   /* City styles */


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to