added an option to delete caches
This commit is contained in:
19
README.rst
19
README.rst
@@ -111,6 +111,25 @@ You can throw these files up to a web server to let others view your map. You
|
|||||||
do *not* need a Google Maps API key (as was the case with older versions of the
|
do *not* need a Google Maps API key (as was the case with older versions of the
|
||||||
API), so just copying the directory to your web server should suffice.
|
API), so just copying the directory to your web server should suffice.
|
||||||
|
|
||||||
|
Clearing the Cache
|
||||||
|
------------------
|
||||||
|
The Overviewer keeps two levels of cache: it saves each chunk rendered
|
||||||
|
individually along side your chunk files in your saved world directory, and it
|
||||||
|
keeps a hash file along side each tile in your output directory. Using these
|
||||||
|
cache files it will not re-render any image that has not changed.
|
||||||
|
|
||||||
|
If you want to clear the cache and re-render everything, run gmap.py with the
|
||||||
|
-d option::
|
||||||
|
|
||||||
|
python gmap.py -d <Path to World> <Output Directory>
|
||||||
|
|
||||||
|
The next time your map is rendered, it will re-render every chunk. This is
|
||||||
|
useful if you've changed texture packs or want to save disk space, but
|
||||||
|
otherwise not too useful.
|
||||||
|
|
||||||
|
This is probably *not* a good idea for very large worlds, since it will take
|
||||||
|
much longer to render the next time you do so.
|
||||||
|
|
||||||
Bugs
|
Bugs
|
||||||
====
|
====
|
||||||
This program has bugs. They are mostly minor things, I wouldn't have released a
|
This program has bugs. They are mostly minor things, I wouldn't have released a
|
||||||
|
|||||||
26
gmap.py
26
gmap.py
@@ -11,7 +11,7 @@ import world
|
|||||||
import quadtree
|
import quadtree
|
||||||
|
|
||||||
helptext = """
|
helptext = """
|
||||||
%prog [-p PROCS] <Path to World> <tiles dest dir>
|
%prog [-p PROCS] [-d] <Path to World> <tiles dest dir>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -21,6 +21,7 @@ def main():
|
|||||||
cpus = 1
|
cpus = 1
|
||||||
parser = OptionParser(usage=helptext)
|
parser = OptionParser(usage=helptext)
|
||||||
parser.add_option("-p", "--processes", dest="procs", help="How many chunks to render in parallel. A good number for this is the number of cores in your computer. Default %s" % cpus, default=cpus, action="store", type="int")
|
parser.add_option("-p", "--processes", dest="procs", help="How many chunks to render in parallel. A good number for this is the number of cores in your computer. Default %s" % cpus, default=cpus, action="store", type="int")
|
||||||
|
parser.add_option("-d", "--delete", dest="delete", help="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")
|
||||||
|
|
||||||
options, args = parser.parse_args()
|
options, args = parser.parse_args()
|
||||||
|
|
||||||
@@ -34,6 +35,9 @@ def main():
|
|||||||
parser.error("Where do you want to save the tiles?")
|
parser.error("Where do you want to save the tiles?")
|
||||||
destdir = args[1]
|
destdir = args[1]
|
||||||
|
|
||||||
|
if options.delete:
|
||||||
|
return delete_all(worlddir, destdir)
|
||||||
|
|
||||||
# First generate the world's chunk images
|
# First generate the world's chunk images
|
||||||
w = world.WorldRenderer(worlddir)
|
w = world.WorldRenderer(worlddir)
|
||||||
w.go(options.procs)
|
w.go(options.procs)
|
||||||
@@ -42,5 +46,25 @@ def main():
|
|||||||
q = quadtree.QuadtreeGen(w, destdir)
|
q = quadtree.QuadtreeGen(w, destdir)
|
||||||
q.go(options.procs)
|
q.go(options.procs)
|
||||||
|
|
||||||
|
def delete_all(worlddir, tiledir):
|
||||||
|
# First delete all images in the world dir
|
||||||
|
imgre = r"img\.[^.]+\.[^.]+\.nocave\.\w+\.png$"
|
||||||
|
matcher = re.compile(imgre)
|
||||||
|
|
||||||
|
for dirpath, dirnames, filenames in os.walk(worlddir):
|
||||||
|
for f in filenames:
|
||||||
|
if matcher.match(f):
|
||||||
|
filepath = os.path.join(dirpath, f)
|
||||||
|
print "Deleting {0}".format(filepath)
|
||||||
|
os.unlink(filepath)
|
||||||
|
|
||||||
|
# Now delete all /hash/ files in the tile dir.
|
||||||
|
for dirpath, dirnames, filenames in os.walk(tiledir):
|
||||||
|
for f in filenames:
|
||||||
|
if f.endswith(".hash"):
|
||||||
|
filepath = os.path.join(dirpath, f)
|
||||||
|
print "Deleting {0}".format(filepath)
|
||||||
|
os.unlink(filepath)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user