analyze will now compute, display, and update the level's SizeOnDisk

analyze will read all of the chunks off the disk, so it might as well take the opportunity to fix an incorrect file size display.
nether worlds are not yet accounted for.
This commit is contained in:
David Vierra 2010-11-04 00:42:19 -10:00
parent 714290b8e2
commit 43a91af59e

10
mce.py
View File

@ -426,14 +426,19 @@ class mce(object):
analyze analyze
Counts all of the block types in every chunk of the world. Counts all of the block types in every chunk of the world.
Also updates the level's 'SizeOnDisk' field, correcting its size in the
world select menu.
""" """
blockCounts = zeros( (256,), 'uint64') blockCounts = zeros( (256,), 'uint64')
sizeOnDisk = 0;
print "Analyzing {0} chunks...".format(len(self.level.presentChunks))
for i, cPos in enumerate(self.level.presentChunks, 1): for i, cPos in enumerate(self.level.presentChunks, 1):
ch = self.level.getChunk(*cPos); ch = self.level.getChunk(*cPos);
counts = bincount(ch.Blocks.ravel()) counts = bincount(ch.Blocks.ravel())
blockCounts[:counts.shape[0]] += counts blockCounts[:counts.shape[0]] += counts
sizeOnDisk += ch.compressedSize();
ch.unload(); ch.unload();
if i % 100 == 0: if i % 100 == 0:
print "Chunk {0}...".format( i ) print "Chunk {0}...".format( i )
@ -442,6 +447,9 @@ class mce(object):
if blockCounts[i]: if blockCounts[i]:
print "{0:30}: {1:10}".format(self.level.materials.names[i], blockCounts[i]); print "{0:30}: {1:10}".format(self.level.materials.names[i], blockCounts[i]);
print "Size on disk: {0:.3}MB".format(sizeOnDisk / 1048576.0)
self.level.SizeOnDisk = sizeOnDisk
self.needsSave = True
def _export(self, command): def _export(self, command):
""" """