From 40231598d8482d7201b9eca7fe93269a83d18dbb Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Sat, 27 Aug 2011 17:16:01 -0400 Subject: [PATCH 1/7] command-line rendermodes can now be separated by ',', ':', or '/' This should fix Issue #472. --- README.rst | 4 ++++ overviewer.py | 2 +- overviewer_core/configParser.py | 8 +++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 0548053..510d083 100644 --- a/README.rst +++ b/README.rst @@ -191,6 +191,10 @@ Options a short description of each. If you provide more than one mode (separated by commas), Overviewer will render all of them at once, and provide a toggle on the resulting map to switch between them. + + If for some reason commas do not work for your shell (like if you're using + Powershell on Windows), you can also use a colon ':' or a forward slash '/' + to separate the modes. --list-rendermodes List the available render modes, and a short description of each. diff --git a/overviewer.py b/overviewer.py index b0103b7..c04001e 100755 --- a/overviewer.py +++ b/overviewer.py @@ -104,7 +104,7 @@ def main(): parser.add_option("-z", "--zoom", dest="zoom", helptext="Sets the zoom level manually instead of calculating it. This can be useful if you have outlier chunks that make your world too big. This value will make the highest zoom level contain (2**ZOOM)^2 tiles", action="store", type="int", advanced=True) parser.add_option("--regionlist", dest="regionlist", helptext="A file containing, on each line, a path to a regionlist to update. Instead of scanning the world directory for regions, it will just use this list. Normal caching rules still apply.") parser.add_option("--forcerender", dest="forcerender", helptext="Force re-rendering the entire map (or the given regionlist). Useful for re-rendering without deleting it.", action="store_true") - parser.add_option("--rendermodes", dest="rendermode", helptext="Specifies the render types, separated by commas. Use --list-rendermodes to list them all.", type="choice", choices=avail_rendermodes, required=True, default=avail_rendermodes[0], listify=True) + parser.add_option("--rendermodes", dest="rendermode", helptext="Specifies the render types, separated by ',', ':', or '/'. Use --list-rendermodes to list them all.", type="choice", choices=avail_rendermodes, required=True, default=avail_rendermodes[0], listify=True) parser.add_option("--list-rendermodes", dest="list_rendermodes", action="store_true", helptext="List available render modes and exit.", commandLineOnly=True) parser.add_option("--imgformat", dest="imgformat", helptext="The image output format to use. Currently supported: png(default), jpg.", advanced=True ) parser.add_option("--imgquality", dest="imgquality", default=95, helptext="Specify the quality of image output when using imgformat=\"jpg\".", type="int", advanced=True) diff --git a/overviewer_core/configParser.py b/overviewer_core/configParser.py index 621979d..af46a33 100644 --- a/overviewer_core/configParser.py +++ b/overviewer_core/configParser.py @@ -11,6 +11,7 @@ class ConfigOptionParser(object): def __init__(self, **kwargs): self.cmdParser = optparse.OptionParser(usage=kwargs.get("usage","")) self.configFile = kwargs.get("config","settings.py") + self.listifyDelimiters = kwargs.get("listdelim", ",:/") self.configVars = [] self.advancedHelp = [] # these are arguments not understood by OptionParser, so they must be removed @@ -154,7 +155,12 @@ class ConfigOptionParser(object): if 'listify' in a.keys(): # this thing may be a list! if configResults.__dict__[n] != None and type(configResults.__dict__[n]) == str: - configResults.__dict__[n] = configResults.__dict__[n].split(a.get("listdelim",",")) + delimiters = a.get("listdelim", self.listifyDelimiters) + # replace the rest of the delimiters with the first + for delim in delimiters[1:]: + configResults.__dict__[n] = configResults.__dict__[n].replace(delim, delimiters[0]) + # split at each occurance of the first delimiter + configResults.__dict__[n] = configResults.__dict__[n].split(delimiters[0]) elif type(configResults.__dict__[n]) != list: configResults.__dict__[n] = [configResults.__dict__[n]] if 'type' in a.keys() and configResults.__dict__[n] != None: From 33e85743f27de1b5106da1063ae73962bdd27033 Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Sun, 28 Aug 2011 12:18:51 +0200 Subject: [PATCH 2/7] Fix black dotted lines in night rendermode. Also reduces the night rendermode render time by a 10% and increses the lighting rendermode render time by a 5% (globally it reduces the render time). --- overviewer_core/src/rendermode-lighting.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/overviewer_core/src/rendermode-lighting.c b/overviewer_core/src/rendermode-lighting.c index 2c8b9b1..76d72a0 100644 --- a/overviewer_core/src/rendermode-lighting.c +++ b/overviewer_core/src/rendermode-lighting.c @@ -227,6 +227,24 @@ do_shading_with_mask(RenderModeLighting *self, RenderState *state, /* this face isn't visible, so don't draw anything */ return; } + } else if ((x == -1) && (state->left_blocks != Py_None)) { + unsigned char block = getArrayByte3D(state->left_blocks, 15, state->y, state->z); + if (!is_transparent(block)) { + /* the same thing but for adjacent chunks, this solves an + ugly black doted line between chunks in night rendermode. + This wouldn't be necessary if the textures were truly + tessellate-able */ + return; + } + } else if ((y == 16) && (state->right_blocks != Py_None)) { + unsigned char block = getArrayByte3D(state->right_blocks, state->x, 0, state->z); + if (!is_transparent(block)) { + /* the same thing but for adjacent chunks, this solves an + ugly black doted line between chunks in night rendermode. + This wouldn't be necessary if the textures were truly + tessellate-able */ + return; + } } black_coeff = get_lighting_coefficient(self, state, x, y, z); From 0d9aa0d9ca117f8c32632a894d987ef12768de08 Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Sun, 28 Aug 2011 19:15:27 +0200 Subject: [PATCH 3/7] Expand user directories for web_assets_path and textures_path options. Fixes #473 --- overviewer.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/overviewer.py b/overviewer.py index c04001e..1fbbd82 100755 --- a/overviewer.py +++ b/overviewer.py @@ -238,6 +238,12 @@ dir but you forgot to put quotes around the directory, since it contains spaces. else: north_direction = 'auto' + # Expand user dir in directories strings + if options.textures_path: + options.textures_path = os.path.expanduser(options.textures_path) + if options.web_assets_path: + options.web_assets_path = os.path.expanduser(options.web_assets_path) + logging.getLogger().setLevel( logging.getLogger().level + 10*options.quiet) logging.getLogger().setLevel( From c0dcda3d84152721dba14b46098b1e72091a27fc Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Tue, 30 Aug 2011 02:37:08 -0400 Subject: [PATCH 4/7] fixed clearOldCache.py contrib script to work with new python package --- contrib/clearOldCache.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/clearOldCache.py b/contrib/clearOldCache.py index 45f8b0a..14316a4 100644 --- a/contrib/clearOldCache.py +++ b/contrib/clearOldCache.py @@ -21,7 +21,7 @@ import os.path overviewer_dir = os.path.split(os.path.split(os.path.abspath(__file__))[0])[0] sys.path.insert(0, overviewer_dir) -import world +from overviewer_core import world from overviewer import list_worlds def main(): From e3fb3f4a660182768241d36d07990f59e26ad2d2 Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Sun, 4 Sep 2011 08:24:15 -0400 Subject: [PATCH 5/7] fixed testRender.py to work with newer overviewer.py --- contrib/testRender.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/testRender.py b/contrib/testRender.py index 4fa9e7e..a928b58 100644 --- a/contrib/testRender.py +++ b/contrib/testRender.py @@ -51,7 +51,10 @@ def clean_render(overviewerargs, quiet): try: # check_call raises CalledProcessError when overviewer.py exits badly check_call(['python', 'setup.py', 'clean', 'build'], quiet=quiet) - check_call([overviewer_script, '-d'] + overviewerargs, quiet=quiet) + try: + check_call([overviewer_script, '-d'] + overviewerargs, quiet=quiet) + except CalledProcessError: + pass starttime = time.time() check_call([overviewer_script,] + overviewerargs + [tempdir,], quiet=quiet) endtime = time.time() From 1cdac6ccdfe62507653828a6a6d38c26bd44f61b Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Mon, 5 Sep 2011 15:27:50 -0400 Subject: [PATCH 6/7] Fixed issue with finding minecraft.jar Fixes #477 --- overviewer_core/textures.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/overviewer_core/textures.py b/overviewer_core/textures.py index dc5fd69..856f7e2 100644 --- a/overviewer_core/textures.py +++ b/overviewer_core/textures.py @@ -82,8 +82,8 @@ def _find_file(filename, mode="rb", verbose=False): "Application Support", "minecraft","bin","minecraft.jar")) jarpaths.append(os.path.join(os.environ['HOME'], ".minecraft", "bin", "minecraft.jar")) - jarpaths.append(programdir) - jarpaths.append(os.getcwd()) + jarpaths.append(os.path.join(programdir,"minecraft.jar")) + jarpaths.append(os.path.join(os.getcwd(), "minecraft.jar")) for jarpath in jarpaths: if os.path.exists(jarpath): From f880f01b460d389c0575dc5679cab087092571f1 Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Mon, 5 Sep 2011 22:35:13 -0400 Subject: [PATCH 7/7] Moved --check-terrain command from setup.py and overviewer.py Also, let textures_path work for minecraft.jar files --- overviewer.py | 20 ++++++++++++++++++++ overviewer_core/textures.py | 13 ++++++++----- setup.py | 21 --------------------- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/overviewer.py b/overviewer.py index 1fbbd82..64a1a84 100755 --- a/overviewer.py +++ b/overviewer.py @@ -113,6 +113,7 @@ def main(): parser.add_option("--web-assets-hook", dest="web_assets_hook", helptext="If provided, run this function after the web assets have been copied, but before actual tile rendering begins. It should accept a QuadtreeGen object as its only argument.", action="store", metavar="SCRIPT", type="function", advanced=True) parser.add_option("--web-assets-path", dest="web_assets_path", helptext="Specifies a non-standard web_assets directory to use. Files here will overwrite the default web assets.", metavar="PATH", type="string", advanced=True) parser.add_option("--textures-path", dest="textures_path", helptext="Specifies a non-standard textures path, from which terrain.png and other textures are loaded.", metavar="PATH", type="string", advanced=True) + parser.add_option("--check-terrain", dest="check_terrain", helptext="Prints the location and hash of terrain.png, useful for debugging terrain.png problems", action="store_true", advanced=False, commandLineOnly=True) parser.add_option("-q", "--quiet", dest="quiet", action="count", default=0, helptext="Print less output. You can specify this option multiple times.") parser.add_option("-v", "--verbose", dest="verbose", action="count", default=0, helptext="Print more output. You can specify this option multiple times.") parser.add_option("--skip-js", dest="skipjs", action="store_true", helptext="Don't output marker.js or regions.js") @@ -143,6 +144,25 @@ def main(): print "{name:{0}} {description}".format(name_width, **info) sys.exit(0) + if options.check_terrain: + import hashlib + from overviewer_core.textures import _find_file + from overviewer_core import textures + if options.textures_path: + textures._find_file_local_path = options.textures_path + + try: + f = _find_file("terrain.png", verbose=True) + except IOError: + logging.error("Could not find the file terrain.png") + sys.exit(1) + + h = hashlib.sha1() + h.update(f.read()) + logging.info("Hash of terrain.png file is: %s", h.hexdigest()) + sys.exit(0) + + if options.advanced_help: parser.advanced_help() sys.exit(0) diff --git a/overviewer_core/textures.py b/overviewer_core/textures.py index 856f7e2..15bc30f 100644 --- a/overviewer_core/textures.py +++ b/overviewer_core/textures.py @@ -23,6 +23,7 @@ import math from random import randint import numpy from PIL import Image, ImageEnhance, ImageOps, ImageDraw +import logging import util import composite @@ -47,13 +48,13 @@ def _find_file(filename, mode="rb", verbose=False): if _find_file_local_path: path = os.path.join(_find_file_local_path, filename) if os.path.exists(path): - if verbose: print "Found %s in '%s'" % (filename, path) + if verbose: logging.info("Found %s in '%s'", filename, path) return open(path, mode) programdir = util.get_program_path() path = os.path.join(programdir, filename) if os.path.exists(path): - if verbose: print "Found %s in '%s'" % (filename, path) + if verbose: logging.info("Found %s in '%s'", filename, path) return open(path, mode) path = os.path.join(programdir, "overviewer_core", "data", "textures", filename) @@ -63,13 +64,13 @@ def _find_file(filename, mode="rb", verbose=False): # windows special case, when the package dir doesn't exist path = os.path.join(programdir, "textures", filename) if os.path.exists(path): - if verbose: print "Found %s in '%s'" % (filename, path) + if verbose: logging.info("Found %s in '%s'", filename, path) return open(path, mode) if sys.platform == "darwin": path = os.path.join("/Applications/Minecraft", filename) if os.path.exists(path): - if verbose: print "Found %s in '%s'" % (filename, path) + if verbose: logging.info("Found %s in '%s'", filename, path) return open(path, mode) # Find minecraft.jar. @@ -84,12 +85,14 @@ def _find_file(filename, mode="rb", verbose=False): "minecraft.jar")) jarpaths.append(os.path.join(programdir,"minecraft.jar")) jarpaths.append(os.path.join(os.getcwd(), "minecraft.jar")) + if _find_file_local_path: + jarpaths.append(os.path.join(_find_file_local_path, "minecraft.jar")) for jarpath in jarpaths: if os.path.exists(jarpath): try: jar = zipfile.ZipFile(jarpath) - if verbose: print "Found %s in '%s'" % (filename, jarpath) + if verbose: logging.info("Found %s in '%s'", filename, jarpath) return jar.open(filename) except (KeyError, IOError): pass diff --git a/setup.py b/setup.py index 823b5d3..dfe552f 100755 --- a/setup.py +++ b/setup.py @@ -251,32 +251,11 @@ class CustomBuildExt(build_ext): self.inplace = True build_ext.build_extensions(self) -class CheckTerrain(Command): - user_options=[] - def initialize_options(self): - pass - def finalize_options(self): - pass - def run(self): - from overviewer_core.textures import _find_file - import hashlib - import zipfile - print "checking..." - try: - f = _find_file("terrain.png", verbose=True) - except IOError: - log.error("Could not find the file terrain.png") - return - - h = hashlib.sha1() - h.update(f.read()) - log.info("Hash of terrain.png file is: %s", h.hexdigest()) setup_kwargs['cmdclass']['clean'] = CustomClean setup_kwargs['cmdclass']['sdist'] = CustomSDist setup_kwargs['cmdclass']['build'] = CustomBuild setup_kwargs['cmdclass']['build_ext'] = CustomBuildExt -setup_kwargs['cmdclass']['check_terrain'] = CheckTerrain ### setup(**setup_kwargs)