Page 1 of 1

sectors2sqlite broke my map

PostPosted: Sun Sep 25, 2011 21:39
by Zmogas
As build 0.2.20110922 arrives, I converted my sectors2 to map.sqlite with sectors2sqlite.py.
And now my map is broken: bloks with z>=0 are correct, but content with z<0 are from another world :).

F.e. there must stairs down to 500m deep mine:
[img=PunBB bbcode test]http://img192.imageshack.us/img192/7580/nuotrauka2.png[/img]

BTW, if I not convert map in to new format with that utility and let it do for the game then map is OK on next game start.


Please fix sectors2sqlite.

PostPosted: Mon Sep 26, 2011 11:30
by kahrl
I found a bug in sectors2sqlite that caused negative y values to be read as large positive numbers. Are you sure the problem was z<0 in your case, and not y<0? I created a patchset to fix the bug I found, would be glad if you could test: https://github.com/kahrl/minetest/commits/sectors2sqlite-fix.

PostPosted: Mon Sep 26, 2011 13:14
by Zmogas
I tested, now converted map is correct. Thanks.

About coordinates. I think that up and down in minetest world is Z axis. But, seems, I thought wrong?

Also, when I execute sectors2sqlite python stops and complains:

File "sectors2sqlite.py", line 117, in <module>
cur.execute('INSERT OR IGNORE INTO `blocks` VALUES(?, ?)', (pos, f.read()))
sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.

I googled a bit and found solution: f.read() content must be passed trough buffer() function, like:
cur.execute('INSERT OR IGNORE INTO `blocks` VALUES(?, ?)', (pos, buffer(f.read())))
Maybe this solution must be added in to official code?

PostPosted: Mon Sep 26, 2011 13:51
by kahrl
Zmogas wrote:I tested, now converted map is correct. Thanks.

About coordinates. I think that up and down in minetest world is Z axis. But, seems, I thought wrong?

Minetest uses the same coordinate system as in Minecraft (except that elevation is not limited to 0 to 127). So Y is up/down. (It's true that many FPS games use the Z axis as up/down instead.)

Zmogas wrote:Also, when I execute sectors2sqlite python stops and complains:

File "sectors2sqlite.py", line 117, in <module>
cur.execute('INSERT OR IGNORE INTO `blocks` VALUES(?, ?)', (pos, f.read()))
sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.

I googled a bit and found solution: f.read() content must be passed trough buffer() function, like:
cur.execute('INSERT OR IGNORE INTO `blocks` VALUES(?, ?)', (pos, buffer(f.read())))
Maybe this solution must be added in to official code?


It's a litte more complicated than that. ;)

When I tested it, I got the exact same error when I tried to run sectors2sqlite.py in Python 2. However using Python 3 worked fine. I found sqlite wants a buffer object in Python 2 but a memoryview object in Python 3, but in 3 (not 2) it can cope with a simple bytestring too. Memoryview objects exist in Python 2.7 too, but sqlite doesn't accept them. Oh well. ;)

PostPosted: Mon Sep 26, 2011 14:15
by Zmogas
kahrl wrote:Minetest uses the same coordinate system as in Minecraft (except that elevation is not limited to 0 to 127). So Y is up/down. (It's true that many FPS games use the Z axis as up/down instead.)


Thanks for clarification. I never played Minecraft :)