[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]
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
};
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"Premature optimization is the root of all evil."
-- D. E. Knuth in "Structured Programming with go to Statements"
|
|