Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2003:
[Freeciv-Dev] (PR#6491) Send unhomed units somewhere on gohome
Home

[Freeciv-Dev] (PR#6491) Send unhomed units somewhere on gohome

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#6491) Send unhomed units somewhere on gohome
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Sun, 12 Oct 2003 05:21:13 -0700
Reply-to: rt@xxxxxxxxxxxxxx

When calling ai_military_gohome(), unhomed units won't budge. This fixes
that problem.

  - Per

Index: ai/aiunit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v
retrieving revision 1.298
diff -u -r1.298 aiunit.c
--- ai/aiunit.c 9 Oct 2003 00:07:33 -0000       1.298
+++ ai/aiunit.c 12 Oct 2003 12:18:59 -0000
@@ -1454,11 +1454,18 @@
 }
 
 /********************************************************************** 
-  Send a unit to its homecity. FIXME: Give it one if it has none.
+  Send a unit to its homecity.
 ***********************************************************************/
 static void ai_military_gohome(struct player *pplayer,struct unit *punit)
 {
   struct city *pcity = find_city_by_id(punit->homecity);
+
+  if (!pcity) {
+    /* Try to find a place to rest. Sitting duck out in the wilderness
+     * is generally a bad idea, since we protect no cities that way, and
+     * it looks silly. */
+    pcity = find_closest_owned_city(pplayer, punit->x, punit->y, FALSE, NULL);
+  }
 
   CHECK_UNIT(punit);
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#6491) Send unhomed units somewhere on gohome, Per I. Mathisen <=