Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2006:
[Freeciv-Dev] Re: (PR#18440) [Bug+Patch] Wrong warmap after generate_war
Home

[Freeciv-Dev] Re: (PR#18440) [Bug+Patch] Wrong warmap after generate_war

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] Re: (PR#18440) [Bug+Patch] Wrong warmap after generate_warmap()
From: "Marko Lindqvist" <cazfi74@xxxxxxxxx>
Date: Tue, 11 Jul 2006 06:19:46 -0700
Reply-to: bugs@xxxxxxxxxxx

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

On 7/9/06, Marko Lindqvist <cazfi74@xxxxxxxxx> wrote:

>   Calling really_generate_warmap() directly is not a good idea. It will
> mess with warmap contents but leaves warunit and warcity variables as
> they were. Next time generate_warmap() is called, it may decide that
> existing warmap is still useful based on warunit and warcity variables.

 Same problem existed with calling find_the_shortest_path() and
air_can_move_between()


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/aiunit.c freeciv/ai/aiunit.c
--- freeciv/ai/aiunit.c 2006-07-11 13:53:29.187500000 +0300
+++ freeciv/ai/aiunit.c 2006-07-11 15:51:15.500000000 +0300
@@ -1321,8 +1321,7 @@
 
   if (ferryboat) {
     boattype = ferryboat->type;
-    really_generate_warmap(tile_get_city(ferryboat->tile),
-                           ferryboat, SEA_MOVING);
+    generate_warmap(tile_get_city(ferryboat->tile), ferryboat);
   } else {
     boattype = best_role_unit_for_player(pplayer, L_FERRYBOAT);
     if (boattype == NULL) {
diff -Nurd -X.diff_ignore freeciv/server/gotohand.c freeciv/server/gotohand.c
--- freeciv/server/gotohand.c   2006-07-11 13:57:11.078125000 +0300
+++ freeciv/server/gotohand.c   2006-07-11 15:54:23.656250000 +0300
@@ -265,8 +265,8 @@
 This would be done by inserting the tiles in a list after their move_cost
 as they were found.
 **************************************************************************/
-void really_generate_warmap(struct city *pcity, struct unit *punit,
-                           enum unit_move_type move_type)
+static void really_generate_warmap(struct city *pcity, struct unit *punit,
+                                   enum unit_move_type move_type)
 {
   int move_cost;
   struct tile *orig_tile;
@@ -608,6 +608,9 @@
 
   BV_CLR_ALL(LOCAL_VECTOR(orig_tile));
 
+  warmap.warunit = NULL;
+  warmap.warcity = NULL;
+
   init_warmap(punit->tile, move_type);
   warmap_cost = (move_type == SEA_MOVING) ? warmap.seacost : warmap.cost;
   add_to_mapqueue(0, orig_tile);
@@ -1552,6 +1555,9 @@
   freelog(LOG_DEBUG,
          "air_can_move_between: quick search didn't work. Lets try full.");
 
+  warmap.warunit = NULL;
+  warmap.warcity = NULL;
+
   init_warmap(src_tile, AIR_MOVING);
 
   /* The 0 is inaccurate under A*, but it doesn't matter. */
diff -Nurd -X.diff_ignore freeciv/server/gotohand.h freeciv/server/gotohand.h
--- freeciv/server/gotohand.h   2006-07-11 16:12:41.953125000 +0300
+++ freeciv/server/gotohand.h   2006-07-11 16:13:26.390625000 +0300
@@ -34,8 +34,6 @@
                              enum goto_move_restriction restriction,
                              bool trigger_special_ability);
 void generate_warmap(struct city *pcity, struct unit *punit);
-void really_generate_warmap(struct city *pcity, struct unit *punit,
-                           enum unit_move_type move_type);
 int calculate_move_cost(struct unit *punit, struct tile *dst_tile);
 int air_can_move_between(int moves, struct tile *src_tile,
                         struct tile *dst_tile, struct player *pplayer);

[Prev in Thread] Current Thread [Next in Thread]