Difference between revisions of "Command Sequences"

From Valve Developer Community
Jump to: navigation, search
(Add documentation for CmdSeq.wc)
 
m (Added note about command struct differing on separate branches. (integer/char))
 
Line 26: Line 26:
 
<source lang="cpp">struct Command
 
<source lang="cpp">struct Command
 
{
 
{
char is_enabled; // 0/1, If command is enabled.
+
char is_enabled; // 0/1, If command is enabled. NOTE: CS:GO's branch of hammer uses an integer value here instead of a character.
 
int special;
 
int special;
 
char executable[260]; // Name of EXE to run.
 
char executable[260]; // Name of EXE to run.

Latest revision as of 19:01, 15 March 2019


The bin/CmdSeq.wc file defines the expert compilation options for Hammer. There are two versions currently in use. All strings are fixed width, with a null character at the end of the used data. Hammer strangely fills the remainder of the data with random memory contents.

struct Header
{
	char signature[31];  // Worldcraft Command Sequences\r\n\x1a
	float version;
	unsigned int seq_count;
	Sequence sequences[];
}

The signature contains "Worldcraft Command Sequences", followed by a carriage return, newline, and Control-Z (byte 26). The version is a floating-point number, 0.1 or 0.2. This is followed by seq_count sequence structs, one for each compile preset defined:

struct Sequence
{
	char name[128];
	unsigned int command_count; // Number of commands
	Command commands[];
}

Each sequence contains a number of commands:

struct Command
{
	char is_enabled; // 0/1, If command is enabled. NOTE: CS:GO's branch of hammer uses an integer value here instead of a character.
	int special;
	char executable[260]; // Name of EXE to run.
	char args[260]; // Arguments for executable.
	int is_long_filename; // Obsolete, but always set to true. Disables MS-DOS 8-char filenames.
	int ensure_check; // Ensure file post-exists after compilation
	char ensure_file[260]; // File to check exists.
	int use_proc_win; // Use Process Window (ignored if exectuable = $game_exe).

	// V 0.2+ only:
	int no_wait;  // Wait for keypress when done compiling.
}

If special is not 0, the executable is not used. Instead a builtin command is run:

Value Command Arguments
256 Change Directory Location
257 Copy File Source Destination
258 Delete File Path
259 Rename File Old New

VBSP, VRAD, VVIS or the game are normal commands using a replace parameter.

Replacement parameters

Commnand names and arguments can use a replacement syntax, following the form $var. These arguments are quoted up until the first space after the parameter (so $file.$ext is quoted in one piece, but $file $ext will produce two sets of surrounding quotes).

Parameter Result
$$ Literal $ sign.
$file Map filename.
$ext Extension of map (vmf, vmm).
$path Full path to folder containing the map, with no trailing slash.
$exedir Path to the location of the game EXE.
$bspdir Location to place BSPs in, set in Build Programs.
$bsp_exe Location of VBSP, set in Build Programs.
$vis_exe Location of VVIS, set in Build Programs.
$light_exe Location of VRAD, set in Build Programs.
$game_exe Location of the game executable, set in Build Programs.
$gamedir Folder containing Gameinfo.txt.