Page 2 of 3

PostPosted: Thu Mar 01, 2012 04:00
by randomproof
Gatharoth wrote:
randomproof wrote:Yes, the client software assumes that the dig happens when it sends the request to the server and there is no way for my mod to tell the server to tell the client that this action didn't complete. The functionality is in the server (it is used when you try to dig something too far from the player) but the server is not checking to see if a mod aborted the function.



Question, do you think forcing a node_update would "fix" this problem?

Edit: Never mind. Tried it, and it didn't work.

The server does something like this when you try to dig something too far away from you. You just need to see how it does that and replicat it. I'd look myself now but I'm away from my computer with minetest on it.

PostPosted: Thu Mar 01, 2012 15:56
by randomproof
Utilisatrice wrote:No, when I download the file init.lua and I start the game, and bah its not working.

There should be a diff for the buildin.lua file but I seem to have lost it off the first post. I will see if I can find it or remake it.

EDIT: Here it is.

PostPosted: Thu Mar 01, 2012 16:12
by randomproof
OK, I updated the extra diffs to the first post.

PostPosted: Fri Mar 02, 2012 22:10
by Temperest
Just to be clear, does this mod work without the patches to builtin.lua and server.cpp?

PostPosted: Fri Mar 02, 2012 22:29
by randomproof
Temperest wrote:Just to be clear, does this mod work without the patches to builtin.lua and server.cpp?

The patch to builtin.lua is necessary, but the one to server.cpp is not exactly so.

The patch for builtin.lua allows the mod to override the server calling 'minetest.node_dig' and 'minetest.item_place'. Mainly this is needed for dugging so that it can check permission on the node before a player removed it from the map. Without this the only thing the mod could do if to put the node back after an unauthorized player removed it. This would cause the node to lose all of its metadata, such as sign text.

EDIT: That said I haven't figured out exactly how to prevent someone from changing a sign's text.

Without the server.cpp patch players will see nodes disappear when they dig them, but on the server they will not be removed if they don't have permission. The patch resends the mapblock to the client so they see it there again. In other words the client assumes that the dig function succeeds and therefore removes the node from its memory immediately so the server must tell the client to put it back, and that is what that patch does.

PostPosted: Fri Mar 09, 2012 01:59
by kahrl
Why does the server.cpp patch modify the punch action (0) and not the dig action (2)? It makes no sense to me.

PostPosted: Fri Mar 09, 2012 14:19
by randomproof
kahrl wrote:Why does the server.cpp patch modify the punch action (0) and not the dig action (2)? It makes no sense to me.

Your are right. I made the patch origianally and then lost it and had to recreate it and I put it in the wrong place. I have updated the patch.

PostPosted: Tue Mar 20, 2012 23:33
by RAPHAEL
Could someone update this mod for latest dev?

PostPosted: Wed Mar 21, 2012 21:43
by randomproof
The only thing that should need updating is the two diffs. Shouldn't take too long...Done

PostPosted: Thu Mar 22, 2012 03:29
by RAPHAEL
randomproof wrote:The only thing that should need updating is the two diffs. Shouldn't take too long...Done

I have never used patch or diff files but did the following (based on googling) and it failed.

patch builtin.lua diff.diff
patching file builtin.lua
Hunk #1 succeeded at 359 with fuzz 1.
Hunk #2 FAILED at 385.
Hunk #3 FAILED at 436.
Hunk #4 FAILED at 454.
3 out of 4 hunks FAILED -- saving rejects to file builtin.lua.rej

PostPosted: Thu Mar 22, 2012 14:31
by randomproof
Hmmm... not sure why that would happen. I edited a stock builtin.lua file. I'll add a download for the edited files, it is just that it can be a pain to keep them up-to-date.

PostPosted: Thu Mar 22, 2012 16:42
by sfan5
RAPHAEL wrote:
randomproof wrote:The only thing that should need updating is the two diffs. Shouldn't take too long...Done

I have never used patch or diff files but did the following (based on googling) and it failed.

patch builtin.lua diff.diff
patching file builtin.lua
Hunk #1 succeeded at 359 with fuzz 1.
Hunk #2 FAILED at 385.
Hunk #3 FAILED at 436.
Hunk #4 FAILED at 454.
3 out of 4 hunks FAILED -- saving rejects to file builtin.lua.rej

The Patch is outdated

PostPosted: Sat Mar 24, 2012 12:59
by bgsmithjr
I applied the patch by hand, I found all the correct lines, but it didn't function properly afterwards. The game loaded I type in the set_owner command, then list_area's it listed the area then said list_area invalid command and other players could still remove blocks and place them and everything.

PostPosted: Sat Mar 24, 2012 18:39
by randomproof
I'll take a closer look when I get some time.

Edit: Everything seems to be working on my sample server. I did fix a bug with the /list_areas command. I left out the 'return true' that told the server that my mod handled the command so it gave the error with that, but it still worked. It should be noted that players will still see nodes disappear, but, if you installed the server.cpp patch correctly, they should see the node reappear and they should see a chat message that they are not allowed to dig there.

PostPosted: Sun Mar 25, 2012 02:52
by bgsmithjr
Ok, glad to hear it. Do I patch server.cpp before or after compilation?

PostPosted: Sun Mar 25, 2012 14:40
by bgsmithjr
I am experiencing difficulty understanding this... players can only own a straight or diagonal line between two point? A single block line straight up would be 0,0,0 0,100,0 that would be one chat command then, 1,0,0 1,100,0, a single block line straight up next to the previous. I would have to keep doing this over and over again 64 times to own a square area 16x16 that was 100 blocks high. For just the height I would have to issue a command for each block of the wall? That would be very tedious especially considering you would have to have the debug version to get coordinates anyway.
EDIT: I think I understand, if your coordinates are kitty-corner. you would then own the a square, 0,0,0 to 16,16,16 would give 16 blocks left to right front to back ground to roof, but would you own 1,16,1? I got another question would if give you every possible combination 0-16, 0-16, 0-16, or would if you the shortest distance between the two points?
Would the ownership look like this. Does it work like checkers the game or mouse drag selection box?
____ or this ___
/ \ | |
/ \ | |

PostPosted: Sun Mar 25, 2012 16:10
by randomproof
Your right about owning the cube between the two points. The math is some much easier if the spaces are aligned along the grid of the map.

PostPosted: Sun Apr 01, 2012 15:22
by bgsmithjr
Why didn't you just copy the init lua section for what happens when a player without build privileges tries to remove a node. I don't think you need to patch the server.cpp

PostPosted: Mon Apr 02, 2012 13:44
by randomproof
bgsmithjr wrote:Why didn't you just copy the init lua section for what happens when a player without build privileges tries to remove a node. I don't think you need to patch the server.cpp

Because there is no such section unless something had changed in the last few days. I'm in the process of moving and my computers are not set up do I can't check right now. By the way the server.cpp patch was copied from the part that handles players without build privs.

PostPosted: Wed Jun 27, 2012 21:23
by Menche
I tried this on my server. Players can only define areas for themselves, setting for other players doesn't work. The .diff files don't seem to patch properly on the latest version.
EDIT: Mistake, it works fine, and without the patches, seems the other player has to be online. Can it be fixed so you can assign property to players while they're offline?

PostPosted: Thu Jun 28, 2012 05:12
by Menche
Could this be edited and moved to Mod Releases?

PostPosted: Mon Jul 23, 2012 15:27
by thomasP.
what you should do is take the //pos1 and //pos2 thing from worldedit instead of doing a 100,100,100 100,100,100 cuz that can be anoying to do. easier if you can just type //pos1 //pos2 and thats that for setting a region

PostPosted: Wed Aug 01, 2012 12:05
by Ancien
thomasP. wrote:what you should do is take the //pos1 and //pos2 thing from worldedit instead of doing a 100,100,100 100,100,100 cuz that can be anoying to do. easier if you can just type //pos1 //pos2 and thats that for setting a region

+1

PostPosted: Thu Aug 02, 2012 08:46
by cactuz_pl
This mod doesn't protect against spilling lava or water. Is there a way to improve this code and prevent spilling on protected areas?

PostPosted: Fri Aug 03, 2012 22:32
by SegFaulter
For some reason, when I try to remove the owner of an area that I set for that area, nothing happens. I accidentally set the owner of a house in ecube's server, but I meant to set myself as the owner of the city and add owners for each lot.
The lot is in the owner's list as area #3.
Can someone help me get this to work right?

PostPosted: Tue Sep 11, 2012 20:07
by wieszak
Ok, i have two strong suggesttion:
First: optimization:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
function minetest.item_place(itemstack, placer, pointed_thing)
        if itemstack:get_definition().type == "node" then
                local pos = pointed_thing.above

                if HasOwner(pos) then 
-- this is pointless as next function check the exactly same thing: return true when player is owner of area OR there is no owner, so this check here only adds cost.


                        if not IsPlayerNodeOwner(pos, placer:get_player_name()) then
                                minetest.chat_send_player(placer:get_player_name(), "You can not place nodes here.")
                                return itemstack
                        end
                end
                return old_node_place(itemstack, placer, pointed_thing)
        end
       
        return old_node_place(itemstack, placer, pointed_thing)
end



second thing: on redcrab server there was crashes when removing some area, debug tells that is stack overflow related. Therefore i suggest double check in the only recursive function:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
function RemoveTableEntryRe(r_id)
        --Find child entries and remove them
        for n,def in pairs(owner_defs) do
 -- if delete flag is set, so this branch was already visited - you can even issue a error message here - it should not happen
              if def.parent == r_id and not def.delete then
                        def.delete = true
                        RemoveTableEntryRe(def.id)
                end
        end
        -- now remove main entry
        for n,def in pairs(owner_defs) do
                if def.id == r_id then
                        table.remove(owner_defs, n)
                        break
                end
        end
end

function RemoveTableEntry(r_id)
        -- initialize 'guardians'
         for n,def in pairs(owner_defs) do
                def.delete = false
          end

        RemoveTableEntryRe(r_id)
       
        --Re-number ids to match place in table
        for n,ndef in pairs(owner_defs) do
                if ndef.id ~= n then
                        for p,pdef in pairs(owner_defs) do
                                if pdef.parent == ndef.id then
                                        pdef.parent = n
                                end
                        end
                        ndef.id = n
                end
        end
       
        table_save( owner_defs, owners_db_filename )
end


PostPosted: Tue Sep 18, 2012 00:07
by joker333
im canfused as to how to set an area like how can u make it where it sests it to a sertent depth an hight in the sky plus the with in every direction???
if that makes any seens

PostPosted: Thu Sep 20, 2012 13:15
by redcrab
After big issues with this mod when you try to "/remove_areas" but with a too large protected area list (lua stackoverflow error, with server crash and often sqlite map corrupted afterward)...

I 've updated the lua code to place a fix ... it works so far ...

original code
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
function RemoveTableEntryRe(r_id)
    --Find child entries and remove them
    for n,def in pairs(owner_defs) do
        if def.parent == r_id then
            RemoveTableEntryRe(def.id)
        end
    end
    -- now remove main entry
    for n,def in pairs(owner_defs) do
        if def.id == r_id then
            table.remove(owner_defs, n)
            break
        end
    end
end

function RemoveTableEntry(r_id)
    RemoveTableEntryRe(r_id)
    --Re-number ids to match place in table
    for n,ndef in pairs(owner_defs) do
        if ndef.id ~= n then
            for p,pdef in pairs(owner_defs) do
                if pdef.parent == ndef.id then
                    pdef.parent = n
                end
            end
            ndef.id = n
        end
    end
    table_save( owner_defs, owners_db_filename )
end


replaced by
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
function RemoveTableEntry(r_id)
    --Find child entries and remove them
    local nomorechild = true
    repeat
        nomorechild = true
        for n,def in pairs(owner_defs) do
            if def.parent == r_id then
                table.remove(owner_defs, n) --RemoveTableEntryRe(def.id)
                nomorechild = false
                break
            end
        end
    until nomorechild
    -- now remove main entry
    for n,def in pairs(owner_defs) do
        if def.id == r_id then
            table.remove(owner_defs, n)
            break
        end
    end
    --Re-number ids to match place in table
    for n,ndef in pairs(owner_defs) do
        if ndef.id ~= n then
            for p,pdef in pairs(owner_defs) do
                if pdef.parent == ndef.id then
                    pdef.parent = n
                end
            end
            ndef.id = n
        end
    end
     table_save( owner_defs, owners_db_filename )
end


PostPosted: Fri Sep 21, 2012 18:01
by wieszak
This is wrong - it will not delete area which has area which has area. If you want make it by iterations not recursive, you should not delete entries, but mark them to be deleted, then for all marked entries check again if they have childs and mark them if find, and repeat it until no more childs found, then delete all marked entries.

PostPosted: Wed Sep 26, 2012 01:29
by mike
I did some change to the code:

1. added redcrabs fix
2. figured out, that the changes of the core minetest application are already built into. so diff files can be dropped.
3. locked the whole world, so noone can dig/place everywhere without concession
4. added a sandbox user. if you grant the sandbox user an area, everyone with interact can edit this.
you can also give subconcessions to the sandbox user if you are a concessionaire of an area.
for example you want to have a trading/play place in your home.
5. added a griefing priv, so players with "griefing" priv set can dig/place everywhere on the map
6. added coords and grantor/concessionaire output on blocked action.

planned:
- fix redcrabs recursion problem (if it exists) or add an depth lock for childs to just one level of childs.
- cleanup code and put hardcoded stuff into statics at top of the file

maybe:
- add a gui

offtopic: added a priv "creative" to the creative inventory, so only these players get the creative inventory.

i will release the code here soon.
if someone wants to work on this mod it would be nice to cooperate.