Pure Servers
A 'pure server' is a server that forces all clients on the server to use content that matches what is on the server. This way, clients who are playing on the server cannot cheat by modifying the game content.
Without pure servers, clients could modify their materials, sounds, and models to give them advantages in the game. They might allow themselves to see through walls, make enemy models larger or brighter, or make certain sounds louder, thus giving them an advantage while playing.
Basic Usage
To use pure server mode on a server, set the sv_pure console variable to 1 or 2. Then, on the next map change, the server will ensure that the content (materials, models, and sounds) on client machines matches the content on the server. The differences between modes 1 and 2 are discussed later on.
By default, the server will kick clients that are using content that is different from the content the server wants to enforce. If a server only wants to give clients a warning or see which clients are using "impure" content, it can set sv_pure_kick_clients to 0.
Mode 1
The list of content that the server enforces is specified in a file called pure_server_whitelist.txt, which is contained in the server's hl2 directory. The server can edit this file to change which content clients are allowed to modify. For example, the server could specify in this file that clients are allowed to modify sounds, but not materials or models. Note: clients do not open pure_server_whitelist.txt, so they cannot hack around the server's usage of the file by editing it.
Mode 2
All game content is required to be from steam. This is identical to have sv_pure set to 1 and setting everything in the whitelist file to from_steam
Whitelist File Format
The pure_server_whitelist.txt file specifies attributes for groups of files. Each line specifies one file or a group of files and the attributes for those files. Here is an example line:
materials\... from_steam
The first part ('materials\...') specifies the files. In this case, it is specifying all files under the materials directory, recursively. The second part ('from_steam') specifies the attributes to apply to those files. In this case, it is saying that all of those files must come from Steam. So if clients have custom content in their materials directories, that content will not be used, and the content from their Steam caches will be used instead.
There are three ways to specify a file group.
1. Filename only. This mode only specifies one file.
Ex: materials\models\props\cs_assault\wirepipe.vtf
2. All files in a certain directory.
Ex: materials\models\props\cs_assault\*.*
3. All files in a certain directory as well as all files in directories below that directory (i.e. all files recursively).
'Ex: materials\models\...'
There are three ways to specify an attribute.
1. from_steam. This forces clients to load this set of files from the Steam cache even if they have custom content on disk.
2. allow_from_disk. If this attribute is specified, then clients can load the specified files from disk. They also don't have to match the content on the server. So these files are totally unprotected.
3. allow_from_disk+check_crc. If this attribute is specified, the clients can load the specified files from disk, but their on-disk files must match the files on the server.
Examples
materials\models\player\... allow_from_disk sounds\... from_steam models\MyMod\... allow_from_disk+check_crc materials\MyMod\Customizable\*.* allow_from_disk materials\models\props\cs_assault\wirepipe.vtf from_steam
Default Attributes
If sv_pure is set to 1, the default attribute for all files is allow_from_disk. So if you had an empty pure_server_whitelist.txt file and you set sv_pure to 1, there would be no difference from sv_pure 0. Note: The default pure_server_whitelist.txt file that ships with the Source Engine does in fact have settings, so even if you don't modify the default pure_server_whitelist.txt file, sv_pure 1 will still enforce most content.
Default pure_server_whitelist.txt File
The default pure_server_whitelist.txt file that ships with the game looks like this. If you want to begin making changes to the whitelist file, you can start with this.
whitelist { // // 3 modifiers are allowed on file specifications: // // from_steam - only check the Steam cache for the file (ignore anything on disk) // allow_from_disk - allow the file to come from disk // check_crc - used with allow_from_disk - server does CRC checks on the client's file to make sure it matches // // The default modifier on all files is allow_from_disk. Thus, all files can come from disk and don't need CRC checks unless // allow_from_disk can be set at the same time as check_crc. Use the + character in between them to signify this: allow_from_disk+check_crc. // // Three types of file specifications: // // 1. directory\*.* - refers to all files under the directory // 2. directory\... - refers to all files under the directory and all directories under that (recursively) // 3. directory\filename - refers to a single file // // By default, when in pure server mode, most content file types are only allowed to come from Steam. // materials\... from_steam models\... from_steam sound\... from_steam // // Allow custom player models. Don't do CRC checks on them because the clients may all // have different custom models and the server won't have them all. // models\player\... allow_from_disk materials\models\player\... allow_from_disk // // Allow custom spray decals. // materials\temp\... allow_from_disk materials\vgui\logos\... allow_from_disk materials\vgui\logos\ui\... allow_from_disk // // (Uncomment and edit these for mods). // Allow mod resources to come from disk. // // materials\mymod\... allow_from_disk+check_crc // models\mymod\... allow_from_disk+check_crc // sound\mymod\... allow_from_disk+check_crc }
Stacking
The attributes for files are applied in top-down order in the pure_server_whitelist.txt file. This way, you can apply one attribute to a large set of files and a different attribute to a subset of those files. For example, if you wanted to force all models to come from Steam except the models under models\MyMod, you could add these lines to your pure_server_whitelist.txt file:
models\... from_steam models\MyMod\... allow_from_disk+check_crc
Advanced Usage
If you set sv_pure to 2, then the server will not even load the pure_server_whitelist.txt file. Instead, it will apply the from_steam attribute to all materials, models, and sounds. This can be useful for competitive matches where one team is hosting the game. The team who is not hosting the game can look in their console at round start and see which sv_pure mode the server is using. If the server is using sv_pure 2, then the non-hosting team can know that the players on the hosting team are not using custom content.
Performance
There are two places where sv_pure will affect performance.
1. When the server loads its first map with sv_pure set to 1, it has to precalculate file CRCs for all files marked as allow_from_disk+check_crc. Generally, this set of files should be set to the minimal set of files. If, for example, the pure_server_whitelist.txt file had a line like this:
materials\... allow_from_disk+check_crc
The server would pause for a very long time the first time it loaded a map because it would calculate CRCs for every single material file in the game.
Setting sv_pure to 2 will not affect server performance because the server does not need to calculate CRCs.
2. When a client loads a map and the value of sv_pure has changed, the client will reload any content necessary to make sure it is obeying the pure server's rules. So if the client had many materials, models, and sounds that were customized on a previous server and then connected to a pure server, the client would have to reload all those materials, models, and sounds.
Generally, the performance hit on the client is negligible because the client will only flush out a few files when connecting to a pure server.
Other Notes
In most cases, even clients who have modified content sitting on their disk are still allowed to play on a pure server. The Source Engine will ensure that the content from Steam (instead of the content from their disk) is used when a client plays on a pure server. This way, clients don't have to wade through their game directories to clean out old content before they play on a pure server. Instead, they just join servers and the correct allowed content is automatically used.