Skip to content

Commit 6aa9276

Browse files
committed
Improve the docs for the game_events_debugger.
1 parent 22297f2 commit 6aa9276

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

game_events_debug.py

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" Game Event Parsing Debugger
2+
===============================
23
34
Recursively searches for unique replays specified by command line argument
45
and attempts a parse in order to catch the ReadError. The ReadError will
@@ -29,16 +30,50 @@
2930
3) Alter the reader code to make it happen
3031
4) Repeat
3132
33+
In the example above:
34+
35+
00 22 ac 00 02 f4 00 00 | 00 0c a1 89 00 10 00 00 00 21 0b 01 00 01 5c 01 00 0c 22 0b
36+
37+
The boundaries should be here:
38+
39+
00 22 ac 00 02 f4 00 00 00 | 0c a1 89 00 10 00 00 | 00 21 0b 01 00 01 5c 01 00 | 0c 22 0b
40+
41+
So the correct bytes for the failed event are these:
42+
43+
00 22 ac 00 02 f4 00 00 00
44+
3245
To figure out how to alter the reader code you'll probably need to compile
33-
lists of failed events with the correct bytes and look for patterns that
34-
would help you read them the right way. Sometimes it also helps to think
35-
about what that event represents and what would make its content length
36-
vary. Cross checking against a replay can also be useful.
46+
lists of failed events with these correct bytes and look for patterns that
47+
would help you read them the right way.
48+
49+
Sometimes it also helps to think about what that event represents and what
50+
would make its content length vary. Cross checking against a replay can
51+
also be useful.
3752
3853
When altering the reader code, NEVER change code in an older game events
3954
reader unless you really really know what you are doing. Instead copy the
4055
function you'd like to change into the GameEventsReader_22612 class and
4156
make your changes there.
57+
58+
59+
Pointers for finding boundaries
60+
==================================
61+
62+
The easiest way to find the right boundary is to scan the following bytes
63+
until you see a clear marker for a different event and then work your way
64+
backwards until you can't anymore.
65+
66+
The first part of a new event is always a timestamp and usually, maybe
67+
9/10 times, the timestamp will only be 1 bye long and therefore a multiple
68+
of 4 (including 0).
69+
70+
Immediately following the timestamp is a byte with bits split 3-5 for
71+
event_type and player_id. The event type is never more than 5 and the
72+
player_id is generally less than 4 for ladder games.
73+
74+
The next byte after that is the event code. Common event codes include:
75+
AC, XD, 61, and XB where X is any number. You can find a list of event
76+
codes in the sc2reader.readers.GameEventsReader_Base class.
4277
"""
4378
import sys
4479
import sc2reader

0 commit comments

Comments
 (0)