[Freeciv-Dev] Re: [RFC] square_dxy_iterate
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Sat, Feb 23, 2002 at 04:56:45PM +0000, Gregory Berkolaiko wrote:
> --- 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
Choose one.
> > + 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)
It is more expensive. It will only be usefull if diplomacy is
implemented. And if diplomacy gets implemented you have to audit the
whole code (and take the runtime hit). So no.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"Reality? That's where the pizza delivery guy comes from!"
- [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, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate,
Raimar Falke <=
- [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
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Jason Short, 2002/02/23
|
|