Kilarin wrote:I had suggested different sized protectors once before, and Ten pointed out to me that it would slow down the mod. Currently the protector mod must check to see if a node is within a standard preset distance (10 in this case) of any existing protector. If we add, say, one small protector with a radius of 3, then we now have to have TWO lists of protectors, and do TWO checks to see if the node is within a distance of 3 from a protector on the small list, and if not, THEN we have to check if it is within a distance of 10 from a large protector. thereby doubling the number of checks required for every interaction with a node on the server.

That's not entirely true. The code must check 9261 blocks for radius 10 but only 343 blocks for radius 3. If the code were to perform the radius 3 test first and found a small or large protector, it would eliminate the need to perform the more costly radius 10 test. If no protector is found in the radius 3 test it would only increase the work by 4%, no where near double. A radius 5 protector would check 1331 blocks and adding a radius 3 check on top of that would be a 26% increase in work, still not double but enough to be noticable. But with radius 10 protectors the radius 3 protector adds almost nothing and has the potential to boost performance.

A player digging in the wild would cause both checks to happen. A player building a road with small protectors would only cause the much faster radius 3 checks. A player building inside their radius 10 protected base would cause both checks unless within 3 blocks from the protector. So in most cases both checks would happen. But any action that only triggers the radius 3 check would be 27 times faster!

The new radius 10 checks are 7 times slower than the old radius 5 checks. In the worst case, adding on a second radius 3 check would only make it a measly 7.2 times slower. ;)

I must have misunderstood how the protector mod worked. I assumed there was a list/database of protectors which was searched for protectors near to a node. I guess I need to pull the code and dig through it sometime.

Kilarin wrote:I must have misunderstood how the protector mod worked. I assumed there was a list/database of protectors which was searched for protectors near to a node. I guess I need to pull the code and dig through it sometime.

Storing all loaded protectors in an octree would probably be faster than checking 9200 blocks, but it would require a little bit of memory and some overhead when loading and unloading areas. Each action would result in 1-20 lookups into the octree and return 0-8 lists of protectors in a 32x32x32 area around the target block. The code then iterates the lists and checks if each protector is in range of the block, based on the given protector's radius.

In the wild, the check would abort before doing 13 lookups and nothing else would need to be done. When near any protectors, it would do all 20 lookups and then iterate over what it found.

This assumes a -32k to +32k world, for worlds with -65k to +65k (max size of minetest worlds) it requires one additional lookup.

--

A flat list of protectors would also use memory (but not as much as an octree, whch isn't much more) and also have overhead when loading and unloading areas. Every action would need to iterate over the entire list (only once, no matter how many sizes of protectors) and do the same range check as the octree would do, but the octree only does the range check for the blocks in the 32x32x32 area around the target block, the flat list does it for all blocks in the list. If only a few protectors were visible by all players then a flat list would be faster than an octree. But the octree becomes much faster once the number of visible protectors increases.

auouymous wrote:A flat list of protectors would also use memory (but not as much as an octree, whch isn't much more) and also have overhead when loading and unloading areas. Every action would need to iterate over the entire list (only once, no matter how many sizes of protectors) and do the same range check as the octree would do, but the octree only does the range check for the blocks in the 32x32x32 area around the target block, the flat list does it for all blocks in the list. If only a few protectors were visible by all players then a flat list would be faster than an octree. But the octree becomes much faster once the number of visible protectors increases.

ist it possible to use both methods?so that the large protectors (where there should be less visible pieces around) use the old method,and the small protectors (where there would be many) use the faster octree method.or does that create conflicts when both protector types are used in one area?

firefox wrote:ist it possible to use both methods?so that the large protectors (where there should be less visible pieces around) use the old method,and the small protectors (where there would be many) use the faster octree method.or does that create conflicts when both protector types are used in one area?

The octree has the same overhead if used for one or both. The old (current) method gets magnitudes slower with each increase of the protector radius. If the overhead for octree is acceptable, it should be used for all protector sizes, the whole point of the octree is to speed up the very slow radius 10 checks.

A 64bit server with 32 players each in a different area and each player able to see 1000 protectors in their area would require about 3MB of memory on the server.

It appears that minetest might not have the ability to notify the mod when a node is loaded into memory. This means the octree can't be done. :(

I added large and small protectors to the mod at http://mt.qzx.com/protector/ and did some benchmarks. But the optimization of scanning radius 3 first and then only scanning radius 10 if no radius 3 protectors where found can't be done because a radius 10 might prohibit the player even though the radius 3 allowed it.

These are average times on my machine in microseconds for comparison purposes only. "Old" is the current mod on Xanadu with only one size protector, "new" is the mod with large and small protectors.

Small radius 3 protectors don't matter when digging, placing or accessing nodes, only the size of the largest protector.

Placing a large protector on either mod is same speed, about 7 times slower than placing a radius 5 protector on current Xanadu map. But placing the small protector would only be 2 times slower. Good reason to make large protectors cost more to craft, if implemented.

If wanted, just drop the two files into the current mod and maybe add new textures for small protectors.

you need to add them when they are loaded first and add / remove them if the node is added / removedthen you can use a function looking big but working fast to search for protectorsthe set, remove and get functions are from vector_extrasyou can e.g. set the name and range in a table to a specific position, you can store the range and name in meta, put them from there into the cache table when caching it and change the big function to test the range and playerbut if you use the names as index, you can skip the protection blocks of the player when searchingyou should set a maximum range because protecting only works if the node has been loaded yet after the server start

you need to add them when they are loaded first and add / remove them if the node is added / removedthen you can use a function looking big but working fast to search for protectorsthe set, remove and get functions are from vector_extrasyou can e.g. set the name and range in a table to a specific position, you can store the range and name in meta, put them from there into the cache table when caching it and change the big function to test the range and playerbut if you use the names as index, you can skip the protection blocks of the player when searchingyou should set a maximum range because protecting only works if the node has been loaded yet after the server start

i have no idea what this means, but it sounds great :P(was this tested already or is it just a theory?i imagine the "skip checking your own protectors" thing to be very handy for building.)

IceAgeComing wrote:At least theres just 1 bonny!

but not for long ...we just need a cupcake and a cloning machine. i guess you know how this works =(^.^)=:P

also is there a specific date for the map change?on the last day of the old map i want to throw all my gold and gems into the spawn to make everyone happyand then troll them when everything gets reset :P