Skip to content

Commit

Permalink
block states with 9, 10, 11, and 12 bits per value now unpack correctly
Browse files Browse the repository at this point in the history
old code mistakenly re-used byte 0 for every aligned stretch of blocks,
causing the wrong block id to be read
  • Loading branch information
agrif committed Feb 22, 2019
1 parent fc4a8ec commit 53fa463
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions overviewer_core/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ def _packed_longarray_to_shorts(self, long_array, n):
i += 7
elif bits_per_value == 9:
result.extend([
((b[i+1] & 0x01) << 8) | b[0],
((b[i+1] & 0x01) << 8) | b[i],
((b[i+2] & 0x03) << 7) | ((b[i+1] & 0xfe) >> 1),
((b[i+3] & 0x07) << 6) | ((b[i+2] & 0xfc) >> 2),
((b[i+4] & 0x0f) << 5) | ((b[i+3] & 0xf8) >> 3),
Expand All @@ -1021,15 +1021,15 @@ def _packed_longarray_to_shorts(self, long_array, n):
i += 9
elif bits_per_value == 10:
result.extend([
((b[i+1] & 0x03) << 8) | b[0],
((b[i+1] & 0x03) << 8) | b[i],
((b[i+2] & 0x0f) << 6) | ((b[i+1] & 0xfc) >> 2),
((b[i+3] & 0x3f) << 4) | ((b[i+2] & 0xf0) >> 4),
(b[i+4] << 2) | ((b[i+3] & 0xc0) >> 6),
])
i += 5
elif bits_per_value == 11:
result.extend([
((b[i+1] & 0x07) << 8) | b[0],
((b[i+1] & 0x07) << 8) | b[i],
((b[i+2] & 0x3f) << 5) | ((b[i+1] & 0xf8) >> 3),
((b[i+4] & 0x01) << 10)| (b[i+3] << 2) | ((b[i+2] & 0xc0) >> 6),
((b[i+5] & 0x0f) << 7) | ((b[i+4] & 0xfe) >> 1),
Expand All @@ -1041,7 +1041,7 @@ def _packed_longarray_to_shorts(self, long_array, n):
i += 11
elif bits_per_value == 12:
result.extend([
((b[i+1] & 0x0f) << 8) | b[0],
((b[i+1] & 0x0f) << 8) | b[i],
(b[i+2] << 4) | ((b[i+1] & 0xf0) >> 4),
])
i += 3
Expand Down

0 comments on commit 53fa463

Please sign in to comment.