Complete.Org: Mailing Lists: Archives: freeciv-ai: May 2004:
[freeciv-ai] Re: (PR#8740) segmentation fault in ai_hunter_findjob
Home

[freeciv-ai] Re: (PR#8740) segmentation fault in ai_hunter_findjob

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: vasc@xxxxxxxxxxxxxx
Subject: [freeciv-ai] Re: (PR#8740) segmentation fault in ai_hunter_findjob
From: "Per Inge Mathisen" <pim@xxxxxxxxxxxx>
Date: Sat, 15 May 2004 09:18:29 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=8740 >

On Fri, 14 May 2004, Vasco Alexandre da Silva Costa wrote:
> I assume it crashes because here:
>     /* We can't chase if we aren't faster or on intercept vector */
>     if (unit_type(punit)->move_rate < unit_type(target)->move_rate
>         && dist1 >= dist2) {
>       UNIT_LOG(LOGLEVEL_HUNT, punit, "can't get to %s(%d, %d) was (%d,
> %d)",
>                unit_type(target)->name, target->x, target->y,
>                target->ai.prev_pos->x, target->ai.prev_pos->y);
>       continue;
>     }
>
> target->ai.prev_pos is NULL and you are unreferencing it.

Uh, yes. That is an overeager comment right there.

--- ai/aihunt.c 4 May 2004 17:40:25 -0000       1.3
+++ ai/aihunt.c 15 May 2004 16:15:45 -0000
@@ -299,9 +299,11 @@
       /* We can't chase if we aren't faster or on intercept vector */
       if (unit_type(punit)->move_rate < unit_type(target)->move_rate
           && dist1 >= dist2) {
-        UNIT_LOG(LOGLEVEL_HUNT, punit, "can't get to %s(%d, %d) was (%d, %d)",
-                 unit_type(target)->name, target->x, target->y,
-                 target->ai.prev_pos->x, target->ai.prev_pos->y);
+        UNIT_LOG(LOGLEVEL_HUNT, punit, "giving up racing %s (%d, %d)->(%d, 
%d)",
+                 unit_type(target)->name,
+                 target->ai.prev_pos ? target->ai.prev_pos->x : 0,
+                 target->ai.prev_pos ? target->ai.prev_pos->y : 0,
+                 target->x, target->y);
         continue;
       }
       unit_list_iterate(ptile->units, sucker) {

Committed.

  - Per




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