-
Notifications
You must be signed in to change notification settings - Fork 0
handle 3.0 replays, work in progress. #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,6 +116,7 @@ def __call__(self, data, replay): | |
| tandem_leader_user_id=data.read_bits(4) if replay.base_build >= 34784 and data.read_bool() else None, | ||
| commander=data.read_aligned_bytes(data.read_bits(9)) if replay.base_build >= 34784 else None, | ||
| commander_level=data.read_uint32() if replay.base_build >= 36442 else None, | ||
| has_silence_penalty=data.read_bool() if replay.base_build >= 38215 else None, | ||
| ) for i in range(data.read_bits(5))], | ||
| random_seed=data.read_uint32(), | ||
| host_user_id=data.read_bits(4) if data.read_bool() else None, | ||
|
|
@@ -1723,6 +1724,49 @@ def control_group_update_event(self, data): | |
| }[data.read_bits(2)](), | ||
| ) | ||
|
|
||
| class GameEventsReader_38215(GameEventsReader_36442): | ||
|
|
||
| def command_event(self, data): | ||
| # this function is exactly the same as command_event() from GameEventsReader_36442 | ||
| # with the only change being that flags now has 25 bits instead of 23. | ||
| return dict( | ||
| flags=data.read_bits(25), | ||
| ability=dict( | ||
| ability_link=data.read_uint16(), | ||
| ability_command_index=data.read_bits(5), | ||
| ability_command_data=data.read_uint8() if data.read_bool() else None, | ||
| ) if data.read_bool() else None, | ||
| data={ # Choice | ||
| 0: lambda: ('None', None), | ||
| 1: lambda: ('TargetPoint', dict( | ||
| point=dict( | ||
| x=data.read_bits(20), | ||
| y=data.read_bits(20), | ||
| z=data.read_uint32() - 2147483648, | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just for my own knowledge, why do we need the subtraction here?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the subtraction is because of https://github.com/Blizzard/s2protocol/blob/master/protocol38215.py#L110 it's a type ggtracker#84, and in this case the x, y and z are part of a type ggtracker#93. https://github.com/Blizzard/s2protocol/blob/master/protocol38215.py#L119
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes sense. thanks for the explanation! |
||
| ) | ||
| )), | ||
| 2: lambda: ('TargetUnit', dict( | ||
| flags=data.read_uint16(), | ||
| timer=data.read_uint8(), | ||
| unit_tag=data.read_uint32(), | ||
| unit_link=data.read_uint16(), | ||
| control_player_id=data.read_bits(4) if data.read_bool() else None, | ||
| upkeep_player_id=data.read_bits(4) if data.read_bool() else None, | ||
| point=dict( | ||
| x=data.read_bits(20), | ||
| y=data.read_bits(20), | ||
| z=data.read_uint32() - 2147483648, | ||
| ), | ||
| )), | ||
| 3: lambda: ('Data', dict( | ||
| data=data.read_uint32() | ||
| )), | ||
| }[data.read_bits(2)](), | ||
| sequence=data.read_uint32() + 1, | ||
| other_unit_tag=data.read_uint32() if data.read_bool() else None, | ||
| unit_group=data.read_uint32() if data.read_bool() else None, | ||
| ) | ||
|
|
||
|
|
||
| class TrackerEventsReader(object): | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it is kind of shitty how this bit of code turned out. I can never get up the motivation to rewrite for less repetition though.