Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2002:
[Freeciv-Dev] Re: unit type iterate
Home

[Freeciv-Dev] Re: unit type iterate

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: unit type iterate
From: Jason Short <vze2zq63@xxxxxxxxxxx>
Date: Mon, 04 Mar 2002 12:32:42 -0500
Reply-to: jdorje@xxxxxxxxxxxx

Tony Stuckey wrote:
On Mon, Mar 04, 2002 at 05:28:47AM -0500, Jason Short wrote:

Gregory Berkolaiko wrote:

Hey you iterate wizards.  How about making unit_type_iterate.
Here's grep to help you:

Are we talking about something like

#define unit_type_iterate(id) {                  \
  int id;                                        \
  for (id = 0; id < game.num_unit_types; id++) {

or something a bit more forward-thinking (and slower) like

#define unit_type_iterate(id, type) {            \
  int id;                                        \
  for (id = 0; id < game.num_unit_types; id++) { \
    struct unit_type *type = get_unit_type(id);

or even something completely forward-thinking (and currently useless) like

#define unit_type_iterate(type) {                   \
  int _id;                                          \
  for (_id = 0; _id < game.num_unit_types; _id++) { \
    struct unit_type *type = get_unit_type(_id);


        You might want to explain the particular reasons for choosing each
of these.

Well, Raimar said he eventually wanted to replace unit type id with struct unit_type *. Presumably he has his reasons. Certainly I can see that it would make many/most calculations easier, since they're all going to have to dereference the unit_type at some point anyway. It's also consistent with the player_id->struct player * change.

After looking at some of this code, I think such a change would have to be done from the bottom up. First the low-level functions need to be changed to accept a struct unit_type instead of a unit_type id.

jason



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