sectors2sqlite broke my map

Post Reply
Zmogas
Member
Posts: 19
Joined: Sun Sep 25, 2011 21:09

sectors2sqlite broke my map

by Zmogas » Post

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.

kahrl
Member
Posts: 236
Joined: Fri Sep 02, 2011 07:51
Location: Rös̓̇chenhof

by kahrl » Post

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/commi ... sqlite-fix.

Zmogas
Member
Posts: 19
Joined: Sun Sep 25, 2011 21:09

by Zmogas » Post

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?

kahrl
Member
Posts: 236
Joined: Fri Sep 02, 2011 07:51
Location: Rös̓̇chenhof

by kahrl » Post

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. ;)

Zmogas
Member
Posts: 19
Joined: Sun Sep 25, 2011 21:09

by Zmogas » Post

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 :)

Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests