Assuming BIT_WATER and BIT_FIRE are not the same bit then
the truth table for
if(bitmap & BIT_WATER) bitmap &= ~BIT_FIRE
is (BIT_WATER, old BIT_FIRE, new BIT_FIRE)
0 0 0
0 1 1
1 0 0
1 1 0
So from a bit perspective that is
BIT_FIRE = (~BIT_WATER)&BIT_FIRE;
1 0 0
1 1 1
0 0 0
0 1 0
Since I dont know the gap between your two bits then something like this which is excessive.
newbit = ((~(bitmap>>BIT_WATER_BIT))&(bitmap>>BIT_FIRE_BIT))&1;
bitmap&=~BIT_FIRE;
bitmap|=newbit<<BIT_FIRE_BIT;
Assuming I didnt make a typo...Also which I assume can be simplified if you take advantage of the specific bit numbers and not do something generic (shift BIT_WATER bit over to land on BIT_FIRE rather than shift everything right then left again. May not make it simpler though.
if bit water bit is 7 and bit fire bit is 3
bitmap = (((~(bitmap>>4))>>4)&(1<<3))&bitmap;
Or maybe this
bitmap = (((bitmap&(~BIT_WATER))^BIT_WATER)>>4)&bitmap;
where >>4 is the direction and delta between BIT_WATER and BIT_FIRE. fill in the proper delta.
bitmap &= ~(bit_fire * static_cast<bool>(bitmap & bit_water));
, but it uses multiplication... – Petr Budnik Sep 13 '13 at 1:00