How to distinguish HotS replays from WoL replays #97

Closed
dsjoerg opened this Issue Feb 19, 2013 · 4 comments

Projects

None yet

3 participants

@dsjoerg
Collaborator

WoL is now on version 2.0.4.24944 as of today.
HotS continues to be on version 2.0.3.24764.

Here's a WoL 2.0.4.24944 replay: http://ggtracker.com/matches/1785997

Using the version number is probably already wrong.
In the HotS beta, even now, you can go to Options->Gameplay and pick Expansion Level: Wings of Liberty.

So people can play Wings of Liberty games using the HotS client.

Presumably there is some other indicator inside the replay to say which version of the game is being played.

This will be mission-critical for GGTracker soon as in statistics we don't want to mix WoL and HotS.

@GraylinKim
Owner

Agreed, the version number is already wrong. I think for this we're going to have to fall back to map dependencies information. Specifically:

>>> import sc2reader
>>> from xml.etree import ElementTree

>>> hots = sc2reader.load_replay('hots.SC2Replay', load_map=True)
>>> hots_xml = ElementTree.fromstring(hots.map.archive.read_file('DocumentInfo'))
>>> [value.text for value in hots_xml.findall('Dependencies/Value')]
['bnet:Swarm (Mod)/0.0/999,file:Mods/Swarm.SC2Mod']

>>> wol = sc2reader.load_replay('wol.SC2Replay', load_map=True)
>>> wol_xml = ElementTree.fromstring(wol.map.archive.read_file('DocumentInfo'))
>>> [value.text for value in wol_xml.findall('Dependencies/Value')]
['bnet:Liberty (Mod)/0.0/999,file:Mods/Liberty.SC2Mod']

It may also be reasonable to do this at the replay level by looking for Swarm (Mod) in the list of map resources found here:

replay.raw_data['replay.details'].unknown7

I'll try to implement something along these lines soon.

@alexhanh
Collaborator

+1

@GraylinKim
Owner

Okay, I'm pushing out an improved fix that doesn't involve fetching dependencies from the depots. Instead it takes advantage of the depot convention of naming files by the sha256 digest their contents. From what I can tell, HotS games depend on 'Standard Data: Swarm.SC2Mod' and WoL games depend on 'Standard Data: Liberty.SC2Mod'.

if hashlib.sha256('Standard Data: Swarm.SC2Mod').hexdigest() in dependency_hashes:
    self.expansion = 'HotS'
elif hashlib.sha256('Standard Data: Liberty.SC2Mod').hexdigest() in dependency_hashes:
    self.expansion = 'WoL'
else:
    self.expansion = ''

I'm pushing this out in the next batch of commits.

@dsjoerg
Collaborator

Outstanding, thank you!

@GraylinKim GraylinKim closed this Mar 11, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment