GraylinKim / sc2reader

A python library that extracts data from various Starcraft II resources to power tools and services for the SC2 community. Who doesn't want to hack on the games they play?
http://sc2reader.readthedocs.org
MIT License
411 stars 85 forks source link

Store extension mods on the replay #181

Closed StoicLoofah closed 9 years ago

StoicLoofah commented 9 years ago

See http://spawningtool.com/16416/ for a replay using the LotV Fan Alpha extension mod.

As far as I can tell, there's nothing in the sc2reader Replay that indicates what extension mods are active. The closest thing I could find is in this commmit https://github.com/GraylinKim/sc2reader/commit/b421a7cd3e70ee05feeaa6c8f138b16c4eacfd00 where it checks the version for whether it supports extension mods or not, but it doesn't figure out if it's actually using them.

I have no idea if it's even documented where to find that, nor do I know how I would go about figuring that out short of asking someone who actually knows things.

GraylinKim commented 9 years ago

I have the next few weeks off, I'll look into this for you.

StoicLoofah commented 9 years ago

Thanks so much. Happy to help out however I can with some direction

GraylinKim commented 9 years ago

When you play an SC2 game, you choose a map. That map has dependencies like Core, Liberty, and Swarm .SC2Mods. All these dependencies are specified by url in the replay.raw_data['replay.details']['cache_handles'] list. When you choose to use one or more mods on a map, it gets added to that list as well.

So to answer the question: you can determine if the LotV mod was used by loading all of the cache handles and checking them individually. Once you determine a mod is the correct one, you can use its md5 name to avoid loading and checking it again. Unfortunately user mod files don't have all the standard map files to check against. The DocumentHeader file has DocInfo/Name as LotV Custom - Unofficial Fan Alpha but I'm not 100% sure how to parse the whole file. Worst case, you could use manual checks to verify md5s for the various versions of the mod.

StoicLoofah commented 9 years ago

Right, I remember this feature now. Makes a ton of sense that they did extension mods that way. I'll look into it. Thanks for the pointer!