DEM (file format): Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (Robot: Automated text replacement (-\{\|\r +{| class=standard-table))
Line 3: Line 3:
For the purpose of this, I 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.
For the purpose of this, I 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===
 
===Заголовок Демо===
{| class=standard-table
{| class=standard-table
! Type || Field || Value
! Тип || Поле || Значение
|-
|-
| [[String]] || Header || 7+NULL characters, should be "HL2DEMO"
| [[String]] || Заголовок || 7+NULL characters, should be "HL2DEMO"
|-
|-
| [[Int]] || Demo Protocol || Demo protocol version, should be '3'
| [[Int]] || Демо Протокол || Версия протокола демо, например '3'
|-
|-
| [[Int]] || Network Protocol || Network protocol version number
| [[Int]] || Протокол Сети || Версия Сетевого протокола
|-
|-
| [[String]] || Server name || 260 characters long
| [[String]] || Имя Сервера || Длиной в 260 символов
|-  
|-  
| [[String]] || Client name || 260 characters long
| [[String]] || Имя клиента || Длиной в 260 символов
|-
|-
| [[String]] || Map name || 260 characters long
| [[String]] || Имя Карты || Длиной в 260 символов
|-
|-
| [[String]] || Game directory || 260 characters long
| [[String]] || Директория Игры  || Длиной в 260 символов
|-
|-
| [[Float]] || Playback time || The length of the demo, in seconds
| [[Float]] || Время игры || Продолжительность записи Демо, в секундах
|-
|-
| [[Int]] || Ticks || The number of ticks in the demo
| [[Int]] || Ticks || The number of ticks in the demo

Revision as of 22:44, 28 January 2009

Note that it is not possible to edit what happens in a Source demo, it basically stores the packets right off the wire, and we don't know the packet format.

For the purpose of this, I 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.


Заголовок Демо

Тип Поле Значение
String Заголовок 7+NULL characters, should be "HL2DEMO"
Int Демо Протокол Версия протокола демо, например '3'
Int Протокол Сети Версия Сетевого протокола
String Имя Сервера Длиной в 260 символов
String Имя клиента Длиной в 260 символов
String Имя Карты Длиной в 260 символов
String Директория Игры Длиной в 260 символов
Float Время игры Продолжительность записи Демо, в секундах
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

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

Depending on the command that was received, a different action needs to be taken.

dem_stop, dem_lastcommand

This is a signal that the demo is over, and there is no more data to be parsed.

dem_consolecmd, dem_datatables, dem_usercmd

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;
}