Skip to content

Event Information Database

Mischanix edited this page Aug 8, 2012 · 14 revisions

Overview

The event information database aims to provide a means to modify the way ability and unit types are handled independent of the actual source code of the replay parser. This requires it to provide information on how all the possible build numbers, CUnit type ids, and CAbil type ids translate to the UnitType, AbilityType, and EventType enums.

A default database will be compiled and embedded into the DLL. A database can also be put in the application path to override the default. The SQLite database can be found in the source at Starcraft2.ReplayParser.DataCompiler/sc2replay.sqlite

SQLite tables

The uncompiled format of the data is SQLite tables. These tables are compiled and translated into small binary lookup tables for each effective build number for typeId-relayed information, and build_info is translated into a binary dictionary.

ability_type

  • ability_type: build number, typeId, CAbil string

Map build number and typeId to a CAbil

CAbil string can, if needed, have a version suffix, but it must map to an entry in abil_info

unit_type

  • unit_type: build number, typeId, CUnit string

Map build number and typeId to a CUnit

CUnit string shouldn't ever need to be disambiguated, because all we need to give information on is the name of the unit, which is directly linked to the id across all versions.

event_type

  • event_type: AbilityType, EventType

Map an enum AbilityType to an enum EventType, allowing us to distinguish abilities between micro, macro, etc. in the case of non-default abilities

unit_subgroup_priority

  • unit_subgroup_priority: UnitType, priority

Map an enum UnitType to a subgroup priority, allowing us to determine which units the subgroup index given in each Selection (0x1c) event refers to

abil_info

  • abil_info: CAbil string (unique), (32 columns) AbilityType

Map a CAbil entry to the 32 possibilities of the 5 bits provided in the Ability event (0x1b)

Sample row

'FleetBeaconResearch', 'ResearchFluxVanes', 'ResearchCarrierWeaponSpeed', 'ResearchPhoenixRange',,,,,,,,,,,,,,,,,,,,,,,,,,,,'CancelResearch',

unit_info

  • unit_info: CUnit string (unique), UnitType

Map a CUnit entry to an enum UnitType

build_info

  • build_info: raw build int (unique), effective build number

Map a replay's build number to an effective build number. Many builds share the same CAbil and CUnit indices, for example across patch version numbers (e.g. all builds in 1.2.* have the same indices). This allows us to tell the parser that a certain build number shares the same data as another build.

Create statements

ability_type

create table ability_type (build INT, typeId INT, CAbil TEXT)

unit_type

create table unit_type (build INT, typeId INT, CUnit TEXT)

event_type

create table event_type (AbilityType TEXT unique on conflict replace, EventType TEXT)

unit_subgroup_priority

create table unit_subgroup_priority (UnitType TEXT unique on conflict replace, priority INT)

abil_info

create table abil_info (CAbil TEXT unique on conflict replace,
info0 TEXT, info1 TEXT, info2 TEXT, info3 TEXT, info4 TEXT, info5 TEXT,
info6 TEXT, info7 TEXT, info8 TEXT, info9 TEXT, info10 TEXT, info11 TEXT,
info12 TEXT, info13 TEXT, info14 TEXT, info15 TEXT, info16 TEXT, info17 TEXT,
info18 TEXT, info19 TEXT, info20 TEXT, info21 TEXT, info22 TEXT, info23 TEXT,
info24 TEXT, info25 TEXT, info26 TEXT, info27 TEXT, info28 TEXT, info29 TEXT,
info30 TEXT, info31 TEXT)

unit_info

create table unit_info (CUnit TEXT unique on conflict replace, UnitType TEXT)

build_info

create table build_info (build INT unique on conflict replace, effectiveBuild INT)

Compiled structures

builds.dat

{ushort build, ushort effectiveBuild}[]

abil{version}.dat

ushort[number of CAbils * 32]

unit{version}.dat

ushort[number of CUnits]

subgroups.dat

byte[length of UnitType]

events.dat

byte[length of AbilityType]

.dat header

16 bytes:

  • 4 byte magic word
  • 4 byte identifier (i.e. abil, unit, subg)
  • 4 byte build number (0 for subgroups)
  • 4 byte remaining file length in bytes