Skip to content

Commit abf8da7

Browse files
committed
Merge branch 'master' into coop_support
Conflicts: test_replays/test_all.py
2 parents f333187 + d1b6ede commit abf8da7

File tree

10 files changed

+94
-36
lines changed

10 files changed

+94
-36
lines changed

.circleci/config.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
version: 2.0
2+
3+
my-steps: &steps
4+
- checkout
5+
- run: sudo pip install -r requirements.txt
6+
- run: sudo pip install flake8 pytest
7+
- run: python --version ; pip --version ; pwd ; ls
8+
# stop the build if there are Python syntax errors or undefined names
9+
- run: flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
10+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
11+
- run: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
12+
#- run: pytest # test_s2gs test_replays
13+
- run: python -m unittest discover test_s2gs
14+
- run: python -m unittest discover test_replays
15+
16+
jobs:
17+
Python_2.7:
18+
docker:
19+
- image: circleci/python:2.7
20+
steps: *steps
21+
22+
Python_3.6:
23+
docker:
24+
- image: circleci/python:3.6
25+
steps: *steps
26+
27+
workflows:
28+
version: 2
29+
build:
30+
jobs:
31+
- Python_2.7
32+
- Python_3.6

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ If you can't share your code/replays publicly try to replicate with a smaller sc
1414
Patches
1515
=========
1616

17-
Please submit patches by pull request where possible. Patches should add a test to confirm their fix and should not break previously working tests.
17+
Please submit patches by pull request where possible. Patches should add a test to confirm their fix and should not break previously working tests. Circle CI automatically runs tests on each pull request so please check https://circleci.com/gh/ggtracker/sc2reader to see the results of those tests.
1818

1919
If you are having trouble running/add/fixing tests for your patch let me know and I'll see if I can help.
2020

circle.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
hacking
1+
mpyq
22
Pillow

sc2reader/engine/plugins/creeptracker.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import absolute_import, print_function, unicode_literals, division
33

4+
from io import BytesIO
5+
46
try:
57
from sets import Set
68
except ImportError:
@@ -113,7 +115,7 @@ def __init__(self,replay):
113115
#Get map information
114116
replayMap = replay.map
115117
# extract image from replay package
116-
mapsio = StringIO(replayMap.minimap)
118+
mapsio = BytesIO(replayMap.minimap)
117119
im = PIL_open(mapsio)
118120
##remove black box around minimap
119121

sc2reader/readers.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,6 +1877,49 @@ def trigger_ping_event(self, data):
18771877
option=data.read_uint32() - 2147483648,
18781878
)
18791879

1880+
class GameEventsReader_64469(GameEventsReader_38996):
1881+
1882+
# this function is exactly the same as command_event() from GameEventsReader_38996
1883+
# with the only change being that flags now has 26 bits instead of 25.
1884+
def command_event(self, data):
1885+
return dict(
1886+
flags=data.read_bits(26),
1887+
ability=dict(
1888+
ability_link=data.read_uint16(),
1889+
ability_command_index=data.read_bits(5),
1890+
ability_command_data=data.read_uint8() if data.read_bool() else None,
1891+
) if data.read_bool() else None,
1892+
data={ # Choice
1893+
0: lambda: ('None', None),
1894+
1: lambda: ('TargetPoint', dict(
1895+
point=dict(
1896+
x=data.read_bits(20),
1897+
y=data.read_bits(20),
1898+
z=data.read_uint32() - 2147483648,
1899+
)
1900+
)),
1901+
2: lambda: ('TargetUnit', dict(
1902+
flags=data.read_uint16(),
1903+
timer=data.read_uint8(),
1904+
unit_tag=data.read_uint32(),
1905+
unit_link=data.read_uint16(),
1906+
control_player_id=data.read_bits(4) if data.read_bool() else None,
1907+
upkeep_player_id=data.read_bits(4) if data.read_bool() else None,
1908+
point=dict(
1909+
x=data.read_bits(20),
1910+
y=data.read_bits(20),
1911+
z=data.read_uint32() - 2147483648,
1912+
),
1913+
)),
1914+
3: lambda: ('Data', dict(
1915+
data=data.read_uint32()
1916+
)),
1917+
}[data.read_bits(2)](),
1918+
sequence=data.read_uint32() + 1,
1919+
other_unit_tag=data.read_uint32() if data.read_bool() else None,
1920+
unit_group=data.read_uint32() if data.read_bool() else None,
1921+
)
1922+
18801923
class TrackerEventsReader(object):
18811924

18821925
def __init__(self):

sc2reader/resources.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,8 @@ def register_default_readers(self):
586586
self.register_reader('replay.game.events', readers.GameEventsReader_36442(), lambda r: 36442 <= r.base_build < 38215)
587587
self.register_reader('replay.game.events', readers.GameEventsReader_38215(), lambda r: 38215 <= r.base_build < 38749)
588588
self.register_reader('replay.game.events', readers.GameEventsReader_38749(), lambda r: 38749 <= r.base_build < 38996)
589-
self.register_reader('replay.game.events', readers.GameEventsReader_38996(), lambda r: 38996 <= r.base_build)
589+
self.register_reader('replay.game.events', readers.GameEventsReader_38996(), lambda r: 38996 <= r.base_build < 64469)
590+
self.register_reader('replay.game.events', readers.GameEventsReader_64469(), lambda r: 64469 <= r.base_build)
590591
self.register_reader('replay.game.events', readers.GameEventsReader_HotSBeta(), lambda r: r.versions[1] == 2 and r.build < 24247)
591592

592593
def register_default_datapacks(self):

sc2reader/scripts/sc2parse.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ def main():
4545
if not args.one_each or replay.is_ladder:
4646
replay = sc2reader.load_replay(path, debug=True)
4747

48-
human.pids = set([human.pid for human in replay.humans])
48+
human_pids = set([human.pid for human in replay.humans])
4949
event_pids = set([event.player.pid for event in replay.events if getattr(event, 'player', None)])
5050
player_pids = set([player.pid for player in replay.players if player.is_human])
5151
ability_pids = set([event.player.pid for event in replay.events if 'CommandEvent' in event.name])
52-
if human.pids != event_pids:
53-
print('Event Pid problem! pids={pids} but event pids={event_pids}'.format(pids=human.pids, event_pids=event_pids))
52+
if human_pids != event_pids:
53+
print('Event Pid problem! pids={pids} but event pids={event_pids}'.format(pids=human_pids, event_pids=event_pids))
5454
print(' with {path}: {build} - {real_type} on {map_name} - Played {start_time}'.format(path=path, **replay.__dict__))
5555
elif player_pids != ability_pids:
5656
print('Ability Pid problem! pids={pids} but event pids={event_pids}'.format(pids=player_pids, event_pids=ability_pids))

test_replays/4.3.0.64469/1.SC2Replay

28.1 KB
Binary file not shown.

test_replays/test_all.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,13 +509,13 @@ def test_33_shift_click_calldown_mule(self):
509509
replay = sc2reader.load_replay("test_replays/3.3.0/ggissue48.SC2Replay")
510510
def efilter(e):
511511
return hasattr(e, "ability") and e.ability_name == "CalldownMULE"
512-
self.assertEqual(len(filter(efilter, replay.events)), 29)
512+
self.assertEqual(len(list(filter(efilter, replay.events))), 29)
513513

514514
def test_33_shift_click_spawn_larva(self):
515515
replay = sc2reader.load_replay("test_replays/3.3.0/ggissue49.SC2Replay")
516516
def efilter(e):
517517
return hasattr(e, "ability") and e.ability_name == "SpawnLarva"
518-
self.assertEqual(len(filter(efilter, replay.events)), 23)
518+
self.assertEqual(len(list(filter(efilter, replay.events))), 23)
519519

520520
def test_34(self):
521521
replay = sc2reader.load_replay("test_replays/3.4.0/issueYY.SC2Replay")
@@ -561,6 +561,13 @@ def test_59587(self):
561561
factory = sc2reader.factories.SC2Factory()
562562
replay = factory.load_replay(replayfilename)
563563

564+
def test_64469(self):
565+
for replayfilename in [
566+
"test_replays/4.3.0.64469/1.SC2Replay",
567+
]:
568+
factory = sc2reader.factories.SC2Factory()
569+
replay = factory.load_replay(replayfilename)
570+
564571
def test_coop(self):
565572
for replayfilename in [
566573
"test_replays/coop/CoA.SC2Replay",

0 commit comments

Comments
 (0)