Reset world on live server

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

Reset world on live server

by ratmix » Sun Mar 03, 2019 08:03

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: 4371
Joined: Thu Oct 03, 2013 07:48
Location: Switzerland
GitHub: SmallJoker

Re: Reset world on live server

by Krock » Sun Mar 03, 2019 17:36

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

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

Re: Reset world on live server

by ratmix » Sun Mar 03, 2019 17:52

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: 148
Joined: Mon May 01, 2017 19:45
In-game: ratmix

Re: Reset world on live server

by ratmix » Sun Mar 03, 2019 18:44

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: 4
Joined: Tue Sep 24, 2019 19:03

Re: Reset world on live server

by dfournier » Wed Oct 09, 2019 17:39

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.
 


Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 5 guests