Permalink
Browse files

Fixes #42 Incorrect resource transfer events.

The multiplier needs to have its trailing 4 bits shifted off and
should not be used when it has a value of zero (and isn't necessary).
  • Loading branch information...
1 parent 8b03fbb commit 25de52801e36e8c36b893a324055a62525fb0e63 @GraylinKim committed May 23, 2012
Showing with 5 additions and 2 deletions.
  1. +5 −2 sc2reader/readers.py
View
@@ -383,8 +383,11 @@ def parse_hotkey_event(self, buffer, frames, type, code, pid):
def parse_transfer_event(self, buffer, frames, type, code, pid):
def read_resource(buffer):
block = buffer.read_int(BIG_ENDIAN)
- base, multiplier, extension = block >> 8, block & 0xF0, block & 0x0F
- return base*multiplier+extension
+ base, multiplier, extension = block >> 8, block & 0xF0 >> 4, block & 0x0F
+ if multiplier == 0:
+ return base+extension
+ else:
+ return base*multiplier+extension
target = code >> 4
buffer.skip(1) #Always 84

0 comments on commit 25de528

Please sign in to comment.