Valve Data Format

From girlwiki
Jump to: navigation, search

Valve Data Format (VDF) files are key-value stores used by Source games and Steam.

Text VDF

Most VDF files you'll see are text-based. The spec is pretty well-defined on the Valve Developer Community wiki.

"ParentElem"
{
    "Key1" "1.25"
    "Key2" "String of text"
    "ChildElem"
    {
        "Key3" "15"
        // and so on
    }
}

Compiled VDF

In some cases, the VDF will be in a "compiled" form.[1] Each entry is in the following format:

   <type> <key> <value>

type is exactly one byte, and appears to be related to the following enum:[2]

enum types_t
{
	TYPE_NONE = 0,
	TYPE_STRING,
	TYPE_INT,
	TYPE_FLOAT,
	TYPE_PTR,
	TYPE_WSTRING,
	TYPE_COLOR,
	TYPE_UINT64,
	TYPE_NUMTYPES, 
};

The key is always a null-terminated string. Arrays appear to be emulated with numeric strings; e.g., "0", "1", "2", ....

The value format is determined by the type. All values are little endian.

Type Data format
0x00 (TYPE_NONE) Represents a nested key-value map. The "value" is the first entry onward. All maps (including the "root" map) must be terminated with 0x08.
0x01 (TYPE_STRING) Null-terminated string.
0x02 (TYPE_INT) Little-endian 32-bit (unsigned?) integer.

Any types not mentioned above haven't been encountered, and I don't know if they exist in "compiled" form.

Notes

  1. As far as I've seen, this is only really with shortcuts.vdf.
  2. From ValveSoftware/source-sdk-2013 on Github.