DEM (file format): Difference between revisions
m (→= dem_consolecmd Format: learn to preview changes...) |
FragMonkey (talk | contribs) (→Frame: Frame IDs for Source 2007 and Left 4 Dead network protocols.) |
||
Line 35: | Line 35: | ||
Each frame begins with 0 or more of these commands: | Each frame begins with 0 or more of these commands: | ||
These are described in hl2sdk\utils\demoinfo\demoformat.h | These are described in hl2sdk\utils\demoinfo\demoformat.h | ||
====Network Protocols 7 and 8==== | |||
{| class=standard-table | {| class=standard-table | ||
! Type || Value | ! Type || Value | ||
Line 53: | Line 55: | ||
|- | |- | ||
| dem_lastcommand || dem_stop | | dem_lastcommand || dem_stop | ||
|} | |||
====Network Protocols 14 and 15==== | |||
{| class=standard-table | |||
! Type || Value | |||
|- | |||
| dem_stringtables || 8 | |||
|- | |||
| dem_lastcommand || dem_stringtables | |||
|} | |||
====Network Protocols 36 and Higher==== | |||
{| class=standard-table | |||
! Type || Value | |||
|- | |||
| dem_customdata || 8 | |||
|- | |||
| dem_stringtables || 9 | |||
|- | |||
| dem_lastcommand || dem_stringtables | |||
|} | |} | ||
Depending on the command that was received, a different action needs to be taken. | Depending on the command that was received, a different action needs to be taken. | ||
====dem_stop | ====dem_stop==== | ||
This is a signal that the demo is over, and there is no more data to be parsed. | This is a signal that the demo is over, and there is no more data to be parsed. | ||
====dem_consolecmd, dem_datatables, dem_usercmd==== | ====dem_consolecmd, dem_datatables, dem_usercmd, dem_stringtables==== | ||
Read a standard data packet, deal with it as necessary. | Read a standard data packet, deal with it as necessary. | ||
Revision as of 20:58, 20 October 2009
DEM, short for demo is the Source demo file format. Used in conjunction with the Source recorder to record demos.

For the purpose of this we will be referring to each collection of events as a frame. This may or may not add up to the number of frames given by the header.
Demo Header
Type | Field | Value |
---|---|---|
String | Header | 7+NULL characters, should be "HL2DEMO" |
Int | Demo Protocol | Demo protocol version, should be '3' |
Int | Network Protocol | Network protocol version number |
String | Server name | 260 characters long |
String | Client name | 260 characters long |
String | Map name | 260 characters long |
String | Game directory | 260 characters long |
Float | Playback time | The length of the demo, in seconds |
Int | Ticks | The number of ticks in the demo |
Int | Frames | The number of frames in the demo |
Int | Sign on length | ? |
Frame
Each frame begins with 0 or more of these commands: These are described in hl2sdk\utils\demoinfo\demoformat.h
Network Protocols 7 and 8
Type | Value |
---|---|
dem_signon | 1 |
dem_packet | 2 |
dem_synctick | 3 |
dem_consolecmd | 4 |
dem_usercmd | 5 |
dem_datatables | 6 |
dem_stop | 7 |
dem_lastcommand | dem_stop |
Network Protocols 14 and 15
Type | Value |
---|---|
dem_stringtables | 8 |
dem_lastcommand | dem_stringtables |
Network Protocols 36 and Higher
Type | Value |
---|---|
dem_customdata | 8 |
dem_stringtables | 9 |
dem_lastcommand | dem_stringtables |
Depending on the command that was received, a different action needs to be taken.
dem_stop
This is a signal that the demo is over, and there is no more data to be parsed.
dem_consolecmd, dem_datatables, dem_usercmd, dem_stringtables
Read a standard data packet, deal with it as necessary.
dem_synctick, dem_signon, dem_packet
Ignore.
Standard Data "Packet"
Any time there is more than one byte to be read in, a standard format is used.
This begins with an integer that has the number of bytes in this packet.
Example code to handle this:
int ReadData(char **buffer) { int len; fread (&len,sizeof(int),1,fDemo); if (len > 0) { *buffer = new char[len]; fread(*buffer,len,1,fDemo); } return len; }
dem_consolecmd Format
{ int console_cmd; // 0x40000000 (32 bit int, big endian) char pad; // 0x00 (Unknown function) int len; // Size of C string (32 bit int, big endian) *buffer = new char[len]; // Null terminated C string containing text input into the console e.g. "net_graph 1\000" }