Detect protected node in area

User avatar
stu
Member
 
Posts: 737
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11

Detect protected node in area

by stu » Tue Sep 30, 2014 19:57

Something I think could be useful is a fast way to check for the existence of protected nodes in either a given radius or min/max position
This could speed up things like TNT greatly (when used with protection) and also make it harder to grief non protected nodes in the same vicinity as protected ones.

I came upon this problem while adding some basic protection support to my shooter mod, checking every position in the 'blast' routine causes a noticeable slow-down even in singleplayer mode and I fear it could end up being a lag fest on public servers :(

Any thoughts on this?

Edit: It looks like the engine doesn't actually handle the protection and requires a mod to override core.is_protected, right?
If that's the case then this is not even possible, I was kinda under the impression protected status was somehow stored in the db :(

Still looking for ideas to speed things up but the topic probably really belongs in modding general
 

User avatar
TenPlus1
Member
 
Posts: 1874
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: Detect protected node in area

by TenPlus1 » Wed Oct 01, 2014 07:20

That's right, is_protected is an empty function which has to be defined by the protection mod in use (protector, areas, simple protection etc.) and when called by game or other mods will use the protection mod's routines to see which areas are covered...

Note: When using my own protection mod and with TNT it doesnt cause any noticable slowdown...
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Detect protected node in area

by rubenwardy » Wed Oct 01, 2014 07:38

Another function like minetest.is_protected_in_area() would be good. Or the ability to pass an area to an is_protected call. Area should also have the ability to be a sphere.

You could add support for individual protection mods by using their APIs, or manually reading their data stores.
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: Detect protected node in area

by kaeza » Wed Oct 01, 2014 09:56

Unfortunately, there's no other way than iterating the area you want to check and call `is_protected` on each position. The idea behind abstracting `is_protected` is that modders are free to implement the protection in whatever way they see fit.

There's no unified way to implement it. Some use cuboid areas stored as a global table (e.g. areas), some use metadata in the node (e.g. node_ownership, though I don't know if it actually overrides `is_protected`), some may simply deny everything to users without a specific priv, or too close to spawn, or not having full health, or if the stars are not aligned, or whatever condition the modder wants to use.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
stu
Member
 
Posts: 737
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11

Re: Detect protected node in area

by stu » Wed Oct 01, 2014 19:59

Thanks for the replies, I get how it works now and things aren't really as bad as I first thought. The reason I see a slight slow-down is because the blast routine otherwise uses a very fast vm explosion routine borrowed from the nuke mod, putting anything else in that loop has a noticeable effect on this ancient desktop of mine.

TenPlus1 wrote:That's right, is_protected is an empty function which has to be defined by the protection mod in use (protector, areas, simple protection etc.) and when called by game or other mods will use the protection mod's routines to see which areas are covered...

Note: When using my own protection mod and with TNT it doesn't cause any noticeable slowdown...


I tried your version of the protector mod and it works very well indeed, good job!
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

Re: Detect protected node in area

by Sokomine » Thu Oct 02, 2014 01:35

On servers that focus on building, TNT is not such a good idea. At least not above ground. A good working solution usually is to set it to work only below a certain depth.

That said, it might be sufficient if you support *some* protection mods likely found on servers where TNT may be used. Those servers usually place protection at secondary or less priority.
A list of my mods can be found here.
 


Return to Minetest Features

Who is online

Users browsing this forum: Bing [Bot] and 9 guests

cron