Merge remote-tracking branch 'origin/dtt-c-render' into dtt-c-render
This commit is contained in:
2
chunk.py
2
chunk.py
@@ -52,7 +52,7 @@ def get_lvldata(world, filename, x, y, retries=2):
|
|||||||
|
|
||||||
# non existent region file doesn't mean corrupt chunk.
|
# non existent region file doesn't mean corrupt chunk.
|
||||||
if filename == None:
|
if filename == None:
|
||||||
return None
|
raise NoSuchChunk
|
||||||
|
|
||||||
try:
|
try:
|
||||||
d = world.load_from_region(filename, x, y)
|
d = world.load_from_region(filename, x, y)
|
||||||
|
|||||||
23
nbt.py
23
nbt.py
@@ -217,12 +217,16 @@ class MCRFileReader(object):
|
|||||||
# go to the correct entry in the chunk location table
|
# go to the correct entry in the chunk location table
|
||||||
self._file.seek(4 * (x + y * 32))
|
self._file.seek(4 * (x + y * 32))
|
||||||
|
|
||||||
# 3-byte offset in 4KiB sectors
|
try:
|
||||||
offset_sectors = self._read_24bit_int()
|
# 3-byte offset in 4KiB sectors
|
||||||
|
offset_sectors = self._read_24bit_int()
|
||||||
# 1-byte length in 4KiB sectors, rounded up
|
|
||||||
byte = self._file.read(1)
|
# 1-byte length in 4KiB sectors, rounded up
|
||||||
length_sectors = struct.unpack("B", byte)[0]
|
byte = self._file.read(1)
|
||||||
|
length_sectors = struct.unpack("B", byte)[0]
|
||||||
|
except (IndexError, struct.error):
|
||||||
|
# got a problem somewhere
|
||||||
|
return None
|
||||||
|
|
||||||
# check for empty chunks
|
# check for empty chunks
|
||||||
if offset_sectors == 0 or length_sectors == 0:
|
if offset_sectors == 0 or length_sectors == 0:
|
||||||
@@ -247,8 +251,11 @@ class MCRFileReader(object):
|
|||||||
# go to the correct entry in the chunk timestamp table
|
# go to the correct entry in the chunk timestamp table
|
||||||
self._file.seek(4 * (x + y * 32) + 4096)
|
self._file.seek(4 * (x + y * 32) + 4096)
|
||||||
|
|
||||||
bytes = self._file.read(4)
|
try:
|
||||||
timestamp = struct.unpack(">I", bytes)[0]
|
bytes = self._file.read(4)
|
||||||
|
timestamp = struct.unpack(">I", bytes)[0]
|
||||||
|
except (IndexError, struct.error):
|
||||||
|
return 0
|
||||||
|
|
||||||
return timestamp
|
return timestamp
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user