Reset world on live server

Post Reply
User avatar
ratmix
Member
Posts: 149
Joined: Mon May 01, 2017 19:45
In-game: ratmix
Contact:

Reset world on live server

by ratmix » Post

I am working on a new sub-game that requires a periodic reset of the world to it's initial/original mapgen state. I have tried minetest.delete_area, however it would take precisely 1 second less than infinity to reset an entire world. So this approach is non-viable.

I then tried to delete the world's map.sqlite file, but this crashes the server. However, on reboot, the world is indeed reset in a flash. This is what I want, but without the crash obviously. Is there any way to tell Minetest to regenerate the map.sqlite file without restarting the server?

Here is the error message produced when I delete the map.sqlite file...

Code: Select all

2019-03-03 20:43:31: ERROR[Emerge-0]: An unhandled exception occurred: Failed to prepare query 'SELECT `data` FROM `blocks` WHERE `pos` = ? LIMIT 1': no such table: blocks
2019-03-03 20:43:31: ERROR[Emerge-0]: In thread 7f206bfff700:
2019-03-03 20:43:31: ERROR[Emerge-0]: /home/realcourse/minetest5/newestMT5/compiled/minetest/src/emerge.cpp:2aa: virtual void* EmergeThread::run(): A fatal error occurred: Failed to prepare query 'SELECT `data` FROM `blocks` WHERE `pos` = ? LIMIT 1': no such table: blocks
So minetest crashes once a query to the deleted map.sqlite fails. So I'm curious if I can execute the same regeneration of the map.sqlite file that occurs on reboot whenever a database query fails - instead of throwing a fatal error.

Something like if !table then create_sqlfile() is what I need I suppose.

Or is there a better or existing solution?
King of the Hill :: Modern Warfare Server RATMIX.COM:30000 | King of the Hill Community Site

User avatar
Krock
Developer
Posts: 4650
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: Reset world on live server

by Krock » Post

How about using the `dummy` database backend? You could then just delete the currently active mapblocks.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
ratmix
Member
Posts: 149
Joined: Mon May 01, 2017 19:45
In-game: ratmix
Contact:

Re: Reset world on live server

by ratmix » Post

Thanks for the idea, but I think the memory required to store the necessary blocks temporarily would exceed my available RAM before it is time deleted them. (30 players on a very large map)

In addition, even for a small radius of 50, delete_blocks took over a minute to complete.

I wonder if emptying the sqlite tables would prevent a crash and force a regen.
King of the Hill :: Modern Warfare Server RATMIX.COM:30000 | King of the Hill Community Site

User avatar
ratmix
Member
Posts: 149
Joined: Mon May 01, 2017 19:45
In-game: ratmix
Contact:

Re: Reset world on live server

by ratmix » Post

This might be a solution:
  • 1. Create a new world and join it
    2. Exit after joining
    3. Save a copy of the map.sqlite file as map.sqlite.orig
    4. Call this function to regen the map os.execute('cp map.sqlite.orig map.sqlite')
This method works seamlessly and ultra fast, with two caveats. First, players should not be in an area you do not need to regen, or their client will not update it's version of the blocks. Second, I'm not sure about how the map_meta.txt file will work once caves, etc. are created. I suppose previous data will be ignored. This hasn't yet been well tested but looks promising.
King of the Hill :: Modern Warfare Server RATMIX.COM:30000 | King of the Hill Community Site

dfournier
New member
Posts: 5
Joined: Tue Sep 24, 2019 19:03

Re: Reset world on live server

by dfournier » Post

Hey ratmix,
Did you get this to work?
I am trying to create a world that is reset when you die, but to the same world not a newly generated one.

disconnected
New member
Posts: 2
Joined: Mon Mar 11, 2019 03:45
GitHub: discon-nected
In-game: disconnected

Re: Reset world on live server

by disconnected » Post

As long as your seed is the same, the world should regen identically to the original. The method posted by ratmix above is the closest we could get to making this work.
King of the Hill (CapturePoint) Server 》》》RATMIX.COM:30000

sofar
Developer
Posts: 2146
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Reset world on live server

by sofar » Post

Perhaps `mtmapprune` can help. It is designed to remove blocks around a certain perimeter, but you could make that perimenter really small, and just maintain a spawn area and preserve that. It's about as efficient as you can make it. It does need to run offline (shut down the server first).

viewtopic.php?f=14&t=18579

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests