Skip to main content

Messages

Demo messages are stored in sequential order as the engine records them. A message always starts with a tagged type followed by the current session tick, a slot index and the type-specific message data.

NameTypeSize in bytesSize in bitsValue
TypeMessageType18-
Tick1int432-
SlotNE 2byte18-
DataMessageData---
1 Old engines might not even include the message tick after the stop byte.

2 The term slot here refers to the selected split-screen index. This byte is only used in engines which support split-screen mode.

Types

TypeValueDescription
SignOn1-
Packet2-
SyncTick3-
ConsoleCmd4-
UserCmd5-
DataTables6-
Stop7-
CustomData8-
StringTables98 for old engine.

Pseudocode Example

To keep this example simple the stop message might contain additional data which is not read here. We also ignore the fact that that reading past the buffer might be possible when parsing corrupted demos.

loop {
let message_type = read_le_i8();

if message_type == 0x07 {
break;
}

let tick = read_le_i32();
let slot = read_le_i8();

read_message_data(message_type);
}