From cd2a2bdf2c6df551359087766d07b5d7ddc8d6d5 Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Tue, 16 Aug 2011 20:52:43 -0400 Subject: [PATCH 01/13] initial version of the contribManager --- contribManager.py | 38 ++++++++++++++++++++++++++++++++++++++ setup.py | 3 ++- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100755 contribManager.py diff --git a/contribManager.py b/contribManager.py new file mode 100755 index 0000000..7f1ab3f --- /dev/null +++ b/contribManager.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python + +# The contrib manager is used to help control the contribs script +# that are shipped with overviewer in Windows packages + +import sys +import os.path + +scripts=dict( # keys are names, values are scripts + benchmark="benchmark.py", + findSigns="findSigns.py", + validate="validateRegionFile.py" + ) + + +# figure out what script to execute +argv=os.path.basename(sys.argv[0]) + +if argv[-4:] == ".exe": + argv=argv[0:-4] +if argv[-3:] == ".py": + argv=argv[0:-3] + +print "argv is ", argv + +if argv in scripts.keys(): + script = scripts[argv] +else: + if sys.argv[1] in scripts.keys(): + script = scripts[sys.argv[1]] + else: + print "what do you want to run?" + sys.exit(1) + + +print "running", script + +execfile(os.path.join("contrib", script)) diff --git a/setup.py b/setup.py index e105bf6..a52880c 100755 --- a/setup.py +++ b/setup.py @@ -91,10 +91,11 @@ def recursive_package_data(src, package_dir='overviewer_core'): # if py2exe is not None: - setup_kwargs['console'] = ['overviewer.py'] + setup_kwargs['console'] = ['overviewer.py', 'contribManager.py'] setup_kwargs['data_files'] = [('', doc_files)] setup_kwargs['data_files'] += recursive_data_files('overviewer_core/data/textures', 'textures') setup_kwargs['data_files'] += recursive_data_files('overviewer_core/data/web_assets', 'web_assets') + setup_kwargs['data_files'] += recursive_data_files('contrib', 'contrib') setup_kwargs['zipfile'] = None if platform.system() == 'Windows' and '64bit' in platform.architecture(): b = 3 From 99932f35a3eb67b7c434602b7b0d2fe7855e4cf7 Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Wed, 17 Aug 2011 09:16:39 -0400 Subject: [PATCH 02/13] Minor changes to the contrib manager add --list-contribs option construct sys.argv correctly for the contrib scripts --- contribManager.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/contribManager.py b/contribManager.py index 7f1ab3f..f750b90 100755 --- a/contribManager.py +++ b/contribManager.py @@ -5,6 +5,8 @@ import sys import os.path +sys.path.append("overviewer_core") +import nbt scripts=dict( # keys are names, values are scripts benchmark="benchmark.py", @@ -12,6 +14,12 @@ scripts=dict( # keys are names, values are scripts validate="validateRegionFile.py" ) +# you can symlink or hardlink contribManager.py to another name to have it +# automatically find the right script to run. For example: +# > ln -s contribManager.py validate.exe +# > chmod +x validate.exe +# > ./validate.exe -h + # figure out what script to execute argv=os.path.basename(sys.argv[0]) @@ -21,18 +29,26 @@ if argv[-4:] == ".exe": if argv[-3:] == ".py": argv=argv[0:-3] -print "argv is ", argv - if argv in scripts.keys(): script = scripts[argv] + sys.argv[0] = script else: - if sys.argv[1] in scripts.keys(): + if "--list-contribs" in sys.argv: + print scripts.keys() + sys.exit(0) + if len(sys.argv) > 1 and sys.argv[1] in scripts.keys(): script = scripts[sys.argv[1]] + sys.argv = [script] + sys.argv[2:] else: print "what do you want to run?" sys.exit(1) -print "running", script +torun = os.path.join("contrib", script) + +if not os.path.exists(torun): + print "Script '%s' is missing!" % script + sys.exit(1) + +execfile(torun) -execfile(os.path.join("contrib", script)) From 320f7a178c1a1c3694acc37c98206428f17f0698 Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Thu, 18 Aug 2011 20:40:36 -0400 Subject: [PATCH 03/13] Fixed lighting issue If more than one half-step or stair is stacked on top of another, the bottom steps/stairs will be black in a lighting render. This is now fixed --- overviewer_core/src/overviewer.h | 2 +- overviewer_core/src/rendermode-lighting.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/overviewer_core/src/overviewer.h b/overviewer_core/src/overviewer.h index e7057e7..4a273bf 100644 --- a/overviewer_core/src/overviewer.h +++ b/overviewer_core/src/overviewer.h @@ -26,7 +26,7 @@ // increment this value if you've made a change to the c extesion // and want to force users to rebuild -#define OVERVIEWER_EXTENSION_VERSION 8 +#define OVERVIEWER_EXTENSION_VERSION 9 /* Python PIL, and numpy headers */ #include diff --git a/overviewer_core/src/rendermode-lighting.c b/overviewer_core/src/rendermode-lighting.c index 057331a..2c8b9b1 100644 --- a/overviewer_core/src/rendermode-lighting.c +++ b/overviewer_core/src/rendermode-lighting.c @@ -185,9 +185,14 @@ get_lighting_coefficient(RenderModeLighting *self, RenderState *state, /* stairs and half-blocks take the skylevel from the upper block if it's transparent */ if (local_z != 127) { - upper_block = getArrayByte3D(blocks, local_x, local_y, local_z + 1); + int upper_counter = 0; + /* but if the upper_block is one of these special half-steps, we need to look at *its* upper_block */ + do { + upper_counter++; + upper_block = getArrayByte3D(blocks, local_x, local_y, local_z + upper_counter); + } while ((upper_block == 44 || upper_block == 54 || upper_block == 67) && local_z < 127); if (is_transparent(upper_block)) { - skylevel = getArrayByte3D(skylight, local_x, local_y, local_z + 1); + skylevel = getArrayByte3D(skylight, local_x, local_y, local_z + upper_counter); } } else { upper_block = 0; @@ -195,7 +200,7 @@ get_lighting_coefficient(RenderModeLighting *self, RenderState *state, } /* the block has a bad blocklevel, estimate it from neigborhood - /* use given coordinates, no local ones! */ + * use given coordinates, no local ones! */ blocklevel = estimate_blocklevel(self, state, x, y, z, NULL); } From 5ae1fc4b640986e4f0dd5b4173ef30e8383776b2 Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Fri, 19 Aug 2011 09:20:49 -0400 Subject: [PATCH 04/13] Very basic player.dat inspection script --- contrib/playerInspect.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 contrib/playerInspect.py diff --git a/contrib/playerInspect.py b/contrib/playerInspect.py new file mode 100644 index 0000000..0c3ff86 --- /dev/null +++ b/contrib/playerInspect.py @@ -0,0 +1,16 @@ +import sys + +sys.path.append(".") + +from overviewer_core.nbt import load + +print "Inspecting %s" % sys.argv[1] + +data = load(sys.argv[1])[1] + + +print "Position: %r" % data['Pos'] +print "Health: %s" % data['Health'] +print "Inventory: %d items" % len(data['Inventory']) +for item in data['Inventory']: + print " %r" % item From 88e889301a8cd4c09bf15dc535bfded88634381c Mon Sep 17 00:00:00 2001 From: asmodai Date: Fri, 19 Aug 2011 11:22:45 -0400 Subject: [PATCH 05/13] Added new items.py file with list of itemID and names --- contrib/playerInspect.py | 4 +- overviewer_core/items.py | 211 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 214 insertions(+), 1 deletion(-) create mode 100644 overviewer_core/items.py diff --git a/contrib/playerInspect.py b/contrib/playerInspect.py index 0c3ff86..c520788 100644 --- a/contrib/playerInspect.py +++ b/contrib/playerInspect.py @@ -3,6 +3,7 @@ import sys sys.path.append(".") from overviewer_core.nbt import load +from overviewer_core import items print "Inspecting %s" % sys.argv[1] @@ -13,4 +14,5 @@ print "Position: %r" % data['Pos'] print "Health: %s" % data['Health'] print "Inventory: %d items" % len(data['Inventory']) for item in data['Inventory']: - print " %r" % item + print " %-3d %s" % (item['Count'], items.id2item(item['id'])) + diff --git a/overviewer_core/items.py b/overviewer_core/items.py new file mode 100644 index 0000000..9b01aed --- /dev/null +++ b/overviewer_core/items.py @@ -0,0 +1,211 @@ +items = { + 0: 'Air', + 1: 'Stone', + 2: 'Grass', + 3: 'Dirt', + 4: 'Cobblestone', + 5: 'Wooden plank', + 6: 'Sapling', + 7: 'Bedrock', + 8: 'Water', + 9: 'Stationary', + 10: 'Lava', + 11: 'Stationary', + 12: 'Sand', + 13: 'Gravel', + 14: 'Gold ore', + 15: 'Iron ore', + 16: 'Coal ore', + 17: 'Wood', + 18: 'Leaves', + 19: 'Sponge', + 20: 'Glass', + 21: 'Lapis lazuli ore', + 22: 'Lapis lazuli block', + 23: 'Dispenser', + 24: 'Sandstone', + 25: 'Note block', + 26: 'Bed', + 27: 'Powered rail', + 28: 'Detector rail', + 29: 'Sticky piston', + 30: 'Cobweb', + 31: 'Tall grass', + 32: 'Dead shrubs', + 33: 'Piston', + 34: 'Piston extension', + 35: 'Wool', + 36: 'Block moved by piston', + 37: 'Dandelion', + 38: 'Rose', + 39: 'Brown mushroom', + 40: 'Red mushroom', + 41: 'Block of gold', + 42: 'Block of iron', + 43: 'Double slabs', + 44: 'Slabs', + 45: 'Brick block', + 46: 'TNT', + 47: 'Bookshelf', + 48: 'Moss stone', + 49: 'Obsidian', + 50: 'Torch', + 51: 'Fire', + 52: 'Monster spawner', + 53: 'Wooden stairs', + 54: 'Chest', + 55: 'Redstone wire', + 56: 'Diamond ore', + 57: 'Block of diamond', + 58: 'Crafting table', + 59: 'Seeds', + 60: 'Farmland', + 61: 'Furnace', + 62: 'Burning furnace', + 63: 'Sign', + 64: 'Wooden door', + 65: 'Ladders', + 66: 'Rails', + 67: 'Cobblestone stairs', + 68: 'Wall sign', + 69: 'Lever', + 70: 'Stone pressure plate', + 71: 'Iron door', + 72: 'Wooden pressure plate', + 73: 'Redstone ore', + 74: 'Glowing redstone ore', + 75: 'Redstone torch (off)', + 76: 'Redstone torch (on)', + 77: 'Stone button', + 78: 'Snow', + 79: 'Ice', + 80: 'Snow block', + 81: 'Cactus', + 82: 'Clay block', + 83: 'Sugar cane', + 84: 'Jukebox', + 85: 'Fence', + 86: 'Pumpkin', + 87: 'Netherrack', + 88: 'Soul sand', + 89: 'Glowstone block', + 90: 'Portal', + 91: 'Jack-O-Lantern', + 92: 'Cake', + 93: 'Redstone repeater (off)', + 94: 'Redstone repeater (on)', + 95: 'Locked', + 96: 'Trapdoor', + 256: 'Iron shovel', + 257: 'Iron pickaxe', + 258: 'Iron axe', + 259: 'Flint and steel', + 260: 'Red apple', + 261: 'Bow', + 262: 'Arrow', + 263: 'Coal', + 264: 'Diamond', + 265: 'Iron ingot', + 266: 'Gold ingot', + 267: 'Iron sword', + 268: 'Wooden sword', + 269: 'Wooden shovel', + 270: 'Wooden pickaxe', + 271: 'Wooden axe', + 272: 'Stone sword', + 273: 'Stone shovel', + 274: 'Stone pickaxe', + 275: 'Stone axe', + 276: 'Diamond sword', + 277: 'Diamond shovel', + 278: 'Diamond pickaxe', + 279: 'Diamond axe', + 280: 'Stick', + 281: 'Bowl', + 282: 'Mushroom soup', + 283: 'Gold sword', + 284: 'Gold shovel', + 285: 'Gold pickaxe', + 286: 'Gold axe', + 287: 'String', + 288: 'Feather', + 289: 'Gunpowder', + 290: 'Wooden hoe', + 291: 'Stone hoe', + 292: 'Iron hoe', + 293: 'Diamond hoe', + 294: 'Gold hoe', + 295: 'Seeds', + 296: 'Wheat', + 297: 'Bread', + 298: 'Leather cap', + 299: 'Leather tunic', + 300: 'Leather pants', + 301: 'Leather boots', + 302: 'Chain helmet', + 303: 'Chain chestplate', + 304: 'Chain leggings', + 305: 'Chain boots', + 306: 'Iron helmet', + 307: 'Iron chestplate', + 308: 'Iron leggings', + 309: 'Iron boots', + 310: 'Diamond helmet', + 311: 'Diamond chestplate', + 312: 'Diamond leggings', + 313: 'Diamond boots', + 314: 'Gold helmet', + 315: 'Gold chestplate', + 316: 'Gold leggings', + 317: 'Gold boots', + 318: 'Flint', + 319: 'Raw porkchop', + 320: 'Cooked porkchop', + 321: 'Paintings', + 322: 'Golden apple', + 323: 'Sign', + 324: 'Wooden door', + 325: 'Bucket', + 326: 'Water bucket', + 327: 'Lava bucket', + 328: 'Minecart', + 329: 'Saddle', + 330: 'Iron door', + 331: 'Redstone', + 332: 'Snowball', + 333: 'Boat', + 334: 'Leather', + 335: 'Milk', + 336: 'Clay brick', + 337: 'Clay', + 338: 'Sugar cane', + 339: 'Paper', + 340: 'Book', + 341: 'Slimeball', + 342: 'Minecart with chest', + 343: 'Minecart with furnace', + 344: 'Egg', + 345: 'Compass', + 346: 'Fishing rod', + 347: 'Clock', + 348: 'Glowstone dust', + 349: 'Raw fish', + 350: 'Cooked fish', + 351: 'Dye', + 352: 'Bone', + 353: 'Sugar', + 354: 'Cake', + 355: 'Bed', + 356: 'Redstone repeater', + 357: 'Cookie', + 358: 'Map', + 359: 'Shears', + 2256: 'Gold music disc', + 2257: 'Green music disc' +} + +def id2item(item_id): + if item_id in items: + return items[item_id] + else: + return item_id From 85e8a1e8895e5d0b908a395a858d55b5bc1127a0 Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Mon, 22 Aug 2011 23:20:17 -0400 Subject: [PATCH 06/13] added more stern warnings about sample.settings.py and the --zoom option --- README.rst | 4 ++-- sample.settings.py | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index e8dede7..0548053 100644 --- a/README.rst +++ b/README.rst @@ -235,8 +235,8 @@ zoom=ZOOM This is equivalent to setting the dimensions of the highest zoom level. It does not actually change how the map is rendered, but rather *how much of - the map is rendered.* (Calling this option "zoom" may be a bit misleading, - I know) + the map is rendered.* Setting this option too low *will crop your map.* + (Calling this option "zoom" may be a bit misleading, I know) To be precise, it sets the width and height of the highest zoom level, in tiles. A zoom level of z means the highest zoom level of your map will be diff --git a/sample.settings.py b/sample.settings.py index cccdac8..f5761ea 100644 --- a/sample.settings.py +++ b/sample.settings.py @@ -33,7 +33,9 @@ if procs < 1: procs = 1 ## 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 -## Normally you should not need to set this variable. +## ***Normally you should not need to set this variable.*** +## ***Setting it too low will crop your map!*** +## Seriously, check the README before using this. ## Default: Automatically calculated from your world ## Type: integer ## Example: @@ -163,7 +165,8 @@ north_direction = "upper-right" -### As a reminder, don't use this file verbatim, it should only be used as -### a guide. +### As a reminder, *don't use this file verbatim*, it should only be used as +### a guide. Be sure to read what each option does before you set it. +### See the README for more details. import sys sys.exit("This sample-settings file shouldn't be used directly!") From 8d398864e337d6af1c6d30beaa22930c4e97be94 Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Tue, 23 Aug 2011 21:37:10 +0200 Subject: [PATCH 07/13] Fix bad handle of both alpha layers being zero in composite.c --- overviewer_core/src/composite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/overviewer_core/src/composite.c b/overviewer_core/src/composite.c index 432ece8..d83701c 100644 --- a/overviewer_core/src/composite.c +++ b/overviewer_core/src/composite.c @@ -194,7 +194,7 @@ alpha_over_full(PyObject *dest, PyObject *src, PyObject *mask, float overall_alp } /* special cases */ - if (in_alpha == 255 || *outmask == 0) { + if (in_alpha == 255 || (*outmask == 0 && in_alpha > 0)) { *outmask = in_alpha; *out = *in; From 03f97340394612a88b55ddf2c09113851e685a55 Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Tue, 23 Aug 2011 22:10:20 +0200 Subject: [PATCH 08/13] Bump overviewer extension version --- overviewer_core/src/overviewer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/overviewer_core/src/overviewer.h b/overviewer_core/src/overviewer.h index 4a273bf..9dd2526 100644 --- a/overviewer_core/src/overviewer.h +++ b/overviewer_core/src/overviewer.h @@ -26,7 +26,7 @@ // increment this value if you've made a change to the c extesion // and want to force users to rebuild -#define OVERVIEWER_EXTENSION_VERSION 9 +#define OVERVIEWER_EXTENSION_VERSION 10 /* Python PIL, and numpy headers */ #include From 240fe128cb28dc134e769d45e8a543988e060575 Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Tue, 23 Aug 2011 20:35:19 -0400 Subject: [PATCH 09/13] Attempt to detect if the user has forgotten to escape spaces in their paths --- overviewer.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/overviewer.py b/overviewer.py index 6743293..b0103b7 100755 --- a/overviewer.py +++ b/overviewer.py @@ -154,6 +154,17 @@ def main(): sys.exit(1) worlddir = args[0] + if len(args) > 2: + # it's possible the user has a space in one of their paths but didn't properly escape it + # attempt to detect this case + for start in range(len(args)): + if not os.path.exists(args[start]): + for end in range(start+1, len(args)+1): + if os.path.exists(" ".join(args[start:end])): + logging.warning("It looks like you meant to specify \"%s\" as your world dir or your output\n\ +dir but you forgot to put quotes around the directory, since it contains spaces." % " ".join(args[start:end])) + sys.exit(1) + if not os.path.exists(worlddir): # world given is either world number, or name worlds = world.get_worlds() From 3304de593f997655abf5500d268ab9c9bd7f460b Mon Sep 17 00:00:00 2001 From: Ryan Rector Date: Wed, 24 Aug 2011 19:38:29 -0600 Subject: [PATCH 10/13] Add contrib script to fix gibberish Cyrillic signs --- contrib/cyrillic_convert.py | 90 +++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100755 contrib/cyrillic_convert.py diff --git a/contrib/cyrillic_convert.py b/contrib/cyrillic_convert.py new file mode 100755 index 0000000..bcd1179 --- /dev/null +++ b/contrib/cyrillic_convert.py @@ -0,0 +1,90 @@ +#!/usr/bin/python + +import fileinput +import os +import sys + +usage = """ +If you have signs that should be Cyrillic, but are instead gibberish, +this script will convert it back to proper Cyrillic. + +usage: python %(script)s +ex. python %(script)s C:\\Inetpub\\www\\map\\markers.js + or %(script)s /srv/http/map/markers.js +""" % {'script': os.path.basename(sys.argv[0])} + +if len(sys.argv) < 2: + sys.exit(usage) + +gibberish_to_cyrillic = { + r"\u00c0": r"\u0410", + r"\u00c1": r"\u0411", + r"\u00c2": r"\u0412", + r"\u00c3": r"\u0413", + r"\u00c4": r"\u0414", + r"\u00c5": r"\u0415", + r"\u00c6": r"\u0416", + r"\u00c7": r"\u0417", + r"\u00c8": r"\u0418", + r"\u00c9": r"\u0419", + r"\u00ca": r"\u041a", + r"\u00cb": r"\u041b", + r"\u00cc": r"\u041c", + r"\u00cd": r"\u041d", + r"\u00ce": r"\u041e", + r"\u00cf": r"\u041f", + r"\u00d0": r"\u0420", + r"\u00d1": r"\u0421", + r"\u00d2": r"\u0422", + r"\u00d3": r"\u0423", + r"\u00d4": r"\u0424", + r"\u00d5": r"\u0425", + r"\u00d6": r"\u0426", + r"\u00d7": r"\u0427", + r"\u00d8": r"\u0428", + r"\u00d9": r"\u0429", + r"\u00da": r"\u042a", + r"\u00db": r"\u042b", + r"\u00dc": r"\u042c", + r"\u00dd": r"\u042d", + r"\u00de": r"\u042e", + r"\u00df": r"\u042f", + r"\u00e0": r"\u0430", + r"\u00e1": r"\u0431", + r"\u00e2": r"\u0432", + r"\u00e3": r"\u0433", + r"\u00e4": r"\u0434", + r"\u00e5": r"\u0435", + r"\u00e6": r"\u0436", + r"\u00e7": r"\u0437", + r"\u00e8": r"\u0438", + r"\u00e9": r"\u0439", + r"\u00ea": r"\u043a", + r"\u00eb": r"\u043b", + r"\u00ec": r"\u043c", + r"\u00ed": r"\u043d", + r"\u00ee": r"\u043e", + r"\u00ef": r"\u043f", + r"\u00f0": r"\u0440", + r"\u00f1": r"\u0441", + r"\u00f2": r"\u0442", + r"\u00f3": r"\u0443", + r"\u00f4": r"\u0444", + r"\u00f5": r"\u0445", + r"\u00f6": r"\u0446", + r"\u00f7": r"\u0447", + r"\u00f8": r"\u0448", + r"\u00f9": r"\u0449", + r"\u00fa": r"\u044a", + r"\u00fb": r"\u044b", + r"\u00fc": r"\u044c", + r"\u00fd": r"\u044d", + r"\u00fe": r"\u044e", + r"\u00ff": r"\u044f" +} + +for line in fileinput.FileInput(inplace=1): + for i, j in gibberish_to_cyrillic.iteritems(): + line = line.replace(i, j) + sys.stdout.write(line) + From 22f40a9075d1b94d06e5066e8f0f756cd747047b Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Thu, 25 Aug 2011 21:57:08 -0400 Subject: [PATCH 11/13] Added docstrings to all contrib scripts --- contrib/benchmark.py | 16 ++++++++++------ contrib/blockcounter.py | 4 ++++ contrib/clearOldCache.py | 3 +++ contrib/findSigns.py | 2 ++ contrib/playerInspect.py | 4 ++++ contrib/rerenderBlocks.py | 2 ++ contrib/testRender.py | 2 ++ contrib/validateRegionFile.py | 5 +++++ 8 files changed, 32 insertions(+), 6 deletions(-) diff --git a/contrib/benchmark.py b/contrib/benchmark.py index 145654e..6de19e1 100644 --- a/contrib/benchmark.py +++ b/contrib/benchmark.py @@ -1,3 +1,13 @@ +"""Simple Benchmarking script. + +Usage and example: + +$ python contrib/benchmark.py World4/ +Rendering 50 chunks... +Took 20.290062 seconds or 0.405801 seconds per chunk, or 2.464261 chunks per second +""" + + import chunk import world import tempfile @@ -8,12 +18,6 @@ import os import sys import shutil -# Simple Benchmarking script. Usage and example: - -# $ python contrib/benchmark.py World4/ -# Rendering 50 chunks... -# Took 20.290062 seconds or 0.405801 seconds per chunk, or 2.464261 chunks per second - # create a new, empty, cache dir cachedir = tempfile.mkdtemp(prefix="benchmark_cache", dir=".") diff --git a/contrib/blockcounter.py b/contrib/blockcounter.py index b3603d3..6d69d55 100644 --- a/contrib/blockcounter.py +++ b/contrib/blockcounter.py @@ -1,3 +1,7 @@ +"""Produces block counts + +""" + import world, chunk import sys diff --git a/contrib/clearOldCache.py b/contrib/clearOldCache.py index 01b604d..45f8b0a 100644 --- a/contrib/clearOldCache.py +++ b/contrib/clearOldCache.py @@ -1,5 +1,8 @@ #!/usr/bin/python +"""Deletes files from the old chunk-based cache""" + + usage = "python contrib/%prog [OPTIONS] " description = """ diff --git a/contrib/findSigns.py b/contrib/findSigns.py index 3213b35..a344c71 100644 --- a/contrib/findSigns.py +++ b/contrib/findSigns.py @@ -1,6 +1,8 @@ #!/usr/bin/python ''' +Updates overviewer.dat file sign info + 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 is either out-of-date or non-existant. diff --git a/contrib/playerInspect.py b/contrib/playerInspect.py index c520788..d20d2ac 100644 --- a/contrib/playerInspect.py +++ b/contrib/playerInspect.py @@ -1,5 +1,9 @@ import sys +""" +Very basic player.dat inspection script +""" + sys.path.append(".") from overviewer_core.nbt import load diff --git a/contrib/rerenderBlocks.py b/contrib/rerenderBlocks.py index eb93871..ff7b02a 100644 --- a/contrib/rerenderBlocks.py +++ b/contrib/rerenderBlocks.py @@ -1,6 +1,8 @@ #!/usr/bin/python ''' +Generate a region list to rerender certain chunks + This is used to force the regeneration of any chunks that contain a certain blockID. The output is a chunklist file that is suitable to use with the --chunklist option to overviewer.py. diff --git a/contrib/testRender.py b/contrib/testRender.py index c4de264..4fa9e7e 100644 --- a/contrib/testRender.py +++ b/contrib/testRender.py @@ -1,5 +1,7 @@ #!/usr/bin/python +"Test Render Script" + import os, shutil, tempfile, time, sys, math, re from subprocess import Popen, PIPE, STDOUT, CalledProcessError from optparse import OptionParser diff --git a/contrib/validateRegionFile.py b/contrib/validateRegionFile.py index 7dd2763..b9276f3 100644 --- a/contrib/validateRegionFile.py +++ b/contrib/validateRegionFile.py @@ -1,5 +1,10 @@ #!/usr/bin/env python +''' +Validate a region file + +TODO description here''' + import os.path import sys overviewer_dir = os.path.split(os.path.split(os.path.abspath(__file__))[0])[0] From 3377be6b37a4514cc285c1c47cf0802d0c768019 Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Thu, 25 Aug 2011 22:00:36 -0400 Subject: [PATCH 12/13] Updated contrib manager print out description for each script based on docstrings added usage info --- contribManager.py | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/contribManager.py b/contribManager.py index f750b90..58fa920 100755 --- a/contribManager.py +++ b/contribManager.py @@ -7,11 +7,13 @@ import sys import os.path sys.path.append("overviewer_core") import nbt +import ast scripts=dict( # keys are names, values are scripts - benchmark="benchmark.py", - findSigns="findSigns.py", - validate="validateRegionFile.py" + benchmark = "benchmark.py", + findSigns = "findSigns.py", + validate = "validateRegionFile.py", + playerInspect = "playerInspect.py" ) # you can symlink or hardlink contribManager.py to another name to have it @@ -29,18 +31,40 @@ if argv[-4:] == ".exe": if argv[-3:] == ".py": argv=argv[0:-3] + +usage="""Usage: +%s --list-contribs |