[Freeciv-Dev] Re: [RFC] x & (1u << y)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Wed, Feb 13, 2002 at 12:04:59PM +0200, Petrus Viljoen wrote:
> Raimar Falke wrote:
>
> > There are a lot of constructs like "x & (1u << y)" in the code:
> > - city options, flags and roles
> > - shared vision
> > - embassy
> > - claims
> > - gotohand
> > - known and sent in maphand
> >
> > These all are used as a bool but aren't a bool. Should they be wrapped
> > with BOOL_VAL, a new test_bit or with functions specific to the
> > domains above?
> >
> > Raimar
>
> Why not change the flags to structs like
>
> struct foo {
> int can_build_t1 : 1; /* This is a one bit int (0 | 1) */
> int can_build_t2 : 1;
> ....
> }
Does only work for the first one. The others are indexed by player_no
or similar.
> then you can use .
>
> if (foo_var.can_build_t1 == TRUE) ....
s/ == TRUE//
> etc..
>
> It should make code more readable than "x & (1u << y)"
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"Sit, disk, sit. Good boy. Now spin up. Very good. Here's a netscape
cookie for you. Fetch me some data. Come on, you can do it. No, not that
data. Bad disk. Bad."
-- Calle Dybedahl, alt.sysadmin.recovery
|
|