Complete.Org: Mailing Lists: Archives: freeciv-ai: December 2002:
[freeciv-ai] stop infinite loops in ai_unit_rampage()
Home

[freeciv-ai] stop infinite loops in ai_unit_rampage()

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-ai@xxxxxxxxxxx
Subject: [freeciv-ai] stop infinite loops in ai_unit_rampage()
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Wed, 4 Dec 2002 22:40:34 +0000 (GMT)

In very rare circumstances, ai_unit_rampage() can go into an endless loop
because we find a good target which is not a unit (hut or city) but are
unable to enter it because we are not in the right activity to move.

This patch fixes it. It may be desirable to put a better failsafe into the
aforementioned function, as well, to prevent future infinite loops from
happening, since their causes are rather hard to track down.

  - Per

Index: ai/aitools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aitools.c,v
retrieving revision 1.63
diff -u -r1.63 aitools.c
--- ai/aitools.c        2 Dec 2002 22:48:13 -0000       1.63
+++ ai/aitools.c        4 Dec 2002 22:27:59 -0000
@@ -281,6 +281,7 @@
   pmove.x = x;
   pmove.y = y;
   pmove.unid = punit->id;
+  handle_unit_activity_request(punit, ACTIVITY_IDLE);
   handle_move_unit(unit_owner(punit), &pmove);

   if (find_unit_by_id(sanity) && same_pos(x, y, punit->x, punit->y)) {




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