Complete.Org: Mailing Lists: Archives: freeciv-ai: August 2002:
[freeciv-ai] Re: ai_military_attack()
Home

[freeciv-ai] Re: ai_military_attack()

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Jordi Negrevernis i Font <jorneg@xxxxxxxxxxx>
Cc: freeciv-ai@xxxxxxxxxxx
Subject: [freeciv-ai] Re: ai_military_attack()
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Mon, 26 Aug 2002 22:37:04 +0000 (GMT)

On Mon, 26 Aug 2002, Jordi Negrevernis i Font wrote:
> >+static struct unit *ai_military_rampage(struct unit *punit, int threshold)
> >+{
> >+int x, y, id = punit->id;
> >+
> >+while (punit && punit->moves_left
> >+       && ai_military_findvictim(punit, &x, &y) >= threshold) {
> >+  ai_unit_attack(punit, x, y);
> >+  punit = find_unit_by_id(id);
> >+}
> >+return punit;
> >+}
> >
>   Be aware that this code does not check to see if the coordinates
> returned by ai_military_findvictim are the same as the unit ones. You
> shouldhave to check that they are diferent or i'll have an assert in
> ai_unit_attack...

As far as I am aware, that should not happen. findvictim should only
return a positive value if it found something to attack _and_ has set
&x, &y to an adjacent tile... am I mistaken?

Yours
Per



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