Replay file format
From RacerWiki
A replay is a sampling of a race. During a race, Racer periodically stores the current state of each car, plus other relevant data, in a memory buffer. The sampling frequency is usually 10 times per second. When you save the replay, the buffer is written to a file.
Replay files are written in a "chunked" format: after the file header, the file is just a sequence of chunks of bytes, each chunk preceded by it size. Each chunk is a sequence of commands (indicating the type of data that follows) plus a number of bytes, whose meaning depends on the command.
The file format version is stored in the header. Version 1.1 was used until Racer 0.5.2. beta 8.7. From beta 8.8, format version 2.1 is used.
Contents |
File Header
| Field | Data type and size | Remarks |
| Marker | string, 4 | "RPLY" |
| Minor version | shortint | Second part of the file format version |
| Major version | shortint | First part of the file format version |
| Track name | string, 64 | Name of the track's subdirectory |
| Number of cars | integer | |
| Car name | string, 64 | Name of the car's subdirectory. Repeated for each car. |
| Marker | string, 4 | "DATA" |
Chunks
| Field | Data type and size | Remarks |
| Chunk size | shortint | Number of bytes in this chunk |
| Time | integer | Time from start of replay, in milliseconds |
Commands
Each command is a shortint. The bytes that follow are:
| Number | Meaning | Followed by |
| 0 | Set current car |
|
| 1 | Set position (obsolete) | |
| 2 | Car state for the current car |
|
| 3 | End of replay (obsolete or unused) | |
| 4 | Smoke particle spawn |
|
| 5 | Start of skid strip |
|
| 6 | Point of skidmark |
|
| 7 | End of skid strip |
|
| 8 | Skid volume (obsolete or unused) | |
| 9 | Car enters game |
|
| 10 | Crossing start/finish (obsolete or unused) | |
| 11 | Crossing a timeline (obsolete or unused) |
Remarks
- The numbers in the file are stored in "little-endian" order, so Racer for the Mac has to reverse the byte order when reading/writing replay files. Strings are zero-terminated, single-byte character strings. Integers are 4 bytes wide, shortint are 2 bytes, and floats are 4 bytes.
- In format version 1.1, the car speed is only 1 float (scalar instead of 3-dimensional vector), and brake light, skid factor and gear are not present.
