Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2003:
[Freeciv-Dev] Re: (PR#4465) a government_iterate macro
Home

[Freeciv-Dev] Re: (PR#4465) a government_iterate macro

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#4465) a government_iterate macro
From: "Raimar Falke" <m~rmZVtvSU~uXNcE$-RG*@rf.risimo.net>
Date: Mon, 30 Jun 2003 13:59:47 -0700
Reply-to: rt@xxxxxxxxxxxxxx

On Sun, Jun 29, 2003 at 08:57:31PM -0700, Jason Short wrote:
> 
> We have iterators for everything else; why not governments types too? 
> It makes things slightly more readible and less error-prone.
> 
> As a side effect I moved the government index initialization in with the
> allocation, since the index values may be used outside of
> get_government_from_name.  In theory we should probably always pass
> around government pointers instead of IDs, though.

Applied. However I change the iterate to use get_government and moved
the assert into the function. I have also removed the changes to
gui-gtk. All guis have the same code in this respect and a better
solution should be found. So instead of doing:

  for (i = 0; i < game.government_count; i++) {
    if (i == game.government_when_anarchy) {
      continue;
    }

    if (can_change_to_government(game.player_ptr, i)) {
      /* ... */
    } else {
      /* ... */
    }
  }

the guis should call a function which returns:

  struct {
    struct government *gov;
    bool available;
  } [...];

This will simplify the gui code IMHO.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "If at first you don't succeed... well so much for skydiving."



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