added the routine _makeChunk for internal use

This commit is contained in:
David Vierra 2010-11-29 21:40:47 -10:00
parent bbb37dbca8
commit c9fe2afff1

View File

@ -2284,21 +2284,25 @@ class MCInfdevOldLevel(MCLevel):
return [self.getChunk(cx,cz) for (cx,cz) in chunks if self.containsChunk(cx,cz)] return [self.getChunk(cx,cz) for (cx,cz) in chunks if self.containsChunk(cx,cz)]
def getChunk(self, cx, cz): def _makeChunk(self, cx,cz):
""" read the chunk from disk, load it, and return it. """return the chunk object at the given position, creating it if necessary.
decompression and unpacking is done lazily.""" because loading the chunk is done later, accesses to chunk attributes may
raise ChunkMalformed"""
if self._allChunks is not None: if not self.containsChunk(cx,cz):
if not (cx,cz) in self._allChunks:
raise ChunkNotPresent, (cx,cz); raise ChunkNotPresent, (cx,cz);
if not (cx,cz) in self._loadedChunks: if not (cx,cz) in self._loadedChunks:
self._loadedChunks[cx,cz] = InfdevChunk(self, (cx, cz)); self._loadedChunks[cx,cz] = InfdevChunk(self, (cx, cz));
return self._loadedChunks[cx,cz]
#raise ChunkNotPresent, "Chunk {0} not present".format((cx,cz)) def getChunk(self, cx, cz):
c = self._loadedChunks[cx,cz] """ read the chunk from disk, load it, and return it.
decompression and unpacking is done lazily."""
c = self._makeChunk(cx,cz)
c.load(); c.load();
if not (cx,cz) in self._loadedChunks: if not (cx,cz) in self._loadedChunks:
raise ChunkMalformed, "Chunk {0} malformed".format((cx,cz)) raise ChunkMalformed, "Chunk {0} malformed".format((cx,cz))