Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2003:
[Freeciv-Dev] (PR#4604) fix bug with 'virtual' unit in settler code
Home

[Freeciv-Dev] (PR#4604) fix bug with 'virtual' unit in settler code

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#4604) fix bug with 'virtual' unit in settler code
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 17 Jul 2003 23:58:11 -0700
Reply-to: rt@xxxxxxxxxxxxxx

In contemplate_terrain_improvements we make use of a 'virtual' unit. 
But since this data isn't created via create_unit_virtual the goto dest 
is never set.  This means cities near (0,0) may behave oddly, and under 
gen-topologies generates a crash...

The attached patch is the simplest fix.  But I think the comment should 
be followed and a "correct" fix made.  There may be other important 
values that aren't initialized...

jason

Index: server/settlers.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settlers.c,v
retrieving revision 1.167
diff -u -r1.167 settlers.c
--- server/settlers.c   2003/07/17 18:56:51     1.167
+++ server/settlers.c   2003/07/18 06:54:42
@@ -1605,12 +1605,15 @@
   struct tile *ptile = map_get_tile(pcity->x, pcity->y);
   struct ai_data *ai = ai_data_get(pplayer);
 
+  /* HACK: we should use create_unit_virtual or perhaps a new function
+   * init_unit_virtual. */
   memset(&virtualunit, 0, sizeof(struct unit));
   virtualunit.id = 0;
   virtualunit.owner = pplayer->player_no;
   virtualunit.x = pcity->x;
   virtualunit.y = pcity->y;
   virtualunit.type = best_role_unit(pcity, F_SETTLERS);
+  clear_goto_dest(&virtualunit);
   if (virtualunit.type == U_LAST) {
     freelog(LOG_DEBUG, "No F_SETTLERS role unit available");
     return;

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