Blizzard / s2client-api

StarCraft II Client - C++ library supported on Windows, Linux and Mac designed for building scripted bots and research using the SC2API.
MIT License
1.66k stars 281 forks source link

Fetch the map hash #75

Open noorus opened 7 years ago

noorus commented 7 years ago

It'd be helpful to get the hash (or whatever unique id) of the current map in the gameinfo data. Of course, the map is loaded based on what I supply as an argument to the game/API, but it'd feel much less flimsy and be more future-proof to get the actual hash of the map that the game ended up loading.

In my case I'd want this for caching: I spend something like 10 seconds generating all kinds of stuff from the terrain and unit information on game start, which I'd like to cache for next sessions by the map ID. Especially important in realtime use, since that 10 seconds is subtracted from active play time.

KevinCalderone commented 7 years ago

I agree some type of uniqueId would be useful. May not be high on our priority list though.

Since you are specifying the map directly, you could try just loading the file from disk yourself and hashing it.

kuzi117 commented 7 years ago

That is what I'm doing and it seems to work fairly well.

herodrigues commented 6 years ago

Hi @noorus

Was your issue solved? If yes, can you close this issue, please?

noorus commented 6 years ago

Hi @herodrigues I wouldn't call it solved. What I indeed ended up doing was hash the map file being loaded myself, but (depending on implementation and compiler settings) this actually takes a while and in turn causes my realtime bot to lag in startup, missing out on maybe a few seconds of precious early game time.

The process is:

So what I then did was to start taking the SHA256 directly from the map file name if it came from the bnet cache instead of calculating it myself, but this is a hack and not a real neat solution.

Of course I could also sidestep the issue by passing an absolute path to a map file to the launcher instead of a map name, but then I'd be missing out on what I see as a cool and useful feature (launching the latest ladder version of a map by name).

TL;DR I hacked my way around it so it's not a pressing issue, but I don't see why whatever internal identifiers battlenet uses for every single map cannot be passed to the bot by the API.

Unless I'm missing something, I don't really see what the PR where this was referenced has to do with this particular problem either.