deleting pos lines in sqlite map db

Post Reply
User avatar
mike
Member
Posts: 45
Joined: Wed Sep 26, 2012 01:15

deleting pos lines in sqlite map db

by mike » Post

Hi,

will there be any problems if i delete some well selected pos lines from sqlite db?

What i need to know is, will deleted lines (entries) be regenerated from seed if not found?
So i could write an SQL Query to delete all sectors which i dont want to preserve.

like delete all pos where pos(x,y,z) is not in myRange.

e.g. delete all except posXYZtoPos(0,0,0 to 100,100,100)

User avatar
Sokomine
Member
Posts: 4017
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine

Re: deleting pos lines in sqlite map db

by Sokomine » Post

mike wrote: What i need to know is, will deleted lines (entries) be regenerated from seed if not found?
So i could write an SQL Query to delete all sectors which i dont want to preserve.
That ought to work well. The only thing you might have to take into consideration is that mapgen generates several mapblocks (16x16x16 blocks) in one go as one chunk (usually 5x5x5 mapblocks, so 80x80x80 blocks). I don't know what will happen if you delete only part of a chunk.
mike wrote: e.g. delete all except posXYZtoPos(0,0,0 to 100,100,100)
You'll have to transform the pos index into coordinates first, but yes, it ought to work then.
A list of my mods can be found here.

User avatar
mike
Member
Posts: 45
Joined: Wed Sep 26, 2012 01:15

Re: deleting pos lines in sqlite map db

by mike » Post

If this is that easy wouldnt it be a function for worldedit or an script?

User avatar
Sokomine
Member
Posts: 4017
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine

Re: deleting pos lines in sqlite map db

by Sokomine » Post

mike wrote: If this is that easy wouldnt it be a function for worldedit or an script?
This is nothing WorldEdit can do, as WorldEdit runs while the server is running. This kind of work is better done while the world is not loaded. The necessary commands depend on the database backend. sqlite3 is easier to handle in that regard than leveldb.
A list of my mods can be found here.

User avatar
sfan5
Moderator
Posts: 3894
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

Re: deleting pos lines in sqlite map db

by sfan5 » Post

If you delete a MapBlock from the database it will get regenerated when you visit the area again.
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

User avatar
mike
Member
Posts: 45
Joined: Wed Sep 26, 2012 01:15

Re: deleting pos lines in sqlite map db

by mike » Post

so i dont have to care if i have to delete a set or just random picks?

User avatar
sfan5
Moderator
Posts: 3894
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

Re: deleting pos lines in sqlite map db

by sfan5 » Post

Yep
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

User avatar
mike
Member
Posts: 45
Joined: Wed Sep 26, 2012 01:15

Re: deleting pos lines in sqlite map db

by mike » Post

is there any code for generating the coords except the one from db spec page?

User avatar
sfan5
Moderator
Posts: 3894
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

Re: deleting pos lines in sqlite map db

by sfan5 » Post

Here's a small python program that does what you want: http://sprunge.us/KOhi
X, Y and Z are MapBlock coords. not node coords.

Example:
You want to delete the 16x16x16 cube the node (-123, 456, 25) belongs to:
-123 / 16 = -7
456 / 16 = 28
25 / 16 = 1
-> ./pos2dbpos.py -7 28 1
Then delete that entry in the database.
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

User avatar
twoelk
Member
Posts: 1365
Joined: Fri Apr 19, 2013 16:19
GitHub: twoelk
IRC: twoelk
In-game: twoelk
Location: northern Germany

Re: deleting pos lines in sqlite map db

by twoelk » Post

Not code but some playing with spreadsheets.

Beware might contain mistakes. Use with care.
Is extracted from some other project of mine therefore might have vital parts missing.
Attachments
Calculating_MapInteger.zip
(17.72 KiB) Downloaded 35 times

User avatar
mike
Member
Posts: 45
Joined: Wed Sep 26, 2012 01:15

Re: deleting pos lines in sqlite map db

by mike » Post

That looks good.
So if i calculate like this for one node, then maximum 16 nodes in all directions will be deleted?

Next i have to think how to write a script which deletes all except "active" played map.
I cant delete e.g. block 123456 until inf. I hate unnormalized databases ;-)

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests