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: Petr Baudis <pasky@xxxxxxxxxxx>
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: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 13 Mar 2002 11:47:23 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Tue, Mar 12, 2002 at 08:09:59PM +0100, Petr Baudis wrote:
> 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;
> }

To be honest I prefer the three assignments over the
initialization. This static variable with initialization and the
single struct assignment is just exotic.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
    1) Customers cause problems.
    2) Marketing is trying to create more customers.
  Therefore:
    3) Marketing is evil.


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