From 43a91af59ecfae36fd31ad5fbfca7e697849a897 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Thu, 4 Nov 2010 00:42:19 -1000 Subject: [PATCH] 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. --- mce.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mce.py b/mce.py index 63ccd88..c4d88e2 100644 --- a/mce.py +++ b/mce.py @@ -426,14 +426,19 @@ class mce(object): analyze 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') + sizeOnDisk = 0; + + print "Analyzing {0} chunks...".format(len(self.level.presentChunks)) for i, cPos in enumerate(self.level.presentChunks, 1): ch = self.level.getChunk(*cPos); counts = bincount(ch.Blocks.ravel()) blockCounts[:counts.shape[0]] += counts - + sizeOnDisk += ch.compressedSize(); ch.unload(); if i % 100 == 0: print "Chunk {0}...".format( i ) @@ -441,7 +446,10 @@ class mce(object): for i in range(256): if 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): """