Quote:
Originally Posted by MasterOfTheXP
Though granted, that would work, considering that checks if buttons & IN_ATTACK is equal to 1 (true), and IN_ATTACK is, coincidentally, 1 (1 << 0). But it can just be shortened to if (buttons & IN_ATTACK).
|
Quote:
Originally Posted by Mitchell
You probably didnt read it right then.
As Master pointed out the correct way.
|
Quote:
Originally Posted by Powerlord
SourcePawn lets you get away with doing it that way (because non-zero values are considered to be true), but it won't work in programming languages with a strict type system.
|
No, it's not the same thing. If IN_ATTACK was 0 the check would fail. No one is crazy enough to have bitflags that are zero, so in practice you can just do if (var & FLAG).
Quote:
The method Merbo used is the correct cross-language way to do it.
|
In what language does if (var & FLAG == FLAG) differ from if (var & FLAG), provided you don't have flags that are set to zero?