[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 Sat, Feb 23, 2002 at 04:10:14PM +0000, Gregory Berkolaiko wrote:
> >
> > But first of all, do you understand what this fuction tries to achieve?
>
> No. Not at all at the time I wrote the first version.
>
> Second version attached. Slower but correct and with comments.
Ah, much better.
Generally I think it can go in, but I have a couple of suggestion first:
>
> +static void invasion_funct(struct unit *punit, bool dest, int radius,
> + int which)
> +{
> int x, y;
> - if (dest) { x = punit->goto_dest_x; y = punit->goto_dest_y; }
> - else { x = punit->x; y = punit->y; }
flag isn't the most explanatory of names.
how about willing_to_attack
or
will_fight_if_needed
> + bool flag = (dest || punit->activity != ACTIVITY_GOTO);
> +
> + 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) {
> + square_iterate(x, y, radius, 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;
> +
pcity->owner != punit->owner assumes that we'd attack anyone we see.
but we should really be only attacking enemies (which is the same in current
situation). how about using is_enemy_city_tile instead of map_get_city above?
(here is_enemy_city_pos(x,y) would be useful)
> + if (pcity && pcity->owner != punit->owner
> + && (pcity->ai.invasion & which) != which &&
> + (flag || !has_defense(pcity))) {
> + pcity->ai.invasion |= which;
> + }
> } 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, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Raimar Falke, 2002/02/23
- [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, 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
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Jason Short, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Raimar Falke, 2002/02/23
|
|