cleaned up some mess, clarified some things in comments
This commit is contained in:
@@ -133,22 +133,29 @@ class World(object):
|
|||||||
self.north_direction = self.persistentData['north_direction']
|
self.north_direction = self.persistentData['north_direction']
|
||||||
north_direction = self.north_direction
|
north_direction = self.north_direction
|
||||||
|
|
||||||
#find region files, or load the region list
|
# This is populated by reload_region(). It is a mapping from region
|
||||||
#this also caches all the region file header info
|
# filename to: (region object, mtime, chunkcache)
|
||||||
logging.info("Scanning regions")
|
|
||||||
regionfiles = {}
|
|
||||||
self.regions = {}
|
self.regions = {}
|
||||||
|
|
||||||
|
# This is populated below. It is a mapping from (x,y) region coords to
|
||||||
|
# (x,y,filename, region object)
|
||||||
|
self.regionfiles = {}
|
||||||
|
|
||||||
|
# If a region list was given, make sure the given paths are absolute
|
||||||
if regionlist:
|
if regionlist:
|
||||||
self.regionlist = map(os.path.abspath, regionlist) # a list of paths
|
self.regionlist = map(os.path.abspath, regionlist)
|
||||||
else:
|
else:
|
||||||
self.regionlist = None
|
self.regionlist = None
|
||||||
|
|
||||||
|
logging.info("Scanning regions")
|
||||||
|
|
||||||
|
# Loads requested/all regions, caching region header info
|
||||||
for x, y, regionfile in self._iterate_regionfiles(regionlist):
|
for x, y, regionfile in self._iterate_regionfiles(regionlist):
|
||||||
|
# reload_region caches the region object in self.regions
|
||||||
mcr = self.reload_region(regionfile)
|
mcr = self.reload_region(regionfile)
|
||||||
mcr.get_chunk_info()
|
mcr.get_chunk_info()
|
||||||
regionfiles[(x,y)] = (x,y,regionfile,mcr)
|
self.regionfiles[(x,y)] = (x,y,regionfile,mcr)
|
||||||
self.regionfiles = regionfiles
|
|
||||||
# set the number of region file handles we will permit open at any time before we start closing them
|
|
||||||
# self.regionlimit = 1000
|
|
||||||
# the max number of chunks we will keep before removing them (includes emptry chunks)
|
# the max number of chunks we will keep before removing them (includes emptry chunks)
|
||||||
self.chunklimit = 1024
|
self.chunklimit = 1024
|
||||||
self.chunkcount = 0
|
self.chunkcount = 0
|
||||||
@@ -182,7 +189,7 @@ class World(object):
|
|||||||
return None ## return none. I think this is who we should indicate missing chunks
|
return None ## return none. I think this is who we should indicate missing chunks
|
||||||
#raise IOError("No such chunk in region: (%i, %i)" % (x, y))
|
#raise IOError("No such chunk in region: (%i, %i)" % (x, y))
|
||||||
|
|
||||||
#we cache the transformed data, not it's raw form
|
#we cache the transformed data, not its raw form
|
||||||
data = nbt.read_all()
|
data = nbt.read_all()
|
||||||
level = data[1]['Level']
|
level = data[1]['Level']
|
||||||
chunk_data = level
|
chunk_data = level
|
||||||
@@ -382,7 +389,7 @@ class World(object):
|
|||||||
y = -temp-1
|
y = -temp-1
|
||||||
yield (x, y, join(self.worlddir, 'region', f))
|
yield (x, y, join(self.worlddir, 'region', f))
|
||||||
else:
|
else:
|
||||||
logging.warning("Ignore path '%s' in regionlist", f)
|
logging.warning("Ignoring non region file '%s' in regionlist", f)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
for path in glob(os.path.join(self.worlddir, 'region') + "/r.*.*.mcr"):
|
for path in glob(os.path.join(self.worlddir, 'region') + "/r.*.*.mcr"):
|
||||||
|
|||||||
Reference in New Issue
Block a user