Flag

From QuakeQEWiki
Revision as of 06:59, 17 February 2022 by Teamred (talk | contribs) (Created page with "Vanilla Quake-C files make ample use of binary flags for entity properties as disparate as whether the entity is touching the ground to which weapons a player possesses. Binary flags can be thought of as a bunch of switches that are either on or off pushed up next to each other. The weapons are a great example of this: {| class="wikitable" |+ !item flag-constant !integer value !2 !binary value |- |IT_SHOTGUN |1 |2^0 |<code>0000 0001</code> |- |IT_SUPER_SHOTGUN |2 |2^1...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Vanilla Quake-C files make ample use of binary flags for entity properties as disparate as whether the entity is touching the ground to which weapons a player possesses.

Binary flags can be thought of as a bunch of switches that are either on or off pushed up next to each other. The weapons are a great example of this:

item flag-constant integer value 2 binary value
IT_SHOTGUN 1 2^0 0000 0001
IT_SUPER_SHOTGUN 2 2^1 0000 0010
IT_NAILGUN 4 2^2 0000 0100
IT_SUPER_NAILGUN 8 2^3 0000 1000
IT_GRENADE_LAUNCHER 16 2^4 0001 0000
IT_ROCKET_LAUNCHER 32 2^5 0010 0000
IT_LIGHTNING 64 2^6 0100 0000