Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -5,17 +5,15 @@ This script will scan through every chunk looking for signs and write out an
|
|||||||
updated overviewer.dat file. This can be useful if your overviewer.dat file
|
updated overviewer.dat file. This can be useful if your overviewer.dat file
|
||||||
is either out-of-date or non-existant.
|
is either out-of-date or non-existant.
|
||||||
|
|
||||||
To run, simply give a path to your world directory, for example:
|
To run, simply give a path to your world directory and the path to your
|
||||||
|
output directory. For example:
|
||||||
|
|
||||||
python contrib/findSigns.py ../world.test/
|
python contrib/findSigns.py ../world.test/ output_dir/
|
||||||
|
|
||||||
Once that is done, simply re-run the overviewer to generate markers.js:
|
Once that is done, simply re-run the overviewer to generate markers.js:
|
||||||
|
|
||||||
python overviewer.py ../world.test/ output_dir/
|
python overviewer.py ../world.test/ output_dir/
|
||||||
|
|
||||||
Note: if your cachedir is not the same as your world-dir, you'll need to manually
|
|
||||||
move overviewer.dat into the correct location.
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
@@ -23,16 +21,22 @@ import os
|
|||||||
import cPickle
|
import cPickle
|
||||||
|
|
||||||
sys.path.append(".")
|
sys.path.append(".")
|
||||||
import nbt
|
from overviewer_core import nbt
|
||||||
|
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|
||||||
worlddir = sys.argv[1]
|
worlddir = sys.argv[1]
|
||||||
|
outputdir = sys.argv[2]
|
||||||
if os.path.exists(worlddir):
|
if os.path.exists(worlddir):
|
||||||
print "Scanning chunks in ", worlddir
|
print "Scanning chunks in ", worlddir
|
||||||
else:
|
else:
|
||||||
sys.exit("Bad WorldDir")
|
sys.exit("Bad WorldDir")
|
||||||
|
|
||||||
|
if os.path.exists(outputdir):
|
||||||
|
print "Output directory is ", outputdir
|
||||||
|
else:
|
||||||
|
sys.exit("Bad OutputDir")
|
||||||
|
|
||||||
matcher = re.compile(r"^r\..*\.mcr$")
|
matcher = re.compile(r"^r\..*\.mcr$")
|
||||||
|
|
||||||
POI = []
|
POI = []
|
||||||
@@ -63,8 +67,12 @@ for dirpath, dirnames, filenames in os.walk(worlddir):
|
|||||||
print "Found sign at (%d, %d, %d): %r" % (newPOI['x'], newPOI['y'], newPOI['z'], newPOI['msg'])
|
print "Found sign at (%d, %d, %d): %r" % (newPOI['x'], newPOI['y'], newPOI['z'], newPOI['msg'])
|
||||||
|
|
||||||
|
|
||||||
|
if os.path.isfile(os.path.join(worlddir, "overviewer.dat")):
|
||||||
|
print "Overviewer.dat detected in WorldDir - this is no longer the correct location\n"
|
||||||
|
print "You may wish to delete the old file. A new overviewer.dat will be created\n"
|
||||||
|
print "Old file: ", os.path.join(worlddir, "overviewer.dat")
|
||||||
|
|
||||||
pickleFile = os.path.join(worlddir,"overviewer.dat")
|
pickleFile = os.path.join(outputdir,"overviewer.dat")
|
||||||
with open(pickleFile,"wb") as f:
|
with open(pickleFile,"wb") as f:
|
||||||
cPickle.dump(dict(POI=POI), f)
|
cPickle.dump(dict(POI=POI), f)
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,9 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
if not (sys.version_info[0] == 2 and sys.version_info[1] >= 6):
|
if not (sys.version_info[0] == 2 and sys.version_info[1] >= 6):
|
||||||
print "Sorry, the Overviewer requires at least Python 2.6 to run" # Python3.0 is not supported either
|
print "Sorry, the Overviewer requires at least Python 2.6 to run"
|
||||||
|
if sys.version_info[0] >= 3:
|
||||||
|
print "and will not run on Python 3.0 or later"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@@ -84,9 +86,7 @@ from overviewer_core import googlemap, rendernode
|
|||||||
|
|
||||||
|
|
||||||
helptext = """
|
helptext = """
|
||||||
%prog [OPTIONS] <World # / Name / Path to World> <tiles dest dir>
|
%prog [OPTIONS] <World # / Name / Path to World> <tiles dest dir>"""
|
||||||
%prog -d <World # / Name / Path to World / Path to cache dir> [tiles dest dir]"""
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -101,14 +101,13 @@ def main():
|
|||||||
parser.add_option("-V", "--version", dest="version", helptext="Displays version information and then exits", action="store_true")
|
parser.add_option("-V", "--version", dest="version", helptext="Displays version information and then exits", action="store_true")
|
||||||
parser.add_option("-p", "--processes", dest="procs", helptext="How many worker processes to start. Default %s" % cpus, default=cpus, action="store", type="int")
|
parser.add_option("-p", "--processes", dest="procs", helptext="How many worker processes to start. Default %s" % cpus, default=cpus, action="store", type="int")
|
||||||
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("-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("-d", "--delete", dest="delete", helptext="Clear all caches. Next time you render your world, it will have to start completely over again. This is probably not a good idea for large worlds. Use this if you change texture packs and want to re-render everything.", action="store_true", commandLineOnly=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("--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 the entire map with --delete.", action="store_true")
|
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 commas. 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("--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("--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)
|
parser.add_option("--imgquality", dest="imgquality", default=95, helptext="Specify the quality of image output when using imgformat=\"jpg\".", type="int", advanced=True)
|
||||||
parser.add_option("--bg_color", dest="bg_color", helptext="Configures the background color for the GoogleMap output. Specify in #RRGGBB format", advanced=True, type="string", default="#1A1A1A")
|
parser.add_option("--bg-color", dest="bg_color", helptext="Configures the background color for the GoogleMap output. Specify in #RRGGBB format", advanced=True, type="string", default="#1A1A1A")
|
||||||
parser.add_option("--optimize-img", dest="optimizeimg", helptext="If using png, perform image file size optimizations on the output. Specify 1 for pngcrush, 2 for pngcrush+advdef and 3 for pngcrush-advdef with more agressive settings. This may double (or more) render times, but will produce up to 30% smaller images. NOTE: requires corresponding programs in $PATH or %PATH%", advanced=True)
|
parser.add_option("--optimize-img", dest="optimizeimg", helptext="If using png, perform image file size optimizations on the output. Specify 1 for pngcrush, 2 for pngcrush+advdef and 3 for pngcrush-advdef with more agressive settings. This may double (or more) render times, but will produce up to 30% smaller images. NOTE: requires corresponding programs in $PATH or %PATH%", advanced=True)
|
||||||
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-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("--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)
|
||||||
@@ -187,13 +186,9 @@ def main():
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if len(args) < 2:
|
if len(args) < 2:
|
||||||
if options.delete:
|
|
||||||
return delete_all(worlddir, None)
|
|
||||||
logging.error("Where do you want to save the tiles?")
|
logging.error("Where do you want to save the tiles?")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
elif len(args) > 2:
|
elif len(args) > 2:
|
||||||
if options.delete:
|
|
||||||
return delete_all(worlddir, None)
|
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
logging.error("Sorry, you specified too many arguments")
|
logging.error("Sorry, you specified too many arguments")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@@ -206,9 +201,6 @@ def main():
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
if options.delete:
|
|
||||||
return delete_all(worlddir, destdir)
|
|
||||||
|
|
||||||
if options.regionlist:
|
if options.regionlist:
|
||||||
regionlist = map(str.strip, open(options.regionlist, 'r'))
|
regionlist = map(str.strip, open(options.regionlist, 'r'))
|
||||||
else:
|
else:
|
||||||
@@ -241,7 +233,7 @@ def main():
|
|||||||
logging.info("Notice: Not using biome data for tinting")
|
logging.info("Notice: Not using biome data for tinting")
|
||||||
|
|
||||||
# First do world-level preprocessing
|
# First do world-level preprocessing
|
||||||
w = world.World(worlddir, useBiomeData=useBiomeData, regionlist=regionlist)
|
w = world.World(worlddir, destdir, useBiomeData=useBiomeData, regionlist=regionlist)
|
||||||
w.go(options.procs)
|
w.go(options.procs)
|
||||||
|
|
||||||
logging.info("Rending the following tilesets: %s", ",".join(options.rendermode))
|
logging.info("Rending the following tilesets: %s", ",".join(options.rendermode))
|
||||||
@@ -277,15 +269,6 @@ def main():
|
|||||||
m.finalize()
|
m.finalize()
|
||||||
|
|
||||||
|
|
||||||
def delete_all(worlddir, tiledir):
|
|
||||||
# TODO should we delete tiledir here too?
|
|
||||||
|
|
||||||
# delete the overviewer.dat persistant data file
|
|
||||||
datfile = os.path.join(worlddir,"overviewer.dat")
|
|
||||||
if os.path.exists(datfile):
|
|
||||||
os.unlink(datfile)
|
|
||||||
logging.info("Deleting {0}".format(datfile))
|
|
||||||
|
|
||||||
def list_worlds():
|
def list_worlds():
|
||||||
"Prints out a brief summary of saves found in the default directory"
|
"Prints out a brief summary of saves found in the default directory"
|
||||||
print
|
print
|
||||||
|
|||||||
@@ -128,8 +128,8 @@ solid_blocks = set([1, 2, 3, 4, 5, 7, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22
|
|||||||
fluid_blocks = set([8,9,10,11])
|
fluid_blocks = set([8,9,10,11])
|
||||||
|
|
||||||
# This set holds block ids that are not candidates for spawning mobs on
|
# This set holds block ids that are not candidates for spawning mobs on
|
||||||
# (glass, half blocks)
|
# (glass, half blocks, fluids)
|
||||||
nospawn_blocks = set([20,44])
|
nospawn_blocks = set([20,44]).union(fluid_blocks)
|
||||||
|
|
||||||
class ChunkCorrupt(Exception):
|
class ChunkCorrupt(Exception):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ class ConfigOptionParser(object):
|
|||||||
g = dict()
|
g = dict()
|
||||||
for a in self.configVars:
|
for a in self.configVars:
|
||||||
n = a['dest']
|
n = a['dest']
|
||||||
if a.get('advanced', False): continue
|
|
||||||
if a.get('commandLineOnly', False): continue
|
if a.get('commandLineOnly', False): continue
|
||||||
v = getattr(options, n)
|
v = getattr(options, n)
|
||||||
if v != None:
|
if v != None:
|
||||||
@@ -133,7 +132,6 @@ class ConfigOptionParser(object):
|
|||||||
# third, merge options into configReslts (with options overwriting anything in configResults)
|
# third, merge options into configReslts (with options overwriting anything in configResults)
|
||||||
for a in self.configVars:
|
for a in self.configVars:
|
||||||
n = a['dest']
|
n = a['dest']
|
||||||
if a.get('advanced', False): continue
|
|
||||||
if getattr(options, n) != None:
|
if getattr(options, n) != None:
|
||||||
configResults.__dict__[n] = getattr(options, n)
|
configResults.__dict__[n] = getattr(options, n)
|
||||||
|
|
||||||
|
|||||||
@@ -69,8 +69,9 @@ class World(object):
|
|||||||
|
|
||||||
mincol = maxcol = minrow = maxrow = 0
|
mincol = maxcol = minrow = maxrow = 0
|
||||||
|
|
||||||
def __init__(self, worlddir, useBiomeData=False,regionlist=None):
|
def __init__(self, worlddir, outputdir, useBiomeData=False,regionlist=None):
|
||||||
self.worlddir = worlddir
|
self.worlddir = worlddir
|
||||||
|
self.outputdir = outputdir
|
||||||
self.useBiomeData = useBiomeData
|
self.useBiomeData = useBiomeData
|
||||||
|
|
||||||
#find region files, or load the region list
|
#find region files, or load the region list
|
||||||
@@ -111,8 +112,20 @@ class World(object):
|
|||||||
# info self.persistentData. This dictionary can hold any information
|
# info self.persistentData. This dictionary can hold any information
|
||||||
# that may be needed between runs.
|
# that may be needed between runs.
|
||||||
# Currently only holds into about POIs (more more details, see quadtree)
|
# Currently only holds into about POIs (more more details, see quadtree)
|
||||||
# TODO maybe store this with the tiles, not with the world?
|
|
||||||
self.pickleFile = os.path.join(self.worlddir, "overviewer.dat")
|
self.pickleFile = os.path.join(self.worlddir, "overviewer.dat")
|
||||||
|
if os.path.exists(self.pickleFile):
|
||||||
|
logging.warning("overviewer.dat detected in WorldDir - this is no longer the correct location")
|
||||||
|
logging.warning("Moving overviewer.dat to OutputDir")
|
||||||
|
import shutil
|
||||||
|
try:
|
||||||
|
shutil.move(self.pickleFile, self.outputdir)
|
||||||
|
logging.info("overviewer.dat moved")
|
||||||
|
except BaseException as ex:
|
||||||
|
logging.error("Unable to move overviewer.dat")
|
||||||
|
logging.debug(ex.str())
|
||||||
|
|
||||||
|
self.pickleFile = os.path.join(self.outputdir, "overviewer.dat")
|
||||||
if os.path.exists(self.pickleFile):
|
if os.path.exists(self.pickleFile):
|
||||||
with open(self.pickleFile,"rb") as p:
|
with open(self.pickleFile,"rb") as p:
|
||||||
self.persistentData = cPickle.load(p)
|
self.persistentData = cPickle.load(p)
|
||||||
|
|||||||
Reference in New Issue
Block a user