Skip to content

Commit 5a1c5d4

Browse files
committed
Improve the camera parsing to extract coordinates.
1 parent 2ec5f71 commit 5a1c5d4

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

sc2reader/readers.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -415,14 +415,19 @@ def parse_cameraX8_event(self, buffer, frames, type, code, pid):
415415
return CameraMovementEvent(frames, pid, type, code)
416416

417417
def parse_cameraX1_event(self, buffer, frames, type, code, pid):
418-
#Get the X and Y, last byte is also a flag
419-
chunk = buffer.read_int(BIG_ENDIAN)
420-
421-
if chunk & 0x10 != 0:
422-
chunk = buffer.read_short(BIG_ENDIAN)
423-
if chunk & 0x20 != 0:
424-
chunk = buffer.read_short(BIG_ENDIAN)
425-
if chunk & 0x40 != 0:
418+
# TODO: Figure out what all this zoom and rotate stuff is about
419+
x = ((code & 0xF0) << 8 | sum(buffer.read(bits=12)))/256.0
420+
y = buffer.read_short()/256.0
421+
422+
flags = buffer.shift(4) << 4
423+
if flags & 0x10 != 0:
424+
# zoom=?
425+
flags = buffer.read_short(BIG_ENDIAN)
426+
if flags & 0x20 != 0:
427+
# zoom=?
428+
flags = buffer.read_short(BIG_ENDIAN)
429+
if flags & 0x40 != 0:
430+
# rotate=?
426431
buffer.skip(2)
427432

428433
return CameraMovementEvent(frames, pid, type, code)

0 commit comments

Comments
 (0)