wiki:SC2ReplayFormat

Version 3 (modified by mseifert, 11 years ago) (diff)

Added information on actions

Sc2Replay

WARP currently supports the extraction of the following information from .SC2Replay files:

  • Player name
  • Player race
  • Player color
  • Game duration
  • Game version
  • Chat log
  • Map preview

The following is a documentation of SC2Replay files.

File Structure

SC2Replay files contain an mpq archive with 8 files. The archive starts at an offset of 1024 bytes. The types used in this documentation are:

TypeDescription
int8A single byte.
int16Two bytes.
int32Four bytes.
stringOne byte that represents the length of the following string. The string has as many characters, as the byte's value
bytesXA number of bytes whose functions and grouping are unknown, where X represents the number of bytes.

All types are Big-Endian.

replay.info

This file contains information about the players and the game in general. All offsets are relative to the described block, unless specified otherwise.

The first part of this file simply stores the player names.

OffsetTypeDescription
0x00int8 Number of player names that are contained in this block. This value usually is 0x10 i.e. 16.

Now, for each player, the entry looks the following:

OffsetTypeDescription
0x00stringPlayer name.
stringLengthbytes5Unknown.

The unknown values always seem to be 0, except for the last two players. The name of the second last player is always an empty string, the name of the last player is always "Dflt".

The player block is followed by:

OffsetTypeDescription
0x00bytes9Unknown. Probably something that has to do with the map.
0x09stringSome kind of checksum or hash. Usually 76 bytes long (75 without the length indicator of the string).

replay.game.events

This file stores all actions the players have ordered.

An action looks like the following:

OffsetTypeDescription
0x00time informationGives information about the time offset of an action to the preceding action. Equivalent to the time information in the chat log.
time informationbyteUnknown.
time information + 1byteAction code.
time information + 2bytesXBytes storing information on the respective action. The size seems to depend on the action code.

Action codes:

Action codeIn-game action
0x0BUsage of any kind of ability or assignment of orders. Includes constructing buildings, training units, moving, attacking, gathering resources, and so on.
0x81Movement of the screen.
0xACSelection or deselection.

To distinguish abilities or orders, a 3 byte identifier for each order is used. These 3 bytes will be called the "ability code":

Ability codeAbility
0x020400Stop
0x020600Move
0x020601Patrol
0x020602Hold position
0x020900Attack
0x050500Set way point
0x060400Gather
0x060401Return cargo
0x060401Cancel
0x060D01Build Supply Depot
0x060D02Build Refinery
0x080700Train SCV

Simply right clicking on an object in order to attack, gather resources, or move, depending on what is the default action, occupies a special ability code:

Ability codeAbility
0xFFFF0FRight click action