Page 1 of 1

Detect protected node in area

PostPosted: Tue Sep 30, 2014 19:57
by stu
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

Re: Detect protected node in area

PostPosted: Wed Oct 01, 2014 07:20
by TenPlus1
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...

Re: Detect protected node in area

PostPosted: Wed Oct 01, 2014 07:38
by rubenwardy
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.

Re: Detect protected node in area

PostPosted: Wed Oct 01, 2014 09:56
by kaeza
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.

Re: Detect protected node in area

PostPosted: Wed Oct 01, 2014 19:59
by stu
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!

Re: Detect protected node in area

PostPosted: Thu Oct 02, 2014 01:35
by Sokomine
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.