aiarena / aiarena-web

A website for running the aiarena.net ladder.
https://aiarena.net
GNU General Public License v3.0
93 stars 15 forks source link

Make our replays compatible with sc2reader #88

Open eladyaniv01 opened 3 years ago

eladyaniv01 commented 3 years ago

below is a starting point suggested on discord

        try:
            self.region = details['cache_handles'][0].server.lower()
            self.map_hash = details['cache_handles'][-1].hash
            self.map_file = details['cache_handles'][-1]
        except:
            ...
        if hashlib.sha256('Standard Data: Void.SC2Mod'.encode('utf8')).hexdigest() in dependency_hashes:
            self.expansion = 'LotV'
        elif hashlib.sha256('Standard Data: Swarm.SC2Mod'.encode('utf8')).hexdigest() in dependency_hashes:
            self.expansion = 'HotS'
        elif hashlib.sha256('Standard Data: Liberty.SC2Mod'.encode('utf8')).hexdigest() in dependency_hashes:
            self.expansion = 'WoL'
        else:
            self.expansion = 'LotV'
            self.speed = 'Faster'

these hacks get the sc2reader a little further @DrInfy#2523

amartin916 commented 3 years ago

Quickly playing with the replay files from bot matches I found a few pieces of information missing, that would need to be faked or avoided. I don't have a lot of experience with sc2reader as I have used s2protocol and s2prot mostly with my own wrapper.

  1. cache_handles are missing, which are used for figuring out the map hash, and expansion type (lotv, hots, wol). The expansion could be stored in any of the cache_handlers, the map hash is the 6th element. The map hash is the unique identifier for the map which is also used for getting the s2ma files from blizzards server.
  2. Attribute Scopes seem to be limited, I don't know exactly how many are missing but the one I look for Scope 16 -> 2001 which returns the format assigned in game.
  3. One other flag I personally check not sure if sc2reader does is Details->Difficulty which I recently started checking for rejected arcade games/coop games. Bot games have this set as 7 (3 is 1v1,2v2,3v3,ext). This value might be a good way to tell its a bot game. Very little is know about this value, its something new someone stumbled across and pointed it out to me.
  4. Toon (Battle.net player info) information is blank for bots, this is how most parsers figure out who is who.

That's the short list of things I noticed where missing when I ran a bot vs AI replay file against my parser. A lot of the values you could assume from the bot ladder. You know the format, you created the game, You know the bots and could give them a unique id. The easiest solution might to just make sc2reader allow the values to be "unknown" (this is the approach s2prot takes when values are missing or unknown).