Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2006:
[Freeciv-Dev] (PR#18441) [Patch] Better warmap caching
Home

[Freeciv-Dev] (PR#18441) [Patch] Better warmap caching

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#18441) [Patch] Better warmap caching
From: "Marko Lindqvist" <cazfi74@xxxxxxxxx>
Date: Sun, 9 Jul 2006 13:06:13 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=18441 >


  Warmap is identical to two units of same type. So reuse existing 
warmap  even if it's not exactly for this unit, but for other unit of 
the same type.


  - ML

diff -Nurd -X.diff_ignore freeciv/server/gotohand.c freeciv/server/gotohand.c
--- freeciv/server/gotohand.c   2006-07-09 22:30:12.187500000 +0300
+++ freeciv/server/gotohand.c   2006-07-09 22:41:20.140625000 +0300
@@ -399,10 +399,10 @@
     }
 
     /* 
-     * If the previous warmap was for the same unit and it's still
+     * If the previous warmap was for the same unit_type and it's still
      * correct (warmap.(sea)cost[x][y] == 0), reuse it.
      */
-    if (warmap.warunit == punit &&
+    if (warmap.warunit == unit_type(punit) &&
        (is_sailing_unit(punit) ? (WARMAP_SEACOST(punit->tile) == 0)
         : (WARMAP_COST(punit->tile) == 0))) {
       return;
@@ -412,7 +412,7 @@
   }
 
   warmap.warcity = pcity;
-  warmap.warunit = punit;
+  warmap.warunit = punit ? unit_type(punit) : NULL;
 
   if (punit) {
     if (is_sailing_unit(punit)) {
diff -Nurd -X.diff_ignore freeciv/server/gotohand.h freeciv/server/gotohand.h
--- freeciv/server/gotohand.h   2006-07-09 22:44:40.484375000 +0300
+++ freeciv/server/gotohand.h   2006-07-09 22:48:16.265625000 +0300
@@ -53,8 +53,8 @@
   unsigned char *vector;
   int size;
 
-  struct city *warcity; /* so we know what we're dealing with here */
-  struct unit *warunit; /* so we know what we're dealing with here */
+  struct city *warcity;      /* so we know what we're dealing with here */
+  struct unit_type *warunit; /* so we know what we're dealing with here */
   struct tile *orig_tile;
 };
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#18441) [Patch] Better warmap caching, Marko Lindqvist <=