[Freeciv-Dev] Re: [RFC] square_dxy_iterate
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
--- Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
> On Fri, Feb 22, 2002 at 06:04:45PM -0500, Jason Short wrote:
> >
> > Another question to think about here is whether the algorithm of
> > invasion_funct can be improved.
>
> Indead. See attached patch.
>
> Raimar
Tell us the truth, you didn't even try to compile it, did you?
But first of all, do you understand what this fuction tries to achieve?
If yes, please comment it.
> ===================================================================
> RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v
> retrieving revision 1.176
> diff -u -r1.176 aiunit.c
> --- ai/aiunit.c 2002/02/22 13:14:38 1.176
> +++ ai/aiunit.c 2002/02/22 23:21:21
> @@ -604,14 +604,28 @@
> static void invasion_funct(struct unit *punit, bool dest, int n, int which)
> {
> int x, y;
> - if (dest) { x = punit->goto_dest_x; y = punit->goto_dest_y; }
> - else { x = punit->x; y = punit->y; }
> + bool flag = (dest || punit->activity != ACTIVITY_GOTO);
> +
what is this if below supposed to mean?
> + if ((pcity->ai.invasion & which) == which) {
> + return;
> + }
>
> + if (dest) {
> + x = punit->goto_dest_x;
> + y = punit->goto_dest_y;
> + } else {
> + x = punit->x;
> + y = punit->y;
> + }
> +
> square_iterate(x, y, n, i, j) {
> struct city *pcity = map_get_city(i, j);
> - if (pcity && pcity->owner != punit->owner)
> - if (dest || punit->activity != ACTIVITY_GOTO || !has_defense(pcity))
> - pcity->ai.invasion |= which;
> +
> + if (pcity && pcity->owner != punit->owner
> + && (flag || !has_defense(pcity))) {
> + pcity->ai.invasion |= which;
> + return;
> + }
> } square_iterate_end;
> }
>
>
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
- [Freeciv-Dev] [RFC] square_dxy_iterate, Raimar Falke, 2002/02/22
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Jason Short, 2002/02/22
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Raimar Falke, 2002/02/22
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate,
Gregory Berkolaiko <=
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Raimar Falke, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Gregory Berkolaiko, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Raimar Falke, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Gregory Berkolaiko, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Raimar Falke, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Gregory Berkolaiko, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Petr Baudis, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Raimar Falke, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Petr Baudis, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Raimar Falke, 2002/02/23
|
|