[Mod] Node ownership [node_ownership]

randomproof
Member
 
Posts: 214
Joined: Thu Nov 17, 2011 06:31

by randomproof » Thu Mar 01, 2012 04:00

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.
 

randomproof
Member
 
Posts: 214
Joined: Thu Nov 17, 2011 06:31

by randomproof » Thu Mar 01, 2012 15:56

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.
Last edited by randomproof on Thu Mar 01, 2012 16:04, edited 1 time in total.
 

randomproof
Member
 
Posts: 214
Joined: Thu Nov 17, 2011 06:31

by randomproof » Thu Mar 01, 2012 16:12

OK, I updated the extra diffs to the first post.
 

Temperest
Member
 
Posts: 651
Joined: Tue Nov 15, 2011 23:13
GitHub: Uberi

by Temperest » Fri Mar 02, 2012 22:10

Just to be clear, does this mod work without the patches to builtin.lua and server.cpp?
WorldEdit 1.0 released

The Mesecons Laboratory - the art of Mesecons circuitry
Latest article: Mesecons Basics.
 

randomproof
Member
 
Posts: 214
Joined: Thu Nov 17, 2011 06:31

by randomproof » Fri Mar 02, 2012 22:29

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.
Last edited by randomproof on Fri Mar 02, 2012 23:21, edited 1 time in total.
 

kahrl
Member
 
Posts: 236
Joined: Fri Sep 02, 2011 07:51

by kahrl » Fri Mar 09, 2012 01:59

Why does the server.cpp patch modify the punch action (0) and not the dig action (2)? It makes no sense to me.
 

randomproof
Member
 
Posts: 214
Joined: Thu Nov 17, 2011 06:31

by randomproof » Fri Mar 09, 2012 14:19

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.
Last edited by randomproof on Fri Mar 09, 2012 16:36, edited 1 time in total.
 

User avatar
RAPHAEL
Member
 
Posts: 627
Joined: Tue Nov 01, 2011 09:09

by RAPHAEL » Tue Mar 20, 2012 23:33

Could someone update this mod for latest dev?
"Before you speak, ask yourself: Is it kind, is it true, is it necessary, does it improve upon the silence?"
My mods: http://goo.gl/n4kpn
(Currently Various, Industrial, Fakeblocks, Jail, MoarCraft, Christmas, Replicator, minetest dev installer for linux, bash mod installer, windows mod installer)
 

randomproof
Member
 
Posts: 214
Joined: Thu Nov 17, 2011 06:31

by randomproof » Wed Mar 21, 2012 21:43

The only thing that should need updating is the two diffs. Shouldn't take too long...Done
Last edited by randomproof on Wed Mar 21, 2012 21:58, edited 1 time in total.
 

User avatar
RAPHAEL
Member
 
Posts: 627
Joined: Tue Nov 01, 2011 09:09

by RAPHAEL » Thu Mar 22, 2012 03:29

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
"Before you speak, ask yourself: Is it kind, is it true, is it necessary, does it improve upon the silence?"
My mods: http://goo.gl/n4kpn
(Currently Various, Industrial, Fakeblocks, Jail, MoarCraft, Christmas, Replicator, minetest dev installer for linux, bash mod installer, windows mod installer)
 

randomproof
Member
 
Posts: 214
Joined: Thu Nov 17, 2011 06:31

by randomproof » Thu Mar 22, 2012 14:31

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.
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Thu Mar 22, 2012 16:42

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
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

User avatar
bgsmithjr
Member
 
Posts: 436
Joined: Thu Mar 08, 2012 23:21

by bgsmithjr » Sat Mar 24, 2012 12:59

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.
 

randomproof
Member
 
Posts: 214
Joined: Thu Nov 17, 2011 06:31

by randomproof » Sat Mar 24, 2012 18:39

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.
Last edited by randomproof on Sun Mar 25, 2012 01:02, edited 1 time in total.
 

User avatar
bgsmithjr
Member
 
Posts: 436
Joined: Thu Mar 08, 2012 23:21

by bgsmithjr » Sun Mar 25, 2012 02:52

Ok, glad to hear it. Do I patch server.cpp before or after compilation?
 

User avatar
bgsmithjr
Member
 
Posts: 436
Joined: Thu Mar 08, 2012 23:21

by bgsmithjr » Sun Mar 25, 2012 14:40

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 ___
/ \ | |
/ \ | |
Last edited by bgsmithjr on Sun Mar 25, 2012 14:57, edited 1 time in total.
 

randomproof
Member
 
Posts: 214
Joined: Thu Nov 17, 2011 06:31

by randomproof » Sun Mar 25, 2012 16:10

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.
 

User avatar
bgsmithjr
Member
 
Posts: 436
Joined: Thu Mar 08, 2012 23:21

by bgsmithjr » Sun Apr 01, 2012 15:22

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
 

randomproof
Member
 
Posts: 214
Joined: Thu Nov 17, 2011 06:31

by randomproof » Mon Apr 02, 2012 13:44

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.
 

User avatar
Menche
Member
 
Posts: 994
Joined: Sat Jul 02, 2011 00:43

by Menche » Wed Jun 27, 2012 21:23

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?
Last edited by Menche on Thu Jun 28, 2012 05:03, edited 1 time in total.
An innocent kitten dies every time you top-post.
I am on the Voxelands Forums more often than here.
Try Voxelands (forked from Minetest 0.3) by darkrose
 

User avatar
Menche
Member
 
Posts: 994
Joined: Sat Jul 02, 2011 00:43

by Menche » Thu Jun 28, 2012 05:12

Could this be edited and moved to Mod Releases?
An innocent kitten dies every time you top-post.
I am on the Voxelands Forums more often than here.
Try Voxelands (forked from Minetest 0.3) by darkrose
 

thomasP.
Member
 
Posts: 25
Joined: Mon May 14, 2012 21:05

by thomasP. » Mon Jul 23, 2012 15:27

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
ingame i am noob
 

Ancien
Member
 
Posts: 21
Joined: Fri Jul 06, 2012 09:05

by Ancien » Wed Aug 01, 2012 12:05

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
 

User avatar
cactuz_pl
Member
 
Posts: 874
Joined: Tue Jun 05, 2012 16:34

by cactuz_pl » Thu Aug 02, 2012 08:46

This mod doesn't protect against spilling lava or water. Is there a way to improve this code and prevent spilling on protected areas?
Nope
 

SegFaulter
 

by SegFaulter » Fri Aug 03, 2012 22:32

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?
 

wieszak
Member
 
Posts: 40
Joined: Mon Feb 20, 2012 17:00

by wieszak » Tue Sep 11, 2012 20:07

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

Last edited by wieszak on Tue Sep 11, 2012 20:08, edited 1 time in total.
 

joker333
Member
 
Posts: 13
Joined: Sat Sep 15, 2012 22:10

by joker333 » Tue Sep 18, 2012 00:07

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
 

User avatar
redcrab
Member
 
Posts: 831
Joined: Tue Dec 13, 2011 13:45

by redcrab » Thu Sep 20, 2012 13:15

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

Last edited by redcrab on Thu Sep 20, 2012 13:18, edited 1 time in total.
0.4 for serious builder click here
Dedicated Minetest redcrab server forum at http://minetestbb.suret.net

It's nice to be important but it is more important to be nice.
 

wieszak
Member
 
Posts: 40
Joined: Mon Feb 20, 2012 17:00

by wieszak » Fri Sep 21, 2012 18:01

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.
 

mike
Member
 
Posts: 45
Joined: Wed Sep 26, 2012 01:15

by mike » Wed Sep 26, 2012 01:29

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.
Last edited by mike on Wed Sep 26, 2012 01:33, edited 1 time in total.
 

PreviousNext

Return to Old Mods

Who is online

Users browsing this forum: No registered users and 1 guest

cron