Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2002:
[Freeciv-Dev] Re: [PATCH] make ai_choice->type enum choice_type (PR#1318
Home

[Freeciv-Dev] Re: [PATCH] make ai_choice->type enum choice_type (PR#1318

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: rf13@xxxxxxxxxxxxxxxxxxxxxx
Cc: Markus Linnala <maage@xxxxxxxxx>, freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [PATCH] make ai_choice->type enum choice_type (PR#1318)
From: Petr Baudis <pasky@xxxxxxxxxxx>
Date: Tue, 12 Mar 2002 20:09:59 +0100

Dear diary, on Tue, Mar 12, 2002 at 08:01:28PM CET, I got a letter,
where Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> told me, that...
> On Mon, Mar 11, 2002 at 11:07:12AM +0100, Petr Baudis wrote:
> > Dear diary, on Sun, Mar 10, 2002 at 05:47:33PM CET, I got a letter, where
> > Markus Linnala <maage@xxxxxxxxx> told me, that...
> > > 
> > > As ai_choice->type is usually of type enum choice_type, make it so. Use
> > > common initialisation function, clear_ai_choice.  aitech.c used type for
> > > something else, so add new field tech_want to ai_choice.
> > 
> > Good thing (tm). However, I believe Ross did something similiar.. and it 
> > looks
> > he did it probably better.
> > 
> > +int init_choice(struct ai_choice *cur)
> > +  static struct ai_choice choice = { A_NONE, 0, CT_NONE };
> > +
> > +  *cur = choice;
> > +  return 1;
> > +}
> > 
> > I happen to like his approach more and also his choice of function name ;).
> 
> *init* is better. The return value is useless. The implementation
> contains a memcpy instead of the three assignments. I prefer the three
> assignments or an initialization in the "new" format:
>  static struct ai_choice choice = { 
>     choice: A_NONE, 
>     want:   0, 
>     type:   CT_NONE 
>   };

Hum.. "new" format.. oh well, after all, why not? :)

void init_choice(struct ai_choice *cur)
{
   static struct ai_choice choice = {
     choice: A_NONE,
     want:   0,
     type:   CT_NONE,
   };

   *cur = choice;
}

-- 

                                Petr "Pasky" Baudis

* elinks maintainer                * IPv6 guy (XS26 co-coordinator)
* IRCnet operator                  * FreeCiv AI hacker
.
"If you have acquired knowledge, what do you lack?
    If you lack knowledge, what have you acquired?"
Lev. R. 1:6
.
Public PGP key && geekcode && homepage: http://pasky.ji.cz/~pasky/


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