Thread: Anti W+M1
View Single Post
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 03-15-2013 , 22:06   Re: Anti W+M1
Reply With Quote #9

Quote:
Originally Posted by MasterOfTheXP View Post
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 View Post
You probably didnt read it right then.
As Master pointed out the correct way.
Quote:
Originally Posted by Powerlord View Post
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?
Seta00 is offline