aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorKahrl <kahrl@gmx.net>2011-09-26 13:10:22 +0200
committerKahrl <kahrl@gmx.net>2011-09-26 13:10:22 +0200
commitd5899a53fd3c1c78b998a3384216ef719e46bf9f (patch)
tree3774b65c14b7d091dcd2fadf8a52eaf59867a54a /util
parentbdf54908aa0b8dabbc67f1925de88bc88a70c935 (diff)
downloadminetest-d5899a53fd3c1c78b998a3384216ef719e46bf9f.tar.gz
minetest-d5899a53fd3c1c78b998a3384216ef719e46bf9f.tar.bz2
minetest-d5899a53fd3c1c78b998a3384216ef719e46bf9f.zip
Fix processing of blocks below y=0 in sectors2sqlite.py.
Diffstat (limited to 'util')
-rwxr-xr-xutil/sectors2sqlite.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/util/sectors2sqlite.py b/util/sectors2sqlite.py
index 16ee7aae4..178842129 100755
--- a/util/sectors2sqlite.py
+++ b/util/sectors2sqlite.py
@@ -23,10 +23,14 @@ if os.path.isdir(path + 'sectors/'):
if not paths:
exit('Could not find sectors folder at ' + path + 'sectors2/ or ' + path + 'sectors/')
-def uint(u):
+def parseSigned12bit(u):
u = int('0x'+u, 16)
return (u if u < 2**11 else u - 2**12)
+def parseSigned16bit(u):
+ u = int('0x'+u, 16)
+ return (u if u < 2**15 else u - 2**16)
+
def int64(u):
while u >= 2**63:
u -= 2**64
@@ -38,12 +42,12 @@ def int64(u):
def getSectorPos(dirname):
if len(dirname) == 8:
# Old layout
- x = uint(dirname[:4])
- z = uint(dirname[4:])
+ x = parseSigned16bit(dirname[:4])
+ z = parseSigned16bit(dirname[4:])
elif len(dirname) == 7:
# New layout
- x = uint(dirname[:3])
- z = uint(dirname[4:])
+ x = parseSigned12bit(dirname[:3])
+ z = parseSigned12bit(dirname[4:])
else:
print('Terrible sector at ' + dirname)
return
@@ -60,7 +64,7 @@ def getBlockPos(sectordir, blockfile):
if len(blockfile) != 4:
print("Invalid block filename: " + blockfile)
- y = uint(blockfile)
+ y = parseSigned16bit(blockfile)
return p2d[0], y, p2d[1]