Merge pull request #862
This commit is contained in:
@@ -400,9 +400,9 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
|
|||||||
else:
|
else:
|
||||||
tex = texcache[texopts_key]
|
tex = texcache[texopts_key]
|
||||||
|
|
||||||
rset = w.get_regionset(render['dimension'])
|
rset = w.get_regionset(render['dimension'][1])
|
||||||
if rset == None: # indicates no such dimension was found:
|
if rset == None: # indicates no such dimension was found:
|
||||||
logging.error("Sorry, you requested dimension '%s' for %s, but I couldn't find it", render['dimension'], render_name)
|
logging.error("Sorry, you requested dimension '%s' for %s, but I couldn't find it", render['dimension'][0], render_name)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
#################
|
#################
|
||||||
|
|||||||
@@ -57,10 +57,9 @@ def handlePlayers(rset, render, worldpath):
|
|||||||
# only handle this region set once
|
# only handle this region set once
|
||||||
if 'Players' in rset._pois:
|
if 'Players' in rset._pois:
|
||||||
return
|
return
|
||||||
dimension = {'overworld': 0,
|
dimension = {None: 0,
|
||||||
'nether': -1,
|
'DIM-1': -1,
|
||||||
'end': 1,
|
'DIM1': 1}[rset.get_type()]
|
||||||
'default': 0}[render['dimension']]
|
|
||||||
playerdir = os.path.join(worldpath, "players")
|
playerdir = os.path.join(worldpath, "players")
|
||||||
if os.path.isdir(playerdir):
|
if os.path.isdir(playerdir):
|
||||||
playerfiles = os.listdir(playerdir)
|
playerfiles = os.listdir(playerdir)
|
||||||
@@ -165,9 +164,9 @@ def main():
|
|||||||
else:
|
else:
|
||||||
w = worldcache[render['world']]
|
w = worldcache[render['world']]
|
||||||
|
|
||||||
rset = w.get_regionset(render['dimension'])
|
rset = w.get_regionset(render['dimension'][1])
|
||||||
if rset == None: # indicates no such dimension was found:
|
if rset == None: # indicates no such dimension was found:
|
||||||
logging.error("Sorry, you requested dimension '%s' for %s, but I couldn't find it", render['dimension'], render_name)
|
logging.error("Sorry, you requested dimension '%s' for %s, but I couldn't find it", render['dimension'][0], render_name)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
for f in render['markers']:
|
for f in render['markers']:
|
||||||
|
|||||||
@@ -182,9 +182,20 @@ def validateStr(s):
|
|||||||
return str(s)
|
return str(s)
|
||||||
|
|
||||||
def validateDimension(d):
|
def validateDimension(d):
|
||||||
if d in ["nether", "overworld", "end", "default"]:
|
# returns (original, argument to get_type)
|
||||||
return d
|
|
||||||
raise ValidationException("%r is not a valid dimension" % d)
|
# these are provided as arguments to RegionSet.get_type()
|
||||||
|
pretty_names = {
|
||||||
|
"nether": "DIM-1",
|
||||||
|
"overworld": None,
|
||||||
|
"end": "DIM1",
|
||||||
|
"default": 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
return (d, pretty_names[d])
|
||||||
|
except KeyError:
|
||||||
|
return (d, d)
|
||||||
|
|
||||||
def validateOutputDir(d):
|
def validateOutputDir(d):
|
||||||
_, d = checkBadEscape(d)
|
_, d = checkBadEscape(d)
|
||||||
|
|||||||
@@ -524,7 +524,7 @@ class TileSet(object):
|
|||||||
base = self.options.get('base'),
|
base = self.options.get('base'),
|
||||||
bgcolor = bgcolorformat(self.options.get('bgcolor')),
|
bgcolor = bgcolorformat(self.options.get('bgcolor')),
|
||||||
world = self.options.get('worldname_orig') +
|
world = self.options.get('worldname_orig') +
|
||||||
(" - " + self.options.get('dimension') if self.options.get('dimension') != 'default' else ''),
|
(" - " + self.options.get('dimension')[0] if self.options.get('dimension')[1] != 0 else ''),
|
||||||
last_rendertime = self.max_chunk_mtime,
|
last_rendertime = self.max_chunk_mtime,
|
||||||
imgextension = self.imgextension,
|
imgextension = self.imgextension,
|
||||||
isOverlay = isOverlay,
|
isOverlay = isOverlay,
|
||||||
|
|||||||
@@ -121,8 +121,8 @@ class World(object):
|
|||||||
mcas = [x for x in files if x.endswith(".mca")]
|
mcas = [x for x in files if x.endswith(".mca")]
|
||||||
if mcas:
|
if mcas:
|
||||||
# construct a regionset object for this
|
# construct a regionset object for this
|
||||||
rset = RegionSet(root)
|
rel = os.path.relpath(root, self.worlddir)
|
||||||
if not rset.is_valid(): continue
|
rset = RegionSet(root, rel)
|
||||||
if root == os.path.join(self.worlddir, "region"):
|
if root == os.path.join(self.worlddir, "region"):
|
||||||
self.regionsets.insert(0, rset)
|
self.regionsets.insert(0, rset)
|
||||||
else:
|
else:
|
||||||
@@ -151,10 +151,7 @@ class World(object):
|
|||||||
def get_regionset(self, index):
|
def get_regionset(self, index):
|
||||||
if type(index) == int:
|
if type(index) == int:
|
||||||
return self.regionsets[index]
|
return self.regionsets[index]
|
||||||
else: # assume a string constant
|
else: # assume a get_type() value
|
||||||
if index == "default":
|
|
||||||
return self.regionsets[0]
|
|
||||||
else:
|
|
||||||
candids = [x for x in self.regionsets if x.get_type() == index]
|
candids = [x for x in self.regionsets if x.get_type() == index]
|
||||||
if len(candids) > 0:
|
if len(candids) > 0:
|
||||||
return candids[0]
|
return candids[0]
|
||||||
@@ -236,17 +233,28 @@ class RegionSet(object):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, regiondir):
|
def __init__(self, regiondir, rel):
|
||||||
"""Initialize a new RegionSet to access the region files in the given
|
"""Initialize a new RegionSet to access the region files in the given
|
||||||
directory.
|
directory.
|
||||||
|
|
||||||
regiondir is a path to a directory containing region files.
|
regiondir is a path to a directory containing region files.
|
||||||
|
|
||||||
|
rel is the relative path of this directory, with respect to the
|
||||||
|
world directory.
|
||||||
|
|
||||||
cachesize, if specified, is the number of chunks to keep parsed and
|
cachesize, if specified, is the number of chunks to keep parsed and
|
||||||
in-memory.
|
in-memory.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self.regiondir = os.path.normpath(regiondir)
|
self.regiondir = os.path.normpath(regiondir)
|
||||||
|
self.rel = os.path.normpath(rel)
|
||||||
|
|
||||||
|
# we want to get rid of /regions, if it exists
|
||||||
|
if self.rel.endswith(os.path.normpath("/region")):
|
||||||
|
self.type = self.rel[0:-len(os.path.normpath("/region"))]
|
||||||
|
if self.rel == "region":
|
||||||
|
# this is the main world
|
||||||
|
self.type = None
|
||||||
|
|
||||||
logging.debug("Scanning regions")
|
logging.debug("Scanning regions")
|
||||||
|
|
||||||
@@ -265,34 +273,21 @@ class RegionSet(object):
|
|||||||
|
|
||||||
# Re-initialize upon unpickling
|
# Re-initialize upon unpickling
|
||||||
def __getstate__(self):
|
def __getstate__(self):
|
||||||
return self.regiondir
|
return (self.regiondir, self.rel)
|
||||||
__setstate__ = __init__
|
def __setstate__(self, state):
|
||||||
|
return self.__init__(*state)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<RegionSet regiondir=%r>" % self.regiondir
|
return "<RegionSet regiondir=%r>" % self.regiondir
|
||||||
|
|
||||||
def is_valid(self):
|
|
||||||
"""If this region set isn't one of the three known regions, then
|
|
||||||
return False"""
|
|
||||||
try:
|
|
||||||
self.get_type()
|
|
||||||
return True
|
|
||||||
except Exception:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
"""Attempts to return a string describing the dimension represented by
|
"""Attempts to return a string describing the dimension
|
||||||
this regionset. Either "nether", "end" or "overworld"
|
represented by this regionset. Usually this is the relative
|
||||||
|
path of the regionset within the world, minus the suffix
|
||||||
|
/region, but for the main world it's None.
|
||||||
"""
|
"""
|
||||||
# path will be normalized in __init__
|
# path will be normalized in __init__
|
||||||
if self.regiondir.endswith(os.path.normpath("/DIM-1/region")):
|
return self.type
|
||||||
return "nether"
|
|
||||||
elif self.regiondir.endswith(os.path.normpath("/DIM1/region")):
|
|
||||||
return "end"
|
|
||||||
elif self.regiondir.endswith(os.path.normpath("/region")):
|
|
||||||
return "overworld"
|
|
||||||
else:
|
|
||||||
raise Exception("Woah, what kind of dimension is this?! %r" % self.regiondir)
|
|
||||||
|
|
||||||
def _get_regionobj(self, regionfilename):
|
def _get_regionobj(self, regionfilename):
|
||||||
# Check the cache first. If it's not there, create the
|
# Check the cache first. If it's not there, create the
|
||||||
|
|||||||
Reference in New Issue
Block a user