Complete.Org: Mailing Lists: Archives: freeciv-ai: June 2003:
[freeciv-ai] Re: (PR#2755) AI hangs at modified rulesets (fix)
Home

[freeciv-ai] Re: (PR#2755) AI hangs at modified rulesets (fix)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: coppensbart@xxxxx
Subject: [freeciv-ai] Re: (PR#2755) AI hangs at modified rulesets (fix)
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Thu, 19 Jun 2003 10:21:02 -0700
Reply-to: rt@xxxxxxxxxxxxxx

On Wed, 18 Jun 2003, Guest wrote:
> Following code causes this hang:
> while (distance >= move_rate) {
> Because I have a unit with a movement-rate of 0, this loop will never finish. 
> Tested
> with succes using freeciv 1.14:
> at line 254 of CVS, add
>
> if (move_rate != 0) {
>
> and add an indent to each following line, until line 276, where this if is 
> ended with an
> extra '}'.

The attached patch has been committed.

  - Per

Index: ai/advmilitary.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advmilitary.c,v
retrieving revision 1.145
diff -u -r1.145 advmilitary.c
--- ai/advmilitary.c    10 May 2003 18:11:24 -0000      1.145
+++ ai/advmilitary.c    19 Jun 2003 17:16:34 -0000
@@ -240,7 +240,7 @@
 }
 
 /************************************************************************** 
-Compute actual danger depending on move rate of enemy and its distance.
+  Compute actual danger depending on move rate of enemy and its distance.
 **************************************************************************/
 static int dangerfunct(int danger, int move_rate, int distance)
 {
@@ -253,7 +253,7 @@
   danger *= 2;
 
   /* Turns to reach us.. */
-  while (distance >= move_rate) {
+  while (distance >= move_rate && move_rate != 0) {
     danger /= 2;
     distance -= move_rate;
   }

[Prev in Thread] Current Thread [Next in Thread]
  • [freeciv-ai] Re: (PR#2755) AI hangs at modified rulesets (fix), Per I. Mathisen <=