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: Tue, 12 Mar 2002 20:01:28 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

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"


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