sc2reader icon indicating copy to clipboard operation
sc2reader copied to clipboard

Which load_level should we use for game metadata?

Open NumberPigeon opened this issue 1 year ago • 1 comments

What is a game metadata and why we need it?

There is a replay.gamemetadata.json file included in the MPQArchive. An example of content is shown below.

{'BaseBuild': 'Base90870',
 'DataBuild': '90870',
 'DataVersion': 'A3FC7B99B9F515326107F490D0E0AA7C',
 'Duration': 1883,
 'GameVersion': '5.0.11.90870',
 'Players': [{'APM': 145.0,
              'AssignedRace': 'Prot',
              'MMR': 2761,
              'PlayerID': 1,
              'Result': 'Win',
              'SelectedRace': 'Prot'},
             {'APM': 261.0,
              'AssignedRace': 'Terr',
              'PlayerID': 2,
              'Result': 'Win',
              'SelectedRace': 'Terr'},
             {'APM': 197.0,
              'AssignedRace': 'Prot',
              'MMR': 5009,
              'PlayerID': 3,
              'Result': 'Loss',
              'SelectedRace': 'Prot'},
             {'APM': 292.0,
              'AssignedRace': 'Zerg',
              'MMR': 2609,
              'PlayerID': 4,
              'Result': 'Loss',
              'SelectedRace': 'Zerg'}],
 'Title': 'Arctic Dream LE'}

While most of the info is duplicated, there are still some interesting info that not included currently:

  1. DataVersion: it seems a hash related to datapack. We dont have it now.
  2. Duration: this indicates the real length of the whole replay, while real_length indicated the time from gamestart to last event. For the several replays I tested, Duration is slightly larger than real_length (usually 1~2 seconds, if count 16 frames as 1 second). I think Duration is the time from gamestart to the time the replay recorder actually left the game.
  3. APM for players: this APM is exactly the number given by SC2 after game summary. I tried several algorithms to get it but still cannot calculate it myself. Someone may be interested in it.
  4. MMR for players: while this MMR equals to 'scaled_rating' mentioned in #89 in 1v1 games, it's different in other types like 2v2. After some tests, I guess the MMR here indicates the players' 1v1 mmr, while 'scaled_rating' indicates the players' mmr for the type of the game like 2v2.

Let's get it! But where?

sc2reader reads replays with different load_level. Where should we put this one? Since it includes Duration and DataVersion, it's better to put it at level 0 or 1. But the players and teams will not be constructed until level 2, leads to all the Players useless at level 0 or 1.

So where should we put it?

NumberPigeon avatar Aug 30 '23 17:08 NumberPigeon

Solid analysis.

To the extent that users haven't been missing this data so far, I'm inclined to put this at load_level 1, with the caveat that the player data only gets incorporated if we have the corresponding objets for that if it's load_level 2.

StoicLoofah avatar Sep 06 '23 21:09 StoicLoofah