tags:

views:

18

answers:

1

I have been using a bitwise comparison to check if entities and maptiles have flags in a roguelike game, but I've run into a problem - I need to check in an if() if a tile/ent doesn't have a flag, but I can't figure out how to do it without using an empty if() {} and else { condition; }, an example being:

if(Tile->Flags & TILE_INVIEW) {} else { attron(A_DIM); }

or

if(Tile->Flags & TILE_RENDER) {} else { SetTileFlags(GetTileFlags() + TILE_RENDER); }

Is there a cleaner way to do this?

+2  A: 

Just reverse your condition:

if(!(Tile->Flags & TILE_INVIEW)) {
    attron(A_DIM);
}

There is a not operator :)

Joey
Thanks. I thought it might be the ! operator, I just didn't use it correctly.
Shawn B