Spawnflags

From Source Entities
Jump to navigation Jump to search

Spawnflags are a collection of boolean variables that are condensed into a single integer. Each boolean is assigned a number value equal to a power of two. When combinations of these numbers are added together, they will never equal the same number as another combination.

This condensation can save the game a large amount of memory. 20 entities with 10 booleans each equals 200 variables that must be individually checked. 20 entities with 1 integer each is only 20 variables to process.

The engine stores flags through a keyvalue called spawnflags.

Bug: In Hammer, if an entity gets flag data from multiple locations in an FGD, Hammer will only read the "checked by default" data from the last spawnflags keyvalue it looked at. i.e. trigger_look will not have Clients checked by default.