Skip to content

Commit aac4a6b

Browse files
committed
Use read_bool() everywhere.
1 parent 5e45b3f commit aac4a6b

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

sc2reader/readers.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -531,13 +531,13 @@ def player_send_resource_event(self, data, fstamp, pid, event_type):
531531
def player_request_resource_event(self, data, fstamp, pid, event_type):
532532
flags = data.read_bits(3) #??
533533
custom = minerals = vespene = terrazine = 0
534-
if data.read_bits(1):
534+
if data.read_bool():
535535
custom = data.read_bits(31) #??
536-
if data.read_bits(1):
536+
if data.read_bool():
537537
minerals = data.read_bits(31)
538-
if data.read_bits(1):
538+
if data.read_bool():
539539
vespene = data.read_bits(31)
540-
if data.read_bits(1):
540+
if data.read_bool():
541541
terrazine = data.read_bits(31) #??
542542
return RequestResourceEvent(fstamp, pid, event_type, minerals, vespene, terrazine, custom)
543543

@@ -546,17 +546,17 @@ def camera_event(self, data, fstamp, pid, event_type):
546546
x = data.read_uint16()/256.0
547547
y = data.read_uint16()/256.0
548548
distance = pitch = yaw = height = 0
549-
if data.read_bits(1):
549+
if data.read_bool():
550550
distance = data.read_uint16()/256.0
551-
if data.read_bits(1):
551+
if data.read_bool():
552552
#Note: this angle is relative to the horizontal plane, but the editor shows the angle relative to the vertical plane. Subtract from 90 degrees to convert.
553553
pitch = data.read_uint16() #?
554554
pitch = 45 * (((((pitch * 0x10 - 0x2000) << 17) - 1) >> 17) + 1) / 4096.0
555-
if data.read_bits(1):
555+
if data.read_bool():
556556
#Note: this angle is the vector from the camera head to the camera target projected on to the x-y plane in positive coordinates. So, default is 90 degrees, while insert and delete produce 45 and 135 degrees by default.
557557
yaw = data.read_uint16() #?
558558
yaw = 45 * (((((yaw * 0x10 - 0x2000) << 17) - 1) >> 17) + 1) / 4096.0
559-
if data.read_bits(1):
559+
if data.read_bool():
560560
height_offset = data.read_uint16()/256.0
561561
return CameraEvent(fstamp, pid, event_type, x, y, distance, pitch, yaw, height)
562562

@@ -616,10 +616,10 @@ def player_ability_event(self, data, fstamp, pid, event_type):
616616
# See sc2replay-csharp wiki for details
617617
flags = data.read_bits(self.PLAYER_ABILITY_FLAGS)
618618

619-
default_ability = not data.read_bits(1)
619+
default_ability = not data.read_bool()
620620
if not default_ability:
621621
ability = data.read_uint16() << 5 | data.read_bits(5)
622-
default_actor = not data.read_bits(1)
622+
default_actor = not data.read_bool()
623623
else:
624624
ability = 0
625625

@@ -629,7 +629,7 @@ def player_ability_event(self, data, fstamp, pid, event_type):
629629
y = data.read_bits(20)/4096.0
630630
z = data.read_uint32()
631631
z = (z>>1)/8192.0 * pow(-1, z & 0x1)
632-
unknown = data.read_bits(1)
632+
unknown = data.read_bool()
633633
return LocationAbilityEvent(fstamp, pid, event_type, ability, flags, (x, y, z))
634634

635635
elif target_type == 2:
@@ -639,22 +639,22 @@ def player_ability_event(self, data, fstamp, pid, event_type):
639639
unit = (data.read_uint32(), data.read_uint16())
640640
if fstamp == 9007 or unit[0] == 0x94880002:
641641
print fstamp, hex(unit[0])
642-
if self.ABILITY_TEAM_FLAG and data.read_bits(1):
642+
if self.ABILITY_TEAM_FLAG and data.read_bool():
643643
team = data.read_bits(4)
644644

645-
if data.read_bits(1):
645+
if data.read_bool():
646646
player = data.read_bits(4)
647647

648648
x = data.read_bits(20)/4096.0
649649
y = data.read_bits(20)/4096.0
650650
z = data.read_uint32()
651651
z = (z>>1)/8192.0 * pow(-1, z & 0x1)
652-
unknown = data.read_bits(1)
652+
unknown = data.read_bool()
653653
return TargetAbilityEvent(fstamp, pid, event_type, ability, flags, unit, player, team, (x, y, z))
654654

655655
elif target_type == 3:
656656
unit_id = data.read_uint32()
657-
unknown = data.read_bits(1)
657+
unknown = data.read_bool()
658658
return SelfAbilityEvent(fstamp, pid, event_type, ability, flags, unit_id)
659659

660660
else:
@@ -693,16 +693,16 @@ def beta_end_game_event(self, data, fstamp, pid, event_type):
693693

694694
def camera_event(self, data, fstamp, pid, event_type):
695695
x = y= distance = pitch = yaw = height = 0
696-
if data.read_bits(1):
696+
if data.read_bool():
697697
x = data.read_uint16()/256.0
698698
y = data.read_uint16()/256.0
699-
if data.read_bits(1):
699+
if data.read_bool():
700700
distance = data.read_uint16()/256.0
701-
if data.read_bits(1):
701+
if data.read_bool():
702702
#Note: this angle is relative to the horizontal plane, but the editor shows the angle relative to the vertical plane. Subtract from 90 degrees to convert.
703703
pitch = data.read_uint16() #?
704704
pitch = 45 * (((((pitch * 0x10 - 0x2000) << 17) - 1) >> 17) + 1) / 4096.0
705-
if data.read_bits(1):
705+
if data.read_bool():
706706
#Note: this angle is the vector from the camera head to the camera target projected on to the x-y plane in positive coordinates. So, default is 90 degrees, while insert and delete produce 45 and 135 degrees by default.
707707
yaw = data.read_uint16() #?
708708
yaw = 45 * (((((yaw * 0x10 - 0x2000) << 17) - 1) >> 17) + 1) / 4096.0

0 commit comments

Comments
 (0)