Dentosal / python-sc2

A StarCraft II bot api client library for Python 3
MIT License
588 stars 182 forks source link

Headless Linux version broken on "develop" branch #286

Open jaens opened 5 years ago

jaens commented 5 years ago

I believe the changes made to make it work with the latest B.net SC2 version actually broke it for the headless Linux build (for which the latest version is still 4.7.1).

The following patch at least gets it running (but would break it for newer versions of course...):

diff --git a/sc2/bot_ai.py b/sc2/bot_ai.py
index 71ecbe3..e6785a6 100644
--- a/sc2/bot_ai.py
+++ b/sc2/bot_ai.py
@@ -786,7 +786,7 @@ class BotAI:
         self.state: GameState = state  # See game_state.py
         # update pathing grid
         self._game_info.pathing_grid: PixelMap = PixelMap(
-            proto_game_info.game_info.start_raw.pathing_grid, in_bits=True, mirrored=False
+            proto_game_info.game_info.start_raw.pathing_grid, in_bits=False, mirrored=False
         )
         # Required for events
         self._units_previous_map: Dict = {unit.tag: unit for unit in self.units}
diff --git a/sc2/game_info.py b/sc2/game_info.py
index 79ac371..f218a11 100644
--- a/sc2/game_info.py
+++ b/sc2/game_info.py
@@ -176,11 +176,11 @@ class GameInfo:
         self.map_size: Size = Size.from_proto(self._proto.start_raw.map_size)

         # self.pathing_grid[point]: if 0, point is not pathable, if 1, point is pathable
-        self.pathing_grid: PixelMap = PixelMap(self._proto.start_raw.pathing_grid, in_bits=True, mirrored=False)
+        self.pathing_grid: PixelMap = PixelMap(self._proto.start_raw.pathing_grid, in_bits=False, mirrored=False)
         # self.terrain_height[point]: returns the height in range of 0 to 255 at that point
         self.terrain_height: PixelMap = PixelMap(self._proto.start_raw.terrain_height, mirrored=False)
         # self.placement_grid[point]: if 0, point is not pathable, if 1, point is pathable
-        self.placement_grid: PixelMap = PixelMap(self._proto.start_raw.placement_grid, in_bits=True, mirrored=False)
+        self.placement_grid: PixelMap = PixelMap(self._proto.start_raw.placement_grid, in_bits=False, mirrored=False)
         self.playable_area = Rect.from_proto(self._proto.start_raw.playable_area)
         self.map_center = self.playable_area.center
         self.map_ramps: List[Ramp] = None  # Filled later by BotAI._prepare_first_step

Looks like these variables need to be dynamically based on whatever version of SC2 is currently selected?

jaens commented 5 years ago

I see this has already been noticed, Dockerfile has a comment:

Disabled until linux client is at version 4.8.5 or newer - issues with pixelmap that are working on the windows client

jaens commented 5 years ago

Looks like no progress on Blizzard's side for the Linux client update https://github.com/Blizzard/s2client-proto/issues/134 . I assume this blocks releasing a new stable version of the sc2 package so might be worth it to work around this with a runtime check...

I think this also affects running replays/games with an older version on other platforms?

tweakimp commented 5 years ago

Looks like these variables need to be dynamically based on whatever version of SC2 is currently selected?

yes, and with all the different sc2 Client versions currently used its hard to keep track of what to use, what works and what is broken.

We have to wait for Blizzards fix for the client to not have the blackscreen bug so that we can all come back to the same version.