0

Merge remote branch 'brownan/master' into rendermode-options

This commit is contained in:
Aaron Griffith
2011-08-26 21:06:14 -04:00
18 changed files with 463 additions and 17 deletions

View File

@@ -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

View File

@@ -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=".")

View File

@@ -1,3 +1,7 @@
"""Produces block counts
"""
import world, chunk
import sys

View File

@@ -1,5 +1,8 @@
#!/usr/bin/python
"""Deletes files from the old chunk-based cache"""
usage = "python contrib/%prog [OPTIONS] <World # / Name / Path to World>"
description = """

92
contrib/cyrillic_convert.py Executable file
View File

@@ -0,0 +1,92 @@
#!/usr/bin/python
"""Convert gibberish back into Cyrillic"""
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 <markers.js>
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)

View File

@@ -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.

22
contrib/playerInspect.py Normal file
View File

@@ -0,0 +1,22 @@
import sys
"""
Very basic player.dat inspection script
"""
sys.path.append(".")
from overviewer_core.nbt import load
from overviewer_core import items
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 " %-3d %s" % (item['Count'], items.id2item(item['id']))

View File

@@ -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.

View File

@@ -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

View File

@@ -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]

79
contribManager.py Executable file
View File

@@ -0,0 +1,79 @@
#!/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
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",
playerInspect = "playerInspect.py",
convertCyrillic = "cyrillic_convert.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])
if argv[-4:] == ".exe":
argv=argv[0:-4]
if argv[-3:] == ".py":
argv=argv[0:-3]
usage="""Usage:
%s --list-contribs | <script name> <arguments>
Executes a contrib script.
Options:
--list-contribs Lists the supported contrib scripts
""" % os.path.basename(sys.argv[0])
if argv in scripts.keys():
script = scripts[argv]
sys.argv[0] = script
else:
if "--list-contribs" in sys.argv:
for contrib in scripts.keys():
# use an AST to extract the docstring for this module
script = scripts[contrib]
with open(os.path.join("contrib",script)) as f:
d = f.read()
node=ast.parse(d, script);
docstring = ast.get_docstring(node)
if docstring:
docstring = docstring.strip().splitlines()[0]
else:
docstring="(no description found. add one by adding a docstring to %s)" % script
print "%s : %s" % (contrib, docstring)
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 usage
sys.exit(1)
torun = os.path.join("contrib", script)
if not os.path.exists(torun):
print "Script '%s' is missing!" % script
sys.exit(1)
execfile(torun)

View File

@@ -159,6 +159,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()

211
overviewer_core/items.py Normal file
View File

@@ -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

View File

@@ -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;

View File

@@ -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 10
/* Python PIL, and numpy headers */
#include <Python.h>

View File

@@ -178,9 +178,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;
@@ -188,7 +193,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);
}

View File

@@ -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!")

View File

@@ -95,10 +95,11 @@ if py2exe is not None:
# py2exe likes a very particular type of version number:
setup_kwargs['version'] = util.findGitVersion().replace("-",".")
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