0

handle bad biome files on load, instead of waiting for an IndexError later

related to <https://github.com/brownan/Minecraft-Overviewer/issues/301>
This commit is contained in:
Aaron Griffith
2011-03-17 21:37:39 -04:00
parent 4aa7fff086
commit ad0899bb8a

View File

@@ -878,14 +878,17 @@ def getBiomeData(worlddir, chunkX, chunkY):
if biomeFile == currentBiomeFile:
return currentBiomeData
currentBiomeFile = biomeFile
f = open(os.path.join(worlddir, "biomes", biomeFile), "rb")
rawdata = f.read()
f.close()
# make sure the file size is correct
if not len(rawdata) == 512 * 512 * 2:
raise Exception("Biome file %s is not valid." % (biomeFile,))
data = numpy.frombuffer(rawdata, dtype=numpy.dtype(">u2"))
currentBiomeFile = biomeFile
currentBiomeData = data
return data